From 9b80c51e66537c42c4eeff1180b1c3161ac42bff Mon Sep 17 00:00:00 2001 From: Alexander Matyushentsev Date: Thu, 24 Aug 2017 00:03:18 -0700 Subject: [PATCH 1/2] Remove not required SharedService class --- saas/axops/src/ui/src/app/services/index.ts | 1 - saas/axops/src/ui/src/app/services/services.module.ts | 2 -- saas/axops/src/ui/src/app/services/shared.service.ts | 11 ----------- .../user-profile/user-profile.component.ts | 9 ++------- .../src/ui/src/app/views/layout/layout.component.ts | 8 +------- 5 files changed, 3 insertions(+), 28 deletions(-) delete mode 100644 saas/axops/src/ui/src/app/services/shared.service.ts diff --git a/saas/axops/src/ui/src/app/services/index.ts b/saas/axops/src/ui/src/app/services/index.ts index 1eeb505d2e1a..522842172169 100644 --- a/saas/axops/src/ui/src/app/services/index.ts +++ b/saas/axops/src/ui/src/app/services/index.ts @@ -44,4 +44,3 @@ export { SlackService } from './slack.service'; export * from './playground-info.service'; export * from './system-request.service'; export * from './retention-policy.service'; -export * from './shared.service'; diff --git a/saas/axops/src/ui/src/app/services/services.module.ts b/saas/axops/src/ui/src/app/services/services.module.ts index 33f01a9568f6..abf68c5600b3 100644 --- a/saas/axops/src/ui/src/app/services/services.module.ts +++ b/saas/axops/src/ui/src/app/services/services.module.ts @@ -50,7 +50,6 @@ import { PlaygroundInfoService } from './playground-info.service'; import { TrackingService } from './tracking.service'; import { SlackService } from './slack.service'; import { SystemRequestService } from './system-request.service'; -import { SharedService } from './shared.service'; @NgModule({ providers: [ @@ -98,7 +97,6 @@ import { SharedService } from './shared.service'; GlobalSearchService, SecretService, TrackingService, - SharedService, PlaygroundInfoService, { provide: ContentService, diff --git a/saas/axops/src/ui/src/app/services/shared.service.ts b/saas/axops/src/ui/src/app/services/shared.service.ts deleted file mode 100644 index c3a7390f34db..000000000000 --- a/saas/axops/src/ui/src/app/services/shared.service.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Injectable } from '@angular/core'; -import {BehaviorSubject} from 'rxjs/BehaviorSubject'; - -@Injectable() -export class SharedService { - - updateSource: BehaviorSubject = new BehaviorSubject({}); - - // tslint:disable-next-line:no-empty - constructor() {} -} diff --git a/saas/axops/src/ui/src/app/views/+user-management/user-profile/user-profile.component.ts b/saas/axops/src/ui/src/app/views/+user-management/user-profile/user-profile.component.ts index 7912c774d430..db73cbe3c913 100644 --- a/saas/axops/src/ui/src/app/views/+user-management/user-profile/user-profile.component.ts +++ b/saas/axops/src/ui/src/app/views/+user-management/user-profile/user-profile.component.ts @@ -3,7 +3,7 @@ import { Router, ActivatedRoute } from '@angular/router'; import { Subscription } from 'rxjs'; import { User } from '../../../model'; -import { UsersService, AuthenticationService, SharedService } from '../../../services'; +import { UsersService, AuthenticationService } from '../../../services'; import { LayoutSettings, HasLayoutSettings } from '../../layout'; import { UserUtils } from '../user-utils'; @@ -27,8 +27,7 @@ export class UserProfileComponent implements OnInit, OnDestroy, LayoutSettings, private usersService: UsersService, private authenticationService: AuthenticationService, private activatedRoute: ActivatedRoute, - private utils: UserUtils, - private sharedService: SharedService) { + private utils: UserUtils) { } public get layoutSettings(): LayoutSettings { @@ -84,15 +83,11 @@ export class UserProfileComponent implements OnInit, OnDestroy, LayoutSettings, } private async loadUser() { - let emitToLayout = !this.user.id; await this.usersService.getUser(this.username).subscribe(result => { this.user = result; if (this.username === this.authenticationService.getUsername()) { this.isCurrentLoggedInUser = true; } - if (emitToLayout) { - this.sharedService.updateSource.next(this.layoutSettings); - } }); } } diff --git a/saas/axops/src/ui/src/app/views/layout/layout.component.ts b/saas/axops/src/ui/src/app/views/layout/layout.component.ts index 8393ee51535a..34691f43fc98 100644 --- a/saas/axops/src/ui/src/app/views/layout/layout.component.ts +++ b/saas/axops/src/ui/src/app/views/layout/layout.component.ts @@ -15,7 +15,6 @@ import { SecretService, ViewPreferencesService, AuthenticationService, - SharedService } from '../../services'; import { Task, Application } from '../../model'; @@ -101,8 +100,7 @@ export class LayoutComponent implements OnInit, OnDestroy { private playgroundInfoService: PlaygroundInfoService, private notificationService: NotificationService, private viewPreferencesService: ViewPreferencesService, - private authenticationService: AuthenticationService, - private sharedService: SharedService) { + private authenticationService: AuthenticationService) { this.encryptForm = new FormGroup({ repo: new FormControl('', Validators.required), @@ -144,10 +142,6 @@ export class LayoutComponent implements OnInit, OnDestroy { this.playgroundTask = info; })); - this.subscriptions.push(this.sharedService.updateSource.subscribe((layout) => { - this.layoutSettings = layout; - })); - this.authenticationService.getCurrentUser().then(user => { this.subscriptions.push(Observable.merge( this.notificationService.getEventsStream(user.username), From f2167b62c1d80b8e839cb12605f8fb69afefa7fb Mon Sep 17 00:00:00 2001 From: Alexander Matyushentsev Date: Thu, 24 Aug 2017 02:21:12 -0700 Subject: [PATCH 2/2] Support updating layout settings after page navigation is completed --- .../ui/src/app/views/layout/layout.component.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/saas/axops/src/ui/src/app/views/layout/layout.component.ts b/saas/axops/src/ui/src/app/views/layout/layout.component.ts index 34691f43fc98..bd02859df638 100644 --- a/saas/axops/src/ui/src/app/views/layout/layout.component.ts +++ b/saas/axops/src/ui/src/app/views/layout/layout.component.ts @@ -1,6 +1,6 @@ import * as moment from 'moment'; import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core'; -import { RouterOutlet, Router, NavigationEnd, ActivatedRoute } from '@angular/router'; +import { RouterOutlet, Router, ActivatedRoute } from '@angular/router'; import { Subject, Subscription, Observable } from 'rxjs'; import { FormControl, FormGroup, Validators } from '@angular/forms'; @@ -69,7 +69,6 @@ export class LayoutComponent implements OnInit, OnDestroy { public jiraIssueCreatorPanelComponent: JiraIssueCreatorPanelComponent; @ViewChild(JiraIssuesPanelComponent) public jiraIssuesPanelComponent: JiraIssuesPanelComponent; - public layoutSettings: LayoutSettings = {}; public globalSearch: GlobalSearchSetting; public hiddenScrollbar: boolean; public openedPanelOffCanvas: boolean; @@ -107,13 +106,6 @@ export class LayoutComponent implements OnInit, OnDestroy { secret: new FormControl('', Validators.required), }); - this.subscriptions.push(router.events.subscribe(event => { - if (event instanceof NavigationEnd) { - let component: any = this.routerOutlet.component; - this.layoutSettings = component ? component.layoutSettings || {} : {}; - } - })); - this.subscriptions.push(this.slidingPanelService.panelOpened.subscribe( isHidden => setTimeout(() => this.hiddenScrollbar = isHidden))); @@ -185,6 +177,11 @@ export class LayoutComponent implements OnInit, OnDestroy { })); } + public get layoutSettings(): LayoutSettings { + let component: any = this.routerOutlet.isActivated ? this.routerOutlet.component : null; + return component ? component.layoutSettings || {} : {}; + } + public ngOnInit() { this.launchPanelService.initPanel(this.multipleServiceLaunchPanel); }