diff --git a/src/sql/parts/jobManagement/common/interfaces.ts b/src/sql/parts/jobManagement/common/interfaces.ts index 2d502e7ece..62f209692e 100644 --- a/src/sql/parts/jobManagement/common/interfaces.ts +++ b/src/sql/parts/jobManagement/common/interfaces.ts @@ -19,18 +19,19 @@ export interface IJobManagementService { registerProvider(providerId: string, provider: sqlops.AgentServicesProvider): void; getJobs(connectionUri: string): Thenable; + getJobHistory(connectionUri: string, jobID: string): Thenable; + deleteJob(connectionUri: string, job: sqlops.AgentJobInfo): Thenable; getAlerts(connectionUri: string): Thenable; + deleteAlert(connectionUri: string, alert: sqlops.AgentAlertInfo): Thenable; getOperators(connectionUri: string): Thenable; + deleteOperator(connectionUri: string, operator: sqlops.AgentOperatorInfo): Thenable; getProxies(connectionUri: string): Thenable; - - getJobHistory(connectionUri: string, jobID: string): Thenable; + deleteProxy(connectionUri: string, proxy: sqlops.AgentProxyInfo): Thenable; jobAction(connectionUri: string, jobName: string, action: string): Thenable; - addToCache(server: string, cache: JobCacheObject); - jobCacheObjectMap: { [server: string]: JobCacheObject; }; } \ No newline at end of file diff --git a/src/sql/parts/jobManagement/common/jobActions.ts b/src/sql/parts/jobManagement/common/jobActions.ts index 66b7d06786..70b092059a 100644 --- a/src/sql/parts/jobManagement/common/jobActions.ts +++ b/src/sql/parts/jobManagement/common/jobActions.ts @@ -6,6 +6,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { Action } from 'vs/base/common/actions'; import * as nls from 'vs/nls'; +import * as sqlops from 'sqlops'; import { INotificationService } from 'vs/platform/notification/common/notification'; import Severity from 'vs/base/common/severity'; import { JobHistoryComponent } from 'sql/parts/jobManagement/views/jobHistory.component'; @@ -19,6 +20,11 @@ export enum JobActions { NewStep = 'newStep' } +export interface IJobActionInfo { + ownerUri: string; + targetObject: any; +} + export class RunJobAction extends Action { public static ID = 'jobaction.runJob'; public static LABEL = nls.localize('jobaction.run', "Run"); @@ -115,79 +121,113 @@ export class NewStepAction extends Action { } } -export class EditJob extends Action { +export class EditJobAction extends Action { public static ID = 'jobaction.editJob'; public static LABEL = nls.localize('jobaction.editJob', "Edit Job"); - constructor( - id: string, - label: string - ) { - super(id, label); + constructor() { + super(EditJobAction.ID, EditJobAction.LABEL); } - public run(info: any): TPromise { + public run(actionInfo: IJobActionInfo): TPromise { return TPromise.as(true); } } -export class DeleteJob extends Action { +export class DeleteJobAction extends Action { public static ID = 'jobaction.deleteJob'; public static LABEL = nls.localize('jobaction.deleteJob', "Delete Job"); constructor( - id: string, - label: string + @INotificationService private _notificationService: INotificationService, + @IJobManagementService private _jobService: IJobManagementService ) { - super(id, label); + super(DeleteJobAction.ID, DeleteJobAction.LABEL); } - public run(info: any): TPromise { + public run(actionInfo: IJobActionInfo): TPromise { + let self = this; + let job = actionInfo.targetObject as sqlops.AgentJobInfo; + self._notificationService.prompt( + Severity.Info, + nls.localize('jobaction.deleteJobConfirm,', "Are you sure you'd like to delete the job '{0}'?", job.name), + [{ + label: DeleteJobAction.LABEL, + run: () => { + self._jobService.deleteJob(actionInfo.ownerUri, actionInfo.targetObject).then(result => { + if (!result || !result.success) { + let errorMessage = nls.localize("jobaction.failedToDeleteJob", "Could not delete job '{0}'.\nError: {1}", + job.name, result.errorMessage ? result.errorMessage : 'Unknown error'); + self._notificationService.error(errorMessage); + } + }); + } + }, { + label: DeleteAlertAction.CancelLabel, + run: () => { } + }] + ); return TPromise.as(true); } } -export class EditAlert extends Action { +export class EditAlertAction extends Action { public static ID = 'jobaction.editAlert'; public static LABEL = nls.localize('jobaction.editAlert', "Edit Alert"); - constructor( - id: string, - label: string - ) { - super(id, label); + constructor() { + super(EditAlertAction.ID, EditAlertAction.LABEL); } - public run(info: any): TPromise { + public run(actionInfo: IJobActionInfo): TPromise { return TPromise.as(true); } } -export class DeleteAlert extends Action { +export class DeleteAlertAction extends Action { public static ID = 'jobaction.deleteAlert'; public static LABEL = nls.localize('jobaction.deleteAlert', "Delete Alert"); + public static CancelLabel = nls.localize('jobaction.Cancel', "Cancel"); constructor( - id: string, - label: string + @INotificationService private _notificationService: INotificationService, + @IJobManagementService private _jobService: IJobManagementService ) { - super(id, label); + super(DeleteAlertAction.ID, DeleteAlertAction.LABEL); } - public run(info: any): TPromise { + public run(actionInfo: IJobActionInfo): TPromise { + let self = this; + let alert = actionInfo.targetObject as sqlops.AgentAlertInfo; + self._notificationService.prompt( + Severity.Info, + nls.localize('jobaction.deleteAlertConfirm,', "Are you sure you'd like to delete the alert '{0}'?", alert.name), + [{ + label: DeleteAlertAction.LABEL, + run: () => { + self._jobService.deleteAlert(actionInfo.ownerUri, actionInfo.targetObject).then(result => { + if (!result || !result.success) { + let errorMessage = nls.localize("jobaction.failedToDeleteAlert", "Could not delete alert '{0}'.\nError: {1}", + alert.name, result.errorMessage ? result.errorMessage : 'Unknown error'); + self._notificationService.error(errorMessage); + } + }); + } + }, { + label: DeleteAlertAction.CancelLabel, + run: () => { } + }] + ); return TPromise.as(true); } } -export class EditOperator extends Action { +export class EditOperatorAction extends Action { public static ID = 'jobaction.editAlert'; public static LABEL = nls.localize('jobaction.editOperator', "Edit Operator"); - constructor( - id: string, - label: string - ) { - super(id, label); + constructor() { + super(EditOperatorAction.ID, EditOperatorAction.LABEL); } public run(info: any): TPromise { @@ -195,32 +235,50 @@ export class EditOperator extends Action { } } -export class DeleteOperator extends Action { +export class DeleteOperatorAction extends Action { public static ID = 'jobaction.deleteOperator'; public static LABEL = nls.localize('jobaction.deleteOperator', "Delete Operator"); constructor( - id: string, - label: string + @INotificationService private _notificationService: INotificationService, + @IJobManagementService private _jobService: IJobManagementService ) { - super(id, label); + super(DeleteOperatorAction.ID, DeleteOperatorAction.LABEL); } - public run(info: any): TPromise { + public run(actionInfo: IJobActionInfo): TPromise { + let self = this; + let operator = actionInfo.targetObject as sqlops.AgentOperatorInfo; + self._notificationService.prompt( + Severity.Info, + nls.localize('jobaction.deleteOperatorConfirm,', "Are you sure you'd like to delete the operator '{0}'?", operator.name), + [{ + label: DeleteOperatorAction.LABEL, + run: () => { + self._jobService.deleteOperator(actionInfo.ownerUri, actionInfo.targetObject).then(result => { + if (!result || !result.success) { + let errorMessage = nls.localize("jobaction.failedToDeleteOperator", "Could not delete operator '{0}'.\nError: {1}", + operator.name, result.errorMessage ? result.errorMessage : 'Unknown error'); + self._notificationService.error(errorMessage); + } + }); + } + }, { + label: DeleteAlertAction.CancelLabel, + run: () => { } + }] + ); return TPromise.as(true); } } -export class EditProxy extends Action { +export class EditProxyAction extends Action { public static ID = 'jobaction.editProxy'; public static LABEL = nls.localize('jobaction.editProxy', "Edit Proxy"); - constructor( - id: string, - label: string - ) { - super(id, label); + constructor() { + super(EditProxyAction.ID, EditProxyAction.LABEL); } public run(info: any): TPromise { @@ -228,18 +286,39 @@ export class EditProxy extends Action { } } -export class DeleteProxy extends Action { - public static ID = 'jobaction.deleteOperator'; +export class DeleteProxyAction extends Action { + public static ID = 'jobaction.deleteProxy'; public static LABEL = nls.localize('jobaction.deleteProxy', "Delete Proxy"); constructor( - id: string, - label: string + @INotificationService private _notificationService: INotificationService, + @IJobManagementService private _jobService: IJobManagementService ) { - super(id, label); + super(DeleteProxyAction.ID, DeleteProxyAction.LABEL); } - public run(info: any): TPromise { + public run(actionInfo: IJobActionInfo): TPromise { + let self = this; + let proxy = actionInfo.targetObject as sqlops.AgentProxyInfo; + self._notificationService.prompt( + Severity.Info, + nls.localize('jobaction.deleteProxyConfirm,', "Are you sure you'd like to delete the proxy '{0}'?", proxy.accountName), + [{ + label: DeleteProxyAction.LABEL, + run: () => { + self._jobService.deleteProxy(actionInfo.ownerUri, actionInfo.targetObject).then(result => { + if (!result || !result.success) { + let errorMessage = nls.localize("jobaction.failedToDeleteProxy", "Could not delete proxy '{0}'.\nError: {1}", + proxy.accountName, result.errorMessage ? result.errorMessage : 'Unknown error'); + self._notificationService.error(errorMessage); + } + }); + } + }, { + label: DeleteAlertAction.CancelLabel, + run: () => { } + }] + ); return TPromise.as(true); } } \ No newline at end of file diff --git a/src/sql/parts/jobManagement/common/jobManagementService.ts b/src/sql/parts/jobManagement/common/jobManagementService.ts index 0b714ff0bb..2100af662c 100644 --- a/src/sql/parts/jobManagement/common/jobManagementService.ts +++ b/src/sql/parts/jobManagement/common/jobManagementService.ts @@ -29,24 +29,47 @@ export class JobManagementService implements IJobManagementService { }); } + public deleteJob(connectionUri: string, job: sqlops.AgentJobInfo): Thenable { + return this._runAction(connectionUri, (runner) => { + return runner.deleteJob(connectionUri, job); + }); + } + public getAlerts(connectionUri: string): Thenable { return this._runAction(connectionUri, (runner) => { return runner.getAlerts(connectionUri); }); } + public deleteAlert(connectionUri: string, alert: sqlops.AgentAlertInfo): Thenable { + return this._runAction(connectionUri, (runner) => { + return runner.deleteAlert(connectionUri, alert); + }); + } + public getOperators(connectionUri: string): Thenable { return this._runAction(connectionUri, (runner) => { return runner.getOperators(connectionUri); }); } + public deleteOperator(connectionUri: string, operator: sqlops.AgentOperatorInfo): Thenable { + return this._runAction(connectionUri, (runner) => { + return runner.deleteOperator(connectionUri, operator); + }); + } + public getProxies(connectionUri: string): Thenable { return this._runAction(connectionUri, (runner) => { return runner.getProxies(connectionUri); }); } + public deleteProxy(connectionUri: string, proxy: sqlops.AgentProxyInfo): Thenable { + return this._runAction(connectionUri, (runner) => { + return runner.deleteProxy(connectionUri, proxy); + }); + } public getJobHistory(connectionUri: string, jobID: string): Thenable { return this._runAction(connectionUri, (runner) => { @@ -60,7 +83,6 @@ export class JobManagementService implements IJobManagementService { }); } - private _runAction(uri: string, action: (handler: sqlops.AgentServicesProvider) => Thenable): Thenable { let providerId: string = this._connectionService.getProviderIdFromUri(uri); diff --git a/src/sql/parts/jobManagement/views/alertsView.component.ts b/src/sql/parts/jobManagement/views/alertsView.component.ts index 159cb4031e..183d76a611 100644 --- a/src/sql/parts/jobManagement/views/alertsView.component.ts +++ b/src/sql/parts/jobManagement/views/alertsView.component.ts @@ -12,7 +12,6 @@ import 'vs/css!../common/media/jobs'; import 'vs/css!sql/media/icons/common-icons'; import 'vs/css!sql/base/browser/ui/table/media/table'; - import * as dom from 'vs/base/browser/dom'; import * as nls from 'vs/nls'; import * as sqlops from 'sqlops'; @@ -21,7 +20,7 @@ import { TabChild } from 'sql/base/browser/ui/panel/tab.component'; import { Table } from 'sql/base/browser/ui/table/table'; import { AgentViewComponent } from 'sql/parts/jobManagement/agent/agentView.component'; import { IJobManagementService } from 'sql/parts/jobManagement/common/interfaces'; -import { EditAlert, DeleteAlert } from 'sql/parts/jobManagement/common/jobActions'; +import { EditAlertAction, DeleteAlertAction } from 'sql/parts/jobManagement/common/jobActions'; import { JobManagementView } from 'sql/parts/jobManagement/views/jobManagementView'; import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { IThemeService } from 'vs/platform/theme/common/themeService'; @@ -31,6 +30,7 @@ import { IAction } from 'vs/base/common/actions'; import { TPromise } from 'vs/base/common/winjs.base'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; export const VIEW_SELECTOR: string = 'jobalertsview-component'; export const ROW_HEIGHT: number = 45; @@ -69,17 +69,19 @@ export class AlertsViewComponent extends JobManagementView implements OnInit { public alerts: sqlops.AgentAlertInfo[]; constructor( - @Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: CommonServiceInterface, @Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef, @Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => AgentViewComponent)) private _agentViewComponent: AgentViewComponent, @Inject(IJobManagementService) private _jobManagementService: IJobManagementService, @Inject(IThemeService) private _themeService: IThemeService, @Inject(ICommandService) private _commandService: ICommandService, + @Inject(IInstantiationService) private _instantiationService: IInstantiationService, + @Inject(forwardRef(() => CommonServiceInterface)) commonService: CommonServiceInterface, @Inject(IContextMenuService) contextMenuService: IContextMenuService, - @Inject(IKeybindingService) keybindingService: IKeybindingService) { - super(contextMenuService, keybindingService); - this._isCloud = this._dashboardService.connectionManagementService.connectionInfo.serverInfo.isCloud; + @Inject(IKeybindingService) keybindingService: IKeybindingService + ) { + super(commonService, contextMenuService, keybindingService); + this._isCloud = commonService.connectionManagementService.connectionInfo.serverInfo.isCloud; } ngOnInit(){ @@ -116,7 +118,7 @@ export class AlertsViewComponent extends JobManagementView implements OnInit { self.openContextMenu(e); })); - let ownerUri: string = this._dashboardService.connectionManagementService.connectionInfo.ownerUri; + let ownerUri: string = this._commonService.connectionManagementService.connectionInfo.ownerUri; this._jobManagementService.getAlerts(ownerUri).then((result) => { if (result && result.alerts) { self.alerts = result.alerts; @@ -153,13 +155,19 @@ export class AlertsViewComponent extends JobManagementView implements OnInit { protected getTableActions(): TPromise { let actions: IAction[] = []; - actions.push(new EditAlert(EditAlert.ID, EditAlert.LABEL)); - actions.push(new DeleteAlert(DeleteAlert.ID, DeleteAlert.LABEL)); + actions.push(this._instantiationService.createInstance(EditAlertAction)); + actions.push(this._instantiationService.createInstance(DeleteAlertAction)); return TPromise.as(actions); } + protected getCurrentTableObject(rowIndex: number): any { + return (this.alerts && this.alerts.length >= rowIndex) + ? this.alerts[rowIndex] + : undefined; + } + private openCreateAlertDialog() { - let ownerUri: string = this._dashboardService.connectionManagementService.connectionInfo.ownerUri; + let ownerUri: string = this._commonService.connectionManagementService.connectionInfo.ownerUri; this._commandService.executeCommand('agent.openCreateAlertDialog', ownerUri); } diff --git a/src/sql/parts/jobManagement/views/jobManagementView.ts b/src/sql/parts/jobManagement/views/jobManagementView.ts index 196abe60d9..4e65171820 100644 --- a/src/sql/parts/jobManagement/views/jobManagementView.ts +++ b/src/sql/parts/jobManagement/views/jobManagementView.ts @@ -4,14 +4,15 @@ *--------------------------------------------------------------------------------------------*/ import { ElementRef, AfterContentChecked } from '@angular/core'; +import { Table } from 'sql/base/browser/ui/table/table'; import { AgentViewComponent } from 'sql/parts/jobManagement/agent/agentView.component'; +import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { IAction } from 'vs/base/common/actions'; import { ResolvedKeybinding } from 'vs/base/common/keyCodes'; +import { Disposable } from 'vs/base/common/lifecycle'; +import { TPromise } from 'vs/base/common/winjs.base'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; -import { Disposable } from 'vs/base/common/lifecycle'; -import { Table } from 'sql/base/browser/ui/table/table'; -import { TPromise } from 'vs/base/common/winjs.base'; export abstract class JobManagementView extends Disposable implements AfterContentChecked { protected isVisible: boolean = false; @@ -23,6 +24,7 @@ export abstract class JobManagementView extends Disposable implements AfterConte protected _table: Table; constructor( + protected _commonService: CommonServiceInterface, protected _contextMenuService: IContextMenuService, protected _keybindingService: IKeybindingService) { super(); @@ -51,17 +53,19 @@ export abstract class JobManagementView extends Disposable implements AfterConte abstract onFirstVisible(); protected openContextMenu(event): void { + let grid = this._table.grid; + let rowIndex = grid.getCellFromEvent(event).row; + + let targetObject = this.getCurrentTableObject(rowIndex); let actions = this.getTableActions(); if (actions) { - let grid = this._table.grid; - let rowIndex = grid.getCellFromEvent(event).row; - + let ownerUri: string = this._commonService.connectionManagementService.connectionInfo.ownerUri; let actionContext= { - rowIndex: rowIndex + ownerUri: ownerUri, + targetObject: targetObject }; let anchor = { x: event.pageX + 1, y: event.pageY }; - this._contextMenuService.showContextMenu({ getAnchor: () => anchor, getActions: () => actions, @@ -79,4 +83,8 @@ export abstract class JobManagementView extends Disposable implements AfterConte protected getTableActions(): TPromise { return undefined; } + + protected getCurrentTableObject(rowIndex: number): any { + return undefined; + } } \ No newline at end of file diff --git a/src/sql/parts/jobManagement/views/jobsView.component.ts b/src/sql/parts/jobManagement/views/jobsView.component.ts index 2f30e7cc25..2667642c29 100644 --- a/src/sql/parts/jobManagement/views/jobsView.component.ts +++ b/src/sql/parts/jobManagement/views/jobsView.component.ts @@ -21,7 +21,7 @@ import { Table } from 'sql/base/browser/ui/table/table'; import { AgentViewComponent } from 'sql/parts/jobManagement/agent/agentView.component'; import { RowDetailView } from 'sql/base/browser/ui/table/plugins/rowdetailview'; import { JobCacheObject } from 'sql/parts/jobManagement/common/jobManagementService'; -import { EditJob, DeleteJob } from 'sql/parts/jobManagement/common/jobActions'; +import { EditJobAction, DeleteJobAction } from 'sql/parts/jobManagement/common/jobActions'; import { JobManagementUtilities } from 'sql/parts/jobManagement/common/jobManagementUtilities'; import { HeaderFilter } from 'sql/base/browser/ui/table/plugins/headerFilter.plugin'; import { IJobManagementService } from 'sql/parts/jobManagement/common/interfaces'; @@ -33,6 +33,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { TPromise } from 'vs/base/common/winjs.base'; import { IAction } from 'vs/base/common/actions'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; export const JOBSVIEW_SELECTOR: string = 'jobsview-component'; export const ROW_HEIGHT: number = 45; @@ -90,19 +91,20 @@ export class JobsViewComponent extends JobManagementView implements OnInit { @ViewChild('jobsgrid') _gridEl: ElementRef; constructor( - @Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: CommonServiceInterface, + @Inject(forwardRef(() => CommonServiceInterface)) commonService: CommonServiceInterface, @Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef, @Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => AgentViewComponent)) private _agentViewComponent: AgentViewComponent, @Inject(IJobManagementService) private _jobManagementService: IJobManagementService, @Inject(IThemeService) private _themeService: IThemeService, @Inject(ICommandService) private _commandService: ICommandService, + @Inject(IInstantiationService) private _instantiationService: IInstantiationService, @Inject(IContextMenuService) contextMenuService: IContextMenuService, @Inject(IKeybindingService) keybindingService: IKeybindingService ) { - super(contextMenuService, keybindingService); + super(commonService, contextMenuService, keybindingService); let jobCacheObjectMap = this._jobManagementService.jobCacheObjectMap; - this._serverName = _dashboardService.connectionManagementService.connectionInfo.connectionProfile.serverName; + this._serverName = commonService.connectionManagementService.connectionInfo.connectionProfile.serverName; let jobCache = jobCacheObjectMap[this._serverName]; if (jobCache) { this._jobCacheObject = jobCache; @@ -111,7 +113,7 @@ export class JobsViewComponent extends JobManagementView implements OnInit { this._jobCacheObject.serverName = this._serverName; this._jobManagementService.addToCache(this._serverName, this._jobCacheObject); } - this._isCloud = this._dashboardService.connectionManagementService.connectionInfo.serverInfo.isCloud; + this._isCloud = commonService.connectionManagementService.connectionInfo.serverInfo.isCloud; } ngOnInit(){ @@ -184,7 +186,7 @@ export class JobsViewComponent extends JobManagementView implements OnInit { this._cd.detectChanges(); } } else { - let ownerUri: string = this._dashboardService.connectionManagementService.connectionInfo.ownerUri; + let ownerUri: string = this._commonService.connectionManagementService.connectionInfo.ownerUri; this._jobManagementService.getJobs(ownerUri).then((result) => { if (result && result.jobs) { self.jobs = result.jobs; @@ -525,7 +527,7 @@ export class JobsViewComponent extends JobManagementView implements OnInit { private loadJobHistories(): void { if (this.jobs) { let erroredJobs = 0; - let ownerUri: string = this._dashboardService.connectionManagementService.connectionInfo.ownerUri; + let ownerUri: string = this._commonService.connectionManagementService.connectionInfo.ownerUri; let separatedJobs = this.separateFailingJobs(); // grab histories of the failing jobs first // so they can be expanded quicker @@ -823,13 +825,27 @@ export class JobsViewComponent extends JobManagementView implements OnInit { protected getTableActions(): TPromise { let actions: IAction[] = []; - actions.push(new EditJob(EditJob.ID, EditJob.LABEL)); - actions.push(new DeleteJob(DeleteJob.ID, DeleteJob.LABEL)); + actions.push(this._instantiationService.createInstance(EditJobAction)); + actions.push(this._instantiationService.createInstance(DeleteJobAction)); return TPromise.as(actions); } + protected getCurrentTableObject(rowIndex: number): any { + let data = this._table.grid.getData(); + if (!data || rowIndex >= data.getLength()) { + return undefined; + } + + let jobId = data.getItem(rowIndex).jobId; + let job = this.jobs.filter(job => { + return job.jobId === jobId; + }); + + return job && job.length > 0 ? job[0] : undefined; + } + private openCreateJobDialog() { - let ownerUri: string = this._dashboardService.connectionManagementService.connectionInfo.ownerUri; + let ownerUri: string = this._commonService.connectionManagementService.connectionInfo.ownerUri; this._commandService.executeCommand('agent.openCreateJobDialog', ownerUri); } diff --git a/src/sql/parts/jobManagement/views/operatorsView.component.ts b/src/sql/parts/jobManagement/views/operatorsView.component.ts index 7568cf7330..00f93febd0 100644 --- a/src/sql/parts/jobManagement/views/operatorsView.component.ts +++ b/src/sql/parts/jobManagement/views/operatorsView.component.ts @@ -19,7 +19,7 @@ import { Component, Inject, forwardRef, ElementRef, ChangeDetectorRef, ViewChild import { Table } from 'sql/base/browser/ui/table/table'; import { AgentViewComponent } from 'sql/parts/jobManagement/agent/agentView.component'; import { IJobManagementService } from 'sql/parts/jobManagement/common/interfaces'; -import { EditOperator, DeleteOperator } from 'sql/parts/jobManagement/common/jobActions'; +import { EditOperatorAction, DeleteOperatorAction } from 'sql/parts/jobManagement/common/jobActions'; import { JobManagementView } from 'sql/parts/jobManagement/views/jobManagementView'; import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { IThemeService } from 'vs/platform/theme/common/themeService'; @@ -29,6 +29,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { TPromise } from 'vs/base/common/winjs.base'; import { IAction } from 'vs/base/common/actions'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; export const VIEW_SELECTOR: string = 'joboperatorsview-component'; export const ROW_HEIGHT: number = 45; @@ -67,18 +68,19 @@ export class OperatorsViewComponent extends JobManagementView implements OnInit public operators: sqlops.AgentOperatorInfo[]; constructor( - @Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: CommonServiceInterface, @Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef, @Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => AgentViewComponent)) private _agentViewComponent: AgentViewComponent, @Inject(IJobManagementService) private _jobManagementService: IJobManagementService, @Inject(IThemeService) private _themeService: IThemeService, @Inject(ICommandService) private _commandService: ICommandService, + @Inject(IInstantiationService) private _instantiationService: IInstantiationService, + @Inject(forwardRef(() => CommonServiceInterface)) commonService: CommonServiceInterface, @Inject(IContextMenuService) contextMenuService: IContextMenuService, @Inject(IKeybindingService) keybindingService: IKeybindingService ) { - super(contextMenuService, keybindingService); - this._isCloud = this._dashboardService.connectionManagementService.connectionInfo.serverInfo.isCloud; + super(commonService, contextMenuService, keybindingService); + this._isCloud = commonService.connectionManagementService.connectionInfo.serverInfo.isCloud; } ngOnInit(){ @@ -115,7 +117,7 @@ export class OperatorsViewComponent extends JobManagementView implements OnInit self.openContextMenu(e); })); - let ownerUri: string = this._dashboardService.connectionManagementService.connectionInfo.ownerUri; + let ownerUri: string = this._commonService.connectionManagementService.connectionInfo.ownerUri; this._jobManagementService.getOperators(ownerUri).then((result) => { if (result && result.operators) { self.operators = result.operators; @@ -150,13 +152,19 @@ export class OperatorsViewComponent extends JobManagementView implements OnInit protected getTableActions(): TPromise { let actions: IAction[] = []; - actions.push(new EditOperator(EditOperator.ID, EditOperator.LABEL)); - actions.push(new DeleteOperator(DeleteOperator.ID, DeleteOperator.LABEL)); + actions.push(this._instantiationService.createInstance(EditOperatorAction)); + actions.push(this._instantiationService.createInstance(DeleteOperatorAction)); return TPromise.as(actions); } + protected getCurrentTableObject(rowIndex: number): any { + return (this.operators && this.operators.length >= rowIndex) + ? this.operators[rowIndex] + : undefined; + } + private openCreateOperatorDialog() { - let ownerUri: string = this._dashboardService.connectionManagementService.connectionInfo.ownerUri; + let ownerUri: string = this._commonService.connectionManagementService.connectionInfo.ownerUri; this._commandService.executeCommand('agent.openCreateOperatorDialog', ownerUri); } diff --git a/src/sql/parts/jobManagement/views/proxiesView.component.ts b/src/sql/parts/jobManagement/views/proxiesView.component.ts index 4d026b03f0..10c8de3730 100644 --- a/src/sql/parts/jobManagement/views/proxiesView.component.ts +++ b/src/sql/parts/jobManagement/views/proxiesView.component.ts @@ -19,7 +19,7 @@ import { Component, Inject, forwardRef, ElementRef, ChangeDetectorRef, ViewChild import { Table } from 'sql/base/browser/ui/table/table'; import { AgentViewComponent } from 'sql/parts/jobManagement/agent/agentView.component'; import { IJobManagementService } from 'sql/parts/jobManagement/common/interfaces'; -import { EditProxy, DeleteProxy } from 'sql/parts/jobManagement/common/jobActions'; +import { EditProxyAction, DeleteProxyAction } from 'sql/parts/jobManagement/common/jobActions'; import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { TabChild } from 'sql/base/browser/ui/panel/tab.component'; import { JobManagementView } from 'sql/parts/jobManagement/views/jobManagementView'; @@ -29,6 +29,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { IAction } from 'vs/base/common/actions'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { IThemeService } from 'vs/platform/theme/common/themeService'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; export const VIEW_SELECTOR: string = 'jobproxiesview-component'; export const ROW_HEIGHT: number = 45; @@ -66,18 +67,19 @@ export class ProxiesViewComponent extends JobManagementView implements OnInit { @ViewChild('proxiesgrid') _gridEl: ElementRef; constructor( - @Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: CommonServiceInterface, @Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef, @Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => AgentViewComponent)) private _agentViewComponent: AgentViewComponent, @Inject(IJobManagementService) private _jobManagementService: IJobManagementService, @Inject(IThemeService) private _themeService: IThemeService, @Inject(ICommandService) private _commandService: ICommandService, + @Inject(IInstantiationService) private _instantiationService: IInstantiationService, + @Inject(forwardRef(() => CommonServiceInterface)) commonService: CommonServiceInterface, @Inject(IContextMenuService) contextMenuService: IContextMenuService, @Inject(IKeybindingService) keybindingService: IKeybindingService ) { - super(contextMenuService, keybindingService); - this._isCloud = this._dashboardService.connectionManagementService.connectionInfo.serverInfo.isCloud; + super(commonService, contextMenuService, keybindingService); + this._isCloud = commonService.connectionManagementService.connectionInfo.serverInfo.isCloud; } ngOnInit(){ @@ -114,7 +116,7 @@ export class ProxiesViewComponent extends JobManagementView implements OnInit { self.openContextMenu(e); })); - let ownerUri: string = this._dashboardService.connectionManagementService.connectionInfo.ownerUri; + let ownerUri: string = this._commonService.connectionManagementService.connectionInfo.ownerUri; this._jobManagementService.getProxies(ownerUri).then((result) => { if (result && result.proxies) { self.proxies = result.proxies; @@ -148,13 +150,19 @@ export class ProxiesViewComponent extends JobManagementView implements OnInit { protected getTableActions(): TPromise { let actions: IAction[] = []; - actions.push(new EditProxy(EditProxy.ID, EditProxy.LABEL)); - actions.push(new DeleteProxy(DeleteProxy.ID, DeleteProxy.LABEL)); + actions.push(this._instantiationService.createInstance(EditProxyAction)); + actions.push(this._instantiationService.createInstance(DeleteProxyAction)); return TPromise.as(actions); } + protected getCurrentTableObject(rowIndex: number): any { + return (this.proxies && this.proxies.length >= rowIndex) + ? this.proxies[rowIndex] + : undefined; + } + private openCreateProxyDialog() { - let ownerUri: string = this._dashboardService.connectionManagementService.connectionInfo.ownerUri; + let ownerUri: string = this._commonService.connectionManagementService.connectionInfo.ownerUri; this._commandService.executeCommand('agent.openCreateProxyDialog', ownerUri); } diff --git a/src/sql/workbench/api/node/extHostDataProtocol.ts b/src/sql/workbench/api/node/extHostDataProtocol.ts index 1d0e94e7cc..b6a47110f1 100644 --- a/src/sql/workbench/api/node/extHostDataProtocol.ts +++ b/src/sql/workbench/api/node/extHostDataProtocol.ts @@ -555,6 +555,13 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape { return this._resolveProvider(handle).jobAction(ownerUri, jobName, action); } + /** + * Deletes a job + */ + $deleteJob(handle: number, ownerUri: string, job: sqlops.AgentJobInfo): Thenable { + throw this._resolveProvider(handle).deleteJob(ownerUri, job); + } + /** * Get Agent Alerts list */ @@ -562,6 +569,13 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape { return this._resolveProvider(handle).getAlerts(ownerUri); } + /** + * Deletes an alert + */ + $deleteAlert(handle: number, ownerUri: string, alert: sqlops.AgentAlertInfo): Thenable { + return this._resolveProvider(handle).deleteAlert(ownerUri, alert); + } + /** * Get Agent Oeprators list */ @@ -569,10 +583,24 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape { return this._resolveProvider(handle).getOperators(ownerUri); } + /** + * Deletes an operator + */ + $deleteOperator(handle: number, ownerUri: string, operator: sqlops.AgentOperatorInfo): Thenable { + return this._resolveProvider(handle).deleteOperator(ownerUri, operator); + } + /** * Get Agent Proxies list */ $getProxies(handle: number, ownerUri: string): Thenable { return this._resolveProvider(handle).getProxies(ownerUri); } + + /** + * Deletes a proxy + */ + $deleteProxy(handle: number, ownerUri: string, proxy: sqlops.AgentProxyInfo): Thenable { + return this._resolveProvider(handle).deleteProxy(ownerUri, proxy); + } } diff --git a/src/sql/workbench/api/node/mainThreadDataProtocol.ts b/src/sql/workbench/api/node/mainThreadDataProtocol.ts index 022207ddcf..96d87fa631 100644 --- a/src/sql/workbench/api/node/mainThreadDataProtocol.ts +++ b/src/sql/workbench/api/node/mainThreadDataProtocol.ts @@ -345,15 +345,27 @@ export class MainThreadDataProtocol implements MainThreadDataProtocolShape { jobAction(connectionUri: string, jobName: string, action: string): Thenable { return self._proxy.$jobAction(handle, connectionUri, jobName, action); }, + deleteJob(connectionUri: string, jobInfo: sqlops.AgentJobInfo): Thenable { + return self._proxy.$deleteJob(handle, connectionUri, jobInfo); + }, getAlerts(connectionUri: string): Thenable { return self._proxy.$getAlerts(handle, connectionUri); }, + deleteAlert(connectionUri: string, alertInfo: sqlops.AgentAlertInfo): Thenable { + return self._proxy.$deleteAlert(handle, connectionUri, alertInfo); + }, getOperators(connectionUri: string): Thenable { return self._proxy.$getOperators(handle, connectionUri); }, + deleteOperator(connectionUri: string, operatorInfo: sqlops.AgentOperatorInfo): Thenable { + return self._proxy.$deleteOperator(handle, connectionUri, operatorInfo); + }, getProxies(connectionUri: string): Thenable { return self._proxy.$getProxies(handle, connectionUri); - } + }, + deleteProxy(connectionUri: string, proxyInfo: sqlops.AgentProxyInfo): Thenable { + return self._proxy.$deleteProxy(handle, connectionUri, proxyInfo); + }, }); return undefined; diff --git a/src/sql/workbench/api/node/sqlExtHost.protocol.ts b/src/sql/workbench/api/node/sqlExtHost.protocol.ts index 03d43f0456..568c68d646 100644 --- a/src/sql/workbench/api/node/sqlExtHost.protocol.ts +++ b/src/sql/workbench/api/node/sqlExtHost.protocol.ts @@ -338,20 +338,40 @@ export abstract class ExtHostDataProtocolShape { */ $jobAction(handle: number, ownerUri: string, jobName: string, action: string): Thenable { throw ni(); } + /** + * Deletes a job + */ + $deleteJob(handle: number, ownerUri: string, job: sqlops.AgentJobInfo): Thenable { throw ni(); } + /** * Get Agent Alerts list */ $getAlerts(handle: number, connectionUri: string): Thenable { throw ni(); } + /** + * Deletes an alert + */ + $deleteAlert(handle: number, connectionUri: string, alert: sqlops.AgentAlertInfo): Thenable { throw ni(); } + /** * Get Agent Oeprators list */ $getOperators(handle: number, connectionUri: string): Thenable { throw ni(); } + /** + * Deletes an operator + */ + $deleteOperator(handle: number, connectionUri: string, operator: sqlops.AgentOperatorInfo): Thenable { throw ni(); } + /** * Get Agent Proxies list */ $getProxies(handle: number, connectionUri: string): Thenable { throw ni(); } + + /** + * Deletes a proxy + */ + $deleteProxy(handle: number, connectionUri: string, proxy: sqlops.AgentProxyInfo): Thenable { throw ni(); } } /**