mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-19 09:35:36 -05:00
Fix agent steps refresh when changing history (#9446)
* layering * switch to events and emitters * changed to self
This commit is contained in:
@@ -208,12 +208,10 @@ export class JobHistoryComponent extends JobManagementView implements OnInit {
|
||||
if (self.agentJobHistoryInfo) {
|
||||
self.agentJobHistoryInfo.runDate = self.formatTime(self.agentJobHistoryInfo.runDate);
|
||||
if (self.agentJobHistoryInfo.steps) {
|
||||
let jobStepStatus = this.didJobFail(self.agentJobHistoryInfo);
|
||||
self._stepRows = self.agentJobHistoryInfo.steps.map(step => {
|
||||
let stepViewRow = new JobStepsViewRow();
|
||||
stepViewRow.message = step.message;
|
||||
stepViewRow.runStatus = jobStepStatus ? JobManagementUtilities.convertToStatusString(0) :
|
||||
JobManagementUtilities.convertToStatusString(step.runStatus);
|
||||
stepViewRow.runStatus = JobManagementUtilities.convertToStatusString(step.runStatus);
|
||||
self._runStatus = JobManagementUtilities.convertToStatusString(self.agentJobHistoryInfo.runStatus);
|
||||
stepViewRow.stepName = step.stepDetails.stepName;
|
||||
stepViewRow.stepId = step.stepDetails.id.toString();
|
||||
@@ -224,25 +222,17 @@ export class JobHistoryComponent extends JobManagementView implements OnInit {
|
||||
self._stepRows[0].stepId = nls.localize('stepRow.stepID', "Step ID");
|
||||
self._stepRows[0].stepName = nls.localize('stepRow.stepName', "Step Name");
|
||||
self._stepRows[0].message = nls.localize('stepRow.message', "Message");
|
||||
this._showSteps = self._stepRows.length > 1;
|
||||
self._showSteps = self._stepRows.length > 1;
|
||||
} else {
|
||||
self._showSteps = false;
|
||||
}
|
||||
if (self._agentViewComponent.showHistory) {
|
||||
self._jobManagementService.onStepsChange(self._stepRows);
|
||||
self._cd.detectChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private didJobFail(job: azdata.AgentJobHistoryInfo): boolean {
|
||||
for (let i = 0; i < job.steps.length; i++) {
|
||||
if (job.steps[i].runStatus === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private buildHistoryTree(self: JobHistoryComponent, jobHistories: azdata.AgentJobHistoryInfo[]) {
|
||||
self._treeController.jobHistories = jobHistories;
|
||||
let jobHistoryRows: JobHistoryRow[] = this._treeController.jobHistories.map(job => self.convertToJobHistoryRow(job));
|
||||
|
||||
@@ -14,7 +14,7 @@ import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/work
|
||||
import { CommonServiceInterface } from 'sql/workbench/services/bootstrap/browser/commonServiceInterface.service';
|
||||
import {
|
||||
JobStepsViewController, JobStepsViewDataSource, JobStepsViewFilter,
|
||||
JobStepsViewRenderer, JobStepsViewModel
|
||||
JobStepsViewRenderer, JobStepsViewModel, JobStepsViewRow
|
||||
} from 'sql/workbench/contrib/jobManagement/browser/jobStepsViewTree';
|
||||
import { JobHistoryComponent } from 'sql/workbench/contrib/jobManagement/browser/jobHistory.component';
|
||||
import { JobManagementView } from 'sql/workbench/contrib/jobManagement/browser/jobManagementView';
|
||||
@@ -25,6 +25,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { TabChild } from 'sql/base/browser/ui/panel/tab.component';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
|
||||
import { IJobManagementService } from 'sql/workbench/services/jobManagement/common/interfaces';
|
||||
|
||||
export const JOBSTEPSVIEW_SELECTOR: string = 'jobstepsview-component';
|
||||
|
||||
@@ -46,6 +47,7 @@ export class JobStepsViewComponent extends JobManagementView implements OnInit,
|
||||
constructor(
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) commonService: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => JobHistoryComponent)) private _jobHistoryComponent: JobHistoryComponent,
|
||||
@Inject(IJobManagementService) private _jobManagementService: IJobManagementService,
|
||||
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
|
||||
@Inject(IInstantiationService) instantiationService: IInstantiationService,
|
||||
@Inject(IContextMenuService) contextMenuService: IContextMenuService,
|
||||
@@ -105,6 +107,10 @@ export class JobStepsViewComponent extends JobManagementView implements OnInit,
|
||||
this._register(attachListStyler(this._tree, this.themeService));
|
||||
const stepsTooltip = nls.localize('agent.steps', "Steps");
|
||||
jQuery('.steps-header > .steps-icon').attr('title', stepsTooltip);
|
||||
this._jobManagementService.stepsChanged((data: JobStepsViewRow[]) => {
|
||||
this._treeDataSource.data = data;
|
||||
this._tree.refresh();
|
||||
});
|
||||
this._telemetryService.publicLog(TelemetryKeys.JobStepsView);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,9 @@ import * as TreeDefaults from 'vs/base/parts/tree/browser/treeDefaults';
|
||||
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { IJobStepsViewRow } from 'sql/workbench/services/jobManagement/common/interfaces';
|
||||
|
||||
export class JobStepsViewRow {
|
||||
export class JobStepsViewRow implements IJobStepsViewRow {
|
||||
public stepId: string;
|
||||
public stepName: string;
|
||||
public message: string;
|
||||
|
||||
@@ -12,12 +12,22 @@ export const SERVICE_ID = 'jobManagementService';
|
||||
|
||||
export const IJobManagementService = createDecorator<IJobManagementService>(SERVICE_ID);
|
||||
|
||||
export interface IJobStepsViewRow {
|
||||
stepId: string;
|
||||
stepName: string;
|
||||
message: string;
|
||||
rowID: string;
|
||||
runStatus: string;
|
||||
}
|
||||
|
||||
export interface IJobManagementService {
|
||||
_serviceBrand: undefined;
|
||||
onDidChange: Event<void>;
|
||||
stepsChanged: Event<IJobStepsViewRow[]>;
|
||||
|
||||
registerProvider(providerId: string, provider: azdata.AgentServicesProvider): void;
|
||||
fireOnDidChange(): void;
|
||||
onStepsChange(data: IJobStepsViewRow[]): void;
|
||||
|
||||
getJobs(connectionUri: string): Thenable<azdata.AgentJobsResult>;
|
||||
getJobHistory(connectionUri: string, jobID: string, jobName: string): Thenable<azdata.AgentJobHistoryResult>;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import * as azdata from 'azdata';
|
||||
import { IJobManagementService } from 'sql/workbench/services/jobManagement/common/interfaces';
|
||||
import { IJobManagementService, IJobStepsViewRow } from 'sql/workbench/services/jobManagement/common/interfaces';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
|
||||
@@ -15,6 +15,10 @@ export class JobManagementService implements IJobManagementService {
|
||||
private _onDidChange = new Emitter<void>();
|
||||
public readonly onDidChange: Event<void> = this._onDidChange.event;
|
||||
|
||||
// data oservables for steps tree
|
||||
private _stepsChanged: Emitter<IJobStepsViewRow[]> = new Emitter<IJobStepsViewRow[]>();
|
||||
public stepsChanged: Event<IJobStepsViewRow[]> = this._stepsChanged.event;
|
||||
|
||||
private _providers: { [handle: string]: azdata.AgentServicesProvider; } = Object.create(null);
|
||||
private _jobCacheObjectMap: { [server: string]: JobCacheObject; } = {};
|
||||
private _operatorsCacheObjectMap: { [server: string]: OperatorsCacheObject; } = {};
|
||||
@@ -23,8 +27,7 @@ export class JobManagementService implements IJobManagementService {
|
||||
private _notebookCacheObjectMap: { [server: string]: NotebookCacheObject; } = {};
|
||||
constructor(
|
||||
@IConnectionManagementService private _connectionService: IConnectionManagementService
|
||||
) {
|
||||
}
|
||||
) { }
|
||||
|
||||
public fireOnDidChange(): void {
|
||||
this._onDidChange.fire(void 0);
|
||||
@@ -62,6 +65,11 @@ export class JobManagementService implements IJobManagementService {
|
||||
});
|
||||
}
|
||||
|
||||
// Notify Steps changed to steps tree
|
||||
public onStepsChange(data: IJobStepsViewRow[]): void {
|
||||
this._stepsChanged.fire(data);
|
||||
}
|
||||
|
||||
// Notebooks
|
||||
public getNotebooks(connectionUri: string): Thenable<azdata.AgentNotebooksResult> {
|
||||
return this._runAction(connectionUri, (runner) => {
|
||||
|
||||
Reference in New Issue
Block a user