src/lib/services/config.service.ts
Properties |
|
Methods |
|
constructor(activatedRoute: ActivatedRoute, discussionService: DiscussionService)
|
|||||||||
Defined in src/lib/services/config.service.ts:21
|
|||||||||
Parameters :
|
Public getBannerOption |
getBannerOption()
|
Defined in src/lib/services/config.service.ts:85
|
Returns :
any
|
Public getCategories |
getCategories()
|
Defined in src/lib/services/config.service.ts:56
|
Returns :
any
|
Public getCategoryid |
getCategoryid()
|
Defined in src/lib/services/config.service.ts:89
|
Returns :
string
|
Public getConfig |
getConfig()
|
Defined in src/lib/services/config.service.ts:52
|
Returns :
IdiscussionConfig
|
Public getContext |
getContext()
|
Defined in src/lib/services/config.service.ts:68
|
Returns :
any
|
Public getHeaderOption |
getHeaderOption()
|
Defined in src/lib/services/config.service.ts:81
|
Returns :
any
|
Public getRouterSlug |
getRouterSlug()
|
Defined in src/lib/services/config.service.ts:93
|
Returns :
any
|
Public hasContext |
hasContext()
|
Defined in src/lib/services/config.service.ts:61
|
Returns :
any
|
ngOnInit |
ngOnInit()
|
Defined in src/lib/services/config.service.ts:28
|
Returns :
void
|
setCategoryid | ||||
setCategoryid(id)
|
||||
Defined in src/lib/services/config.service.ts:75
|
||||
Parameters :
Returns :
void
|
setConfig | ||||
setConfig(activatedRoute)
|
||||
Defined in src/lib/services/config.service.ts:32
|
||||
Parameters :
Returns :
void
|
setConfigFromParams | ||||
setConfigFromParams(activatedRoute)
|
||||
Defined in src/lib/services/config.service.ts:38
|
||||
Parameters :
Returns :
void
|
setConfigFromWidgetBaseClass | ||||
setConfigFromWidgetBaseClass(config)
|
||||
Defined in src/lib/services/config.service.ts:48
|
||||
Parameters :
Returns :
void
|
Private _config |
Type : IdiscussionConfig
|
Defined in src/lib/services/config.service.ts:14
|
Public activatedRoute |
Type : ActivatedRoute
|
Defined in src/lib/services/config.service.ts:24
|
categoryId |
Type : string
|
Defined in src/lib/services/config.service.ts:21
|
Public checkContext |
Type : boolean
|
Defined in src/lib/services/config.service.ts:15
|
getContextData |
Type : any
|
Defined in src/lib/services/config.service.ts:17
|
getParams |
Type : IdiscussionConfig
|
Defined in src/lib/services/config.service.ts:19
|
hasContextData |
Type : any
|
Defined in src/lib/services/config.service.ts:18
|
paramsSubscription |
Type : Subscription
|
Defined in src/lib/services/config.service.ts:13
|
Public queryParams |
Defined in src/lib/services/config.service.ts:16
|
setCategoryId |
Default value : new ReplaySubject(1)
|
Defined in src/lib/services/config.service.ts:20
|
import { DiscussionService } from './discussion.service';
import { Injectable, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ReplaySubject, Subscription } from 'rxjs';
import * as _ from 'lodash'
import { IdiscussionConfig } from '../models/discussion-config.model';
@Injectable({
providedIn: 'root'
})
export class ConfigService implements OnInit {
paramsSubscription: Subscription;
private _config: IdiscussionConfig;
public checkContext: boolean;
public queryParams;
getContextData: any;
hasContextData: any;
getParams: IdiscussionConfig;
setCategoryId = new ReplaySubject(1)
categoryId: string
constructor(
public activatedRoute: ActivatedRoute,
private discussionService: DiscussionService,
) { }
ngOnInit() {
}
setConfig(activatedRoute) {
activatedRoute.data.subscribe((config) => {
this._config = config.data;
});
}
setConfigFromParams(activatedRoute) {
activatedRoute.queryParams.subscribe((params) => {
const obj: IdiscussionConfig = {
userId : _.get(params, 'userId'),
categories : JSON.parse(_.get(params, 'categories'))
};
this._config = obj;
});
}
setConfigFromWidgetBaseClass(config){
this._config = config
}
public getConfig() {
return this._config;
}
public getCategories() {
this.getParams = this.getConfig()
return _.get(this.getParams, 'categories')
}
public hasContext() {
this.hasContextData = this.getCategories() ?
(this.getCategories().result ? this.getCategories().result.length : null)
: null
return this.hasContextData
}
public getContext() {
this.getContextData = this.getCategories() ?
(this.getCategories().result ? this.getCategories().result : null)
: null
return this.getContextData
}
setCategoryid(id) {
this.categoryId = id
this.setCategoryId.next(id)
}
public getHeaderOption() {
return this._config.headerOptions !== undefined ? this._config.headerOptions : true;
}
public getBannerOption() {
return this._config.bannerOption ? this._config.bannerOption : false;
}
public getCategoryid() {
return this.categoryId
}
public getRouterSlug() {
return this._config.routerSlug ? this._config.routerSlug : '';
}
}