Project

General

Profile

« Previous | Next » 

Revision 60118

[Library | Trunk]: Add isDashboad subject on laypout service

View differences:

modules/uoa-services-library/trunk/ng-openaire-library/src/app/dashboard/sharedComponents/sidebar/layout.service.ts
6 6
  providedIn: 'root'
7 7
})
8 8
export class LayoutService {
9

  
9
  
10 10
  /**
11 11
   * Set this to true when sidebar items are ready.
12 12
   */
13 13
  private openSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
14

  
14
  
15 15
  /**
16 16
   *  Add hasSidebar: false on data of route config, if sidebar is not needed.
17 17
   */
18 18
  private hasSidebarSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
19

  
19
  
20 20
  /**
21 21
   *  Add hasHeader: false on data of route config, if header is not needed.
22 22
   */
......
25 25
  /**
26 26
   *  Add hasAdminMenu: true on data of route config, if global sidebar should be used.
27 27
   */
28
  private _hasAdminMenuSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
28
  private hasAdminMenuSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
29 29
  /**
30 30
   *  Add hasMiniMenu: true on data of route config, if sidebar should be closed to mini should be used.
31 31
   */
32
  private _hasMiniMenuSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
32
  private hasMiniMenuSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
33 33
  /**
34 34
   *  Add isFrontPage: true on data of route config, if current route is for front page.
35 35
   */
36
  private _isFrontPageSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
37
  private _isSmallScreenSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
38

  
39
  sub:any;
40

  
36
  private isFrontPageSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
37
  /**
38
   *  Add isSmallScreen: true on data of route config, if screen is small.
39
   */
40
  private isSmallScreenSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
41
  
42
  /**
43
   *  Add isDashboard: false on data of route config, if page is for a stakeholder but not for dashboard.
44
   */
45
  private isDashboardSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
46
  
47
  sub: any;
48
  
41 49
  ngOnDestroy() {
42 50
    this.clearSubscriptions();
43 51
  }
44

  
45
  clearSubscriptions(){
52
  
53
  clearSubscriptions() {
46 54
    if (this.sub instanceof Subscriber) {
47 55
      this.sub.unsubscribe();
48 56
    }
49 57
  }
58
  
50 59
  constructor(private router: Router) {
51 60
    this.sub = this.router.events.subscribe(event => {
52 61
      if (event instanceof ActivationStart) {
......
87 96
        } else {
88 97
          this.setSmallScreen(false);
89 98
        }
99
        if (data['isDashboard'] !== undefined &&
100
          data['isDashboard'] === false) {
101
          this.setDashboard(false);
102
        } else {
103
          this.setDashboard(true);
104
        }
90 105
      }
91 106
    });
92 107
  }
93

  
108
  
94 109
  get open(): boolean {
95 110
    return this.openSubject.getValue();
96 111
  }
97

  
112
  
98 113
  setOpen(value: boolean) {
99 114
    this.openSubject.next(value);
100 115
  }
101

  
116
  
102 117
  get hasSidebar(): Observable<boolean> {
103 118
    return this.hasSidebarSubject.asObservable();
104 119
  }
105

  
120
  
106 121
  setHasSidebar(value: boolean) {
107 122
    this.hasSidebarSubject.next(value);
108 123
  }
109

  
124
  
110 125
  get hasHeader(): Observable<boolean> {
111 126
    return this.hasHeaderSubject.asObservable();
112 127
  }
113

  
128
  
114 129
  setHasHeader(value: boolean) {
115 130
    this.hasHeaderSubject.next(value);
116 131
  }
117

  
118

  
132
  
133
  
119 134
  get hasAdminMenu(): Observable<boolean> {
120
    return this._hasAdminMenuSubject.asObservable();
135
    return this.hasAdminMenuSubject.asObservable();
121 136
  }
122

  
137
  
123 138
  setHasAdminMenu(value: boolean) {
124
    this._hasAdminMenuSubject.next(value);
139
    this.hasAdminMenuSubject.next(value);
125 140
  }
126

  
141
  
127 142
  get hasMiniMenu(): Observable<boolean> {
128
    return this._hasMiniMenuSubject.asObservable();
143
    return this.hasMiniMenuSubject.asObservable();
129 144
  }
130

  
145
  
131 146
  setHasMiniMenu(value: boolean) {
132
    this._hasMiniMenuSubject.next(value);
147
    this.hasMiniMenuSubject.next(value);
133 148
  }
149
  
134 150
  get isFrontPage(): Observable<boolean> {
135
    return this._isFrontPageSubject.asObservable();
151
    return this.isFrontPageSubject.asObservable();
136 152
  }
137

  
153
  
138 154
  setFrontPage(value: boolean) {
139
    this._isFrontPageSubject.next(value);
155
    this.isFrontPageSubject.next(value);
140 156
  }
141
  get isSmallScreen(): boolean{
142
    return this._isSmallScreenSubject.getValue();
157
  
158
  get isDashboard(): Observable<boolean> {
159
    return this.isDashboardSubject.asObservable();
143 160
  }
144

  
161
  
162
  setDashboard(value: boolean) {
163
    this.isDashboardSubject.next(value);
164
  }
165
  
166
  get isSmallScreen(): boolean {
167
    return this.isSmallScreenSubject.getValue();
168
  }
169
  
145 170
  setSmallScreen(value: boolean) {
146
    this._isSmallScreenSubject.next(value);
171
    this.isSmallScreenSubject.next(value);
147 172
  }
148 173
}

Also available in: Unified diff