1 import { Component, OnInit, ViewChild } from '@angular/core';
3 import {MatTableDataSource} from '@angular/material/table';
4 import { MatPaginator } from '@angular/material/paginator';
5 import { RoboService } from './../../app/robo.service';
7 import { appsinfo,pvpvsinfo,backupsinfo,restoresinfo,backupData,restoreData } from './../../app/datainterface'
9 import { ToastrService } from 'ngx-toastr';
12 selector: 'app-backuprestore',
13 templateUrl: './backuprestore.component.html',
14 styleUrls: ['./backuprestore.component.scss']
16 export class BackuprestoreComponent implements OnInit {
18 appsColumns: string [] = ['namespace','name','ready','status','restarts','age','ip','node','nominatednode','readinessgates']
19 appsDataSource = new MatTableDataSource<appsinfo>(APPS_INFO_LIST);
23 pvsColumns: string [] = ['namespace','name','status','volume','capacity','accessmodes','storageclass','age','volumemode']
24 pvsDataSource = new MatTableDataSource<pvpvsinfo>(PVS_INFO_LIST);
28 backupsColumns: string [] = ['name','status','errors','warnings','created']
29 backupsDataSource = new MatTableDataSource<backupsinfo>(BACKUPS_INFO_LIST);
31 backupsArrayList = [];
33 restoresColumns: string [] = ['name','backup','status']
34 restoresDataSource = new MatTableDataSource<restoresinfo>(RESTORES_INFO_LIST);
36 restoresArrayList = [];
38 selectedNamespace : string
39 selectedBackupName : string
41 selectedRestoreName: string
42 selectedBackupname : string
46 backupData = {} as backupData
48 restoreData = {} as restoreData
50 @ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
53 private roboService: RoboService,
54 private toastService: ToastrService
58 this.selectedBackupName = "backup01"
59 this.selectedRestoreName = "restore01"
60 this.selectedNamespace = "default"
61 this.selectedBackupname = "backup01"
65 this.getBackupsRestores();
69 this.roboService.getAppsPvcsInfo()
74 this.appsArrayList = data.appsData;
75 this.appsDataSource = new MatTableDataSource(this.appsArrayList);
76 this.appsDataSource.paginator = this.paginator;
78 this.pvsArrayList = data.pvcData;
79 this.pvsDataSource = new MatTableDataSource(this.pvsArrayList);
80 this.pvsDataSource.paginator = this.paginator;
82 error => console.log(error));
85 getBackupsRestores() {
86 this.roboService.getBackupRestoreInfo()
91 this.backupsArrayList = data.backupsData;
92 this.backupsDataSource = new MatTableDataSource(this.backupsArrayList);
93 this.backupsDataSource.paginator = this.paginator;
95 this.restoresArrayList = data.restoresData;
96 this.restoresDataSource = new MatTableDataSource(this.restoresArrayList);
97 this.restoresDataSource.paginator = this.paginator;
99 error => console.log(error));
104 this.getBackupsRestores();
109 console.log("Inside postBackup.....")
110 this.backupData.backupName = this.selectedBackupName;
111 this.backupData.namespace = this.selectedNamespace;
112 this.showBackupSuccess()
113 this.roboService.postBackup(this.backupData)
116 if(data.responce == "success"){
117 this.showBackupSuccess();
121 ,error => console.log(error)
126 console.log("Inside postBackup.....")
128 this.restoreData.restoreName = this.selectedRestoreName;
129 this.restoreData.backupName = this.selectedBackupname;
130 this.showRestoreSuccess()
131 this.roboService.postRestore(this.restoreData)
134 if(data.responce == "success"){
135 this.showRestoreSuccess();
139 ,error => console.log(error)
143 showBackupSuccess() {
144 this.toastService.success('Backup Successful..','Backup Data');
147 showRestoreSuccess() {
148 this.toastService.success('Restore Successful..','Restore Data');
152 console.log("Inside simulateDisaster....")
153 this.roboService.disturbCluster()
158 error => console.log(error));
163 const APPS_INFO_LIST: appsinfo[] = [
164 { namespace: '',name: '', ready: '', status: '', restarts: '', age: '', ip: '', node: '', nominatednode: '', readinessgates: '' }
167 const PVS_INFO_LIST: pvpvsinfo[] = [
168 { namespace: '',name: '', status: '', volume: '', capacity: '', accessmodes: '', storageclass: '', age: '', volumemode: '' }
171 const BACKUPS_INFO_LIST: backupsinfo[] = [
172 { name: '', status: '', errors: '', warnings: '', created: ''}
175 const RESTORES_INFO_LIST: restoresinfo[] = [
176 { name: '', backup: '', status: ''}
180 // "zone.js": "~0.10.2"