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','status','ip','node']
19 appsDataSource = new MatTableDataSource<appsinfo>(APPS_INFO_LIST);
21 appsArrayList: appsinfo [];
23 pvsColumns: string [] = ['namespace','name','status','volume','storageclass','volumemode']
24 pvsDataSource = new MatTableDataSource<pvpvsinfo>(PVS_INFO_LIST);
26 pvsArrayList : pvpvsinfo [];
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;
76 this.appsDataSource = new MatTableDataSource(this.appsArrayList);
77 this.appsDataSource.paginator = this.paginator;
79 this.pvsArrayList = data.pvcData;
80 this.pvsDataSource = new MatTableDataSource(this.pvsArrayList);
81 this.pvsDataSource.paginator = this.paginator;
83 error => console.log(error));
86 getBackupsRestores() {
87 this.roboService.getBackupRestoreInfo()
92 this.backupsArrayList = data.backupsData;
93 this.backupsDataSource = new MatTableDataSource(this.backupsArrayList);
94 this.backupsDataSource.paginator = this.paginator;
96 this.restoresArrayList = data.restoresData;
97 this.restoresDataSource = new MatTableDataSource(this.restoresArrayList);
98 this.restoresDataSource.paginator = this.paginator;
100 error => console.log(error));
105 this.getBackupsRestores();
110 console.log("Inside postBackup.....")
111 this.backupData.backupName = this.selectedBackupName;
112 this.backupData.namespace = this.selectedNamespace;
113 this.showBackupSuccess()
114 this.roboService.postBackup(this.backupData)
117 if(data.responce == "success"){
118 this.showBackupSuccess();
122 ,error => console.log(error)
127 console.log("Inside postBackup.....")
129 this.restoreData.restoreName = this.selectedRestoreName;
130 this.restoreData.backupName = this.selectedBackupname;
131 this.showRestoreSuccess()
132 this.roboService.postRestore(this.restoreData)
135 if(data.responce == "success"){
136 this.showRestoreSuccess();
140 ,error => console.log(error)
144 showBackupSuccess() {
145 this.toastService.success('Backup Successful..','Backup Data');
148 showRestoreSuccess() {
149 this.toastService.success('Restore Successful..','Restore Data');
153 console.log("Inside simulateDisaster....")
154 this.roboService.disturbCluster()
159 error => console.log(error));
164 const APPS_INFO_LIST: appsinfo[] = [
165 { namespace: '',name: '', status: '', ip: '', node: ''}
168 const PVS_INFO_LIST: pvpvsinfo[] = [
169 { namespace: '',name: '', status: '', volume: '', storageclass: '', volumemode: '' }
172 const BACKUPS_INFO_LIST: backupsinfo[] = [
173 { name: '', status: '', errors: '', warnings: '', created: ''}
176 const RESTORES_INFO_LIST: restoresinfo[] = [
177 { name: '', backup: '', status: ''}
181 // "zone.js": "~0.10.2"