UNPKG

@wasp-ui/ng-golden-layout

Version:
142 lines 4.98 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ import { Inject, Injectable, Optional } from "@angular/core"; import { GoldenLayoutConfiguration, GoldenLayoutDefaultSettings } from "./config"; import { GoldenLayoutStateStore } from "./state"; import * as _ from "lodash"; /** * golden-layout component initialization callback type. * @record */ export function ComponentInitCallback() { } function ComponentInitCallback_tsickle_Closure_declarations() { /* TODO: handle strange member: (container: GoldenLayout.Container, componentState: any): void; */ } /** * @record */ export function ComponentInitCallbackFactory() { } function ComponentInitCallbackFactory_tsickle_Closure_declarations() { /** @type {?} */ ComponentInitCallbackFactory.prototype.createComponentInitCallback; } var GoldenLayoutService = (function () { function GoldenLayoutService(config, stateStore) { this.config = config; this.stateStore = stateStore; this.layoutSettings = GoldenLayoutDefaultSettings; if (_.has(this.config, 'layoutSettings')) { this.layoutSettings = _.assign({}, this.layoutSettings, this.config.layoutSettings); } console.log("layoutSettings", this.layoutSettings); } /** * @param {?} goldenLayout * @param {?} componentInitCallbackFactory * @return {?} */ GoldenLayoutService.prototype.initialize = /** * @param {?} goldenLayout * @param {?} componentInitCallbackFactory * @return {?} */ function (goldenLayout, componentInitCallbackFactory) { var _this = this; this._goldenLayout = goldenLayout; this.config.components.forEach(function (componentConfig) { var /** @type {?} */ componentInitCallback = componentInitCallbackFactory.createComponentInitCallback(componentConfig.component); goldenLayout.registerComponent(componentConfig.componentName, componentInitCallback); }); if (this.stateStore) { (/** @type {?} */ ((/** @type {?} */ (goldenLayout)))).on('stateChanged', function () { _this._saveState(goldenLayout); }); } }; /** * @param {?} goldenLayout * @return {?} */ GoldenLayoutService.prototype._saveState = /** * @param {?} goldenLayout * @return {?} */ function (goldenLayout) { if (this.stateStore && goldenLayout.isInitialised && this.layoutSettings.persistLayoutState) { try { this.stateStore.writeState(goldenLayout.toConfig()); } catch (/** @type {?} */ ex) { // Workaround for https://github.com/deepstreamIO/golden-layout/issues/192 } } }; /** * @return {?} */ GoldenLayoutService.prototype.getState = /** * @return {?} */ function () { var _this = this; if (this.stateStore && this.layoutSettings.persistLayoutState) { return this.stateStore.loadState().catch(function () { return _this.config.defaultLayout; }); } else { this.stateStore.clearState(); } return Promise.resolve(this.config.defaultLayout); }; /** * @return {?} */ GoldenLayoutService.prototype.getGoldenLayout = /** * @return {?} */ function () { return this._goldenLayout; }; /** * @return {?} */ GoldenLayoutService.prototype.isInitialised = /** * @return {?} */ function () { return this._goldenLayout.isInitialised; }; GoldenLayoutService.decorators = [ { type: Injectable }, ]; /** @nocollapse */ GoldenLayoutService.ctorParameters = function () { return [ { type: GoldenLayoutConfiguration, decorators: [{ type: Inject, args: [GoldenLayoutConfiguration,] },] }, { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [GoldenLayoutStateStore,] },] }, ]; }; return GoldenLayoutService; }()); export { GoldenLayoutService }; function GoldenLayoutService_tsickle_Closure_declarations() { /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */ GoldenLayoutService.decorators; /** * @nocollapse * @type {function(): !Array<(null|{type: ?, decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>)})>} */ GoldenLayoutService.ctorParameters; /** @type {?} */ GoldenLayoutService.prototype.layoutSettings; /** @type {?} */ GoldenLayoutService.prototype._goldenLayout; /** @type {?} */ GoldenLayoutService.prototype.config; /** @type {?} */ GoldenLayoutService.prototype.stateStore; } //# sourceMappingURL=golden-layout.service.js.map