portal-preferences
Version:
This is an angular component which enables configuration of an IBM WebSphere Portal scripting portlet by using its preferences REST service.
2 lines • 2.61 kB
JavaScript
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@angular/core"),require("rxjs"),require("@angular/forms")):"function"==typeof define&&define.amd?define("portal-preferences",["exports","@angular/core","rxjs","@angular/forms"],r):r(e["portal-preferences"]={},e.ng.core,e.rxjs,e.ng.forms)}(this,function(e,r,t,n){"use strict";var o=function(){function e(){this.preferencesLoaded=null;try{this.spInstance=__SPNS__spHelper}catch(e){}}return e.prototype.getPreferences=function(){return this.spInstance?(null==this.preferencesLoaded&&(this.preferencesLoaded=this.spInstance.getPortletPreferences()),t.from(this.preferencesLoaded)):t.throwError("portal-preferences: Not running in portal. Add your own override for local testing.")},e.prototype.setPreferences=function(e){if(this.spInstance){var r=this.spInstance.setPortletPreferences(e);return t.from(r)}return t.throwError("portal-preferences: Not running in portal. Add your own override for local testing.")},e.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[]},e.ngInjectableDef=r.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),s=function(){function e(e){this.portalPreferencesService=e,this.preferencesString="",this.logMessage=""}return e.prototype.ngOnInit=function(){var r=this;this.portalPreferencesService.getPreferences().subscribe(function(e){r.preferencesString=JSON.stringify(e,null,3)},function(e){console.log(e)})},e.prototype.savePreferences=function(){var r=this;this.logMessage="";var e={};try{e=JSON.parse(this.preferencesString)}catch(t){return this.logMessage="Failed to parse JSON. Logged to console.",void console.log(t)}this.portalPreferencesService.setPreferences(e).subscribe(function(e){r.logMessage="Portlet preferences updated."},function(e){r.logMessage="Save failed! Logged to console.",console.log(e)})},e.decorators=[{type:r.Component,args:[{selector:"lib-portlet-preferences",template:'<p>\n Configure the portlet with valid JSON:\n <br>\n <textarea cols="50" rows="10" [(ngModel)]="preferencesString"></textarea>\n <br>\n <button (click)="savePreferences()">Save</button> {{logMessage}}\n</p>\n',styles:[]}]}],e.ctorParameters=function(){return[{type:o}]},e}(),c=function(){function e(){}return e.decorators=[{type:r.NgModule,args:[{imports:[n.FormsModule],declarations:[s],exports:[s]}]}],e}();e.PortalPreferencesService=o,e.PortalPreferencesComponent=s,e.PortalPreferencesModule=c,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=portal-preferences.umd.min.js.map