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
| .. | .. |
|---|
| 26 | 26 | import { MenuComponent } from './menu.component'; |
|---|
| 27 | 27 | import { NoMenuComponent } from './nomenu.component'; |
|---|
| 28 | 28 | import { FooterComponent } from './footer.component'; |
|---|
| 29 | | - |
|---|
| 30 | | - |
|---|
| 29 | +import { LicenseListComponent } from './license.list.component'; |
|---|
| 31 | 30 | import { appRoutes, appRoutingProviders } from './app.routes'; |
|---|
| 32 | 31 | import { requestOptionsProvider, requestBackendProvider } from './common/default.requests.options'; |
|---|
| 33 | 32 | import { LocaleServiceModule } from './common/i18n'; |
|---|
| .. | .. |
|---|
| 56 | 55 | PackFormComponent, |
|---|
| 57 | 56 | LoginFormComponent, |
|---|
| 58 | 57 | ErrorCheckerComponent, |
|---|
| 58 | + LicenseListComponent, |
|---|
| 59 | 59 | I18nDirective, |
|---|
| 60 | 60 | HomeComponent, |
|---|
| 61 | 61 | MenuComponent, |
|---|
| .. | .. |
|---|
| 4 | 4 | import { MenuComponent } from './menu.component'; |
|---|
| 5 | 5 | import { NoMenuComponent } from './nomenu.component'; |
|---|
| 6 | 6 | import { PackListComponent } from './pack.list.component'; |
|---|
| 7 | +import { LicenseListComponent } from './license.list.component'; |
|---|
| 7 | 8 | import { LoginFormComponent } from './login.form.component'; |
|---|
| 8 | 9 | |
|---|
| 9 | 10 | const routes: Routes = [ |
|---|
| 10 | 11 | // {path: '', redirectTo: '/packs', pathMatch: 'full'}, |
|---|
| 11 | 12 | {path: 'menu', component: MenuComponent, |
|---|
| 12 | 13 | children: [ |
|---|
| 13 | | - {path: 'packs', component: PackListComponent } |
|---|
| 14 | + {path: 'packs', children: [ |
|---|
| 15 | + {path: '', component: PackListComponent }, |
|---|
| 16 | + {path: ':id/licenses', component: LicenseListComponent }, |
|---|
| 17 | + ]} |
|---|
| 14 | 18 | ] |
|---|
| 15 | 19 | }, |
|---|
| 16 | 20 | {path: 'nomenu', component: NoMenuComponent, |
|---|
| .. | .. |
|---|
| 18 | 22 | {path: 'login', component: LoginFormComponent } |
|---|
| 19 | 23 | ] |
|---|
| 20 | 24 | } |
|---|
| 25 | + |
|---|
| 21 | 26 | ]; |
|---|
| 22 | 27 | /* {path: 'product', component: DashboardProductComponent, children: [ |
|---|
| 23 | 28 | {path: '', component: ProductOverviewComponent}, |
|---|
| .. | .. |
|---|
| 108 | 108 | @Directive({ selector: '[i18n]' }) |
|---|
| 109 | 109 | export class I18nDirective { |
|---|
| 110 | 110 | constructor(private el: ElementRef, private renderer: Renderer, private $L: LocaleService) { |
|---|
| 111 | | - console.log(el); |
|---|
| 112 | 111 | } |
|---|
| 113 | 112 | |
|---|
| 114 | 113 | ngAfterViewChecked() { |
|---|
| .. | .. |
|---|
| 1 | 1 | import { Http } from '@angular/http'; |
|---|
| 2 | 2 | import { ToastsManager } from 'ng2-toastr/ng2-toastr'; |
|---|
| 3 | 3 | |
|---|
| 4 | | -import { PacksService } from '../resources/packs'; |
|---|
| 4 | +import { PacksService, PACK_STATUS } from '../resources/packs'; |
|---|
| 5 | 5 | import { LicenseTypesService } from '../resources/license_types'; |
|---|
| 6 | 6 | import { LocaleService } from '../common/i18n'; |
|---|
| 7 | 7 | import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core'; |
|---|
| .. | .. |
|---|
| 100 | 100 | |
|---|
| 101 | 101 | ngOnInit(): void { |
|---|
| 102 | 102 | this.loadCombos(); |
|---|
| 103 | | - // this.data = {}; |
|---|
| 103 | + if (this.isNew) { |
|---|
| 104 | + this.data.status = PACK_STATUS.CREATED; |
|---|
| 105 | + } |
|---|
| 104 | 106 | this.form_title = this.$L.get('Pack data'); |
|---|
| 105 | 107 | this.form_subtitle = this.$L.get(this.isNew ? 'Create a new licenses pack': 'Modify the licenses pack data') ; |
|---|
| 106 | 108 | } |
|---|
| .. | .. |
|---|
| 44 | 44 | <span i18n="field.license_preactivation"></span> |
|---|
| 45 | 45 | </md-checkbox> |
|---|
| 46 | 46 | </div> |
|---|
| 47 | | - <div layout="column" layout-fill flex> |
|---|
| 47 | + <div layout="column" layout-fill flex *ngIf="!isNew"> |
|---|
| 48 | 48 | <div layout="column" class="mat-input-container" flex> |
|---|
| 49 | 49 | <label class="mat-input-placeholder mat-float"> |
|---|
| 50 | 50 | <span class="placeholder" i18n="field.status"></span> |
|---|
| .. | .. |
|---|
| 1 | | - |
|---|
| 2 | | - <router-outlet></router-outlet> |
|---|
| 1 | + <router-outlet></router-outlet> |
|---|
| .. | .. |
|---|
| 1 | 1 | import { Router } from '@angular/router'; |
|---|
| 2 | | -import { MdDialog } from '@angular/material'; |
|---|
| 2 | +import { MdDialog, MdDialogConfig } from '@angular/material'; |
|---|
| 3 | 3 | import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core'; |
|---|
| 4 | 4 | import { IPageChangeEvent } from '@covalent/core'; |
|---|
| 5 | 5 | import { Component, AfterViewInit } from '@angular/core'; |
|---|
| .. | .. |
|---|
| 22 | 22 | pack_id: 18, |
|---|
| 23 | 23 | 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"}', |
|---|
| 24 | 24 | status: 'AC' } |
|---|
| 25 | + |
|---|
| 26 | +const DIALOG_OPTIONS : MdDialogConfig = { |
|---|
| 27 | + height: '80%', // can be px or % |
|---|
| 28 | + width: '45%', // can be px or % |
|---|
| 29 | +} |
|---|
| 25 | 30 | |
|---|
| 26 | 31 | @Component({ |
|---|
| 27 | 32 | selector: 'license-list', |
|---|
| .. | .. |
|---|
| 85 | 90 | this.filter(); |
|---|
| 86 | 91 | } |
|---|
| 87 | 92 | |
|---|
| 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 | + |
|---|
| 93 | 96 | ref.componentInstance.isNew = true; |
|---|
| 97 | + ref.componentInstance.data = {}; |
|---|
| 94 | 98 | ref.afterClosed().subscribe(result => { |
|---|
| 95 | | - console.log(result); |
|---|
| 96 | 99 | this.filter(); |
|---|
| 97 | 100 | }); |
|---|
| 101 | + |
|---|
| 98 | 102 | } |
|---|
| 99 | 103 | |
|---|
| 100 | 104 | 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); |
|---|
| 105 | 106 | ref.componentInstance.isNew = false; |
|---|
| 106 | 107 | ref.componentInstance.data = lic; |
|---|
| 107 | 108 | ref.afterClosed().subscribe(result => { |
|---|
| 108 | | - console.log(result); |
|---|
| 109 | 109 | this.filter(); |
|---|
| 110 | 110 | }); |
|---|
| 111 | 111 | } |
|---|
| .. | .. |
|---|
| 14 | 14 | <md-divider></md-divider> |
|---|
| 15 | 15 | <div layout="row" layout-align="center center"> |
|---|
| 16 | 16 | <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%"> |
|---|
| 18 | 24 | <template tdDataTableTemplate="used_licenses" let-row="row"> |
|---|
| 19 | 25 | <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> |
|---|
| 24 | 30 | </div> |
|---|
| 25 | 31 | </template> |
|---|
| 26 | 32 | <template tdDataTableTemplate="code" let-row="row" let-value="value"> |
|---|
| .. | .. |
|---|
| 1 | 1 | import { Router } from '@angular/router'; |
|---|
| 2 | | -import { MdDialog } from '@angular/material'; |
|---|
| 2 | +import { MdDialog, MdDialogConfig } from '@angular/material'; |
|---|
| 3 | 3 | import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core'; |
|---|
| 4 | 4 | import { IPageChangeEvent } from '@covalent/core'; |
|---|
| 5 | 5 | import { Component, AfterViewInit } from '@angular/core'; |
|---|
| 6 | 6 | import { TdMediaService } from '@covalent/core'; |
|---|
| 7 | 7 | import { PacksService } from './resources/packs'; |
|---|
| 8 | 8 | import { PackFormComponent } from './forms/pack.form.component'; |
|---|
| 9 | +import { LocaleService } from './common/i18n'; |
|---|
| 10 | + |
|---|
| 9 | 11 | |
|---|
| 10 | 12 | var pack_example = { |
|---|
| 11 | 13 | id: 7, |
|---|
| .. | .. |
|---|
| 36 | 38 | renew_valid_period: 0, |
|---|
| 37 | 39 | } |
|---|
| 38 | 40 | |
|---|
| 41 | +const DIALOG_OPTIONS : MdDialogConfig = { |
|---|
| 42 | + height: '80%', // can be px or % |
|---|
| 43 | + width: '45%', // can be px or % |
|---|
| 44 | +} |
|---|
| 45 | + |
|---|
| 39 | 46 | @Component({ |
|---|
| 40 | 47 | selector: 'pack-list', |
|---|
| 41 | 48 | templateUrl: 'src/app/pack.list.component.html' |
|---|
| .. | .. |
|---|
| 58 | 65 | fromRow: number = 1; |
|---|
| 59 | 66 | currentPage: number = 1; |
|---|
| 60 | 67 | pageSize: number = 10; |
|---|
| 61 | | - sortBy: string = 'application_name'; |
|---|
| 68 | + sortBy: string = 'code'; |
|---|
| 62 | 69 | sortOrder: TdDataTableSortingOrder = TdDataTableSortingOrder.Descending; |
|---|
| 63 | 70 | filteredItems = this.data.length; |
|---|
| 64 | 71 | pack_menu_options : any[] = [{ |
|---|
| .. | .. |
|---|
| 81 | 88 | private media: TdMediaService, |
|---|
| 82 | 89 | private router: Router, |
|---|
| 83 | 90 | private dialog: MdDialog, |
|---|
| 91 | + private $L: LocaleService, |
|---|
| 84 | 92 | private packForm: PackFormComponent, |
|---|
| 85 | 93 | private packs: PacksService) { |
|---|
| 86 | 94 | this.packs.get().subscribe( |
|---|
| .. | .. |
|---|
| 97 | 105 | } |
|---|
| 98 | 106 | |
|---|
| 99 | 107 | 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); |
|---|
| 104 | 109 | ref.componentInstance.isNew = true; |
|---|
| 105 | 110 | ref.afterClosed().subscribe(result => { |
|---|
| 106 | 111 | console.log(result); |
|---|
| .. | .. |
|---|
| 113 | 118 | } |
|---|
| 114 | 119 | |
|---|
| 115 | 120 | 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); |
|---|
| 120 | 122 | ref.componentInstance.isNew = false; |
|---|
| 121 | 123 | ref.componentInstance.data = pack; |
|---|
| 122 | 124 | ref.afterClosed().subscribe(result => { |
|---|
| .. | .. |
|---|
| 127 | 129 | |
|---|
| 128 | 130 | |
|---|
| 129 | 131 | sort(sortEvent: ITdDataTableSortChangeEvent): void { |
|---|
| 130 | | - this.sortBy = sortEvent.name; |
|---|
| 132 | + this.sortBy = sortEvent.name === 'used_licenses' ? 'num_available' : sortEvent.name; |
|---|
| 131 | 133 | this.sortOrder = sortEvent.order; |
|---|
| 132 | 134 | this.filter(); |
|---|
| 133 | 135 | } |
|---|
| .. | .. |
|---|
| 1 | 1 | { |
|---|
| 2 | 2 | "field.code": "Code", |
|---|
| 3 | 3 | "field.num_licenses": "Num. licenses", |
|---|
| 4 | + "field.num_available": "Available licenses", |
|---|
| 4 | 5 | "field.pack": "Pack", |
|---|
| 5 | 6 | "field.id": "ID", |
|---|
| 6 | 7 | "field.init_valid_date": "Init valid date", |
|---|