From 6f39a37656726e6711e9510f80c9ffec14d054ed Mon Sep 17 00:00:00 2001 From: Aditya Bist Date: Thu, 4 Oct 2018 13:54:17 -0700 Subject: [PATCH] Agent/history update (#2756) * refresh history when job is run * refresh history and jobs when stopped --- .../parts/jobManagement/common/jobActions.ts | 23 ++++++++++++------- .../views/jobHistory.component.ts | 5 ++++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/sql/parts/jobManagement/common/jobActions.ts b/src/sql/parts/jobManagement/common/jobActions.ts index ccb13a7bf8..fbd8b21317 100644 --- a/src/sql/parts/jobManagement/common/jobActions.ts +++ b/src/sql/parts/jobManagement/common/jobActions.ts @@ -16,6 +16,7 @@ import { JobsViewComponent } from '../views/jobsView.component'; import { AlertsViewComponent } from 'sql/parts/jobManagement/views/alertsView.component'; import { OperatorsViewComponent } from 'sql/parts/jobManagement/views/operatorsView.component'; import { ProxiesViewComponent } from 'sql/parts/jobManagement/views/proxiesView.component'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; export enum JobActions { Run = 'run', @@ -38,7 +39,7 @@ export class JobsRefreshAction extends Action { super(JobsRefreshAction.ID, JobsRefreshAction.LABEL, 'refreshIcon'); } - public run(context: JobsViewComponent): TPromise { + public run(context: JobsViewComponent | JobHistoryComponent): TPromise { return new TPromise((resolve, reject) => { if (context) { context.refreshJobs(); @@ -77,7 +78,8 @@ export class RunJobAction extends Action { constructor( @INotificationService private notificationService: INotificationService, - @IJobManagementService private jobManagementService: IJobManagementService + @IJobManagementService private jobManagementService: IJobManagementService, + @IInstantiationService private instantationService: IInstantiationService ) { super(RunJobAction.ID, RunJobAction.LABEL, 'runJobIcon'); } @@ -85,9 +87,11 @@ export class RunJobAction extends Action { public run(context: JobHistoryComponent): TPromise { let jobName = context.agentJobInfo.name; let ownerUri = context.ownerUri; + let refreshAction = this.instantationService.createInstance(JobsRefreshAction); return new TPromise((resolve, reject) => { this.jobManagementService.jobAction(ownerUri, jobName, JobActions.Run).then(result => { if (result.success) { + refreshAction.run(context); var startMsg = nls.localize('jobSuccessfullyStarted', ': The job was successfully started.'); this.notificationService.notify({ severity: Severity.Info, @@ -112,7 +116,8 @@ export class StopJobAction extends Action { constructor( @INotificationService private notificationService: INotificationService, - @IJobManagementService private jobManagementService: IJobManagementService + @IJobManagementService private jobManagementService: IJobManagementService, + @IInstantiationService private instantationService: IInstantiationService ) { super(StopJobAction.ID, StopJobAction.LABEL, 'stopJobIcon'); } @@ -120,14 +125,16 @@ export class StopJobAction extends Action { public run(context: JobHistoryComponent): TPromise { let jobName = context.agentJobInfo.name; let ownerUri = context.ownerUri; + let refreshAction = this.instantationService.createInstance(JobsRefreshAction); return new TPromise((resolve, reject) => { this.jobManagementService.jobAction(ownerUri, jobName, JobActions.Stop).then(result => { if (result.success) { - var stopMsg = nls.localize('jobSuccessfullyStopped', ': The job was successfully stopped.'); - this.notificationService.notify({ - severity: Severity.Info, - message: jobName+ stopMsg - }); + refreshAction.run(context); + var stopMsg = nls.localize('jobSuccessfullyStopped', ': The job was successfully stopped.'); + this.notificationService.notify({ + severity: Severity.Info, + message: jobName+ stopMsg + }); resolve(true); } else { this.notificationService.notify({ diff --git a/src/sql/parts/jobManagement/views/jobHistory.component.ts b/src/sql/parts/jobManagement/views/jobHistory.component.ts index 7bb4953634..fc5971f574 100644 --- a/src/sql/parts/jobManagement/views/jobHistory.component.ts +++ b/src/sql/parts/jobManagement/views/jobHistory.component.ts @@ -315,6 +315,10 @@ export class JobHistoryComponent extends JobManagementView implements OnInit { } } + public refreshJobs() { + this._agentViewComponent.refresh = true; + } + protected initActionBar() { let runJobAction = this.instantiationService.createInstance(RunJobAction); let stopJobAction = this.instantiationService.createInstance(StopJobAction); @@ -353,4 +357,5 @@ export class JobHistoryComponent extends JobManagementView implements OnInit { this._showSteps = value; this._cd.detectChanges(); } + }