From 2762277c60db7df5ad3214b10a0dd93d4f2f1128 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Fri, 10 Mar 2017 08:53:44 +0000
Subject: [PATCH] #3527 feature - Added more features to angular2 version
---
securis/src/main/webapp/src/app/pack.list.component.ts | 166 +++++++++++++++++++++++++++++++++---------------------
1 files changed, 101 insertions(+), 65 deletions(-)
diff --git a/securis/src/main/webapp/src/app/pack.list.component.ts b/securis/src/main/webapp/src/app/pack.list.component.ts
index 2355901..8b883a0 100644
--- a/securis/src/main/webapp/src/app/pack.list.component.ts
+++ b/securis/src/main/webapp/src/app/pack.list.component.ts
@@ -1,83 +1,119 @@
-import { Hero } from './hero';
+import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core';
+import { IPageChangeEvent } from '@covalent/core';
import { Component, AfterViewInit } from '@angular/core';
import { TdMediaService } from '@covalent/core';
+import { PacksService } from './resources/packs';
-
-const HEROES: Hero[] = [
- { id: 11, name: 'Mr. Nice' },
- { id: 12, name: 'Narco' },
- { id: 13, name: 'Bombasto' },
- { id: 14, name: 'Celeritas' },
- { id: 15, name: 'Magneta' },
- { id: 16, name: 'RubberMan' },
- { id: 17, name: 'Dynama' },
- { id: 18, name: 'Dr IQ' },
- { id: 19, name: 'Magma' },
- { id: 20, name: 'Tornado' }
-];
+var pack_example = {
+ id: 7,
+ code: 'DX250000',
+ status: 'AC',
+ application_name: 'Doxr',
+ created_by_id: 'admin',
+ created_by_name: 'Administrator (admin)',
+ creation_timestamp: 1440597540000,
+ end_valid_date: 2051222400000,
+ init_valid_date: 1440547200000,
+ license_preactivation: true,
+ license_type_id: 5,
+ licensetype_code: 'DXL3',
+ metadata:
+ [ { key: 'max_docs',
+ value: '250000',
+ readonly: true,
+ mandatory: true,
+ pack_id: 7 } ],
+ num_activations: 7,
+ num_available: -2,
+ num_creations: 7,
+ num_licenses: 5,
+ organization_id: 2,
+ organization_name: 'CurisTec',
+ preactivation_valid_period: 70,
+ renew_valid_period: 0,
+}
@Component({
selector: 'pack-list',
templateUrl: 'src/app/pack.list.component.html'
})
-
- /*`
- <h2>My Heroes</h2>
- <ul class="heroes">
- <li *ngFor="let hero of heroes"
- [class.selected]="hero === selectedHero"
- (click)="onSelect(hero)">
- <span class="badge">{{hero.id}}</span> {{hero.name}}
- </li>
- </ul>
-<div *ngIf="selectedHero">
- <my-hero-detail [hero]="selectedHero"></my-hero-detail>
-</div>
-
- `*/
-
export class PackListComponent implements AfterViewInit {
- routes: Object[] = [
- {
- title: 'Dashboard',
- route: '/',
- icon: 'dashboard',
- }, {
- title: 'Product Dashboard',
- route: '/',
- icon: 'view_quilt',
- }, {
- title: 'Product Logs',
- route: '/',
- icon: 'receipt',
- }, {
- title: 'Manage Users',
- route: '/',
- icon: 'people',
- }, {
- title: 'Covalent Templates',
- route: '/',
- icon: 'view_module',
- },
- ];
+ data: any[] = [];
+ columns: ITdDataTableColumn[] = [
+ { name: 'code', label: 'Code', tooltip: 'License pack code' },
+ { name: 'application_name', label: 'App name' },
+ { name: 'licensetype_code', label: 'License type' },
+ { name: 'organization_name', label: 'Organization' },
+ { name: 'num_licenses', label: 'Lic', numeric: true, tooltip: 'Initial pack licenses' },
+ { name: 'num_available', label: 'Ava', numeric: true, tooltip: 'Available licenses' },
+ ];
- title = 'Tour of Heroes';
- heroes = HEROES;
- selectedHero: Hero;
- hero: Hero = {
- id: 1,
- name: 'Windstorm'
- };
+ filteredData: any[] = this.data;
+ filteredTotal: number = this.data.length;
- constructor(public media: TdMediaService) {
-
+ searchTerm: string = '';
+ fromRow: number = 1;
+ currentPage: number = 1;
+ pageSize: number = 10;
+ sortBy: string = 'application_name';
+ sortOrder: TdDataTableSortingOrder = TdDataTableSortingOrder.Descending;
+ filteredItems = this.data.length;
+
+ constructor(private _dataTableService: TdDataTableService,
+ private media: TdMediaService,
+ private packs: PacksService) {
+ this.packs.get().subscribe(
+ list => {
+ this.data = list;
+ this.filter();
+ },
+ err => console.error(err)
+ );
}
- onSelect(hero: Hero): void {
- this.selectedHero = hero;
+ ngOnInit(): void {
+ this.filter();
+ }
+
+ createPack() : void {
+
+ }
+
+ sort(sortEvent: ITdDataTableSortChangeEvent): void {
+ this.sortBy = sortEvent.name;
+ this.sortOrder = sortEvent.order;
+ this.filter();
+ }
+
+ search(searchTerm: string): void {
+ this.searchTerm = searchTerm;
+ this.filter();
+ }
+
+ page(pagingEvent: IPageChangeEvent): void {
+ this.fromRow = pagingEvent.fromRow;
+ this.currentPage = pagingEvent.page;
+ this.pageSize = pagingEvent.pageSize;
+ this.filter();
+ }
+
+ loadData() {
+
+ }
+
+ filter(): void {
+ let newData: any[] = this.data;
+ newData = this._dataTableService.filterData(newData, this.searchTerm, true);
+ this.filteredTotal = newData.length;
+ this.filteredItems = newData.length;
+ newData = this._dataTableService.sortData(newData, this.sortBy, this.sortOrder);
+ newData = this._dataTableService.pageData(newData, this.fromRow, this.currentPage * this.pageSize);
+ this.filteredData = newData;
}
ngAfterViewInit(): void {
- this.media.broadcast();
+ this.media.broadcast();
+
}
}
+
--
Gitblit v1.3.2