1 import { Component, OnInit, ViewChild, Output } from '@angular/core';
2 import {MatTableDataSource} from '@angular/material/table';
3 import {SelectionModel} from '@angular/cdk/collections';
5 import { historyInformation, historyDetails, historyPostInfo, fileDownload, currentDeployInfo, currentDeployDetails } from '../datainterface';
7 import { EliotserviceService } from '../eliotservice.service';
9 import { MatPaginator } from '@angular/material/paginator';
12 selector: 'app-history',
13 templateUrl: './history.component.html',
14 styleUrls: ['./history.component.scss']
16 export class HistoryComponent implements OnInit {
20 date: Date = new Date();
30 yamlfiles : string[] = ["yaml1","yaml2","yaml3","yaml4","yaml5","yaml6"];
32 historyColumns: string [] = ['select','date','csarPackage','yamlFile','status'];
34 historyJanColumns: string [] = ['select','date','yamlFile','status','download'];
36 historyDataSource = new MatTableDataSource<historyInformation>(HISTORY_INFO_LIST);
38 historyInfo = {} as historyDetails;
39 historyPostInfo = {} as historyPostInfo;
40 currentDeployDetail = {} as currentDeployDetails
45 postIdInfo = {} as fileDownload;
51 monthBool: boolean = false;
52 janBool: boolean = false;
55 currentStatus: boolean;
57 currentDeployColumns: string [] = ['appName','yamlName','nodeIp','runningStatus'];
58 currentDeployDataSource = new MatTableDataSource<currentDeployInfo>(CURRENT_DEPLOY_INFO_LIST);
59 currentDeployArrayList = [];
61 statusHistoryArray: string[] = ['Current History','Past History'];
62 statusSelected: string;
66 @ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
68 constructor(private serviceObj:EliotserviceService) { }
71 this.description = "Application Package (.csar) / Deployment Yaml History.....!"
73 this.months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
74 this.tempArray = Object.assign([], this.months);
75 this.getHistoryData();
76 this.currentHistoryData();
79 this.statusSelected = "Past History";
80 // this.currentStatus = true;
83 selectedStatus(event) {
86 if(event.value=="Current History"){
87 this.currentStatus = true;
88 this.getCurrentHistoryData()
90 if(event.value=="Past History"){
91 this.currentStatus = false;
95 selectedMonth(m: string){
96 this.sessionArr = JSON.parse(sessionStorage.getItem('datakey'));
98 this.historyDataSource = new MatTableDataSource<historyInformation>(HISTORY_INFO_LIST);
99 this.sessionArr.forEach(data => {
100 if (data.month == m) {
101 this.january.push(data);
102 this.historyDataSource = new MatTableDataSource(this.january);
107 clearMonth(m: string){
108 console.log("Inside clearMonth");
109 this.selectedMonth(m);
110 this.historyDataSource = new MatTableDataSource<historyInformation>(HISTORY_INFO_LIST);
115 this.monthBool == true;
116 if(this.monthBool == true){
117 console.log("Month bool is true...");
118 console.log(this.historyDataSource.data);
120 this.selection.selected.forEach( data => {
121 this.postIdInfo.id = data.id;
122 this.postIdInfo.fileName = data.yamlFile;
123 this.historyId.push(this.postIdInfo);
129 this.historyPostInfo.fileDownload = this.historyId;
132 this.serviceObj.postHistoryId(this.historyId).subscribe(
146 this.monthDetails = [
148 monthName: 'Jan - Monthwise Deployment Historical Data',
150 displayName: 'download',
154 monthName: 'Feb - Monthwise Deployment Historical Data',
156 displayName: 'download',
160 monthName: 'Mar - Monthwise Deployment Historical Data',
162 displayName: 'download',
166 monthName: 'Apr - Monthwise Deployment Historical Data',
168 displayName: 'download',
172 monthName: 'May - Monthwise Deployment Historical Data',
174 displayName: 'download',
178 monthName: 'Jun - Monthwise Deployment Historical Data',
180 displayName: 'download',
184 monthName: 'Jul - Monthwise Deployment Historical Data',
186 displayName: 'download',
190 monthName: 'Aug - Monthwise Deployment Historical Data',
192 displayName: 'download',
196 monthName: 'Sep - Monthwise Deployment Historical Data',
198 displayName: 'download',
202 monthName: 'Oct - Monthwise Deployment Historical Data',
204 displayName: 'download',
208 monthName: 'Nov - Monthwise Deployment Historical Data',
210 displayName: 'download',
214 monthName: 'Dec - Monthwise Deployment Historical Data',
216 displayName: 'download',
224 this.serviceObj.getHistoryInfo().subscribe(
226 this.historyInfo = data;
227 sessionStorage.setItem('datakey',JSON.stringify(this.historyInfo.eliotHistory));
229 this.sessionArr = JSON.parse(sessionStorage.getItem('datakey'));
237 getCurrentHistoryData() {
238 this.serviceObj.getCurrentDeployInfo()
241 this.currentDeployDetail = data;
242 this.currentDeployArrayList = this.currentDeployDetail.currentDeployArray;
243 this.currentDeployDataSource = new MatTableDataSource(this.currentDeployArrayList);
244 this.currentDeployDataSource.paginator = this.paginator;
246 error => console.log(error));
249 currentHistoryData() {
250 if(this.statusSelected=="Current History"){
251 this.currentStatus = true;
255 this.currentStatus = false;
259 selection = new SelectionModel<historyInformation>(true, []);
262 const numSelected = this.selection.selected.length;
263 const numRows = this.historyDataSource.data.length;
264 this.monthBool = true;
265 return numSelected === numRows;
269 this.isAllSelectedJan() ?
270 this.selection.clear() :
271 this.historyDataSource.data.forEach(row => this.selection.select(row));
274 checkboxLabelJan(row?: historyInformation): string {
276 return `${this.isAllSelectedJan() ? 'select' : 'deselect'} all`;
278 return `${this.selection.isSelected(row) ? 'deselect' : 'select'} row ${row.id + 1}`;
282 const HISTORY_INFO_LIST: historyInformation[] = [
283 { id:'', date:'',csarPackage:'',yamlFile:'', month:'', status:''}
286 const CURRENT_DEPLOY_INFO_LIST: currentDeployInfo[] = [
287 { deployId:'',appName: '', yamlName: '', nodeIp: '', runningStatus: ''}