From 89a0646d18da6f3290a883121e38f4086a6fb37e Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Wed, 07 Jun 2017 16:35:16 +0000
Subject: [PATCH] #3531 fea - Added acces to packs from license type, organizatins and applications listing
---
securis/src/main/webapp/src/app/listing/pack.list.component.ts | 50 ++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/securis/src/main/webapp/src/app/listing/pack.list.component.ts b/securis/src/main/webapp/src/app/listing/pack.list.component.ts
index 9fcef79..0d92901 100644
--- a/securis/src/main/webapp/src/app/listing/pack.list.component.ts
+++ b/securis/src/main/webapp/src/app/listing/pack.list.component.ts
@@ -1,4 +1,5 @@
import { Router, ActivatedRoute } from '@angular/router';
+import { Location } from '@angular/common';
import { ToastsManager } from 'ng2-toastr/ng2-toastr';
import { MdDialog, MdDialogConfig } from '@angular/material';
import {
@@ -11,12 +12,12 @@
import { IPageChangeEvent } from '@covalent/core';
import { Component, ViewChild, AfterViewInit } from '@angular/core';
import { TdMediaService } from '@covalent/core';
-import { PacksService, PACK_ACTIONS } from '../resources/packs';
+import { PacksService, PACK_ACTIONS, PacksFilter } from '../resources/packs';
import { PackFormComponent } from '../forms/pack.form.component';
import { LocaleService } from '../common/i18n';
import { ListingBase } from './base';
-
+/**
var pack_example = {
id: 7,
code: 'DX250000',
@@ -45,7 +46,7 @@
preactivation_valid_period: 70,
renew_valid_period: 0,
}
-
+*/
@Component({
selector: 'pack-list',
templateUrl: 'src/app/listing/pack.list.component.html'
@@ -63,6 +64,8 @@
];
pack_menu_options = PACK_ACTIONS;
+ filter_description : string;
+ prevUrl : string = null;
constructor(_dataTableService: TdDataTableService,
private media: TdMediaService,
@@ -76,14 +79,42 @@
super(_dataTableService);
}
- reload() : void {
- this.packs.get().subscribe(
+ reload(filter?: PacksFilter) : void {
+ this.prepareFilteredBehavior(filter);
+ this.packs.get(filter).subscribe(
(list : any[]) => {
this.data = list;
this.refresh();
},
(err: any) => console.error(err)
);
+ }
+
+ goBack() : void {
+ if (this.prevUrl) {
+ this.router.navigate([this.prevUrl]);
+ }
+ }
+
+ prepareFilteredBehavior(filter: PacksFilter) {
+ if (!filter) {
+ this.filter_description = '';
+ this.prevUrl = null;
+ } else {
+ if (!!filter.applicationId) {
+ this.filter_description = `Application: ${filter.name}`;
+ this.prevUrl = 'applications';
+ } else if (!!filter.organizationId) {
+ this.filter_description = `Organization: ${filter.name}`;
+ this.prevUrl = 'organizations';
+ } else if (!!filter.licenseTypeId) {
+ this.filter_description = `License type: ${filter.name}`;
+ this.prevUrl = 'licensetypes';
+ } else {
+ this.filter_description = '';
+ this.prevUrl = null;
+ }
+ }
}
packAction(action: string, pack: any) {
@@ -113,10 +144,13 @@
this.sortOrder = sortEvent.order;
this.refresh();
}
-
+
ngAfterViewInit(): void {
- this.reload();
this.media.broadcast();
+ this.route.queryParams.subscribe(params => {
+ let filter = params as PacksFilter;
+ this.reload(filter);
+ });
}
}
-
+
--
Gitblit v1.3.2