Skip to content

Commit

Permalink
recommend child bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
bwp91 committed Nov 13, 2023
1 parent 0e57693 commit abc1c7f
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 113 deletions.
94 changes: 47 additions & 47 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@
"@types/tar": "^6.1.9",
"@types/tcp-port-used": "^1.0.4",
"@types/unzipper": "^0.10.9",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"babel-jest": "^29.7.0",
"bash-color": "^0.0.4",
"buffer-shims": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/core/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export class AuthService {
*/
private async saveUserFile(users: UserDto[]) {
// update the auth.json
return fs.writeJson(this.configService.authPath, users, { spaces: 4 });
return fs.writeJsonSync(this.configService.authPath, users, { spaces: 4 });
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/modules/backup/backup.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class BackupService {
}
} else {
// when not using a custom backup path, just ensure it exists
return fs.ensureDir(this.configService.instanceBackupPath);
return fs.ensureDirSync(this.configService.instanceBackupPath);
}
}

Expand Down Expand Up @@ -337,7 +337,7 @@ export class BackupService {
*/
async removeRestoreDirectory() {
if (this.restoreDirectory) {
return fs.remove(this.restoreDirectory);
return fs.removeSync(this.restoreDirectory);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/config-editor/config-editor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export class ConfigEditorService {
}

// read source backup
return fs.readFile(requestedBackupPath);
return fs.readFileSync(requestedBackupPath);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class PluginsSettingsUiService {
// dev server is only enabled for private plugins
return (await this.httpService.get(pluginUi.devServer, { responseType: 'text' }).toPromise()).data;
} else {
return fs.readFile(path.join(pluginUi.publicPath, 'index.html'), 'utf8');
return fs.readFileSync(path.join(pluginUi.publicPath, 'index.html'), 'utf8');
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/plugins/plugins.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ export class PluginsService {
const schemaPath = path.resolve(plugin.installPath, pluginName, 'config.schema.json');

if (this.miscSchemas[pluginName] && !await fs.pathExists(schemaPath)) {
return fs.readJson(this.miscSchemas[pluginName]);
return fs.readJsonSync(this.miscSchemas[pluginName]);
}

let configSchema = await fs.readJson(schemaPath);
Expand Down
6 changes: 3 additions & 3 deletions ui/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 ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build --configuration production --output-path=../public --source-map=false --aot=true",
"lint": "ng lint --fix"
"lint": "ng lint"
},
"private": true,
"dependencies": {
Expand Down
30 changes: 15 additions & 15 deletions ui/src/app/modules/plugins/plugin-card/plugin-card.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,36 +51,41 @@ <h4 class="card-title mb-0">
</a>

<div class="ml-auto">
<a href="javascript:void(0)" class="card-link ml-3"
*ngIf="plugin.updateAvailable || plugin.betaUpdateAvailable" (click)="$plugin.updatePlugin(plugin, plugin.betaUpdateAvailable ? 'beta' : 'latest')"
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 && recommendChildBridge"
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>
</a>
<ng-container *ngIf="hasChildBridges">
<a href="javascript:void(0);" class="card-link grey-text ml-3" rel="noopener noreferrer"
aria-label="Connect to HomeKit"
*ngIf="!childBridgeRestartInProgress && hasUnpairedChildBridges && childBridgeStatus === 'ok'"
ngbTooltip="{{'child_bridge.label_bridge_connect_to_homekit' | translate}}" placement="top" container="body"
openDelay="150" (click)="$plugin.bridgeSettings(plugin)">
<i class="fa-fw icon-button fas fa-fw fa-qrcode"></i>
<i class="fa-fw icon-button fas fa-fw fa-circle-exclamation primary-text"></i>
</a>

<i class="fas fa-fw fa-circle ml-3" [ngClass]="{
'green-text': childBridgeStatus === 'ok',
'text-warning': childBridgeStatus === 'pending',
'red-text': childBridgeStatus === 'down'
}"></i>

<a href="javascript:void(0);" class="card-link grey-text ml-3" aria-label="Restart Child Bridge(s)"
*ngIf="!childBridgeRestartInProgress && !plugin.disabled"
ngbTooltip="{{'child_bridge.label_bridge_restart_child_bridges' | translate}}" placement="top"
container="body" openDelay="150" (click)="doChildBridgeAction('restart')">
<i class="fa-fw icon-button fas fa-fw fa-power-off"></i>
</a>
<i *ngIf="childBridgeRestartInProgress" class="ml-3 grey-text fas fa-fw fa-fw fa-spinner fa-pulse"></i>
</ng-container>

<span ngbDropdown placement="bottom-right top-right" class="d-inline-block ml-3">
<a class="card-link" href="javascript:void(0)" aria-label="Plugin actions drop down menu" ngbDropdownToggle>
<i class="fas fa-fw fa-ellipsis-v" [ngClass]="{'grey-text': !plugin.updateAvailable && !plugin.betaUpdateAvailable, 'primary-text': plugin.updateAvailable || plugin.betaUpdateAvailable }"></i>
<i class="fas fa-fw fa-ellipsis-v"></i>
</a>
<div ngbDropdownMenu aria-labelledby="Plugin actions drop down menu">
<ng-container *ngIf="hasChildBridges && !plugin.disabled">
<button ngbDropdownItem *ngIf="!childBridgeRestartInProgress && !plugin.disabled" (click)="doChildBridgeAction('restart')">
<i class="fa-fw icon-button fas fa-fw fa-power-off"></i> {{ 'child_bridge.label_bridge_restart_child_bridges' | translate }}
</button>
<button ngbDropdownItem *ngIf="!allChildBridgesStopped" (click)="doChildBridgeAction('stop')">
<i class="fas fa-fw fa-stop"></i> {{ 'child_bridge.label_child_stop' | translate }}
</button>
Expand All @@ -89,11 +94,6 @@ <h4 class="card-title mb-0">
</button>
<div class="dropdown-divider"></div>
</ng-container>
<button ngbDropdownItem *ngIf="plugin.updateAvailable || plugin.betaUpdateAvailable"
(click)="$plugin.updatePlugin(plugin, plugin.betaUpdateAvailable ? 'beta' : 'latest')">
<i class="fas fa-fw fa-arrow-alt-circle-up primary-text"></i>
{{ 'plugins.button_update' | translate }} (v{{ plugin.latestVersion }})
</button>
<button ngbDropdownItem *ngIf="plugin.publicPackage" (click)="$plugin.installPreviousVersion(plugin)">
<i class="fas fa-fw fa-fw fa-history"></i>
{{ 'plugins.manage.message_install_alternate_version' | translate }}
Expand Down
25 changes: 22 additions & 3 deletions ui/src/app/modules/plugins/plugin-card/plugin-card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ManagePluginsService } from '@/app/core/manage-plugins/manage-plugins.s
import { PluginLogModalComponent } from '@/app/core/manage-plugins/plugin-log-modal/plugin-log-modal.component';
import { MobileDetectService } from '@/app/core/mobile-detect.service';
import { NotificationService } from '@/app/core/notification.service';
import { SettingsService } from '@/app/core/settings.service';
import { WsService } from '@/app/core/ws.service';
import { DonateModalComponent } from '@/app/modules/plugins/donate-modal/donate-modal.component';

Expand All @@ -30,6 +31,7 @@ export class PluginCardComponent implements OnInit {
public allChildBridgesStopped = false;
public childBridgeStatus = 'pending';
public childBridgeRestartInProgress = false;
public recommendChildBridge = false;

constructor(
public $plugin: ManagePluginsService,
Expand All @@ -40,9 +42,26 @@ export class PluginCardComponent implements OnInit {
private $modal: NgbModal,
private $toastr: ToastrService,
private $md: MobileDetectService,
) { }

ngOnInit(): void {}
private $settings: SettingsService,
) {}

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 Down
Loading

0 comments on commit abc1c7f

Please sign in to comment.