mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-19 15:23:51 +00:00
Improve control of installation
This commit is contained in:
@ -59,9 +59,7 @@ ipcMain.on('installed-software-install', async function (event, software) {
|
|||||||
message: error.message
|
message: error.message
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let child;
|
let child;
|
||||||
@ -74,16 +72,17 @@ ipcMain.on('installed-software-install', async function (event, software) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
child.on('exit', () => {
|
child.on('exit', () => {
|
||||||
console.log("exited");
|
event.sender.send(responseChannel, {
|
||||||
|
success: true
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
child.on('error', (err) => {
|
child.on('error', (err) => {
|
||||||
console.log(err);
|
event.sender.send(responseChannel, {
|
||||||
|
success: false,
|
||||||
|
message: err.message
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
child.stdin.end();
|
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';
|
import { ElectronService } from 'ngx-electron';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -6,7 +6,7 @@ import { ElectronService } from 'ngx-electron';
|
|||||||
templateUrl: './install-software.component.html',
|
templateUrl: './install-software.component.html',
|
||||||
styleUrls: ['./install-software.component.scss']
|
styleUrls: ['./install-software.component.scss']
|
||||||
})
|
})
|
||||||
export class InstallSoftwareComponent implements OnInit, OnDestroy {
|
export class InstallSoftwareComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
@Input('software')
|
@Input('software')
|
||||||
software: any;
|
software: any;
|
||||||
|
|
||||||
@ -26,13 +26,15 @@ export class InstallSoftwareComponent implements OnInit, OnDestroy {
|
|||||||
this.updateButton();
|
this.updateButton();
|
||||||
this.installedChanged.emit(data);
|
this.installedChanged.emit(data);
|
||||||
});
|
});
|
||||||
this.updateButton();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.electronService.ipcRenderer.removeAllListeners(this.responseChannel);
|
this.electronService.ipcRenderer.removeAllListeners(this.responseChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnChanges() {
|
||||||
|
this.updateButton();
|
||||||
|
}
|
||||||
|
|
||||||
install() {
|
install() {
|
||||||
this.disabled = true;
|
this.disabled = true;
|
||||||
@ -44,7 +46,7 @@ export class InstallSoftwareComponent implements OnInit, OnDestroy {
|
|||||||
return `installed-software-installed-${this.software.name}`;
|
return `installed-software-installed-${this.software.name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateButton() {
|
private updateButton() {
|
||||||
this.disabled = this.software.installed;
|
this.disabled = this.software.installed;
|
||||||
|
|
||||||
if (this.software.installed) {
|
if (this.software.installed) {
|
||||||
|
@ -15,11 +15,6 @@
|
|||||||
<mat-header-cell *matHeaderCellDef></mat-header-cell>
|
<mat-header-cell *matHeaderCellDef></mat-header-cell>
|
||||||
<mat-cell *matCellDef="let row;" style="text-align: right">
|
<mat-cell *matCellDef="let row;" style="text-align: right">
|
||||||
<app-install-software [software]="row" (installedChanged)="onInstalled($event)"></app-install-software>
|
<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>
|
</mat-cell>
|
||||||
</ng-container>
|
</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 { InstalledSoftwareService } from '../../services/installed-software.service';
|
||||||
import { DataSource } from '@angular/cdk/table';
|
import { DataSource } from '@angular/cdk/table';
|
||||||
import { Observable, of, BehaviorSubject } from 'rxjs';
|
import { Observable, of, BehaviorSubject } from 'rxjs';
|
||||||
@ -13,15 +13,23 @@ export class InstalledSoftwareComponent implements OnInit {
|
|||||||
displayedColumns = ['name', 'actions'];
|
displayedColumns = ['name', 'actions'];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private installedSoftwareService: InstalledSoftwareService
|
private installedSoftwareService: InstalledSoftwareService,
|
||||||
|
private changeDetectorRef: ChangeDetectorRef
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.dataSource = new InstalledSoftwareDataSource(this.installedSoftwareService);
|
this.dataSource = new InstalledSoftwareDataSource(this.installedSoftwareService);
|
||||||
}
|
}
|
||||||
|
|
||||||
onInstalled(event) {
|
onInstalled(event) {
|
||||||
this.dataSource.refresh();
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user