@lxlib/theme
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
165 lines • 11.8 kB
JavaScript
/**
* @fileoverview added by tsickle
* Generated from: src/services/settings/settings.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
import * as i0 from "@angular/core";
/** @type {?} */
export const LAYOUT = 'layout';
/** @type {?} */
export const USER = 'user';
/** @type {?} */
export const APP = 'app';
/** @type {?} */
export const COMPANY = 'company';
export class SettingsService {
constructor() {
this.notify$ = new Subject();
this._app = null;
this._user = null;
this._layout = null;
this._company = null;
}
/**
* @private
* @param {?} key
* @return {?}
*/
get(key) {
return JSON.parse(localStorage.getItem(key) || 'null') || null;
}
/**
* @private
* @param {?} key
* @param {?} value
* @return {?}
*/
set(key, value) {
localStorage.setItem(key, JSON.stringify(value));
}
/**
* @return {?}
*/
get layout() {
if (!this._layout) {
this._layout = Object.assign({ fixed: true, collapsed: false, boxed: false, lang: null }, this.get(LAYOUT));
this.set(LAYOUT, this._layout);
}
return (/** @type {?} */ (this._layout));
}
/**
* @return {?}
*/
get app() {
if (!this._app) {
this._app = Object.assign({ year: new Date().getFullYear() }, this.get(APP));
this.set(APP, this._app);
}
return (/** @type {?} */ (this._app));
}
/**
* @return {?}
*/
get company() {
if (!this._company) {
this._company = Object.assign({ last_login: new Date() }, this.get(COMPANY));
this.set(COMPANY, this._company);
}
return (/** @type {?} */ (this._company));
}
/**
* @return {?}
*/
get user() {
if (!this._user) {
this._user = Object.assign({}, this.get(USER));
this.set(USER, this._user);
}
return (/** @type {?} */ (this._user));
}
/**
* @return {?}
*/
get notify() {
return this.notify$.asObservable();
}
/**
* @param {?} name
* @param {?=} value
* @return {?}
*/
setLayout(name, value) {
if (typeof name === 'string') {
this.layout[name] = value;
}
else {
this._layout = name;
}
this.set(LAYOUT, this._layout);
this.notify$.next((/** @type {?} */ ({ type: 'layout', name, value })));
return true;
}
/**
* @param {?} value
* @return {?}
*/
setApp(value) {
this._app = value;
this.set(APP, value);
this.notify$.next({ type: 'app', value });
return true;
}
/**
* @param {?} value
* @return {?}
*/
setUser(value) {
this._user = value;
this.set(USER, value);
this.notify$.next({ type: 'user', value });
return true;
}
/**
* @param {?} value
* @return {?}
*/
setCompany(value) {
this._company = value;
this.set(COMPANY, value);
this.notify$.next({ type: 'campany', value });
}
}
SettingsService.decorators = [
{ type: Injectable, args: [{ providedIn: 'root' },] }
];
/** @nocollapse */ SettingsService.ɵprov = i0.ɵɵdefineInjectable({ factory: function SettingsService_Factory() { return new SettingsService(); }, token: SettingsService, providedIn: "root" });
if (false) {
/**
* @type {?}
* @private
*/
SettingsService.prototype.notify$;
/**
* @type {?}
* @private
*/
SettingsService.prototype._app;
/**
* @type {?}
* @private
*/
SettingsService.prototype._user;
/**
* @type {?}
* @private
*/
SettingsService.prototype._layout;
/**
* @type {?}
* @private
*/
SettingsService.prototype._company;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2V0dGluZ3Muc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BseGxpYi90aGVtZS8iLCJzb3VyY2VzIjpbInNyYy9zZXJ2aWNlcy9zZXR0aW5ncy9zZXR0aW5ncy5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUMzQyxPQUFPLEVBQWMsT0FBTyxFQUFFLE1BQU0sTUFBTSxDQUFDOzs7QUFHM0MsTUFBTSxPQUFPLE1BQU0sR0FBRyxRQUFROztBQUU5QixNQUFNLE9BQU8sSUFBSSxHQUFHLE1BQU07O0FBRTFCLE1BQU0sT0FBTyxHQUFHLEdBQUcsS0FBSzs7QUFFeEIsTUFBTSxPQUFPLE9BQU8sR0FBRyxTQUFTO0FBR2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