UNPKG

graphdb-workbench

Version:
2 lines 15.6 kB
(window.webpackJsonp=window.webpackJsonp||[]).push([[48],{33:function(e,t,n){"use strict";n.r(t);n(4),n(12);function r(e,t,n,r,o,i,a,s,u,c,d,l,g,f){const y={id:"1",name:"",query:"select * where { \n\t?s ?p ?o .\n} limit 100 \n",inference:!0,sameAs:!0};let p,m=c.getPrincipal();function h(e,t){y.inference=t.appSettings.DEFAULT_INFERENCE,y.sameAs=t.appSettings.DEFAULT_SAMEAS,e.skipCountQuery=!t.appSettings.EXECUTE_COUNT,e.ignoreSharedQueries=t.appSettings.IGNORE_SHARED_QUERIES,e.tabsData=e.tabs=g.get(f.TABS_STATE)||[y],e.$watchCollection("[currentQuery.inference, currentQuery.sameAs]",(function(e,t,n){T(n.currentQuery)})),e.$on("repositoryIsSet",S)}function T(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))})),g.set(f.TABS_STATE,e.tabs)}function b(t,n,r,o){const i=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,i.addClass("hide")):(e.progressMessage="",e.extraMessage="",e.noLoaderTimer=!1,e.currentTrackAlias=null,e.abortRequested=!1,i.removeClass("hide")),null===e.$$phase&&e.$apply()}function w(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 C(){w(!0)}function S(t,n){n.newRepo&&(e.tabsData=g.get(f.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})),g.set(f.TABS_STATE,e.tabsData),e.tabs=e.tabsData,e.currentQuery={},e.errorMessage=null,e.repositoryError=null)}function E(e){t((function(){$('a[data-id = "'+e+'"]').tab("show")}),0)}function v(o,i){if(e.executedQueryTab=e.currentQuery,i){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=i,!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 Q(){e.showSampleQueries=!e.showSampleQueries,e.showSampleQueries?a.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 M(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?h(e,m):e.$on("securityInit",(function(e){m=c.getPrincipal(),h(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=g.get(f.TABS_STATE)||[y];const o=q(n),i=e.tabsData[o];i.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=i.outputType,i.yasrData&&(i.yasrData.customError?(e.yasr.results={getException:function(){return i.yasrData.customError}},b(!1)):t((function(){e.setYasrResponse(i.yasrData,i.textStatus,i.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),g.set(f.TABS_STATE_CURRENT_ID,n),e.currentQuery=i,t((function(){e.currentTabConfig={},e.currentTabConfig.queryType=i.queryType,e.currentTabConfig.resultsCount=i.resultsCount,e.currentTabConfig.offset=i.offset,e.currentTabConfig.allResultsCount=i.allResultsCount,e.currentTabConfig.allResultsCountExact=i.allResultsCountExact,e.currentTabConfig.page=i.page,e.currentTabConfig.pageSize=i.pageSize,e.currentTabConfig.timeFinished=i.timeFinished,e.currentTabConfig.timeTook=i.timeTook,e.currentTabConfig.sizeDelta=i.sizeDelta,e.currentTabConfig.customUpdateMessage=i.customUpdateMessage,e.currentTabConfig.errorMessage=i.errorMessage,e.currentTabConfig.warningMessage=i.warningMessage,e.$apply()}),0),$("#yasr").css("padding","0"),p||(p=setInterval(x,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(!_(!0))return;let i;i=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};D++;const a=""+D;e.tabsData=e.tabs;const s=i;s.id=a,e.tabsData.push(s),g.set(f.TABS_STATE_MAXID,D),g.set(f.TABS_STATE,e.tabsData);const u=Array.prototype.slice.call(arguments,1);t((function(){e.$apply(),E(a),n&&n.apply(this,u)}),0),e.tabs=e.tabsData},e.isTabChangeOk=_,e.runQuery=v,e.abortCurrentQuery=function(){l.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?a.addNewSavedQuery(o).success((function(){e.deleteQueryHttp(t.name,!0)})).error((function(e){const t=getError(e);n.error(t,"Error! Cannot edit saved query")})):a.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,d.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(){v(!0,e.explainRequested)},e.toggleSampleQueries=Q,e.addKnownPrefixes=function(){a.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)?E(n):e.addNewTab(null,t.name,t.body))},e.deleteQuery=function(t){i.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){a.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){a.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=T,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=w,e.changeViewMode=function(){e.viewMode="none",e.orientationViewMode=!e.orientationViewMode,g.set(f.VIEW_MODE,e.orientationViewMode),w()},e.showHideEditor=C,e.focusQueryEditor=function(){angular.element(document).find(".editable-input").is(":focus")||angular.element(document).find(".CodeMirror textarea:first-child").focus()},e.orientationViewMode=!g.get(f.VIEW_MODE)||"true"===g.get(f.VIEW_MODE),e.viewMode="none",e.getActiveRepository=function(){return r.getActiveRepository()},e.getActiveRepositoryNoError=function(){if(!e.repositoryError)return r.getActiveRepository()},e.orientationViewMode||C(),window.onbeforeunload=function(){e.currentQuery&&e.saveTab(e.currentQuery.id),g.set(f.TABS_STATE,e.tabs)},e.$on("$destroy",(function(){e.currentQuery&&e.saveTab(e.currentQuery.id),g.set(f.TABS_STATE,e.tabs),clearInterval(p)})),e.$on("$destroy",(function(){clearInterval(p),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&&Q()}));let D=g.get(f.TABS_STATE_MAXID)||1;function R(e){return $(e).attr("data-id")}function x(){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 _(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(R(r.relatedTarget))),e.loadTab(R(r.target));const o=["#ED4F2F","","#ED4F2F"],i=[400,400,400];if(e.highlightNextTabChange){e.highlightNextTabChange=!1;let n=0;$(r.target).css("color",o[n]);const a=function(){n++,n<o.length?($(r.target).css("color",o[n]),r.target.timer=t(a,i[n])):$(r.target).css("color","")};t(a,i[n])}})),e.$on("deleteAllexeptSelected",(function(t,n){e.tabsData=n,e.tabs=n})),e.currentQuery={},e.showSampleQueries=!1,e.savedQuery={},e.sampleQueries={},e.editQueryModal=M("#editQueryContainer"),e.deleteQueryModal=M("#confirmDeleteContainer"),e.saveQueryModal=M("#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 N=function(){};angular.element(u).bind("resize",N),e.$on("$destroy",(function(){angular.element(u).unbind("resize",N)}))}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","$uibModal","ModalService","SparqlRestService","$filter","$window","$jwtAuth","RDF4JRepositoriesRestService","MonitoringRestService","LocalStorageAdapter","LSKeys"],o.$inject=["$scope","$uibModalInstance","data"]}}]); //# sourceMappingURL=48.10699147cdbee9af3c2b.bundle.js.map