diff options
Diffstat (limited to 'vid-webpack-master/src/app/shared/components/spinner/spinner.component.ts')
-rw-r--r-- | vid-webpack-master/src/app/shared/components/spinner/spinner.component.ts | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/vid-webpack-master/src/app/shared/components/spinner/spinner.component.ts b/vid-webpack-master/src/app/shared/components/spinner/spinner.component.ts index 0ce5d2074..94a0e1c52 100644 --- a/vid-webpack-master/src/app/shared/components/spinner/spinner.component.ts +++ b/vid-webpack-master/src/app/shared/components/spinner/spinner.component.ts @@ -1,18 +1,50 @@ -import { Component, Input } from '@angular/core'; -import { Subject } from 'rxjs/Subject'; +import {Component} from '@angular/core'; +import {Subject} from 'rxjs/Subject'; +import * as _ from 'lodash'; @Component({ selector : 'spinner-component', - templateUrl : './spinner.component.html', - styleUrls : ['./spinner.component.scss'] + templateUrl: './spinner.component.html', + styleUrls : ['./spinner.component.scss'], + providers : [] + }) -export class SpinnerComponent { - show : boolean = false; - static showSpinner: Subject<boolean> = new Subject<boolean>(); +export class SpinnerComponent{ + show : boolean; + size = "large"; + global = true; + + requestMap = {}; + + static showSpinner: Subject<SpinnerInfo> = new Subject<SpinnerInfo>(); constructor(){ - SpinnerComponent.showSpinner.subscribe((status) => { - this.show = status; + SpinnerComponent.showSpinner.subscribe((spinnerInfo) => { + let status = spinnerInfo['status']; + let requestType = spinnerInfo['requestType']; + let requestUrl = spinnerInfo['requestUrl']; + + if(status && requestType === 'json'){ + this.requestMap[requestUrl] = true; + }else { + delete this.requestMap[requestUrl] + } + console.log(this.requestMap); + this.show = !_.isEmpty(this.requestMap) && this.requestMap !== undefined; + }) } } + + +export class SpinnerInfo { + status : boolean; + requestUrl : string; + requestType : string; + + constructor(status : boolean, requestUrl : string, requestType : string){ + this.status = status; + this.requestUrl = requestUrl; + this.requestType = requestType; + } +} |