From 60c65f2110f65221bc3a71b2887667e78c53c53e Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Wed, 22 Mar 2017 17:44:16 +0000
Subject: [PATCH] #3527 fix - Added pack/license actions and a lot of bugfixing

---
 securis/src/main/webapp/src/app/listing/pack.list.component.ts |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 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 3060af9..42927b1 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 { ToastsManager } from 'ng2-toastr/ng2-toastr';
 import { MdDialog, MdDialogConfig } from '@angular/material';
 import {
     ITdDataTableColumn,
@@ -10,7 +11,7 @@
 import { IPageChangeEvent } from '@covalent/core';
 import { Component, ViewChild, AfterViewInit } from '@angular/core';
 import { TdMediaService } from '@covalent/core';
-import { PacksService } from '../resources/packs';
+import { PacksService, PACK_ACTIONS } from '../resources/packs';
 import { PackFormComponent } from '../forms/pack.form.component';
 import { LocaleService } from '../common/i18n';
 import { ListingBase } from './base';
@@ -57,17 +58,11 @@
     { name: 'licensetype_code', label: 'License type' },
     { name: 'organization_name', label: 'Organization' },
     { name: 'used_licenses', label: 'Licenses', tooltip: 'Initial/Available pack licenses' },
+    { name: 'status', label: 'Status', tooltip: 'Pack status' },
     { name: 'menu', label: '' }
   ];
 
-  pack_menu_options : any[] = [{
-    command: 'edit',
-    name: 'Edit'
-  },{
-    command: 'cancel',
-    name: 'Cancel'
-  }]
-  
+  pack_menu_options = PACK_ACTIONS;
 
   constructor(_dataTableService: TdDataTableService,
     private media: TdMediaService,
@@ -75,25 +70,30 @@
     private route: ActivatedRoute,
     private dialog: MdDialog,
     private $L: LocaleService,
+    private toaster: ToastsManager,
     private packForm: PackFormComponent,
     private packs: PacksService) {
       super(_dataTableService);
-      this.packs.get().subscribe(
-        (list : any[]) => {
-          this.data = list;
-          this.refresh();
-        },
-        (err: any) => console.error(err)
-      );
   }
 
-
-  packAction(action: any) {
-    console.log(action.command);
+  reload() : void  {
+    this.packs.get().subscribe(
+      (list : any[]) => {
+        this.data = list;
+        this.refresh();
+      },
+      (err: any) => console.error(err)
+    );
   }
 
-  isActionAvailable(pack : any) : boolean {
-    return true;
+  packAction(action: string, pack: any) {
+    return this.packs[action](pack.id).subscribe(
+      (actionResponse : any) => {
+        this.toaster.success(this.$L.get('Action "{}" executed successfully', action));
+        this.reload();
+      },
+      (err : any) => this.toaster.error(this.$L.get('Action "{}" failed', action))
+    );
   }
 
   showLicenses(pack: any) : void {
@@ -115,8 +115,8 @@
   }
 
   ngAfterViewInit(): void {
+    this.reload();
     this.media.broadcast();
-
   }
 }
 

--
Gitblit v1.3.2