From b5d8dfa5095ec854f934abb3f7c13990ff217e86 Mon Sep 17 00:00:00 2001 From: Aditya Bist Date: Thu, 29 Mar 2018 16:29:40 -0700 Subject: [PATCH] Agent WIP (#1031) * WIP * wip * SQL Agent wip * wip * Initial control host (wip) * Initial hookup of SQL Agent service to job component * Update agent package.json * Hook up getJobs call * A couple job view updates * Add some more agent views * added back button, run actions and overview accordion * refactoring * overview table complete * fixed the dropdown arrow for the overview section * added table for prev job list * fixed agent job result type * Rename some 'agent' classes to 'jobManagement' * code cleaning and code review comments * fixed yarn.lock conflicts * added function for job history * changed vscode-languageclient version * changed yarn lock file * fixed yarn lock file * fixed yarn file * fixed css paths * added images to packaging step * fix resource path for packaging * job history page (#852) * added back button, run actions and overview accordion * refactoring * overview table complete * fixed the dropdown arrow for the overview section * added table for prev job list * fixed agent job result type * code cleaning and code review comments * fixed yarn.lock conflicts * added function for job history * changed vscode-languageclient version * changed yarn lock file * fixed yarn lock file * fixed yarn file * fixed css paths * added images to packaging step * fix resource path for packaging * added steps lists * fixed style and dimensions * fixed conflicts * Switch back getJobs return type * Make enum const * Remove sqlops const * WIP * WIP * implemented job list * added the Date and Status columns * update yarn files * merged feature/agent1 * added theme styling for light theme * changed yarn lock files * Feature/agent1 adbist (#899) * added back button, run actions and overview accordion * refactoring * overview table complete * fixed the dropdown arrow for the overview section * added table for prev job list * fixed agent job result type * code cleaning and code review comments * fixed yarn.lock conflicts * added function for job history * changed vscode-languageclient version * changed yarn lock file * fixed yarn lock file * fixed yarn file * fixed css paths * added images to packaging step * fix resource path for packaging * added steps lists * fixed style and dimensions * fixed conflicts * implemented job list * added the Date and Status columns * update yarn files * merged feature/agent1 * added theme styling for light theme * changed yarn lock files * made job history page css more specific * Add visiblity check to job view * added method signatures for job history with DMP * Clean up jobs styling and call getJobHistory * Add more Job Table styling * Enable detail view in job table * Use updated slickgrid repo * vbumped slickgrid * added methods for job running * added job actions to sqlops * Convert rowdetail slickgrid plug to TypeScript * Feature/agent1 adbist (#945) * added back button, run actions and overview accordion * refactoring * overview table complete * fixed the dropdown arrow for the overview section * added table for prev job list * fixed agent job result type * code cleaning and code review comments * fixed yarn.lock conflicts * added function for job history * changed vscode-languageclient version * changed yarn lock file * fixed yarn lock file * fixed yarn file * fixed css paths * added images to packaging step * fix resource path for packaging * added steps lists * fixed style and dimensions * fixed conflicts * implemented job list * added the Date and Status columns * update yarn files * merged feature/agent1 * added theme styling for light theme * changed yarn lock files * added method signatures for job history with DMP * added methods for job running * added job actions to sqlops * Refer to dataprotocol from feature/agentDmp1 branch * Update SQL Tools version to 1.4.0-alpha.13 * Change Feb to March in release note prompt * SQL Agent extension metadata * add feature explicitly in client creation * Update Agent job registration * navigation works but is really slow to load data * Update package.json * fixed conflicts * Feature/agent1 adbist (#955) * added back button, run actions and overview accordion * refactoring * overview table complete * fixed the dropdown arrow for the overview section * added table for prev job list * fixed agent job result type * code cleaning and code review comments * fixed yarn.lock conflicts * added function for job history * changed vscode-languageclient version * changed yarn lock file * fixed yarn lock file * fixed yarn file * fixed css paths * added images to packaging step * fix resource path for packaging * added steps lists * fixed style and dimensions * fixed conflicts * implemented job list * added the Date and Status columns * update yarn files * merged feature/agent1 * added theme styling for light theme * changed yarn lock files * added method signatures for job history with DMP * added methods for job running * added job actions to sqlops * navigation works but is really slow to load data * Add jobs view icon * fixed bug where not all steps were being shown * Misc. cleanups * added more to history page * added loadHistories and code review comments * made the params standard * fixed json local paths * added step implementation * fixed conflict * cleaned up code * removed extension-modules * CR comments * fix css * fixed data injection * steps now support big messages * improve history page UX * added messages for job actions * styling fix * cr comments --- .../views/jobHistory.component.ts | 51 ++++++++++++++----- src/sql/sqlops.d.ts | 2 +- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/sql/parts/jobManagement/views/jobHistory.component.ts b/src/sql/parts/jobManagement/views/jobHistory.component.ts index 9331a399a0..7a181b16b5 100644 --- a/src/sql/parts/jobManagement/views/jobHistory.component.ts +++ b/src/sql/parts/jobManagement/views/jobHistory.component.ts @@ -12,6 +12,7 @@ import { attachListStyler } from 'vs/platform/theme/common/styler'; import { Tree } from 'vs/base/parts/tree/browser/treeImpl'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; +import { IMessageService, Severity } from 'vs/platform/message/common/message'; import { PanelComponent } from 'sql/base/browser/ui/panel/panel.component'; import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { IJobManagementService } from '../common/interfaces'; @@ -21,6 +22,7 @@ import { JobHistoryController, JobHistoryDataSource, JobHistoryRenderer, JobHistoryFilter, JobHistoryModel, JobHistoryRow } from 'sql/parts/jobManagement/views/jobHistoryTree'; import { JobStepsViewComponent } from 'sql/parts/jobManagement/views/jobStepsView.component'; import { JobStepsViewRow } from './jobStepsViewTree'; +import { localize } from 'vs/nls'; export const DASHBOARD_SELECTOR: string = 'jobhistory-component'; @@ -48,7 +50,7 @@ export class JobHistoryComponent extends Disposable implements OnInit { private _stepRows: JobStepsViewRow[] = []; private _showSteps: boolean = false; private _runStatus: string = undefined; - + private _messageService: IMessageService; constructor( @Inject(BOOTSTRAP_SERVICE_ID) private bootstrapService: IBootstrapService, @@ -59,6 +61,7 @@ export class JobHistoryComponent extends Disposable implements OnInit { ) { super(); this._jobManagementService = bootstrapService.jobManagementService; + this._messageService = bootstrapService.messageService; } ngOnInit() { @@ -82,15 +85,17 @@ export class JobHistoryComponent extends Disposable implements OnInit { self.agentJobHistoryInfo = self._treeController.jobHistories.filter(history => history.instanceId === element.instanceID)[0]; if (self.agentJobHistoryInfo) { self.agentJobHistoryInfo.runDate = self.formatTime(self.agentJobHistoryInfo.runDate); - self._stepRows = self.agentJobHistoryInfo.steps.map(step => { - let stepViewRow = new JobStepsViewRow(); - stepViewRow.message = step.message; - stepViewRow.runStatus = JobHistoryRow.convertToStatusString(self.agentJobHistoryInfo.runStatus); - self._runStatus = stepViewRow.runStatus; - stepViewRow.stepName = step.stepName; - stepViewRow.stepID = step.stepId.toString(); - return stepViewRow; - }); + if (self.agentJobHistoryInfo.steps) { + self._stepRows = self.agentJobHistoryInfo.steps.map(step => { + let stepViewRow = new JobStepsViewRow(); + stepViewRow.message = step.message; + stepViewRow.runStatus = JobHistoryRow.convertToStatusString(self.agentJobHistoryInfo.runStatus); + self._runStatus = stepViewRow.runStatus; + stepViewRow.stepName = step.stepName; + stepViewRow.stepID = step.stepId.toString(); + return stepViewRow; + }); + } this._showSteps = true; self._cd.detectChanges(); } @@ -120,13 +125,15 @@ export class JobHistoryComponent extends Disposable implements OnInit { const self = this; let ownerUri: string = this._dashboardService.connectionManagementService.connectionInfo.ownerUri; this._jobManagementService.getJobHistory(ownerUri, this.jobId).then((result) => { - if (result.jobs) { + if (result && result.jobs) { self._treeController.jobHistories = result.jobs; let jobHistoryRows = self._treeController.jobHistories.map(job => self.convertToJobHistoryRow(job)); self._treeDataSource.data = jobHistoryRows; self._tree.setInput(new JobHistoryModel()); self.agentJobHistoryInfo = self._treeController.jobHistories[0]; - self.agentJobHistoryInfo.runDate = self.formatTime(self.agentJobHistoryInfo.runDate); + if (this.agentJobHistoryInfo) { + self.agentJobHistoryInfo.runDate = self.formatTime(self.agentJobHistoryInfo.runDate); + } self._cd.detectChanges(); } }); @@ -144,7 +151,25 @@ export class JobHistoryComponent extends Disposable implements OnInit { private jobAction(action: string, jobName: string): void { let ownerUri: string = this._dashboardService.connectionManagementService.connectionInfo.ownerUri; - this._jobManagementService.jobAction(ownerUri, jobName, action); + const self = this; + this._jobManagementService.jobAction(ownerUri, jobName, action).then(result => { + if (result.succeeded) { + switch (action) { + case ('run'): + var startMsg = localize('jobSuccessfullyStarted', 'The job was successfully started.'); + this._messageService.show(Severity.Info, startMsg); + break; + case ('stop'): + var stopMsg = localize('jobSuccessfullyStopped', 'The job was successfully stopped.'); + this._messageService.show(Severity.Info, stopMsg); + break; + default: + break; + } + } else { + this._messageService.show(Severity.Error, result.errorMessage); + } + }); } private goToJobs(): void { diff --git a/src/sql/sqlops.d.ts b/src/sql/sqlops.d.ts index 27c45762c2..a421afa807 100644 --- a/src/sql/sqlops.d.ts +++ b/src/sql/sqlops.d.ts @@ -1038,7 +1038,7 @@ declare module 'sqlops' { } export interface AgentJobActionResult { - succeeded: string; + succeeded: boolean; errorMessage: string; }