From abb9cc75e166c32cfa97244c497e6a69d14ea114 Mon Sep 17 00:00:00 2001
From: CeĢsar Calvo <ccalvo@curisit.net>
Date: Wed, 15 Mar 2017 15:32:23 +0000
Subject: [PATCH] Merge branch 'angular2' of https://git.curisit.net/gitblit/git/common/securis into angular2
---
securis/src/main/webapp/src/app/common/i18n.ts | 1
securis/src/main/webapp/src/app/home.component.html | 3 -
securis/src/main/webapp/src/app/license.list.component.ts | 24 ++++++------
securis/src/main/webapp/src/app/pack.list.component.html | 16 +++++--
securis/src/main/webapp/src/app/forms/pack.form.component.ts | 6 ++-
securis/src/main/webapp/src/app/app.module.ts | 4 +-
securis/src/main/webapp/src/app/app.routes.ts | 7 +++
securis/src/main/webapp/src/app/forms/pack.form.html | 2
securis/src/main/webapp/src/app/pack.list.component.ts | 24 ++++++-----
securis/src/main/webapp/src/lang/messages_en.json | 1
10 files changed, 51 insertions(+), 37 deletions(-)
diff --git a/securis/src/main/webapp/src/app/app.module.ts b/securis/src/main/webapp/src/app/app.module.ts
index 2eec1d6..cc94e7c 100644
--- a/securis/src/main/webapp/src/app/app.module.ts
+++ b/securis/src/main/webapp/src/app/app.module.ts
@@ -26,8 +26,7 @@
import { MenuComponent } from './menu.component';
import { NoMenuComponent } from './nomenu.component';
import { FooterComponent } from './footer.component';
-
-
+import { LicenseListComponent } from './license.list.component';
import { appRoutes, appRoutingProviders } from './app.routes';
import { requestOptionsProvider, requestBackendProvider } from './common/default.requests.options';
import { LocaleServiceModule } from './common/i18n';
@@ -56,6 +55,7 @@
PackFormComponent,
LoginFormComponent,
ErrorCheckerComponent,
+ LicenseListComponent,
I18nDirective,
HomeComponent,
MenuComponent,
diff --git a/securis/src/main/webapp/src/app/app.routes.ts b/securis/src/main/webapp/src/app/app.routes.ts
index 1fd75a7..060a1ff 100644
--- a/securis/src/main/webapp/src/app/app.routes.ts
+++ b/securis/src/main/webapp/src/app/app.routes.ts
@@ -4,13 +4,17 @@
import { MenuComponent } from './menu.component';
import { NoMenuComponent } from './nomenu.component';
import { PackListComponent } from './pack.list.component';
+import { LicenseListComponent } from './license.list.component';
import { LoginFormComponent } from './login.form.component';
const routes: Routes = [
// {path: '', redirectTo: '/packs', pathMatch: 'full'},
{path: 'menu', component: MenuComponent,
children: [
- {path: 'packs', component: PackListComponent }
+ {path: 'packs', children: [
+ {path: '', component: PackListComponent },
+ {path: ':id/licenses', component: LicenseListComponent },
+ ]}
]
},
{path: 'nomenu', component: NoMenuComponent,
@@ -18,6 +22,7 @@
{path: 'login', component: LoginFormComponent }
]
}
+
];
/* {path: 'product', component: DashboardProductComponent, children: [
{path: '', component: ProductOverviewComponent},
diff --git a/securis/src/main/webapp/src/app/common/i18n.ts b/securis/src/main/webapp/src/app/common/i18n.ts
index 58f1411..148f562 100644
--- a/securis/src/main/webapp/src/app/common/i18n.ts
+++ b/securis/src/main/webapp/src/app/common/i18n.ts
@@ -108,7 +108,6 @@
@Directive({ selector: '[i18n]' })
export class I18nDirective {
constructor(private el: ElementRef, private renderer: Renderer, private $L: LocaleService) {
- console.log(el);
}
ngAfterViewChecked() {
diff --git a/securis/src/main/webapp/src/app/forms/pack.form.component.ts b/securis/src/main/webapp/src/app/forms/pack.form.component.ts
index 9c43e46..49b41ec 100644
--- a/securis/src/main/webapp/src/app/forms/pack.form.component.ts
+++ b/securis/src/main/webapp/src/app/forms/pack.form.component.ts
@@ -1,7 +1,7 @@
import { Http } from '@angular/http';
import { ToastsManager } from 'ng2-toastr/ng2-toastr';
-import { PacksService } from '../resources/packs';
+import { PacksService, PACK_STATUS } from '../resources/packs';
import { LicenseTypesService } from '../resources/license_types';
import { LocaleService } from '../common/i18n';
import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core';
@@ -100,7 +100,9 @@
ngOnInit(): void {
this.loadCombos();
- // this.data = {};
+ if (this.isNew) {
+ this.data.status = PACK_STATUS.CREATED;
+ }
this.form_title = this.$L.get('Pack data');
this.form_subtitle = this.$L.get(this.isNew ? 'Create a new licenses pack': 'Modify the licenses pack data') ;
}
diff --git a/securis/src/main/webapp/src/app/forms/pack.form.html b/securis/src/main/webapp/src/app/forms/pack.form.html
index 4dc10c0..9575db2 100644
--- a/securis/src/main/webapp/src/app/forms/pack.form.html
+++ b/securis/src/main/webapp/src/app/forms/pack.form.html
@@ -44,7 +44,7 @@
<span i18n="field.license_preactivation"></span>
</md-checkbox>
</div>
- <div layout="column" layout-fill flex>
+ <div layout="column" layout-fill flex *ngIf="!isNew">
<div layout="column" class="mat-input-container" flex>
<label class="mat-input-placeholder mat-float">
<span class="placeholder" i18n="field.status"></span>
diff --git a/securis/src/main/webapp/src/app/home.component.html b/securis/src/main/webapp/src/app/home.component.html
index ba626e8..468e1fa 100644
--- a/securis/src/main/webapp/src/app/home.component.html
+++ b/securis/src/main/webapp/src/app/home.component.html
@@ -1,2 +1 @@
-
- <router-outlet></router-outlet>
+ <router-outlet></router-outlet>
\ No newline at end of file
diff --git a/securis/src/main/webapp/src/app/license.list.component.ts b/securis/src/main/webapp/src/app/license.list.component.ts
index a14377e..9ff77ba 100644
--- a/securis/src/main/webapp/src/app/license.list.component.ts
+++ b/securis/src/main/webapp/src/app/license.list.component.ts
@@ -1,5 +1,5 @@
import { Router } from '@angular/router';
-import { MdDialog } from '@angular/material';
+import { MdDialog, MdDialogConfig } from '@angular/material';
import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core';
import { IPageChangeEvent } from '@covalent/core';
import { Component, AfterViewInit } from '@angular/core';
@@ -22,6 +22,11 @@
pack_id: 18,
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"}',
status: 'AC' }
+
+const DIALOG_OPTIONS : MdDialogConfig = {
+ height: '80%', // can be px or %
+ width: '45%', // can be px or %
+}
@Component({
selector: 'license-list',
@@ -85,27 +90,22 @@
this.filter();
}
- createPack() : void {
- var ref = this.dialog.open(LicenseFormComponent, {
- height: '50%', // can be px or %
- width: '40%', // can be px or %
- });
+ createLicense() : void {
+ let ref = this.dialog.open(LicenseFormComponent, DIALOG_OPTIONS);
+
ref.componentInstance.isNew = true;
+ ref.componentInstance.data = {};
ref.afterClosed().subscribe(result => {
- console.log(result);
this.filter();
});
+
}
editLicense(lic: any) : void {
- var ref = this.dialog.open(LicenseFormComponent, {
- height: '50%', // can be px or %
- width: '40%', // can be px or %
- });
+ let ref = this.dialog.open(LicenseFormComponent, DIALOG_OPTIONS);
ref.componentInstance.isNew = false;
ref.componentInstance.data = lic;
ref.afterClosed().subscribe(result => {
- console.log(result);
this.filter();
});
}
diff --git a/securis/src/main/webapp/src/app/pack.list.component.html b/securis/src/main/webapp/src/app/pack.list.component.html
index 25969b2..07e1b18 100644
--- a/securis/src/main/webapp/src/app/pack.list.component.html
+++ b/securis/src/main/webapp/src/app/pack.list.component.html
@@ -14,13 +14,19 @@
<md-divider></md-divider>
<div layout="row" layout-align="center center">
<div flex="80" layout="column" layout-align="end center" >
-<td-data-table [data]="filteredData" [columns]="columns" style="width: 100%">
+<td-data-table
+ [data]="filteredData"
+ [columns]="columns"
+ [sortable]="true"
+ [sortBy]="sortBy"
+ (sortChange)="sort($event)"
+ style="width: 100%">
<template tdDataTableTemplate="used_licenses" let-row="row">
<div layout="row">
- <td-notification-count color="secondary" [notifications]="row['num_licenses']">
- </td-notification-count>
- <td-notification-count color="primary" [notifications]="row['num_available']">
- </td-notification-count>
+ <md-chip-list flex>
+ <md-chip selected [mdTooltip]="$L.get('field.num_licenses')" color="secondary" >{{row['num_licenses']}}</md-chip>
+ <md-chip selected [mdTooltip]="$L.get('field.num_available')" [color]="row['num_available'] > 0 ? 'primary': 'warn'">{{row['num_available']}}</md-chip>
+ </md-chip-list>
</div>
</template>
<template tdDataTableTemplate="code" let-row="row" let-value="value">
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 0af18bb..7df79ab 100644
--- a/securis/src/main/webapp/src/app/pack.list.component.ts
+++ b/securis/src/main/webapp/src/app/pack.list.component.ts
@@ -1,11 +1,13 @@
import { Router } from '@angular/router';
-import { MdDialog } from '@angular/material';
+import { MdDialog, MdDialogConfig } from '@angular/material';
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';
import { PackFormComponent } from './forms/pack.form.component';
+import { LocaleService } from './common/i18n';
+
var pack_example = {
id: 7,
@@ -36,6 +38,11 @@
renew_valid_period: 0,
}
+const DIALOG_OPTIONS : MdDialogConfig = {
+ height: '80%', // can be px or %
+ width: '45%', // can be px or %
+}
+
@Component({
selector: 'pack-list',
templateUrl: 'src/app/pack.list.component.html'
@@ -58,7 +65,7 @@
fromRow: number = 1;
currentPage: number = 1;
pageSize: number = 10;
- sortBy: string = 'application_name';
+ sortBy: string = 'code';
sortOrder: TdDataTableSortingOrder = TdDataTableSortingOrder.Descending;
filteredItems = this.data.length;
pack_menu_options : any[] = [{
@@ -81,6 +88,7 @@
private media: TdMediaService,
private router: Router,
private dialog: MdDialog,
+ private $L: LocaleService,
private packForm: PackFormComponent,
private packs: PacksService) {
this.packs.get().subscribe(
@@ -97,10 +105,7 @@
}
createPack() : void {
- var ref = this.dialog.open(PackFormComponent, {
- height: '50%', // can be px or %
- width: '40%', // can be px or %
- });
+ var ref = this.dialog.open(PackFormComponent, DIALOG_OPTIONS);
ref.componentInstance.isNew = true;
ref.afterClosed().subscribe(result => {
console.log(result);
@@ -113,10 +118,7 @@
}
editPack(pack: any) : void {
- var ref = this.dialog.open(PackFormComponent, {
- height: '70%', // can be px or %
- width: '40%', // can be px or %
- });
+ var ref = this.dialog.open(PackFormComponent, DIALOG_OPTIONS);
ref.componentInstance.isNew = false;
ref.componentInstance.data = pack;
ref.afterClosed().subscribe(result => {
@@ -127,7 +129,7 @@
sort(sortEvent: ITdDataTableSortChangeEvent): void {
- this.sortBy = sortEvent.name;
+ this.sortBy = sortEvent.name === 'used_licenses' ? 'num_available' : sortEvent.name;
this.sortOrder = sortEvent.order;
this.filter();
}
diff --git a/securis/src/main/webapp/src/lang/messages_en.json b/securis/src/main/webapp/src/lang/messages_en.json
index 6e275b0..a50b002 100644
--- a/securis/src/main/webapp/src/lang/messages_en.json
+++ b/securis/src/main/webapp/src/lang/messages_en.json
@@ -1,6 +1,7 @@
{
"field.code": "Code",
"field.num_licenses": "Num. licenses",
+ "field.num_available": "Available licenses",
"field.pack": "Pack",
"field.id": "ID",
"field.init_valid_date": "Init valid date",
--
Gitblit v1.3.2