Skip to content

Commit

Permalink
add child bridge restart
Browse files Browse the repository at this point in the history
  • Loading branch information
donavanbecker committed Nov 8, 2023
1 parent c331caf commit de064b6
Show file tree
Hide file tree
Showing 30 changed files with 106 additions and 46 deletions.
8 changes: 6 additions & 2 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"watch": [
"src"
"src",
"ui"
],
"ext": [
"ts",
"html"
],
"ext": "ts",
"ignore": [
"src/**/*.spec.ts"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ <h5 class="modal-title">{{ presentTenseVerb }}: {{ pluginName }}</h5>
<h3 class="text-center primary-text" [translate]="'platform.version.title_service_restart_required'">
Restart Required
</h3>
<p class="text-center grey-text" translate="plugins.manage.message_thanks_for_updating" [translateParams]="{ pluginName: pluginName, targetVersion: targetVersion }"></p>
<p *ngIf="!['homebridge', 'homebridge-config-ui-x'].includes(pluginName)" class="text-center grey-text" [translate]="'plugins.manage.message_thanks_for_updating_restart'">
Please restart Homebridge for the changes to apply. Alternatively, if you have this plugin running in child bridges, you can close this modal and restart these instead.
<p class="text-center grey-text" translate="plugins.manage.message_thanks_for_updating"
[translateParams]="{ pluginName: pluginName, targetVersion: targetVersion }"></p>
<p *ngIf="!['homebridge', 'homebridge-config-ui-x'].includes(pluginName)" class="text-center grey-text"
[translate]="'plugins.manage.message_thanks_for_updating_restart'">
Please restart Homebridge for the changes to apply. Alternatively, if you have this plugin running in child
bridges, you can close this modal and restart these instead.
</p>
<div class="text-center">
<button type="button" class="btn btn-primary" (click)="onRestartChildBridgeClick(item._bridge?.username)"
[translate]="'plugins.manage.child_bridge_button_restart_now'">Restart Child Bridge Now</button>
<button type="button" class="btn btn-primary" (click)="onRestartHomebridgeClick()"
[translate]="'plugins.manage.button_restart_now'">Restart Homebridge Now</button>
<button *ngIf="!['homebridge', 'homebridge-config-ui-x'].includes(pluginName)" type="button" class="btn btn-primary" data-dismiss="modal" (click)="activeModal.dismiss('Cross click')"
<button *ngIf="!['homebridge', 'homebridge-config-ui-x'].includes(pluginName)" type="button"
class="btn btn-primary" data-dismiss="modal" (click)="activeModal.dismiss('Cross click')"
[translate]="'form.button_close'">Close</button>
</div>
<hr>
Expand Down Expand Up @@ -53,4 +59,4 @@ <h5>{{ release.name }}</h5>
<button *ngIf="onlineUpdateOk && showReleaseNotes" type="button" class="btn btn-primary" (click)="update()"
[translate]="'plugins.button_update'">Update</button>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {

public onlineUpdateOk: boolean;

public childBridges = [];

constructor(
public activeModal: NgbActiveModal,
public $toastr: ToastrService,
private translate: TranslateService,
private $translate: TranslateService,
private $settings: SettingsService,
private $api: ApiService,
private $ws: WsService,
Expand All @@ -63,20 +65,20 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
this.term.write(data);
});

this.toastSuccess = this.translate.instant('toast.title_success');
this.toastSuccess = this.$translate.instant('toast.title_success');

this.onlineUpdateOk = !(['homebridge', 'homebridge-config-ui-x'].includes(this.pluginName) && this.$settings.env.platform === 'win32');

switch (this.action) {
case 'Install':
this.install();
this.presentTenseVerb = this.translate.instant('plugins.manage.label_install');
this.pastTenseVerb = this.translate.instant('plugins.manage.label_installed');
this.presentTenseVerb = this.$translate.instant('plugins.manage.label_install');
this.pastTenseVerb = this.$translate.instant('plugins.manage.label_installed');
break;
case 'Uninstall':
this.uninstall();
this.presentTenseVerb = this.translate.instant('plugins.manage.label_uninstall');
this.pastTenseVerb = this.translate.instant('plugins.manage.label_uninstalled');
this.presentTenseVerb = this.$translate.instant('plugins.manage.label_uninstall');
this.pastTenseVerb = this.$translate.instant('plugins.manage.label_uninstalled');
break;
case 'Update':
switch (this.targetVersion) {
Expand All @@ -91,8 +93,8 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
default:
this.update();
}
this.presentTenseVerb = this.translate.instant('plugins.manage.label_update');
this.pastTenseVerb = this.translate.instant('plugins.manage.label_updated');
this.presentTenseVerb = this.$translate.instant('plugins.manage.label_update');
this.pastTenseVerb = this.$translate.instant('plugins.manage.label_updated');
break;
}
}
Expand Down Expand Up @@ -122,7 +124,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
(err) => {
this.actionFailed = true;
this.$router.navigate(['/plugins']);
this.$toastr.error(err.message, this.translate.instant('toast.title_error'));
this.$toastr.error(err.message, this.$translate.instant('toast.title_error'));
},
);
}
Expand All @@ -140,7 +142,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
},
(err) => {
this.actionFailed = true;
this.$toastr.error(err.message, this.translate.instant('toast.title_error'));
this.$toastr.error(err.message, this.$translate.instant('toast.title_error'));
},
);
}
Expand Down Expand Up @@ -173,7 +175,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
},
(err) => {
this.actionFailed = true;
this.$toastr.error(err.message, this.translate.instant('toast.title_error'));
this.$toastr.error(err.message, this.$translate.instant('toast.title_error'));
},
);
}
Expand All @@ -191,7 +193,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
},
(err) => {
this.actionFailed = true;
this.$toastr.error(err.message, this.translate.instant('toast.title_error'));
this.$toastr.error(err.message, this.$translate.instant('toast.title_error'));
},
);
}
Expand Down Expand Up @@ -231,6 +233,27 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
this.activeModal.close();
}

