Skip to content

Commit

Permalink
plugin card
Browse files Browse the repository at this point in the history
  • Loading branch information
bwp91 committed Nov 13, 2023
1 parent 6f00fc4 commit 71cd358
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h4 class="card-title mb-0">
placement="top" ngbTooltip="{{'plugins.status_update_available' | translate:plugin }}" container="body" [openDelay]="150">
<i class="fas fa-fw fa-arrow-alt-circle-up primary-text"></i>
</a>
<a href="javascript:void(0);" class="card-link ml-3" *ngIf="!hasChildBridges && !plugin.disabled && recommendChildBridge"
<a href="javascript:void(0);" class="card-link ml-3" *ngIf="!hasChildBridges && !plugin.disabled && recommendChildBridge && childBridgesLoaded"
ngbTooltip="{{'child_bridge.label_bridge_setup_child_bridges' | translate}}" placement="top" container="body"
[openDelay]="150" (click)="$plugin.bridgeSettings(plugin)">
<i class="fa-fw icon-button fas fa-fw fa-circle-exclamation primary-text"></i>
Expand Down
34 changes: 19 additions & 15 deletions ui/src/app/modules/plugins/plugin-card/plugin-card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class PluginCardComponent implements OnInit {
public childBridgeStatus = 'pending';
public childBridgeRestartInProgress = false;
public recommendChildBridge = false;
public childBridgesLoaded = false;

constructor(
public $plugin: ManagePluginsService,
Expand All @@ -45,7 +46,23 @@ export class PluginCardComponent implements OnInit {
private $settings: SettingsService,
) {}

ngOnInit(): void {}
ngOnInit(): void {
if (
!this.$settings.env.recommendChildBridges
|| !this.$settings.env.serviceMode
|| ['homebridge', 'homebridge-config-ui-x'].includes(this.plugin.name)
) {
this.recommendChildBridge = false;
return;
}
this.$api.get(`/plugins/config-schema/${encodeURIComponent(this.plugin.name)}`, {}).toPromise()
.then((schema) => {
this.recommendChildBridge = schema.pluginType === 'platform';
})
.catch(() => {
this.recommendChildBridge = false;
});
}

@Input() set childBridges(childBridges: any[]) {
this.hasChildBridges = childBridges.length > 0;
Expand All @@ -64,20 +81,7 @@ export class PluginCardComponent implements OnInit {
}

this._childBridges = childBridges;

if (
this.$settings.env.recommendChildBridges
&& this.$settings.env.serviceMode
&& !['homebridge', 'homebridge-config-ui-x'].includes(this.plugin.name)
) {
this.$api.get(`/plugins/config-schema/${encodeURIComponent(this.plugin.name)}`, {}).toPromise()
.then((schema) => {
this.recommendChildBridge = schema.pluginType === 'platform';
})
.catch(() => {
// ignore
});
}
this.childBridgesLoaded = true;
}

openFundingModal(plugin: any) {
Expand Down

0 comments on commit 71cd358

Please sign in to comment.