Skip to content

Commit

Permalink
next
Browse files Browse the repository at this point in the history
  • Loading branch information
bwp91 committed Nov 10, 2023
1 parent c101948 commit db56899
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import { NotificationService } from '@/app/core/notification.service';
templateUrl: './manage-plugins-modal.component.html',
styleUrls: ['./manage-plugins-modal.component.scss'],
})

export class ManagePluginsModalComponent implements OnInit, OnDestroy {
@Input() pluginName;
@Input() pluginName: string;
@Input() targetVersion = 'latest';
@Input() action;
@Input() action: string;

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

Expand All @@ -33,7 +34,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
public justUpdatedPlugin = false;
public updateToBeta = false;
public changeLog: string;
public release;
public release: any;

private toastSuccess: string;
public presentTenseVerb: string;
Expand All @@ -45,7 +46,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
public activeModal: NgbActiveModal,
public $toastr: ToastrService,
private $translate: TranslateService,
private $settings: SettingsService,
public $settings: SettingsService,
private $api: ApiService,
private $ws: WsService,
private $notification: NotificationService,
Expand All @@ -59,7 +60,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
this.term.open(this.termTarget);
this.fitAddon.fit();

this.io.socket.on('stdout', (data) => {
this.io.socket.on('stdout', (data: string | Uint8Array) => {
this.term.write(data);
});

Expand Down Expand Up @@ -112,7 +113,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
termCols: this.term.cols,
termRows: this.term.rows,
}).subscribe(
(data) => {
() => {
this.$router.navigate(['/plugins'], {
queryParams: { installed: this.pluginName },
});
Expand All @@ -133,7 +134,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
termCols: this.term.cols,
termRows: this.term.rows,
}).subscribe(
(data) => {
() => {
this.activeModal.close();
this.$router.navigate(['/plugins']);
this.$toastr.success(`${this.pastTenseVerb} ${this.pluginName}`, this.toastSuccess);
Expand Down Expand Up @@ -164,7 +165,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
termCols: this.term.cols,
termRows: this.term.rows,
}).subscribe(
(data) => {
() => {
this.justUpdatedPlugin = true;
this.$router.navigate(['/plugins']);
this.$toastr.success(`${this.pastTenseVerb} ${this.pluginName}`, this.toastSuccess);
Expand All @@ -184,7 +185,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
termCols: this.term.cols,
termRows: this.term.rows,
}).subscribe(
(data) => {
() => {
this.$router.navigate(['/restart']);
this.activeModal.close();
this.$toastr.success(this.pastTenseVerb, this.toastSuccess);
Expand All @@ -206,7 +207,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
this.activeModal.close();
}
},
(err) => {
() => {
this.activeModal.close();
},
);
Expand All @@ -218,7 +219,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
this.showReleaseNotes = true;
this.release = data;
},
(err) => {
() => {
if (this.onlineUpdateOk) {
this.update();
}
Expand Down Expand Up @@ -268,5 +269,4 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
ngOnDestroy() {
this.io.end();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ <h5 class="m-0">{{ block.name || pluginAlias }}</h5>
</div>
<div class="modal-footer justify-content-between">
<div style="min-width: 25%;" class="text-left">
<button type="button" class="btn btn-elegant mr-auto" data-dismiss="modal" (click)="addBlock()"
*ngIf="canConfigure">
<i class="fa fa-fw fa-plus"></i> Add {{ pluginType }}
</button>
<button type="button" class="btn btn-elegant" data-dismiss="modal" (click)="activeModal.close()"
[translate]="'form.button_close'">Close</button>
</div>

<div style="min-width: 25%;" class="d-none d-lg-inline text-center">
Expand All @@ -79,8 +77,11 @@ <h5 class="m-0">{{ block.name || pluginAlias }}</h5>
</div>

<div style="min-width: 25%;" class="text-right">
<button type="button" class="btn btn-elegant" data-dismiss="modal" (click)="activeModal.close()"
[translate]="'form.button_close'">Close</button>
<button type="button" class="btn btn-elegant mr-auto" data-dismiss="modal" (click)="addBlock()"
*ngIf="canConfigure">
Add {{ pluginType }}
</button>

<button type="button" class="btn btn-primary" data-dismiss="modal" (click)="save()" [disabled]="saveInProgress"
*ngIf="canConfigure">
{{ 'form.button_save' | translate }} <i *ngIf="saveInProgress" class="fas fa-fw fa-spinner fa-pulse"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { NotificationService } from '@/app/core/notification.service';
styleUrls: ['./manual-plugin-config-modal.component.scss'],
})
export class ManualPluginConfigModalComponent implements OnInit {
@Input() plugin;
@Input() plugin: any;

public pluginAlias: string;
public pluginType: 'platform' | 'accessory';
Expand All @@ -30,7 +30,7 @@ export class ManualPluginConfigModalComponent implements OnInit {
public currentBlockIndex: number | null = null;
public saveInProgress = false;

public monacoEditor;
public monacoEditor: any;
public editorOptions = {
language: 'json',
theme: this.$settings.theme.startsWith('dark-mode') ? 'vs-dark' : 'vs-light',
Expand Down Expand Up @@ -62,7 +62,7 @@ export class ManualPluginConfigModalComponent implements OnInit {
return this.pluginType === 'accessory' ? 'accessories' : 'platforms';
}

async onEditorInit(editor) {
async onEditorInit(editor: any) {
this.monacoEditor = editor;
window['editor'] = editor;
await this.monacoEditor.getModel().setValue(this.currentBlock);
Expand All @@ -80,7 +80,7 @@ export class ManualPluginConfigModalComponent implements OnInit {
this.loading = false;
}
},
(err) => {
() => {
this.loading = false;
},
);
Expand All @@ -103,9 +103,11 @@ export class ManualPluginConfigModalComponent implements OnInit {
);
}

// configBlocks(): Array<any> {
// return this.pluginConfig;
// }
blockChanged() {
for (const block of this.pluginConfig) {
block.name = block.config.name || block.name;
}
}

addBlock() {
if (!this.saveCurrentBlock()) {
Expand Down Expand Up @@ -204,33 +206,30 @@ export class ManualPluginConfigModalComponent implements OnInit {
this.show = '';
}

save() {
async save() {
this.saveInProgress = true;
if (!this.saveCurrentBlock()) {
this.saveInProgress = false;
return;
}

return this.$api.post(`/config-editor/plugin/${encodeURIComponent(this.plugin.name)}`, this.pluginConfig)
.toPromise()
.then(data => {
this.$toastr.success(
this.translate.instant('plugins.settings.toast_restart_required'),
this.translate.instant('plugins.settings.toast_plugin_config_saved'),
);

this.$notification.configUpdated.next(undefined);
this.activeModal.close();
})
.catch(err => {
this.$toastr.error(this.translate.instant('config.toast_failed_to_save_config'), this.translate.instant('toast.title_error'));
this.saveInProgress = false;
});
try {
await this.$api.post(`/config-editor/plugin/${encodeURIComponent(this.plugin.name)}`, this.pluginConfig)
.toPromise();
this.$toastr.success(
this.translate.instant('plugins.settings.toast_restart_required'),
this.translate.instant('plugins.settings.toast_plugin_config_saved'));

this.$notification.configUpdated.next(undefined);
this.activeModal.close();
} catch {
this.$toastr.error(this.translate.instant('config.toast_failed_to_save_config'), this.translate.instant('toast.title_error'));
this.saveInProgress = false;
}
}

openFullConfigEditor() {
this.$router.navigate(['/config']);
this.activeModal.close();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import { TranslateService } from '@ngx-translate/core';
import { ToastrService } from 'ngx-toastr';

import { WsService } from '@/app/core/ws.service';
import { ManagePluginsService } from '@/app/core/manage-plugins/manage-plugins.service';

@Component({
selector: 'app-child-bridge-widget',
templateUrl: './child-bridge-widget.component.html',
styleUrls: ['./child-bridge-widget.component.scss'],
})
export class ChildBridgeWidgetComponent implements OnInit, OnDestroy {
@Input() widget;
@Input() widget: any;

private io = this.$ws.connectToNamespace('child-bridges');

Expand All @@ -21,7 +20,6 @@ export class ChildBridgeWidgetComponent implements OnInit, OnDestroy {
private $toastr: ToastrService,
private $translate: TranslateService,
private $ws: WsService,
public $plugin: ManagePluginsService,
) { }

ngOnInit(): void {
Expand All @@ -30,7 +28,7 @@ export class ChildBridgeWidgetComponent implements OnInit, OnDestroy {
this.io.socket.emit('monitor-child-bridge-status');
});

this.io.socket.on('child-bridge-status-update', (data) => {
this.io.socket.on('child-bridge-status-update', (data: any) => {
const existingBridge = this.childBridges.find(x => x.username === data.username);
if (existingBridge) {
Object.assign(existingBridge, data);
Expand All @@ -46,7 +44,7 @@ export class ChildBridgeWidgetComponent implements OnInit, OnDestroy {
});
}

async restartChildBridge(bridge) {
async restartChildBridge(bridge: any) {
bridge.restartInProgress = true;
try {
await this.io.request('restart-child-bridge', bridge.username).toPromise();
Expand Down

0 comments on commit db56899

Please sign in to comment.