Skip to content

Commit

Permalink
Revert "add child bridge restart"
Browse files Browse the repository at this point in the history
This reverts commit 2eef4ff.
  • Loading branch information
donavanbecker committed Nov 8, 2023
1 parent 2eef4ff commit 72b344f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,14 @@ <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 *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 @@ -64,4 +53,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 @@ -20,16 +20,9 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
@Input() pluginName;
@Input() targetVersion = 'latest';
@Input() action;
@Input() plugin;

private io = this.$ws.connectToNamespace('plugins');

public canConfigure = true;
public configBlocks: any[] = [];
public enabledBlocks: Record<number, boolean> = {};
public usernameCache: Map<number, string> = new Map();
public deviceInfo: Map<string, any> = new Map();

private term = new Terminal();
private termTarget: HTMLElement;
private fitAddon = new FitAddon();
Expand All @@ -39,7 +32,6 @@ 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 @@ -53,7 +45,6 @@ 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 All @@ -63,8 +54,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
this.term.loadAddon(this.fitAddon);
}

ngOnInit(): void {
this.loadPluginConfig();
ngOnInit() {
this.termTarget = document.getElementById('plugin-log-output');
this.term.open(this.termTarget);
this.fitAddon.fit();
Expand Down Expand Up @@ -107,32 +97,6 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
}
}

loadPluginConfig() {
this.$api.get(`/config-editor/plugin/${encodeURIComponent(this.plugin.name)}`).subscribe(
(configBlocks) => {
this.configBlocks = configBlocks;
for (const [i, block] of this.configBlocks.entries()) {
if (block._bridge && block._bridge.username) {
this.enabledBlocks[i] = true;
this.usernameCache.set(i, block._bridge.username);
this.getDeviceInfo(block._bridge.username);
}
}
},
(err) => {
this.canConfigure = false;
},
);
}

async getDeviceInfo(username: string) {
try {
this.deviceInfo[username] = await this.$api.get(`/server/pairings/${username.replace(/:/g, '')}`).toPromise();
} catch (e) {
this.deviceInfo[username] = false;
}
}

install() {
if (!this.onlineUpdateOk) {
return;
Expand Down Expand Up @@ -214,27 +178,6 @@ 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 72b344f

Please sign in to comment.