UNPKG

graphdb-workbench

Version:
2 lines 29 kB
(window.webpackJsonp=window.webpackJsonp||[]).push([[28,35,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 m(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 y(t,o,a){const i=m(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){y(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){y(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=m(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,$uibModalInstance:r,connector:a,$uibModal: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","$uibModal","toastr","ModalService","$q","RDF4JRepositoriesRestService","ConnectorsRestService"],c.$inject=["$scope","$uibModalInstance","type","isExternal"],l.$inject=["$scope","$uibModalInstance","connector","$uibModal","toastr"],d.$inject=["$scope","$controller","$http","$uibModalInstance","connector","$uibModal","values","options"],p.$inject=["$scope","$interval","$http","$repositories"]},34:function(e,t,n){"use strict";n.r(t);n(29),n(4),n(32);var r=n(210),o=n.n(r),a=n(208),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(m,y,C){m.nostorage=C.hasOwnProperty("nostorage"),m.notabs=C.hasOwnProperty("notabs"),m.notoolbar=C.hasOwnProperty("notoolbar"),m.notoolbarSaved=C.hasOwnProperty("notoolbarSaved"),m.notoolbarCopy=C.hasOwnProperty("notoolbarCopy"),m.notoolbarInference=C.hasOwnProperty("notoolbarInference"),m.notoolbarSameAs=C.hasOwnProperty("notoolbarSameAs"),m.nostatus=C.hasOwnProperty("nostatus"),m.norun=C.hasOwnProperty("norun"),m.runButtonName="Run",C.runButtonName&&(m.runButtonName=C.runButtonName);if(m.nocount="true"===C.nocount,C.callbackOnChange){const e=m[C.callbackOnChange];"function"==typeof e&&(f=e)}e((function(){!function(m){function y(){angular.element("#wb-sparql-saveQuery")[0].click()}function C(){m.runQuery(!1,!1)}function b(){m.runQuery(!1,!0)}function h(){if(m.tabs.length<2||!m.currentQuery.id||!m.isTabChangeOk(!1))return;let e=O(m.currentQuery.id);e=(e+1)%m.tabs.length,w(m.tabs[e].id)}function T(){if(m.tabs.length<2||!m.currentQuery.id||!m.isTabChangeOk(!1))return;let e=O(m.currentQuery.id);e--,-1===e&&(e=m.tabs.length-1),w(m.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)}m.changePagination=function(){m.runQuery(!0,m.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":b,"Shift-Cmd-Enter":b,"Ctrl-Alt-T":m.addNewTab,"Cmd-Alt-T":m.addNewTab,"Ctrl-S":y,"Cmd-S":y,"Ctrl-Alt-Left":T,"Cmd-Alt-Left":T,"Ctrl-Alt-Right":h,"Cmd-Alt-Right":h}}),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(m.changesTimeout);const e=!window.editor.queryValid;m.changesTimeout=setTimeout(f?f():function(){const t=O(m.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),m.currentQuery.query=window.editor.getValue(),m.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(){m.nostorage||p.set(g.TABS_STATE,m.tabs),m.saveTab(m.currentQuery.id)};const R=o.a.executeQuery,S=o.a.getUrlArguments;function x(e,t,n){return{status:e,statusText:t,responseText:n}}let A,E;m.$on("$destroy",(function(){m.nostorage||p.set(g.TABS_STATE,m.tabs),o.a.executeQuery=R,o.a.getUrlArguments=S,m.saveTab(m.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=S(e,t),r=window.editor.getQueryType();return"SELECT"!==r&&"CONSTRUCT"!==r&&"DESCRIBE"!==r||(n.push({name:"limit",value:m.currentTabConfig.pageSize+1}),m.currentTabConfig.offset=(m.currentTabConfig.page-1)*m.currentTabConfig.pageSize+1,n.push({name:"offset",value:m.currentTabConfig.offset-1})),!m.explainRequested||"SELECT"!==r&&"CONSTRUCT"!==r||n.push({name:"explain",value:"true"}),n},o.a.executeQuery=function(e){if(E&&$(E.resultsContainer).length&&$(E.resultsContainer).empty(),e.options.sparql.headers["X-GraphDB-Catch"]=m.currentTabConfig.pageSize+"; throw",m.currentTrackAlias="query-editor-"+performance.now()+"-"+Date.now(),e.options.sparql.headers["X-GraphDB-Track-Alias"]=m.currentTrackAlias,m.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:m.currentQuery.inference},{name:"sameAs",value:m.currentQuery.sameAs}],m.currentTabConfig.customUpdateMessage="","update"!==window.editor.getQueryMode()){const t=m.currentTabConfig,n=m.executedQueryTab.id;return window.editor.options.sparql.handlers.countCallback=function(e,r,o){if(200===e.status){const a=m.tabs[O(n)];a&&(E.setResultsCount(e,r,o),t.allResultsCount=E.allCount,a.allResultsCount=E.allCount,t.allResultsCountExact=!0,a.allResultsCountExact=!0,m.saveTab(a.id))}else t.countTimeouted=!0},null!=m.currentQuery.outputType?E.options.output=m.currentQuery.outputType:E.options.output="table",m.currentTabConfig.queryType=window.editor.getQueryType(),m.queryStartTime=(new Date).getTime(),R(e,{setQueryLimit:function(e){return"CONSTRUCT"===m.currentTabConfig.queryType&&r.isActiveRepoOntopType()?window.editor.getValueWithoutComments():e}})}{const t=function(){m.currentTabConfig.queryType="UPDATE",l.getRepositorySize().success((function(t){return m.repoSize=parseInt(t),m.queryStartTime=(new Date).getTime(),R(e,{})})).error((function(t){return n.warning("Could not get repository size for: "+r.getActiveRepository()+"; "+getError(t)),m.queryStartTime=(new Date).getTime(),R(e,{})}))};d.checkConnector(window.editor.getValue()).then((function(e){if(e.data.command&&!e.data.hasSupport){m.currentTabConfig.queryType="ERROR",m.currentTabConfig.timeFinished=Date.now(),m.currentTabConfig.timeTook=(m.currentTabConfig.timeFinished-m.queryStartTime)/1e3;const t=x(-1,"No support for "+e.data.connectorName,e.data.connectorName+" connectors are not supported because the plugin "+e.data.pluginName+" is not active.");return E.results={getException:function(){return t}},m.setLoader(!1),void q({customError:t},"",null)}if("create"===e.data.command||"repair"===e.data.command){const t="repair"===e.data.command;t?(m.setLoader(!0,"Repairing connector "+e.data.name),m.currentTabConfig.customUpdateMessage="Repaired connector "+e.data.name+"."):(m.setLoader(!0,"Creating connector "+e.data.name),m.currentTabConfig.customUpdateMessage="Created connector "+e.data.name+".");const n=m.$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=m.getHumanReadableSeconds,A=u.open({templateUrl:"pages/connectorProgress.html",controller:"CreateProgressCtrl",size:"lg",backdrop:"static",scope:n})}else"drop"===e.data.command&&(m.setLoader(!0,"Deleting connector "+e.data.name),m.currentTabConfig.customUpdateMessage="Deleted connector "+e.data.name+".");t()}),(function(){t()}))}};const k=o.a.getAjaxConfig;function q(e,t,n){e.getResponseHeader&&e.getResponseHeader("content-type")&&(e.contentType=e.getResponseHeader("content-type")),delete e.response;const r=O(m.executedQueryTab.id),o=m.tabs[r],a={queryType:m.currentTabConfig.queryType,yasrData:e,textStatus:t,jqXhrOrErrorString:n,page:m.currentTabConfig.page,pageSize:m.currentTabConfig.pageSize,allResultsCount:m.currentTabConfig.allResultsCount,allResultsCountExact:m.currentTabConfig.allResultsCountExact,resultsCount:m.currentTabConfig.resultsCount,offset:m.currentTabConfig.offset,timeTook:m.currentTabConfig.timeTook,timeFinished:m.currentTabConfig.timeFinished,sizeDelta:m.currentTabConfig.sizeDelta,customUpdateMessage:m.currentTabConfig.customUpdateMessage,errorMessage:m.currentTabConfig.errorMessage,warningMessage:m.currentTabConfig.warningMessage};"ERROR"!==m.currentTabConfig.queryType&&"UPDATE"!==m.currentTabConfig.queryType&&"ASK"!==m.currentTabConfig.queryType&&(a.outputType=m.yasr.options.output),angular.extend(m.currentQuery,a),angular.extend(o,a),m.nostorage||p.set(g.TABS_STATE,m.tabs),$('a[data-id = "'+m.executedQueryTab.id+'"]').tab("show")}function Q(){var e=E.results.getBindings(),t=E.results.getVariables(),n=e[0],r=t[0];if(1===t.length&&1===e.length&&"plan"===r&&n[r].value.includes("# NOTE: Optimization groups")){var a=document.getElementsByClassName("nonUri")[0];a.classList.add("cm-s-default"),a.setAttribute("id","highlighted_output");var i=a.innerText.substring(1,a.innerText.length-1);a.innerHTML="",o.a.runMode(i,"sparql11",document.getElementById("highlighted_output"))}}function O(e){for(let t=0;t<m.tabs.length;t++){if(m.tabs[t].id===e)return t}}function B(e){return angular.isDefined(e)&&"false"!==e}function M(e,n,r){const o=m.getExistingTabId(e),a=m.$on("tabLoaded",(function(){angular.isDefined(n)&&(m.currentQuery.inference=B(n)),angular.isDefined(r)&&(m.currentQuery.sameAs=B(r)),B(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(){m.runQuery(!1)})):m.runQuery(!1)),a()}));m.highlightNextTabChange=!0,angular.isDefined(o)?w(o):m.addNewTab(null,e.name,e.body)}function D(){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){M(e,o,i)})).error((function(t){n.error("Could not get data for saved query: "+e+"; "+getError(t))}));else if(t.search().query){M({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 U(){m.getNamespaces(),o.a.signal(window.editor,"repositoryOrAuthorizationChanged",r.getActiveRepository(),c.getAuthToken()),D()}o.a.getAjaxConfig=function(e,t){const n=k(e,t);return _.extend(n.headers,{Authorization:c.getAuthToken()}),n},m.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:m.currentQuery.name,infer:m.currentQuery.inference,sameAs:m.currentQuery.sameAs,query:window.editor.getValue()});return n}(e,t))},m.copyToClipboardResult=function(e){s.openCopyToClipboardModal(e)},m.goToVisual=function(){const e={query:window.editor.getValue(),sameAs:m.currentQuery.sameAs,inference:m.currentQuery.inference};t.path("graphs-visualizations").search(e)},$("textarea").on("paste",(function(){e((function(){m.addKnownPrefixes()}),0)})),E=i()(document.getElementById("yasr"),{getUsedPrefixes:{},persistency:!1}),window.yasr=E,E.afterCopy=v,E.getQueryResultsAsFormat=function(e){const t=$("#wb-download");t.attr("action","repositories/"+r.getActiveRepository()),$("#wb-download-query").val(m.currentQuery.query),window.editor.getValue()!==m.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(m.currentQuery.inference),$("#wb-download-sameAs").val(m.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(){q(t,r,o)}if(A&&A.dismiss("cancel"),null===window.editor)return void m.setLoader(!1);if(m.currentTabConfig.errorMessage=t.getResponseHeader("X-GraphDB-Error"),m.currentTabConfig.warningMessage=t.getResponseHeader("X-GraphDB-Warning"),E.currentQuery=m.currentQuery,m.currentTabConfig.timeFinished=Date.now(),m.currentTabConfig.timeTook=(m.currentTabConfig.timeFinished-m.queryStartTime)/1e3,t.status>=400)return t.responseText=t.responseText.replace(/^([^: ]+: )+/,""),m.currentTabConfig.queryType="ERROR",a(),m.setYasrResponse(t,r,o),void m.setLoader(!1);if(0===t.status){m.currentTabConfig.queryType="ERROR";const e=x(-1,"Request was aborted","The request has been aborted. There are no results to show.");return E.results={getException:function(){return e}},m.setLoader(!1),void q({customError:e},"",null)}let i;if(m.setLoader(!1),"update"===window.editor.getQueryMode())i=function(){l.getRepositorySize().success((function(e){let t;void 0!==m.repoSize&&(t=Number(e)-m.repoSize),m.currentTabConfig.sizeDelta=t,a()})).error((function(e){n.warning("Could not get repository size for: "+m.getActiveRepository()+"; "+getError(e)),m.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&&(m.currentTabConfig.resultsCount=t.responseJSON.results.bindings.length,t.responseJSON.results.bindings.length>m.currentTabConfig.pageSize&&(t.responseJSON.results.bindings.length=m.currentTabConfig.pageSize),m.currentTabConfig.allResultsCountExact||((m.nocount||m.countTimeouted||m.currentTabConfig.resultsCount<=m.currentTabConfig.pageSize)&&(t.status=204),m.currentTabConfig.allResultsCount=Math.max(m.currentTabConfig.allResultsCount,m.currentTabConfig.pageSize*(m.currentTabConfig.page-1)+m.currentTabConfig.resultsCount),m.currentTabConfig.resultsCount<=m.currentTabConfig.pageSize&&(m.currentTabConfig.allResultsCountExact=!0)))}m.setLoader(!0,"Rendering results",null,!0),i=function(){m.setYasrResponse(t,r,o),a(),m.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(){},m.yasr=E,m.setYasrResponse=function(e,t,n){e.responseJSON&&(e.response=e.responseJSON,e.responseText=void 0),window.yasr.plugins.table.options.highlightLiteralCellResult=Q,E.setResponse(e,t,n)},m.$watch("yasr.options.output",(function(e){if(e&&"UPDATE"!==m.currentTabConfig.queryType&&"ASK"!==m.currentTabConfig.queryType){const t=m.tabs[O(m.currentQuery.id)];angular.isDefined(t)&&m.currentTabConfig.queryType&&t.outputType!==e&&(t.outputType=m.currentQuery.outputType=e,m.saveTab(t.id))}})),void m.$watch("namespaces",(function(){m.namespaces&&(E&&E.options&&m.namespaces&&(E.options.getUsedPrefixes=m.namespaces),o.a.signal(window.editor,"namespacesChanged",m.namespaces))})),$(document).mouseup((function(e){const t=$("#sampleQueriesCollapse");!t.is(e.target)&&0===t.has(e.target).length&&m.showSampleQueries&&m.toggleSampleQueries()})),r.getActiveRepository()&&U();m.$on("repositoryIsSet",(function(){r.getActiveRepository()&&U()})),e((function(){angular.element(document).find(".CodeMirror textarea:first-child").focus()}),50)}(m)}),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","$uibModal","$jwtAuth","RDF4JRepositoriesRestService","ConnectorsRestService","LocalStorageAdapter","LSKeys"]}}]); //# sourceMappingURL=28.8f5d9fc8ee46db2a6357.bundle.js.map