UNPKG

vibe-sharedui

Version:

EuroMonitor EMI vibe models

409 lines (398 loc) 15.8 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('@angular/material'), require('@angular/flex-layout'), require('@angular/router'), require('@angular/material/core'), require('@angular/material/datepicker'), require('@angular/material/dialog'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators')) : typeof define === 'function' && define.amd ? define('vibe-sharedui', ['exports', '@angular/core', '@angular/common', '@angular/forms', '@angular/material', '@angular/flex-layout', '@angular/router', '@angular/material/core', '@angular/material/datepicker', '@angular/material/dialog', '@angular/common/http', 'rxjs', 'rxjs/operators'], factory) : (global = global || self, factory(global['vibe-sharedui'] = {}, global.ng.core, global.ng.common, global.ng.forms, global.ng.material, global.ng['flex-layout'], global.ng.router, global.ng.material.core, global.ng.material.datepicker, global.ng.material.dialog, global.ng.common.http, global.rxjs, global.rxjs.operators)); }(this, function (exports, core, common, forms, material, flexLayout, router, core$1, datepicker, dialog, http, rxjs, operators) { 'use strict'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var materialModules = [ material.MatAutocompleteModule, material.MatButtonModule, material.MatBadgeModule, material.MatButtonToggleModule, material.MatCheckboxModule, material.MatToolbarModule, material.MatTooltipModule, material.MatCardModule, material.MatChipsModule, material.MatDatepickerModule, material.MatExpansionModule, material.MatFormFieldModule, material.MatGridListModule, material.MatIconModule, material.MatListModule, material.MatMenuModule, material.MatNativeDateModule, material.MatPaginatorModule, material.MatProgressBarModule, material.MatProgressSpinnerModule, material.MatRadioModule, material.MatRippleModule, material.MatSelectModule, material.MatSidenavModule, material.MatInputModule, material.MatSliderModule, material.MatSlideToggleModule, material.MatSnackBarModule, material.MatSortModule, material.MatTableModule, material.MatTabsModule, material.MatStepperModule, material.MatTreeModule ]; var SFGSharedMaterialModule = /** @class */ (function () { function SFGSharedMaterialModule() { } SFGSharedMaterialModule.decorators = [ { type: core.NgModule, args: [{ imports: materialModules, exports: materialModules },] } ]; return SFGSharedMaterialModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var SharedFlexLayoutModule = /** @class */ (function () { function SharedFlexLayoutModule() { } SharedFlexLayoutModule.decorators = [ { type: core.NgModule, args: [{ imports: [flexLayout.FlexLayoutModule.withConfig({ useColumnBasisZero: false })], exports: [flexLayout.FlexLayoutModule], },] } ]; return SharedFlexLayoutModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var SharedModule = /** @class */ (function () { function SharedModule() { } SharedModule.decorators = [ { type: core.NgModule, args: [{ imports: [common.CommonModule], exports: [ common.CommonModule, router.RouterModule, SFGSharedMaterialModule, forms.ReactiveFormsModule, forms.FormsModule, SharedFlexLayoutModule ] },] } ]; return SharedModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var MODULE_EXPORTS = [datepicker.MatDatepickerModule, core$1.MatNativeDateModule]; /** @type {?} */ var DATE_FORMATS = { parse: { dateInput: 'LL', }, display: { dateInput: 'LL', monthYearLabel: 'MMM YYYY', dateA11yLabel: 'LL', monthYearA11yLabel: 'MMMM YYYY', }, }; var ɵ0 = DATE_FORMATS; var SharedMaterialDateModule = /** @class */ (function () { function SharedMaterialDateModule() { } SharedMaterialDateModule.decorators = [ { type: core.NgModule, args: [{ exports: MODULE_EXPORTS, providers: [{ provide: core$1.MAT_DATE_FORMATS, useValue: ɵ0 }, { provide: core$1.MAT_DATE_LOCALE, useValue: 'en-GB' }], },] } ]; return SharedMaterialDateModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @abstract * @template TEntity */ var EntityFormComponent = /** @class */ (function () { function EntityFormComponent(data, dialogRef) { this.data = data; this.dialogRef = dialogRef; this.title = data.title; this.entity = data.payload; } /** * @return {?} */ EntityFormComponent.prototype.ngOnInit = /** * @return {?} */ function () { this.buildForm(this.entity); }; /** * @return {?} */ EntityFormComponent.prototype.submit = /** * @return {?} */ function () { this.dialogRef.close((/** @type {?} */ (this.entityForm.value))); }; /** @nocollapse */ EntityFormComponent.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: core.Inject, args: [dialog.MAT_DIALOG_DATA,] }] }, { type: dialog.MatDialogRef } ]; }; return EntityFormComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @abstract * @template T */ var EntityService = /** @class */ (function () { function EntityService(httpClient, environment) { this.httpClient = httpClient; this.loadingSubject = new rxjs.BehaviorSubject(false); this.loading$ = this.loadingSubject.asObservable(); this.baseUrl = environment.API_BASE_URL; } /** * @param {?} id * @return {?} */ EntityService.prototype.getById = /** * @param {?} id * @return {?} */ function (id) { // this.loadingSubject.next(true); return this.httpClient.get(this.baseUrl + "/" + this.entityPath + "/" + id).pipe(operators.catchError(this.handleError)); }; // findAll(filter: Filter, order = 'DESC', skip = 0, take = 100): Observable<IPagination<T>> | Observable<never> { // findAll(filter: Filter, order = 'DESC', skip = 0, take = 100): Observable<IPagination<T>> | Observable<never> { /** * @param {?} filter * @param {?=} order * @param {?=} skip * @param {?=} take * @return {?} */ EntityService.prototype.findAll = // findAll(filter: Filter, order = 'DESC', skip = 0, take = 100): Observable<IPagination<T>> | Observable<never> { /** * @param {?} filter * @param {?=} order * @param {?=} skip * @param {?=} take * @return {?} */ function (filter, order, skip, take) { var _this = this; if (order === void 0) { order = 'DESC'; } if (skip === void 0) { skip = 0; } if (take === void 0) { take = 100; } this.loadingSubject.next(true); return this.httpClient .get(this.baseUrl + "/" + this.entityPath, { params: new http.HttpParams() .set('filter', 'filter TODO') .set('order', order) .set('skip', skip.toString()) .set('take', take.toString()), }) .pipe(operators.retry(3), // retry a failed request up to 3 times operators.catchError(this.handleError), operators.finalize((/** * @return {?} */ function () { return _this.loadingSubject.next(false); }))); }; // getAll(): Observable<IPagination<T>> { // getAll(): Observable<IPagination<T>> { /** * @return {?} */ EntityService.prototype.getAll = // getAll(): Observable<IPagination<T>> { /** * @return {?} */ function () { var _this = this; this.loadingSubject.next(true); return this.httpClient.get(this.baseUrl + "/" + this.entityPath).pipe(operators.retry(3), // retry a failed request up to 3 times operators.catchError(this.handleError), operators.finalize((/** * @return {?} */ function () { return _this.loadingSubject.next(false); }))); }; /** * @param {?} id * @return {?} */ EntityService.prototype.delete = /** * @param {?} id * @return {?} */ function (id) { var _this = this; this.loadingSubject.next(true); return this.httpClient.delete(this.baseUrl + "/" + this.entityPath + "/" + id).pipe(operators.catchError(this.handleError), operators.finalize((/** * @return {?} */ function () { return _this.loadingSubject.next(false); }))); }; /** * @param {?} entity * @return {?} */ EntityService.prototype.post = /** * @param {?} entity * @return {?} */ function (entity) { var _this = this; this.loadingSubject.next(true); return this.httpClient.post(this.baseUrl + "/" + this.entityPath, entity).pipe(operators.catchError(this.handleError), operators.finalize((/** * @return {?} */ function () { return _this.loadingSubject.next(false); }))); }; /** * @param {?} id * @param {?} entity * @return {?} */ EntityService.prototype.put = /** * @param {?} id * @param {?} entity * @return {?} */ function (id, entity) { var _this = this; console.log(entity); this.loadingSubject.next(true); return this.httpClient.put(this.baseUrl + "/" + this.entityPath + "/" + id, entity).pipe(operators.catchError(this.handleError), operators.finalize((/** * @return {?} */ function () { return _this.loadingSubject.next(false); }))); }; /** * @protected * @param {?} error * @return {?} */ EntityService.prototype.handleError = /** * @protected * @param {?} error * @return {?} */ function (error) { // in a real world app, we may send the server to some remote logging infrastructure // instead of just logging it to the console /** @type {?} */ var errorMessage; if (typeof error === 'string') { errorMessage = error; } else { if (error.error instanceof ErrorEvent) { // A client-side or network error occurred. Handle it accordingly. errorMessage = "An error occurred: " + error.error.message; } else { // The backend returned an unsuccessful response code. // The response body may contain clues as to what went wrong, errorMessage = "Backend returned code " + error.status + ", with body " + error.message; } } console.error(error); // return an ErrorObservable with a user-facing error message return rxjs.throwError(errorMessage); }; /** * @protected * @param {?} body * @return {?} */ EntityService.prototype.convertToJson = /** * @protected * @param {?} body * @return {?} */ function (body) { return body; }; /** @nocollapse */ EntityService.ctorParameters = function () { return [ { type: http.HttpClient }, { type: undefined, decorators: [{ type: core.Inject, args: ['environment',] }] } ]; }; return EntityService; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @abstract */ var /** * @abstract */ Entity = /** @class */ (function () { function Entity(init) { Object.assign(this, init); } return Entity; }()); /** * @template T */ var /** * @template T */ EntityColumnDef = /** @class */ (function () { function EntityColumnDef(init) { var _this = this; this.header = this.property; this.visible = true; this.displayFn = (/** * @param {?} entity * @return {?} */ function (entity) { return entity[_this.property]; }); Object.assign(this, init); } return EntityColumnDef; }()); exports.Entity = Entity; exports.EntityColumnDef = EntityColumnDef; exports.EntityFormComponent = EntityFormComponent; exports.EntityService = EntityService; exports.SFGSharedMaterialModule = SFGSharedMaterialModule; exports.SharedFlexLayoutModule = SharedFlexLayoutModule; exports.SharedMaterialDateModule = SharedMaterialDateModule; exports.SharedModule = SharedModule; Object.defineProperty(exports, '__esModule', { value: true }); })); //# sourceMappingURL=vibe-sharedui.umd.js.map