Guest User

Untitled

a guest
Dec 11th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. this.loading = true;
  2. this.userService.getTableConfig(this.auth.user.id, 'widget_config').subscribe(this.doSthWithConf.bind(this),
  3. (error) => {
  4. this.loading = false;
  5. });
  6.  
  7. if (this.isEmpty(configs.data)) {
  8.  
  9. } else {
  10. this.defaultconfig = configs.data;
  11. const tasks$ = [];
  12. for (let i = 0; i < this.defaultconfig.length; i++) {
  13. const conf = this.defaultconfig[i];
  14. tasks$.push(this.createWidget(conf));
  15. }
  16.  
  17.  
  18. Observable.forkJoin(...tasks$).subscribe(r => {
  19. this.loading = false;
  20. }, (error) => {
  21. this.loading = false;
  22. });
  23. }
  24.  
  25. return this.widgetservce.getUsageMonthly(conf.id).do((data) => {
  26. if (data.data) {
  27. setTimeout(() => {
  28. this.widgets.push(new WidgetModel(conf.title, conf.type,
  29. conf.payload, true, data.data, conf));
  30. }, 7000);
  31. }
  32. }).catch(e => Observable.of({ notLoaded: true, name: `ERROR Loading!` }))
  33. .map((res: any) => {
  34. if (res.notLoaded) {
  35. setTimeout(() => {
  36. this.widgets.push(new WidgetModel(conf.title, conf.type,
  37. conf.payload, true, '', conf));
  38. }, 7000)
  39. }
  40. return { models: res, error: (res[0] || {}).error }
  41. });
Add Comment
Please, Sign In to add comment