Agent - committer work (#4758)

* fix delete job

* added the ability to change and retrieve jobowner

* fixed UX for delete step

* improved operator actions

* fixed operators and proxies

* added errors for failures
This commit is contained in:
Aditya Bist
2019-03-29 13:46:52 -07:00
committed by GitHub
parent e70d5838a8
commit d4f287298f
9 changed files with 99 additions and 59 deletions

View File

@@ -108,6 +108,7 @@ export class JobData implements IAgentDialogData {
this._defaultOwner = jobDefaults.owner;
this._operators = ['', this._defaultOwner];
this.owner = this.owner ? this.owner : this._defaultOwner;
}
this._jobCompletionActionConditions = [{
@@ -128,8 +129,22 @@ export class JobData implements IAgentDialogData {
? await this._agentService.createJob(this.ownerUri, jobInfo)
: await this._agentService.updateJob(this.ownerUri, this.originalName, jobInfo);
if (!result || !result.success) {
vscode.window.showErrorMessage(
localize('jobData.saveErrorMessage', "Job update failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
if (this.dialogMode === AgentDialogMode.EDIT) {
vscode.window.showErrorMessage(
localize('jobData.saveErrorMessage', "Job update failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
} else {
vscode.window.showErrorMessage(
localize('jobData.newJobErrorMessage', "Job creation failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
}
} else {
if (this.dialogMode === AgentDialogMode.EDIT) {
vscode.window.showInformationMessage(
localize('jobData.saveSucessMessage', "Job '{0}' updated successfully", jobInfo.name));
} else {
vscode.window.showInformationMessage(
localize('jobData.newJobSuccessMessage',"Job '{0}' created successfully", jobInfo.name));
}
}
}
@@ -149,7 +164,7 @@ export class JobData implements IAgentDialogData {
public toAgentJobInfo(): azdata.AgentJobInfo {
return {
name: this.name,
owner: this.owner,
owner: this.owner ? this.owner : this.defaultOwner,
description: this.description,
emailLevel: this.emailLevel,
pageLevel: this.pageLevel,

View File

@@ -31,11 +31,25 @@ export class OperatorData implements IAgentDialogData {
constructor(ownerUri:string, operatorInfo: azdata.AgentOperatorInfo) {
this.ownerUri = ownerUri;
if (operatorInfo) {
this.dialogMode = AgentDialogMode.EDIT;
this.name = operatorInfo.name;
this.id = operatorInfo.id;
this.emailAddress = operatorInfo.emailAddress;
this.enabled = operatorInfo.enabled;
this.lastEmailDate = operatorInfo.lastEmailDate;
this.lastNetSendDate = operatorInfo.lastNetSendDate;
this.lastPagerDate = operatorInfo.lastPagerDate;
this.pagerAddress = operatorInfo.pagerAddress;
this.categoryName = operatorInfo.categoryName;
this.pagerDays = operatorInfo.pagerDays.toString();
this.saturdayPagerEndTime = operatorInfo.saturdayPagerEndTime;
this.saturdayPagerStartTime = operatorInfo.saturdayPagerStartTime;
this.sundayPagerEndTime = operatorInfo.sundayPagerEndTime;
this.sundayPagerStartTime = operatorInfo.sundayPagerStartTime;
this.netSendAddress = operatorInfo.netSendAddress;
this.weekdayPagerStartTime = operatorInfo.weekdayPagerStartTime;
this.weekdayPagerEndTime = operatorInfo.weekdayPagerEndTime;
}
}

View File

@@ -4,9 +4,12 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as nls from 'vscode-nls';
import * as azdata from 'azdata';
import * as vscode from 'vscode';
import { AgentUtils } from '../agentUtils';
import { IAgentDialogData, AgentDialogMode } from '../interfaces';
const localize = nls.loadMessageBundle();
export class ProxyData implements IAgentDialogData {
public dialogMode: AgentDialogMode = AgentDialogMode.CREATE;
@@ -34,9 +37,20 @@ export class ProxyData implements IAgentDialogData {
public async save() {
let agentService = await AgentUtils.getAgentService();
let result = await agentService.createProxy(this.ownerUri, this.toAgentProxyInfo());
let proxyInfo = this.toAgentProxyInfo();
let result = await agentService.createProxy(this.ownerUri, proxyInfo);
if (!result || !result.success) {
// TODO handle error here
vscode.window.showErrorMessage(
localize('proxyData.saveErrorMessage', "Proxy update failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
} else {
if (this.dialogMode === AgentDialogMode.EDIT) {
vscode.window.showInformationMessage(
localize('proxyData.saveSucessMessage', "Proxy '{0}' updated successfully", proxyInfo.accountName));
} else {
vscode.window.showInformationMessage(
localize('proxyData.newJobSuccessMessage',"Proxy '{0}' created successfully", proxyInfo.accountName));
}
}
}