graphdb-workbench 1.10.1 → 1.11.0-TR4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/10.e1e902adfd32b7c4a241.bundle.js +2 -0
  2. package/dist/10.e1e902adfd32b7c4a241.bundle.js.map +1 -0
  3. package/dist/{111.b136aca89a5c4d49c088.bundle.js → 111.056eb71072bfd8f6551b.bundle.js} +2 -2
  4. package/dist/{111.b136aca89a5c4d49c088.bundle.js.map → 111.056eb71072bfd8f6551b.bundle.js.map} +1 -1
  5. package/dist/113.2c059fa7d06fd04149eb.bundle.js +1 -1
  6. package/dist/113.2c059fa7d06fd04149eb.bundle.js.map +1 -1
  7. package/dist/{12.449fb5148a68a44ba324.bundle.js → 12.60db051e76264d3f95b2.bundle.js} +2 -2
  8. package/dist/12.60db051e76264d3f95b2.bundle.js.map +1 -0
  9. package/dist/14.610f5a8ef2eedd3fe082.bundle.js +4 -0
  10. package/dist/14.610f5a8ef2eedd3fe082.bundle.js.map +1 -0
  11. package/dist/15.97d30c0784a0224dade4.bundle.js +2 -0
  12. package/dist/15.97d30c0784a0224dade4.bundle.js.map +1 -0
  13. package/dist/16.6029d21bf28b30749fb6.bundle.js +2 -0
  14. package/dist/16.6029d21bf28b30749fb6.bundle.js.map +1 -0
  15. package/dist/{18.e045a7a0f1de6ae60c0b.bundle.js → 18.7093ec69673a80c6c263.bundle.js} +2 -2
  16. package/dist/18.7093ec69673a80c6c263.bundle.js.map +1 -0
  17. package/dist/22.93d86caa997992a46006.bundle.js +1 -1
  18. package/dist/22.93d86caa997992a46006.bundle.js.map +1 -1
  19. package/dist/26.a7b51e1e02b31ee71f94.bundle.js +2 -0
  20. package/dist/26.a7b51e1e02b31ee71f94.bundle.js.map +1 -0
  21. package/dist/27.9363b742c27da92da504.bundle.js +2 -0
  22. package/dist/27.9363b742c27da92da504.bundle.js.map +1 -0
  23. package/dist/28.9f56a33e383eeb54d985.bundle.js +2 -0
  24. package/dist/28.9f56a33e383eeb54d985.bundle.js.map +1 -0
  25. package/dist/30.5ed60b4ae0a67956c66b.bundle.js +1 -1
  26. package/dist/30.5ed60b4ae0a67956c66b.bundle.js.map +1 -1
  27. package/dist/{34.af70302b47e62d49d058.bundle.js → 34.9dab6ede2827d8976d8a.bundle.js} +2 -2
  28. package/dist/34.9dab6ede2827d8976d8a.bundle.js.map +1 -0
  29. package/dist/35.b8c8d16a8707c20a1fcb.bundle.js +2 -0
  30. package/dist/35.b8c8d16a8707c20a1fcb.bundle.js.map +1 -0
  31. package/dist/36.53cea4c4866328aef1aa.bundle.js +2 -0
  32. package/dist/36.53cea4c4866328aef1aa.bundle.js.map +1 -0
  33. package/dist/37.571a0ab8fb0508c3f1fe.bundle.js +1 -1
  34. package/dist/37.571a0ab8fb0508c3f1fe.bundle.js.map +1 -1
  35. package/dist/38.c611acd72558ca546c47.bundle.js +1 -1
  36. package/dist/38.c611acd72558ca546c47.bundle.js.map +1 -1
  37. package/dist/48.52c5b13ab244c45a8c43.bundle.js +2 -0
  38. package/dist/48.52c5b13ab244c45a8c43.bundle.js.map +1 -0
  39. package/dist/{bundle.e7b22d8ef84fbe277d35.bundle.js → bundle.5c0b5a431cb9c6b94629.bundle.js} +4 -4
  40. package/dist/bundle.5c0b5a431cb9c6b94629.bundle.js.map +1 -0
  41. package/dist/css/graphs-vizualizations.css +9 -1
  42. package/dist/index.html +3 -3
  43. package/dist/js/angular/core/directives/queryeditor/templates/query-editor.html +1 -0
  44. package/dist/js/angular/core/directives/rdfresourcesearch/templates/rdfResourceSearchTemplate.html +1 -1
  45. package/dist/pages/autocomplete.html +1 -1
  46. package/dist/pages/choose-repository-type.html +1 -1
  47. package/dist/pages/clusterInfo.html +1 -1
  48. package/dist/pages/create-index.html +4 -4
  49. package/dist/pages/dependencies.html +1 -1
  50. package/dist/pages/domainRangeInfo.html +2 -2
  51. package/dist/pages/edit.html +1 -1
  52. package/dist/pages/explore.html +1 -1
  53. package/dist/pages/export.html +1 -1
  54. package/dist/pages/find.html +1 -1
  55. package/dist/pages/graph-config/saveGraphConfig.html +29 -17
  56. package/dist/pages/graphs-visualizations.html +19 -15
  57. package/dist/pages/import.html +1 -1
  58. package/dist/pages/jdbc-create.html +5 -5
  59. package/dist/pages/monitor/queries.html +1 -1
  60. package/dist/pages/monitor/resources.html +2 -2
  61. package/dist/pages/namespaces.html +2 -2
  62. package/dist/pages/rdfClassHierarchyInfo.html +7 -7
  63. package/dist/pages/rdfrank.html +2 -2
  64. package/dist/pages/repositories.html +2 -2
  65. package/dist/pages/repository.html +2 -2
  66. package/dist/pages/similarity-indexes.html +1 -1
  67. package/dist/pages/sparql-template-create.html +5 -5
  68. package/dist/pages/sparql.html +3 -3
  69. package/dist/pages/webapi.html +2 -2
  70. package/dist/res/swagger/index.html +25 -25
  71. package/package.json +1 -1
  72. package/dist/10.a1beb5a39f13b1df6fab.bundle.js +0 -2
  73. package/dist/10.a1beb5a39f13b1df6fab.bundle.js.map +0 -1
  74. package/dist/12.449fb5148a68a44ba324.bundle.js.map +0 -1
  75. package/dist/14.c7175f400470b470e034.bundle.js +0 -4
  76. package/dist/14.c7175f400470b470e034.bundle.js.map +0 -1
  77. package/dist/15.42e5580cb96eefbb1f0b.bundle.js +0 -2
  78. package/dist/15.42e5580cb96eefbb1f0b.bundle.js.map +0 -1
  79. package/dist/16.01bd96cfd64f6b616999.bundle.js +0 -2
  80. package/dist/16.01bd96cfd64f6b616999.bundle.js.map +0 -1
  81. package/dist/18.e045a7a0f1de6ae60c0b.bundle.js.map +0 -1
  82. package/dist/26.34bd7614fd5d46aa6d89.bundle.js +0 -2
  83. package/dist/26.34bd7614fd5d46aa6d89.bundle.js.map +0 -1
  84. package/dist/27.5089831daf42bf903e6c.bundle.js +0 -2
  85. package/dist/27.5089831daf42bf903e6c.bundle.js.map +0 -1
  86. package/dist/28.bbe49746541a2419b9a7.bundle.js +0 -2
  87. package/dist/28.bbe49746541a2419b9a7.bundle.js.map +0 -1
  88. package/dist/34.af70302b47e62d49d058.bundle.js.map +0 -1
  89. package/dist/35.8b3e5f2143c615155e8d.bundle.js +0 -2
  90. package/dist/35.8b3e5f2143c615155e8d.bundle.js.map +0 -1
  91. package/dist/36.466f06017a4f9d2277fb.bundle.js +0 -2
  92. package/dist/36.466f06017a4f9d2277fb.bundle.js.map +0 -1
  93. package/dist/48.14a8f14de3765cbe330c.bundle.js +0 -2
  94. package/dist/48.14a8f14de3765cbe330c.bundle.js.map +0 -1
  95. package/dist/bundle.e7b22d8ef84fbe277d35.bundle.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ (window.webpackJsonp=window.webpackJsonp||[]).push([[10,27,35,48,84],{29:function(e,t){angular.module("graphdb.framework.rest.connectors.service",[]).factory("ConnectorsRestService",r),r.$inject=["$http"];const n="rest/connectors";function r(e){return{getConnectors:function(){return e.get(n)},initConnector:function(t){return e.get(`${n}/options?prefix=${t}`)},hasConnector:function(t){return e.get(`${n}/existing?prefix=${t}`)},checkConnector:function(t){return e.post(`${n}/check`,t,{headers:{"Content-Type":"text/plain"}})}}}},32:function(e,t,n){"use strict";n.r(t);n(10),n(29);function r(e){const t=[];return Object.keys(e).forEach((function(n){t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]))})),t.join("&")}function o(e,t){for(let r=0;r<t.length;r++){const o=t[r];if("StringArray"===o.__type)e[o.__name]||(e[o.__name]=[""]);else if("OptionArray"===o.__type)if(e[o.__name])for(let t=0;t<o.__childOptions.length;t++){const n=o.__childOptions[t];if("Boolean"===n.__type)for(let t=0;t<e[o.__name].length;t++){const r=e[o.__name][t];!r.hasOwnProperty([n.__name])&&angular.isDefined(n.__defaultValue)&&(r[n.__name]=n.__defaultValue)}}else{e[o.__name]=[];const t={};for(let e=0;e<o.__childOptions.length;e++){const n=o.__childOptions[e];"StringArray"===n.__type?t[n.__name]=[""]:t[n.__name]=angular.isUndefined(n.__defaultValue)?"":n.__defaultValue}e[o.__name].push(t)}else"Map"===o.__type?e[o.__name]?e[o.__name]=(n=e[o.__name],_.map(n,(function(e,t){return{key:t,value:e}}))):e[o.__name]=[]:"JsonString"===o.__type?!e[o.__name]||e[o.__name]instanceof String||"string"==typeof e[o.__name]||(e[o.__name]=angular.toJson(e[o.__name],2)):angular.isUndefined(e[o.__name])&&(e[o.__name]=angular.isUndefined(o.__defaultValue)?"":o.__defaultValue)}var n;return e}function a(e,t,n){return e.post("repositories/"+t,r({query:n}),{headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/sparql-results+json","X-GraphDB-Local-Consistency":"updating"}})}function i(e){return e.substring(0,e.length-1)+"/instance#"}function s(e,t,n,r,o){const a=function e(t,n){const r={};return _.each(n,(function(n){angular.isDefined(t[n.__name])&&("OptionArray"===n.__type?(r[n.__name]=[],_.each(t[n.__name],(function(t){r[n.__name].push(e(t,n.__childOptions))}))):r[n.__name]=angular.copy(t[n.__name]))})),r}(n,r);for(let e=0;e<r.length;e++)try{"Map"===r[e].__type?a[r[e].__name]=(s=a[r[e].__name],_.reduce(s,(function(e,t){if(""===t.key&&""===t.value);else{if(""===t.key)throw new Error('Key may not be empty with value "'+t.value+'"');if(e.hasOwnProperty(t.key))throw new Error("Duplicate key "+t.key);e[t.key]=t.value}return e}),{})):"JsonString"===r[e].__type&&(a[r[e].__name]=angular.fromJson(a[r[e].__name]))}catch(t){return o(r[e].__label,t.message),null}var s;!function e(t){Array.isArray(t)&&(t=_.filter(t,(function(e){return null!==e&&(!e.trim||""!==e.trim())})));return Object.keys(t).forEach((function(n){""!==t[n]&&null!=t[n]||!1===t[n]?"object"==typeof t[n]&&(t[n]=e(t[n])):delete t[n]})),t}(a);let u="";return u+="PREFIX :<"+t+">\n",u+="PREFIX inst:<"+i(t)+">\n",u+="INSERT DATA {\n",u+="\tinst:"+e+" :createConnector '''\n",u+=angular.toJson(a,2),u+="\n''' .\n}\n",u=u.replace(/\\/g,"\\\\\\"),u}function u(e,t,n,u,c,l,d,p,g){function f(t){e.beingBuiltConnector={percentDone:0,status:{processedEntities:0,estimatedEntities:0,indexedEntities:0,entitiesPerSecond:0},actionName:t?"Repairing":"Creating",waitOnRepairStartOnce:!!t,eta:"-",inline:!1,iri:null}}function y(t,n,r){return f(r),$.extend(e.beingBuiltConnector,{iri:i(t)+n,name:n,inline:!1,doneCallback:function(){e.beingBuiltConnector.modalInstance.dismiss("cancel")}}),e.beingBuiltConnector.modalInstance=u.open({templateUrl:"pages/connectorProgress.html",controller:"CreateProgressCtrl",size:"lg",backdrop:"static",scope:e}),e.beingBuiltConnector.modalInstance}function m(t,o,a){const i=y(t.value,o.name,!1);p.addStatements(n.getActiveRepository(),r({update:o.query})).then((function(){g.getConnectors().then((function(){g.hasConnector(encodeURIComponent(t.value)).then((function(n){e.existing[t.key]=n.data}))})),c.success("Created connector "+o.name)}),(function(e){c.error(getError(e)),a()})).finally((function(){i.dismiss("cancel")}))}e.loader=!1,e.controllers=[],e.existing={},e.definitions={},e.getLoaderMessage=function(){const t=(Date.now()-e.loaderStartTime)/1e3,n=e.getHumanReadableSeconds(t);let r="";return r=e.progressMessage?e.progressMessage+"... "+n:"Running operation..."+n,e.extraMessage&&t>10&&(r+="\n"+e.extraMessage),r},e.setLoader=function(t,n,r){t?(e.loader=!0,e.loaderStartTime=Date.now(),e.progressMessage=n,e.extraMessage=r):(e.loader=!1,e.progressMessage="",e.extraMessage="")},e.initConnector=function(t){return g.initConnector(encodeURIComponent(t.value)).then((function(n){return e.definitions[t.key]=n.data,g.hasConnector(encodeURIComponent(t.value)).then((function(n){e.existing[t.key]=n.data}))}))},e.getConnectors=function(){e.canWriteActiveRepo()&&(e.setLoader(!0,"Fetching connectors","Normally this is a fast operation but it may take longer if a bigger repository needs to be initialised first."),g.getConnectors().then((function(r){e.connectors=Object.keys(r.data).map((function(e){return{key:e,value:r.data[e]}})),d.all(_.map(e.connectors,(function(t){return e.initConnector(t)}))).finally((function(){f();const r=function(e){const t=_.map(e,(function(e){return"<"+e.value+"connectorStatus>"})).join("|");return t?"SELECT ?connector ?status { ?connector "+t+" ?status }":null}(e.connectors);r?function(e){return a(t,n.getActiveRepository(),e)}(r).then((function(t){const n=function(e){if(e.bindings)for(let t=0;t<e.bindings.length;t++)try{const n=JSON.parse(e.bindings[t].status.value);if("BUILDING"===n.status)return{connector:e.bindings[t].connector.value,status:n}}catch(e){console.error(e)}return{}}(t.data.results);if(n.connector){const t=n.connector.split(/#/);t[0]=t[0].replace(/\/instance$/,"#"),r=t[0],o=t[1],f(),$.extend(e.beingBuiltConnector,{iri:i(r)+o,name:o,inline:!0,doneCallback:function(){e.beingBuiltConnector.inline=!1}})}var r,o})).finally((function(){e.setLoader(!1)})):e.setLoader(!1)}))})).catch((function(t){e.setLoader(!1),c.error(getError(t),"Could not get connectors")})),e.existing={})},e.getOptions=function(t){return e.definitions[t.key]},e.isEmpty=function(e){return angular.isObject(e)&&0===Object.keys(e).length},e.toPrettyJson=function(e){return angular.toJson(e,2)},e.$watch((function(){return n.getActiveRepository()}),e.getConnectors),e.$watch((function(){return n.getActiveLocation()}),e.getConnectors),e.copyConnector=function(t,n){let r;angular.isUndefined(n)||(r=angular.copy(n),r.name=r.name+"-copy"),u.open({templateUrl:"pages/createConnector.html",controller:"CreateConnectorCtrl",size:"lg",backdrop:"static",resolve:{connector:function(){return t},values:function(){return angular.isUndefined(r)?{name:"",values:{}}:r},options:function(){return e.getOptions(t)}}}).result.then((function(n){m(t,n,(function(){n.skipConversion=!0,e.newConnector(t,n)}))}))},e.newConnector=function(t,n){u.open({templateUrl:"pages/createConnector.html",controller:"CreateConnectorCtrl",size:"lg",backdrop:"static",resolve:{connector:function(){return t},values:function(){return angular.isUndefined(n)?{name:"",values:{}}:n},options:function(){return e.getOptions(t)}}}).result.then((function(n){m(t,n,(function(){n.skipConversion=!0,e.newConnector(t,n)}))}))},e.repair=function(t,o){l.openSimpleModal({title:"Confirm repair",message:"Are you sure you want to repair this connector?<br>Note that repair means delete + recreate with the same settings.",warning:!0}).result.then((function(){const a=y(o.value,t.name,!0),s=(u=t.name,"PREFIX prefix:<"+(l=o.value)+">\nINSERT DATA {\n\t<"+i(l)+u+'> prefix:repairConnector ""\n}');var u,l;p.addStatements(n.getActiveRepository(),r({update:s})).then((function(){g.getConnectors().then((function(){g.hasConnector(encodeURIComponent(o.value)).then((function(t){e.existing[o.key]=t.data}))})),c.success("Repaired connector "+t.name)}),(function(e){c.error(getError(e))})).finally((function(){a.dismiss("cancel")}))}))},e.delete=function(t,o){const a=o.key.indexOf("Elastic")>=0||o.key.indexOf("Solr")>=0;u.open({templateUrl:"js/angular/externalsync/templates/deleteConnector.html",controller:"DeleteConnectorCtrl",resolve:{type:function(){return o.key},isExternal:function(){return a}}}).result.then((function(i){e.setLoader(!0,"Deleting connector "+t.name,"This is usually a fast operation but it might take a while.");const s=function(e,t,n){const r=t.substring(0,t.length-1)+"/instance#";return"PREFIX prefix:<"+t+">\nINSERT DATA {\n\t<"+r+e+'> prefix:dropConnector "'+(n?"force":"")+'"\n}'}(t.name,o.value,i);p.addStatements(n.getActiveRepository(),r({update:s})).then((function(){g.getConnectors().then((function(){g.hasConnector(encodeURIComponent(o.value)).then((function(t){e.existing[o.key]=t.data}))})),i?(c.success("Deleted (with force) connector "+t.name),a&&c.warning("You may have to remove the index manually from "+o.key)):c.success("Deleted connector "+t.name)}),(function(e){c.error(getError(e))})).finally((function(){e.setLoader(!1)}))}))},e.viewQuery=function(t,n){u.open({templateUrl:"pages/viewQuery.html",controller:"ViewQueryCtrl",resolve:{query:function(){const r=e.getOptions(t);return s(n.name,t.value,o(n.values,r),r)}}})}}function c(e,t,n,r){e.force=!1,e.type=n,e.isExternal=r,e.ok=function(){t.close(e.force)},e.cancel=function(){t.dismiss()}}function l(e,t,n,r,o){function a(){return s(e.name,n.value,e.values,e.options,(function(e,t){o.error(t,e)}))}e.connector=n,e.addField=function(t,n){const r=angular.copy(e.defaultValues[n][0]);e.values[n].splice(t+1,0,r)},e.addOption=function(e,t){t.splice(e+1,0,"")},e.deleteOption=function(e,t){t.splice(e,1)},e.addMapOption=function(e,t){t.splice(e+1,0,{key:"",value:""})},e.deleteMapOption=function(e,t){t.splice(e,1)},e.ok=function(){if(e.form.$valid){const n=a();n&&t.close({name:e.name,values:e.values,options:e.options,query:n})}},e.viewQuery=function(){const e=a();e&&r.open({templateUrl:"pages/viewQuery.html",controller:"ViewQueryCtrl",resolve:{query:function(){return e}}})},e.cancel=function(){t.dismiss("cancel")}}function d(e,t,n,r,a,i,s,u){angular.extend(this,t("ExtendNewConnectorCtrl",{$scope:e,$modalInstance:r,connector:a,$modal:i})),e.values=s.values,e.options=u,e.name=s.name,s.skipConversion||(e.values=o(e.values,e.options)),e.defaultValues=angular.copy(e.values)}function p(e,t,n,r){function o(){const o=function(e){const t=e.replace(/\/instance#.+$/,"#connectorStatus");let n="";return n+="SELECT ?status {\n",n+="\t<"+e+"> <"+t+"> ?status",n+="\n}",n}(e.beingBuiltConnector.iri);e.beingBuiltConnector.iri=null,e.progressInterval=t((function(){(function(e){return a(n,r.getActiveRepository(),e)})(o).then((function(n){const r=function(e){if(e.bindings&&e.bindings.length>0)try{return JSON.parse(e.bindings[0].status.value)}catch(e){console.error(e)}return{}}(n.data.results);"BUILDING"===r.status?(e.beingBuiltConnector.status=r,e.beingBuiltConnector.percentDone=(100*r.processedEntities/r.estimatedEntities).toFixed(0),e.beingBuiltConnector.eta=e.getHumanReadableSeconds(r.etaSeconds),e.beingBuiltConnector.actionName=r.repair?"Repairing":"Creating",e.beingBuiltConnector.waitOnRepairStartOnce=!1):"BUILT"!==r.status||e.beingBuiltConnector.waitOnRepairStartOnce||(t.cancel(e.progressInterval),e.beingBuiltConnector.doneCallback&&e.beingBuiltConnector.doneCallback())}))}),1e3),e.$on("$destroy",(function(){t.cancel(e.progressInterval)}))}e.beingBuiltConnector=e.beingBuiltConnector||{},!e.beingBuiltConnector.inline&&e.beingBuiltConnector.iri&&o(),e.$watch("beingBuiltConnector.iri",(function(t){e.beingBuiltConnector.inline&&t&&o()}))}angular.module("graphdb.framework.externalsync.controllers",["graphdb.framework.rest.rdf4j.repositories.service","graphdb.framework.rest.connectors.service"]).controller("ConnectorsCtrl",u).controller("ExtendNewConnectorCtrl",l).controller("CreateConnectorCtrl",d).controller("CreateProgressCtrl",p).controller("DeleteConnectorCtrl",c).filter("ceil",(function(){return function(e){return Math.ceil(e)}})),u.$inject=["$scope","$http","$repositories","$modal","toastr","ModalService","$q","RDF4JRepositoriesRestService","ConnectorsRestService"],c.$inject=["$scope","$modalInstance","type","isExternal"],l.$inject=["$scope","$modalInstance","connector","$modal","toastr"],d.$inject=["$scope","$controller","$http","$modalInstance","connector","$modal","values","options"],p.$inject=["$scope","$interval","$http","$repositories"]},33:function(e,t,n){"use strict";n.r(t);n(4),n(12);function r(e,t,n,r,o,a,i,s,u,c,l,d,p,g){const f={id:"1",name:"",query:"select * where { \n\t?s ?p ?o .\n} limit 100 \n",inference:!0,sameAs:!0};let y,m=c.getPrincipal();function C(e,t){f.inference=t.appSettings.DEFAULT_INFERENCE,f.sameAs=t.appSettings.DEFAULT_SAMEAS,e.skipCountQuery=!t.appSettings.EXECUTE_COUNT,e.ignoreSharedQueries=t.appSettings.IGNORE_SHARED_QUERIES,e.tabsData=e.tabs=p.get(g.TABS_STATE)||[f],e.$watchCollection("[currentQuery.inference, currentQuery.sameAs]",(function(e,t,n){h(n.currentQuery)})),e.$on("repositoryIsSet",v)}function h(t){!function(){if(r.isActiveRepoOntopType())return;const t=document.getElementById("sameAs");!t||e.currentQuery.inference||t.disabled?e.currentQuery.inference&&t.disabled&&(t.removeAttribute("disabled"),e.currentQuery.sameAs=m.appSettings.DEFAULT_SAMEAS):(t.disabled=!0,e.currentQuery.sameAs=!1)}(),e.tabs.forEach((function(n,o){n.id===t.id&&(e.tabs[o].query=t.query,r.isActiveRepoOntopType()||(e.tabs[o].inference=t.inference,e.tabs[o].sameAs=t.sameAs))})),p.set(g.TABS_STATE,e.tabs)}function b(t,n,r,o){const a=angular.element(document.getElementById("yasr-inner"));e.queryIsRunning=t,t?(e.queryStartTime=Date.now(),e.countTimeouted=!1,e.progressMessage=n,e.extraMessage=r,e.noLoaderTimer=o,a.addClass("hide")):(e.progressMessage="",e.extraMessage="",e.noLoaderTimer=!1,e.currentTrackAlias=null,e.abortRequested=!1,a.removeClass("hide")),null===e.$$phase&&e.$apply()}function T(n){function r(){return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0}if(e.orientationViewMode){if("yasr"===e.viewMode){let e=r()-document.querySelector(".CodeMirror-wrap").getBoundingClientRect().top;e-=40,document.querySelector(".CodeMirror-wrap").style.height=e+"px"}else e.noPadding={},document.querySelector(".CodeMirror-wrap").style.height="";document.getElementById("yasr").style.minHeight=""}else if(e.noPadding={paddingRight:15,paddingLeft:0},window.editor&&document.querySelector(".CodeMirror-wrap")){let e=r()-document.querySelector(".CodeMirror-wrap").getBoundingClientRect().top;e-=40,document.querySelector(".CodeMirror-wrap").style.height=e+"px",document.getElementById("yasr").style.minHeight=e+"px"}else{let r;r=t(n?function(){e.fixSizesOnHorizontalViewModeSwitch(n)}:e.fixSizesOnHorizontalViewModeSwitch,100),e.$on("$destroy",(function(){t.cancel(r)}))}window.yasr&&window.yasr.container&&t((function(){window.yasr.container.resize()}),100)}function w(){T(!0)}function v(t,n){n.newRepo&&(e.tabsData=p.get(g.TABS_STATE),e.tabsData.forEach((function(e){e.yasrData=void 0,e.queryType=void 0,e.resultsCount=0,e.allResultsCount=0,e.sizeDelta=void 0})),p.set(g.TABS_STATE,e.tabsData),e.tabs=e.tabsData,e.currentQuery={},e.errorMessage=null,e.repositoryError=null)}function S(e){t((function(){$('a[data-id = "'+e+'"]').tab("show")}),0)}function E(o,a){if(e.executedQueryTab=e.currentQuery,a){if("SELECT"!==window.editor.getQueryType()&&"CONSTRUCT"!==window.editor.getQueryType())return void n.warning("Explain only works with SELECT or CONSTRUCT queries.");if(r.isActiveRepoOntopType())return void n.warning("Explain not supported for Virtual repositories.")}if(e.explainRequested=a,!e.queryIsRunning){if(o?e.currentTabConfig.resultsCount=0:e.resetCurrentTabConfig(),e.lastRunQueryMode=window.editor.getQueryMode(),"update"===e.lastRunQueryMode&&r.isActiveRepoOntopType())return void n.warning("Updates are not supported for Virtual repositories.");if(b(!0,"update"===e.lastRunQueryMode?"Executing update":"Evaluating query"),"none"!==e.viewMode){e.viewMode="none",e.orientationViewMode&&e.fixSizesOnHorizontalViewModeSwitch();const n=t(window.editor.query,500);e.$on("$destroy",(function(){t.cancel(n)}))}else window.editor.query()}}function R(){e.showSampleQueries=!e.showSampleQueries,e.showSampleQueries?i.getSavedQueries().success((function(t){e.sampleQueries=t,$("#sampleQueriesCollapse").collapse("show").width("300px")})).error((function(e){const t=getError(e);n.error(t,"Error! Could not get saved queries")})):$("#sampleQueriesCollapse").collapse("hide")}function A(t){let n=void 0;return e.tabsData.forEach((function(e){if(e.name===t.name&&e.query===t.body)return n=e.id,e})),n}function _(t){return function(n,r,o){e.savedQuery={name:n,query:r||window.editor.getValue(),shared:o},$(t).modal("show")}}function Q(t){for(let n=0;n<e.tabsData.length;n++){if(e.tabsData[n].id===t)return n}}m?C(e,m):e.$on("securityInit",(function(e){m=c.getPrincipal(),C(e.currentScope,m)})),this.hint=document.createElement("span"),this.hint.innerHTML='Hint: "abC" matches "abC*", "ab c*" and "ab-c*"',this.hint.style.fontSize="12px",this.hint.style.color="gray",this.hint.style.backgroundColor="white",this.hint.style.position="absolute",this.hint.style.zIndex="3",this.hint.style.paddingLeft="12px",e.$watch((function(){return angular.element(".CodeMirror-hints").length}),e=>{if(e){const e=angular.element(".CodeMirror-hints")[0].getBoundingClientRect();document.body.appendChild(this.hint),this.hint.style.top=e.top-20+"px",this.hint.style.left=e.right-this.hint.offsetWidth-12+"px"}else this.hint&&this.hint.parentNode&&this.hint.parentNode.removeChild(this.hint)}),e.resetCurrentTabConfig=function(){e.currentTabConfig={pageSize:1e3,page:1,allResultsCount:0,resultsCount:0}},e.queryExists=!1,e.resetCurrentTabConfig(),e.saveTab=function(t){const n=Q(t);if(void 0===n)return{};const r=e.tabsData[n];return e.saveQueryToLocal(r),r},e.loadTab=function(n){e.tabsData=p.get(g.TABS_STATE)||[f];const o=Q(n),a=e.tabsData[o];a.yasrData&&b(!0,"Rendering results",null,!0);t((function(){""===e.currentQuery.query&&(e.currentQuery.query=" "),t((function(){window.editor.setValue(e.currentQuery.query),e.yasr.updateDownloadDropdown(),e.$broadcast("tabLoaded",e.currentQuery.id),e.yasr.options.output=a.outputType,a.yasrData&&(a.yasrData.customError?(e.yasr.results={getException:function(){return a.yasrData.customError}},b(!1)):t((function(){e.setYasrResponse(a.yasrData,a.textStatus,a.jqXhrOrErrorString),b(!1),$(".yasr_btnGroup li:nth-child(2)").hasClass("active")&&t((function(){$(".yasr_btnGroup li:nth-child(2) a").get(0).click()}),0)}),0))}),0)}),0),p.set(g.TABS_STATE_CURRENT_ID,n),e.currentQuery=a,t((function(){e.currentTabConfig={},e.currentTabConfig.queryType=a.queryType,e.currentTabConfig.resultsCount=a.resultsCount,e.currentTabConfig.offset=a.offset,e.currentTabConfig.allResultsCount=a.allResultsCount,e.currentTabConfig.allResultsCountExact=a.allResultsCountExact,e.currentTabConfig.page=a.page,e.currentTabConfig.pageSize=a.pageSize,e.currentTabConfig.timeFinished=a.timeFinished,e.currentTabConfig.timeTook=a.timeTook,e.currentTabConfig.sizeDelta=a.sizeDelta,e.currentTabConfig.customUpdateMessage=a.customUpdateMessage,e.currentTabConfig.errorMessage=a.errorMessage,e.currentTabConfig.warningMessage=a.warningMessage,e.$apply()}),0),$("#yasr").css("padding","0"),y||(y=setInterval(D,200));!function(){const t=r.isActiveRepoOntopType(),n=r.isActiveRepoFedXType();(function(e){const t=document.getElementById("sameAs"),n=document.getElementById("inference");t&&(t.disabled=!!e);n&&(n.disabled=!!e)})(t),e.nocount=!(!t&&!n)||!m.appSettings.EXECUTE_COUNT,t&&(e.currentQuery.inference=!0,e.currentQuery.sameAs=!0)}()},e.addNewTab=function(n,r,o){if(!M(!0))return;let a;a=r||o?{id:"1",name:r,query:o,inference:m.appSettings.DEFAULT_INFERENCE,sameAs:m.appSettings.DEFAULT_SAMEAS}:{id:"1",name:"",query:"select * where { \n\t?s ?p ?o .\n} limit 100 \n",inference:m.appSettings.DEFAULT_INFERENCE,sameAs:m.appSettings.DEFAULT_SAMEAS};q++;const i=""+q;e.tabsData=e.tabs;const s=a;s.id=i,e.tabsData.push(s),p.set(g.TABS_STATE_MAXID,q),p.set(g.TABS_STATE,e.tabsData);const u=Array.prototype.slice.call(arguments,1);t((function(){e.$apply(),S(i),n&&n.apply(this,u)}),0),e.tabs=e.tabsData},e.isTabChangeOk=M,e.runQuery=E,e.abortCurrentQuery=function(){d.abortQueryByAlias(e.currentTrackAlias).success((function(){e.abortRequested=!0}))},e.editQuery=function(t){o.open({templateUrl:"js/angular/core/directives/queryeditor/templates/query-sample.html",controller:"QuerySampleModalCtrl",resolve:{data:function(){return{title:'Edit Saved Query: "'+t.name+'"',query:t,edit:!0,okButtonText:"Save"}}}}).result.then((function(r){const o={name:r.name,body:r.body,shared:r.shared};t.name!==r.name?i.addNewSavedQuery(o).success((function(){e.deleteQueryHttp(t.name,!0)})).error((function(e){const t=getError(e);n.error(t,"Error! Cannot edit saved query")})):i.editSavedQuery(o).success((function(){$("#editQueryContainer").modal("hide"),e.toggleSampleQueries(),n.success("Saved query "+t.name+" was edited.")})).error((function(e){const t=getError(e);n.error(t,"Error! Cannot edit Saved query")}))}))},e.getNamespaces=function(){b(!0,"Refreshing namespaces","Normally this is a fast operation but it may take longer if a bigger repository needs to be initialised first."),e.namespacesLoading=!0,l.getRepositoryNamespaces().success((function(t){const n={};t.results.bindings.forEach((function(e){n[e.prefix.value]=e.namespace.value})),e.namespaces=n})).error((function(t){e.repositoryError=getError(t)})).finally((function(){b(!1),e.namespacesLoading=!1}))},e.changePagination=function(){E(!0,e.explainRequested)},e.toggleSampleQueries=R,e.addKnownPrefixes=function(){i.addKnownPrefixes(JSON.stringify(window.editor.getValue())).success((function(e){angular.isDefined(window.editor)&&angular.isDefined(e)&&e!==window.editor.getValue()&&window.editor.setValue(e)})).error((function(e){const t=getError(e);return n.error(t,"Error! Could not add known prefixes"),!0}))},e.getExistingTabId=A,e.querySelected=function(t){const n=A(t);e.toggleSampleQueries(),e.isTabChangeOk(!1)&&(e.highlightNextTabChange=!0,angular.isDefined(n)?S(n):e.addNewTab(null,t.name,t.body))},e.deleteQuery=function(t){a.openSimpleModal({title:"Confirm",message:"Are you sure you want to delete the saved query '"+t+"'?",warning:!0}).result.then((function(){e.deleteQueryHttp(t)}))},e.deleteQueryHttp=function(t,r){i.deleteSavedQuery(t).success((function(){e.toggleSampleQueries(),r||n.success("Saved query: "+t+" was deleted.")})).error((function(e){const t=getError(e);n.error(t,"Error! Cannot delete saved query")}))},e.saveQuery=function(t,n){o.open({templateUrl:"js/angular/core/directives/queryeditor/templates/query-sample.html",controller:"QuerySampleModalCtrl",resolve:{data:function(){return{title:"Create New Saved Query",query:{name:t.name,body:t.query,shared:t.shared},edit:!1,okButtonText:"Create",queryExists:n}}}}).result.then((function(t){e.saveQueryHttp(t)}),(function(){}))},e.saveQueryHttp=function(t){i.addNewSavedQuery(t).success((function(){n.success("Saved query "+t.name+" was saved.")})).error((function(r){let o=getError(r);if(n.error(o,"Error! Cannot create saved query"),o="Query '"+t.name+"' already exists!"){t.query=t.body;const n=!0;e.saveQuery(t,n)}}))},e.saveQueryToLocal=h,e.setLoader=b,e.getLoaderMessage=function(){const t=(Date.now()-e.queryStartTime)/1e3;let n="",r="";e.noLoaderTimer||(n=e.getHumanReadableSeconds(t));r=e.progressMessage?e.progressMessage+"... "+n:"Running operation... "+n;e.extraMessage&&t>10&&(r+="\n"+e.extraMessage);return r},e.fixSizesOnHorizontalViewModeSwitch=T,e.changeViewMode=function(){e.viewMode="none",e.orientationViewMode=!e.orientationViewMode,p.set(g.VIEW_MODE,e.orientationViewMode),T()},e.showHideEditor=w,e.focusQueryEditor=function(){angular.element(document).find(".editable-input").is(":focus")||angular.element(document).find(".CodeMirror textarea:first-child").focus()},e.orientationViewMode=!p.get(g.VIEW_MODE)||"true"===p.get(g.VIEW_MODE),e.viewMode="none",e.getActiveRepository=function(){return r.getActiveRepository()},e.getActiveRepositoryNoError=function(){if(!e.repositoryError)return r.getActiveRepository()},e.orientationViewMode||w(),window.onbeforeunload=function(){e.currentQuery&&e.saveTab(e.currentQuery.id),p.set(g.TABS_STATE,e.tabs)},e.$on("$destroy",(function(){e.currentQuery&&e.saveTab(e.currentQuery.id),p.set(g.TABS_STATE,e.tabs),clearInterval(y)})),e.$on("$destroy",(function(){clearInterval(y),window.editor=null,window.yasr=null})),$(document).mouseup((function(t){const n=$("#sampleQueriesCollapse");!n.is(t.target)&&0===n.has(t.target).length&&e.showSampleQueries&&R()}));let q=p.get(g.TABS_STATE_MAXID)||1;function x(e){return $(e).attr("data-id")}function D(){if(e.currentTabConfig.resultsCount>=0){const e=$(".saveAsDropDown");e.length>0&&!window.editor.queryValid?yasr.header.find(".saveAsDropDown").remove():0===e.length&&window.editor.queryValid&&yasr.updateDownloadDropdown()}}function M(t){return!(e.queryIsRunning&&!e.namespacesLoading)||(t?n.info("New tabs may not be opened while query or update is running."):n.info("Tabs may not be switched while query or update is running."),!1)}e.highlightNextTabChange=!1,e.$on("tabAction",(function(n,r){r.relatedTarget&&(t.cancel(r.relatedTarget.timer),$(r.relatedTarget).css("color",""),e.saveTab(x(r.relatedTarget))),e.loadTab(x(r.target));const o=["#ED4F2F","","#ED4F2F"],a=[400,400,400];if(e.highlightNextTabChange){e.highlightNextTabChange=!1;let n=0;$(r.target).css("color",o[n]);const i=function(){n++,n<o.length?($(r.target).css("color",o[n]),r.target.timer=t(i,a[n])):$(r.target).css("color","")};t(i,a[n])}})),e.$on("deleteAllexeptSelected",(function(t,n){e.tabsData=n,e.tabs=n})),e.currentQuery={},e.showSampleQueries=!1,e.savedQuery={},e.sampleQueries={},e.editQueryModal=_("#editQueryContainer"),e.deleteQueryModal=_("#confirmDeleteContainer"),e.saveQueryModal=_("#saveQueryContainer"),e.getResultsDescription=function(){let t;if(0===e.currentTabConfig.resultsCount)t="No results.";else{const n=(e.currentTabConfig.page-1)*e.currentTabConfig.pageSize+Math.min(e.currentTabConfig.resultsCount,e.currentTabConfig.pageSize);t="Showing results from "+s("currency")(e.currentTabConfig.offset,"",0)+" to "+s("currency")(n,"",0),e.currentTabConfig.allResultsCount>0&&(t+=e.currentTabConfig.allResultsCountExact?" of ":" of at least ",t+=s("currency")(e.currentTabConfig.allResultsCount,"",0)),t+="."}return t},e.getUpdateDescription=function(){return e.currentTabConfig.customUpdateMessage?e.currentTabConfig.customUpdateMessage:void 0===e.currentTabConfig.sizeDelta?"":e.currentTabConfig.sizeDelta<0?"Removed "+Math.abs(e.currentTabConfig.sizeDelta)+" statements.":e.currentTabConfig.sizeDelta>0?"Added "+e.currentTabConfig.sizeDelta+" statements.":"The number of statements did not change."},e.getStaleWarningMessage=function(){const t=60*Math.round((Date.now()-e.currentTabConfig.timeFinished)/6e4);if(t>=3600)return"Possibly stale result (obtained "+e.getHumanReadableSeconds(t)+" ago)."};const k=function(){};angular.element(u).bind("resize",k),e.$on("$destroy",(function(){angular.element(u).unbind("resize",k)}))}function o(e,t,n){n.queryExists&&(e.queryExists=!0),e.query=angular.copy(n.query),e.title=n.title,e.edit=n.edit,e.okButtonText=n.okButtonText,e.ok=function(){e.form.$valid&&t.close(e.query)},e.cancel=function(){t.dismiss("cancel")}}angular.module("graphdb.framework.core.directives.queryeditor.controllers",["graphdb.framework.utils.localstorageadapter","graphdb.framework.rest.sparql.service"]).controller("QueryEditorCtrl",r).controller("QuerySampleModalCtrl",o),r.$inject=["$scope","$timeout","toastr","$repositories","$modal","ModalService","SparqlRestService","$filter","$window","$jwtAuth","RDF4JRepositoriesRestService","MonitoringRestService","LocalStorageAdapter","LSKeys"],o.$inject=["$scope","$modalInstance","data"]},34:function(e,t,n){"use strict";n.r(t);n(29),n(4),n(32);var r=n(209),o=n.n(r),a=n(207),i=n.n(a);function s(e,t,n,r,a,s,u,c,l,d,p,g){let f;return{restrict:"AE",scope:!1,templateUrl:"js/angular/core/directives/queryeditor/templates/query-editor.html",link:function(y,m,C){y.nostorage=C.hasOwnProperty("nostorage"),y.notabs=C.hasOwnProperty("notabs"),y.notoolbar=C.hasOwnProperty("notoolbar"),y.notoolbarSaved=C.hasOwnProperty("notoolbarSaved"),y.notoolbarCopy=C.hasOwnProperty("notoolbarCopy"),y.notoolbarInference=C.hasOwnProperty("notoolbarInference"),y.notoolbarSameAs=C.hasOwnProperty("notoolbarSameAs"),y.nostatus=C.hasOwnProperty("nostatus"),y.norun=C.hasOwnProperty("norun"),y.runButtonName="Run",C.runButtonName&&(y.runButtonName=C.runButtonName);if(y.nocount="true"===C.nocount,C.callbackOnChange){const e=y[C.callbackOnChange];"function"==typeof e&&(f=e)}e((function(){!function(y){function m(){angular.element("#wb-sparql-saveQuery")[0].click()}function C(){y.runQuery(!1,!1)}function h(){y.runQuery(!1,!0)}function b(){if(y.tabs.length<2||!y.currentQuery.id||!y.isTabChangeOk(!1))return;let e=D(y.currentQuery.id);e=(e+1)%y.tabs.length,w(y.tabs[e].id)}function T(){if(y.tabs.length<2||!y.currentQuery.id||!y.isTabChangeOk(!1))return;let e=D(y.currentQuery.id);e--,-1===e&&(e=y.tabs.length-1),w(y.tabs[e].id)}function w(t){e((function(){let e=$('a[data-id = "'+t+'"]');0===e.length&&(e=$("a[data-id]").first()),e.tab("show")}),0)}y.changePagination=function(){y.runQuery(!0,y.explainRequested)},window.editor=o.a.fromTextArea(document.getElementById("query"),{persistent:null,value:"",indentUnit:4,createShareLink:null,cursorHeight:1,sparql:{showQueryButton:!1,acceptHeaderGraph:"application/x-graphdb-table-results+json, application/rdf+json;q=0.9, */*;q=0.8",acceptHeaderSelect:"application/x-sparqlstar-results+json, application/sparql-results+json;q=0.9, */*;q=0.8"},extraKeys:{"Ctrl-Enter":C,"Cmd-Enter":C,"Shift-Ctrl-Enter":h,"Shift-Cmd-Enter":h,"Ctrl-Alt-T":y.addNewTab,"Cmd-Alt-T":y.addNewTab,"Ctrl-S":m,"Cmd-S":m,"Ctrl-Alt-Left":T,"Cmd-Alt-Left":T,"Ctrl-Alt-Right":b,"Cmd-Alt-Right":b}}),window.editor.toastBuildIndex=function(){n.warning("",'<div class="autocomplete-toast"><a href="autocomplete">Autocomplete is OFF<br>Go to Setup -> Autocomplete</a></div>',{allowHtml:!0})},window.editor.toastError=function(e){n.error("Cannot execute autocomplete query. "+getError(e))},window.editor.on("changes",(function(){angular.element(".CodeMirror-linenumbers").css("width","1px"),angular.element(".CodeMirror-sizer").css("margin-left","0px"),clearTimeout(y.changesTimeout);const e=!window.editor.queryValid;y.changesTimeout=setTimeout(f?f():function(){const t=D(y.currentQuery.id)+1;$('a[data-id = "'+t+'"]').toggleClass("query-has-error",e).attr("title",e?"Query contains a syntax error. See the relevant line for more information.":"")},200),y.currentQuery.query=window.editor.getValue(),y.currentQuery.queryType=window.editor.getQueryType()})),$(".fullscreenToggleBtns").hide();const v=function(e){$(e.target).removeClass("fa-link").addClass("fa-check").blur(),setTimeout((function(){$(e.target).removeClass("fa-check").addClass("fa-link")}),1e3)};window.onbeforeunload=function(){y.nostorage||p.set(g.TABS_STATE,y.tabs),y.saveTab(y.currentQuery.id)};const S=o.a.executeQuery,E=o.a.getUrlArguments;function R(e,t,n){return{status:e,statusText:t,responseText:n}}let A,Q;y.$on("$destroy",(function(){y.nostorage||p.set(g.TABS_STATE,y.tabs),o.a.executeQuery=S,o.a.getUrlArguments=E,y.saveTab(y.currentQuery.id)})),o.a.drawButtons=function(e){e.buttons=$("#yasqe_buttons_mocked")},o.a.getActiveRepository=function(){return r.getActiveRepository()},o.a.getUrlArguments=function(e,t){const n=E(e,t),r=window.editor.getQueryType();return"SELECT"!==r&&"CONSTRUCT"!==r&&"DESCRIBE"!==r||(n.push({name:"limit",value:y.currentTabConfig.pageSize+1}),y.currentTabConfig.offset=(y.currentTabConfig.page-1)*y.currentTabConfig.pageSize+1,n.push({name:"offset",value:y.currentTabConfig.offset-1})),!y.explainRequested||"SELECT"!==r&&"CONSTRUCT"!==r||n.push({name:"explain",value:"true"}),n},o.a.executeQuery=function(e){if(Q&&$(Q.resultsContainer).length&&$(Q.resultsContainer).empty(),e.options.sparql.headers["X-GraphDB-Catch"]=y.currentTabConfig.pageSize+"; throw",y.currentTrackAlias="query-editor-"+performance.now()+"-"+Date.now(),e.options.sparql.headers["X-GraphDB-Track-Alias"]=y.currentTrackAlias,y.countTimeouted=!1,"query"===e.getQueryMode()?e.options.sparql.endpoint="repositories/"+r.getActiveRepository():"update"===e.getQueryMode()&&(e.options.sparql.endpoint="repositories/"+r.getActiveRepository()+"/statements"),e.options.sparql.args=[{name:"infer",value:y.currentQuery.inference},{name:"sameAs",value:y.currentQuery.sameAs}],y.currentTabConfig.customUpdateMessage="","update"!==window.editor.getQueryMode()){const t=y.currentTabConfig,n=y.executedQueryTab.id;return window.editor.options.sparql.handlers.countCallback=function(e,r,o){if(200===e.status){const a=y.tabs[D(n)];a&&(Q.setResultsCount(e,r,o),t.allResultsCount=Q.allCount,a.allResultsCount=Q.allCount,t.allResultsCountExact=!0,a.allResultsCountExact=!0,y.saveTab(a.id))}else t.countTimeouted=!0},null!=y.currentQuery.outputType?Q.options.output=y.currentQuery.outputType:Q.options.output="table",y.currentTabConfig.queryType=window.editor.getQueryType(),y.queryStartTime=(new Date).getTime(),S(e,{setQueryLimit:function(e){return"CONSTRUCT"===y.currentTabConfig.queryType&&r.isActiveRepoOntopType()?window.editor.getValueWithoutComments():e}})}{const t=function(){y.currentTabConfig.queryType="UPDATE",l.getRepositorySize().success((function(t){return y.repoSize=parseInt(t),y.queryStartTime=(new Date).getTime(),S(e,{})})).error((function(t){return n.warning("Could not get repository size for: "+r.getActiveRepository()+"; "+getError(t)),y.queryStartTime=(new Date).getTime(),S(e,{})}))};d.checkConnector(window.editor.getValue()).then((function(e){if(e.data.command&&!e.data.hasSupport){y.currentTabConfig.queryType="ERROR",y.currentTabConfig.timeFinished=Date.now(),y.currentTabConfig.timeTook=(y.currentTabConfig.timeFinished-y.queryStartTime)/1e3;const t=R(-1,"No support for "+e.data.connectorName,e.data.connectorName+" connectors are not supported because the plugin "+e.data.pluginName+" is not active.");return Q.results={getException:function(){return t}},y.setLoader(!1),void x({customError:t},"",null)}if("create"===e.data.command||"repair"===e.data.command){const t="repair"===e.data.command;t?(y.setLoader(!0,"Repairing connector "+e.data.name),y.currentTabConfig.customUpdateMessage="Repaired connector "+e.data.name+"."):(y.setLoader(!0,"Creating connector "+e.data.name),y.currentTabConfig.customUpdateMessage="Created connector "+e.data.name+".");const n=y.$new(!0);n.beingBuiltConnector={percentDone:0,status:{processedEntities:0,estimatedEntities:0,indexedEntities:0,entitiesPerSecond:0},actionName:t?"Repairing":"Creating",eta:"-",inline:!1,iri:e.data.iri,name:e.data.name,doneCallback:function(){A.dismiss("cancel")}},n.getHumanReadableSeconds=y.getHumanReadableSeconds,A=u.open({templateUrl:"pages/connectorProgress.html",controller:"CreateProgressCtrl",size:"lg",backdrop:"static",scope:n})}else"drop"===e.data.command&&(y.setLoader(!0,"Deleting connector "+e.data.name),y.currentTabConfig.customUpdateMessage="Deleted connector "+e.data.name+".");t()}),(function(){t()}))}};const q=o.a.getAjaxConfig;function x(e,t,n){e.getResponseHeader&&e.getResponseHeader("content-type")&&(e.contentType=e.getResponseHeader("content-type")),delete e.response;const r=D(y.executedQueryTab.id),o=y.tabs[r],a={queryType:y.currentTabConfig.queryType,yasrData:e,textStatus:t,jqXhrOrErrorString:n,page:y.currentTabConfig.page,pageSize:y.currentTabConfig.pageSize,allResultsCount:y.currentTabConfig.allResultsCount,allResultsCountExact:y.currentTabConfig.allResultsCountExact,resultsCount:y.currentTabConfig.resultsCount,offset:y.currentTabConfig.offset,timeTook:y.currentTabConfig.timeTook,timeFinished:y.currentTabConfig.timeFinished,sizeDelta:y.currentTabConfig.sizeDelta,customUpdateMessage:y.currentTabConfig.customUpdateMessage,errorMessage:y.currentTabConfig.errorMessage,warningMessage:y.currentTabConfig.warningMessage};"ERROR"!==y.currentTabConfig.queryType&&"UPDATE"!==y.currentTabConfig.queryType&&"ASK"!==y.currentTabConfig.queryType&&(a.outputType=y.yasr.options.output),angular.extend(y.currentQuery,a),angular.extend(o,a),y.nostorage||p.set(g.TABS_STATE,y.tabs),$('a[data-id = "'+y.executedQueryTab.id+'"]').tab("show")}function D(e){for(let t=0;t<y.tabs.length;t++){if(y.tabs[t].id===e)return t}}function M(e){return angular.isDefined(e)&&"false"!==e}function k(e,n,r){const o=y.getExistingTabId(e),a=y.$on("tabLoaded",(function(){angular.isDefined(n)&&(y.currentQuery.inference=M(n)),angular.isDefined(r)&&(y.currentQuery.sameAs=M(r)),M(t.search().execute)&&("update"===window.editor.getQueryMode()?s.openSimpleModal({title:"Confirm execute",message:"This is an update and it may change the data in the repository.<br>Are you sure you want to execute it automatically?",warning:!0}).result.then((function(){y.runQuery(!1)})):y.runQuery(!1)),a()}));y.highlightNextTabChange=!0,angular.isDefined(o)?w(o):y.addNewTab(null,e.name,e.body)}function O(){if(t.search().savedQueryName)e=t.search().savedQueryName,r=t.search().owner,o=t.search().infer,i=t.search().sameAs,a.getSavedQuery(e,r).success((function(e){k(e,o,i)})).error((function(t){n.error("Could not get data for saved query: "+e+"; "+getError(t))}));else if(t.search().query){k({name:t.search().name,body:t.search().query},t.search().infer,t.search().sameAs)}else{w(p.get(g.TABS_STATE_CURRENT_ID))}var e,r,o,i}function B(){y.getNamespaces(),o.a.signal(window.editor,"repositoryOrAuthorizationChanged",r.getActiveRepository(),c.getAuthToken()),O()}o.a.getAjaxConfig=function(e,t){const n=q(e,t);return _.extend(n.headers,{Authorization:c.getAuthToken()}),n},y.copyToClipboardQuery=function(e,t){s.openCopyToClipboardModal(function(e,t){let n=[location.protocol,"//",location.host,location.pathname].join("");e?(n=n+"?savedQueryName="+encodeURIComponent(e),null!=t&&(n+="&owner="+encodeURIComponent(t))):n=n+"?"+$.param({name:y.currentQuery.name,infer:y.currentQuery.inference,sameAs:y.currentQuery.sameAs,query:window.editor.getValue()});return n}(e,t))},y.copyToClipboardResult=function(e){s.openCopyToClipboardModal(e)},y.goToVisual=function(){const e={query:window.editor.getValue(),sameAs:y.currentQuery.sameAs,inference:y.currentQuery.inference};t.path("graphs-visualizations").search(e)},$("textarea").on("paste",(function(){e((function(){y.addKnownPrefixes()}),0)})),Q=i()(document.getElementById("yasr"),{getUsedPrefixes:{},persistency:!1}),window.yasr=Q,Q.afterCopy=v,Q.getQueryResultsAsFormat=function(e){const t=$("#wb-download");t.attr("action","repositories/"+r.getActiveRepository()),$("#wb-download-query").val(y.currentQuery.query),window.editor.getValue()!==y.currentQuery.query&&n.warning("The query in your editor does not match the query results. Download will save the results from the last executed query."),$("#wb-download-infer").val(y.currentQuery.inference),$("#wb-download-sameAs").val(y.currentQuery.sameAs);const o=localStorage.getItem("com.ontotext.graphdb.auth");o&&$("#wb-auth-token").val(o),$("#wb-download-accept").val(e),t.submit()},window.editor.options.sparql.handlers.complete=function(t,r,o){function a(){x(t,r,o)}if(A&&A.dismiss("cancel"),null===window.editor)return void y.setLoader(!1);if(y.currentTabConfig.errorMessage=t.getResponseHeader("X-GraphDB-Error"),y.currentTabConfig.warningMessage=t.getResponseHeader("X-GraphDB-Warning"),Q.currentQuery=y.currentQuery,y.currentTabConfig.timeFinished=Date.now(),y.currentTabConfig.timeTook=(y.currentTabConfig.timeFinished-y.queryStartTime)/1e3,t.status>=400)return t.responseText=t.responseText.replace(/^([^: ]+: )+/,""),y.currentTabConfig.queryType="ERROR",a(),y.setYasrResponse(t,r,o),void y.setLoader(!1);if(0===t.status){y.currentTabConfig.queryType="ERROR";const e=R(-1,"Request was aborted","The request has been aborted. There are no results to show.");return Q.results={getException:function(){return e}},y.setLoader(!1),void x({customError:e},"",null)}let i;if(y.setLoader(!1),"update"===window.editor.getQueryMode())i=function(){l.getRepositorySize().success((function(e){let t;void 0!==y.repoSize&&(t=Number(e)-y.repoSize),y.currentTabConfig.sizeDelta=t,a()})).error((function(e){n.warning("Could not get repository size for: "+y.getActiveRepository()+"; "+getError(e)),y.currentTabConfig.sizeDelta=void 0,a()}))};else{if(200===t.status){const e=t.getResponseHeader("Content-Type");0!==e.indexOf("application/sparql-results+json")&&0!==e.indexOf("application/x-sparqlstar-results+json")&&0!==e.indexOf("application/x-graphdb-table-results+json")||t.responseJSON.results&&(y.currentTabConfig.resultsCount=t.responseJSON.results.bindings.length,t.responseJSON.results.bindings.length>y.currentTabConfig.pageSize&&(t.responseJSON.results.bindings.length=y.currentTabConfig.pageSize),y.currentTabConfig.allResultsCountExact||((y.nocount||y.countTimeouted||y.currentTabConfig.resultsCount<=y.currentTabConfig.pageSize)&&(t.status=204),y.currentTabConfig.allResultsCount=Math.max(y.currentTabConfig.allResultsCount,y.currentTabConfig.pageSize*(y.currentTabConfig.page-1)+y.currentTabConfig.resultsCount),y.currentTabConfig.resultsCount<=y.currentTabConfig.pageSize&&(y.currentTabConfig.allResultsCountExact=!0)))}y.setLoader(!0,"Rendering results",null,!0),i=function(){y.setYasrResponse(t,r,o),a(),y.setLoader(!1)}}e((function(){i(),"CONSTRUCT"!==window.editor.getQueryType()?($(".yasr_btnGroup.nav.nav-tabs li a.disabled").removeClass("disabled").css("font-weight","400"),$(".yasr_btnGroup.nav.nav-tabs li.disabled a").addClass("disabled").css("font-weight","200"),"DESCRIBE"===window.editor.getQueryType()&&$(".yasr_btnGroup.nav.nav-tabs li a").removeClass("disabled").css("font-weight","400")):"CONSTRUCT"===window.editor.getQueryType()&&$(".yasr_btnGroup.nav.nav-tabs li a.disabled").removeClass("disabled").css("font-weight","400"),$("#yasr").css("padding","0"),$(".yasr_btnGroup li:nth-child(2)").hasClass("active")&&e((function(){$(".yasr_btnGroup li:nth-child(2) a").get(0).click()}),100),$("#wb-sparql-addNewTab").click((function(){$(".dataTables_filter").hide(),$(".resultsTable").hide()}))}),100)},window.editor.options.sparql.handlers.resetResults=function(){},y.yasr=Q,y.setYasrResponse=function(e,t,n){e.responseJSON&&(e.response=e.responseJSON,e.responseText=void 0),Q.setResponse(e,t,n)},y.$watch("yasr.options.output",(function(e){if(e&&"UPDATE"!==y.currentTabConfig.queryType&&"ASK"!==y.currentTabConfig.queryType){const t=y.tabs[D(y.currentQuery.id)];angular.isDefined(t)&&y.currentTabConfig.queryType&&t.outputType!==e&&(t.outputType=y.currentQuery.outputType=e,y.saveTab(t.id))}})),void y.$watch("namespaces",(function(){y.namespaces&&(Q&&Q.options&&y.namespaces&&(Q.options.getUsedPrefixes=y.namespaces),o.a.signal(window.editor,"namespacesChanged",y.namespaces))})),$(document).mouseup((function(e){const t=$("#sampleQueriesCollapse");!t.is(e.target)&&0===t.has(e.target).length&&y.showSampleQueries&&y.toggleSampleQueries()})),r.getActiveRepository()&&B();y.$on("repositoryIsSet",(function(){r.getActiveRepository()&&B()})),e((function(){angular.element(document).find(".CodeMirror textarea:first-child").focus()}),50)}(y)}),150)}}}angular.module("graphdb.framework.core.directives.queryeditor.queryeditor",["ngCookies","graphdb.framework.externalsync.controllers","graphdb.framework.rest.connectors.service","graphdb.framework.utils.localstorageadapter"]).directive("queryEditor",s),s.$inject=["$timeout","$location","toastr","$repositories","SparqlRestService","ModalService","$modal","$jwtAuth","RDF4JRepositoriesRestService","ConnectorsRestService","LocalStorageAdapter","LSKeys"]}}]);
2
+ //# sourceMappingURL=10.e1e902adfd32b7c4a241.bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["webpack:///./src/js/angular/rest/connectors.rest.service.js","webpack:///./src/js/angular/externalsync/controllers.js","webpack:///./src/js/angular/core/directives/queryeditor/query-editor.controller.js","webpack:///./src/js/angular/core/directives/queryeditor/query-editor.directive.js"],"names":["angular","module","factory","ConnectorsRestService","$inject","CONNECTORS_ENDPOINT","$http","getConnectors","get","initConnector","prefix","hasConnector","checkConnector","data","post","headers","jsonToFormData","str","Object","keys","forEach","key","push","encodeURIComponent","join","mapCreateValuesToUiValues","values","options","i","length","option","__type","__name","j","__childOptions","child","k","valueK","hasOwnProperty","isDefined","__defaultValue","optionEl","isUndefined","map","_","value","String","toJson","_evaluateSparqlQuery","http","repository","query","buildNamePrefix","substring","createConnectorQuery","name","fields","reportError","fcopy","sortObject","obj","newObject","each","childOption","copy","arrayMap","reduce","acc","Error","fromJson","e","__label","message","removeEmptyValues","Array","isArray","filter","item","trim","finalString","replace","ConnectorsCtrl","$scope","$repositories","$modal","toastr","ModalService","$q","RDF4JRepositoriesRestService","resetProgress","repair","beingBuiltConnector","percentDone","status","processedEntities","estimatedEntities","indexedEntities","entitiesPerSecond","actionName","waitOnRepairStartOnce","eta","inline","iri","openProgressModal","$","extend","doneCallback","modalInstance","dismiss","open","templateUrl","controller","size","backdrop","scope","executeCreate","connector","errorCallback","modal","addStatements","getActiveRepository","update","then","res","existing","success","err","error","getError","finally","loader","controllers","definitions","getLoaderMessage","timeSeconds","Date","now","loaderStartTime","timeHuman","getHumanReadableSeconds","progressMessage","extraMessage","setLoader","isRunning","canWriteActiveRepo","connectors","all","connectorIris","createStatusQueryForAny","evaluateSparqlQuery","results","bindings","statusObject","JSON","parse","console","parseFirstBuildingResult","d","split","catch","getOptions","isEmpty","isObject","toPrettyJson","$watch","getActiveLocation","copyConnector","newValues","resolve","result","skipConversion","newConnector","inst","type","openSimpleModal","title","warning","delete","isExternal","indexOf","force","namePrefix","deleteConnectorQuery","viewQuery","DeleteConnectorCtrl","$modalInstance","ok","close","cancel","ExtendNewConnectorCtrl","toQuery","label","addField","index","optionName","newField","defaultValues","splice","addOption","array","deleteOption","addMapOption","deleteMapOption","form","$valid","CreateConnectorCtrl","$controller","this","CreateProgressCtrl","$interval","initProgress","statusIri","createStatusQueryForIri","progressInterval","getFirstStatusFromResult","toFixed","etaSeconds","$on","input","Math","ceil","QueryEditorCtrl","$timeout","SparqlRestService","$filter","$window","$jwtAuth","MonitoringRestService","LocalStorageAdapter","LSKeys","defaultTabConfig","id","inference","sameAs","checkQueryIntervalId","principal","getPrincipal","initTabs","appSettings","DEFAULT_INFERENCE","DEFAULT_SAMEAS","skipCountQuery","EXECUTE_COUNT","ignoreSharedQueries","IGNORE_SHARED_QUERIES","tabsData","tabs","TABS_STATE","$watchCollection","newVal","oldVal","saveQueryToLocal","currentQuery","deleteCachedSparqlResults","currentQueryTab","isActiveRepoOntopType","sameAsBtn","document","getElementById","disabled","removeAttribute","shouldDisableSameAs","tab","set","noTimer","yasrInnerContainer","element","queryIsRunning","queryStartTime","countTimeouted","noLoaderTimer","addClass","currentTrackAlias","abortRequested","removeClass","$$phase","$apply","fixSizesOnHorizontalViewModeSwitch","verticalView","visibleWindowHeight","window","innerHeight","documentElement","clientHeight","body","orientationViewMode","viewMode","newHeight","querySelector","getBoundingClientRect","style","height","noPadding","minHeight","paddingRight","paddingLeft","editor","timer","yasr","container","resize","showHideEditor","foo","params","newRepo","yasrData","undefined","queryType","resultsCount","allResultsCount","sizeDelta","errorMessage","repositoryError","selectTab","runQuery","changePage","explain","executedQueryTab","getQueryType","explainRequested","currentTabConfig","resetCurrentTabConfig","lastRunQueryMode","getQueryMode","toggleSampleQueries","showSampleQueries","getSavedQueries","sampleQueries","collapse","width","msg","getExistingTabId","existingTabId","showModal","modalSelector","shared","savedQuery","getValue","findTabIndexByID","currentScope","hint","createElement","innerHTML","fontSize","color","backgroundColor","position","zIndex","newValue","elRect","appendChild","top","left","right","offsetWidth","parentNode","removeChild","pageSize","page","queryExists","saveTab","idx","loadTab","setValue","updateDownloadDropdown","$broadcast","output","outputType","customError","getException","setYasrResponse","textStatus","jqXhrOrErrorString","hasClass","click","TABS_STATE_CURRENT_ID","offset","allResultsCountExact","timeFinished","timeTook","customUpdateMessage","warningMessage","css","setInterval","showOrHideSaveAsDropDown","isOntop","isFedX","isActiveRepoFedXType","inferenceBtn","handleSameAsAndInferenceBtns","nocount","overrideSameAsInferenceAndNoCountIfNeeded","addNewTab","callback","tabName","isTabChangeOk","maxID","newID","newTab","TABS_STATE_MAXID","callbackArgs","prototype","slice","call","arguments","apply","abortCurrentQuery","abortQueryByAlias","editQuery","edit","okButtonText","queryModal","addNewSavedQuery","deleteQueryHttp","editSavedQuery","getNamespaces","namespacesLoading","getRepositoryNamespaces","usedPrefixes","namespace","namespaces","changePagination","addKnownPrefixes","stringify","querySelected","tabId","highlightNextTabChange","deleteQuery","savedQueryName","deleteSavedQuery","saveQuery","saveQueryHttp","changeViewMode","VIEW_MODE","focusQueryEditor","find","is","focus","getActiveRepositoryNoError","onbeforeunload","clearInterval","mouseup","event","target","has","getQueryID","attr","$saveAsDropDown","queryValid","header","remove","isNew","info","tabEvent","relatedTarget","colors","times","highlightFun","editQueryModal","deleteQueryModal","saveQueryModal","getResultsDescription","desc","currentPageEnd","min","getUpdateDescription","abs","getStaleWarningMessage","secondsAgo","round","bind","unbind","QuerySampleModalCtrl","queryEditorDirective","$location","callbackOnChange","restrict","link","attrs","nostorage","notabs","notoolbar","notoolbarSaved","notoolbarCopy","notoolbarInference","notoolbarSameAs","nostatus","norun","runButtonName","saveQueryAction","runQueryAction","explainQueryAction","goToNextTabAction","goToPreviousTabAction","requestedTab","first","fromTextArea","persistent","indentUnit","createShareLink","cursorHeight","sparql","showQueryButton","acceptHeaderGraph","acceptHeaderSelect","extraKeys","toastBuildIndex","allowHtml","toastError","on","clearTimeout","changesTimeout","hasError","setTimeout","toggleClass","hide","afterCopy","blur","originalExecuteQuery","executeQuery","originalGetUrlArguments","getUrlArguments","createCustomError","statusText","responseText","connectorProgressModal","drawButtons","yasqe","buttons","config","qType","cm","resultsContainer","empty","performance","endpoint","args","thisTabConfig","thisTabId","handlers","countCallback","dataOrJqXhr","setResultsCount","allCount","getTime","setQueryLimit","getValueWithoutComments","doExecute","getRepositorySize","repoSize","parseInt","command","hasSupport","connectorName","pluginName","setNewTabState","progressScope","$new","originalGetAjaxConfig","getAjaxConfig","getResponseHeader","contentType","response","executedQueryTabIdx","queryResultState","toBoolean","v","loadQueryIntoExistingOrNewTab","infer","onHandler","search","execute","addTabWithQueryIfNeeded","owner","getSavedQuery","updateRepositoryAndSecurity","signal","getAuthToken","callbackOrConfig","copyToClipboardQuery","openCopyToClipboardModal","url","location","protocol","host","pathname","param","createQueryURL","copyToClipboardResult","resultURI","goToVisual","paramsToParse","path","getUsedPrefixes","persistency","getQueryResultsAsFormat","downloadFormat","$wbDownload","val","auth","localStorage","getItem","submit","complete","setNewTabStateForThis","updateResultsCallback","repoSizeDiff","Number","responseJSON","max","resetResults","setResponse","drawQueryEditor","directive"],"mappings":"uFAAAA,QACKC,OAAO,4CAA6C,IACpDC,QAAQ,wBAAyBC,GAEtCA,EAAsBC,QAAU,CAAC,SAEjC,MAAMC,EAAsB,kBAE5B,SAASF,EAAsBG,GAE3B,MAAO,CACHC,cAMJ,WACI,OAAOD,EAAME,IAAIH,IANjBI,cASJ,SAAuBC,GACnB,OAAOJ,EAAME,IAAI,GAAGH,oBAAsCK,MAT1DC,aAYJ,SAAsBD,GAClB,OAAOJ,EAAME,IAAI,GAAGH,qBAAuCK,MAZ3DE,eAeJ,SAAwBC,GACpB,OAAOP,EAAMQ,KAAK,GAAGT,UAA6BQ,EAAM,CACpDE,QAAS,CACL,eAAgB,oB,gCChChC,mBAiBA,SAASC,EAAeH,GACpB,MAAMI,EAAM,GAIZ,OAHAC,OAAOC,KAAKN,GAAMO,SAAQ,SAAUC,GAChCJ,EAAIK,KAAKC,mBAAmBF,GAAO,IAAME,mBAAmBV,EAAKQ,QAE9DJ,EAAIO,KAAK,KAwBpB,SAASC,EAA0BC,EAAQC,GACvC,IAAK,IAAIC,EAAI,EAAGA,EAAID,EAAQE,OAAQD,IAAK,CACrC,MAAME,EAASH,EAAQC,GACvB,GAAsB,gBAAlBE,EAAOC,OACFL,EAAOI,EAAOE,UACfN,EAAOI,EAAOE,QAAU,CAAC,UAE1B,GAAsB,gBAAlBF,EAAOC,OACd,GAAKL,EAAOI,EAAOE,QAcf,IAAK,IAAIC,EAAI,EAAGA,EAAIH,EAAOI,eAAeL,OAAQI,IAAK,CACnD,MAA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A,GAA8C,WAArCqE,EAAM8M,iBAAiBb,WAA+D,QAArCjM,EAAM8M,iBAAiBb,UAAqB,CACtG,MAAM7C,EAAMpJ,EAAMoI,KAAK4F,EAAiBhO,EAAM0I,aAAarB,KAEvDvO,QAAQuC,UAAU+N,IAAQpJ,EAAM8M,iBAAiBb,WAC7C7C,EAAIyG,aAAelU,IACnByN,EAAIyG,WAAa7P,EAAM0I,aAAamH,WAAalU,EACjDqE,EAAMsP,QAAQlG,EAAI/B,cAMlCrH,EAAMkD,OAAO,cAAc,WACnBlD,EAAMkT,aACF1H,GAAQA,EAAK/Q,SAAWuF,EAAMkT,aAE9B1H,EAAK/Q,QAAQsjB,gBAAkB/d,EAAMkT,YAIzC,IAAM4J,OAAOxS,OAAOgB,OAAQ,oBAAqBtL,EAAMkT,gBAYnE5T,EAAEyJ,UAAUwL,SAAQ,SAAUC,GAC1B,MAAM/I,EAAYnM,EAAE,2BACfmM,EAAUyI,GAAGM,EAAMC,SACsB,IAAvChJ,EAAUiJ,IAAIF,EAAMC,QAAQ9Z,QAC5BqF,EAAMmN,mBACTnN,EAAMkN,yBA8FVjP,EAAcqC,uBACduc,IAIJ7c,EAAMuG,IAAI,mBAAmB,WACrBtI,EAAcqC,uBACduc,OAMRjW,GAAS,WACL9N,QAAQ0Q,QAAQT,UAAUkL,KAAK,oCAAoCE,UACpE,IA1yBC+K,CAAgBlf,KACjB,OA7DXlH,QACKC,OAAO,4DAA6D,CACjE,YACA,6CACA,4CACA,gDAEHomB,UAAU,cAAe5I,GAE9BA,EAAqBrd,QAAU,CAAC,WAAY,YAAa,SAAU,gBAAiB,oBAAqB,eAAgB,SAAU,WAAY,+BAAgC,wBAAyB,sBAAuB","file":"10.e1e902adfd32b7c4a241.bundle.js","sourcesContent":["angular\n .module('graphdb.framework.rest.connectors.service', [])\n .factory('ConnectorsRestService', ConnectorsRestService);\n\nConnectorsRestService.$inject = ['$http'];\n\nconst CONNECTORS_ENDPOINT = 'rest/connectors';\n\nfunction ConnectorsRestService($http) {\n\n return {\n getConnectors,\n initConnector,\n hasConnector,\n checkConnector\n };\n\n function getConnectors() {\n return $http.get(CONNECTORS_ENDPOINT);\n }\n\n function initConnector(prefix) {\n return $http.get(`${CONNECTORS_ENDPOINT}/options?prefix=${prefix}`);\n }\n\n function hasConnector(prefix) {\n return $http.get(`${CONNECTORS_ENDPOINT}/existing?prefix=${prefix}`);\n }\n\n function checkConnector(data) {\n return $http.post(`${CONNECTORS_ENDPOINT}/check`, data, {\n headers: {\n 'Content-Type': 'text/plain'\n }\n });\n }\n}\n","import 'angular/rest/rdf4j.repositories.rest.service';\nimport 'angular/rest/connectors.rest.service';\n\nconst modules = [\n 'graphdb.framework.rest.rdf4j.repositories.service',\n 'graphdb.framework.rest.connectors.service'\n];\n\nangular\n .module('graphdb.framework.externalsync.controllers', modules)\n .controller('ConnectorsCtrl', ConnectorsCtrl)\n .controller('ExtendNewConnectorCtrl', ExtendNewConnectorCtrl)\n .controller('CreateConnectorCtrl', CreateConnectorCtrl)\n .controller('CreateProgressCtrl', CreateProgressCtrl)\n .controller('DeleteConnectorCtrl', DeleteConnectorCtrl)\n .filter('ceil', ceil);\n\nfunction jsonToFormData(data) {\n const str = [];\n Object.keys(data).forEach(function (key) {\n str.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]));\n });\n return str.join('&');\n}\n\nfunction toArrayMap(map) {\n return _.map(map, function (value, key) {\n return {key: key, value: value};\n });\n}\n\nfunction fromArrayMap(arrayMap) {\n return _.reduce(arrayMap, function (acc, value) {\n if (value.key === '' && value.value === '') {\n // empty pair, skip it\n } else if (value.key === '') {\n throw new Error('Key may not be empty with value \"' + value.value + '\"');\n } else if (acc.hasOwnProperty(value.key)) {\n throw new Error('Duplicate key ' + value.key);\n } else {\n acc[value.key] = value.value;\n }\n return acc;\n }, {});\n}\n\nfunction mapCreateValuesToUiValues(values, options) {\n for (let i = 0; i < options.length; i++) {\n const option = options[i];\n if (option.__type === 'StringArray') {\n if (!values[option.__name]) {\n values[option.__name] = [''];\n }\n } else if (option.__type === 'OptionArray') {\n if (!values[option.__name]) { // values has no entry for this option\n values[option.__name] = [];\n const optionEl = {};\n for (let j = 0; j < option.__childOptions.length; j++) {\n const child = option.__childOptions[j];\n if (child.__type === 'StringArray') {\n optionEl[child.__name] = [''];\n } else {\n optionEl[child.__name] = (!angular.isUndefined(child.__defaultValue) ? child.__defaultValue : '');\n }\n }\n values[option.__name].push(optionEl);\n } else { // values already has en entry for this option\n // Copies the default value for Boolean child options if no explicit value is set\n for (let j = 0; j < option.__childOptions.length; j++) {\n const child = option.__childOptions[j];\n if (child.__type === 'Boolean') {\n for (let k = 0; k < values[option.__name].length; k++) {\n const valueK = values[option.__name][k];\n if (!valueK.hasOwnProperty([child.__name]) && angular.isDefined(child.__defaultValue)) {\n valueK[child.__name] = child.__defaultValue;\n }\n }\n }\n }\n }\n } else if (option.__type === 'Map') {\n if (!values[option.__name]) {\n values[option.__name] = [];\n } else {\n values[option.__name] = toArrayMap(values[option.__name]);\n }\n } else if (option.__type === 'JsonString') {\n if (values[option.__name] && !(values[option.__name] instanceof String) && typeof values[option.__name] !== 'string') {\n values[option.__name] = angular.toJson(values[option.__name], 2);\n }\n } else {\n if (angular.isUndefined(values[option.__name])) {\n values[option.__name] = (!angular.isUndefined(option.__defaultValue) ? option.__defaultValue : '');\n }\n }\n }\n\n return values;\n}\n\nfunction _evaluateSparqlQuery(http, repository, query) {\n return http.post('repositories/' + repository, jsonToFormData({query: query}),\n {\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'Accept': 'application/sparql-results+json',\n 'X-GraphDB-Local-Consistency': 'updating'\n }\n });\n}\n\nfunction buildNamePrefix(prefix) {\n return prefix.substring(0, prefix.length - 1) + '/instance#';\n}\n\nfunction createConnectorQuery(name, prefix, fields, options, reportError) {\n // Returns a copy of the parameter obj sorted according to the order in options\n function sortObject(obj, options) {\n const newObject = {};\n _.each(options, function (option) {\n if (angular.isDefined(obj[option.__name])) {\n if (option.__type === 'OptionArray') {\n newObject[option.__name] = [];\n _.each(obj[option.__name], function (childOption) {\n newObject[option.__name].push(sortObject(childOption, option.__childOptions));\n });\n } else {\n newObject[option.__name] = angular.copy(obj[option.__name]);\n }\n }\n });\n return newObject;\n }\n\n const fcopy = sortObject(fields, options);\n\n for (let i = 0; i < options.length; i++) {\n try {\n if (options[i].__type === 'Map') {\n fcopy[options[i].__name] = fromArrayMap(fcopy[options[i].__name]);\n } else if (options[i].__type === 'JsonString') {\n fcopy[options[i].__name] = angular.fromJson(fcopy[options[i].__name]);\n }\n } catch (e) {\n reportError(options[i].__label, e.message);\n return null;\n }\n }\n\n removeEmptyValues(fcopy);\n //escapeValues(fields);\n let finalString = '';\n finalString += 'PREFIX :<' + prefix + '>\\n';\n const namePrefix = buildNamePrefix(prefix);\n finalString += 'PREFIX inst:<' + namePrefix + '>\\n';\n finalString += 'INSERT DATA {\\n';\n finalString += \"\\tinst:\" + name + \" :createConnector '''\\n\"; // eslint-disable-line quotes\n finalString += angular.toJson(fcopy, 2);\n finalString += \"\\n''' .\\n}\\n\"; // eslint-disable-line quotes\n finalString = finalString.replace(/\\\\/g, '\\\\\\\\\\\\');\n return finalString;\n}\n\nfunction createStatusQueryForIri(iri) {\n const statusIri = iri.replace(/\\/instance#.+$/, '#connectorStatus');\n let finalString = '';\n finalString += 'SELECT ?status {\\n';\n finalString += '\\t<' + iri + '> <' + statusIri + '> ?status';\n finalString += '\\n}';\n return finalString;\n}\n\nfunction createStatusQueryForAny(connectors) {\n const connectorIris = _.map(connectors,\n function (k) {\n return '<' + k.value + 'connectorStatus' + '>';\n }).join('|');\n\n if (connectorIris) {\n return 'SELECT ?connector ?status { ?connector ' + connectorIris + ' ?status }';\n }\n\n return null;\n}\n\nfunction repairConnectorQuery(name, prefix) {\n const namePrefix = buildNamePrefix(prefix);\n return 'PREFIX prefix:<' + prefix + '>\\n' +\n 'INSERT DATA {\\n' +\n '\\t<' + namePrefix + name + '> prefix:repairConnector \"\"\\n' +\n '}';\n}\n\nfunction deleteConnectorQuery(name, prefix, force) {\n const namePrefix = prefix.substring(0, prefix.length - 1) + \"/instance#\";\n return 'PREFIX prefix:<' + prefix + '>\\n' +\n 'INSERT DATA {\\n' +\n '\\t<' + namePrefix + name + '> prefix:dropConnector \"' + (force ? \"force\" : \"\") + '\"\\n' +\n '}';\n}\n\nfunction removeEmptyValues(data) {\n // remove empty values from array\n if (Array.isArray(data)) {\n data = _.filter(data, function (item) {\n return item !== null && (!item.trim || item.trim() !== '');\n });\n }\n // remove empty values from object values\n Object.keys(data).forEach(function (key) {\n if ((data[key] === '' || data[key] == null) && data[key] !== false) {\n delete data[key];\n } else if (typeof data[key] === 'object') {\n data[key] = removeEmptyValues(data[key]);\n }\n });\n return data;\n}\n\nfunction parseFirstBuildingResult(results) {\n if (results.bindings) {\n for (let i = 0; i < results.bindings.length; i++) {\n try {\n const statusObject = JSON.parse(results.bindings[i].status.value);\n if (statusObject.status === 'BUILDING') {\n return {\n connector: results.bindings[i].connector.value,\n status: statusObject\n };\n }\n } catch (e) {\n console.error(e); // eslint-disable-line no-console\n }\n }\n }\n\n return {};\n}\n\nConnectorsCtrl.$inject = ['$scope', '$http', '$repositories', '$modal', 'toastr', 'ModalService', '$q', 'RDF4JRepositoriesRestService', 'ConnectorsRestService'];\n\nfunction ConnectorsCtrl($scope, $http, $repositories, $modal, toastr, ModalService, $q, RDF4JRepositoriesRestService, ConnectorsRestService) {\n $scope.loader = false;\n\n $scope.controllers = [];\n\n $scope.existing = {};\n\n $scope.definitions = {};\n\n $scope.getLoaderMessage = function () {\n const timeSeconds = (Date.now() - $scope.loaderStartTime) / 1000;\n const timeHuman = $scope.getHumanReadableSeconds(timeSeconds);\n let message = '';\n if ($scope.progressMessage) {\n message = $scope.progressMessage + '... ' + timeHuman;\n } else {\n message = 'Running operation...' + timeHuman;\n }\n if ($scope.extraMessage && timeSeconds > 10) {\n message += '\\n' + $scope.extraMessage;\n }\n\n return message;\n };\n\n $scope.setLoader = function (isRunning, progressMessage, extraMessage) {\n if (isRunning) {\n $scope.loader = true;\n $scope.loaderStartTime = Date.now();\n $scope.progressMessage = progressMessage;\n $scope.extraMessage = extraMessage;\n } else {\n $scope.loader = false;\n $scope.progressMessage = '';\n $scope.extraMessage = '';\n }\n };\n\n $scope.initConnector = function (connector) {\n return ConnectorsRestService.initConnector(encodeURIComponent(connector.value))\n .then(function (res) {\n $scope.definitions[connector.key] = res.data;\n\n return ConnectorsRestService.hasConnector(encodeURIComponent(connector.value))\n .then(function (res) {\n $scope.existing[connector.key] = res.data;\n\n });\n });\n };\n\n $scope.getConnectors = function () {\n if (!$scope.canWriteActiveRepo()) {\n return;\n }\n\n $scope.setLoader(true, 'Fetching connectors', 'Normally this is a fast operation but it may take longer if a bigger repository needs to be initialised first.');\n\n ConnectorsRestService.getConnectors()\n .then(function (res) {\n $scope.connectors = Object.keys(res.data).map(function (key) {\n return {key: key, value: res.data[key]};\n });\n\n $q.all(_.map($scope.connectors, function (connector) {\n return $scope.initConnector(connector);\n })).finally(function () {\n resetProgress();\n\n const query = createStatusQueryForAny($scope.connectors);\n\n if (query) {\n evaluateSparqlQuery(query)\n .then(function (res) {\n const status = parseFirstBuildingResult(res.data.results);\n if (status.connector) {\n // has a building connector, open progress indicator\n const d = status.connector.split(/#/);\n d[0] = d[0].replace(/\\/instance$/, '#');\n showProgress(d[0], d[1]);\n }\n })\n .finally(function () {\n $scope.setLoader(false);\n });\n } else {\n $scope.setLoader(false);\n }\n });\n }).catch(function (e) {\n $scope.setLoader(false);\n toastr.error(getError(e), 'Could not get connectors');\n });\n\n $scope.existing = {};\n };\n\n $scope.getOptions = function (connector) {\n return $scope.definitions[connector.key];\n };\n\n $scope.isEmpty = function (value) {\n return angular.isObject(value) && Object.keys(value).length === 0;\n };\n\n $scope.toPrettyJson = function (value) {\n return angular.toJson(value, 2);\n };\n\n $scope.$watch(function () {\n return $repositories.getActiveRepository();\n }, $scope.getConnectors);\n\n $scope.$watch(function () {\n return $repositories.getActiveLocation();\n }, $scope.getConnectors);\n\n function evaluateSparqlQuery(query) {\n return _evaluateSparqlQuery($http, $repositories.getActiveRepository(), query);\n }\n\n function resetProgress(repair) {\n $scope.beingBuiltConnector = {\n percentDone: 0,\n status: {\n processedEntities: 0,\n estimatedEntities: 0,\n indexedEntities: 0,\n entitiesPerSecond: 0\n },\n actionName: repair ? 'Repairing' : 'Creating',\n waitOnRepairStartOnce: !!repair,\n eta: '-',\n inline: false,\n iri: null\n };\n }\n\n function openProgressModal(prefix, name, repair) {\n resetProgress(repair);\n\n $.extend($scope.beingBuiltConnector, {\n iri: buildNamePrefix(prefix) + name,\n name: name,\n inline: false,\n doneCallback: function () {\n $scope.beingBuiltConnector.modalInstance.dismiss('cancel');\n }\n });\n\n $scope.beingBuiltConnector.modalInstance = $modal.open({\n templateUrl: 'pages/connectorProgress.html',\n controller: 'CreateProgressCtrl',\n size: 'lg',\n backdrop: 'static',\n scope: $scope\n });\n\n return $scope.beingBuiltConnector.modalInstance;\n }\n\n function showProgress(prefix, name) {\n resetProgress();\n\n $.extend($scope.beingBuiltConnector, {\n iri: buildNamePrefix(prefix) + name,\n name: name,\n inline: true,\n doneCallback: function () {\n $scope.beingBuiltConnector.inline = false;\n }\n });\n }\n\n function executeCreate(connector, obj, errorCallback) {\n const modal = openProgressModal(connector.value, obj.name, false);\n RDF4JRepositoriesRestService.addStatements($repositories.getActiveRepository(), jsonToFormData({update: obj.query}))\n .then(function () {\n ConnectorsRestService.getConnectors().then(function () {\n ConnectorsRestService.hasConnector(encodeURIComponent(connector.value)).then(function (res) {\n $scope.existing[connector.key] = res.data;\n });\n });\n toastr.success('Created connector ' + obj.name);\n }, function (err) {\n toastr.error(getError(err));\n errorCallback();\n }).finally(function () {\n modal.dismiss('cancel');\n });\n }\n\n $scope.copyConnector = function (connector, values) {\n let newValues;\n if (!angular.isUndefined(values)) {\n newValues = angular.copy(values);\n newValues.name = newValues.name + '-copy';\n }\n const modal = $modal.open({\n templateUrl: 'pages/createConnector.html',\n controller: 'CreateConnectorCtrl',\n size: 'lg',\n backdrop: 'static',\n resolve: {\n connector: function () {\n return connector;\n },\n values: function () {\n return angular.isUndefined(newValues) ? {name: '', values: {}} : newValues;\n },\n options: function () {\n return $scope.getOptions(connector);\n }\n }\n });\n\n modal.result.then(function (obj) {\n executeCreate(connector, obj, function () {\n obj.skipConversion = true;\n $scope.newConnector(connector, obj);\n });\n });\n };\n\n $scope.newConnector = function (connector, values) {\n const modal = $modal.open({\n templateUrl: 'pages/createConnector.html',\n controller: 'CreateConnectorCtrl',\n size: 'lg',\n backdrop: 'static',\n resolve: {\n connector: function () {\n return connector;\n },\n values: function () {\n return angular.isUndefined(values) ? {name: '', values: {}} : values;\n },\n options: function () {\n return $scope.getOptions(connector);\n }\n }\n });\n\n modal.result.then(function (obj) {\n executeCreate(connector, obj, function () {\n obj.skipConversion = true;\n $scope.newConnector(connector, obj);\n });\n });\n };\n\n $scope.repair = function (inst, type) {\n ModalService.openSimpleModal({\n title: 'Confirm repair',\n message: 'Are you sure you want to repair this connector?<br>Note that repair means delete + recreate with the same settings.',\n warning: true\n }).result\n .then(function () {\n const modal = openProgressModal(type.value, inst.name, true);\n\n const query = repairConnectorQuery(inst.name, type.value);\n\n RDF4JRepositoriesRestService.addStatements($repositories.getActiveRepository(), jsonToFormData({update: query}))\n .then(function () {\n ConnectorsRestService.getConnectors().then(function () {\n ConnectorsRestService.hasConnector(encodeURIComponent(type.value)).then(function (res) {\n $scope.existing[type.key] = res.data;\n });\n });\n toastr.success('Repaired connector ' + inst.name);\n }, function (err) {\n toastr.error(getError(err));\n }).finally(function () {\n modal.dismiss('cancel');\n });\n });\n };\n\n $scope.delete = function (inst, type) {\n const isExternal = type.key.indexOf(\"Elastic\") >= 0 || type.key.indexOf(\"Solr\") >= 0;\n\n $modal.open({\n templateUrl: 'js/angular/externalsync/templates/deleteConnector.html',\n controller: 'DeleteConnectorCtrl',\n resolve: {\n type: function () {\n return type.key;\n },\n isExternal: function () {\n return isExternal;\n }\n }\n }).result\n .then(function(force) {\n $scope.setLoader(true, 'Deleting connector ' + inst.name, 'This is usually a fast operation but it might take a while.');\n\n const query = deleteConnectorQuery(inst.name, type.value, force);\n RDF4JRepositoriesRestService.addStatements($repositories.getActiveRepository(), jsonToFormData({update: query}))\n .then(function () {\n ConnectorsRestService.getConnectors().then(function () {\n ConnectorsRestService.hasConnector(encodeURIComponent(type.value)).then(function (res) {\n $scope.existing[type.key] = res.data;\n });\n });\n if (force) {\n toastr.success(\"Deleted (with force) connector \" + inst.name);\n if (isExternal) {\n toastr.warning(\"You may have to remove the index manually from \" + type.key);\n }\n } else {\n toastr.success(\"Deleted connector \" + inst.name);\n }\n }, function (err) {\n toastr.error(getError(err));\n }).finally(function() {\n $scope.setLoader(false);\n });\n });\n };\n\n $scope.viewQuery = function (connector, inst) {\n $modal.open({\n templateUrl: 'pages/viewQuery.html',\n controller: 'ViewQueryCtrl',\n resolve: {\n query: function () {\n const options = $scope.getOptions(connector);\n return createConnectorQuery(inst.name, connector.value,\n mapCreateValuesToUiValues(inst.values, options), options);\n }\n }\n });\n };\n}\n\nDeleteConnectorCtrl.$inject = ['$scope', '$modalInstance', 'type', 'isExternal'];\nfunction DeleteConnectorCtrl($scope, $modalInstance, type, isExternal) {\n $scope.force = false;\n $scope.type = type;\n $scope.isExternal = isExternal;\n\n $scope.ok = function () {\n $modalInstance.close($scope.force);\n };\n\n $scope.cancel = function () {\n $modalInstance.dismiss();\n };\n}\n\nExtendNewConnectorCtrl.$inject = ['$scope', '$modalInstance', 'connector', '$modal', 'toastr'];\nfunction ExtendNewConnectorCtrl($scope, $modalInstance, connector, $modal, toastr) {\n\n $scope.connector = connector;\n\n $scope.addField = function (index, optionName) {\n const newField = angular.copy($scope.defaultValues[optionName][0]);\n $scope.values[optionName].splice(index + 1, 0, newField);\n };\n\n $scope.addOption = function (index, array) {\n array.splice(index + 1, 0, '');\n };\n\n $scope.deleteOption = function (index, array) {\n array.splice(index, 1);\n };\n\n $scope.addMapOption = function (index, array) {\n array.splice(index + 1, 0, {key: '', value: ''});\n };\n\n $scope.deleteMapOption = function (index, array) {\n array.splice(index, 1);\n };\n\n function toQuery() {\n return createConnectorQuery($scope.name, connector.value, $scope.values, $scope.options,\n function (label, error) {\n toastr.error(error, label);\n });\n }\n\n $scope.ok = function () {\n if ($scope.form.$valid) {\n const query = toQuery();\n\n if (query) {\n $modalInstance.close({name: $scope.name, values: $scope.values, options: $scope.options, query: query});\n }\n }\n };\n\n $scope.viewQuery = function () {\n const query = toQuery();\n\n if (query) {\n $modal.open({\n templateUrl: 'pages/viewQuery.html',\n controller: 'ViewQueryCtrl',\n resolve: {\n query: function () {\n return query;\n }\n }\n });\n }\n };\n\n $scope.cancel = function () {\n $modalInstance.dismiss('cancel');\n };\n}\n\nCreateConnectorCtrl.$inject = ['$scope', '$controller', '$http', '$modalInstance', 'connector', '$modal', 'values', 'options'];\n\nfunction CreateConnectorCtrl($scope, $controller, $http, $modalInstance, connector, $modal, values, options) {\n angular.extend(this, $controller('ExtendNewConnectorCtrl', {\n $scope: $scope,\n $modalInstance: $modalInstance,\n connector: connector,\n $modal: $modal\n }));\n $scope.values = values.values;\n $scope.options = options;\n $scope.name = values.name;\n if (!values.skipConversion) {\n $scope.values = mapCreateValuesToUiValues($scope.values, $scope.options);\n }\n $scope.defaultValues = angular.copy($scope.values);\n}\n\n// Note that this is a fancy controller: it's used both for a modal and for a directive.\n// This means you can't rely on custom injection through resolve in the modal and the scope\n// must be shared with the main connectors controller.\nCreateProgressCtrl.$inject = ['$scope', '$interval', '$http', '$repositories'];\n\nfunction CreateProgressCtrl($scope, $interval, $http, $repositories) {\n function evaluateSparqlQuery(query) {\n return _evaluateSparqlQuery($http, $repositories.getActiveRepository(), query);\n }\n\n function initProgress() {\n const query = createStatusQueryForIri($scope.beingBuiltConnector.iri);\n\n // reset iri value so that watch will fire again when we do something with the same connector\n $scope.beingBuiltConnector.iri = null;\n\n $scope.progressInterval = $interval(function () {\n function getFirstStatusFromResult(results) {\n if (results.bindings) {\n if (results.bindings.length > 0) {\n try {\n return JSON.parse(results.bindings[0].status.value);\n } catch (e) {\n console.error(e); // eslint-disable-line no-console\n }\n }\n }\n\n return {};\n }\n\n evaluateSparqlQuery(query)\n .then(function (res) {\n const status = getFirstStatusFromResult(res.data.results);\n if (status.status === 'BUILDING') {\n $scope.beingBuiltConnector.status = status;\n $scope.beingBuiltConnector.percentDone = (100 * status.processedEntities / status.estimatedEntities).toFixed(0);\n $scope.beingBuiltConnector.eta = $scope.getHumanReadableSeconds(status.etaSeconds);\n $scope.beingBuiltConnector.actionName = status.repair ? 'Repairing' : 'Creating';\n $scope.beingBuiltConnector.waitOnRepairStartOnce = false;\n } else if (status.status === 'BUILT' && !$scope.beingBuiltConnector.waitOnRepairStartOnce) {\n // done\n $interval.cancel($scope.progressInterval);\n if ($scope.beingBuiltConnector.doneCallback) {\n $scope.beingBuiltConnector.doneCallback();\n }\n }\n });\n }, 1000);\n\n $scope.$on('$destroy', function () {\n $interval.cancel($scope.progressInterval);\n });\n }\n\n $scope.beingBuiltConnector = $scope.beingBuiltConnector || {};\n\n // for modal instance we get the iri before hand and can start progress now\n if (!$scope.beingBuiltConnector.inline && $scope.beingBuiltConnector.iri) {\n initProgress();\n }\n\n // for inline progress we need to watch for the iri value\n $scope.$watch('beingBuiltConnector.iri', function (value) {\n if ($scope.beingBuiltConnector.inline && value) {\n initProgress();\n }\n });\n}\n\nfunction ceil() {\n return function (input) {\n return Math.ceil(input);\n };\n}\n","import 'angular/utils/local-storage-adapter';\nimport 'angular/rest/sparql.rest.service';\n\nangular\n .module('graphdb.framework.core.directives.queryeditor.controllers', [\n 'graphdb.framework.utils.localstorageadapter',\n 'graphdb.framework.rest.sparql.service'\n ])\n .controller('QueryEditorCtrl', QueryEditorCtrl)\n .controller('QuerySampleModalCtrl', QuerySampleModalCtrl);\n\nQueryEditorCtrl.$inject = ['$scope', '$timeout', 'toastr', '$repositories', '$modal', 'ModalService', 'SparqlRestService', '$filter', '$window', '$jwtAuth', 'RDF4JRepositoriesRestService', 'MonitoringRestService', 'LocalStorageAdapter', 'LSKeys'];\n\nfunction QueryEditorCtrl($scope, $timeout, toastr, $repositories, $modal, ModalService, SparqlRestService, $filter, $window, $jwtAuth, RDF4JRepositoriesRestService, MonitoringRestService, LocalStorageAdapter, LSKeys) {\n const defaultTabConfig = {\n id: \"1\",\n name: '',\n query: 'select * where { \\n' +\n '\\t?s ?p ?o .\\n' +\n '} limit 100 \\n',\n inference: true,\n sameAs: true\n };\n\n let principal = $jwtAuth.getPrincipal();\n let checkQueryIntervalId;\n if (principal) {\n initTabs($scope, principal);\n // principal is not yet set, wait for its initialization\n } else {\n $scope.$on('securityInit', function (scope) {\n principal = $jwtAuth.getPrincipal();\n initTabs(scope.currentScope, principal);\n });\n }\n\n function initTabs(scope, principal) {\n defaultTabConfig.inference = principal.appSettings.DEFAULT_INFERENCE;\n defaultTabConfig.sameAs = principal.appSettings.DEFAULT_SAMEAS;\n\n scope.skipCountQuery = !principal.appSettings.EXECUTE_COUNT;\n scope.ignoreSharedQueries = principal.appSettings.IGNORE_SHARED_QUERIES;\n scope.tabsData = scope.tabs = LocalStorageAdapter.get(LSKeys.TABS_STATE) || [defaultTabConfig];\n\n scope.$watchCollection('[currentQuery.inference, currentQuery.sameAs]', function (newVal, oldVal, scope) {\n saveQueryToLocal(scope.currentQuery);\n });\n\n scope.$on('repositoryIsSet', deleteCachedSparqlResults);\n }\n\n this.hint = document.createElement(\"span\");\n this.hint.innerHTML = \"Hint: \\\"abC\\\" matches \\\"abC*\\\", \\\"ab c*\\\" and \\\"ab-c*\\\"\";\n this.hint.style.fontSize = \"12px\";\n this.hint.style.color = \"gray\";\n this.hint.style.backgroundColor = \"white\";\n this.hint.style.position = \"absolute\";\n this.hint.style.zIndex = \"3\";\n this.hint.style.paddingLeft = 12 + \"px\";\n\n $scope.$watch(function() {\n return angular.element('.CodeMirror-hints').length;\n }, (newValue) => {\n if (newValue) {\n const elRect = angular.element('.CodeMirror-hints')[0].getBoundingClientRect();\n document.body.appendChild(this.hint);\n this.hint.style.top = elRect.top - 20 + \"px\";\n this.hint.style.left = elRect.right - this.hint.offsetWidth - 12 + \"px\";\n } else {\n this.hint && this.hint.parentNode && this.hint.parentNode.removeChild(this.hint);\n }\n });\n\n $scope.resetCurrentTabConfig = function () {\n $scope.currentTabConfig = {\n pageSize: 1000,\n page: 1,\n allResultsCount: 0,\n resultsCount: 0\n };\n };\n\n $scope.queryExists = false;\n\n $scope.resetCurrentTabConfig();\n\n // query tab operations\n $scope.saveTab = saveTab;\n $scope.loadTab = loadTab;\n $scope.addNewTab = addNewTab;\n $scope.isTabChangeOk = isTabChangeOk;\n\n // query operations\n $scope.runQuery = runQuery;\n $scope.abortCurrentQuery = abortCurrentQuery;\n $scope.editQuery = editQuery;\n $scope.getNamespaces = getNamespaces;\n $scope.changePagination = changePagination;\n $scope.toggleSampleQueries = toggleSampleQueries;\n $scope.addKnownPrefixes = addKnownPrefixes;\n $scope.getExistingTabId = getExistingTabId;\n $scope.querySelected = querySelected;\n $scope.deleteQuery = deleteQuery;\n $scope.deleteQueryHttp = deleteQueryHttp;\n $scope.saveQuery = saveQuery;\n $scope.saveQueryHttp = saveQueryHttp;\n $scope.saveQueryToLocal = saveQueryToLocal;\n\n $scope.setLoader = setLoader;\n $scope.getLoaderMessage = getLoaderMessage;\n\n // query editor and results orientation\n $scope.fixSizesOnHorizontalViewModeSwitch = fixSizesOnHorizontalViewModeSwitch;\n $scope.changeViewMode = changeViewMode;\n $scope.showHideEditor = showHideEditor;\n $scope.focusQueryEditor = focusQueryEditor;\n $scope.orientationViewMode = LocalStorageAdapter.get(LSKeys.VIEW_MODE) ? LocalStorageAdapter.get(LSKeys.VIEW_MODE) === \"true\" : true;\n $scope.viewMode = 'none';\n\n // start of repository actions\n // FIXME: do we need this??\n // $scope.getActiveRepository();\n $scope.getActiveRepository = function () {\n // same as getActiveRepository() but takes into account repo errors\n return $repositories.getActiveRepository();\n };\n\n $scope.getActiveRepositoryNoError = function () {\n if (!$scope.repositoryError) {\n return $repositories.getActiveRepository();\n }\n };\n\n function saveQueryToLocal(currentQueryTab) {\n shouldDisableSameAs();\n $scope.tabs.forEach(function (tab, index) {\n if (tab.id === currentQueryTab.id) {\n $scope.tabs[index].query = currentQueryTab.query;\n // Don't store inference and sameAs values for Ontop repository,\n // because they are overridden afterwards to true\n if (!$repositories.isActiveRepoOntopType()) {\n $scope.tabs[index].inference = currentQueryTab.inference;\n $scope.tabs[index].sameAs = currentQueryTab.sameAs;\n }\n }\n });\n LocalStorageAdapter.set(LSKeys.TABS_STATE, $scope.tabs);\n }\n\n function setLoader(isRunning, progressMessage, extraMessage, noTimer) {\n const yasrInnerContainer = angular.element(document.getElementById(\"yasr-inner\"));\n $scope.queryIsRunning = isRunning;\n if (isRunning) {\n $scope.queryStartTime = Date.now();\n $scope.countTimeouted = false;\n $scope.progressMessage = progressMessage;\n $scope.extraMessage = extraMessage;\n $scope.noLoaderTimer = noTimer;\n yasrInnerContainer.addClass(\"hide\");\n } else {\n $scope.progressMessage = \"\";\n $scope.extraMessage = \"\";\n $scope.noLoaderTimer = false;\n $scope.currentTrackAlias = null;\n $scope.abortRequested = false;\n yasrInnerContainer.removeClass(\"hide\");\n }\n // We might call this from angular or outside angular so take care of applying the scope.\n if ($scope.$$phase === null) {\n $scope.$apply();\n }\n }\n\n function getLoaderMessage() {\n const timeSeconds = (Date.now() - $scope.queryStartTime) / 1000;\n let timeHuman = \"\";\n let message = \"\";\n\n if (!$scope.noLoaderTimer) {\n timeHuman = $scope.getHumanReadableSeconds(timeSeconds);\n }\n\n if ($scope.progressMessage) {\n message = $scope.progressMessage + \"... \" + timeHuman;\n } else {\n message = \"Running operation... \" + timeHuman;\n }\n if ($scope.extraMessage && timeSeconds > 10) {\n message += \"\\n\" + $scope.extraMessage;\n }\n\n return message;\n }\n\n // start of query editor results orientation operations\n function fixSizesOnHorizontalViewModeSwitch(verticalView) {\n function visibleWindowHeight() {\n return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0;\n }\n\n if (!$scope.orientationViewMode) {\n $scope.noPadding = {paddingRight: 15, paddingLeft: 0};\n\n // window.editor is undefined if no repo is selected\n if (window.editor && document.querySelector('.CodeMirror-wrap')) {\n let newHeight = visibleWindowHeight() - (document.querySelector('.CodeMirror-wrap').getBoundingClientRect().top);\n newHeight -= 40;\n document.querySelector('.CodeMirror-wrap').style.height = newHeight + 'px';\n document.getElementById('yasr').style.minHeight = newHeight + 'px';\n //window.editor.refresh();\n } else {\n let timer;\n if (verticalView) {\n timer = $timeout(function () {\n $scope.fixSizesOnHorizontalViewModeSwitch(verticalView);\n }, 100);\n } else {\n timer = $timeout($scope.fixSizesOnHorizontalViewModeSwitch, 100);\n }\n\n $scope.$on(\"$destroy\", function () {\n $timeout.cancel(timer);\n });\n }\n } else {\n if ($scope.viewMode === 'yasr') {\n let newHeight = visibleWindowHeight() - (document.querySelector('.CodeMirror-wrap').getBoundingClientRect().top);\n newHeight -= 40;\n document.querySelector('.CodeMirror-wrap').style.height = newHeight + 'px';\n //window.editor.refresh();\n } else {\n $scope.noPadding = {};\n document.querySelector('.CodeMirror-wrap').style.height = '';\n //window.editor.refresh();\n }\n document.getElementById('yasr').style.minHeight = '';\n }\n if (window.yasr && window.yasr.container) {\n $timeout(function () {\n window.yasr.container.resize();\n }, 100);\n }\n }\n\n if (!$scope.orientationViewMode) {\n showHideEditor();\n }\n\n function changeViewMode() {\n $scope.viewMode = 'none';\n $scope.orientationViewMode = !$scope.orientationViewMode;\n LocalStorageAdapter.set(LSKeys.VIEW_MODE, $scope.orientationViewMode);\n fixSizesOnHorizontalViewModeSwitch();\n }\n\n function showHideEditor() {\n fixSizesOnHorizontalViewModeSwitch(true);\n }\n\n function focusQueryEditor() {\n if (!angular.element(document).find('.editable-input').is(\":focus\")) {\n angular.element(document).find('.CodeMirror textarea:first-child').focus();\n }\n }\n\n // end of query editor results orientation operations\n\n function deleteCachedSparqlResults(foo, params) {\n if (params.newRepo) {\n $scope.tabsData = LocalStorageAdapter.get(LSKeys.TABS_STATE);\n $scope.tabsData.forEach(function (item) {\n item.yasrData = undefined;\n item.queryType = undefined;\n item.resultsCount = 0;\n item.allResultsCount = 0;\n item.sizeDelta = undefined;\n });\n\n LocalStorageAdapter.set(LSKeys.TABS_STATE, $scope.tabsData);\n $scope.tabs = $scope.tabsData;\n\n // The repository is changed. Remove error messages as well, if any\n $scope.currentQuery = {};\n $scope.errorMessage = null;\n $scope.repositoryError = null;\n }\n }\n\n function selectTab(id) {\n $timeout(function () {\n $('a[data-id = \"' + id + '\"]').tab('show');\n }, 0);\n }\n\n window.onbeforeunload = function () {\n if ($scope.currentQuery) {\n $scope.saveTab($scope.currentQuery.id);\n }\n LocalStorageAdapter.set(LSKeys.TABS_STATE, $scope.tabs);\n };\n\n $scope.$on('$destroy', function () {\n if ($scope.currentQuery) {\n $scope.saveTab($scope.currentQuery.id);\n }\n LocalStorageAdapter.set(LSKeys.TABS_STATE, $scope.tabs);\n clearInterval(checkQueryIntervalId);\n });\n\n // start of query operations\n function runQuery(changePage, explain) {\n $scope.executedQueryTab = $scope.currentQuery;\n if (explain) {\n if (!(window.editor.getQueryType() === 'SELECT' || window.editor.getQueryType() === 'CONSTRUCT')) {\n toastr.warning('Explain only works with SELECT or CONSTRUCT queries.');\n return;\n }\n\n if ($repositories.isActiveRepoOntopType()) {\n toastr.warning('Explain not supported for Virtual repositories.');\n return;\n }\n }\n\n $scope.explainRequested = explain;\n if (!$scope.queryIsRunning) {\n if (changePage) {\n $scope.currentTabConfig.resultsCount = 0;\n } else {\n $scope.resetCurrentTabConfig();\n }\n\n $scope.lastRunQueryMode = window.editor.getQueryMode();\n\n if ($scope.lastRunQueryMode === 'update' && $repositories.isActiveRepoOntopType()) {\n toastr.warning('Updates are not supported for Virtual repositories.');\n return;\n }\n\n setLoader(true, $scope.lastRunQueryMode === 'update' ? 'Executing update' : 'Evaluating query');\n if ($scope.viewMode !== 'none') {\n $scope.viewMode = 'none';\n if ($scope.orientationViewMode) {\n $scope.fixSizesOnHorizontalViewModeSwitch();\n }\n const timer = $timeout(window.editor.query, 500);\n $scope.$on('$destroy', function () {\n $timeout.cancel(timer);\n });\n } else {\n window.editor.query();\n }\n }\n }\n\n function abortCurrentQuery() {\n MonitoringRestService.abortQueryByAlias($scope.currentTrackAlias)\n .success(function () {\n $scope.abortRequested = true;\n });\n }\n\n function getNamespaces() {\n // Signals the namespaces are to be fetched => loader will be shown\n setLoader(true, 'Refreshing namespaces', 'Normally this is a fast operation but it may take longer if a bigger repository needs to be initialised first.');\n $scope.namespacesLoading = true;\n\n RDF4JRepositoriesRestService.getRepositoryNamespaces()\n .success(function (data) {\n const usedPrefixes = {};\n data.results.bindings.forEach(function (e) {\n usedPrefixes[e.prefix.value] = e.namespace.value;\n });\n $scope.namespaces = usedPrefixes;\n })\n .error(function (data) {\n $scope.repositoryError = getError(data);\n })\n .finally(function () {\n // Signals namespaces were fetched => loader will be hidden\n setLoader(false);\n $scope.namespacesLoading = false;\n });\n }\n\n function changePagination() {\n runQuery(true, $scope.explainRequested);\n }\n\n $scope.$on(\"$destroy\", function () {\n clearInterval(checkQueryIntervalId);\n window.editor = null;\n window.yasr = null;\n });\n\n function toggleSampleQueries() {\n $scope.showSampleQueries = !$scope.showSampleQueries;\n if ($scope.showSampleQueries) {\n SparqlRestService.getSavedQueries()\n .success(function (data) {\n $scope.sampleQueries = data;\n $('#sampleQueriesCollapse').collapse('show').width('300px');\n })\n .error(function (data) {\n const msg = getError(data);\n toastr.error(msg, 'Error! Could not get saved queries');\n });\n } else {\n $('#sampleQueriesCollapse').collapse('hide');\n }\n }\n\n // Hide the sample queries when the user clicks somewhere else in the UI.\n $(document).mouseup(function (event) {\n const container = $('#sampleQueriesCollapse');\n if (!container.is(event.target) // if the target of the click isn't the container..\n && container.has(event.target).length === 0 //... nor a descendant of the container\n && $scope.showSampleQueries) {\n toggleSampleQueries();\n }\n });\n\n // Add known prefixes\n function addKnownPrefixes() {\n SparqlRestService.addKnownPrefixes(JSON.stringify(window.editor.getValue()))\n .success(function (data) {\n if (angular.isDefined(window.editor) && angular.isDefined(data) && data !== window.editor.getValue()) {\n window.editor.setValue(data);\n }\n })\n .error(function (data) {\n const msg = getError(data);\n toastr.error(msg, 'Error! Could not add known prefixes');\n return true;\n });\n }\n\n function querySelected(query) {\n const tabId = getExistingTabId(query);\n $scope.toggleSampleQueries();\n\n if ($scope.isTabChangeOk(false)) {\n $scope.highlightNextTabChange = true;\n if (!angular.isDefined(tabId)) {\n $scope.addNewTab(null, query.name, query.body);\n } else {\n selectTab(tabId);\n }\n }\n }\n\n function getExistingTabId(query) {\n let existingTabId = undefined;\n $scope.tabsData.forEach(function (item) {\n if (item.name === query.name && item.query === query.body) {\n existingTabId = item.id;\n return item;\n }\n });\n return existingTabId;\n }\n\n function editQuery(query) {\n const modalInstance = $modal.open({\n templateUrl: 'js/angular/core/directives/queryeditor/templates/query-sample.html',\n controller: 'QuerySampleModalCtrl',\n resolve: {\n data: function () {\n return {\n title: 'Edit Saved Query: \"' + query.name + '\"',\n query: query,\n edit: true,\n okButtonText: 'Save'\n };\n }\n }\n });\n\n modalInstance.result.then(function (queryModal) {\n const data = {\n name: queryModal.name,\n body: queryModal.body,\n shared: queryModal.shared\n };\n if (query.name !== queryModal.name) {\n SparqlRestService.addNewSavedQuery(data)\n .success(function () {\n $scope.deleteQueryHttp(query.name, true);\n })\n .error(function (error) {\n const msg = getError(error);\n toastr.error(msg, 'Error! Cannot edit saved query');\n });\n } else {\n SparqlRestService.editSavedQuery(data)\n .success(function () {\n $('#editQueryContainer').modal('hide');\n $scope.toggleSampleQueries();\n toastr.success('Saved query ' + query.name + ' was edited.');\n })\n .error(function (error) {\n const msg = getError(error);\n toastr.error(msg, 'Error! Cannot edit Saved query');\n });\n }\n });\n }\n\n function deleteQueryHttp(savedQueryName, edit) {\n SparqlRestService.deleteSavedQuery(savedQueryName)\n .success(function () {\n $scope.toggleSampleQueries();\n if (!edit) {\n toastr.success('Saved query: ' + savedQueryName + ' was deleted.');\n }\n })\n .error(function (data) {\n const msg = getError(data);\n toastr.error(msg, 'Error! Cannot delete saved query');\n });\n }\n\n function deleteQuery(savedQueryName) {\n ModalService.openSimpleModal({\n title: 'Confirm',\n message: 'Are you sure you want to delete the saved query ' + '\\'' + savedQueryName + '\\'?',\n warning: true\n }).result\n .then(function () {\n $scope.deleteQueryHttp(savedQueryName);\n });\n }\n\n function saveQueryHttp(query) {\n SparqlRestService.addNewSavedQuery(query)\n .success(function () {\n toastr.success('Saved query ' + query.name + ' was saved.');\n })\n .error(function (data) {\n let msg = getError(data);\n toastr.error(msg, 'Error! Cannot create saved query');\n // TODO: This condition will always be true\n if (msg = \"Query '\" + query.name + \"' already exists!\") {\n query.query = query.body;\n const queryExists = true;\n $scope.saveQuery(query, queryExists);\n }\n });\n }\n\n function saveQuery(query, queryExists) {\n const modalInstance = $modal.open({\n templateUrl: 'js/angular/core/directives/queryeditor/templates/query-sample.html',\n controller: 'QuerySampleModalCtrl',\n resolve: {\n data: function () {\n return {\n title: 'Create New Saved Query',\n query: {name: query.name, body: query.query, shared: query.shared},\n edit: false,\n okButtonText: 'Create',\n queryExists: queryExists\n };\n }\n }\n });\n\n modalInstance.result.then(function (query) {\n $scope.saveQueryHttp(query);\n }, function () {\n });\n }\n\n // end of query operations\n\n function showModal(modalSelector) {\n return function (name, query, shared) {\n $scope.savedQuery = {\n name: name,\n query: query || window.editor.getValue(),\n shared: shared\n };\n $(modalSelector).modal('show');\n };\n }\n\n\n // start of query tab operations\n function findTabIndexByID(id) {\n for (let i = 0; i < $scope.tabsData.length; i++) {\n const tab = $scope.tabsData[i];\n if (tab.id === id) {\n return i;\n }\n }\n }\n\n function saveTab(id) {\n const idx = findTabIndexByID(id);\n // Tab was deleted, don't try to save it's state\n if (idx === undefined) {\n return {};\n }\n const tab = $scope.tabsData[idx];\n //tab.query = window.editor.getValue();\n $scope.saveQueryToLocal(tab);\n return tab;\n }\n\n let maxID = LocalStorageAdapter.get(LSKeys.TABS_STATE_MAXID) || 1;\n\n function addNewTab(callback, tabName, savedQuery) { // optional callback to call after tab has been added\n if (!isTabChangeOk(true)) {\n return;\n }\n let defaultTabConfig;\n if (tabName || savedQuery) {\n defaultTabConfig = {\n id: \"1\",\n name: tabName,\n query: savedQuery,\n inference: principal.appSettings.DEFAULT_INFERENCE,\n sameAs: principal.appSettings.DEFAULT_SAMEAS\n };\n } else {\n defaultTabConfig = {\n id: \"1\",\n name: '',\n query: 'select * where { \\n' +\n '\\t?s ?p ?o .\\n' +\n '} limit 100 \\n',\n inference: principal.appSettings.DEFAULT_INFERENCE,\n sameAs: principal.appSettings.DEFAULT_SAMEAS\n };\n }\n\n maxID++;\n const newID = '' + maxID;\n $scope.tabsData = $scope.tabs;\n\n const newTab = defaultTabConfig;\n newTab.id = newID;\n\n $scope.tabsData.push(newTab);\n\n LocalStorageAdapter.set(LSKeys.TABS_STATE_MAXID, maxID);\n LocalStorageAdapter.set(LSKeys.TABS_STATE, $scope.tabsData);\n const callbackArgs = Array.prototype.slice.call(arguments, 1); // skip one argument, i.e. the callback itself\n $timeout(function () {\n $scope.$apply();\n selectTab(newID);\n if (callback) {\n callback.apply(this, callbackArgs);\n }\n }, 0);\n $scope.tabs = $scope.tabsData;\n }\n\n function loadTab(id) {\n $scope.tabsData = LocalStorageAdapter.get(LSKeys.TABS_STATE) || [defaultTabConfig];\n\n // find available tab\n const idx = findTabIndexByID(id);\n const tab = $scope.tabsData[idx];\n\n if (tab.yasrData) {\n setLoader(true, 'Rendering results', null, true);\n }\n\n // set query in editor available on the current tab\n $timeout(function () {\n if ($scope.currentQuery.query === '') {\n $scope.currentQuery.query = \" \";\n }\n $timeout(function () {\n window.editor.setValue($scope.currentQuery.query);\n $scope.yasr.updateDownloadDropdown();\n $scope.$broadcast('tabLoaded', $scope.currentQuery.id);\n\n // set query results in query results sections after\n // previous query execution. Yasr response rendering depends on the\n // query type of window.editor!\n $scope.yasr.options.output = tab.outputType; // this may be undefined, that's fine!\n if (tab.yasrData) {\n if (tab.yasrData.customError) {\n // Our injected custom (not real HTTP) error\n $scope.yasr.results = {\n getException: function () {\n return tab.yasrData.customError;\n }\n };\n setLoader(false);\n } else {\n // Real YASR result\n $timeout(function () {\n $scope.setYasrResponse(tab.yasrData, tab.textStatus, tab.jqXhrOrErrorString);\n setLoader(false);\n if ($('.yasr_btnGroup li:nth-child(2)').hasClass(\"active\")) {\n $timeout(function () {\n $('.yasr_btnGroup li:nth-child(2) a').get(0).click();\n }, 0);\n }\n }, 0);\n }\n }\n }, 0);\n }, 0);\n\n\n // persist current tab id in local storage\n LocalStorageAdapter.set(LSKeys.TABS_STATE_CURRENT_ID, id);\n\n $scope.currentQuery = tab;\n\n $timeout(function () {\n $scope.currentTabConfig = {};\n $scope.currentTabConfig.queryType = tab.queryType;\n $scope.currentTabConfig.resultsCount = tab.resultsCount;\n\n $scope.currentTabConfig.offset = tab.offset;\n $scope.currentTabConfig.allResultsCount = tab.allResultsCount;\n $scope.currentTabConfig.allResultsCountExact = tab.allResultsCountExact;\n $scope.currentTabConfig.page = tab.page;\n $scope.currentTabConfig.pageSize = tab.pageSize;\n\n $scope.currentTabConfig.timeFinished = tab.timeFinished;\n $scope.currentTabConfig.timeTook = tab.timeTook;\n $scope.currentTabConfig.sizeDelta = tab.sizeDelta;\n $scope.currentTabConfig.customUpdateMessage = tab.customUpdateMessage;\n $scope.currentTabConfig.errorMessage = tab.errorMessage;\n $scope.currentTabConfig.warningMessage = tab.warningMessage;\n\n $scope.$apply();\n }, 0);\n\n //Remove paddign of yasr so it will be aligned with sparql editor\n $('#yasr').css('padding', '0');\n\n if (!checkQueryIntervalId) {\n checkQueryIntervalId = setInterval(showOrHideSaveAsDropDown, 200);\n }\n overrideSameAsInferenceAndNoCountIfNeeded();\n }\n\n function getQueryID(element) {\n return $(element).attr('data-id');\n }\n\n function showOrHideSaveAsDropDown() {\n // If selected tab has results and query in editor controller is invalid save as\n // dropdown menu will be removed and on fixing query latter will be added\n if ($scope.currentTabConfig.resultsCount >= 0) {\n const $saveAsDropDown = $('.saveAsDropDown');\n if ($saveAsDropDown.length > 0 && !window.editor.queryValid) {\n yasr.header.find('.saveAsDropDown').remove();\n } else if ($saveAsDropDown.length === 0 && window.editor.queryValid) {\n yasr.updateDownloadDropdown();\n }\n }\n }\n\n function isTabChangeOk(isNew) {\n if ($scope.queryIsRunning && !$scope.namespacesLoading) {\n if (isNew) {\n toastr.info('New tabs may not be opened while query or update is running.');\n } else {\n toastr.info('Tabs may not be switched while query or update is running.');\n }\n\n return false;\n }\n\n return true;\n }\n\n // Raise this flag to provide visual feedback to the user the next time a tab changes\n // (either manually or by the system). See GDB-1983.\n $scope.highlightNextTabChange = false;\n $scope.$on('tabAction', function (e, tabEvent) {\n if (tabEvent.relatedTarget) {\n // Cancel any highlight timer that might have been left by the last highlight\n $timeout.cancel(tabEvent.relatedTarget.timer);\n $(tabEvent.relatedTarget).css('color', '');\n\n $scope.saveTab(getQueryID(tabEvent.relatedTarget));\n }\n\n $scope.loadTab(getQueryID(tabEvent.target));\n\n // These arrays define how the tab change will be visually enhanced.\n // colors contains the colors to set to the tab name,\n // while times defines the times in milliseconds to keep each color.\n // Once we cycle through the arrays we restore the default color.\n const colors = ['#ED4F2F', '', '#ED4F2F'];\n const times = [400, 400, 400];\n if ($scope.highlightNextTabChange) {\n $scope.highlightNextTabChange = false;\n let index = 0;\n $(tabEvent.target).css('color', colors[index]);\n const highlightFun = function () {\n index++;\n if (index < colors.length) {\n $(tabEvent.target).css('color', colors[index]);\n tabEvent.target.timer = $timeout(highlightFun, times[index]);\n } else {\n $(tabEvent.target).css('color', '');\n }\n };\n $timeout(highlightFun, times[index]);\n }\n });\n\n $scope.$on('deleteAllexeptSelected', function (e, tabs) {\n $scope.tabsData = tabs;\n $scope.tabs = tabs;\n });\n // end of query tab operations\n\n $scope.currentQuery = {};\n // $scope.state = {};\n $scope.showSampleQueries = false;\n $scope.savedQuery = {};\n $scope.sampleQueries = {};\n $scope.editQueryModal = showModal('#editQueryContainer');\n $scope.deleteQueryModal = showModal('#confirmDeleteContainer');\n $scope.saveQueryModal = showModal('#saveQueryContainer');\n\n $scope.getResultsDescription = function () {\n let desc;\n if ($scope.currentTabConfig.resultsCount === 0) {\n desc = \"No results.\";\n } else {\n const currentPageEnd = ($scope.currentTabConfig.page - 1) * $scope.currentTabConfig.pageSize\n + Math.min($scope.currentTabConfig.resultsCount, $scope.currentTabConfig.pageSize);\n desc = \"Showing results from \" + $filter('currency')($scope.currentTabConfig.offset, '', 0)\n + \" to \" + $filter('currency')(currentPageEnd, '', 0);\n if ($scope.currentTabConfig.allResultsCount > 0) {\n // Unsure total results count \"of at least\" happens if counting timed out or\n // counting was disabled and we got at least $pageSize + 1 results for the current page.\n // It may reset become exact when we navigate and reach the end of results.\n desc += $scope.currentTabConfig.allResultsCountExact\n ? \" of \" : \" of at least \";\n desc += $filter('currency')($scope.currentTabConfig.allResultsCount, '', 0);\n }\n desc += \".\";\n }\n\n return desc;\n };\n\n $scope.getUpdateDescription = function () {\n if ($scope.currentTabConfig.customUpdateMessage) {\n return $scope.currentTabConfig.customUpdateMessage;\n } else if ($scope.currentTabConfig.sizeDelta === undefined) {\n return '';\n } else if ($scope.currentTabConfig.sizeDelta < 0) {\n return 'Removed ' + Math.abs($scope.currentTabConfig.sizeDelta) + ' statements.';\n } else if ($scope.currentTabConfig.sizeDelta > 0) {\n return 'Added ' + $scope.currentTabConfig.sizeDelta + ' statements.';\n } else {\n return 'The number of statements did not change.';\n }\n };\n\n $scope.getStaleWarningMessage = function () {\n const secondsAgo = Math.round((Date.now() - $scope.currentTabConfig.timeFinished) / 60000) * 60;\n if (secondsAgo >= 3600) { // must be at least an hour\n return \"Possibly stale result (obtained \" + $scope.getHumanReadableSeconds(secondsAgo) + \" ago).\";\n }\n };\n\n const resize = function () {\n // $scope.fixSizesOnHorizontalViewModeSwitch();\n };\n\n angular.element($window).bind('resize', resize);\n\n $scope.$on('$destroy', function () {\n angular.element($window).unbind('resize', resize);\n });\n\n /**\n * In case of Ontop repository, sameAs, inference and nocount are\n * overridden to true and #sameAs and #inference buttons are disabled, In case of FedX repo nocount is overridden\n */\n function overrideSameAsInferenceAndNoCountIfNeeded() {\n const isOntop = $repositories.isActiveRepoOntopType();\n const isFedX = $repositories.isActiveRepoFedXType();\n handleSameAsAndInferenceBtns(isOntop);\n\n $scope.nocount = (isOntop || isFedX) ? true : !principal.appSettings.EXECUTE_COUNT;\n if (isOntop) {\n $scope.currentQuery.inference = true;\n $scope.currentQuery.sameAs = true;\n }\n }\n\n function handleSameAsAndInferenceBtns(isOntop) {\n const sameAsBtn = document.getElementById('sameAs');\n const inferenceBtn = document.getElementById('inference');\n\n if (sameAsBtn) {\n sameAsBtn.disabled = !!isOntop;\n }\n\n if (inferenceBtn) {\n inferenceBtn.disabled = !!isOntop;\n }\n }\n\n // The sameAs is meaningless without inference.\n // Set its value to false and disable button\n function shouldDisableSameAs() {\n // don't try to override sameAs if repository is Ontop type\n if ($repositories.isActiveRepoOntopType()) {\n return;\n }\n const sameAsBtn = document.getElementById('sameAs');\n if (sameAsBtn && !$scope.currentQuery.inference && !sameAsBtn.disabled) {\n sameAsBtn.disabled = true;\n $scope.currentQuery.sameAs = false;\n } else if ($scope.currentQuery.inference && sameAsBtn.disabled) {\n sameAsBtn.removeAttribute('disabled');\n $scope.currentQuery.sameAs = principal.appSettings.DEFAULT_SAMEAS;\n }\n }\n}\n\nQuerySampleModalCtrl.$inject = ['$scope', '$modalInstance', 'data'];\n\nfunction QuerySampleModalCtrl($scope, $modalInstance, data) {\n if (data.queryExists) {\n $scope.queryExists = true;\n }\n $scope.query = angular.copy(data.query);\n $scope.title = data.title;\n $scope.edit = data.edit;\n $scope.okButtonText = data.okButtonText;\n $scope.ok = function () {\n if ($scope.form.$valid) {\n $modalInstance.close($scope.query);\n }\n };\n\n $scope.cancel = function () {\n $modalInstance.dismiss('cancel');\n };\n}\n","import 'angular/rest/connectors.rest.service';\nimport 'angular/utils/local-storage-adapter';\nimport 'angular/externalsync/controllers';\nimport YASQE from 'lib/yasqe.bundled';\nimport YASR from 'lib/yasr.bundled';\n\nangular\n .module('graphdb.framework.core.directives.queryeditor.queryeditor', [\n 'ngCookies',\n 'graphdb.framework.externalsync.controllers',\n 'graphdb.framework.rest.connectors.service',\n 'graphdb.framework.utils.localstorageadapter'\n ])\n .directive('queryEditor', queryEditorDirective);\n\nqueryEditorDirective.$inject = ['$timeout', '$location', 'toastr', '$repositories', 'SparqlRestService', 'ModalService', '$modal', '$jwtAuth', 'RDF4JRepositoriesRestService', 'ConnectorsRestService', 'LocalStorageAdapter', 'LSKeys'];\n\nfunction queryEditorDirective($timeout, $location, toastr, $repositories, SparqlRestService, ModalService, $modal, $jwtAuth, RDF4JRepositoriesRestService, ConnectorsRestService, LocalStorageAdapter, LSKeys) {\n\n let callbackOnChange;\n\n return {\n restrict: 'AE',\n scope: false,\n templateUrl: 'js/angular/core/directives/queryeditor/templates/query-editor.html',\n link: linkFunc\n };\n\n //function updateLineGutter() in Yasqe receive wrong data and line numbers div have width 100%\n // magic value 150 seems to work well (including Safari), smaller values work on other browsers but not always on Safari\n function linkFunc(scope, element, attrs) {\n // Doesn't store anything in local storage\n scope.nostorage = attrs.hasOwnProperty('nostorage');\n // Doesn't allow multiple tabs in the editor, only a single tab is active\n scope.notabs = attrs.hasOwnProperty('notabs');\n // Hides all the vertical toolbar inside the editor\n scope.notoolbar = attrs.hasOwnProperty('notoolbar');\n // Hides the saved queries icons in the toolbar\n scope.notoolbarSaved = attrs.hasOwnProperty('notoolbarSaved');\n // Hides the copy query link icon in the toolbar\n scope.notoolbarCopy = attrs.hasOwnProperty('notoolbarCopy');\n // Hides the inference icon in the toolbar\n scope.notoolbarInference = attrs.hasOwnProperty('notoolbarInference');\n // Hides the sameAs icon in the toolbar\n scope.notoolbarSameAs = attrs.hasOwnProperty('notoolbarSameAs');\n // Doesn't show any status messages in YASR (e.g. no results, query took that many seconds, etc)\n scope.nostatus = attrs.hasOwnProperty('nostatus');\n // Doesn't show the run button\n scope.norun = attrs.hasOwnProperty('norun');\n // Name of the Run button in the editor\n scope.runButtonName = \"Run\";\n if (attrs.runButtonName) {\n scope.runButtonName = attrs.runButtonName;\n }\n // Doesn't execute the count query\n scope.nocount = attrs.nocount === \"true\";\n\n // Custom callback to call when the content changes (fired within timeout of 200)\n if (attrs.callbackOnChange) {\n const callback = scope[attrs.callbackOnChange];\n if (typeof callback === 'function') {\n callbackOnChange = callback;\n }\n }\n\n $timeout(function () {\n drawQueryEditor(scope);\n }, 150);\n }\n\n function drawQueryEditor(scope) {\n scope.changePagination = changePagination;\n\n // start of keyboard shortcut actions\n function saveQueryAction() {\n angular.element('#wb-sparql-saveQuery')[0].click();\n }\n\n function runQueryAction() {\n scope.runQuery(false, false);\n }\n\n function explainQueryAction() {\n scope.runQuery(false, true);\n }\n\n function goToNextTabAction() {\n if (scope.tabs.length < 2 || !scope.currentQuery.id || !scope.isTabChangeOk(false)) {\n return;\n }\n let idx = findTabIndexByID(scope.currentQuery.id);\n idx = (idx + 1) % scope.tabs.length;\n const tab = scope.tabs[idx];\n selectTab(tab.id);\n }\n\n function goToPreviousTabAction() {\n if (scope.tabs.length < 2 || !scope.currentQuery.id || !scope.isTabChangeOk(false)) {\n return;\n }\n let idx = findTabIndexByID(scope.currentQuery.id);\n idx--;\n if (idx === -1) {\n idx = scope.tabs.length - 1;\n }\n const tab = scope.tabs[idx];\n selectTab(tab.id);\n }\n\n window.editor = YASQE.fromTextArea(\n document.getElementById(\"query\"), {\n persistent: null,\n value: \"\",\n indentUnit: 4,\n createShareLink: null,\n cursorHeight: 1.0,\n sparql: {\n showQueryButton: false,\n acceptHeaderGraph: \"application/x-graphdb-table-results+json, application/rdf+json;q=0.9, */*;q=0.8\",\n acceptHeaderSelect: \"application/x-sparqlstar-results+json, application/sparql-results+json;q=0.9, */*;q=0.8\"\n },\n // We provide a wrapper for executeQuery so we have to redefine those here\n extraKeys: {\n \"Ctrl-Enter\": runQueryAction,\n \"Cmd-Enter\": runQueryAction,\n \"Shift-Ctrl-Enter\": explainQueryAction,\n \"Shift-Cmd-Enter\": explainQueryAction,\n \"Ctrl-Alt-T\": scope.addNewTab,\n \"Cmd-Alt-T\": scope.addNewTab,\n \"Ctrl-S\": saveQueryAction,\n \"Cmd-S\": saveQueryAction,\n \"Ctrl-Alt-Left\": goToPreviousTabAction,\n \"Cmd-Alt-Left\": goToPreviousTabAction,\n \"Ctrl-Alt-Right\": goToNextTabAction,\n \"Cmd-Alt-Right\": goToNextTabAction\n }\n }\n );\n\n window.editor.toastBuildIndex = function () {\n toastr.warning('', '<div class=\"autocomplete-toast\"><a href=\"autocomplete\">Autocomplete is OFF<br>Go to Setup -> Autocomplete</a></div>',\n {allowHtml: true});\n };\n\n window.editor.toastError = function (data) {\n toastr.error('Cannot execute autocomplete query. ' + getError(data));\n };\n\n window.editor.on(\"changes\", function () {\n angular.element('.CodeMirror-linenumbers').css('width', '1px');\n angular.element('.CodeMirror-sizer').css('margin-left', '0px');\n clearTimeout(scope.changesTimeout);\n const hasError = !window.editor.queryValid;\n scope.changesTimeout = setTimeout(callbackOnChange ? callbackOnChange() : function () {\n const idx = findTabIndexByID(scope.currentQuery.id) + 1;\n $('a[data-id = \"' + idx + '\"]')\n .toggleClass('query-has-error', hasError)\n .attr('title', hasError ?\n 'Query contains a syntax error. See the relevant line for more information.' :\n '');\n }, 200);\n scope.currentQuery.query = window.editor.getValue();\n scope.currentQuery.queryType = window.editor.getQueryType();\n });\n\n\n function selectTab(id) {\n $timeout(function () {\n let requestedTab = $('a[data-id = \"' + id + '\"]');\n if (requestedTab.length === 0) {\n // tab has been deleted in another browser window or something else occurred,\n // select first tab instead\n requestedTab = $('a[data-id]').first();\n }\n requestedTab.tab('show');\n }, 0);\n }\n\n // hide unneeded yasqe fullscreen button\n $(\".fullscreenToggleBtns\").hide();\n\n const afterCopy = function (event) {\n $(event.target).removeClass('fa-link').addClass('fa-check').blur();\n setTimeout(function () {\n $(event.target).removeClass('fa-check').addClass('fa-link');\n }, 1000);\n };\n\n window.onbeforeunload = function () {\n if (!scope.nostorage) {\n LocalStorageAdapter.set(LSKeys.TABS_STATE, scope.tabs);\n }\n scope.saveTab(scope.currentQuery.id);\n };\n\n /*\n * Patch the execute query to take into account the inference\n * and the same as options\n */\n const originalExecuteQuery = YASQE.executeQuery;\n const originalGetUrlArguments = YASQE.getUrlArguments;\n\n scope.$on('$destroy', function () {\n if (!scope.nostorage) {\n LocalStorageAdapter.set(LSKeys.TABS_STATE, scope.tabs);\n }\n YASQE.executeQuery = originalExecuteQuery;\n YASQE.getUrlArguments = originalGetUrlArguments;\n scope.saveTab(scope.currentQuery.id);\n });\n\n /*\n * Add our own buttons\n */\n YASQE.drawButtons = function (yasqe) {\n // Define this property because otherwise there are errors in yasgui's code.\n yasqe.buttons = $(\"#yasqe_buttons_mocked\");\n };\n\n YASQE.getActiveRepository = function () {\n return $repositories.getActiveRepository();\n };\n\n YASQE.getUrlArguments = function (yasqe, config) {\n const data = originalGetUrlArguments(yasqe, config);\n const qType = window.editor.getQueryType();\n if ('SELECT' === qType || 'CONSTRUCT' === qType || 'DESCRIBE' === qType) {\n // We request pageSize + 1 to know if there are more pages when total count isn't known\n data.push({name: 'limit', value: scope.currentTabConfig.pageSize + 1});\n scope.currentTabConfig.offset = (scope.currentTabConfig.page - 1) * scope.currentTabConfig.pageSize + 1;\n data.push({name: 'offset', value: scope.currentTabConfig.offset - 1});\n }\n // even though we have explainRequested in our scope too it doesn't always contain a fresh value\n if (scope.explainRequested && ('SELECT' === qType || 'CONSTRUCT' === qType)) {\n data.push({name: 'explain', value: 'true'});\n }\n return data;\n };\n\n function createCustomError(status, statusText, responseText) {\n return {\n status: status,\n statusText: statusText,\n responseText: responseText\n };\n }\n\n // Generates a new tracking alias for queries based on time\n function newTrackAlias() {\n return \"query-editor-\" + performance.now() + \"-\" + Date.now();\n }\n\n let connectorProgressModal;\n let yasr;\n\n YASQE.executeQuery = function (cm) {\n if (yasr && $(yasr.resultsContainer).length) {\n $(yasr.resultsContainer).empty();\n }\n // Request extra error/warning handling\n cm.options.sparql.headers['X-GraphDB-Catch'] = scope.currentTabConfig.pageSize + '; throw';\n scope.currentTrackAlias = newTrackAlias();\n cm.options.sparql.headers['X-GraphDB-Track-Alias'] = scope.currentTrackAlias;\n scope.countTimeouted = false;\n if (cm.getQueryMode() === 'query') {\n cm.options.sparql.endpoint = 'repositories/' + $repositories.getActiveRepository();\n } else if (cm.getQueryMode() === 'update') {\n cm.options.sparql.endpoint = 'repositories/' + $repositories.getActiveRepository() + '/statements';\n }\n cm.options.sparql.args = [{\n name: 'infer',\n value: scope.currentQuery.inference\n },\n {\n name: 'sameAs',\n value: scope.currentQuery.sameAs\n }];\n\n scope.currentTabConfig.customUpdateMessage = \"\";\n\n if (window.editor.getQueryMode() === \"update\") {\n const doExecute = function () {\n scope.currentTabConfig.queryType = \"UPDATE\";\n\n RDF4JRepositoriesRestService.getRepositorySize()\n .success(function (data) {\n scope.repoSize = parseInt(data);\n scope.queryStartTime = new Date().getTime();\n return originalExecuteQuery(cm, {});\n })\n .error(function (data) {\n toastr.warning('Could not get repository size for: ' + $repositories.getActiveRepository() + '; ' + getError(data));\n scope.queryStartTime = new Date().getTime();\n return originalExecuteQuery(cm, {});\n });\n };\n\n ConnectorsRestService.checkConnector(window.editor.getValue())\n .then(function (res) {\n if (res.data.command && !res.data.hasSupport) {\n // it's a connector query but the relevant plugin isn't active, stop executing and warn the user\n scope.currentTabConfig.queryType = 'ERROR';\n scope.currentTabConfig.timeFinished = Date.now();\n scope.currentTabConfig.timeTook = (scope.currentTabConfig.timeFinished - scope.queryStartTime) / 1000;\n\n const customError = createCustomError(-1, 'No support for ' + res.data.connectorName, res.data.connectorName\n + ' connectors are not supported because the plugin ' + res.data.pluginName + ' is not active.');\n\n yasr.results = {\n getException: function () {\n return customError;\n }\n };\n\n scope.setLoader(false);\n\n setNewTabState({customError: customError}, '', null);\n\n return;\n }\n\n if (res.data.command === 'create' || res.data.command === 'repair') {\n const repair = res.data.command === 'repair';\n if (repair) {\n scope.setLoader(true, 'Repairing connector ' + res.data.name);\n scope.currentTabConfig.customUpdateMessage = 'Repaired connector ' + res.data.name + '.';\n } else {\n scope.setLoader(true, 'Creating connector ' + res.data.name);\n scope.currentTabConfig.customUpdateMessage = 'Created connector ' + res.data.name + '.';\n }\n\n const progressScope = scope.$new(true);\n\n // This duplicates code in the externalsync module but we can't get it from there\n progressScope.beingBuiltConnector = {\n percentDone: 0,\n status: {\n processedEntities: 0,\n estimatedEntities: 0,\n indexedEntities: 0,\n entitiesPerSecond: 0\n },\n actionName: repair ? 'Repairing' : 'Creating',\n eta: \"-\",\n inline: false,\n iri: res.data.iri,\n name: res.data.name,\n doneCallback: function () {\n connectorProgressModal.dismiss('cancel');\n }\n };\n progressScope.getHumanReadableSeconds = scope.getHumanReadableSeconds;\n\n connectorProgressModal = $modal.open({\n templateUrl: 'pages/connectorProgress.html',\n controller: 'CreateProgressCtrl',\n size: 'lg',\n backdrop: 'static',\n scope: progressScope\n });\n } else if (res.data.command === 'drop') {\n scope.setLoader(true, 'Deleting connector ' + res.data.name);\n scope.currentTabConfig.customUpdateMessage = 'Deleted connector ' + res.data.name + '.';\n }\n\n doExecute();\n }, function () {\n // for some reason we couldn't check if this is a connector update, so just execute it\n doExecute();\n });\n\n } else {\n const thisTabConfig = scope.currentTabConfig;\n const thisTabId = scope.executedQueryTab.id;\n\n // Assign a fresh callback function so that we can associate the count result\n // with the right tab (or lack of tab).\n window.editor.options.sparql.handlers.countCallback = function (dataOrJqXhr, textStatus, jqXhrOrErrorString) {\n if (dataOrJqXhr.status === 200) {\n const tab = scope.tabs[findTabIndexByID(thisTabId)];\n if (tab) {\n yasr.setResultsCount(dataOrJqXhr, textStatus, jqXhrOrErrorString);\n thisTabConfig.allResultsCount = yasr.allCount;\n tab.allResultsCount = yasr.allCount;\n thisTabConfig.allResultsCountExact = true;\n tab.allResultsCountExact = true;\n scope.saveTab(tab.id);\n } // Else tab was closed while we wait for the count, ignore result\n } else {\n // count query timed out or something else went wrong\n thisTabConfig.countTimeouted = true;\n }\n };\n\n // Tell YASR what format we want, or else it will mess it up when switching between tabs.\n if (scope.currentQuery.outputType != null) {\n yasr.options.output = scope.currentQuery.outputType;\n } else { // Default to table if no format has been configured yet.\n yasr.options.output = \"table\";\n }\n scope.currentTabConfig.queryType = window.editor.getQueryType();\n scope.queryStartTime = new Date().getTime();\n return originalExecuteQuery(cm, {\n setQueryLimit: function (query) {\n // Until weird conversion of CONSTRUCT queries is fixed\n // in Ontop project, comments should be removed from them\n // TODO: Remove this check when ${link https://github.com/ontop/ontop/issues/362} is fixed\n if (scope.currentTabConfig.queryType === 'CONSTRUCT' && $repositories.isActiveRepoOntopType()) {\n return window.editor.getValueWithoutComments();\n }\n // For all types of queries we handle limit/offset in our RepositoriesController.\n // TODO: Get rid of this method\n return query;\n }\n });\n }\n\n };\n\n // Override yasqe's getAjaxConfig() so we can inject our authorization header\n const originalGetAjaxConfig = YASQE.getAjaxConfig;\n YASQE.getAjaxConfig = function (yasqe, callbackOrConfig) {\n const config = originalGetAjaxConfig(yasqe, callbackOrConfig);\n\n _.extend(config.headers, {\n 'Authorization': $jwtAuth.getAuthToken()\n });\n\n return config;\n };\n\n function createQueryURL(savedQueryName, owner) {\n let url = [location.protocol, '//', location.host, location.pathname].join('');\n if (savedQueryName) {\n url = url + '?savedQueryName=' + encodeURIComponent(savedQueryName);\n if (owner != null) {\n url += '&owner=' + encodeURIComponent(owner);\n }\n } else {\n url = url + '?' + $.param({\n name: scope.currentQuery.name,\n infer: scope.currentQuery.inference,\n sameAs: scope.currentQuery.sameAs,\n query: window.editor.getValue()\n });\n }\n return url;\n }\n\n scope.copyToClipboardQuery = function (savedQueryName, owner) {\n ModalService.openCopyToClipboardModal(createQueryURL(savedQueryName, owner));\n };\n\n scope.copyToClipboardResult = function (resultURI) {\n ModalService.openCopyToClipboardModal(resultURI);\n };\n\n scope.goToVisual = function () {\n const paramsToParse = {\n query: window.editor.getValue(),\n sameAs: scope.currentQuery.sameAs,\n inference: scope.currentQuery.inference\n };\n\n $location.path('graphs-visualizations').search(paramsToParse);\n };\n\n // Adds prefixes when the user pastes a query. This was in the controller before and it stopped working\n // (needs to happen to after YASQE adds the textarea), see GDB-1936\n $('textarea').on('paste', function () {\n $timeout(function () {\n scope.addKnownPrefixes();\n }, 0);\n });\n\n function setNewTabState(dataOrJqXhr, textStatus, jqXhrOrErrorString) {\n // store explicitly the contentType\n if (dataOrJqXhr.getResponseHeader && dataOrJqXhr.getResponseHeader(\"content-type\")) {\n dataOrJqXhr.contentType = dataOrJqXhr.getResponseHeader(\"content-type\");\n }\n\n // We use this when we set YASR results to avoid double JSON parsing and to enforce\n // using the modified responseJSON. We'll save responseJSON instead (no need to save both).\n delete dataOrJqXhr.response;\n\n const executedQueryTabIdx = findTabIndexByID(scope.executedQueryTab.id);\n const executedQueryTab = scope.tabs[executedQueryTabIdx];\n const queryResultState = {\n queryType: scope.currentTabConfig.queryType,\n yasrData: dataOrJqXhr,\n textStatus: textStatus,\n jqXhrOrErrorString: jqXhrOrErrorString,\n page: scope.currentTabConfig.page,\n pageSize: scope.currentTabConfig.pageSize,\n allResultsCount: scope.currentTabConfig.allResultsCount,\n allResultsCountExact: scope.currentTabConfig.allResultsCountExact,\n resultsCount: scope.currentTabConfig.resultsCount,\n offset: scope.currentTabConfig.offset,\n timeTook: scope.currentTabConfig.timeTook,\n timeFinished: scope.currentTabConfig.timeFinished,\n sizeDelta: scope.currentTabConfig.sizeDelta,\n customUpdateMessage: scope.currentTabConfig.customUpdateMessage,\n errorMessage: scope.currentTabConfig.errorMessage,\n warningMessage: scope.currentTabConfig.warningMessage\n };\n\n // Save the output type only if it isn't an update or an ask query.\n // This way we preserve the existing output type when we execute an update and then\n // execute a non-ask query.\n if (scope.currentTabConfig.queryType !== \"ERROR\" && scope.currentTabConfig.queryType !== \"UPDATE\"\n && scope.currentTabConfig.queryType !== \"ASK\") {\n queryResultState.outputType = scope.yasr.options.output;\n }\n\n // merge query results state with the tab object\n angular.extend(scope.currentQuery, queryResultState);\n\n angular.extend(executedQueryTab, queryResultState);\n if (!scope.nostorage) {\n LocalStorageAdapter.set(LSKeys.TABS_STATE, scope.tabs);\n }\n $('a[data-id = \"' + scope.executedQueryTab.id + '\"]').tab('show');\n }\n\n function initYasr() {\n yasr = YASR(document.getElementById(\"yasr\"), { // eslint-disable-line new-cap\n getUsedPrefixes: {}, // initially blank, populated when we fetch the namespaces\n persistency: false\n });\n window.yasr = yasr;\n yasr.afterCopy = afterCopy;\n yasr.getQueryResultsAsFormat = function (downloadFormat) {\n // Simple cross-browser download with a form\n const $wbDownload = $('#wb-download');\n $wbDownload.attr('action', 'repositories/' + $repositories.getActiveRepository());\n $('#wb-download-query').val(scope.currentQuery.query);\n if (window.editor.getValue() !== scope.currentQuery.query) {\n toastr.warning('The query in your editor does not match the query results. Download will save the results from the last executed query.');\n }\n $('#wb-download-infer').val(scope.currentQuery.inference);\n $('#wb-download-sameAs').val(scope.currentQuery.sameAs);\n const auth = localStorage.getItem('com.ontotext.graphdb.auth');\n if (auth) {\n $('#wb-auth-token').val(auth);\n }\n $('#wb-download-accept').val(downloadFormat);\n $wbDownload.submit();\n };\n window.editor.options.sparql.handlers.complete = function (dataOrJqXhr, textStatus, jqXhrOrErrorString) {\n function setNewTabStateForThis() {\n setNewTabState(dataOrJqXhr, textStatus, jqXhrOrErrorString);\n }\n\n if (connectorProgressModal) {\n connectorProgressModal.dismiss('cancel');\n }\n\n // If yasqe was destroyed when scope was destroyed, do nothing\n if (null === window.editor) {\n scope.setLoader(false);\n\n return;\n }\n\n // Extra error/warning through headers\n scope.currentTabConfig.errorMessage = dataOrJqXhr.getResponseHeader('X-GraphDB-Error');\n scope.currentTabConfig.warningMessage = dataOrJqXhr.getResponseHeader('X-GraphDB-Warning');\n\n yasr.currentQuery = scope.currentQuery;\n\n scope.currentTabConfig.timeFinished = Date.now();\n scope.currentTabConfig.timeTook = (scope.currentTabConfig.timeFinished - scope.queryStartTime) / 1000;\n\n if (dataOrJqXhr.status >= 400) {\n // Removes useless com.blah.whatever.FooException: ... from the error message\n dataOrJqXhr.responseText = dataOrJqXhr.responseText.replace(/^([^: ]+: )+/, '');\n\n scope.currentTabConfig.queryType = 'ERROR';\n setNewTabStateForThis();\n scope.setYasrResponse(dataOrJqXhr, textStatus, jqXhrOrErrorString);\n\n scope.setLoader(false);\n\n return;\n }\n\n if (dataOrJqXhr.status === 0) {\n // Query was aborted, typically through window.editor.xhr.abort()\n\n scope.currentTabConfig.queryType = 'ERROR';\n\n const customError = createCustomError(-1, 'Request was aborted', 'The request has been aborted. There are no results to show.');\n\n yasr.results = {\n getException: function () {\n return customError;\n }\n };\n\n scope.setLoader(false);\n\n setNewTabState({customError: customError}, '', null);\n\n return;\n }\n\n scope.setLoader(false);\n\n let updateResultsCallback;\n\n if (window.editor.getQueryMode() === \"update\") {\n updateResultsCallback = function () {\n RDF4JRepositoriesRestService.getRepositorySize()\n .success(function (data) {\n let repoSizeDiff;\n if (scope.repoSize !== undefined) {\n repoSizeDiff = Number(data) - scope.repoSize;\n }\n scope.currentTabConfig.sizeDelta = repoSizeDiff;\n setNewTabStateForThis();\n }).error(function (data) {\n toastr.warning('Could not get repository size for: ' + scope.getActiveRepository() + '; ' + getError(data));\n scope.currentTabConfig.sizeDelta = undefined;\n setNewTabStateForThis();\n });\n };\n } else {\n if (dataOrJqXhr.status === 200) {\n const contentType = dataOrJqXhr.getResponseHeader('Content-Type');\n\n if (contentType.indexOf('application/sparql-results+json') === 0\n || contentType.indexOf('application/x-sparqlstar-results+json') === 0\n || contentType.indexOf('application/x-graphdb-table-results+json') === 0) {\n if (dataOrJqXhr.responseJSON.results) {\n // SELECT results in one of the standard formats or\n // CONSTRUCT or DESCRIBE results in our custom format that looks\n // like a SELECT result.\n scope.currentTabConfig.resultsCount = dataOrJqXhr.responseJSON.results.bindings.length;\n if (dataOrJqXhr.responseJSON.results.bindings.length > scope.currentTabConfig.pageSize) {\n // The results are more than the page size (because we request +1), truncate to page size\n // and raise flag to know we have at least one page more.\n dataOrJqXhr.responseJSON.results.bindings.length = scope.currentTabConfig.pageSize;\n }\n if (!scope.currentTabConfig.allResultsCountExact) {\n if (scope.nocount || scope.countTimeouted\n || scope.currentTabConfig.resultsCount <= scope.currentTabConfig.pageSize) {\n // No count requested or count timed out or the results are less than the pageSize + 1 buffer\n // In all of these cases it doesn't make sense to run\n // the counting query so we tweak the status to signal that to YASQE.\n dataOrJqXhr.status = 204; // 204 is no content, YASQE counts only if status is 200\n }\n\n // Calculate an \"at least\" all results count, i.e. at least what we have until now + 1.\n // The number will increase when we go to the next page eventually reaching the exact count.\n // A count query may also provide the exact count asynchronously.\n scope.currentTabConfig.allResultsCount = Math.max(scope.currentTabConfig.allResultsCount,\n scope.currentTabConfig.pageSize * (scope.currentTabConfig.page - 1) + scope.currentTabConfig.resultsCount);\n\n // We know we reached the end and the count is exact now.\n if (scope.currentTabConfig.resultsCount <= scope.currentTabConfig.pageSize) {\n scope.currentTabConfig.allResultsCountExact = true;\n }\n }\n }\n }\n }\n\n // The following long-running code needs to be in timeout to get the updated loader message\n scope.setLoader(true, 'Rendering results', null, true);\n\n updateResultsCallback = function () {\n scope.setYasrResponse(dataOrJqXhr, textStatus, jqXhrOrErrorString);\n\n setNewTabStateForThis();\n scope.setLoader(false);\n };\n }\n\n // By having this in timeout we manage to get the updated loader message\n $timeout(function () {\n updateResultsCallback();\n\n // Move disabled class to a, and clean from the li\n if (window.editor.getQueryType() !== \"CONSTRUCT\") {\n $('.yasr_btnGroup.nav.nav-tabs li a.disabled').removeClass('disabled').css('font-weight', '400');\n $('.yasr_btnGroup.nav.nav-tabs li.disabled a').addClass('disabled').css('font-weight', '200');\n if (window.editor.getQueryType() === \"DESCRIBE\") {\n $('.yasr_btnGroup.nav.nav-tabs li a').removeClass('disabled').css('font-weight', '400');\n }\n } else if (window.editor.getQueryType() === \"CONSTRUCT\") {\n $('.yasr_btnGroup.nav.nav-tabs li a.disabled').removeClass('disabled').css('font-weight', '400');\n }\n\n\n //Remove paddign of yasr so it will be aligned with sparql editor\n $('#yasr').css('padding', '0');\n\n if ($('.yasr_btnGroup li:nth-child(2)').hasClass(\"active\")) {\n $timeout(function () {\n $('.yasr_btnGroup li:nth-child(2) a').get(0).click();\n }, 100);\n }\n\n //\n $('#wb-sparql-addNewTab').click(function () {\n $('.dataTables_filter').hide();\n $('.resultsTable').hide();\n });\n }, 100);\n };\n\n window.editor.options.sparql.handlers.resetResults = function () {\n };\n\n scope.yasr = yasr;\n\n scope.setYasrResponse = function(dataOrJqXhr, textStatus, jqXhrOrErrorString) {\n // If YASR doesn't see a \"response\" property it will parse the textual JSON in \"responseText\".\n // This is both slow and interferes with the +1 result per page policy when we truncate responseJSON.\n if (dataOrJqXhr.responseJSON) {\n dataOrJqXhr.response = dataOrJqXhr.responseJSON;\n dataOrJqXhr.responseText = undefined;\n }\n yasr.setResponse(dataOrJqXhr, textStatus, jqXhrOrErrorString);\n };\n\n // Track changes in the output type (tab in yasr) so that we can save this together with\n // the rest of the tab's data.\n scope.$watch('yasr.options.output', function (value) {\n // Save the output type only if it isn't an update or an ask query (see comment where we save all properties).\n if (value && scope.currentTabConfig.queryType !== \"UPDATE\" && scope.currentTabConfig.queryType !== \"ASK\") {\n const tab = scope.tabs[findTabIndexByID(scope.currentQuery.id)];\n // Do not save tab on default yasr initalization since default table overrides saved value\n if (angular.isDefined(tab) && scope.currentTabConfig.queryType) {\n if (tab.outputType !== value) {\n tab.outputType = scope.currentQuery.outputType = value;\n scope.saveTab(tab.id);\n }\n }\n }\n });\n\n scope.$watch('namespaces', function () {\n if (scope.namespaces) {\n if (yasr && yasr.options && scope.namespaces) {\n // this way, the URLs in the results are prettified using the defined prefixes\n yasr.options.getUsedPrefixes = scope.namespaces;\n }\n\n // Notify YASQE about the new namespaces\n YASQE.signal(window.editor, 'namespacesChanged', scope.namespaces);\n }\n });\n }\n\n initYasr();\n\n function changePagination() {\n scope.runQuery(true, scope.explainRequested);\n }\n\n // Hide the sample queries when the user clicks somewhere else in the UI.\n $(document).mouseup(function (event) {\n const container = $('#sampleQueriesCollapse');\n if (!container.is(event.target) // if the target of the click isn't the container..\n && container.has(event.target).length === 0 //... nor a descendant of the container\n && scope.showSampleQueries) {\n scope.toggleSampleQueries();\n }\n });\n\n function findTabIndexByID(id) {\n for (let i = 0; i < scope.tabs.length; i++) {\n const tab = scope.tabs[i];\n if (tab.id === id) {\n return i;\n }\n }\n }\n\n // functions to load query param or saved queries\n function toBoolean(v) {\n return angular.isDefined(v) && v !== 'false';\n }\n\n function autoexecuteQueryIfRequested() {\n const isRequested = toBoolean($location.search().execute);\n\n if (isRequested) {\n if (window.editor.getQueryMode() === 'update') {\n ModalService.openSimpleModal({\n title: 'Confirm execute',\n message: 'This is an update and it may change the data in the repository.<br>Are you sure you want to execute it automatically?',\n warning: true\n }).result\n .then(function () {\n scope.runQuery(false);\n });\n } else {\n scope.runQuery(false);\n }\n }\n }\n\n function loadQueryIntoExistingOrNewTab(query, infer, sameAs) {\n const tabId = scope.getExistingTabId(query);\n // Ah, the joys of non-synchronous events\n const onHandler = scope.$on('tabLoaded', function () {\n if (angular.isDefined(infer)) {\n scope.currentQuery.inference = toBoolean(infer);\n }\n if (angular.isDefined(sameAs)) {\n scope.currentQuery.sameAs = toBoolean(sameAs);\n }\n autoexecuteQueryIfRequested();\n onHandler();\n });\n\n // See comment about this flag in controller. It's a good idea to be consistent and do this\n // every time a tab changes without the user clicking on it.\n scope.highlightNextTabChange = true;\n\n if (!angular.isDefined(tabId)) {\n scope.addNewTab(null, query.name, query.body);\n } else {\n selectTab(tabId);\n }\n }\n\n function loadSavedQueryIntoExistingOrNewTab(savedQueryName, owner, infer, sameAs) {\n SparqlRestService.getSavedQuery(savedQueryName, owner)\n .success(function (data) {\n loadQueryIntoExistingOrNewTab(data, infer, sameAs);\n })\n .error(function (data) {\n toastr.error('Could not get data for saved query: ' + savedQueryName + '; ' + getError(data));\n });\n }\n\n function addTabWithQueryIfNeeded() {\n if ($location.search().savedQueryName) {\n // new way\n loadSavedQueryIntoExistingOrNewTab($location.search().savedQueryName, $location.search().owner,\n $location.search().infer, $location.search().sameAs);\n } else if ($location.search().query) {\n const query = {name: $location.search().name, body: $location.search().query};\n loadQueryIntoExistingOrNewTab(query, $location.search().infer, $location.search().sameAs);\n } else {\n // Restore the previous tab after the dom has loaded\n const currentid = LocalStorageAdapter.get(LSKeys.TABS_STATE_CURRENT_ID);\n selectTab(currentid);\n }\n }\n\n function updateRepositoryAndSecurity() {\n scope.getNamespaces();\n YASQE.signal(window.editor, \"repositoryOrAuthorizationChanged\",\n $repositories.getActiveRepository(), $jwtAuth.getAuthToken());\n addTabWithQueryIfNeeded();\n }\n\n if ($repositories.getActiveRepository()) {\n updateRepositoryAndSecurity();\n }\n\n // When no repo is selected (editor hidden) and the user selects a repo the SPARQL params should be handled\n scope.$on('repositoryIsSet', function () {\n if ($repositories.getActiveRepository()) {\n updateRepositoryAndSecurity();\n }\n });\n // end of repository actions\n\n // focus the editor\n $timeout(function () {\n angular.element(document).find('.CodeMirror textarea:first-child').focus();\n }, 50);\n\n }\n}\n"],"sourceRoot":""}