diff --git a/installed-software.js b/installed-software.js index ccba7a8e..7bd27075 100644 --- a/installed-software.js +++ b/installed-software.js @@ -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 - }); }); diff --git a/src/app/components/installed-software/install-software/install-software.component.ts b/src/app/components/installed-software/install-software/install-software.component.ts index aedf2193..88733ada 100644 --- a/src/app/components/installed-software/install-software/install-software.component.ts +++ b/src/app/components/installed-software/install-software/install-software.component.ts @@ -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) { diff --git a/src/app/components/installed-software/installed-software.component.html b/src/app/components/installed-software/installed-software.component.html index 987b7af3..6f7b2e7d 100644 --- a/src/app/components/installed-software/installed-software.component.html +++ b/src/app/components/installed-software/installed-software.component.html @@ -15,11 +15,6 @@ - - diff --git a/src/app/components/installed-software/installed-software.component.ts b/src/app/components/installed-software/installed-software.component.ts index efe67032..64300e14 100644 --- a/src/app/components/installed-software/installed-software.component.ts +++ b/src/app/components/installed-software/installed-software.component.ts @@ -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(); } }