UNPKG

8.65 kBJavaScriptView Raw
1!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/http"),require("rxjs/Rx"),require("rxjs/Subject"),require("angular-2-local-storage")):"function"==typeof define&&define.amd?define("easy-core",["exports","@angular/core","@angular/http","rxjs/Rx","rxjs/Subject","angular-2-local-storage"],e):e(t["easy-core"]={},t.ng.core,t.ng.http,t.Rx,t.Rx,t.angular2LocalStorage)}(this,function(t,e,r,n,o,i){"use strict";var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};function s(t,e){function r(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var c=function(t,e){this.key=t,this.value=e},u=function(){function t(t){this.http=t,this.paths=[],this.config=[],this.env=null,this.subject=new n.Subject,this.initialized=this.subject.asObservable()}return t.prototype.getPresentationConfigs=function(){return this.config.filter(function(t){return t.key.toLowerCase().endsWith("config")})},t.prototype.get=function(e){var t=this.config.filter(function(t){return t.key.toLowerCase()==e.toLowerCase()});return 0<t.length?t[0].value:null},t.prototype.getEnv=function(t){return this.env[t]},t.prototype.addNavigationItems=function(t,e){var r,n,o=function(e){0==i.paths.filter(function(t){return t.value.name==e.name}).length&&i.paths.push(new c(t,{name:e.name,route:e.route}))},i=this;try{for(var a=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}(e),s=a.next();!s.done;s=a.next()){o(s.value)}}catch(u){r={error:u}}finally{try{s&&!s.done&&(n=a["return"])&&n.call(a)}finally{if(r)throw r.error}}},t.prototype.fetchNavigationItems=function(e){return this.paths.filter(function(t){return t.key===e}).map(function(t){return new c(t.value.name,t.value.route)})},t.prototype.initialize=function(t,e){this.config=this.config.concat(t),this.env=e,this.subject.next(!0)},t}();u.decorators=[{type:e.Injectable}],u.ctorParameters=function(){return[{type:r.Http}]};var p=new r.Headers;p.append("Accept","application/json"),p.append("Content-Type","application/json");var l=function(){function t(){this.loaderSubject=new o.Subject,this.loaderState=this.loaderSubject.asObservable()}return t.prototype.show=function(){this.loaderSubject.next({show:!0})},t.prototype.hide=function(){this.loaderSubject.next({show:!1})},t}();l.decorators=[{type:e.Injectable}],l.ctorParameters=function(){return[]};var h=function(){function t(t){this.loaderService=t,this.show=!1}return t.prototype.ngOnInit=function(){var e=this;this.subscription=this.loaderService.loaderState.subscribe(function(t){e.show=t.show})},t.prototype.ngOnDestroy=function(){this.subscription.unsubscribe()},t}();h.decorators=[{type:e.Component,args:[{selector:"angular-loader",template:'<div [class.loader-hidden]="!show">\n <div class="loader-overlay">\n <div>\n <mat-progress-bar color="warn" mode="indeterminate" *ngIf="show"></mat-progress-bar>\n </div>\n </div>\n </div>',styles:[".loader-hidden {\n visibility: hidden;\n }\n .loader-overlay {\n position: absolute;\n width:100%;\n top:0;\n left: 0;\n opacity: 1;\n z-index: 9999999999;\n }"]}]}],h.ctorParameters=function(){return[{type:l}]};var f=function(){function t(){this.subject=new o.Subject,this.OnError=this.subject.asObservable()}return t.prototype.error=function(t){this.subject.next(t)},t}();f.decorators=[{type:e.Injectable}];var y=function(a){function t(t,e,r,n,o){var i=a.call(this,t,e)||this;return i.localStorageService=r,i.loaderService=n,i.httpIntegrationService=o,i}return s(t,a),t.prototype.get=function(t,e){var r=this;return this.showLoader(),a.prototype.get.call(this,t,this.getRequestOptionArgs(e))["do"](function(t){r.onSuccess(t)},function(t){r.onError(t)})["finally"](function(){r.onEnd()})},t.prototype.post=function(t,e,r){var n=this;return this.showLoader(),a.prototype.post.call(this,t,e,this.getRequestOptionArgs(r))["do"](function(t){n.onSuccess(t)},function(t){n.onError(t)})["finally"](function(){n.onEnd()})},t.prototype.put=function(t,e,r){var n=this;return this.showLoader(),a.prototype.put.call(this,t,e,this.getRequestOptionArgs(r))["do"](function(t){n.onSuccess(t)},function(t){n.onError(t)})["finally"](function(){n.onEnd()})},t.prototype["delete"]=function(t,e){var r=this;return this.showLoader(),a.prototype["delete"].call(this,t,this.getRequestOptionArgs(e))["do"](function(t){r.onSuccess(t)},function(t){r.onError(t)})["finally"](function(){r.onEnd()})},t.prototype.getRequestOptionArgs=function(t){return null==t&&(t=new r.RequestOptions),null==t.headers&&(t.headers=new r.Headers),t.withCredentials||this.createAuthorizationHeader(t.headers),t},t.prototype.createAuthorizationHeader=function(t){null!=this.localStorageService.get("id_token")&&t.append("Authorization",this.localStorageService.get("id_token"))},t.prototype.onSuccess=function(t){console.log("Request successful")},t.prototype.onError=function(t){console.log("Error, status code: "+t.status),this.httpIntegrationService.error(t)},t.prototype.onEnd=function(){this.hideLoader()},t.prototype.showLoader=function(){this.loaderService.show()},t.prototype.hideLoader=function(){this.loaderService.hide()},t}(r.Http);y.decorators=[{type:e.Injectable}],y.ctorParameters=function(){return[{type:r.ConnectionBackend},{type:r.RequestOptions},{type:i.LocalStorageService},{type:l},{type:f}]},Array.prototype.add||(Array.prototype.add=function(t){this.push(t)}),Array.prototype.addRange||(Array.prototype.addRange=function(t){var e=this;t.forEach(function(t){return e.push(t)})}),Array.prototype.remove||(Array.prototype.remove=function(t){var e=this.indexOf(t);return this.splice(e,0),-1!=e}),Array.prototype.where||(Array.prototype.where=function(t){return this.filter(t)}),Array.prototype.orderBy||(Array.prototype.orderBy=function(r){for(var t=Array(),e=function(t,e){return r(t)>r(e)?1:r(e)>r(t)?-1:0},n=0;n<this.length;n++)return this.sort(e);return t}),Array.prototype.orderByDescending||(Array.prototype.orderByDescending=function(r){for(var t=Array(),e=function(t,e){return r(t)>r(e)?-1:r(e)>r(t)?1:0},n=0;n<this.length;n++)return this.sort(e);return t}),Array.prototype.single||(Array.prototype.single=function(t){void 0===t&&(t=null);var e=this;if(null!=t&&(e=this.filter(t)),1<e.length)throw new g;if(0==e.length)throw new d;return e[0]}),Array.prototype.singleOrDefault||(Array.prototype.singleOrDefault=function(t){void 0===t&&(t=null);var e=this;if(null!=t&&(e=this.filter(t)),1<e.length)throw new g;return 0==e.length?null:e[0]}),Array.prototype.first||(Array.prototype.first=function(t){void 0===t&&(t=null);var e=this;if(null!=t&&(e=this.filter(t)),e.any())return e[0];throw new d}),Array.prototype.firstOrDefault||(Array.prototype.firstOrDefault=function(t){void 0===t&&(t=null);var e=this;return null!=t&&(e=this.filter(t)),0<e.length?e[0]:null}),Array.prototype.last||(Array.prototype.last=function(t){void 0===t&&(t=null);var e=this.reverse();if(null!=t&&(e=this.filter(t)),1<(e=this.filter(t)).length)return e[0];throw new d}),Array.prototype.lastOrDefault||(Array.prototype.lastOrDefault=function(t){void 0===t&&(t=null);var e=this.reverse();return null!=t&&(e=this.filter(t)),0<e.length?e[0]:null}),Array.prototype.any||(Array.prototype.any=function(t){void 0===t&&(t=null);var e=this;return null!=t&&(e=this.filter(t)),0<e.length}),Array.prototype.all||(Array.prototype.all=function(t){return this.filter(t).length==this.length});var d=function(e){function r(){var t=e.call(this)||this;return Object.setPrototypeOf(t,r.prototype),t}return s(r,e),r}(Error),g=function(e){function r(){var t=e.call(this)||this;return Object.setPrototypeOf(t,r.prototype),t}return s(r,e),r}(Error),v=function(){};String.prototype.fromCamelCase||(String.prototype.fromCamelCase=function(){return this.replace(/([a-z](?=[A-Z]))/g,"$1 ")});var w=function(){},b=function(){};b.decorators=[{type:e.NgModule,args:[{imports:[u,r.HttpModule],declarations:[],providers:[u],exports:[h]}]}],t.CoreModule=b,t.LoaderComponent=h,t.httpFactory=function(t,e,r,n,o){return new y(t,e,r,n,o)},t.AppConfig=u,t.Setting=c,t.contentHeaders=p,t.LoaderService=l,t.HttpIntegrationService=f,t.InterceptedHttp=y,t.ArrayExtensions=v,t.StringExtensions=w,Object.defineProperty(t,"__esModule",{value:!0})});
2//# sourceMappingURL=easy-core.umd.min.js.map