diff --git a/src/app/app.component.ts b/src/app/app.component.ts index c71c6a3..6bc753f 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -141,18 +141,9 @@ export class AppComponent implements OnInit, OnDestroy { this.stakeholder = stakeholder; LinksResolver.setProperties(this.stakeholder.alias); this.setProperties(this.stakeholder.alias, this.stakeholder.type); - if (params && params['topic'] && !this.activeTopic) { - this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.isPublicOrIsMember(topic.visibility)); - } else { - this.activeTopic = this.stakeholder.topics.find(topic => this.isPublicOrIsMember(topic.visibility)); - } - if (params && params['category']) { - this.activeCategory = this.activeTopic.categories.find(category => category.alias === decodeURIComponent(params['category']) && this.isPublicOrIsMember(category.visibility)); - } else { - this.activeCategory = this.activeTopic.categories.find(category => this.isPublicOrIsMember(category.visibility)); - } - this.setSideBar(); this.buildMenu(); + this.setActives(params); + this.setSideBar(); this.loading = false; } else { this.stakeholder = null; @@ -164,16 +155,7 @@ export class AppComponent implements OnInit, OnDestroy { })); } else { this.buildMenu(); - if (params && params['topic']) { - this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.isPublicOrIsMember(topic.visibility)); - } else { - this.activeTopic = this.stakeholder.topics.find(topic => this.isPublicOrIsMember(topic.visibility)); - } - if (params && params['category']) { - this.activeCategory = this.activeTopic.categories.find(category => category.alias === decodeURIComponent(params['category']) && this.isPublicOrIsMember(category.visibility)); - } else { - this.activeCategory = this.activeTopic.categories.find(category => this.isPublicOrIsMember(category.visibility)); - } + this.setActives(params); this.loading = false; } } else { @@ -207,6 +189,26 @@ export class AppComponent implements OnInit, OnDestroy { })); } + setActives(params: Params) { + if (params && params['topic']) { + this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.isPublicOrIsMember(topic.visibility)); + } else { + this.activeTopic = this.stakeholder.topics.find(topic => this.isPublicOrIsMember(topic.visibility)); + } + if(this.activeTopic) { + if (params && params['category']) { + this.activeCategory = this.activeTopic.categories.find(category => category.alias === decodeURIComponent(params['category']) && this.isPublicOrIsMember(category.visibility)); + } else { + this.activeCategory = this.activeTopic.categories.find(category => this.isPublicOrIsMember(category.visibility)); + } + if(!this.activeCategory) { + this.navigateToError(); + } + } else { + this.navigateToError(); + } + } + public setNotificationGroups() { this.entities = this.stakeholderUtils.types.map(option => option.value); this.notificationGroups = []; diff --git a/src/app/monitor/monitor.component.html b/src/app/monitor/monitor.component.html index fb746cf..3c37e1b 100644 --- a/src/app/monitor/monitor.component.html +++ b/src/app/monitor/monitor.component.html @@ -39,10 +39,10 @@