Commit 1d247143 authored by Jan Marchel's avatar Jan Marchel
Browse files

adding cleaning all byon nodes button

parent 861ad9c2
Pipeline #17661 failed with stage
in 2 minutes and 37 seconds
......@@ -13,6 +13,14 @@
Create new byon definition
</button>
<p>
<button color="warn" mat-raised-button
(click)="onCleanByonDefinitionsClick()">
<mat-icon>restart_alt</mat-icon>
Clean Byon Nodes
</button>
</p>
<mat-form-field>
<input matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
</mat-form-field>
......
......@@ -18,6 +18,8 @@ export class ByonListComponent extends ByonListCommonComponent implements OnInit
'diagnostic', 'sshConnection', 'edit', 'delete'];
byonDefinitionDialog: MatDialogRef<ByonDefinitionFormComponent>;
confirmationDialog: MatDialogRef<ConfirmationDialogComponent>;
preparationInProgress = false;
operationInfo = '';
constructor(private processOfferService: ProcessOfferService,
private dialog: MatDialog,
......@@ -29,6 +31,45 @@ export class ByonListComponent extends ByonListCommonComponent implements OnInit
localStorage.setItem('viewTitle', 'Byon definitions');
this.getByonDefinitionList();
}
onCleanByonDefinitionsClick() {
this.confirmationDialog = this.createConfirmationDialog();
this.confirmationDialog.afterClosed().subscribe(value => {
if (value) {
console.log(`Confirmed cleaning of databases.`);
this.cleanByon();
} else {
console.log(`Cancel cleaning of databases.`);
}
});
}
createConfirmationDialog(): MatDialogRef<ConfirmationDialogComponent> {
return this.dialog.open(ConfirmationDialogComponent, {
hasBackdrop: false,
data: {
title: 'Cleaning Byon Nodes',
message: `All data will be permanently deleted.
Do you want to continue?`
},
width: '30%'
});
}
private cleanByon() {
this.preparationInProgress = true;
this.operationInfo = 'Cleaning byon nodes definitions...';
this.byonService.cleanByon().subscribe(() => {
this.preparationInProgress = false;
this.snackBar.open(`Cleaning Byon Nodes successfully started`, 'Close', {duration: 10000});
this.operationInfo = '';
},
error1 => {
this.preparationInProgress = false;
this.operationInfo = '';
this.snackBar.open(`Problem by deleting Byon Nodes: ${error1.error.message}. Please, try again.`, 'Close',
{duration: 10000});
});
}
getByonDefinitionList() {
this.byonLoadingInProgress = true;
......
......@@ -102,4 +102,14 @@ export class ByonService {
e => console.log(`Error by getting byon enums:`, e))
);
}
cleanByon() {
const requestUrl = `${this.apiUrl}/cleanByon`;
return this.http.get(requestUrl, httpOptions).pipe(
tap((response: ByonEnums) => {
console.log(`Byon definitions successfully deleted`);
},
e => console.log(`Error by deleting byon definitions:`, e))
);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment