UNPKG

nakedobjects.spa

Version:

Single Page Application client for a Naked Objects application.

91 lines 3.49 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { Injectable } from '@angular/core'; import { Http } from '@angular/http'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/toPromise'; import assign from 'lodash/assign'; export function configFactory(config) { return function () { return config.load(); }; } export function localeFactory(config) { return config.config.defaultLocale; } var ConfigService = (function () { function ConfigService(http) { this.http = http; // defaults this.appConfig = { authenticate: false, appPath: "", applicationName: "", logoffUrl: "", postLogoffUrl: "/gemini/home", defaultPageSize: 20, listCacheSize: 5, shortCutMarker: "___", urlShortCuts: [], keySeparator: "--", objectColor: "object-color", linkColor: "link-color", autoLoadDirty: true, showDirtyFlag: false, defaultLocale: "en-GB", httpCacheDepth: 50, transientCacheDepth: 4, recentCacheDepth: 20, doUrlValidation: false, leftClickHomeAlwaysGoesToSinglePane: true, logLevel: "error", dateInputFormat: "D MMM YYYY" }; } Object.defineProperty(ConfigService.prototype, "config", { get: function () { return this.appConfig; }, set: function (newConfig) { // merge defaults assign(this.appConfig, newConfig); }, enumerable: true, configurable: true }); ConfigService.prototype.getAppPath = function (appPath) { if (appPath.charAt(appPath.length - 1) === "/") { return appPath.length > 1 ? appPath.substring(0, appPath.length - 1) : ""; } return appPath; }; ConfigService.prototype.checkAppPath = function () { this.appConfig.appPath = this.getAppPath(this.appConfig.appPath); }; ConfigService.prototype.load = function () { var _this = this; var options = { withCredentials: true }; return this.http.get('config.json', options). map(function (res) { return res.json(); }). toPromise(). then(function (serverConfig) { _this.config = serverConfig; _this.checkAppPath(); return true; }); }; return ConfigService; }()); ConfigService = __decorate([ Injectable(), __metadata("design:paramtypes", [Http]) ], ConfigService); export { ConfigService }; //# sourceMappingURL=config.service.js.map