(window.webpackJsonp=window.webpackJsonp||[]).push([[56,213],{134:function(e,t,n){"use strict";n.r(t);n(65);angular.module("graphdb.framework.clustermanagement.controllers.create-cluster",[]).controller("CreateClusterCtrl",r);const o=function(){const e=document.getElementById("advancedOptions");if(e){const t=e.getAttribute("aria-expanded");if(t&&"true"===t)return"fa fa-angle-down"}return"fa fa-angle-right"};function r(e,t,n,r,s,a,c,i,u,l){e.pageTitle=a.instant("cluster_management.cluster_page.create_page_title"),e.autofocusId="autofocus",e.errors=[],e.clusterConfiguration={electionMinTimeout:8e3,electionRangeTimeout:6e3,heartbeatInterval:2e3,messageSizeKB:64,verificationTimeout:1500,transactionLogMaximumSizeGB:50,nodes:[]},e.locations=c.clusterModel.locations.filter(e=>!e.isLocal),e.selectedLocations=c.clusterModel.locations.filter(e=>e.isLocal),e.loader=!1,e.deleteLocation=function(t,n){t.preventDefault(),t.stopPropagation(),c.deleteLocation(n).then(()=>e.locations=e.locations.filter(e=>e.endpoint!==n.endpoint))},e.getAdvancedOptionsClass=o,e.createCluster=function(){return e.setLoader(!0,a.instant("cluster_management.cluster_page.creating_cluster_loader")),e.clusterConfiguration.nodes=e.selectedLocations.map(e=>e.rpcAddress),r.createCluster(e.clusterConfiguration).then(()=>{s.success(a.instant("cluster_management.cluster_page.notifications.create_success")),t.close()}).catch((function(t){!function(t,n){let o;delete e.preconditionErrors,e.errors.splice(0),412===n?e.preconditionErrors=Object.keys(t).map(e=>`${e} - ${t[e]}`):400===n?e.errors.push(...t):409===n?e.errors.push(t):(t.message||"string"==typeof t)&&(o=t.message||t);s.error(o,a.instant("cluster_management.cluster_page.notifications.create_failed"))}(t.data,t.status)})).finally(()=>{e.setLoader(!1),l.$broadcast("reloadLocations")})},e.isClusterConfigurationValid=()=>{const t=!e.clusterConfigurationForm.$invalid,n=e.selectedLocations&&e.selectedLocations.length>=2;return t&&n},e.setLoader=function(t,o){n.cancel(e.loaderTimeout),t?e.loaderTimeout=n((function(){e.loader=t,e.loaderMessage=o}),300):e.loader=!1},e.addNodeToList=function(t){t.rpcAddress&&(e.selectedLocations.push(t),e.locations=e.locations.filter(e=>e.endpoint!==t.endpoint))},e.removeNodeFromList=function(t,n){n.isLocal||(e.selectedLocations.splice(t,1),e.locations.push(n))},e.addLocation=function(){u.addLocation().then(t=>{t&&e.locations.push(t)})},e.ok=function(){e.isClusterConfigurationValid()?e.createCluster():s.warning(a.instant("cluster_management.cluster_page.notifications.form_invalid"))},e.cancel=function(){t.dismiss("cancel")}}r.$inject=["$scope","$uibModalInstance","$timeout","ClusterRestService","toastr","$translate","data","$uibModal","RemoteLocationsService","$rootScope"]},65:function(e,t){angular.module("graphdb.framework.rest.cluster.service",[]).factory("ClusterRestService",n),n.$inject=["$http"];function n(e){return{getClusterConfig:function(){return e.get("rest/cluster/config")},createCluster:function(t){return e.post("rest/cluster/config",t)},updateCluster:function(t){t.nodes&&delete t.nodes;return e.patch("rest/cluster/config",t)},deleteCluster:function(t){const n=$.param({force:t});return e.delete("rest/cluster/config?"+n)},addNodesToCluster:function(t){return e.post("rest/cluster/config/node",{nodes:t})},replaceNodesInCluster:function(t){return e.patch("rest/cluster/config/node",t)},removeNodesFromCluster:function(t){return e.delete("rest/cluster/config/node",{data:{nodes:t},headers:{"Content-Type":"application/json"}})},getClusterStatus:function(){return e.get("rest/cluster/group/status")},getNodeStatus:function(){return e.get("rest/cluster/node/status")}}}}}]);