rsanchez
2017-03-21 a6e1ace2b6bdba8c08a4acfa42433f3ac073b747
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import { Router, ActivatedRoute } from '@angular/router';
import { MdDialog, MdDialogConfig } from '@angular/material';
import {
    ITdDataTableColumn,
    ITdDataTableSortChangeEvent,
    TdDataTableService,
    TdDataTableSortingOrder,
    TdPagingBarComponent
} from '@covalent/core';
import { IPageChangeEvent } from '@covalent/core';
import { Component, ViewChild, AfterViewInit } from '@angular/core';
import { TdMediaService } from '@covalent/core';
import { ApplicationsService } from '../resources/applications';
import { PackFormComponent } from '../forms/pack.form.component';
import { LocaleService } from '../common/i18n';
import { ListingBase } from './base';
var app_example = { 
   code: 'CICS',
  creation_timestamp: 1418384439000,
  description: 'Wellbore integrity analysis software',
  id: 1,
  license_filename: 'config_server.lic',
  name: 'CurisIntegrity',
  metadata: 
   [ { key: 'max_docs',
       value: '250000',
       readonly: true,
       mandatory: true } ] 
}
@Component({
  selector: 'application-list',
  templateUrl: 'src/app/listing/application.list.component.html'
})
export class ApplicationListComponent extends ListingBase implements AfterViewInit {
  columns: ITdDataTableColumn[] = [
    { name: 'code', label: 'Code', tooltip: 'Application code' },
    { name: 'name', label: 'Application name' },
    { name: 'creation_timestamp', label: 'Creation date' },
    { name: 'menu', label: '' }
  ];
  pack_menu_options : any[] = [{
    command: 'edit',
    name: 'Edit'
  },{
    command: 'cancel',
    name: 'Cancel'
  }]
  
  constructor(_dataTableService: TdDataTableService,
    private media: TdMediaService,
    private router: Router,
    private $L: LocaleService,
    private applicationForm: PackFormComponent,
    private applications: ApplicationsService) {
      super(_dataTableService);
      this.applications.get().subscribe(
        (list : any[]) => {
          this.data = list;
          this.refresh();
        },
        (err: any) => console.error(err)
      );
  }
  packAction(action: any) {
    console.log(action.command);
  }
  isActionAvailable(pack : any) : boolean {
    return true;
  }
  create() : void {
    this.router.navigate(['applications/create']);
  }
  edit(appId: number | string) : void {
    this.router.navigate([`applications/edit/${appId}`]);
  }
}