UNPKG

npm-uimapping

Version:
184 lines (173 loc) 6.64 kB
import * as i1 from '@angular/common/http'; import { HttpHeaders, HttpClientModule } from '@angular/common/http'; import * as i0 from '@angular/core'; import { Injectable, Pipe, NgModule } from '@angular/core'; import * as i2 from 'ngx-cookie-service'; class UiMapLibService { constructor(httpClient, cookieService) { this.httpClient = httpClient; this.cookieService = cookieService; } init(conf) { this.initService(conf); } isConfigured() { let configuredData = this.cookieService.get('UIMapConfigured'); return configuredData !== undefined && configuredData !== null; } getConf() { if (!this.isConfigured()) { return null; } let confString = localStorage.getItem('ui_map_conf_data'); if (confString === null) { return null; } return JSON.parse(confString); } initService(conf) { if (!this.isConfigured()) { console.error('UIMap Service not configured!'); return; } const url = conf.basePath + '/project/' + conf.project; this.get(url, conf); } get(url, conf) { let headerList = new HttpHeaders(); headerList = headerList.set('Accept', '*/*'); this.httpClient .get(url, { responseType: 'json', withCredentials: false, headers: headerList, observe: 'body', reportProgress: false, }) .subscribe((data) => { if (data !== undefined) { localStorage.setItem('ui_map_project_data', JSON.stringify(data)); localStorage.setItem('ui_map_conf_data', JSON.stringify(conf)); this.cookieService.set('UIMapConfigured', 'true'); } }); } transform(value, ...args) { let uiMapStringdata = localStorage.getItem('ui_map_project_data'); if (uiMapStringdata === null) { console.error('UI Map data not loaded!'); return '[' + value + ' not found!]'; } let rv = JSON.parse(uiMapStringdata); if (args !== null && args.length == 1 && rv.pages !== undefined && rv.pages.length > 0) { const param = args[0][0]; let filteredPage = null; for (let i = 0; i < rv.pages.length; i++) { const pageName = rv.pages[i].name; if (pageName === pageName) { filteredPage = rv.pages[i]; break; } } if (filteredPage !== null && filteredPage[param.lang] !== undefined) { rv = filteredPage[param.lang].values; } } if (rv === undefined) { return '[' + value + ' not found!]'; } const parts = value.split('.'); for (let i = 0; i < parts.length; i++) { rv = rv[parts[i]]; if (rv === undefined) { return '[' + value + ' not found!]'; } } return rv; } } UiMapLibService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UiMapLibService, deps: [{ token: i1.HttpClient }, { token: i2.CookieService }], target: i0.ɵɵFactoryTarget.Injectable }); UiMapLibService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UiMapLibService, providedIn: 'root' }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UiMapLibService, decorators: [{ type: Injectable, args: [{ providedIn: 'root', }] }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i2.CookieService }]; } }); class UmapPipe { constructor(uiMapLibService) { this.uiMapLibService = uiMapLibService; } transform(value, ...args) { return this.uiMapLibService.transform(value, args); } } UmapPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UmapPipe, deps: [{ token: UiMapLibService }], target: i0.ɵɵFactoryTarget.Pipe }); UmapPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UmapPipe, name: "umap", pure: false }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UmapPipe, decorators: [{ type: Pipe, args: [{ name: 'umap', pure: false, }] }], ctorParameters: function () { return [{ type: UiMapLibService }]; } }); class UiMapLibModule { static forRoot() { return { ngModule: UiMapLibModule, }; } } UiMapLibModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UiMapLibModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); UiMapLibModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UiMapLibModule, declarations: [UmapPipe], imports: [HttpClientModule], exports: [UmapPipe] }); UiMapLibModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UiMapLibModule, providers: [UmapPipe], imports: [[HttpClientModule]] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UiMapLibModule, decorators: [{ type: NgModule, args: [{ declarations: [UmapPipe], imports: [HttpClientModule], providers: [UmapPipe], exports: [UmapPipe], }] }] }); class UiMapConf { constructor() { this['lang'] = 'tr'; } } class Sort { constructor() { this.empty = false; this.sorted = false; this.unsorted = true; } } class Pageable { constructor() { this.offset = 0; this.paged = true; this.unpaged = false; this.pageSize = 5; this.pageNumber = 0; this.sort = new Sort(); this.sort.sorted = false; this.sort.unsorted = true; this.sort.empty = false; } } class PageableResult { constructor() { this.sort = new Sort(); } } /* * Public API Surface of ui-map-lib */ /** * Generated bundle index. Do not edit. */ export { Pageable, PageableResult, Sort, UiMapConf, UiMapLibModule, UiMapLibService, UmapPipe }; //# sourceMappingURL=npm-uimapping.mjs.map