mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-03-12 23:44:59 +00:00
60 lines
1.4 KiB
TypeScript
60 lines
1.4 KiB
TypeScript
import { Component, OnInit, Output, EventEmitter, Input, OnDestroy, OnChanges } from '@angular/core';
|
|
import { ElectronService } from 'ngx-electron';
|
|
|
|
@Component({
|
|
selector: 'app-install-software',
|
|
templateUrl: './install-software.component.html',
|
|
styleUrls: ['./install-software.component.scss']
|
|
})
|
|
export class InstallSoftwareComponent implements OnInit, OnDestroy, OnChanges {
|
|
@Input('software')
|
|
software: any;
|
|
|
|
@Output()
|
|
installedChanged = new EventEmitter();
|
|
|
|
public disabled = false;
|
|
public readyToInstall = true;
|
|
public buttonText: string;
|
|
|
|
constructor(
|
|
private electronService: ElectronService
|
|
) { }
|
|
|
|
ngOnInit() {
|
|
this.electronService.ipcRenderer.on(this.responseChannel, (event, data) => {
|
|
this.updateButton();
|
|
this.installedChanged.emit(data);
|
|
});
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
this.electronService.ipcRenderer.removeAllListeners(this.responseChannel);
|
|
}
|
|
|
|
ngOnChanges() {
|
|
this.updateButton();
|
|
}
|
|
|
|
install() {
|
|
this.disabled = true;
|
|
this.buttonText = "Installing";
|
|
this.electronService.ipcRenderer.send('installed-software-install', this.software);
|
|
}
|
|
|
|
private get responseChannel() {
|
|
return `installed-software-installed-${this.software.name}`;
|
|
}
|
|
|
|
private updateButton() {
|
|
this.disabled = this.software.installed;
|
|
|
|
if (this.software.installed) {
|
|
this.buttonText = "Installed";
|
|
}
|
|
else {
|
|
this.buttonText = "Install";
|
|
}
|
|
}
|
|
}
|