Skip to content

Commit

Permalink
Remove not required SharedService class (argoproj#24)
Browse files Browse the repository at this point in the history
* Remove not required SharedService class

* Support updating layout settings after page navigation is completed
  • Loading branch information
alexmt authored and wokeGit committed Nov 20, 2017
1 parent 797afde commit 8b7cef3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 37 deletions.
1 change: 0 additions & 1 deletion saas/axops/src/ui/src/app/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
2 changes: 0 additions & 2 deletions saas/axops/src/ui/src/app/services/services.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -98,7 +97,6 @@ import { SharedService } from './shared.service';
GlobalSearchService,
SecretService,
TrackingService,
SharedService,
PlaygroundInfoService,
{
provide: ContentService,
Expand Down
11 changes: 0 additions & 11 deletions saas/axops/src/ui/src/app/services/shared.service.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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 {
Expand Down Expand Up @@ -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);
}
});
}
}
23 changes: 7 additions & 16 deletions saas/axops/src/ui/src/app/views/layout/layout.component.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -15,7 +15,6 @@ import {
SecretService,
ViewPreferencesService,
AuthenticationService,
SharedService
} from '../../services';
import { Task, Application } from '../../model';

Expand Down Expand Up @@ -70,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;
Expand Down Expand Up @@ -101,21 +99,13 @@ 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),
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)));

Expand Down Expand Up @@ -144,10 +134,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),
Expand Down Expand Up @@ -191,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);
}
Expand Down

0 comments on commit 8b7cef3

Please sign in to comment.