Feature/agent2 adbist (#1113)

* added caching for jobs view and history page

* added build fix

* removed agent from cache service name

* put cache in job mgmt service and fixed view destroy error

* jobs view cache and refresh implemented

* refresh and cache complete

* added refresh to job history page

* fixed steps style

* explicitly tell user when no steps are available

* show message when no prev runs available

* code review refactor

* cleaned code

* added code that got left out
This commit is contained in:
Aditya Bist
2018-04-12 10:36:34 -07:00
committed by GitHub
parent 20853ddf7e
commit 8ec5451e64
17 changed files with 221 additions and 171 deletions

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./dashboardControlHostContainer';
import { Component, forwardRef, Input, AfterContentInit, ViewChild } from '@angular/core';
import { Component, forwardRef, Input, AfterContentInit, ViewChild, OnChanges } from '@angular/core';
import Event, { Emitter } from 'vs/base/common/event';
import { DashboardTab } from 'sql/parts/dashboard/common/interfaces';
import { TabConfig } from 'sql/parts/dashboard/common/dashboardWidget';
@@ -18,6 +18,7 @@ import { ControlHostContent } from 'sql/parts/dashboard/contents/controlHostCont
</controlhost-content>
`
})
export class DashboardControlHostContainer extends DashboardTab implements AfterContentInit {
@Input() private tab: TabConfig;
@@ -53,6 +54,6 @@ export class DashboardControlHostContainer extends DashboardTab implements After
}
public refresh(): void {
// no op
this._hostContent.refresh();
}
}

View File

@@ -5,5 +5,4 @@
*--------------------------------------------------------------------------------------------*/
-->
<agentview-component *ngIf="(controlType) === 'agent'">
</agentview-component>
<agentview-component #agent *ngIf="(controlType) === 'agent'"></agentview-component>

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./controlHostContent';
import { Component, forwardRef, Input, OnInit, Inject, ChangeDetectorRef, ElementRef } from '@angular/core';
import { Component, forwardRef, Input, OnInit, Inject, ChangeDetectorRef, ElementRef, ViewChild } from '@angular/core';
import Event, { Emitter } from 'vs/base/common/event';
import { Parts } from 'vs/workbench/services/part/common/partService';
@@ -16,12 +16,13 @@ import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboar
import * as sqlops from 'sqlops';
import { memoize } from 'vs/base/common/decorators';
import { AgentViewComponent } from '../../jobManagement/agent/agentView.component';
@Component({
templateUrl: decodeURI(require.toUrl('sql/parts/dashboard/contents/controlHostContent.component.html')),
selector: 'controlhost-content'
})
export class ControlHostContent implements OnInit {
export class ControlHostContent {
@Input() private webviewId: string;
private _onResize = new Emitter<void>();
@@ -32,6 +33,9 @@ export class ControlHostContent implements OnInit {
private _onMessageDisposable: IDisposable;
private _type: string;
/* Children components */
@ViewChild('agent') private _agentViewComponent: AgentViewComponent;
constructor(
@Inject(forwardRef(() => DashboardServiceInterface)) private _dashboardService: DashboardServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
@@ -39,9 +43,6 @@ export class ControlHostContent implements OnInit {
) {
}
ngOnInit() {
}
public layout(): void {
}
@@ -73,4 +74,8 @@ export class ControlHostContent implements OnInit {
public get controlType(): string {
return this._type;
}
public refresh() {
this._agentViewComponent.refresh = true;
}
}

View File

@@ -12,7 +12,7 @@
<jobsview-component></jobsview-component>
</div>
<div id="historyDiv" class="fullsize" *ngIf="showHistory === true">
<jobhistory-component [jobId]="jobId" [agentJobInfo]="agentJobInfo" [agentJobHistories]="agentJobHistories"></jobhistory-component>
<jobhistory-component></jobhistory-component>
</div>
</tab>
</panel>

View File

@@ -5,7 +5,7 @@
import 'vs/css!../common/media/jobs';
import * as nls from 'vs/nls';
import { Component, Inject, forwardRef, ElementRef, ChangeDetectorRef, ViewChild, Injectable } from '@angular/core';
import { Component, Inject, forwardRef, ElementRef, ChangeDetectorRef, ViewChild, Injectable} from '@angular/core';
import * as Utils from 'sql/parts/connection/common/utils';
import { RefreshWidgetAction, EditDashboardAction } from 'sql/parts/dashboard/common/actions';
import { IColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService';
@@ -18,6 +18,7 @@ import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboar
import { AgentJobInfo, AgentJobHistoryInfo } from 'sqlops';
import { PanelComponent, IPanelOptions, NavigationBarLayout } from 'sql/base/browser/ui/panel/panel.component';
export const DASHBOARD_SELECTOR: string = 'agentview-component';
@Component({
@@ -31,14 +32,10 @@ export class AgentViewComponent {
// tslint:disable:no-unused-variable
private readonly jobsComponentTitle: string = nls.localize('jobview.Jobs', "Jobs");
private readonly alertsComponentTitle: string = nls.localize('jobview.Alerts', "Alerts");
private readonly schedulesComponentTitle: string = nls.localize('jobview.Schedules', "Schedules");
private readonly operatorsComponentTitle: string = nls.localize('jobview.Operator', "Operators");
private readonly jobHistoryComponentTitle: string = nls.localize('jobview.History', "History");
private _showHistory: boolean = false;
private _jobId: string = null;
private _agentJobInfo: AgentJobInfo = null;
private _agentJobHistories: AgentJobHistoryInfo[] = null;
private _refresh: boolean = undefined;
public jobsIconClass: string = 'jobsview-icon';
@@ -68,8 +65,8 @@ export class AgentViewComponent {
return this._agentJobInfo;
}
public get agentJobHistories(): AgentJobHistoryInfo[] {
return this._agentJobHistories;
public get refresh(): boolean {
return this._refresh;
}
/**
@@ -91,8 +88,8 @@ export class AgentViewComponent {
this._cd.detectChanges();
}
public set agentJobHistories(value: AgentJobHistoryInfo[]) {
this._agentJobHistories = value;
public set refresh(value: boolean) {
this._refresh = value;
this._cd.detectChanges();
}
}

View File

@@ -1,54 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { Injectable } from '@angular/core';
import * as sqlops from 'sqlops';
import * as vscode from 'vscode';
import { IAgentJobCacheService } from './interfaces';
@Injectable()
export class AgentJobCacheService implements IAgentJobCacheService {
_serviceBrand: any;
private _jobs: sqlops.AgentJobInfo[];
private _jobHistories: { [jobId: string]: sqlops.AgentJobHistoryInfo[]; } = {};
private _prevJobID: string;
/* Getters */
public get jobs(): sqlops.AgentJobInfo[] {
return this._jobs;
}
public get jobHistories(): { [jobId: string]: sqlops.AgentJobHistoryInfo[] } {
return this._jobHistories;
}
public get prevJobID(): string {
return this._prevJobID;
}
public getJobHistory(jobID: string): sqlops.AgentJobHistoryInfo[] {
return this._jobHistories[jobID];
}
/* Setters */
public set jobs(value: sqlops.AgentJobInfo[]) {
this._jobs = value;
}
public set jobHistories(value: { [jobId: string]: sqlops.AgentJobHistoryInfo[]; }) {
this._jobHistories = value;
}
public set prevJobID(value: string) {
this._prevJobID = value;
}
public setJobHistory(jobID:string, value: sqlops.AgentJobHistoryInfo[]) {
this._jobHistories[jobID] = value;
}
}

View File

@@ -8,12 +8,11 @@
import * as sqlops from 'sqlops';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { Table } from 'sql/base/browser/ui/table/table';
import { JobCacheObject } from './jobManagementService';
export const SERVICE_ID = 'jobManagementService';
export const CACHE_ID = 'jobCacheService';
export const IJobManagementService = createDecorator<IJobManagementService>(SERVICE_ID);
export const IAgentJobCacheService = createDecorator<IAgentJobCacheService>(CACHE_ID);
export interface IJobManagementService {
_serviceBrand: any;
@@ -25,18 +24,8 @@ export interface IJobManagementService {
getJobHistory(connectionUri: string, jobID: string): Thenable<sqlops.AgentJobHistoryResult>;
jobAction(connectionUri: string, jobName: string, action: string): Thenable<sqlops.AgentJobActionResult>;
}
export interface IAgentJobCacheService {
_serviceBrand: any;
addToCache(server: string, cache: JobCacheObject);
jobs: sqlops.AgentJobInfo[];
jobHistories: { [jobId: string]: sqlops.AgentJobHistoryInfo[]; };
prevJobID: string;
getJobHistory(jobID: string): sqlops.AgentJobHistoryInfo[];
setJobHistory(jobID: string, value: sqlops.AgentJobHistoryInfo[]);
jobCacheObjectMap: { [server: string]: JobCacheObject; };
}

View File

@@ -6,17 +6,20 @@
'use strict';
import { localize } from 'vs/nls';
import * as sqlops from 'sqlops';
import * as vscode from 'vscode';
import { TPromise } from 'vs/base/common/winjs.base';
import { Injectable } from '@angular/core';
import { IJobManagementService } from 'sql/parts/jobManagement/common/interfaces';
import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
import { TPromise } from 'vs/base/common/winjs.base';
import * as sqlops from 'sqlops';
export class JobManagementService implements IJobManagementService {
_serviceBrand: any;
private _providers: { [handle: string]: sqlops.AgentServicesProvider; } = Object.create(null);
private _jobCacheObject : {[server: string]: JobCacheObject; } = {};
constructor(
@IConnectionManagementService private _connectionService: IConnectionManagementService,
@@ -60,4 +63,66 @@ export class JobManagementService implements IJobManagementService {
public registerProvider(providerId: string, provider: sqlops.AgentServicesProvider): void {
this._providers[providerId] = provider;
}
public get jobCacheObjectMap(): {[server: string]: JobCacheObject;} {
return this._jobCacheObject;
}
public addToCache(server: string, cacheObject: JobCacheObject) {
this._jobCacheObject[server] = cacheObject;
}
}
/**
* Server level caching of jobs/job histories
*/
export class JobCacheObject {
_serviceBrand: any;
private _jobs: sqlops.AgentJobInfo[] = [];
private _jobHistories: { [jobId: string]: sqlops.AgentJobHistoryInfo[]; } = {};
private _prevJobID: string;
private _serverName: string;
/* Getters */
public get jobs(): sqlops.AgentJobInfo[] {
return this._jobs;
}
public get jobHistories(): { [jobId: string]: sqlops.AgentJobHistoryInfo[] } {
return this._jobHistories;
}
public get prevJobID(): string {
return this._prevJobID;
}
public getJobHistory(jobID: string): sqlops.AgentJobHistoryInfo[] {
return this._jobHistories[jobID];
}
public get serverName(): string {
return this._serverName;
}
/* Setters */
public set jobs(value: sqlops.AgentJobInfo[]) {
this._jobs = value;
}
public set jobHistories(value: { [jobId: string]: sqlops.AgentJobHistoryInfo[]; }) {
this._jobHistories = value;
}
public set prevJobID(value: string) {
this._prevJobID = value;
}
public setJobHistory(jobID:string, value: sqlops.AgentJobHistoryInfo[]) {
this._jobHistories[jobID] = value;
}
public set serverName(value: string) {
this._serverName = value;
}
}

View File

@@ -5,7 +5,7 @@
*--------------------------------------------------------------------------------------------*/
-->
<h1 class="job-heading">Jobs | {{agentJobInfo.name}} </h1>
<h1 class="job-heading">Jobs | {{this._agentJobInfo?.name}} </h1>
<!-- Back -->
<div class="all-jobs">
@@ -15,10 +15,10 @@
<!-- Actions -->
<ul class="action-buttons">
<li>
<div class="icon-start" (click)="jobAction('run', agentJobInfo.name)">Run</div>
<div class="icon-start" (click)="jobAction('run', this._agentJobInfo.name)">Run</div>
</li>
<li>
<div class="icon-stop" (click)="jobAction('stop', agentJobInfo.name)">Stop</div>
<div class="icon-stop" (click)="jobAction('stop', this._.agentJobInfo.name)">Stop</div>
</li>
</ul>
@@ -37,13 +37,13 @@
Category:
</td>
<td id='col2'>
{{agentJobInfo.category}}
{{this._agentJobInfo?.category}}
</td>
<td id='col3'>
Enabled:
</td>
<td id='col4'>
{{agentJobInfo.enabled}}
{{this._agentJobInfo?.enabled}}
</td>
</tr>
<tr>
@@ -51,13 +51,13 @@
Has Alert:
</td>
<td id='col2'>
{{agentJobInfo.hasTarget}}
{{this._agentJobInfo?.hasTarget}}
</td>
<td id='col3'>
Has Schedule:
</td>
<td id='col4'>
{{agentJobInfo.hasSchedule}}
{{this._agentJobInfo?.hasSchedule}}
</td>
</tr>
<tr>
@@ -65,13 +65,13 @@
Last Run:
</td>
<td id='col2'>
{{agentJobInfo.lastRun}}
{{this._agentJobInfo?.lastRun}}
</td>
<td id='col3'>
Next Run:
</td>
<td id='col4'>
{{agentJobInfo.nextRun}}
{{this._agentJobInfo?.nextRun}}
</td>
</tr>
</table>
@@ -83,7 +83,7 @@
<div class='history-details'>
<!-- Previous run list -->
<div style="width: 20%">
<table>
<table *ngIf="_showPreviousRuns === true">
<tr>
<td class="date-column">
<b>Date</b>
@@ -93,6 +93,7 @@
</td>
</tr>
</table>
<h3 *ngIf="_showPreviousRuns === false">No Previous Runs Available</h3>
<div #table class="step-table prev-run-list" style="position: relative; height: 100%; width: 100%"></div>
</div>
<!-- Job Steps -->
@@ -158,7 +159,8 @@
</td>
</tr>
</table>
<jobstepsview-component *ngIf="showSteps() === true" [stepRows]="_stepRows"></jobstepsview-component>
<jobstepsview-component *ngIf="showSteps === true" [stepRows]="_stepRows"></jobstepsview-component>
<h3 *ngIf="showSteps === false">No Steps Available</h3>
</div>
</div>

View File

@@ -5,25 +5,26 @@
import 'vs/css!./jobHistory';
import { OnInit, OnChanges, Component, Inject, forwardRef, ElementRef, ChangeDetectorRef, OnDestroy, ViewChild, Input, Injectable, ChangeDetectionStrategy } from '@angular/core';
import { OnInit, OnChanges, Component, Inject, Input, forwardRef, ElementRef, ChangeDetectorRef, ViewChild, ChangeDetectionStrategy } from '@angular/core';
import { AgentJobHistoryInfo, AgentJobInfo } from 'sqlops';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { attachListStyler } from 'vs/platform/theme/common/styler';
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { localize } from 'vs/nls';
import { INotificationService } from 'vs/platform/notification/common/notification';
import Severity from 'vs/base/common/severity';
import { PanelComponent } from 'sql/base/browser/ui/panel/panel.component';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
import { IJobManagementService, IAgentJobCacheService } from '../common/interfaces';
import { IJobManagementService } from '../common/interfaces';
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
import { AgentViewComponent } from 'sql/parts/jobManagement/agent/agentView.component';
import { JobHistoryController, JobHistoryDataSource,
JobHistoryRenderer, JobHistoryFilter, JobHistoryModel, JobHistoryRow } from 'sql/parts/jobManagement/views/jobHistoryTree';
import { JobStepsViewComponent } from 'sql/parts/jobManagement/views/jobStepsView.component';
import { JobStepsViewRow } from './jobStepsViewTree';
import { localize } from 'vs/nls';
import { INotificationService } from 'vs/platform/notification/common/notification';
import Severity from 'vs/base/common/severity';
import { JobCacheObject } from 'sql/parts/jobManagement/common/jobManagementService';
export const DASHBOARD_SELECTOR: string = 'jobhistory-component';
@@ -44,16 +45,17 @@ export class JobHistoryComponent extends Disposable implements OnInit {
@ViewChild('table') private _tableContainer: ElementRef;
@Input() public agentJobInfo: AgentJobInfo = undefined;
@Input() public jobId: string = undefined;
@Input() public agentJobHistories: AgentJobHistoryInfo[] = undefined;
public agentJobHistoryInfo: AgentJobHistoryInfo = undefined;
private _isVisible: boolean = false;
private _stepRows: JobStepsViewRow[] = [];
private _showSteps: boolean = false;
private _showSteps: boolean = undefined;
private _showPreviousRuns: boolean = undefined;
private _runStatus: string = undefined;
private _agentJobCacheService: IAgentJobCacheService;
private _jobCacheObject: JobCacheObject;
private _notificationService: INotificationService;
private _agentJobInfo: AgentJobInfo;
constructor(
@Inject(BOOTSTRAP_SERVICE_ID) private bootstrapService: IBootstrapService,
@@ -68,8 +70,18 @@ export class JobHistoryComponent extends Disposable implements OnInit {
this._treeRenderer = new JobHistoryRenderer();
this._treeFilter = new JobHistoryFilter();
this._jobManagementService = bootstrapService.jobManagementService;
this._agentJobCacheService = bootstrapService.agentJobCacheService;
this._notificationService = bootstrapService.notificationService;
let jobCacheObjectMap = this._jobManagementService.jobCacheObjectMap;
let serverName = _dashboardService.connectionManagementService.connectionInfo.connectionProfile.serverName;
let jobCache = jobCacheObjectMap[serverName];
if (jobCache) {
this._jobCacheObject = jobCache;
} else {
this._jobCacheObject = new JobCacheObject();
this._jobCacheObject.serverName = serverName;
this._jobManagementService.addToCache(serverName, this._jobCacheObject);
}
}
ngOnInit() {
@@ -103,8 +115,10 @@ export class JobHistoryComponent extends Disposable implements OnInit {
stepViewRow.stepID = step.stepId.toString();
return stepViewRow;
});
this._showSteps = true;
} else {
this._showSteps = false;
}
this._showSteps = true;
self._cd.detectChanges();
}
}
@@ -121,23 +135,28 @@ export class JobHistoryComponent extends Disposable implements OnInit {
}
ngAfterContentChecked() {
this._agentJobInfo = this._agentViewComponent.agentJobInfo;
if (!this.agentJobInfo) {
this.agentJobInfo = this._agentJobInfo;
}
if (this._isVisible === false && this._tableContainer.nativeElement.offsetParent !== null) {
this._isVisible = true;
if (this.agentJobHistories && this.agentJobHistories.length > 0) {
if (this._agentJobCacheService.prevJobID === this.jobId || this.agentJobHistories[0].jobId === this.jobId) {
this.agentJobHistoryInfo = this.agentJobHistories[0];
this.agentJobHistoryInfo.runDate = this.formatTime(this.agentJobHistories[0].runDate);
this._treeController.jobHistories = this.agentJobHistories;
this._agentJobCacheService.setJobHistory(this.jobId, this.agentJobHistories);
let jobHistoryRows = this._treeController.jobHistories.map(job => this.convertToJobHistoryRow(job));
this._treeDataSource.data = jobHistoryRows;
this._tree.setInput(new JobHistoryModel());
let jobHistories = this._jobCacheObject.jobHistories[this._agentViewComponent.jobId];
if (jobHistories && jobHistories.length > 0) {
const self = this;
if (this._jobCacheObject.prevJobID === this._agentViewComponent.jobId || jobHistories[0].jobId === this._agentViewComponent.jobId) {
this.buildHistoryTree(self, jobHistories);
this._cd.detectChanges();
}
} else {
this.loadHistory();
} else if (jobHistories && jobHistories.length === 0 ){
this._showPreviousRuns = false;
this._showSteps = false;
this._cd.detectChanges();
}
this._agentJobCacheService.prevJobID = this.jobId;
this._jobCacheObject.prevJobID = this._agentViewComponent.jobId;
} else if (this._isVisible === true && this._agentViewComponent.refresh) {
this.loadHistory();
this._agentViewComponent.refresh = false;
} else if (this._isVisible === true && this._tableContainer.nativeElement.offsetParent === null) {
this._isVisible = false;
}
@@ -146,22 +165,38 @@ export class JobHistoryComponent extends Disposable implements OnInit {
loadHistory() {
const self = this;
let ownerUri: string = this._dashboardService.connectionManagementService.connectionInfo.ownerUri;
this._jobManagementService.getJobHistory(ownerUri, this.jobId).then((result) => {
this._jobManagementService.getJobHistory(ownerUri, this._agentViewComponent.jobId).then((result) => {
if (result && result.jobs) {
self._treeController.jobHistories = result.jobs;
self._agentJobCacheService.setJobHistory(self.jobId, result.jobs);
let jobHistoryRows = self._treeController.jobHistories.map(job => self.convertToJobHistoryRow(job));
self._treeDataSource.data = jobHistoryRows;
self._tree.setInput(new JobHistoryModel());
self.agentJobHistoryInfo = self._treeController.jobHistories[0];
if (this.agentJobHistoryInfo) {
self.agentJobHistoryInfo.runDate = self.formatTime(self.agentJobHistoryInfo.runDate);
if (result.jobs.length > 0) {
self._showPreviousRuns = true;
self.buildHistoryTree(self, result.jobs);
if (self._agentViewComponent.showHistory) {
self._cd.detectChanges();
}
} else {
self._jobCacheObject.setJobHistory(self._agentViewComponent.jobId, result.jobs);
self._showPreviousRuns = false;
}
self._cd.detectChanges();
} else {
self._showPreviousRuns = false;
self._showSteps = false;
this._cd.detectChanges();
}
});
}
private buildHistoryTree(self: any, jobHistories: AgentJobHistoryInfo[]) {
self._treeController.jobHistories = jobHistories;
self._jobCacheObject.setJobHistory(self._agentViewComponent.jobId, jobHistories);
let jobHistoryRows = this._treeController.jobHistories.map(job => self.convertToJobHistoryRow(job));
self._treeDataSource.data = jobHistoryRows;
self._tree.setInput(new JobHistoryModel());
self.agentJobHistoryInfo = self._treeController.jobHistories[0];
if (self.agentJobHistoryInfo) {
self.agentJobHistoryInfo.runDate = self.formatTime(self.agentJobHistoryInfo.runDate);
}
}
private toggleCollapse(): void {
let arrow: HTMLElement = $('.resultsViewCollapsible').get(0);
let checkbox: any = document.getElementById('accordion');
@@ -221,8 +256,13 @@ export class JobHistoryComponent extends Disposable implements OnInit {
return time.replace('T', ' ');
}
public showSteps(): boolean {
public get showSteps(): boolean {
return this._showSteps;
}
public set showSteps(value: boolean) {
this._showSteps = value;
this._cd.detectChanges();
}
}

View File

@@ -73,8 +73,5 @@ export class JobStepsViewComponent extends Disposable implements OnInit, OnChang
this._tree.setInput(new JobStepsViewModel());
}
}
ngAfterContentChecked() {
}
}

View File

@@ -37,7 +37,7 @@
padding-left: 50px;
}
.step-columns .step-id-col, .step-tree .tree-id-col {
.step-columns .step-id-col, .steps-tree .tree-id-col {
padding-left: 10px;
white-space: normal;
text-align: center;
@@ -45,14 +45,14 @@
}
.step-columns .step-name-col, .step-tree .tree-name-col {
.step-columns .step-name-col, .steps-tree .tree-name-col {
padding-right: 10px;
white-space: normal;
text-align: center;
width: 350px;
}
.step-columns .step-message-col, .step-tree .tree-message-col {
.step-columns .step-message-col, .steps-tree .tree-message-col {
padding-right: 10px;
white-space: normal;
text-align: center;

View File

@@ -11,7 +11,7 @@ import 'vs/css!sql/parts/grid/media/slickGrid';
import 'vs/css!../common/media/jobs';
import 'vs/css!../common/media/detailview';
import { Component, Inject, forwardRef, ElementRef, ChangeDetectorRef, ViewChild, Input } from '@angular/core';
import { Component, Inject, forwardRef, ElementRef, ChangeDetectorRef, ViewChild, AfterContentChecked } from '@angular/core';
import * as Utils from 'sql/parts/connection/common/utils';
import { IColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IDisposable } from 'vs/base/common/lifecycle';
@@ -19,7 +19,7 @@ import * as themeColors from 'vs/workbench/common/theme';
import { DashboardPage } from 'sql/parts/dashboard/common/dashboardPage.component';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
import { IJobManagementService, IAgentJobCacheService } from '../common/interfaces';
import { IJobManagementService } from '../common/interfaces';
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
import * as sqlops from 'sqlops';
import * as vscode from 'vscode';
@@ -31,7 +31,8 @@ import { attachTableStyler } from 'sql/common/theme/styler';
import { JobHistoryComponent } from './jobHistory.component';
import { AgentViewComponent } from '../agent/agentView.component';
import { RowDetailView } from 'sql/base/browser/ui/table/plugins/rowdetailview';
import { AgentJobCacheService } from 'sql/parts/jobManagement/common/agentJobCacheService';
import { JobCacheObject } from 'sql/parts/jobManagement/common/jobManagementService';
export const JOBSVIEW_SELECTOR: string = 'jobsview-component';
@@ -39,10 +40,11 @@ export const JOBSVIEW_SELECTOR: string = 'jobsview-component';
selector: JOBSVIEW_SELECTOR,
templateUrl: decodeURI(require.toUrl('./jobsView.component.html'))
})
export class JobsViewComponent {
export class JobsViewComponent implements AfterContentChecked {
private _jobManagementService: IJobManagementService;
private _jobCacheService: IAgentJobCacheService;
private _jobCacheObject: JobCacheObject;
private _disposables = new Array<vscode.Disposable>();
@@ -68,6 +70,7 @@ export class JobsViewComponent {
private _table: Table<any>;
public jobs: sqlops.AgentJobInfo[];
public jobHistories: { [jobId: string]: sqlops.AgentJobHistoryInfo[]; } = Object.create(null);
private _serverName: string;
constructor(
@Inject(BOOTSTRAP_SERVICE_ID) private bootstrapService: IBootstrapService,
@@ -77,15 +80,24 @@ export class JobsViewComponent {
@Inject(forwardRef(() => AgentViewComponent)) private _agentViewComponent: AgentViewComponent
) {
this._jobManagementService = bootstrapService.jobManagementService;
this._jobCacheService = bootstrapService.agentJobCacheService;
let jobCacheObjectMap = this._jobManagementService.jobCacheObjectMap;
this._serverName = _dashboardService.connectionManagementService.connectionInfo.connectionProfile.serverName;
let jobCache = jobCacheObjectMap[this._serverName];
if (jobCache) {
this._jobCacheObject = jobCache;
} else {
this._jobCacheObject = new JobCacheObject();
this._jobCacheObject.serverName = this._serverName;
this._jobManagementService.addToCache(this._serverName, this._jobCacheObject);
}
}
ngAfterContentChecked() {
if (this.isVisible === false && this._gridEl.nativeElement.offsetParent !== null) {
this.isVisible = true;
if (!this.isInitialized) {
if (this._jobCacheService.jobs !== undefined) {
this.jobs = this._jobCacheService.jobs;
if (this._jobCacheObject.serverName === this._serverName && this._jobCacheObject.jobs.length > 0) {
this.jobs = this._jobCacheObject.jobs;
this.onFirstVisible(true);
this.isInitialized = true;
} else {
@@ -93,6 +105,11 @@ export class JobsViewComponent {
this.isInitialized = true;
}
}
} else if (this.isVisible === true && this._agentViewComponent.refresh === true) {
this.onFirstVisible(false);
this._agentViewComponent.refresh = false;
} else if (this.isVisible === true && this._agentViewComponent.refresh === false) {
this.onFirstVisible(true);
} else if (this.isVisible === true && this._gridEl.nativeElement.offsetParent === null) {
this.isVisible = false;
}
@@ -117,10 +134,11 @@ export class JobsViewComponent {
preTemplate: this.loadingTemplate,
process: (job) => {
(<any>rowDetail).onAsyncResponse.notify({
'itemDetail': job
}, undefined, this);
'itemDetail': job,
}, undefined, null);
},
panelRows: 2
panelRows: 2,
postTemplate: () => ''
});
this.rowDetail = rowDetail;
@@ -132,24 +150,19 @@ export class JobsViewComponent {
let job = self.getJob(args);
self._agentViewComponent.jobId = job.jobId;
self._agentViewComponent.agentJobInfo = job;
self.isVisible = false;
if (self._jobCacheService.getJobHistory(job.jobId)) {
self._agentViewComponent.agentJobHistories = self._jobCacheService.getJobHistory(job.jobId);
}
setTimeout(() => {
self._agentViewComponent.showHistory = true;
}, 500);
});
this._cd.detectChanges();
if (cached) {
this.onJobsAvailable(this._jobCacheService.jobs);
if (cached && this._agentViewComponent.refresh !== true) {
this.onJobsAvailable(this._jobCacheObject.jobs);
} else {
let ownerUri: string = this._dashboardService.connectionManagementService.connectionInfo.ownerUri;
this._jobManagementService.getJobs(ownerUri).then((result) => {
if (result && result.jobs) {
this.jobs = result.jobs;
this._jobCacheService.jobs = this.jobs;
this.onJobsAvailable(result.jobs);
self.jobs = result.jobs;
self._jobCacheObject.jobs = self.jobs;
self.onJobsAvailable(result.jobs);
}
});
}
@@ -209,7 +222,7 @@ export class JobsViewComponent {
this._jobManagementService.getJobHistory(ownerUri, job.jobId).then((result) => {
if (result.jobs) {
this.jobHistories[job.jobId] = result.jobs;
this._jobCacheService.setJobHistory(job.jobId, result.jobs);
this._jobCacheObject.setJobHistory(job.jobId, result.jobs);
}
});
});
@@ -222,4 +235,4 @@ export class JobsViewComponent {
let job = this.jobs.filter(job => job.name === jobName)[0];
return job;
}
}
}

View File

@@ -40,7 +40,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { ConfigurationEditingService } from 'vs/workbench/services/configuration/node/configurationEditingService';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IJobManagementService, IAgentJobCacheService } from 'sql/parts/jobManagement/common/interfaces';
import { IJobManagementService } from 'sql/parts/jobManagement/common/interfaces';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { INotificationService } from 'vs/platform/notification/common/notification';
@@ -95,7 +95,6 @@ export interface IBootstrapService {
commandService: ICommandService;
dashboardWebviewService: IDashboardWebviewService;
jobManagementService: IJobManagementService;
agentJobCacheService: IAgentJobCacheService;
environmentService: IEnvironmentService;
/*

View File

@@ -44,7 +44,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { ConfigurationEditingService } from 'vs/workbench/services/configuration/node/configurationEditingService';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IJobManagementService, IAgentJobCacheService } from 'sql/parts/jobManagement/common/interfaces';
import { IJobManagementService } from 'sql/parts/jobManagement/common/interfaces';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { INotificationService } from 'vs/platform/notification/common/notification';
@@ -104,7 +104,6 @@ export class BootstrapService implements IBootstrapService {
@ICommandService public commandService: ICommandService,
@IDashboardWebviewService public dashboardWebviewService: IDashboardWebviewService,
@IJobManagementService public jobManagementService: IJobManagementService,
@IAgentJobCacheService public agentJobCacheService: IAgentJobCacheService,
@IEnvironmentService public environmentService: IEnvironmentService
) {
this.configurationEditorService = this.instantiationService.createInstance(ConfigurationEditingService);