Refresh agent dashboard panel after create\update\delete operations (#1861)

* Edit alert WIP

* A couple alert edit bugs

* Hook up dashboard refresh notification

* Hook onchange event to other agent service calls

* Switch update handler to scalar value

* Add null check on handler callback
This commit is contained in:
Karl Burtram
2018-07-06 08:57:30 -07:00
committed by GitHub
parent 6f9a27ecc7
commit 21bad7a01f
25 changed files with 280 additions and 103 deletions

View File

@@ -18,6 +18,7 @@ import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
import { AgentJobInfo, AgentJobHistoryInfo } from 'sqlops';
import { PanelComponent, IPanelOptions, NavigationBarLayout } from 'sql/base/browser/ui/panel/panel.component';
import { IJobManagementService } from 'sql/parts/jobManagement/common/interfaces';
export const DASHBOARD_SELECTOR: string = 'agentview-component';
@@ -56,8 +57,15 @@ export class AgentViewComponent {
};
constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef) {
@Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef,
@Inject(IJobManagementService) jobManagementService: IJobManagementService) {
this._expanded = new Map<string, string>();
let self = this;
jobManagementService.onDidChange((args) => {
self.refresh = true;
self._cd.detectChanges();
});
}
/**

View File

@@ -8,6 +8,7 @@
import * as sqlops from 'sqlops';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { JobCacheObject } from './jobManagementService';
import { Event } from 'vs/base/common/event';
export const SERVICE_ID = 'jobManagementService';
@@ -15,8 +16,10 @@ export const IJobManagementService = createDecorator<IJobManagementService>(SERV
export interface IJobManagementService {
_serviceBrand: any;
onDidChange: Event<void>;
registerProvider(providerId: string, provider: sqlops.AgentServicesProvider): void;
fireOnDidChange(): void;
getJobs(connectionUri: string): Thenable<sqlops.AgentJobsResult>;
getJobHistory(connectionUri: string, jobID: string): Thenable<sqlops.AgentJobHistoryResult>;

View File

@@ -244,11 +244,17 @@ export class EditAlertAction extends Action {
public static ID = 'jobaction.editAlert';
public static LABEL = nls.localize('jobaction.editAlert', "Edit Alert");
constructor() {
constructor(
@ICommandService private _commandService: ICommandService
) {
super(EditAlertAction.ID, EditAlertAction.LABEL);
}
public run(actionInfo: IJobActionInfo): TPromise<boolean> {
this._commandService.executeCommand(
'agent.openAlertDialog',
actionInfo.ownerUri,
actionInfo.targetObject);
return TPromise.as(true);
}
}

View File

@@ -10,11 +10,14 @@ import * as sqlops from 'sqlops';
import { TPromise } from 'vs/base/common/winjs.base';
import { IJobManagementService } from 'sql/parts/jobManagement/common/interfaces';
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
import { Event, Emitter } from 'vs/base/common/event';
export class JobManagementService implements IJobManagementService {
_serviceBrand: any;
private _onDidChange = new Emitter<void>();
public readonly onDidChange: Event<void> = this._onDidChange.event;
private _providers: { [handle: string]: sqlops.AgentServicesProvider; } = Object.create(null);
private _jobCacheObject : {[server: string]: JobCacheObject; } = {};
@@ -23,6 +26,10 @@ export class JobManagementService implements IJobManagementService {
) {
}
public fireOnDidChange(): void {
this._onDidChange.fire(void 0);
}
public getJobs(connectionUri: string): Thenable<sqlops.AgentJobsResult> {
return this._runAction(connectionUri, (runner) => {
return runner.getJobs(connectionUri);

View File

@@ -164,7 +164,7 @@ export class AlertsViewComponent extends JobManagementView implements OnInit {
public openCreateAlertDialog() {
let ownerUri: string = this._commonService.connectionManagementService.connectionInfo.ownerUri;
this._commandService.executeCommand('agent.openCreateAlertDialog', ownerUri);
this._commandService.executeCommand('agent.openAlertDialog', ownerUri);
}
private refreshJobs() {

View File

@@ -136,7 +136,7 @@ export class ProxiesViewComponent extends JobManagementView implements OnInit {
private onProxiesAvailable(proxies: sqlops.AgentProxyInfo[]) {
let items: any = proxies.map((item) => {
return {
id: item.id,
id: item.accountName,
accountName: item.accountName,
credentialName: item.credentialName
};

3
src/sql/sqlops.d.ts vendored
View File

@@ -1384,12 +1384,13 @@ declare module 'sqlops' {
updateProxy(ownerUri: string, originalProxyName: string, proxyInfo: AgentProxyInfo): Thenable<UpdateAgentOperatorResult>;
deleteProxy(ownerUri: string, proxyInfo: AgentProxyInfo): Thenable<ResultStatus>;
// Job Schedule management methods
getJobSchedules(ownerUri: string): Thenable<AgentJobSchedulesResult>;
createJobSchedule(ownerUri: string, scheduleInfo: AgentJobScheduleInfo): Thenable<CreateAgentJobScheduleResult>;
updateJobSchedule(ownerUri: string, originalScheduleName: string, scheduleInfo: AgentJobScheduleInfo): Thenable<UpdateAgentJobScheduleResult>;
deleteJobSchedule(ownerUri: string, scheduleInfo: AgentJobScheduleInfo): Thenable<ResultStatus>;
registerOnUpdated(handler: () => any): void;
}
// Task service interfaces ----------------------------------------------------------------------------

View File

@@ -603,4 +603,11 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
$deleteProxy(handle: number, ownerUri: string, proxy: sqlops.AgentProxyInfo): Thenable<sqlops.ResultStatus> {
return this._resolveProvider<sqlops.AgentServicesProvider>(handle).deleteProxy(ownerUri, proxy);
}
/**
* SQL Agent job data update notification
*/
public $onJobDataUpdated(handle: Number): void {
this._proxy.$onJobDataUpdated(handle);
}
}

View File

@@ -460,6 +460,11 @@ export class MainThreadDataProtocol implements MainThreadDataProtocolShape {
this._profilerService.onSessionStopped(response);
}
// SQL Server Agent handlers
public $onJobDataUpdated(handle: Number): void {
this._jobManagementService.fireOnDidChange();
}
public $unregisterProvider(handle: number): TPromise<any> {
let capabilitiesRegistration = this._capabilitiesRegistrations[handle];
if (capabilitiesRegistration) {

View File

@@ -265,6 +265,10 @@ export function createApiFactory(
};
let registerAgentServicesProvider = (provider: sqlops.AgentServicesProvider): vscode.Disposable => {
provider.registerOnUpdated(() => {
extHostDataProvider.$onJobDataUpdated(provider.handle);
});
return extHostDataProvider.$registerAgentServiceProvider(provider);
};

View File

@@ -456,6 +456,7 @@ export interface MainThreadDataProtocolShape extends IDisposable {
$onScriptingComplete(handle: number, message: sqlops.ScriptingCompleteResult): void;
$onSessionEventsAvailable(handle: number, response: sqlops.ProfilerSessionEvents): void;
$onSessionStopped(handle: number, response: sqlops.ProfilerSessionStoppedParams): void;
$onJobDataUpdated(handle: Number): void;
/**
* Callback when a session has completed initialization