mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-08 11:04:15 +00:00
Improve control of installation
This commit is contained in:
parent
157e3150b5
commit
6527554aa3
@ -59,9 +59,7 @@ ipcMain.on('installed-software-install', async function (event, software) {
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let child;
|
||||
@ -74,16 +72,17 @@ ipcMain.on('installed-software-install', async function (event, software) {
|
||||
}
|
||||
|
||||
child.on('exit', () => {
|
||||
console.log("exited");
|
||||
event.sender.send(responseChannel, {
|
||||
success: true
|
||||
});
|
||||
});
|
||||
|
||||
child.on('error', (err) => {
|
||||
console.log(err);
|
||||
event.sender.send(responseChannel, {
|
||||
success: false,
|
||||
message: err.message
|
||||
});
|
||||
});
|
||||
|
||||
child.stdin.end();
|
||||
|
||||
event.sender.send(responseChannel, {
|
||||
success: true
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Component, OnInit, Output, EventEmitter, Input, OnDestroy } from '@angular/core';
|
||||
import { Component, OnInit, Output, EventEmitter, Input, OnDestroy, OnChanges } from '@angular/core';
|
||||
import { ElectronService } from 'ngx-electron';
|
||||
|
||||
@Component({
|
||||
@ -6,7 +6,7 @@ import { ElectronService } from 'ngx-electron';
|
||||
templateUrl: './install-software.component.html',
|
||||
styleUrls: ['./install-software.component.scss']
|
||||
})
|
||||
export class InstallSoftwareComponent implements OnInit, OnDestroy {
|
||||
export class InstallSoftwareComponent implements OnInit, OnDestroy, OnChanges {
|
||||
@Input('software')
|
||||
software: any;
|
||||
|
||||
@ -26,13 +26,15 @@ export class InstallSoftwareComponent implements OnInit, OnDestroy {
|
||||
this.updateButton();
|
||||
this.installedChanged.emit(data);
|
||||
});
|
||||
this.updateButton();
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.electronService.ipcRenderer.removeAllListeners(this.responseChannel);
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
this.updateButton();
|
||||
}
|
||||
|
||||
install() {
|
||||
this.disabled = true;
|
||||
@ -44,7 +46,7 @@ export class InstallSoftwareComponent implements OnInit, OnDestroy {
|
||||
return `installed-software-installed-${this.software.name}`;
|
||||
}
|
||||
|
||||
updateButton() {
|
||||
private updateButton() {
|
||||
this.disabled = this.software.installed;
|
||||
|
||||
if (this.software.installed) {
|
||||
|
@ -15,11 +15,6 @@
|
||||
<mat-header-cell *matHeaderCellDef></mat-header-cell>
|
||||
<mat-cell *matCellDef="let row;" style="text-align: right">
|
||||
<app-install-software [software]="row" (installedChanged)="onInstalled($event)"></app-install-software>
|
||||
|
||||
<!-- <button *ngIf="row.installed" mat-button color="primary" (click)="install(row)" [disabled]="row.installed">
|
||||
<ng-container *ngIf="row.installed">Installed</ng-container>
|
||||
<ng-container *ngIf="!row.installed">Install</ng-container>
|
||||
</button> -->
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
|
||||
import { InstalledSoftwareService } from '../../services/installed-software.service';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { Observable, of, BehaviorSubject } from 'rxjs';
|
||||
@ -13,15 +13,23 @@ export class InstalledSoftwareComponent implements OnInit {
|
||||
displayedColumns = ['name', 'actions'];
|
||||
|
||||
constructor(
|
||||
private installedSoftwareService: InstalledSoftwareService
|
||||
private installedSoftwareService: InstalledSoftwareService,
|
||||
private changeDetectorRef: ChangeDetectorRef
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.dataSource = new InstalledSoftwareDataSource(this.installedSoftwareService);
|
||||
}
|
||||
|
||||
|
||||
onInstalled(event) {
|
||||
this.dataSource.refresh();
|
||||
console.log("On installed", event);
|
||||
/**
|
||||
* During software installation we are not performing any user action
|
||||
* in browser hence Angular doesn't know something suppose to change.
|
||||
* Here we ask to detect changes manually.
|
||||
*/
|
||||
this.changeDetectorRef.detectChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user