Home page carousel
[eliot.git] / blueprints / common / eliot-ui / frontend-src / src / app / nodes / nodes.component.ts
index 0e3e6e1..31d87b9 100644 (file)
@@ -1,10 +1,21 @@
-import { Component, OnInit, ViewChild } from '@angular/core';
+import { Component, OnInit, ViewChild, Inject } from '@angular/core';
 import { MatPaginator } from '@angular/material/paginator';
-import {MatTableDataSource} from '@angular/material/table';
+import { MatTableDataSource } from '@angular/material/table';
 import { nodeDetailss, nodinfo } from './../../app/datainterface';
 import { nodeDetails } from './../datainterface';
-import { MyserviceService } from './../myservice.service';
+import { EliotserviceService } from '../eliotservice.service';
 
+import { NgxPermissionsService } from 'ngx-permissions';
+
+import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
+
+// import { DialogOverviewExampleDialog } from './../nodes';
+import { debug } from 'util';
+
+export interface DialogData {
+  animal: string;
+  name: string;
+}
 
 @Component({
   selector: 'app-nodes',
@@ -12,30 +23,52 @@ import { MyserviceService } from './../myservice.service';
   styleUrls: ['./nodes.component.scss']
 })
 
-
-
 export class NodesComponent implements OnInit {
-
+  animal: string;
+  name: string;
   nodeInfo = {} as nodeDetails;
 
   nodeArray = {} as nodinfo;
   display: boolean;
   message: string;
   variable: any;
+  role =  [];
+  hide = true;
 
   nodeColumns: string [] = ['nodeName','nodeStatus','nodeRole','age','version','internalIp','externalIp','osImage','kernel','containerRuntime'];
 
   nodeDataSource= new MatTableDataSource<nodinfo>(NODE_INFO_LIST);
   nodeArrayList = [];
 
+  addNode: boolean;
+  deleteNode: boolean;
+  editNode: boolean;
+
   @ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
 
-  constructor(private serviceobj:MyserviceService) { }
+  constructor(
+    private serviceobj:EliotserviceService,
+    public nodeDialog: MatDialog,
+    private permissionsService: NgxPermissionsService
+  ) { }
 
   ngOnInit() {
     this.display = true;
-    this.nodeDataSource.paginator = this.paginator;
+    
     this.getNodes();
+    this.nodeDataSource.paginator = this.paginator;
+    this.addNode = true;
+    this.editNode = true;
+    this.deleteNode = true;
+
+    this.role[0] = sessionStorage.getItem('roleName');
+    debugger;
+    // this.role[0] = perm[1];
+     debugger;
+    this.permissionsService.loadPermissions(this.role);
+    
+    console.log(this.role);
+    
   }
 
   nodeFilter(filterValue: string) {
@@ -43,7 +76,6 @@ export class NodesComponent implements OnInit {
   }
 
   getNodes() {
-
     this.serviceobj.getNodesInfoo()
        .subscribe(data => {
         debugger;
@@ -51,11 +83,44 @@ export class NodesComponent implements OnInit {
         this.nodeArrayList = this.nodeInfo.eliotNodes;
         this.nodeDataSource = new MatTableDataSource(this.nodeArrayList);
         this.nodeDataSource.paginator = this.paginator;
-        
        },
        error => console.log(error));
   }
 
+  addNodeDialog() {
+    this.addNode = true;
+    debugger;
+    this.openDialog();
+  }
+
+  deleteNodeDialog() {
+    this.deleteNode = true;
+    debugger;
+    this.openDialog();
+  }
+
+  editNodeDialog() {
+    this.editNode = true;
+    debugger;
+    this.openDialog();
+  }
+
+  // dialogChoose() {
+  //   this.openDialog();  
+  // }
+
+  openDialog(): void {
+    const dialogRef = this.nodeDialog.open(DialogOverviewExampleDialog, {
+      width: '380px',
+      data: {name: this.name, animal: this.animal}
+    });
+
+    dialogRef.afterClosed().subscribe(result => {
+      console.log('The dialog was closed');
+      this.animal = result;
+    });
+  }
+
 }
 
 const NODE_LIST: nodeDetailss[] = [
@@ -67,3 +132,32 @@ const NODE_LIST: nodeDetailss[] = [
 const NODE_INFO_LIST: nodinfo[] = [
   { nodeName: '', nodeStatus: '', nodeRole: '', age: '', version: '', internalIp: '', externalIp: '', osImage: '', kernel: '', containerRuntime: ''}
 ];
+
+const perm = ["ADMIN", "DEVELOPER"];
+
+
+
+
+
+
+
+
+@Component({
+  selector: 'dialog-overview-example-dialog',
+  templateUrl: 'dialog-overview-example-dialog.html',
+})
+export class DialogOverviewExampleDialog {
+
+  credential = "ELIOT EDGE NODE Credentials";
+  hide = true;
+  constructor(
+    public dialogRef: MatDialogRef<DialogOverviewExampleDialog>,
+    @Inject(MAT_DIALOG_DATA) public data: DialogData) {}
+
+  onNoClick(): void {
+    this.dialogRef.close();
+  }
+
+  
+
+}
\ No newline at end of file