rsanchez
2017-03-10 6078e6018ca05bcc0203241dc44071a59cf5e78c
#3527 fix - Customizing packs listing
8 files modified
changed files
securis/src/main/webapp/assets/securis.css patch | view | blame | history
securis/src/main/webapp/src/app/forms/pack.form.1.html patch | view | blame | history
securis/src/main/webapp/src/app/forms/pack.form.component.ts patch | view | blame | history
securis/src/main/webapp/src/app/forms/pack.form.html patch | view | blame | history
securis/src/main/webapp/src/app/login.form.component.ts patch | view | blame | history
securis/src/main/webapp/src/app/pack.list.component.html patch | view | blame | history
securis/src/main/webapp/src/app/pack.list.component.ts patch | view | blame | history
securis/src/main/webapp/src/app/user.service.ts patch | view | blame | history
securis/src/main/webapp/assets/securis.css
....@@ -23,4 +23,9 @@
2323
2424 td-layout-footer {
2525 font-size: 0.8em;
26
+}
27
+
28
+.td-data-table-row > .td-data-table-cell:first-child,
29
+.td-data-table-row > .td-data-table-column:first-child {
30
+ max-width: 30px !important;
2631 }
securis/src/main/webapp/src/app/forms/pack.form.1.html
....@@ -1,5 +1,5 @@
11 <h3 md-dialog-title>{{form_title}}</h3>
2
-<form #packForm="ngForm" class="inset" (keyup.enter)="save()">
2
+<form #packForm="ngForm" (keyup.enter)="save()">
33 <md-dialog-content>
44 <div layout="column" layout-align="start center">
55 <div layout="row" layout-align="start center" layout-margin>
securis/src/main/webapp/src/app/forms/pack.form.component.ts
....@@ -30,22 +30,26 @@
3030 this.http.get('organization')
3131 .map(response => response.json().map((org : any) => <IComboOption>{id: org.id, label: `(${org.code}) ${org.name}`}))
3232 .subscribe(
33
- data => this.organizations = data,
33
+ data => this.organizations = (<IComboOption[]>data).sort((e1, e2) => e1.label.localeCompare(e2.label)),
3434 err => console.error('Error loading orgs')
3535 );
3636 this.http.get('licensetype')
3737 .map(response => response.json().map((lt : any) => <IComboOption>{id: lt.id, label: `(${lt.code}) ${lt.name}`}))
3838 .subscribe(
39
- data => this.licensetypes = data,
40
- err => console.error('Error loading orgs')
39
+ data => this.licensetypes = (<IComboOption[]>data).sort((e1, e2) => e1.label.localeCompare(e2.label)),
40
+ err => console.error('Error loading license types')
4141 );
4242 }
4343
44
-
44
+ log(obj: any) {
45
+ console.log(obj)
46
+ }
47
+
4548 ngOnInit(): void {
4649 this.loadCombos();
4750 this.data = {};
4851 this.form_title = this.$L.get('Pack data');
52
+ this.form_subtitle = this.$L.get('Create a new licenses pack');
4953 }
5054
5155
securis/src/main/webapp/src/app/forms/pack.form.html
....@@ -8,49 +8,58 @@
88 </md-card-subtitle>
99 <md-divider></md-divider>
1010 <md-card-content>
11
- <div layout="column" layout-align="start center">
12
- <div layout="row" layout-align="start center" layout-margin>
13
- <md-input-container flex>
11
+ <div layout="column" layout-align="start center" layout-fill>
12
+ <div layout="row" layout-fill layout-padding>
13
+ <div layout="column" layout-fill flex="50">
14
+ <md-input-container>
1415 <input mdInput maxLength="50" type="text" [(ngModel)]="data.code" name="code" required />
1516 <md-placeholder>
1617 <span i18n>Code</span>
1718 </md-placeholder>
1819 </md-input-container>
20
+ {{log(packForm.controls)}}
21
+ <div *ngIf="packForm.controls.code?.touched && packForm.controls.code.invalid" layout="column">
22
+ <span *ngIf="packForm.controls.code.errors.required" align="end">Code is required</span>
23
+ <span align="end">Code is ok</span>
24
+ </div>
25
+ </div>
1926 <!-- TODO: <div class="alert inline-alert alert-warning" ng-show="packForm.code.$invalid">
2027 <span class="glyphicon glyphicon-warning-sign"></span>
2128 <span ng-show="packForm.code.$error.maxlength" ng-bind="maxLengthErrorMsg('Code', maxlength.code)"
2229 class="ng-binding ng-hide">Code length is too long (max: 50).</span>
2330 <span ng-show="packForm.code.$error.required" ng-bind="mandatoryFieldErrorMsg('Code')" class="ng-binding">'Code' is required.</span>
2431 </div> -->
25
- <md-input-container flex>
32
+ <md-input-container flex="50">
2633 <input mdInput type="number" type="text" [(ngModel)]="data.num_licenses" name="num_licenses" required />
2734 <md-placeholder>
2835 <span i18n>Num. licenses</span>
2936 </md-placeholder>
3037 </md-input-container>
3138 </div>
32
- <div layout="row" layout-align="start center" layout-margin>
39
+ <div layout="row" layout-align="start center" layout-fill layout-padding>
3340 <md-input-container flex>
3441 <input mdInput type="date" type="text" [(ngModel)]="data.init_valid_date" name="init_valid_date" required />
3542 <md-placeholder>
3643 <span i18n>Initial date</span>
3744 </md-placeholder>
45
+ <md-hint align="end">YYYY-MM-DD</md-hint>
3846 </md-input-container>
3947 <md-input-container flex>
4048 <input mdInput type="date" type="text" [(ngModel)]="data.end_valid_date" name="end_valid_date" required />
4149 <md-placeholder>
4250 <span i18n>End date</span>
4351 </md-placeholder>
52
+ <md-hint align="end">YYYY-MM-DD</md-hint>
4453 </md-input-container>
4554 </div>
46
- <div layout="row" layout-align="start center" layout-margin>
55
+ <div layout="row" layout-fill layout-padding>
4756 <md-select flex placeholder="Organization" [(ngModel)]="data.organization_id" name="organization_id">
4857 <md-option *ngFor="let org of organizations" [value]="org.id">
4958 {{org.label}}
5059 </md-option>
5160 </md-select>
5261 <md-select flex placeholder="License type" [(ngModel)]="data.license_type_id" name="license_type_id">
53
- <md-option *ngFor="let lt of lictypes" [value]="lt.id">
62
+ <md-option *ngFor="let lt of licensetypes" [value]="lt.id">
5463 {{lt.label}}
5564 </md-option>
5665 </md-select>
....@@ -60,7 +69,7 @@
6069 <md-divider></md-divider>
6170 <md-card-actions>
6271 <button [disabled]="!packForm.form.valid" md-raised-button color="primary" (click)="save()">Save</button>
63
- <button md-button (click)="close()">Cancel</button>
72
+ <button md-button md-dialog-close>Cancel</button>
6473 </md-card-actions>
6574 </md-card>
6675 </form>
securis/src/main/webapp/src/app/login.form.component.ts
....@@ -25,7 +25,9 @@
2525
2626 public login() {
2727 this.userService.login(this.data.username, this.data.password).subscribe(
28
- token => this.router.navigateByUrl("packs"),
28
+ token => {
29
+ this.router.navigateByUrl("packs");
30
+ },
2931 errMsg => this.toaster.error(errMsg, 'Login error'));
3032 }
3133
securis/src/main/webapp/src/app/pack.list.component.html
....@@ -1,26 +1,38 @@
11 <md-toolbar role="toolbar" class="mat-secondary">
2
- <span class="push-left-sm">
2
+ <span class="push-left-sm">
33 <span class="md-title" i18n>License Packs</span>
4
- </span>
5
- <span class="push-left-sm" *ngIf="filteredItems < data.length">
4
+ </span>
5
+ <span class="push-left-sm" *ngIf="filteredItems < data.length">
66 <span class="md-body-1">{{filteredItems}} of {{data.length}} packs filtered</span>
7
- </span>
8
- <td-search-box #searchBox class="push-right-sm" placeholder="Search here" (searchDebounce)="search($event)" flex>
9
- </td-search-box>
10
- <button md-mini-fab color="accent" (click)="createPack()">
7
+ </span>
8
+ <td-search-box #searchBox class="push-right-sm" placeholder="Search here" (searchDebounce)="search($event)" flex>
9
+ </td-search-box>
10
+ <button md-mini-fab color="accent" (click)="createPack()">
1111 <md-icon>add</md-icon>
1212 </button>
1313 </md-toolbar>
1414 <md-divider></md-divider>
15
-<td-data-table
16
- [data]="filteredData"
17
- [columns]="columns"
18
- [sortable]="true"
19
- [sortBy]="sortBy"
20
- [sortOrder]="sortOrder"
21
- (sortChange)="sort($event)">
15
+<td-data-table [data]="filteredData" [columns]="columns">
16
+
17
+ <template tdDataTableTemplate="used_licenses" let-row="row">
18
+ <div layout="row">
19
+ <td-notification-count color="secondary" [notifications]="row['num_licenses']">
20
+ </td-notification-count>
21
+ <td-notification-count color="green" [notifications]="row['num_available']">
22
+ </td-notification-count>
23
+ </div>
24
+ </template>
25
+ <template tdDataTableTemplate="lics" let-row="row">
26
+ <button md-icon-button color="primary"><md-icon>arrow_right</md-icon></button>
27
+ </template>
28
+ <template tdDataTableTemplate="menu" let-row="row">
29
+ <div layout="row">
30
+ <button md-icon-button color="primary"><md-icon>arrow_right</md-icon></button>
31
+ <button md-icon-button><md-icon>edit</md-icon></button>
32
+ <button md-icon-button><md-icon>more_vert</md-icon></button>
33
+ </div>
34
+ </template>
2235 </td-data-table>
2336 <td-paging-bar #pagingBar [pageSizes]="[10, 20, 40]" [total]="filteredTotal" (change)="page($event)">
24
- <span td-paging-bar-label hide-xs>Rows per page:</span>
25
- {{pagingBar.range}} <span hide-xs>of {{pagingBar.total}}</span>
26
-</td-paging-bar>
37
+ <span td-paging-bar-label hide-xs>Rows per page:</span> {{pagingBar.range}} <span hide-xs>of {{pagingBar.total}}</span>
38
+</td-paging-bar>
securis/src/main/webapp/src/app/pack.list.component.ts
....@@ -42,12 +42,13 @@
4242 export class PackListComponent implements AfterViewInit {
4343 data: any[] = [];
4444 columns: ITdDataTableColumn[] = [
45
+ { name: 'lics', label: '' },
4546 { name: 'code', label: 'Code', tooltip: 'License pack code' },
4647 { name: 'application_name', label: 'App name' },
4748 { name: 'licensetype_code', label: 'License type' },
4849 { name: 'organization_name', label: 'Organization' },
49
- { name: 'num_licenses', label: 'Lic', numeric: true, tooltip: 'Initial pack licenses' },
50
- { name: 'num_available', label: 'Ava', numeric: true, tooltip: 'Available licenses' },
50
+ { name: 'used_licenses', label: 'Lics', tooltip: 'Initial/Available pack licenses' },
51
+ { name: 'menu', label: '' }
5152 ];
5253
5354 filteredData: any[] = this.data;
....@@ -80,12 +81,31 @@
8081 }
8182
8283 createPack() : void {
83
- this.dialog.open(PackFormComponent, {
84
+ var ref = this.dialog.open(PackFormComponent, {
8485 height: '50%', // can be px or %
8586 width: '40%', // can be px or %
8687 });
88
+ ref.componentInstance.isNew = true;
89
+ ref.afterClosed().subscribe(result => {
90
+ console.log(result);
91
+ this.filter();
92
+ });
8793 }
8894
95
+ editPack(pack: any) : void {
96
+ var ref = this.dialog.open(PackFormComponent, {
97
+ height: '50%', // can be px or %
98
+ width: '40%', // can be px or %
99
+ });
100
+ ref.componentInstance.isNew = false;
101
+ ref.componentInstance.data = pack;
102
+ ref.afterClosed().subscribe(result => {
103
+ console.log(result);
104
+ this.filter();
105
+ });
106
+ }
107
+
108
+
89109 sort(sortEvent: ITdDataTableSortChangeEvent): void {
90110 this.sortBy = sortEvent.name;
91111 this.sortOrder = sortEvent.order;
securis/src/main/webapp/src/app/user.service.ts
....@@ -52,7 +52,6 @@
5252 }
5353
5454 existsToken() : Boolean {
55
- console.log(this.store.get("token"));
5655 return this.store.get("token") !== null;
5756 }
5857