UNPKG

graphdb-workbench

Version:
2 lines 13.1 kB
export const __webpack_id__=20227;export const __webpack_ids__=[20227,61105];export const __webpack_modules__={20227:(n,e,t)=>{t.r(e),t(98977),t(61105);const o=t(304).LoggerProvider.logger;function r(n){const e=[];return Object.keys(n).forEach(function(t){e.push(encodeURIComponent(t)+"="+encodeURIComponent(n[t]))}),e.join("&")}function i(n){return _.map(n,function(n,e){return{key:e,value:n}})}function a(n,e){return _.reduce(n,function(n,t){if(""===t.key&&""===t.value);else{if(""===t.key)throw new Error(e.instant("externalsync.empty.value.key.error",{value:t.value}));if(n.hasOwnProperty(t.key))throw new Error(e.instant("externalsync.duplicate.key.error",{key:t.key}));n[t.key]=t.value}return n},{})}function c(n,e){for(let t=0;t<e.length;t++){const o=e[t];if("StringArray"===o.__type)n[o.__name]||(n[o.__name]=[""]);else if("OptionArray"===o.__type)if(n[o.__name])for(let e=0;e<o.__childOptions.length;e++){const t=o.__childOptions[e];if("Boolean"===t.__type)for(let e=0;e<n[o.__name].length;e++){const r=n[o.__name][e];!r.hasOwnProperty([t.__name])&&angular.isDefined(t.__defaultValue)&&(r[t.__name]=t.__defaultValue)}}else{n[o.__name]=[];const e={};for(let n=0;n<o.__childOptions.length;n++){const t=o.__childOptions[n];"StringArray"===t.__type?e[t.__name]=[""]:e[t.__name]=angular.isUndefined(t.__defaultValue)?"":t.__defaultValue}n[o.__name].push(e)}else"Map"===o.__type?n[o.__name]?n[o.__name]=i(n[o.__name]):n[o.__name]=[]:"JsonString"===o.__type?!n[o.__name]||n[o.__name]instanceof String||"string"==typeof n[o.__name]||(n[o.__name]=angular.toJson(n[o.__name],2)):angular.isUndefined(n[o.__name])&&(n[o.__name]=angular.isUndefined(o.__defaultValue)?"":o.__defaultValue)}return n}function s(n,e,t){return n.post("repositories/"+e,r({query:t}),{headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/sparql-results+json","X-GraphDB-Local-Consistency":"updating"}})}function l(n){return n.substring(0,n.length-1)+"/instance#"}function u(n,e,t,o,r){const i=function n(e,t){const o={};return _.each(t,function(t){angular.isDefined(e[t.__name])&&("OptionArray"===t.__type?(o[t.__name]=[],_.each(e[t.__name],function(e){o[t.__name].push(n(e,t.__childOptions))})):o[t.__name]=_.cloneDeep(e[t.__name]))}),o}(t,o);for(let n=0;n<o.length;n++)try{"Map"===o[n].__type?i[o[n].__name]=a(i[o[n].__name],$translate):"JsonString"===o[n].__type&&(i[o[n].__name]=angular.fromJson(i[o[n].__name]))}catch(e){return r(o[n].__label,e.message),null}p(i);let c="";return c+="PREFIX :<"+e+">\n",c+="PREFIX inst:<"+l(e)+">\n",c+="INSERT DATA {\n",c+="\tinst:"+n+" :createConnector '''\n",c+=angular.toJson(i,2),c+="\n''' .\n}\n",c=c.replace(/\\/g,"\\\\\\"),c}function p(n){return Array.isArray(n)&&(n=_.filter(n,function(n){return null!==n&&(!n.trim||""!==n.trim())})),Object.keys(n).forEach(function(e){""!==n[e]&&null!==n[e]&&void 0!==n[e]||!1===n[e]?"object"==typeof n[e]&&(n[e]=p(n[e])):delete n[e]}),n}function f(n,e,t,i,a,p,f,g,d,m){function y(e){n.beingBuiltConnector={percentDone:0,status:{processedEntities:0,estimatedEntities:0,indexedEntities:0,entitiesPerSecond:0},actionName:e?m.instant("externalsync.repairing"):m.instant("externalsync.creating"),waitOnRepairStartOnce:!!e,eta:"-",inline:!1,iri:null}}function C(e,t,o){return y(o),$.extend(n.beingBuiltConnector,{iri:l(e)+t,name:t,inline:!1,doneCallback:function(){n.beingBuiltConnector.modalInstance.dismiss("cancel")}}),n.beingBuiltConnector.modalInstance=i.open({templateUrl:"pages/connectorProgress.html",controller:"CreateProgressCtrl",size:"lg",backdrop:"static",scope:n}),n.beingBuiltConnector.modalInstance}function h(e,o,i){const c=C(e.value,o.name,!1);g.addStatements(t.getActiveRepository(),r({update:o.query})).then(function(){d.getConnectors().then(function(){d.hasConnector(encodeURIComponent(e.value)).then(function(t){n.existing[e.key]=t.data})}),a.success(m.instant("created.connector",{name:o.name}))},function(n){a.error(getError(n)),i()}).finally(function(){c.dismiss("cancel")})}n.loader=!1,n.controllers=[],n.existing={},n.definitions={},n.getLoaderMessage=function(){const e=(Date.now()-n.loaderStartTime)/1e3,t=n.getHumanReadableSeconds(e);let o="";return o=n.progressMessage?n.progressMessage+"... "+t:m.instant("common.running.operation",{timeHuman:t}),n.extraMessage&&e>10&&(o+="\n"+n.extraMessage),o},n.setLoader=function(e,t,o){e?(n.loader=!0,n.loaderStartTime=Date.now(),n.progressMessage=t,n.extraMessage=o):(n.loader=!1,n.progressMessage="",n.extraMessage="")},n.initConnector=function(e){return d.initConnector(encodeURIComponent(e.value)).then(function(t){return n.definitions[e.key]=t.data,d.hasConnector(encodeURIComponent(e.value)).then(function(t){n.existing[e.key]=t.data})})},n.getConnectors=function(){n.isLicenseValid()&&n.canWriteActiveRepo()&&(n.setLoader(!0,m.instant("externalsync.fetching.connectors"),m.instant("common.extra.message")),d.getConnectors().then(function(r){n.connectors=Object.keys(r.data).map(function(n){return{key:n,value:r.data[n]}}),f.all(_.map(n.connectors,function(e){return n.initConnector(e)})).finally(function(){y();const r=function(n){const e=_.map(n,function(n){return"<"+n.value+"connectorStatus>"}).join("|");return e?"SELECT ?connector ?status { ?connector "+e+" ?status }":null}(n.connectors);r?function(n){return s(e,t.getActiveRepository(),n)}(r).then(function(e){const t=function(n){if(n.bindings)for(let e=0;e<n.bindings.length;e++)try{const t=JSON.parse(n.bindings[e].status.value);if("BUILDING"===t.status)return{connector:n.bindings[e].connector.value,status:t}}catch(n){o.error(n)}return{}}(e.data.results);if(t.connector){const e=t.connector.split(/#/);e[0]=e[0].replace(/\/instance$/,"#"),r=e[0],i=e[1],y(),$.extend(n.beingBuiltConnector,{iri:l(r)+i,name:i,inline:!0,doneCallback:function(){n.beingBuiltConnector.inline=!1}})}var r,i}).finally(function(){n.setLoader(!1)}):n.setLoader(!1)})}).catch(function(e){n.setLoader(!1),a.error(getError(e),m.instant("externalsync.could.not.get.connectors.error"))}),n.existing={})},n.getOptions=function(e){return n.definitions[e.key]},n.isEmpty=function(n){return angular.isObject(n)&&0===Object.keys(n).length},n.toPrettyJson=function(n){return angular.toJson(n,2)},n.$watch(function(){return t.getActiveRepository()},n.getConnectors),n.$watch(function(){return t.getActiveLocation()},n.getConnectors),n.copyConnector=function(e,t){let o;angular.isUndefined(t)||(o=_.cloneDeep(t),o.name=o.name+"-copy"),i.open({templateUrl:"pages/createConnector.html",controller:"CreateConnectorCtrl",size:"lg",backdrop:"static",resolve:{connector:function(){return e},values:function(){return angular.isUndefined(o)?{name:"",values:{}}:o},options:function(){return n.getOptions(e)}}}).result.then(function(t){h(e,t,function(){t.skipConversion=!0,n.newConnector(e,t)})})},n.newConnector=function(e,t){i.open({templateUrl:"pages/createConnector.html",controller:"CreateConnectorCtrl",size:"lg",backdrop:"static",resolve:{connector:function(){return e},values:function(){return angular.isUndefined(t)?{name:"",values:{}}:t},options:function(){return n.getOptions(e)}}}).result.then(function(t){h(e,t,function(){t.skipConversion=!0,n.newConnector(e,t)})})},n.repair=function(e,o){p.openSimpleModal({title:m.instant("externalsync.confirm.repair"),message:m.instant("externalsync.repair.warning.msg"),warning:!0}).result.then(function(){const i=C(o.value,e.name,!0),c=(s=e.name,"PREFIX prefix:<"+(u=o.value)+">\nINSERT DATA {\n\t<"+l(u)+s+'> prefix:repairConnector ""\n}');var s,u;g.addStatements(t.getActiveRepository(),r({update:c})).then(function(){d.getConnectors().then(function(){d.hasConnector(encodeURIComponent(o.value)).then(function(e){n.existing[o.key]=e.data})}),a.success(m.instant("externalsync.repair.success.msg",{name:e.name}))},function(n){a.error(getError(n))}).finally(function(){i.dismiss("cancel")})})},n.delete=function(e,o){const c=o.key.indexOf("Elastic")>=0||o.key.indexOf("Solr")>=0;i.open({templateUrl:"js/angular/externalsync/templates/deleteConnector.html",controller:"DeleteConnectorCtrl",resolve:{popoverMsg:function(){return c?m.instant("delete.connector.conditional",{type:o.key}):""}}}).result.then(function(i){n.setLoader(!0,m.instant("externalsync.delete.progress.msg",{name:e.name}),m.instant("externalsync.extra.message.warning"));const s=function(n,e,t){const o=e.substring(0,e.length-1)+"/instance#";return"PREFIX prefix:<"+e+">\nINSERT DATA {\n\t<"+o+n+'> prefix:dropConnector "'+(t?"force":"")+'"\n}'}(e.name,o.value,i);g.addStatements(t.getActiveRepository(),r({update:s})).then(function(){d.getConnectors().then(function(){d.hasConnector(encodeURIComponent(o.value)).then(function(e){n.existing[o.key]=e.data})}),i?(a.success(m.instant("externalsync.delete.force.success.msg",{name:e.name})),c&&a.warning(m.instant("externalsync.delete.remote.warning",{key:o.key}))):a.success(m.instant("externalsync.delete.success.msg",{name:e.name}))},function(n){a.error(getError(n))}).finally(function(){n.setLoader(!1)})})},n.viewQuery=function(e,t){i.open({templateUrl:"pages/viewQuery.html",controller:"ViewQueryCtrl",resolve:{query:function(){const o=n.getOptions(e);return u(t.name,e.value,c(t.values,o),o)}}})}}function g(n,e,t){n.force=!1,n.popoverMsg=t,n.ok=function(){e.close(n.force)},n.cancel=function(){e.dismiss()}}function d(n,e,t,o,r){function i(){return u(n.name,t.value,n.values,n.options,function(n,e){r.error(e,n)})}n.connector=t,n.addField=function(e,t){const o=_.cloneDeep(n.defaultValues[t][0]);n.values[t].splice(e+1,0,o)},n.addOption=function(n,e){e.splice(n+1,0,"")},n.deleteOption=function(n,e){e.splice(n,1)},n.addMapOption=function(n,e){e.splice(n+1,0,{key:"",value:""})},n.deleteMapOption=function(n,e){e.splice(n,1)},n.ok=function(){if(n.form.$valid){const t=i();t&&e.close({name:n.name,values:n.values,options:n.options,query:t})}},n.viewQuery=function(){const n=i();n&&o.open({templateUrl:"pages/viewQuery.html",controller:"ViewQueryCtrl",resolve:{query:function(){return n}}})},n.cancel=function(){e.dismiss("cancel")}}function m(n,e,t,o,r,i,a,s){angular.extend(this,e("ExtendNewConnectorCtrl",{$scope:n,$uibModalInstance:o,connector:r,$uibModal:i})),n.values=a.values,n.options=s,n.name=a.name,a.skipConversion||(n.values=c(n.values,n.options)),n.defaultValues=_.cloneDeep(n.values)}function y(n,e,t,r,i){function a(){const a=function(n){const e=n.replace(/\/instance#.+$/,"#connectorStatus");let t="";return t+="SELECT ?status {\n",t+="\t<"+n+"> <"+e+"> ?status",t+="\n}",t}(n.beingBuiltConnector.iri);n.beingBuiltConnector.iri=null,n.progressInterval=e(function(){(function(n){return s(t,r.getActiveRepository(),n)})(a).then(function(t){const r=function(n){if(n.bindings&&n.bindings.length>0)try{return JSON.parse(n.bindings[0].status.value)}catch(n){o.error(n)}return{}}(t.data.results);"BUILDING"===r.status?(n.beingBuiltConnector.status=r,n.beingBuiltConnector.percentDone=(100*r.processedEntities/r.estimatedEntities).toFixed(0),n.beingBuiltConnector.eta=n.getHumanReadableSeconds(r.etaSeconds),n.beingBuiltConnector.actionName=r.repair?i.instant("externalsync.repairing"):i.instant("externalsync.creating"),n.beingBuiltConnector.waitOnRepairStartOnce=!1):"BUILT"!==r.status||n.beingBuiltConnector.waitOnRepairStartOnce||(e.cancel(n.progressInterval),n.beingBuiltConnector.doneCallback&&n.beingBuiltConnector.doneCallback())})},1e3),n.$on("$destroy",function(){e.cancel(n.progressInterval)})}n.beingBuiltConnector=n.beingBuiltConnector||{},!n.beingBuiltConnector.inline&&n.beingBuiltConnector.iri&&a(),n.$watch("beingBuiltConnector.iri",function(e){n.beingBuiltConnector.inline&&e&&a()})}angular.module("graphdb.framework.externalsync.controllers",["graphdb.framework.rest.rdf4j.repositories.service","graphdb.framework.rest.connectors.service"]).controller("ConnectorsCtrl",f).controller("ExtendNewConnectorCtrl",d).controller("CreateConnectorCtrl",m).controller("CreateProgressCtrl",y).controller("DeleteConnectorCtrl",g).filter("ceil",function(){return function(n){return Math.ceil(n)}}),f.$inject=["$scope","$http","$repositories","$uibModal","toastr","ModalService","$q","RDF4JRepositoriesRestService","ConnectorsRestService","$translate"],g.$inject=["$scope","$uibModalInstance","popoverMsg"],d.$inject=["$scope","$uibModalInstance","connector","$uibModal","toastr"],m.$inject=["$scope","$controller","$http","$uibModalInstance","connector","$uibModal","values","options"],y.$inject=["$scope","$interval","$http","$repositories","$translate"]},61105:()=>{angular.module("graphdb.framework.rest.connectors.service",[]).factory("ConnectorsRestService",e),e.$inject=["$http"];const n="rest/connectors";function e(e){return{getConnectors:function(t,o){return t?e.get(n,{headers:{"X-GraphDB-Repository":t,"X-GraphDB-Repository-Location":o}}):e.get(n)},initConnector:function(t){return e.get(`${n}/options?prefix=${t}`)},hasConnector:function(t,o,r){return o?e.get(`${n}/existing?prefix=${t}`,{headers:{"X-GraphDB-Repository":o,"X-GraphDB-Repository-Location":r}}):e.get(`${n}/existing?prefix=${t}`)},checkConnector:function(t){return e.post(`${n}/check`,t,{headers:{"Content-Type":"text/plain"}})}}}}}; //# sourceMappingURL=20227.a9333aa1320edea7264b.bundle.js.map