getChildBridgeMetadata() {
this.io.request('get-homebridge-child-bridge-status').subscribe((data) => {
this.childBridges = data;
});
}

public async onRestartChildBridgeClick(bridge) {
bridge.restartInProgress = true;
try {
await this.io.request('restart-child-bridge', bridge.username).toPromise();
} catch (err) {
this.$toastr.error(
'Failed to restart bridge: ' + err.error?.message,
this.$translate.instant('toast.title_error'),
);
bridge.restartInProgress = false;
} finally {
this.activeModal.close();
}
}

ngOnDestroy() {
this.io.end();
}
Expand Down
3 changes: 2 additions & 1 deletion ui/src/i18n/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"plugins.donate.message_learn_more": "Learn more about donation links on plugins.",
"plugins.donate.tile_donate_to": "Donate to {{ author }}",
"plugins.manage.button_restart_now": "Рестартирай Homebridge сега",
"plugins.manage.child_bridge_button_restart_now": "Restart Child Bridge Now",
"plugins.manage.disable": "Disable",
"plugins.manage.enable": "Enable",
"plugins.manage.json_config": "JSON Config",
Expand Down Expand Up @@ -389,4 +390,4 @@
"users.toast_failed_to_delete_user": "Неуспешно изтриване на потребителя",
"users.toast_updated_user": "Потребителя е обновен",
"users.toast_user_deleted": "Потребителя е изтрит"
}
}
3 changes: 2 additions & 1 deletion ui/src/i18n/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"plugins.donate.message_learn_more": "Obteniu més informació sobre els enllaços de donació als plugins.",
"plugins.donate.tile_donate_to": "Donar a {{ author }}",
"plugins.manage.button_restart_now": "Reiniciar Homebridge ara",
"plugins.manage.child_bridge_button_restart_now": "Restart Child Bridge Now",
"plugins.manage.disable": "Desactivar",
"plugins.manage.enable": "Activar",
"plugins.manage.json_config": "Configuració JSON",
Expand Down Expand Up @@ -389,4 +390,4 @@
"users.toast_failed_to_delete_user": "Error a l'eliminar l'usuari",
"users.toast_updated_user": "Usuari actualitzat",
"users.toast_user_deleted": "Usuari eliminat"
}
}
3 changes: 2 additions & 1 deletion ui/src/i18n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"plugins.donate.message_learn_more": "Zjistěte více o odkazech podpory na pluginech.",
"plugins.donate.tile_donate_to": "Podpořit {{ author }}",
"plugins.manage.button_restart_now": "Restartujte Homebridge nyní",
"plugins.manage.child_bridge_button_restart_now": "Restart Child Bridge Now",
"plugins.manage.disable": "Disable",
"plugins.manage.enable": "Enable",
"plugins.manage.json_config": "JSON Config",
Expand Down Expand Up @@ -389,4 +390,4 @@
"users.toast_failed_to_delete_user": "Smazání uživatele se nezdařilo",
"users.toast_updated_user": "Uživatel byl aktualizovaný",
"users.toast_user_deleted": "Uživatel byl smazán"
}
}
3 changes: 2 additions & 1 deletion ui/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"plugins.donate.message_learn_more": "Erfahre mehr über Spenden-Links bei Plugins.",
"plugins.donate.tile_donate_to": "An {{ author }} spenden",
"plugins.manage.button_restart_now": "Jetzt neustarten",
"plugins.manage.child_bridge_button_restart_now": "Restart Child Bridge Now",
"plugins.manage.disable": "Deaktivieren",
"plugins.manage.enable": "Aktivieren",
"plugins.manage.json_config": "JSON Konfiguration",
Expand Down Expand Up @@ -389,4 +390,4 @@
"users.toast_failed_to_delete_user": "Fehler beim Löschen des Benutzers",
"users.toast_updated_user": "Benutzer aktualisiert",
"users.toast_user_deleted": "Benutzer gelöscht"
}
}
3 changes: 2 additions & 1 deletion ui/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"plugins.donate.message_learn_more": "Learn more about donation links on plugins.",
"plugins.donate.tile_donate_to": "Donate to {{ author }}",
"plugins.manage.button_restart_now": "Restart Homebridge Now",
"plugins.manage.child_bridge_button_restart_now": "Restart Child Bridge Now",
"plugins.manage.disable": "Disable",
"plugins.manage.enable": "Enable",
"plugins.manage.json_config": "JSON Config",
Expand Down Expand Up @@ -389,4 +390,4 @@
"users.toast_failed_to_delete_user": "Failed to Delete user",
"users.toast_updated_user": "Updated User",
"users.toast_user_deleted": "User Deleted"
}
}
3 changes: 2 additions & 1 deletion ui/src/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"plugins.donate.message_learn_more": "Aprender más sobre los enlaces de donación de los plugins.",
"plugins.donate.tile_donate_to": "Donar a {{ author }}",
"plugins.manage.button_restart_now": "Reiniciar Homebridge ahora",
"plugins.manage.child_bridge_button_restart_now": "Restart Child Bridge Now",
"plugins.manage.disable": "Deshabilitar",
"plugins.manage.enable": "Habilitar",
"plugins.manage.json_config": "JSON Config",
Expand Down Expand Up @@ -389,4 +390,4 @@
"users.toast_failed_to_delete_user": "Error al eliminar el usuario",
"users.toast_updated_user": "Usuario actualizado",
"users.toast_user_deleted": "Usuario eliminado"
}
}
3 changes: 2 additions & 1 deletion ui/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"plugins.donate.message_learn_more": "Informations à propos des dons pour les plugins.",
"plugins.donate.tile_donate_to": "Faire un don à {{ author }}",
"plugins.manage.button_restart_now": "Redémarrer Homebridge maintenant",
"plugins.manage.child_bridge_button_restart_now": "Restart Child Bridge Now",
"plugins.manage.disable": "Désactiver",
"plugins.manage.enable": "Activer",
"plugins.manage.json_config": "Config JSON",
Expand Down Expand Up @@ -389,4 +390,4 @@
"users.toast_failed_to_delete_user": "Erreur lors de la suppression de l'utilisateur",
"users.toast_updated_user": "Utilisateur mis à jour",
"users.toast_user_deleted": "Utilisateur supprimé"
}
}
3 changes: 2 additions & 1 deletion ui/src/i18n/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"plugins.donate.message_learn_more": "למה יותר על לינקי תרומה לתוספים",
"plugins.donate.tile_donate_to": "תרום ל {{ author }}",
"plugins.manage.button_restart_now": "אתחל הומברידג' עכשיו",
"plugins.manage.child_bridge_button_restart_now": "Restart Child Bridge Now",
"plugins.manage.disable": "לא פעיל",
"plugins.manage.enable": "מאופשר",
"plugins.manage.json_config": "הגדרות ג'סון",
Expand Down Expand Up @@ -389,4 +390,4 @@
"users.toast_failed_to_delete_user": "כשלון במחיקת משתמש",
"users.toast_updated_user": "משתמש עודכן",
"users.toast_user_deleted": "משתמש נמחק"
}
}
3 changes: 2 additions & 1 deletion ui/src/i18n/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"plugins.donate.message_learn_more": "Learn more about donation links on plugins.",
"plugins.donate.tile_donate_to": "Donate to {{ author }}",
"plugins.manage.button_restart_now": "Homebridge újraindítása most",
"plugins.manage.child_bridge_button_restart_now": "Restart Child Bridge Now",
"plugins.manage.disable": "Disable",
"plugins.manage.enable": "Enable",
"plugins.manage.json_config": "JSON Config",
Expand Down Expand Up @@ -389,4 +390,4 @@
"users.toast_failed_to_delete_user": "Probléma törléskor",
"users.toast_updated_user": "Felhasználó frissítve",
"users.toast_user_deleted": "Felhasználó törölve"
}
}
3 changes: 2 additions & 1 deletion ui/src/i18n/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"plugins.donate.message_learn_more": "Pelajari lebih lanjut tentang link donasi plugin.",
"plugins.donate.tile_donate_to": "Donasi ke {{ author }}",
"plugins.manage.button_restart_now": "Mengulang Kembali Homebridge Sekarang",
"plugins.manage.child_bridge_button_restart_now": "Restart Child Bridge Now",
"plugins.manage.disable": "Nonaktifkan",
"plugins.manage.enable": "Aktifkan",
"plugins.manage.json_config": "Konfigurasi JSON",
Expand Down Expand Up @@ -389,4 +390,4 @@
"users.toast_failed_to_delete_user": "Gagal Menghapus Pengguna",
"users.toast_updated_user": "Pengguna yang Diperbarui",
"users.toast_user_deleted": "Pengguna Dihapus"
}
}
3 changes: 2 additions & 1 deletion ui/src/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"plugins.donate.message_learn_more": "Scopri di più riguardo i link per le donazioni dei plugin.",
"plugins.donate.tile_donate_to": "Dona a {{ author }}",
"plugins.manage.button_restart_now": "Riavvia Homebridge adesso",
"plugins.manage.child_bridge_button_restart_now": "Restart Child Bridge Now",
"plugins.manage.disable": "Disattiva",
"plugins.manage.enable": "Attiva",
"plugins.manage.json_config": "Configurazione JSON",
Expand Down Expand Up @@ -389,4 +390,4 @@
"users.toast_failed_to_delete_user": "Impossibile eliminare utente",
"users.toast_updated_user": "Utente aggiornato",
"users.toast_user_deleted": "Utente eliminato"
}
}
3 changes: 2 additions & 1 deletion ui/src/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"plugins.donate.message_learn_more": "プラグインの寄付リンクについてさらに詳しく",
"plugins.donate.tile_donate_to": "{{ author }} に寄付する",
"plugins.manage.button_restart_now": "いますぐHomebridgeを再起動",
"plugins.manage.child_bridge_button_restart_now": "Restart Child Bridge Now",
"plugins.manage.disable": "Disable",
"plugins.manage.enable": "Enable",
"plugins.manage.json_config": "JSON Config",
Expand Down Expand Up @@ -389,4 +390,4 @@
"users.toast_failed_to_delete_user": "ユーザーの削除に失敗しました",
"users.toast_updated_user": "ユーザーを更新しました",
"users.toast_user_deleted": "ユーザーを削除しました"
}
}
3 changes: 2 additions & 1 deletion ui/src/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"plugins.donate.message_learn_more": "플러그인의 기부 링크에 대해 자세히 알아보기",
"plugins.donate.tile_donate_to": "{{ author }}에 기부",
"plugins.manage.button_restart_now": "지금 Homebridge 재시작",
"plugins.manage.child_bridge_button_restart_now": "Restart Child Bridge Now",
"plugins.manage.disable": "Disable",
"plugins.manage.enable": "Enable",
"plugins.manage.json_config": "JSON Config",
Expand Down Expand Up @@ -389,4 +390,4 @@
"users.toast_failed_to_delete_user": "사용자 삭제 실패",
"users.toast_updated_user": "사용자 정보 수정됨",
"users.toast_user_deleted": "사용자 삭제됨"
}
}
3 changes: 2 additions & 1 deletion ui/src/i18n/mk.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"plugins.donate.message_learn_more": "Дознај повеќе за донациски линкови.",
"plugins.donate.tile_donate_to": "Донирај на {{ author }}",
"plugins.manage.button_restart_now": "Рестартирај Homebridge",
"plugins.manage.child_bridge_button_restart_now": "Restart Child Bridge Now",
"plugins.manage.disable": "Disable",
"plugins.manage.enable": "Enable",
"plugins.manage.json_config": "JSON Config",
Expand Down Expand Up @@ -389,4 +390,4 @@
"users.toast_failed_to_delete_user": "Грешка при отстранување на корисник",
"users.toast_updated_user": "Ажурирај корисник",
"users.toast_user_deleted": "Корисникот е отстранет"
}
}
3 changes: 2 additions & 1 deletion ui/src/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"plugins.donate.message_learn_more": "Meer informatie over donatie links van plugins.",
"plugins.donate.tile_donate_to": "Doneer aan {{ author }}",
"plugins.manage.button_restart_now": "Herstart Homebridge Nu",
"plugins.manage.child_bridge_button_restart_now": "Restart Child Bridge Now",
"plugins.manage.disable": "Deactiveren",
"plugins.manage.enable": "Activeren",
"plugins.manage.json_config": "JSON Config",
Expand Down Expand Up @@ -389,4 +390,4 @@
"users.toast_failed_to_delete_user": "Kon gebruiker niet verwijderen",
"users.toast_updated_user": "Gebruiker Bijgewerkt",
"users.toast_user_deleted": "Gebruiker Verwijderd"
}
}
Loading

0 comments on commit de064b6

Please sign in to comment.