From e70d5838a88c735ce9ad3baea090f14fc5b76cf7 Mon Sep 17 00:00:00 2001 From: Aditya Bist Date: Fri, 29 Mar 2019 13:42:34 -0700 Subject: [PATCH] Agent - stop job (#4410) * stop job behavior similar to ssms * removed agent from sqlops * fix couple UX issues * let sqlops remain unchanged --- src/sql/azdata.proposed.d.ts | 2 +- .../views/jobHistory.component.ts | 20 +++++++++---------- .../jobManagement/views/jobHistoryTree.ts | 1 + .../views/jobStepsView.component.ts | 2 +- .../jobManagement/views/jobsView.component.ts | 4 ++-- .../jobManagement/common/jobActions.ts | 2 +- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/sql/azdata.proposed.d.ts b/src/sql/azdata.proposed.d.ts index e115da8f59..f7d0d7f6f8 100644 --- a/src/sql/azdata.proposed.d.ts +++ b/src/sql/azdata.proposed.d.ts @@ -1503,9 +1503,9 @@ declare module 'azdata' { export interface AgentJobHistoryResult extends ResultStatus { histories: AgentJobHistoryInfo[]; - steps: AgentJobStepInfo[]; schedules: AgentJobScheduleInfo[]; alerts: AgentAlertInfo[]; + steps: AgentJobStepInfo[]; } export interface CreateAgentJobResult extends ResultStatus { diff --git a/src/sql/parts/jobManagement/views/jobHistory.component.ts b/src/sql/parts/jobManagement/views/jobHistory.component.ts index f13eb8e90f..78bb074dd2 100644 --- a/src/sql/parts/jobManagement/views/jobHistory.component.ts +++ b/src/sql/parts/jobManagement/views/jobHistory.component.ts @@ -184,10 +184,16 @@ export class JobHistoryComponent extends JobManagementView implements OnInit { }); } - private setStepsTree(element: any) { + private setStepsTree(element: JobHistoryRow) { const self = this; - self.agentJobHistoryInfo = self._treeController.jobHistories.find( + let cachedHistory = self._jobCacheObject.getJobHistory(element.jobID); + if (cachedHistory) { + self.agentJobHistoryInfo = cachedHistory.find( history => self.formatTime(history.runDate) === self.formatTime(element.runDate)); + } else { + self.agentJobHistoryInfo = self._treeController.jobHistories.find( + history => self.formatTime(history.runDate) === self.formatTime(element.runDate)); + } if (self.agentJobHistoryInfo) { self.agentJobHistoryInfo.runDate = self.formatTime(self.agentJobHistoryInfo.runDate); if (self.agentJobHistoryInfo.steps) { @@ -264,6 +270,7 @@ export class JobHistoryComponent extends JobManagementView implements OnInit { jobHistoryRow.runDate = this.formatTime(historyInfo.runDate); jobHistoryRow.runStatus = JobManagementUtilities.convertToStatusString(historyInfo.runStatus); jobHistoryRow.instanceID = historyInfo.instanceId; + jobHistoryRow.jobID = historyInfo.jobId; return jobHistoryRow; } @@ -334,15 +341,6 @@ export class JobHistoryComponent extends JobManagementView implements OnInit { protected initActionBar() { let runJobAction = this.instantiationService.createInstance(RunJobAction); let stopJobAction = this.instantiationService.createInstance(StopJobAction); - switch(this._agentJobInfo.currentExecutionStatus) { - case(1): - case(2): - case(3): - stopJobAction.enabled = true; - break; - default: - stopJobAction.enabled = false; - } let editJobAction = this.instantiationService.createInstance(EditJobAction); let refreshAction = this.instantiationService.createInstance(JobsRefreshAction); let taskbar = this.actionBarContainer.nativeElement; diff --git a/src/sql/parts/jobManagement/views/jobHistoryTree.ts b/src/sql/parts/jobManagement/views/jobHistoryTree.ts index 3fdbe0df06..740b62a10c 100644 --- a/src/sql/parts/jobManagement/views/jobHistoryTree.ts +++ b/src/sql/parts/jobManagement/views/jobHistoryTree.ts @@ -20,6 +20,7 @@ export class JobHistoryRow { runStatus: string; instanceID: number; rowID: string = generateUuid(); + jobID: string; } // Empty class just for tree input diff --git a/src/sql/parts/jobManagement/views/jobStepsView.component.ts b/src/sql/parts/jobManagement/views/jobStepsView.component.ts index eeefa747a5..9e8417a57c 100644 --- a/src/sql/parts/jobManagement/views/jobStepsView.component.ts +++ b/src/sql/parts/jobManagement/views/jobStepsView.component.ts @@ -61,7 +61,6 @@ export class JobStepsViewComponent extends JobManagementView implements OnInit, ngAfterContentChecked() { $('.steps-tree .step-column-heading').closest('.monaco-tree-row').addClass('step-column-row'); this.layout(); - this._tree.setInput(new JobStepsViewModel()); this._tree.onDidScroll(() => { $('.steps-tree .step-column-heading').closest('.monaco-tree-row').addClass('step-column-row'); }); @@ -94,6 +93,7 @@ export class JobStepsViewComponent extends JobManagementView implements OnInit, let element = this._tree.getFocus(); this._tree.select(element); }); + this._tree.setInput(new JobStepsViewModel()); } ngOnInit() { diff --git a/src/sql/parts/jobManagement/views/jobsView.component.ts b/src/sql/parts/jobManagement/views/jobsView.component.ts index c74c102042..b93f871e8a 100644 --- a/src/sql/parts/jobManagement/views/jobsView.component.ts +++ b/src/sql/parts/jobManagement/views/jobsView.component.ts @@ -622,7 +622,7 @@ export class JobsViewComponent extends JobManagementView implements OnInit, OnDe let chartHeights = this.getChartHeights(jobHistories); let runCharts = []; for (let i = 0; i < chartHeights.length; i++) { - let runGraph = $(`table#${jobId}.jobprevruns > tbody > tr > td > div.bar${i}`); + let runGraph = $(`table.jobprevruns#${jobId} > tbody > tr > td > div.bar${i}`); if (runGraph.length > 0) { runGraph.css('height', chartHeights[i]); let bgColor = jobHistories[i].runStatus === 0 ? 'red' : 'green'; @@ -666,7 +666,7 @@ export class JobsViewComponent extends JobManagementView implements OnInit, OnDe // if the durations are all 0 secs, show minimal chart // instead of nothing if (zeroDurationJobCount === jobHistories.length) { - return ['5px', '5px', '5px', '5px', '5px']; + return Array(jobHistories.length).fill('5px'); } else { return chartHeights; } diff --git a/src/sql/platform/jobManagement/common/jobActions.ts b/src/sql/platform/jobManagement/common/jobActions.ts index c3fbd47b5b..94f79afcc7 100644 --- a/src/sql/platform/jobManagement/common/jobActions.ts +++ b/src/sql/platform/jobManagement/common/jobActions.ts @@ -165,7 +165,7 @@ export class EditJobAction extends Action { this._commandService.executeCommand( 'agent.openJobDialog', actionInfo.ownerUri, - actionInfo.targetObject); + actionInfo.targetObject.job); return Promise.resolve(true); } }