Skip to content

Commit

Permalink
add childbridge restart
Browse files Browse the repository at this point in the history
  • Loading branch information
donavanbecker committed Nov 2, 2023
1 parent af0da46 commit d4a6442
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@ <h3 class="text-center primary-text" [translate]="'platform.version.title_servic
<p class="text-center grey-text" [translate]="'plugins.manage.message_thanks_for_updating'">
Thanks for installing the latest version of {{ pluginName }}.
</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 *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 *ngIf="$settings.env.serviceMode" class="btn btn-primary waves-effect mr-0"
[disabled]="restartInProgress[item._bridge?.username]" ngbTooltip="{{'menu.tooltip_restart' | translate}}"
container="body" openDelay="150" (click)="restartChildBridge(item._bridge?.username)">
<i class="fas fa-fw nav-menu-icon" [ngClass]="{
'fa-power-off': !restartInProgress[item._bridge?.username],
'fa-spinner fa-pulse': restartInProgress[item._bridge?.username]
}"></i>
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 @@ -55,4 +66,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 @@ -32,6 +32,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
public showReleaseNotes = false;
public justUpdatedPlugin = false;
public updateToBeta = false;
public restartInProgress: Record<string, boolean> = {};
public changeLog: string;
public release;

Expand All @@ -45,6 +46,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
public activeModal: NgbActiveModal,
public $toastr: ToastrService,
private translate: TranslateService,
private $translate: TranslateService,
private $settings: SettingsService,
private $api: ApiService,
private $ws: WsService,
Expand Down Expand Up @@ -178,6 +180,27 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
);
}

async restartChildBridge(username: string) {
this.restartInProgress[username] = true;
try {
await this.$api.put(`/server/restart/${username.replace(/:/g, '')}`, {}).toPromise();
this.$toastr.success(
this.$translate.instant('child_bridge.toast_restart_requested'),
this.$translate.instant('toast.title_success'),
);
} catch (err) {
this.$toastr.error(
'Failed to restart bridge: ' + err.error?.message,
this.$translate.instant('toast.title_error'),
);
this.restartInProgress[username] = false;
} finally {
setTimeout(() => {
this.restartInProgress[username] = false;
}, 12000);
}
}

upgradeHomebridge() {
this.io.request('homebridge-update', {
version: this.targetVersion,
Expand Down

0 comments on commit d4a6442

Please sign in to comment.