Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.loading = true;
- this.userService.getTableConfig(this.auth.user.id, 'widget_config').subscribe(this.doSthWithConf.bind(this),
- (error) => {
- this.loading = false;
- });
- if (this.isEmpty(configs.data)) {
- } else {
- this.defaultconfig = configs.data;
- const tasks$ = [];
- for (let i = 0; i < this.defaultconfig.length; i++) {
- const conf = this.defaultconfig[i];
- tasks$.push(this.createWidget(conf));
- }
- Observable.forkJoin(...tasks$).subscribe(r => {
- this.loading = false;
- }, (error) => {
- this.loading = false;
- });
- }
- return this.widgetservce.getUsageMonthly(conf.id).do((data) => {
- if (data.data) {
- setTimeout(() => {
- this.widgets.push(new WidgetModel(conf.title, conf.type,
- conf.payload, true, data.data, conf));
- }, 7000);
- }
- }).catch(e => Observable.of({ notLoaded: true, name: `ERROR Loading!` }))
- .map((res: any) => {
- if (res.notLoaded) {
- setTimeout(() => {
- this.widgets.push(new WidgetModel(conf.title, conf.type,
- conf.payload, true, '', conf));
- }, 7000)
- }
- return { models: res, error: (res[0] || {}).error }
- });
Add Comment
Please, Sign In to add comment