blob: 94a0e1c52b1ba3b4abdafb6673b0e3efd54ae4c8 [file] [log] [blame]
Ittay Stern6f900cc2018-08-29 17:01:32 +03001import {Component} from '@angular/core';
2import {Subject} from 'rxjs/Subject';
3import * as _ from 'lodash';
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03004
5@Component({
6 selector : 'spinner-component',
Ittay Stern6f900cc2018-08-29 17:01:32 +03007 templateUrl: './spinner.component.html',
8 styleUrls : ['./spinner.component.scss'],
9 providers : []
10
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030011})
Ittay Stern6f900cc2018-08-29 17:01:32 +030012export class SpinnerComponent{
13 show : boolean;
14 size = "large";
15 global = true;
16
17 requestMap = {};
18
19 static showSpinner: Subject<SpinnerInfo> = new Subject<SpinnerInfo>();
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030020
21 constructor(){
Ittay Stern6f900cc2018-08-29 17:01:32 +030022 SpinnerComponent.showSpinner.subscribe((spinnerInfo) => {
23 let status = spinnerInfo['status'];
24 let requestType = spinnerInfo['requestType'];
25 let requestUrl = spinnerInfo['requestUrl'];
26
27 if(status && requestType === 'json'){
28 this.requestMap[requestUrl] = true;
29 }else {
30 delete this.requestMap[requestUrl]
31 }
32 console.log(this.requestMap);
33 this.show = !_.isEmpty(this.requestMap) && this.requestMap !== undefined;
34
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030035 })
36 }
37}
Ittay Stern6f900cc2018-08-29 17:01:32 +030038
39
40export class SpinnerInfo {
41 status : boolean;
42 requestUrl : string;
43 requestType : string;
44
45 constructor(status : boolean, requestUrl : string, requestType : string){
46 this.status = status;
47 this.requestUrl = requestUrl;
48 this.requestType = requestType;
49 }
50}