diff --git a/src/sql/parts/dashboard/containers/dashboardControlHostContainer.component.ts b/src/sql/parts/dashboard/containers/dashboardControlHostContainer.component.ts index 10a773287f..4ac0a72be2 100644 --- a/src/sql/parts/dashboard/containers/dashboardControlHostContainer.component.ts +++ b/src/sql/parts/dashboard/containers/dashboardControlHostContainer.component.ts @@ -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 ` }) + 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(); } } diff --git a/src/sql/parts/dashboard/contents/controlHostContent.component.html b/src/sql/parts/dashboard/contents/controlHostContent.component.html index 0b6f2d8184..5fcba550bf 100644 --- a/src/sql/parts/dashboard/contents/controlHostContent.component.html +++ b/src/sql/parts/dashboard/contents/controlHostContent.component.html @@ -5,5 +5,4 @@ *--------------------------------------------------------------------------------------------*/ --> - - + diff --git a/src/sql/parts/dashboard/contents/controlHostContent.component.ts b/src/sql/parts/dashboard/contents/controlHostContent.component.ts index 9ab2071624..0790528263 100644 --- a/src/sql/parts/dashboard/contents/controlHostContent.component.ts +++ b/src/sql/parts/dashboard/contents/controlHostContent.component.ts @@ -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(); @@ -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; + } } diff --git a/src/sql/parts/jobManagement/agent/agentView.component.html b/src/sql/parts/jobManagement/agent/agentView.component.html index 1d8706ff71..4e8ae961fb 100644 --- a/src/sql/parts/jobManagement/agent/agentView.component.html +++ b/src/sql/parts/jobManagement/agent/agentView.component.html @@ -12,7 +12,7 @@
- +
diff --git a/src/sql/parts/jobManagement/agent/agentView.component.ts b/src/sql/parts/jobManagement/agent/agentView.component.ts index 9814fdc022..d839ca5c7e 100644 --- a/src/sql/parts/jobManagement/agent/agentView.component.ts +++ b/src/sql/parts/jobManagement/agent/agentView.component.ts @@ -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(); } } diff --git a/src/sql/parts/jobManagement/common/agentJobCacheService.ts b/src/sql/parts/jobManagement/common/agentJobCacheService.ts deleted file mode 100644 index 904e352afc..0000000000 --- a/src/sql/parts/jobManagement/common/agentJobCacheService.ts +++ /dev/null @@ -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; - } - -} diff --git a/src/sql/parts/jobManagement/common/interfaces.ts b/src/sql/parts/jobManagement/common/interfaces.ts index 72844169a2..184ca255c7 100644 --- a/src/sql/parts/jobManagement/common/interfaces.ts +++ b/src/sql/parts/jobManagement/common/interfaces.ts @@ -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(SERVICE_ID); -export const IAgentJobCacheService = createDecorator(CACHE_ID); export interface IJobManagementService { _serviceBrand: any; @@ -25,18 +24,8 @@ export interface IJobManagementService { getJobHistory(connectionUri: string, jobID: string): Thenable; jobAction(connectionUri: string, jobName: string, action: string): Thenable; -} -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; }; } \ No newline at end of file diff --git a/src/sql/parts/jobManagement/common/jobManagementService.ts b/src/sql/parts/jobManagement/common/jobManagementService.ts index de6a04fbcd..9052de6ae8 100644 --- a/src/sql/parts/jobManagement/common/jobManagementService.ts +++ b/src/sql/parts/jobManagement/common/jobManagementService.ts @@ -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; + } + } diff --git a/src/sql/parts/jobManagement/views/jobHistory.component.html b/src/sql/parts/jobManagement/views/jobHistory.component.html index 9764e56ec1..408047bb49 100644 --- a/src/sql/parts/jobManagement/views/jobHistory.component.html +++ b/src/sql/parts/jobManagement/views/jobHistory.component.html @@ -5,7 +5,7 @@ *--------------------------------------------------------------------------------------------*/ --> -

Jobs | {{agentJobInfo.name}}

+

Jobs | {{this._agentJobInfo?.name}}

@@ -15,10 +15,10 @@
  • -
    Run
    +
    Run
  • -
    Stop
    +
    Stop
@@ -37,13 +37,13 @@ Category: - {{agentJobInfo.category}} + {{this._agentJobInfo?.category}} Enabled: - {{agentJobInfo.enabled}} + {{this._agentJobInfo?.enabled}} @@ -51,13 +51,13 @@ Has Alert: - {{agentJobInfo.hasTarget}} + {{this._agentJobInfo?.hasTarget}} Has Schedule: - {{agentJobInfo.hasSchedule}} + {{this._agentJobInfo?.hasSchedule}} @@ -65,13 +65,13 @@ Last Run: - {{agentJobInfo.lastRun}} + {{this._agentJobInfo?.lastRun}} Next Run: - {{agentJobInfo.nextRun}} + {{this._agentJobInfo?.nextRun}} @@ -83,7 +83,7 @@
- +
Date @@ -93,6 +93,7 @@
+

No Previous Runs Available

@@ -158,7 +159,8 @@ - + +

No Steps Available

diff --git a/src/sql/parts/jobManagement/views/jobHistory.component.ts b/src/sql/parts/jobManagement/views/jobHistory.component.ts index ca2ec3710c..13d84a75d9 100644 --- a/src/sql/parts/jobManagement/views/jobHistory.component.ts +++ b/src/sql/parts/jobManagement/views/jobHistory.component.ts @@ -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(); + } } diff --git a/src/sql/parts/jobManagement/views/jobStepsView.component.ts b/src/sql/parts/jobManagement/views/jobStepsView.component.ts index f20d3cbabc..7006d9cda4 100644 --- a/src/sql/parts/jobManagement/views/jobStepsView.component.ts +++ b/src/sql/parts/jobManagement/views/jobStepsView.component.ts @@ -73,8 +73,5 @@ export class JobStepsViewComponent extends Disposable implements OnInit, OnChang this._tree.setInput(new JobStepsViewModel()); } } - - ngAfterContentChecked() { - } } diff --git a/src/sql/parts/jobManagement/views/jobStepsView.css b/src/sql/parts/jobManagement/views/jobStepsView.css index 6c1f2adf35..443e366fd7 100644 --- a/src/sql/parts/jobManagement/views/jobStepsView.css +++ b/src/sql/parts/jobManagement/views/jobStepsView.css @@ -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; diff --git a/src/sql/parts/jobManagement/views/jobsView.component.ts b/src/sql/parts/jobManagement/views/jobsView.component.ts index 679131e586..f37436b6bf 100644 --- a/src/sql/parts/jobManagement/views/jobsView.component.ts +++ b/src/sql/parts/jobManagement/views/jobsView.component.ts @@ -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(); @@ -68,6 +70,7 @@ export class JobsViewComponent { private _table: Table; 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) => { (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; } -} +} \ No newline at end of file diff --git a/src/sql/services/bootstrap/bootstrapService.ts b/src/sql/services/bootstrap/bootstrapService.ts index fc207b1730..bc889db460 100644 --- a/src/sql/services/bootstrap/bootstrapService.ts +++ b/src/sql/services/bootstrap/bootstrapService.ts @@ -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; /* diff --git a/src/sql/services/bootstrap/bootstrapServiceImpl.ts b/src/sql/services/bootstrap/bootstrapServiceImpl.ts index 5b6fa70d30..ab8457ae6e 100644 --- a/src/sql/services/bootstrap/bootstrapServiceImpl.ts +++ b/src/sql/services/bootstrap/bootstrapServiceImpl.ts @@ -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); diff --git a/src/typings/modules/@angular/core/index.d.ts b/src/typings/modules/@angular/core/index.d.ts index d9f322caea..6eebdc2850 100644 --- a/src/typings/modules/@angular/core/index.d.ts +++ b/src/typings/modules/@angular/core/index.d.ts @@ -6633,7 +6633,7 @@ export class ResolvedReflectiveFactory { /** * Factory function which can return an instance of an object represented by a key. */ - factory: Function, + factory: Function, /** * Arguments (dependencies) to the `factory` function. */ diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index f4bf795241..b17e62d0b0 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -130,9 +130,8 @@ import { IQueryManagementService, QueryManagementService } from 'sql/parts/query import { IEditorDescriptorService, EditorDescriptorService } from 'sql/parts/query/editor/editorDescriptorService'; import { IScriptingService, ScriptingService } from 'sql/services/scripting/scriptingService'; import { IAdminService, AdminService } from 'sql/parts/admin/common/adminService'; -import { IJobManagementService, IAgentJobCacheService } from 'sql/parts/jobManagement/common/interfaces'; +import { IJobManagementService } from 'sql/parts/jobManagement/common/interfaces'; import { JobManagementService } from 'sql/parts/jobManagement/common/jobManagementService'; -import { AgentJobCacheService } from 'sql/parts/jobManagement/common/agentJobCacheService'; import { IBackupService, IBackupUiService } from 'sql/parts/disasterRecovery/backup/common/backupService'; import { BackupService, BackupUiService } from 'sql/parts/disasterRecovery/backup/common/backupServiceImp'; import { IRestoreDialogController, IRestoreService } from 'sql/parts/disasterRecovery/restore/common/restoreService'; @@ -703,7 +702,6 @@ export class Workbench implements IPartService { serviceCollection.set(IScriptingService, this.instantiationService.createInstance(ScriptingService)); serviceCollection.set(IAdminService, this.instantiationService.createInstance(AdminService)); serviceCollection.set(IJobManagementService, this.instantiationService.createInstance(JobManagementService)); - serviceCollection.set(IAgentJobCacheService, this.instantiationService.createInstance(AgentJobCacheService)); serviceCollection.set(IBackupService, this.instantiationService.createInstance(BackupService)); serviceCollection.set(IBackupUiService, this.instantiationService.createInstance(BackupUiService)); serviceCollection.set(IRestoreService, this.instantiationService.createInstance(RestoreService));