César Calvo
2017-03-15 abb9cc75e166c32cfa97244c497e6a69d14ea114
Merge branch 'angular2' of https://git.curisit.net/gitblit/git/common/securis into angular2

Conflicts:
securis/src/main/webapp/src/app/app.module.ts
securis/src/main/webapp/src/app/app.routes.ts
securis/src/main/webapp/src/app/home.component.html
10 files modified
changed files
securis/src/main/webapp/src/app/app.module.ts patch | view | blame | history
securis/src/main/webapp/src/app/app.routes.ts patch | view | blame | history
securis/src/main/webapp/src/app/common/i18n.ts 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/home.component.html patch | view | blame | history
securis/src/main/webapp/src/app/license.list.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/lang/messages_en.json patch | view | blame | history
securis/src/main/webapp/src/app/app.module.ts
....@@ -26,8 +26,7 @@
2626 import { MenuComponent } from './menu.component';
2727 import { NoMenuComponent } from './nomenu.component';
2828 import { FooterComponent } from './footer.component';
29
-
30
-
29
+import { LicenseListComponent } from './license.list.component';
3130 import { appRoutes, appRoutingProviders } from './app.routes';
3231 import { requestOptionsProvider, requestBackendProvider } from './common/default.requests.options';
3332 import { LocaleServiceModule } from './common/i18n';
....@@ -56,6 +55,7 @@
5655 PackFormComponent,
5756 LoginFormComponent,
5857 ErrorCheckerComponent,
58
+ LicenseListComponent,
5959 I18nDirective,
6060 HomeComponent,
6161 MenuComponent,
securis/src/main/webapp/src/app/app.routes.ts
....@@ -4,13 +4,17 @@
44 import { MenuComponent } from './menu.component';
55 import { NoMenuComponent } from './nomenu.component';
66 import { PackListComponent } from './pack.list.component';
7
+import { LicenseListComponent } from './license.list.component';
78 import { LoginFormComponent } from './login.form.component';
89
910 const routes: Routes = [
1011 // {path: '', redirectTo: '/packs', pathMatch: 'full'},
1112 {path: 'menu', component: MenuComponent,
1213 children: [
13
- {path: 'packs', component: PackListComponent }
14
+ {path: 'packs', children: [
15
+ {path: '', component: PackListComponent },
16
+ {path: ':id/licenses', component: LicenseListComponent },
17
+ ]}
1418 ]
1519 },
1620 {path: 'nomenu', component: NoMenuComponent,
....@@ -18,6 +22,7 @@
1822 {path: 'login', component: LoginFormComponent }
1923 ]
2024 }
25
+
2126 ];
2227 /* {path: 'product', component: DashboardProductComponent, children: [
2328 {path: '', component: ProductOverviewComponent},
securis/src/main/webapp/src/app/common/i18n.ts
....@@ -108,7 +108,6 @@
108108 @Directive({ selector: '[i18n]' })
109109 export class I18nDirective {
110110 constructor(private el: ElementRef, private renderer: Renderer, private $L: LocaleService) {
111
- console.log(el);
112111 }
113112
114113 ngAfterViewChecked() {
securis/src/main/webapp/src/app/forms/pack.form.component.ts
....@@ -1,7 +1,7 @@
11 import { Http } from '@angular/http';
22 import { ToastsManager } from 'ng2-toastr/ng2-toastr';
33
4
-import { PacksService } from '../resources/packs';
4
+import { PacksService, PACK_STATUS } from '../resources/packs';
55 import { LicenseTypesService } from '../resources/license_types';
66 import { LocaleService } from '../common/i18n';
77 import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core';
....@@ -100,7 +100,9 @@
100100
101101 ngOnInit(): void {
102102 this.loadCombos();
103
- // this.data = {};
103
+ if (this.isNew) {
104
+ this.data.status = PACK_STATUS.CREATED;
105
+ }
104106 this.form_title = this.$L.get('Pack data');
105107 this.form_subtitle = this.$L.get(this.isNew ? 'Create a new licenses pack': 'Modify the licenses pack data') ;
106108 }
securis/src/main/webapp/src/app/forms/pack.form.html
....@@ -44,7 +44,7 @@
4444 <span i18n="field.license_preactivation"></span>
4545 </md-checkbox>
4646 </div>
47
- <div layout="column" layout-fill flex>
47
+ <div layout="column" layout-fill flex *ngIf="!isNew">
4848 <div layout="column" class="mat-input-container" flex>
4949 <label class="mat-input-placeholder mat-float">
5050 <span class="placeholder" i18n="field.status"></span>
securis/src/main/webapp/src/app/home.component.html
....@@ -1,2 +1 @@
1
-
2
- <router-outlet></router-outlet>
1
+ <router-outlet></router-outlet>
securis/src/main/webapp/src/app/license.list.component.ts
....@@ -1,5 +1,5 @@
11 import { Router } from '@angular/router';
2
-import { MdDialog } from '@angular/material';
2
+import { MdDialog, MdDialogConfig } from '@angular/material';
33 import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core';
44 import { IPageChangeEvent } from '@covalent/core';
55 import { Component, AfterViewInit } from '@angular/core';
....@@ -22,6 +22,11 @@
2222 pack_id: 18,
2323 request_data: '{"appCode":"CISA","activationCode":"19fa8d30-29cb-4b59-81b5-3837af8204b6","arch":"x86_64","osName":"Mac OS X","macAddresses":["60-03-08-95-AE-D0","B6-2B-33-E9-64-2D"],"crcLogo":"10f6379e0e1c00ebc403160307e3c5d0aba0727c9cae0bf1ac7cd19d84fdc80f"}',
2424 status: 'AC' }
25
+
26
+const DIALOG_OPTIONS : MdDialogConfig = {
27
+ height: '80%', // can be px or %
28
+ width: '45%', // can be px or %
29
+}
2530
2631 @Component({
2732 selector: 'license-list',
....@@ -85,27 +90,22 @@
8590 this.filter();
8691 }
8792
88
- createPack() : void {
89
- var ref = this.dialog.open(LicenseFormComponent, {
90
- height: '50%', // can be px or %
91
- width: '40%', // can be px or %
92
- });
93
+ createLicense() : void {
94
+ let ref = this.dialog.open(LicenseFormComponent, DIALOG_OPTIONS);
95
+
9396 ref.componentInstance.isNew = true;
97
+ ref.componentInstance.data = {};
9498 ref.afterClosed().subscribe(result => {
95
- console.log(result);
9699 this.filter();
97100 });
101
+
98102 }
99103
100104 editLicense(lic: any) : void {
101
- var ref = this.dialog.open(LicenseFormComponent, {
102
- height: '50%', // can be px or %
103
- width: '40%', // can be px or %
104
- });
105
+ let ref = this.dialog.open(LicenseFormComponent, DIALOG_OPTIONS);
105106 ref.componentInstance.isNew = false;
106107 ref.componentInstance.data = lic;
107108 ref.afterClosed().subscribe(result => {
108
- console.log(result);
109109 this.filter();
110110 });
111111 }
securis/src/main/webapp/src/app/pack.list.component.html
....@@ -14,13 +14,19 @@
1414 <md-divider></md-divider>
1515 <div layout="row" layout-align="center center">
1616 <div flex="80" layout="column" layout-align="end center" >
17
-<td-data-table [data]="filteredData" [columns]="columns" style="width: 100%">
17
+<td-data-table
18
+ [data]="filteredData"
19
+ [columns]="columns"
20
+ [sortable]="true"
21
+ [sortBy]="sortBy"
22
+ (sortChange)="sort($event)"
23
+ style="width: 100%">
1824 <template tdDataTableTemplate="used_licenses" let-row="row">
1925 <div layout="row">
20
- <td-notification-count color="secondary" [notifications]="row['num_licenses']">
21
- </td-notification-count>
22
- <td-notification-count color="primary" [notifications]="row['num_available']">
23
- </td-notification-count>
26
+ <md-chip-list flex>
27
+ <md-chip selected [mdTooltip]="$L.get('field.num_licenses')" color="secondary" >{{row['num_licenses']}}</md-chip>
28
+ <md-chip selected [mdTooltip]="$L.get('field.num_available')" [color]="row['num_available'] > 0 ? 'primary': 'warn'">{{row['num_available']}}</md-chip>
29
+ </md-chip-list>
2430 </div>
2531 </template>
2632 <template tdDataTableTemplate="code" let-row="row" let-value="value">
securis/src/main/webapp/src/app/pack.list.component.ts
....@@ -1,11 +1,13 @@
11 import { Router } from '@angular/router';
2
-import { MdDialog } from '@angular/material';
2
+import { MdDialog, MdDialogConfig } from '@angular/material';
33 import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core';
44 import { IPageChangeEvent } from '@covalent/core';
55 import { Component, AfterViewInit } from '@angular/core';
66 import { TdMediaService } from '@covalent/core';
77 import { PacksService } from './resources/packs';
88 import { PackFormComponent } from './forms/pack.form.component';
9
+import { LocaleService } from './common/i18n';
10
+
911
1012 var pack_example = {
1113 id: 7,
....@@ -36,6 +38,11 @@
3638 renew_valid_period: 0,
3739 }
3840
41
+const DIALOG_OPTIONS : MdDialogConfig = {
42
+ height: '80%', // can be px or %
43
+ width: '45%', // can be px or %
44
+}
45
+
3946 @Component({
4047 selector: 'pack-list',
4148 templateUrl: 'src/app/pack.list.component.html'
....@@ -58,7 +65,7 @@
5865 fromRow: number = 1;
5966 currentPage: number = 1;
6067 pageSize: number = 10;
61
- sortBy: string = 'application_name';
68
+ sortBy: string = 'code';
6269 sortOrder: TdDataTableSortingOrder = TdDataTableSortingOrder.Descending;
6370 filteredItems = this.data.length;
6471 pack_menu_options : any[] = [{
....@@ -81,6 +88,7 @@
8188 private media: TdMediaService,
8289 private router: Router,
8390 private dialog: MdDialog,
91
+ private $L: LocaleService,
8492 private packForm: PackFormComponent,
8593 private packs: PacksService) {
8694 this.packs.get().subscribe(
....@@ -97,10 +105,7 @@
97105 }
98106
99107 createPack() : void {
100
- var ref = this.dialog.open(PackFormComponent, {
101
- height: '50%', // can be px or %
102
- width: '40%', // can be px or %
103
- });
108
+ var ref = this.dialog.open(PackFormComponent, DIALOG_OPTIONS);
104109 ref.componentInstance.isNew = true;
105110 ref.afterClosed().subscribe(result => {
106111 console.log(result);
....@@ -113,10 +118,7 @@
113118 }
114119
115120 editPack(pack: any) : void {
116
- var ref = this.dialog.open(PackFormComponent, {
117
- height: '70%', // can be px or %
118
- width: '40%', // can be px or %
119
- });
121
+ var ref = this.dialog.open(PackFormComponent, DIALOG_OPTIONS);
120122 ref.componentInstance.isNew = false;
121123 ref.componentInstance.data = pack;
122124 ref.afterClosed().subscribe(result => {
....@@ -127,7 +129,7 @@
127129
128130
129131 sort(sortEvent: ITdDataTableSortChangeEvent): void {
130
- this.sortBy = sortEvent.name;
132
+ this.sortBy = sortEvent.name === 'used_licenses' ? 'num_available' : sortEvent.name;
131133 this.sortOrder = sortEvent.order;
132134 this.filter();
133135 }
securis/src/main/webapp/src/lang/messages_en.json
....@@ -1,6 +1,7 @@
11 {
22 "field.code": "Code",
33 "field.num_licenses": "Num. licenses",
4
+ "field.num_available": "Available licenses",
45 "field.pack": "Pack",
56 "field.id": "ID",
67 "field.init_valid_date": "Init valid date",