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

@@ -4,14 +4,20 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as nls from 'vscode-nls';
import * as vscode from 'vscode';
import * as sqlops from 'sqlops';
import { AgentUtils } from '../agentUtils';
import { IAgentDialogData } from '../interfaces';
import { IAgentDialogData, AgentDialogMode } from '../interfaces';
const localize = nls.loadMessageBundle();
export class AlertData implements IAgentDialogData {
ownerUri: string;
dialogMode: AgentDialogMode = AgentDialogMode.CREATE;
id: number;
name: string;
originalName: string;
delayBetweenResponses: number;
eventDescriptionKeyword: string;
eventSource: string;
@@ -34,8 +40,36 @@ export class AlertData implements IAgentDialogData {
wmiEventNamespace: string;
wmiEventQuery: string;
constructor(ownerUri:string) {
constructor(ownerUri:string, alertInfo: sqlops.AgentAlertInfo) {
this.ownerUri = ownerUri;
if (alertInfo) {
this.dialogMode = AgentDialogMode.EDIT;
this.id = alertInfo.id;
this.name = alertInfo.name;
this.originalName = alertInfo.name;
this.delayBetweenResponses = alertInfo.delayBetweenResponses;
this.eventDescriptionKeyword = alertInfo.eventDescriptionKeyword;
this.eventSource = alertInfo.eventSource;
this.hasNotification = alertInfo.hasNotification;
this.includeEventDescription = alertInfo.includeEventDescription.toString();
this.isEnabled = alertInfo.isEnabled;
this.jobId = alertInfo.jobId;
this.jobName = alertInfo.jobName;
this.lastOccurrenceDate = alertInfo.lastOccurrenceDate;
this.lastResponseDate = alertInfo.lastResponseDate;
this.messageId = alertInfo.messageId;
this.notificationMessage = alertInfo.notificationMessage;
this.occurrenceCount = alertInfo.occurrenceCount;
this.performanceCondition = alertInfo.performanceCondition;
this.severity = alertInfo.severity;
this.databaseName = alertInfo.databaseName;
this.countResetDate = alertInfo.countResetDate;
this.categoryName = alertInfo.categoryName;
this.alertType = alertInfo.alertType.toString();
this.wmiEventNamespace = alertInfo.wmiEventNamespace;
this.wmiEventQuery = alertInfo.wmiEventQuery;
}
}
public async initialize() {
@@ -43,9 +77,13 @@ export class AlertData implements IAgentDialogData {
public async save() {
let agentService = await AgentUtils.getAgentService();
let result = await agentService.createAlert(this.ownerUri, this.toAgentAlertInfo());
let result = this.dialogMode === AgentDialogMode.CREATE
? await agentService.createAlert(this.ownerUri, this.toAgentAlertInfo())
: await agentService.updateAlert(this.ownerUri, this.originalName, this.toAgentAlertInfo());
if (!result || !result.success) {
// TODO handle error here
vscode.window.showErrorMessage(
localize('alertData.saveErrorMessage', "Alert update failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
}
}
@@ -76,4 +114,4 @@ export class AlertData implements IAgentDialogData {
wmiEventQuery: this.wmiEventQuery
};
}
}
}

View File

@@ -6,7 +6,7 @@
import * as sqlops from 'sqlops';
import { AgentUtils } from '../agentUtils';
import { IAgentDialogData } from '../interfaces';
import { IAgentDialogData, AgentDialogMode } from '../interfaces';
export class JobData implements IAgentDialogData {
@@ -23,6 +23,7 @@ export class JobData implements IAgentDialogData {
private _defaultOwner: string;
private _jobCompletionActionConditions: sqlops.CategoryValue[];
public dialogMode: AgentDialogMode = AgentDialogMode.CREATE;
public name: string;
public enabled: boolean = true;
public description: string;

View File

@@ -5,9 +5,10 @@
'use strict';
import { AgentUtils } from '../agentUtils';
import { IAgentDialogData } from '../interfaces';
import { IAgentDialogData, AgentDialogMode } from '../interfaces';
export class JobStepData implements IAgentDialogData {
public dialogMode: AgentDialogMode = AgentDialogMode.CREATE;
public ownerUri: string;
public jobId: string; //
public jobName: string;

View File

@@ -6,9 +6,10 @@
import * as sqlops from 'sqlops';
import { AgentUtils } from '../agentUtils';
import { IAgentDialogData } from '../interfaces';
import { IAgentDialogData, AgentDialogMode } from '../interfaces';
export class OperatorData implements IAgentDialogData {
public dialogMode: AgentDialogMode = AgentDialogMode.CREATE;
ownerUri: string;
name: string;
id: number;

View File

@@ -6,9 +6,10 @@
import * as sqlops from 'sqlops';
import { AgentUtils } from '../agentUtils';
import { IAgentDialogData } from '../interfaces';
import { IAgentDialogData, AgentDialogMode } from '../interfaces';
export class PickScheduleData implements IAgentDialogData {
public dialogMode: AgentDialogMode = AgentDialogMode.VIEW;
public ownerUri: string;
public schedules: sqlops.AgentJobScheduleInfo[];
public selectedSchedule: sqlops.AgentJobScheduleInfo;

View File

@@ -6,9 +6,10 @@
import * as sqlops from 'sqlops';
import { AgentUtils } from '../agentUtils';
import { IAgentDialogData } from '../interfaces';
import { IAgentDialogData, AgentDialogMode } from '../interfaces';
export class ProxyData implements IAgentDialogData {
public dialogMode: AgentDialogMode = AgentDialogMode.CREATE;
ownerUri: string;
id: number;
accountName: string;

View File

@@ -6,9 +6,10 @@
import * as sqlops from 'sqlops';
import { AgentUtils } from '../agentUtils';
import { IAgentDialogData } from '../interfaces';
import { IAgentDialogData, AgentDialogMode } from '../interfaces';
export class ScheduleData implements IAgentDialogData {
public dialogMode: AgentDialogMode = AgentDialogMode.CREATE;
public ownerUri: string;
public schedules: sqlops.AgentJobScheduleInfo[];
public selectedSchedule: sqlops.AgentJobScheduleInfo;