Skip to content

Commit

Permalink
restart statues
Browse files Browse the repository at this point in the history
  • Loading branch information
oznu committed Oct 13, 2020
1 parent 97f59d9 commit 411261c
Show file tree
Hide file tree
Showing 31 changed files with 125 additions and 35 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ All notable changes to this project will be documented in this file. This projec
* Click the Homebridge version on the status dashboard to access this feature
* **Config Editor:** Automatic backups of the `config.json` file are now saved to `./backups/config-backups/` to reduce clutter in the Homebridge storage folder ([#732](https://github.com/oznu/homebridge-config-ui-x/pull/732))
* Existing config backup files will be moved on next restart
* **System:** Made it more obvious when Homebridge needs to be restarted, and which button to click to restart Homebridge
* **Restart:** Made it more obvious which button to click when you need to restart Homebridge
* **Restart:** The restart page now shows separate statues for the UI and Homebridge
* **Restart:** Users running with [`hb-service`](https://github.com/oznu/homebridge-config-ui-x/wiki/Homebridge-Service-Command) will now be prompted to view the Homebridge logs if the Homebridge service is taking a long time to come back online after a restart
* **i18n:** Brazillian Portuguese (pt-BR) language added by [@zearthur99](https://github.com/zearthur99) ([#880](https://github.com/oznu/homebridge-config-ui-x/pull/880))
* The Homebridge UI is now available in 21 different languages!

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "homebridge-config-ui-x",
"displayName": "Homebridge Config UI X",
"version": "4.29.0-test.9",
"version": "4.29.0-test.10",
"description": "A web based management, configuration and control platform for Homebridge",
"license": "MIT",
"author": "oznu <dev@oz.nu>",
Expand Down
4 changes: 2 additions & 2 deletions src/modules/server/server.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class ServerService {
process.emit('message', 'restartHomebridge', undefined);
// reset the pool of discovered homebridge instances
this.accessoriesService.resetInstancePool();
return { ok: true, command: 'SIGTERM' };
return { ok: true, command: 'SIGTERM', restartingUI: false };
}

setTimeout(() => {
Expand All @@ -54,7 +54,7 @@ export class ServerService {
}
}, 500);

return { ok: true, command: this.configService.ui.restart };
return { ok: true, command: this.configService.ui.restart, restartingUI: true };
}

/**
Expand Down
1 change: 1 addition & 0 deletions ui/src/app/core/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ import { Subject } from 'rxjs';
})
export class NotificationService {
readonly configUpdated = new Subject();
readonly restartTriggered = new Subject();
}
44 changes: 39 additions & 5 deletions ui/src/app/modules/restart/restart.component.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,47 @@
<app-spinner *ngIf="!error"></app-spinner>

<div class="row">
<div class="col-md-12 text-center">
<h3 class="primary-text" [translate]="'restart.title_restart'">Restarting Homebridge</h3>
<p class="grey-text" *ngIf="!timeout && !error" [translate]="'restart.message_please_wait_while_server_restarts'">Please wait, this page will automatically redirect when the server is back online.</p>
<p class="grey-text" *ngIf="!timeout && !error" [translate]="'restart.message_please_wait_while_server_restarts'">
Please wait, this page will automatically redirect when the server is back online.</p>
<p class="grey-text" *ngIf="error">{{ error }}</p>
<div *ngIf="timeout">
<p class="grey-text" [translate]="'restart.message_server_is_taking_long_time_to_restart'">Server restart is taking a long time. You may need to bring up the Homebridge service manually.</p>
<p class="grey-text"><span [translate]="'restart.label_restart_command_executed'">Restart Command Executed</span>: {{ resp.command || "End Process" }}</p>
<p class="grey-text" [translate]="'restart.message_server_is_taking_long_time_to_restart'">
Server restart is taking a long time. You may need to bring up the Homebridge service manually.
</p>
<p class="grey-text">
<span [translate]="'restart.label_restart_command_executed'">Restart Command Executed</span>:
{{ resp.command || "End Process" }}
</p>
<p *ngIf="uiOnline">
<button class="btn btn-primary" (click)="viewLogs()">
{{ 'menu.tooltip_view_logs' | translate }}
</button>
</p>
</div>
</div>
</div>

<div class="row mt-4" *ngIf="!this.error">
<div class="col-md-12 d-flex justify-content-center">
<div>

<div class="restart-progress-box text-center primary-text">
<span>
<i [ngClass]="{
'fas fa-spinner fa-spin': !uiOnline,
'far fa-check-circle': uiOnline
}"></i> {{ 'restart.message_homebridge_ui_online' | translate }}
</span>
</div>

<div class="restart-progress-box text-center primary-text">
<span [ngClass]="{ 'grey-text': !uiOnline }">
<i [ngClass]="{
'far fa-pause-circle': !uiOnline,
'fas fa-spinner fa-spin': uiOnline
}"></i> {{ 'restart.message_homebridge_service_ready' | translate }}
</span>
</div>
</div>
</div>
</div>
4 changes: 4 additions & 0 deletions ui/src/app/modules/restart/restart.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.restart-progress-box {
font-size: 25px;
margin-top: 15px;
}
26 changes: 22 additions & 4 deletions ui/src/app/modules/restart/restart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { ToastrService } from 'ngx-toastr';

import { ApiService } from '../../core/api.service';
import { WsService } from '../../core/ws.service';
import { AuthService } from '../../core/auth/auth.service';
import { ApiService } from '@/app/core/api.service';
import { WsService } from '@/app/core/ws.service';
import { AuthService } from '@/app/core/auth/auth.service';
import { NotificationService } from '@/app/core/notification.service';

@Component({
selector: 'app-restart',
templateUrl: './restart.component.html',
styleUrls: [
'./restart.component.scss',
],
})
export class RestartComponent implements OnInit, OnDestroy {
private io = this.$ws.connectToNamespace('status');
Expand All @@ -20,16 +24,22 @@ export class RestartComponent implements OnInit, OnDestroy {
timeout = false;
error: any = false;

public uiOnline = false;
public homebridgeOnline = false;

constructor(
private $api: ApiService,
private $ws: WsService,
private $auth: AuthService,
private $notification: NotificationService,
public $toastr: ToastrService,
private translate: TranslateService,
private $router: Router,
) { }

ngOnInit() {
this.$notification.restartTriggered.next();

this.io.connected.subscribe(() => {
this.io.socket.emit('monitor-server-status');
this.$auth.getAppSettings().catch(/* do nothing */);
Expand All @@ -39,6 +49,9 @@ export class RestartComponent implements OnInit, OnDestroy {
data => {
this.resp = data;
this.checkIfServerUp();
if (!data.restartingUI) {
this.uiOnline = true;
}
},
err => {
const toastRestartError = this.translate.instant('restart.toast_server_restart_error');
Expand All @@ -52,12 +65,13 @@ export class RestartComponent implements OnInit, OnDestroy {
this.checkDelay = setTimeout(() => {
// listen to homebridge-status events to see when it's back online
this.io.socket.on('homebridge-status', (data) => {
this.uiOnline = true;
if (data.status === 'up') {
this.$toastr.success(this.translate.instant('restart.toast_server_restarted'), this.translate.instant('toast.title_success'));
this.$router.navigate(['/']);
}
});
}, 5000);
}, 7000);

this.checkTimeout = setTimeout(() => {
this.$toastr.warning(this.translate.instant('restart.toast_sever_restart_timeout'), this.translate.instant('toast.title_warning'), {
Expand All @@ -67,6 +81,10 @@ export class RestartComponent implements OnInit, OnDestroy {
}, 40000);
}

viewLogs() {
this.$router.navigate(['/logs']);
}

ngOnDestroy() {
this.io.end();

Expand Down
3 changes: 1 addition & 2 deletions ui/src/app/shared/layout/layout.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
</li>
<li class="nav-item waves-effect waves-light" routerLinkActive="active" placement="bottom"
ngbTooltip="{{'menu.tooltip_restart' | translate}}" container="body">
<a class="nav-link" routerLink="/restart" [ngbPopover]="'plugins.settings.toast_restart_required' | translate"
triggers="manual" #restartHelpPopover="ngbPopover" container="body" placement="left">
<a class="nav-link" routerLink="/restart">
<i #restartHomebridgeIcon class="fas fa-power-off nav-menu-icon"></i>
</a>
</li>
Expand Down
26 changes: 8 additions & 18 deletions ui/src/app/shared/layout/layout.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class LayoutComponent implements OnInit {
private io = this.$ws.connectToNamespace('app');

@ViewChild('restartHomebridgeIcon') restartHomebridgeIcon: ElementRef;
@ViewChild('restartHelpPopover') public restartHelpPopover: NgbPopover;

constructor(
public translate: TranslateService,
Expand All @@ -39,29 +38,20 @@ export class LayoutComponent implements OnInit {
this.$auth.checkToken();
});

this.$notification.configUpdated.pipe(throttleTime(60000)).subscribe(() => {
this.$notification.configUpdated.pipe(throttleTime(15000)).subscribe(() => {
// highlight the homebridge restart icon
const element = (this.restartHomebridgeIcon.nativeElement as HTMLElement);
element.classList.add('uix-highlight-icon');
setTimeout(() => {
element.classList.remove('uix-highlight-icon');
}, 15000);

// popup message next to homebridge restart icon
const scrollListener = () => {
console.log('listening to scroll');
this.restartHelpPopover.close();
window.removeEventListener('scroll', scrollListener);
};

window.addEventListener('scroll', scrollListener);
}, 14900);
});

if (window.innerWidth >= 992) {
this.restartHelpPopover.open();
setTimeout(() => {
window.removeEventListener('scroll', scrollListener);
this.restartHelpPopover.close();
}, 5000);
this.$notification.restartTriggered.subscribe(() => {
// ensure restart icon is not highlighted when restart is triggered
const element = (this.restartHomebridgeIcon?.nativeElement as HTMLElement);
if (element) {
element.classList.remove('uix-highlight-icon');
}
});
}
Expand Down
2 changes: 2 additions & 0 deletions ui/src/i18n/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@
"reset.toast_failed_to_reset": "Неуспешно нулиране на Homebridge. Виж лог.",
"reset.toast_removing_cached_accessory_please_wait": "Removing accessory from cache, please wait...",
"restart.label_restart_command_executed": "Командата за рестартиране е изпълнена",
"restart.message_homebridge_service_ready": "Homebridge Server Ready",
"restart.message_homebridge_ui_online": "Homebridge UI Online",
"restart.message_please_wait_while_server_restarts": "Моля, изчакайте, тази страница автоматично ще се пренасочи, когато сървърът отново е онлайн.",
"restart.message_server_is_taking_long_time_to_restart": "Рестартирането на сървъра отнема много време. Може да се наложи да стартирате услугата Homebridge ръчно.",
"restart.title_restart": "Рестартиране на Homebridge",
Expand Down
2 changes: 2 additions & 0 deletions ui/src/i18n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@
"reset.toast_failed_to_reset": "Resetování Homebridge se nezdařilo. Viz log.",
"reset.toast_removing_cached_accessory_please_wait": "Odebírání příslušenství z cache, čekejte prosím...",
"restart.label_restart_command_executed": "Příkaz restartování spuštěn",
"restart.message_homebridge_service_ready": "Homebridge Server Ready",
"restart.message_homebridge_ui_online": "Homebridge UI Online",
"restart.message_please_wait_while_server_restarts": "Čekejte prosím, tato stránka se automaticky přesměruje, když bude server znovu online.",
"restart.message_server_is_taking_long_time_to_restart": "Restartování serveru trvá dlouhou dobu. Možná budete muset ručně spustit službu Homebridge.",
"restart.title_restart": "Restartování Homebridge",
Expand Down
2 changes: 2 additions & 0 deletions ui/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@
"reset.toast_failed_to_reset": "Homebridge konnte nicht zurückgesetzt werden. Siehe Protokoll.",
"reset.toast_removing_cached_accessory_please_wait": "Gerät aus dem Cache entfernen, bitte warten ...",
"restart.label_restart_command_executed": "Neustart angestoßen",
"restart.message_homebridge_service_ready": "Homebridge Server Ready",
"restart.message_homebridge_ui_online": "Homebridge UI Online",
"restart.message_please_wait_while_server_restarts": "Bitte warte, du wirst automatisch umgeleitet, wenn der Server wieder online ist.",
"restart.message_server_is_taking_long_time_to_restart": "Der Neustart des Servers dauert länger als gewöhnlich. Möglicherweise muss der Homebridge-Dienst manuell gestartet werden.",
"restart.title_restart": "Homebridge neustarten",
Expand Down
4 changes: 3 additions & 1 deletion ui/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@
"reset.toast_failed_to_reset": "Failed to reset Homebridge. See Logs.",
"reset.toast_removing_cached_accessory_please_wait": "Removing accessory from cache, please wait...",
"restart.label_restart_command_executed": "Restart Command Executed",
"restart.message_homebridge_service_ready": "Homebridge Server Ready",
"restart.message_homebridge_ui_online": "Homebridge UI Online",
"restart.message_please_wait_while_server_restarts": "Please wait, this page will automatically redirect when the server is back online.",
"restart.message_server_is_taking_long_time_to_restart": "Server restart is taking a long time. You may need to bring up the Homebridge service manually.",
"restart.title_restart": "Restarting Homebridge",
Expand Down Expand Up @@ -342,4 +344,4 @@
"users.toast_failed_to_update_user": "Failed To Update User",
"users.toast_updated_user": "Updated User",
"users.toast_user_deleted": "User Deleted"
}
}
2 changes: 2 additions & 0 deletions ui/src/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@
"reset.toast_failed_to_reset": "Error al reiniciar Homebridge. Mira los logs.",
"reset.toast_removing_cached_accessory_please_wait": "Eliminando accesorio de la caché, por favor espera...",
"restart.label_restart_command_executed": "Comando de reinicio ejecutado",
"restart.message_homebridge_service_ready": "Homebridge Server Ready",
"restart.message_homebridge_ui_online": "Homebridge UI Online",
"restart.message_please_wait_while_server_restarts": "Por favor, espera, esta página te redireccionará automáticamente cuando el servidor vuelva a estar disponible.",
"restart.message_server_is_taking_long_time_to_restart": "El reinicio está tardando demasiado tiempo. Quizá debas iniciar Homebridge de forma manual.",
"restart.title_restart": "Reiniciando Homebridge.",
Expand Down
2 changes: 2 additions & 0 deletions ui/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@
"reset.toast_failed_to_reset": "Erreur lors de la réinitialisation d'Homebridge. Regarder les Logs.",
"reset.toast_removing_cached_accessory_please_wait": "Suppression de l'accessoire du cache, patientez SVP...",
"restart.label_restart_command_executed": "Commande de redémarrage exécutée",
"restart.message_homebridge_service_ready": "Homebridge Server Ready",
"restart.message_homebridge_ui_online": "Homebridge UI Online",
"restart.message_please_wait_while_server_restarts": "Merci de patienter, cette page redirigera automatiquement quand le serveur sera de nouveau en ligne.",
"restart.message_server_is_taking_long_time_to_restart": "Le redémarrage du serveur met beaucoup de temps. Vous aurez peut-être besoin de démarrer le service Homebridge manuellement.",
"restart.title_restart": "Redémarrage d'Homebridge",
Expand Down
2 changes: 2 additions & 0 deletions ui/src/i18n/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@
"reset.toast_failed_to_reset": "Nem sikerült resetelni a Homebridge-t. Logok megtekintése.",
"reset.toast_removing_cached_accessory_please_wait": "Removing accessory from cache, please wait...",
"restart.label_restart_command_executed": "Újraindítás kérelem kiküldve",
"restart.message_homebridge_service_ready": "Homebridge Server Ready",
"restart.message_homebridge_ui_online": "Homebridge UI Online",
"restart.message_please_wait_while_server_restarts": "Kérjük várjon, ez az oldal automatikusan frissül, amint visszatér a szerver.",
"restart.message_server_is_taking_long_time_to_restart": "Túl sokáig tart a szerver újraindítása. Kézi módon kellene a Homebridge szervizt újraindítani",
"restart.title_restart": "Homebridge újraindítása",
Expand Down
2 changes: 2 additions & 0 deletions ui/src/i18n/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@
"reset.toast_failed_to_reset": "Gagal mengatur-ulang Homebridge. Lihat catatan.",
"reset.toast_removing_cached_accessory_please_wait": "Menghapus aksesoris dari cache, harap tunggu...",
"restart.label_restart_command_executed": "Perintah mengulang kembali Dieksekusi",
"restart.message_homebridge_service_ready": "Homebridge Server Ready",
"restart.message_homebridge_ui_online": "Homebridge UI Online",
"restart.message_please_wait_while_server_restarts": "Harap tunggu, halaman ini akan secara otomatis mengarahkan ulang ketika server kembali online.",
"restart.message_server_is_taking_long_time_to_restart": "Mengulang kembali server membutuhkan waktu lebih lama. Anda mungkin perlu menjalankan layanan Homebridge secara manual.",
"restart.title_restart": "Mengulang Kembali Homebridge",
Expand Down
2 changes: 2 additions & 0 deletions ui/src/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@
"reset.toast_failed_to_reset": "Impossibile ripristinare Homebridge. Controlla i log.",
"reset.toast_removing_cached_accessory_please_wait": "Cancello l'accessorio dalla cache, attendi...",
"restart.label_restart_command_executed": "Riavvio richiesto",
"restart.message_homebridge_service_ready": "Homebridge Server Ready",
"restart.message_homebridge_ui_online": "Homebridge UI Online",
"restart.message_please_wait_while_server_restarts": "Attendi, questa pagina verrà reindirizzata automaticamente quando il sistema sarà di nuovo online.",
"restart.message_server_is_taking_long_time_to_restart": "Il riavvio del sistema richiede molto tempo. Potrebbe essere necessario riavviare manualmente Homebridge.",
"restart.title_restart": "Riavvio Homebridge",
Expand Down
2 changes: 2 additions & 0 deletions ui/src/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@
"reset.toast_failed_to_reset": "ホームページの再読み込みに失敗しました。ログを確認してください。",
"reset.toast_removing_cached_accessory_please_wait": "Removing accessory from cache, please wait...",
"restart.label_restart_command_executed": "再起動コマンドが実行されました",
"restart.message_homebridge_service_ready": "Homebridge Server Ready",
"restart.message_homebridge_ui_online": "Homebridge UI Online",
"restart.message_please_wait_while_server_restarts": "このページはサーバーがオンラインに復帰すると自動でリダイレクトします。しばらくお待ちください。",
"restart.message_server_is_taking_long_time_to_restart": "サーバーの再起動に時間がかかっています。手動でサーバーを再起動する必要がある可能性があります。",
"restart.title_restart": "再起動しています",
Expand Down
2 changes: 2 additions & 0 deletions ui/src/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@
"reset.toast_failed_to_reset": "Kon Homebridge niet resetten. Zie Logs.",
"reset.toast_removing_cached_accessory_please_wait": "Accessoire van cache aan het verwijderen, even geduld...",
"restart.label_restart_command_executed": "Herstart Commando Uitgevoerd",
"restart.message_homebridge_service_ready": "Homebridge Server Ready",
"restart.message_homebridge_ui_online": "Homebridge UI Online",
"restart.message_please_wait_while_server_restarts": "Even geduld aub, deze pagina zal automatisch doorverwijzen wanneer de server weer online is.",
"restart.message_server_is_taking_long_time_to_restart": "Het opnieuw opstarten van de server duurt te lang. Mogelijk moet u de Homebridge-service handmatig starten.",
"restart.title_restart": "Homebridge Herstarten",
Expand Down
Loading

0 comments on commit 411261c

Please sign in to comment.