loop-modules
Version:
Shared modules for the Loop product suite.
49 lines (43 loc) • 1.28 kB
text/typescript
// angular
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
// libs
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs/Observable';
/**
* Service reponsible for managing the company's primary brand color
* @author Sean Perkins <sean@meetmaestro.com | sean-perkins>
*
* @export
* @class BrandService
*/
()
export class BrandService {
private static DEFAULT_BRAND_COLOR: string = '#CD445B';
private brandColor: string;
constructor(private http: Http) {}
/**
* Sets the primary brand color from the backend-server
*
* @returns {Observable<any>} Observable of the loaded brand color
*
* @memberOf BrandService
*/
setBrand(): Observable<any> {
return Observable.create((observer: any) => {
this.http.get('/ma_loop/api/v1/configuration').map(res => res.json()).subscribe((result: any) => {
this.brandColor = result.brand_color_1 || BrandService.DEFAULT_BRAND_COLOR;
observer.next(this.brandColor);
});
});
}
/**
* Returns the organization's brand primary color
*
* @readonly
* @type {string}
*/
get color(): string {
return this.brandColor;
}
}