Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI for turning off the visor #1642

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class NodeActionsHelper {
returnButtonText: string;

private rebootSubscription: Subscription;
private shutdownSubscription: Subscription;
private updateSubscription: Subscription;

// Services this class need.
Expand Down Expand Up @@ -84,6 +85,12 @@ export class NodeActionsHelper {
actionName: 'reboot',
icon: 'rotate_right'
});

this.options.push({
name: 'actions.menu.turn-off',
actionName: 'shutdown',
icon: 'power_settings_new'
});
}

// TODO: remove if the option will not be added again. Delete the translatable strings too.
Expand Down Expand Up @@ -138,6 +145,8 @@ export class NodeActionsHelper {
this.runtimeLogs();
} else if (actionName === 'reboot') {
this.reboot();
} else if (actionName === 'shutdown') {
this.shutdown();
} else if (actionName === null) {
// Null is returned if the back button was pressed.
this.back();
Expand All @@ -151,6 +160,9 @@ export class NodeActionsHelper {
if (this.rebootSubscription) {
this.rebootSubscription.unsubscribe();
}
if (this.shutdownSubscription) {
this.shutdownSubscription.unsubscribe();
}
if (this.updateSubscription) {
this.updateSubscription.unsubscribe();
}
Expand All @@ -173,6 +185,25 @@ export class NodeActionsHelper {
});
}

shutdown() {
const confirmationDialog = GeneralUtils.createConfirmationDialog(this.dialog, 'actions.turn-off.confirmation');

confirmationDialog.componentInstance.operationAccepted.subscribe(() => {
confirmationDialog.componentInstance.showProcessing();

this.shutdownSubscription = this.nodeService.shutdown(this.currentNodeKey).subscribe(() => {
this.snackbarService.showDone('actions.turn-off.done');
confirmationDialog.close();

this.router.navigate(['nodes']);
}, (err: OperationError) => {
err = processServiceError(err);

confirmationDialog.componentInstance.showDone('confirmation.error-header-text', err.translatableErrorMsg);
});
});
}

update() {
const confirmationDialog = GeneralUtils.createConfirmationDialog(this.dialog, 'actions.update.confirmation');

Expand Down
7 changes: 7 additions & 0 deletions static/skywire-manager-src/src/app/services/node.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,13 @@ export class NodeService {
return this.apiService.post(`visors/${nodeKey}/restart`);
}

/**
* Turns off a node.
*/
shutdown(nodeKey: string): Observable<any> {
return this.apiService.post(`visors/${nodeKey}/shutdown`);
}

/**
* Checks if a node is currently being updated.
*/
Expand Down
5 changes: 5 additions & 0 deletions static/skywire-manager-src/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,17 @@
"config": "Configuration",
"update": "Update",
"reboot": "Reboot",
"turn-off": "Turn off",
"logs": "View logs"
},
"reboot": {
"confirmation": "Are you sure you want to reboot the visor?",
"done": "The visor is restarting."
},
"turn-off": {
"confirmation": "Are you sure you want to turn off the visor?",
"done": "The visor is shutting down."
},
"update": {
"confirmation": "A terminal will be opened in a new tab and the update procedure will be started automatically. Do you want to continue?"
},
Expand Down
5 changes: 5 additions & 0 deletions static/skywire-manager-src/src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,17 @@
"config": "Configuración",
"update": "Actualizar",
"reboot": "Reiniciar",
"turn-off": "Apagar",
"logs": "Ver logs"
},
"reboot": {
"confirmation": "¿Seguro que desea reiniciar el visor?",
"done": "El visor se está reiniciando."
},
"turn-off": {
"confirmation": "¿Seguro que desea apagar el visor?",
"done": "El visor se está apagando."
},
"update": {
"confirmation": "Una terminal será abierta en una nueva pestaña y el proceso de actualización iniciará automáticamente. ¿Desea continuar?"
},
Expand Down
5 changes: 5 additions & 0 deletions static/skywire-manager-src/src/assets/i18n/es_base.json
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,17 @@
"config": "Configuration",
"update": "Update",
"reboot": "Reboot",
"turn-off": "Turn off",
"logs": "View logs"
},
"reboot": {
"confirmation": "Are you sure you want to reboot the visor?",
"done": "The visor is restarting."
},
"turn-off": {
"confirmation": "Are you sure you want to turn off the visor?",
"done": "The visor is shutting down."
},
"update": {
"confirmation": "A terminal will be opened in a new tab and the update procedure will be started automatically. Do you want to continue?"
},
Expand Down