/**
* IBM Confidential OCO Source Materials IBM Business Platform: Content Apps
* (C) Copyright IBM Corp. 2016, 2018
*
* The source code for this program is not published or otherwise divested of
* its trade secrets, irrespective of what has been deposited with the U.S.
* Copyright Office
*/
define("bi/content_apps/CapabilitiesView",["jquery","underscore","bi/glass/app/ContentView","bi/content_apps/nls/StringResource","bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl","bacontentnav/utils/GlassContextHelper"],function(e,a,t,o,n,i){"use strict";var s=t.extend({init:function(e){s.inherited("init",this,arguments),a.extend(this,e)},render:function(){return this._containerElement=e("
",{class:"propertyUIControl capabilitiesView"}),this.$el.append(this._containerElement),this._getCapabilityInformation().then(function(e){var t=[],n=[];this._translateUserCapabilityNames(e,t,n);var i=this._createHierarchicalList(t,n);return this._oPropertyUIControl=this._getPropertyUIControl({el:this.$el,glassContext:this.glassContext,items:[{type:"Banner",name:"detailsBanner",value:o.get("preferencesMyCapabilities"),centerLabel:!0,hintText:o.get("preferencesCapabilitiesHintText"),backButton:!0,editable:!1,readOnly:!0,onClose:function(){this.slideout.hide()}.bind(this)},{type:"HierarchicalList",name:"capabilities",data:a.sortBy(i,"defaultName")}]}),this._oPropertyUIControl.render()}.bind(this),function(){return this.slideout.hide(),Promise.reject()}.bind(this))},_getPropertyUIControl:function(e){return new n(e)},_getCapabilityInformation:function(){return this.glassContext.services.ajax.ajax({dataType:"json",type:"GET",url:"v1/capabilities"}).then(function(e){return e.data?e.data:Promise.reject()}.bind(this),this._handleError.bind(this))},_createHierarchicalList:function(e,t){for(var n=[],i=0;i
");return $(e).append(t),t.append(this.$contentBars),this.renderContentList({el:t,columns:this._getColumnSpecification(),$container:this.$el,url:this.url||this._getDefaultRequestURL(),dataManipulationCallback:function(e){e&&e.data&&(e.data=l.filter(e.data,function(e){return l.contains(e.permissions,"traverse")}))}}).then(function(){this.getListControl().setIsAccountPickerSlideout(),this.setFocus()}.bind(this))},_onCancelClick:function(){this.slideout.hide()},_onAddClick:function(){var e=this.getListControl().getSelectedObjects();"function"==typeof this.addCallback&&this.addCallback(e),this.setFocus()},_renderPostListControls:function(){var e=this.$el.find(".l_findUser2");e.attr("tabindex","0"),this._createDropDown(e),this.getListControl().getDatatable().fnGetData().forEach(function(e){"namespace"===e.type&&(this.namespaceMap[e.defaultName.toLowerCase()]=e.id)}.bind(this))},_getDefaultRequestURL:function(){return t.getBaseNamespaceURL()},_getDefaultSelfURL:function(){return t.getBaseNamespaceURL()},_getModuleName:function(){return"bi/content_apps/AccountPickerSlideoutView"},contentbarItems:function(){var e="ACCOUNTPICKER_FILTER_",t=window.localStorage.getItem("filterString_"+this.stateId);return[{name:"nameLabel",position:"leading",style:"nameLabel",module:"bacontentnav/common/ui/contentbar_components/HiddenLabel",label:n.get("policiesTableLable")},{name:e+"typeMenu",label:n.get("type"),labelOnly:!0,hcLabel:!1,position:"trailing",supportCustomCollapse:!0,showTitle:!1,updateLabel:!0,icon:"common-filter",bSVG:!0,module:"bacontentnav/common/ui/contentbar_components/ToggleMenuBar",items:[{name:e+"allContent",icon:"wft_checkmark",label:n.get("allGenericItems"),checked:""===t,action:function(){this._filter("")}.bind(this)},{name:e+"accounts",icon:"wft_checkmark",label:n.get("policyFilterAccounts"),checked:"account"===t,action:function(){this._filter("account")}.bind(this)},{name:e+"groups",icon:"wft_checkmark",label:n.get("policyFilterGroups"),checked:"group"===t,action:function(){this._filter("group")}.bind(this)},{name:e+"roles",icon:"wft_checkmark",label:n.get("policyFilterRoles"),checked:"role"===t,action:function(){this._filter("role")}.bind(this)}]}]},getListControlOptions:function(){return{ajaxProp:"data",emptyFolderString:n.get("emptyPolicyList"),showEmptyNewFolderButton:!1,rightClickContextMenu:!1}},getDefaultSort:function(){return[1,"asc"]},_handleSearchMenuButtonDown:function(e){return e.keyCode!==r.SPACE&&e.keyCode!==r.ENTER&&e.keyCode!==r.DOWN_ARROW||!$(e.currentTarget).click||($(e.currentTarget).click(),e.stopPropagation(),!1)},_getColumnSpecification:function(){return[{type:"Icon"},{type:"Name",navigateOnly:!0},{type:"Time",propertyName:"modificationTime"}]},_adjustWidth:function(){this.$el.addClass("pageview-small")},_navigate:function(e){c.inherited("navigate",this,arguments),this.setFocus()}});return c}),define("bi/content_apps/CredentialsView",["bacontentnav/common/ContentListPageView","bi/content_apps/common/ui/permissions/Policy","bi/content_apps/nls/StringResource","bacontentnav/utils/ContentStoreObject","bi/commons/ui/Slideout","bacontentnav/utils/GlassContextHelper","bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl","bi/content_apps/AccountPickerSlideoutView","underscore"],function(e,d,s,t,n,i,o,a,r){"use strict";var l=e.extend({init:function(e){l.inherited("init",this,arguments),r.extend(this,e),this.contentListFacets={accounts:"account",groups:"group",roles:"role"}},renderContent:function(){this.$el.addClass("policies"),this.$contentBars=this.$el.children().detach();var e=[{module:"bi/content_apps/ui/RenderCallback",renderCallback:this._renderListControl.bind(this)},{type:"Banner",name:"credentialsBanner",value:s.get("preferencesMyCredentials"),centerLabel:!0,hintText:s.get("preferencesCredentialsHintText"),backButton:!0,editable:!1,readOnly:!0,onClose:this._onClose.bind(this)},{type:"Footer",items:[{type:"Button",label:s.get("applyLabel"),onSelect:this._onApplyClick.bind(this),primary:!0},{type:"Button",label:s.get("cancel"),onSelect:this._onCancelClick.bind(this),primary:!1}]}];return this._oPropertyUIControl=this._getPropertyUIControl({el:this.$el,glassContext:this.glassContext,items:e}),this._oPropertyUIControl.render()},_getPropertyUIControl:function(e){return new o(e)},_renderListControl:function(e){var t=$("");return $(e).append(t),t.append(this.$contentBars),this.renderContentList({el:t,columns:this._getColumnSpecification(),$container:this.$el,getJSONDataCallback:this._getCredentialData.bind(this)}).then(function(){this.getListControl().setIsAccountPickerSlideout()}.bind(this))},_getCredentialData:function(){return this._getUserCredentials().then(function(){return this._getPolicies(this.credentialId).then(function(){return{data:this.policyArray.data[0].policies}}.bind(this))}.bind(this)).catch(function(e){return this.slideout.hide(),Promise.reject(e)}.bind(this))},_getUserCredentials:function(){return this._sendRequest({dataType:"json",type:"GET",url:"v1/users/~/credentials"},function(e){if(!e.data||!e.data.id)return Promise.reject(new Error);this.credentialId=e.data.id}.bind(this))},_getPolicies:function(e){return this._sendRequest({dataType:"json",type:"GET",url:"v1/objects/"+e+"?fields=policies{defaultName,id,searchPath}"},function(e){return e.data&&e.data.data[0].policies?(this.policyArray=e.data,this.policyArray):Promise.reject(new Error)}.bind(this))},_onApplyClick:function(){var e={};e.policies=this.policyArray.data[0].policies,e.type="credential";var t=JSON.stringify(e),n={headers:{Accept:"application/json","Content-Type":"application/json"},type:"PUT",url:"v1/objects/"+this.credentialId,data:t};return this._sendRequest(n,function(){})},_onCancelClick:function(){this.slideout.hide()},_sendRequest:function(e,t){return this.glassContext.getCoreSvc(".Ajax").ajax(e).then(t.bind(this)).catch(function(e){return e.message&&this.glassContext.appController.showErrorMessage(e.message,"Error"),Promise.reject(e)}.bind(this))},_getDefaultRequestURL:function(){return this.itemURL},_getModuleName:function(){return"bi/content_apps/CredentialsView"},getDefaultSort:function(){return[1,"asc"]},setFocus:function(){var e=this.$el.find(":tabbable");0
");this.slideout.$el.append(t);var n=this._getSlideout({glassContext:this.glassContext,position:this.position||"right",el:t,overlay:!0,width:this.slideout.$el.width(),enableTabLooping:!0,content:{module:a,showBreadcrumbs:!0,navigateOnRowSelect:!0,addCallback:function(e){this.addSelection(e)}.bind(this),objectInformation:e,glassContext:this.glassContext}});n.render().then(function(){n.show()})},_getSlideout:function(e){return new n(e)},contentbarItems:function(){var e=window.localStorage.getItem("filterString_"+this.stateId);return[{name:"nameLabel",position:"leading",label:s.get("preferencesCredentialsLabel"),style:"nameLabel",module:"bacontentnav/common/ui/contentbar_components/HiddenLabel"},{name:"typeMenu",label:s.get("type"),labelOnly:!0,hcLabel:!1,position:"trailing",supportCustomCollapse:!0,showTitle:!1,updateLabel:!0,icon:"common-filter",bSVG:!0,module:"bacontentnav/common/ui/contentbar_components/ToggleMenuBar",items:[{name:"allContent",icon:"wft_checkmark",label:s.get("allGenericItems"),checked:"allContent"===e,action:function(){this._filter("allContent")}.bind(this)},{name:"accounts",icon:"wft_checkmark",label:s.get("policyFilterAccounts"),checked:"accounts"===e,action:function(){this._filter("accounts")}.bind(this)},{name:"groups",icon:"wft_checkmark",label:s.get("policyFilterGroups"),checked:"groups"===e,action:function(){this._filter("groups")}.bind(this)},{name:"roles",icon:"wft_checkmark",label:s.get("policyFilterRoles"),checked:"roles"===e,action:function(){this._filter("roles")}.bind(this)}]},{name:"separator",type:"Separator",position:"trailing"},{name:"add",position:"trailing",displayLabel:!1,label:s.get("policesAddMemberButtonLabel"),module:"bacontentnav/common/ui/contentbar_components/Button",className:"addNewFolder",icon:"common-add",_handleClick:function(){this._openAddMembersSlideout()}.bind(this)}]},getListControlOptions:function(){return{ajaxProp:"data",emptyFolderString:s.get("emptyPolicyList"),showEmptyNewFolderButton:!0,multiSelect:!0,rightClickContextMenu:!1}},_getColumnSpecification:function(){return[{type:"Icon",getDataFn:function(e){return"nil"===e.securityObject[t.TYPE]?s.get("unknown"):e.securityObject[t.TYPE]}},{type:"Name",scope:"row",getDataFn:function(e){return void 0===e.securityObject[t.DEFAULT_NAME]?s.get("unavailable"):r.escape(e.securityObject[t.DEFAULT_NAME])}},{type:"ClickableIcon",name:s.get("policesRemove"),icon:"common-remove-delete",clickCallback:this.removeSelection.bind(this)}]},_adjustWidth:function(){this.$el.addClass("pageview-small")},_multiselectbarItems:function(){return Promise.resolve([{name:"removeButton",position:"leading",icon:"common-remove-delete",module:"bacontentnav/common/ui/contentbar_components/Button",className:"policyMulSel",action:this.removeSelection.bind(this)},{name:"selectedLabel",position:"leading",module:"../../lib/gemini/app/ui/toolbar_components/Label",style:"selectedLabel"},{position:"leading",type:"Separator"},{name:"cancelButton",position:"trailing",label:s.get("cancel"),text:s.get("cancel"),labelOnly:!0,module:"bacontentnav/common/ui/contentbar_components/Button",className:"cancelButton",_handleClick:function(){this.getListControl()._clearRows(),this.multiselectBar.hide(),this.contentBar.show()}.bind(this)}])},getFilterSpec:function(){return[{name:"allContent",label:s.get("allContent"),value:"allContent"},{name:"accounts",label:s.get("policyFilterAccounts"),value:"accounts"},{name:"groups",label:s.get("policyFilterGroups"),value:"groups"},{name:"roles",label:s.get("policyFilterRoles"),value:"roles"}]}});return l}),define("bi/content_apps/DataSourceCredentialsView",["q","jquery","underscore","bacontentnav/common/ContentListPageView","bi/content_apps/nls/StringResource","bacontentnav/utils/GlassContextHelper","bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl"],function(o,n,t,e,i,s,a){"use strict";var r=e.extend({init:function(e){this.itemURL=e.itemURL,r.inherited("init",this,arguments),t.extend(this,e)},renderContent:function(){this.$contentBars=this.$el.children().detach();var e=[];e.push({module:"bi/content_apps/ui/RenderCallback",renderCallback:this._renderListControl.bind(this)},{type:"Banner",name:"credentialsBanner",value:i.get("preferencesDatasourceTitle"),centerLabel:!0,hintText:i.get("preferencesDataSourceCredentialsHintText"),backButton:!0,editable:!1,readOnly:!0,onClose:this._onClose.bind(this)}),this._oPropertyUIControl=new a({el:this.$el,glassContext:this.glassContext,items:e}),this._oPropertyUIControl.render().then(function(){return this})},_renderListControl:function(e){var t=n("");return n(e).append(t),t.append(this.$contentBars),this.renderContentList({el:t,columns:this._getColumnSpecification(),$container:this.$el,url:this._getRequestURL()}).then(function(){this.setFocus()}.bind(this))},_getRequestURL:function(){return"v1/objects/"+this.glassContext.profile.account.id+"/items?types=dataSourceCredential&fields=dataSourceName,dataSourceConnectionName,defaultName"},_getDefaultRequestURL:function(){return this.itemURL},_getModuleName:function(){return"bi/content_apps/DataSourceCredentialsView"},_sendRequest:function(e,t){var n=o.defer();return t||(t=this._handleSuccess),this.glassContext.services.ajax.ajax(e).then(t.bind(this,n),this._handleError.bind(this,n)),n.promise},_handleSuccess:function(e){e.resolve()},_handleError:function(e,t,n){s.showAjaxServiceErrorMessage(this.glassContext,n),e.reject()},contentbarItems:function(){return[{name:"nameLabel",position:"leading",style:"nameLabel",label:i.get("preferencesDataSourceCredentialsLabel"),module:"bacontentnav/common/ui/contentbar_components/HiddenLabel"}]},getListControlOptions:function(){return{ajaxProp:"data",emptyFolderString:i.get("emptyPolicyList"),showEmptyNewFolderButton:!1,multiSelect:!0,rightClickContextMenu:!1}},setFocus:function(){var e=this.$el.find(":tabbable");0",{class:"propertyUIControl"}),this.$el.append(this._containerElement),this._getGroupsAndRoles().then(function(){var e=this._createHierarchicalList();this._oPropertyUIControl=new i({el:this.$el,glassContext:this.glassContext,items:[{type:"Banner",name:"GroupsAndRolesBanner",value:r.get("preferencesGroupsAndRoles"),centerLabel:!0,hintText:r.get("preferencesGroupsAndRolesHintText"),backButton:!0,editable:!1,readOnly:!0,onClose:function(){this.slideout.hide()}.bind(this)},{type:"HierarchicalList",name:"groups_and_roles",data:e}]}),this._oPropertyUIControl.render().done(t.resolve)}.bind(this),function(){this.slideout.hide()}.bind(this)),t.promise},_getGroupsAndRoles:function(){var i=e.defer();return this.glassContext.services.ajax.ajax({dataType:"json",type:"GET",url:"v1/users/~/identity"}).then(function(e){var t=[],n=[];e.data.forEach(function(e){"role"===e.type?t.push(e):"group"===e.type&&n.push(e)}.bind(this)),0