<commit_before>import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { ActivatedRoute, ParamMap } from '@angular/router';
import { Observable } from 'rxjs/Rx';
import { GridOptions } from 'ag-grid/main';
import * as Autolinker from 'autolinker';
import * as moment from 'moment';
import Moment = moment.Moment;

import { GridHeaderComponent } from '../../shared/grid-header/grid-header.component';
import { Repository, Manifest } from '../repository.model';
import { RepositoryService } from '../repository.service';

@Component({
  selector: 'app-manifest-list',
  templateUrl: './manifest-list.component.html',
  styleUrls: ['./manifest-list.component.scss']
})
export class ManifestListComponent implements OnInit {
  gridOptions: GridOptions;
  columnDefs: any[];
  repository: Repository;
  manifests: Manifest[];
  selectedManifest: Manifest;
  tableWidth: number;
  tableHeight: number;

  constructor(private repositoryService: RepositoryService, private route: ActivatedRoute) {
    this.gridOptions = <GridOptions>{};
    this.gridOptions.defaultColDef = {
      headerComponentFramework: <{ new(): GridHeaderComponent }>GridHeaderComponent,
      headerComponentParams: {
        menuIcon: 'fa-bars'
      }
    };

    this.columnDefs = [
      { headerName: 'Tag', field: 'tag', headerComponentParams: { menuIcon: 'fa fa-qrcode' } },
      {
        headerName: 'Image ID', field: 'metadata.id', valueFormatter: this.idFormatter,
        headerComponentParams: { menuIcon: 'fa fa-qrcode' }
      },
      {
        headerName: 'Created', field: 'metadata.created', valueFormatter: this.dateFormatter,
        headerComponentParams: { menuIcon: 'fa fa-calendar' }
      },
      {
        headerName: 'Author', field: 'metadata.author', valueFormatter: this.authorFormatter,
        headerComponentParams: { menuIcon: 'fa fa-user' }
      },
      { headerName: 'Docker Version', field: 'metadata.docker_version', headerComponentParams: { menuIcon: 'fa fa-ship' } },
      { headerName: 'OS', field: 'metadata.os', headerComponentParams: { menuIcon: 'fa fa-laptop' } }
    ];
  }

  ngOnInit(): void {
    this.route.paramMap
      .switchMap((params: ParamMap) => this.repositoryService.tags({ name: params.get('namespace') + '/' + params.get('name') }))
      .subscribe(repository => {
        this.repository = repository;
        const observables: Observable<Manifest>[] = [];
        repository.tags.forEach(tag => {
          observables.push(this.repositoryService.manifest({ name: repository.name, tag: tag }));
        });
        Observable.forkJoin(observables).subscribe(manifests => {
          this.manifests = manifests;

          this.tableHeight = Math.min(30 * manifests.length + 50, 400);
          this.tableWidth = 1200;
          this.gridOptions.api.doLayout();
        });
      });
  }

  onGridReady(params) {
    params.api.sizeColumnsToFit();
  }

  onSelectionChanged(event) {
    this.selectedManifest = event.api.getSelectedRows()[0];
  }

  authorFormatter(params) {
    return Autolinker.link(params.value);
  }

  dateFormatter(params) {
    console.log(params);
    return moment(params.value).fromNow();
  }

  idFormatter(params) {
    return params.value.substring(0, 12);
  }
}<commit_msg>remove id column<commit_after>import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { ActivatedRoute, ParamMap } from '@angular/router';
import { Observable } from 'rxjs/Rx';
import { GridOptions } from 'ag-grid/main';
import * as Autolinker from 'autolinker';
import * as moment from 'moment';
import Moment = moment.Moment;

import { GridHeaderComponent } from '../../shared/grid-header/grid-header.component';
import { Repository, Manifest } from '../repository.model';
import { RepositoryService } from '../repository.service';

@Component({
  selector: 'app-manifest-list',
  templateUrl: './manifest-list.component.html',
  styleUrls: ['./manifest-list.component.scss']
})
export class ManifestListComponent implements OnInit {
  gridOptions: GridOptions;
  columnDefs: any[];
  repository: Repository;
  manifests: Manifest[];
  selectedManifest: Manifest;
  tableWidth: number;
  tableHeight: number;

  constructor(private repositoryService: RepositoryService, private route: ActivatedRoute) {
    this.gridOptions = <GridOptions>{};
    this.gridOptions.defaultColDef = {
      headerComponentFramework: <{ new(): GridHeaderComponent }>GridHeaderComponent,
      headerComponentParams: {
        menuIcon: 'fa-bars'
      }
    };

    this.columnDefs = [
      { headerName: 'Tag', field: 'tag', headerComponentParams: { menuIcon: 'fa fa-qrcode' } },
      {
        headerName: 'Created', field: 'metadata.created', valueFormatter: this.dateFormatter,
        headerComponentParams: { menuIcon: 'fa fa-calendar' }
      },
      {
        headerName: 'Author', field: 'metadata.author', valueFormatter: this.authorFormatter,
        headerComponentParams: { menuIcon: 'fa fa-user' }
      },
      { headerName: 'Docker Version', field: 'metadata.docker_version', headerComponentParams: { menuIcon: 'fa fa-ship' } },
      { headerName: 'OS', field: 'metadata.os', headerComponentParams: { menuIcon: 'fa fa-laptop' } }
    ];
  }

  ngOnInit(): void {
    this.route.paramMap
      .switchMap((params: ParamMap) => this.repositoryService.tags({ name: params.get('namespace') + '/' + params.get('name') }))
      .subscribe(repository => {
        this.repository = repository;
        const observables: Observable<Manifest>[] = [];
        repository.tags.forEach(tag => {
          observables.push(this.repositoryService.manifest({ name: repository.name, tag: tag }));
        });
        Observable.forkJoin(observables).subscribe(manifests => {
          this.manifests = manifests;

          this.tableHeight = Math.min(30 * manifests.length + 50, 400);
          this.tableWidth = 1200;
          this.gridOptions.api.doLayout();
        });
      });
  }

  onGridReady(params) {
    params.api.sizeColumnsToFit();
  }

  onSelectionChanged(event) {
    this.selectedManifest = event.api.getSelectedRows()[0];
  }

  authorFormatter(params) {
    return Autolinker.link(params.value);
  }

  dateFormatter(params) {
    return moment(params.value).fromNow();
  }
}
{'fraction_non_alphanumeric': 0.14108674928503337, 'fraction_numerical': 0.004289799809342231, 'mean_word_length': 3.5157819225251075, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6078015', 'n_tokens_mistral': 1869, 'n_tokens_neox': 1815, 'n_words': 374}