UNPKG

graphdb-workbench

Version:
2 lines 7.85 kB
export const __webpack_esm_id__=78070;export const __webpack_esm_ids__=[2134,27899,43006,78070,78618];export const __webpack_esm_modules__={2134(e,t,n){n.d(t,{x:()=>r});class r extends Error{}},27899(e,t,n){n.d(t,{Q:()=>a,y:()=>r});class r{constructor(e,t,n,r){this.status=e,this.mesage=r,this.messageLabelKey=t,this.parameters=n}}const a={ERROR:"error",SUCCESS:"success"}},43006(e,t,n){n.d(t,{H:()=>r});const r={CREATE:"create",REPAIR:"repair",DROP:"drop"}},78070(e,t,n){var r=n(98857),a=n(85694),o=(n(61105),n(20227),n(85727)),s=n(14604),i=n(43006),c=n(27899),u=n(97421),d=n(60529),l=n(78618),p=n(22201),g=n(2134),m=n(10799),y=(n(81655),n(304)),h=n(57154);const S=y.I.logger;function v(e,t,n,y,v,E,f,C,R,w,q,A,_,b,x,L,T){const P=(0,h.service)(h.SecurityContextService);this.repository="";const O="#query-editor";let U=E.getActiveRepository(),Q=E.isActiveRepoOntopType();t.yasguiConfig=void 0,t.savedQueryConfig=void 0,t.prefixes={},t.inferUserSetting=!0,t.sameAsUserSetting=!0;const N=new Map;let k=!1;t.updateConfig=e=>{t.yasguiConfig={endpoint:I,componentId:p.y,prefixes:t.prefixes,infer:Q||t.inferUserSetting,sameAs:Q||t.sameAsUserSetting,yasrToolbarPlugins:[z],beforeUpdateQuery:V(),outputHandlers:new Map([[u.r.QUERY_EXECUTED,$],[u.r.REQUEST_ABORTED,M]]),clearState:void 0!==e&&e}},t.getActiveRepositoryNoError=()=>U;const I=e=>{const t=(e=>{const t=e.getTab();if(t)return t.getYasqe()})(e);if(t)return E.resolveSparqlEndpoint(t.getQueryMode())},$=e=>{const t=N.get(e.tabId);t&&(t.dismiss(),N.delete(e.tabId))},M=e=>{if(e&&m.g.UPDATE!==e.queryMode){const t=e.getRepository(),n=e.getQueryTrackAlias();t&&n&&b.deleteQuery(n,t)}},D=e=>o.p3.getOntotextYasguiElementAsync(O).then(t=>t.openTab(e)).then(e=>o.p3.highlightTabName(e)),Y=()=>{k=!0;const e=y.search()[h.REPOSITORY_ID_PARAM];y.search(e?{repositoryId:e}:{}),y.replace()},H=()=>(0,l.G4)(y.search().execute)?o.p3.getOntotextYasguiElementAsync(O).then(G).then(j):Promise.resolve(),G=e=>e.getQueryMode().then(t=>({yasguiComponent:e,queryMode:t})),j=({yasguiComponent:e,queryMode:t})=>"update"!==t?e.query():new Promise(t=>{const n=R.instant("confirm.execute"),r=(0,d.Gz)(R.instant("query.editor.automatically.execute.update.warning"));_.openConfirmation(n,r,()=>t(e.query()),()=>t())}),z={createElement:e=>{const t=document.createElement("span");t.classList.add("explore-visual-graph-button-name");const n=document.createElement("button");return n.classList.add("explore-visual-graph-button"),n.classList.add("icon-data"),n.onclick=function(){const t={query:e.yasqe.getValue(),sameAs:e.yasqe.getSameAs(),inference:e.yasqe.getInfer()};y.path("graphs-visualizations").search(t)},n.appendChild(t),n},updateElement:(e,t)=>{if(e.classList.add("hidden"),!t.hasResults())return;const n=t.yasqe.getQueryType();s.b.CONSTRUCT!==n&&s.b.DESCRIBE!==n||e.classList.remove("hidden"),e.querySelector(".explore-visual-graph-button-name").innerText=R.instant("query.editor.visual.btn")},getOrder:()=>2},B=(e,t)=>({key:e,value:t}),F=e=>[B("name",e.data.name)],K=(e,n,r)=>{const a=t.$new(!0);a.beingBuiltConnector={percentDone:0,status:{processedEntities:0,estimatedEntities:0,indexedEntities:0,entitiesPerSecond:0},actionName:e,eta:"-",inline:!1,iri:n,name:r,doneCallback:function(){o.dismiss("cancel")}},a.getHumanReadableSeconds=t.getHumanReadableSeconds;const o=f.open({templateUrl:"pages/connectorProgress.html",controller:"CreateProgressCtrl",size:"lg",backdrop:"static",scope:a});return o},V=()=>(e,t)=>q.checkConnector(e).then(e=>e.data.command?e.data.hasSupport?i.H.CREATE===e.data.command?((e,t)=>{const n=K(R.instant("externalsync.creating"),e.data.iri,e.data.name);return N.set(t,n),new c.y(c.Q.SUCCESS,"created.connector",F(e))})(e,t):i.H.REPAIR===e.data.command?((e,t)=>{const n=K(R.instant("externalsync.repairing"),e.data.iri,e.data.name);return N.set(t,n),new c.y(c.Q.SUCCESS,"query.editor.repaired.connector",F(e))})(e,t):i.H.DROP===e.data.command?(e=>new c.y(c.Q.SUCCESS,"externalsync.delete.success.msg",F(e)))(e):void 0:(e=>{const t=[B("connectorName",e.data.connectorName),B("pluginName",e.data.pluginName)];return new c.y(c.Q.ERROR,"query.editor.inactive.plugin.warning.msg",t)})(e):new c.y(c.Q.SUCCESS)).catch(e=>{S.error("Checking connector error: ",e)}),X=e=>{const o=document.querySelectorAll('script[src*="https://www.gstatic.com/"]');if(o.length>0){const e=v.getLanguage();let t="module.js";if("en"!==e&&(t=`module__${e}.js`),!Array.prototype.some.call(o,e=>e.src.includes(t)))return void location.reload()}const s=P.getAuthenticatedUser();n.when(E.getPrefixes(U)).then(n=>{t.prefixes=n,(e=>{t.inferUserSetting=e?.appSettings.DEFAULT_INFERENCE,t.sameAsUserSetting=e?.appSettings.DEFAULT_SAMEAS})(s),((e=!1)=>{t.updateConfig(e);const n=y.search();n.hasOwnProperty(a.L.savedQueryName)?(e=>{const t=e[a.L.savedQueryName],n=e[a.L.savedQueryOwner];w.getSavedQuery(t,n).then(e=>{const t=(0,r.YS)(e);D(t).then(H).finally(Y)}).catch(e=>{C.error(R.instant("query.editor.missing.saved.query.data.error",{savedQueryName:t,error:getError(e)}))})})(n):n.hasOwnProperty(a.L.query)?(e=>{const t=e[a.L.name],n=e[a.L.query],o=e[a.L.owner],s=(0,r.mX)(n,t,o,!0);D(s).then(H).finally(Y)})(n):A.isActive()&&D()})(e)})},J=[],W=e=>{const t=o.p3.getOntotextYasguiElement(O);t&&t.abortAllRequests().then(()=>{})};window.addEventListener("beforeunload",W);let Z;J.push(h.ServiceProvider.get(h.EventService).subscribe(h.EventName.NAVIGATION_START,e=>(e=>{if(k)return void(k=!1);const t=o.p3.getOntotextYasguiElement(O);if(!t||Z)return;const n=new URL(e.newUrl),r=n.pathname+n.search+n.hash;e.cancelNavigation(),t.getOngoingRequestsInfo().then(e=>{return t=e,new Promise((e,n)=>{if(!t||t.queriesCount<1&&t.updatesCount<1)return void e();const r=R.instant("common.confirm"),a=(0,d.Gz)((e=>{let t="view.sparql-editor.leave_page.run_queries.confirmation.";!e||e.queriesCount<1?t+="none_queries_":1===e.queriesCount?t+="one_query_":t+="queries_",e.updatesCount&&0!==e.updatesCount?1===e.updatesCount?t+="one_update":t+="updates":t+="non_updates",t+=".message";const n={queriesCount:e.queriesCount,updatesCount:e.updatesCount};return R.instant(t,n)})(t));_.openSimpleModal({title:r,message:a,warning:!0}).result.then(function(){e()},function(){n(new g.x)})});var t}).then(()=>t.abortAllRequests()).then(()=>{Z=!0,(0,h.navigateTo)(r)()}).catch(e=>{e instanceof g.x||(S.error(e),Z=!0,(0,h.navigateTo)(r)())})})(e)));const ee=()=>{L.set(T.SPARQL_LAST_REPO,U)};J.push(t.$on("language-changed",function(){location.reload()}));const te=h.ServiceProvider.get(h.LanguageContextService).onSelectedLanguageChanged(()=>{},()=>new Promise(e=>{_.openSimpleModal({title:R.instant("query.editor.language.change.warning.title"),message:R.instant("query.editor.reload.page.warning"),warning:!0}).result.then(function(){e(!0)},function(){e(!1)})}));J.push(te),J.push(t.$on("$destroy",()=>{ee(),J.forEach(e=>e()),window.removeEventListener("beforeunload",W)})),J.push(t.$watch(t.getActiveRepositoryObject,e=>{e&&(U=E.getActiveRepository(),Q=E.isActiveRepoOntopType(e),L.get(T.SPARQL_LAST_REPO)!==U?(X(!0),ee()):X(!1))}))}angular.module("graphdb.framework.sparql-editor.controllers",["ui.bootstrap","graphdb.framework.rest.connectors.service","graphdb.framework.externalsync.controllers","graphdb.framework.utils.event-emitter-service","graphdb.framework.utils.localstorageadapter"]).controller("SparqlEditorCtrl",v),v.$inject=["$rootScope","$scope","$q","$location","$languageService","$repositories","$uibModal","toastr","$translate","SparqlRestService","ConnectorsRestService","GuidesService","ModalService","MonitoringRestService","EventEmitterService","LocalStorageAdapter","LSKeys"]},78618(e,t,n){n.d(t,{G4:()=>o,Sn:()=>s,hK:()=>a});var r=n(98980);const a=e=>e.replace(/[()']/g,""),o=e=>"string"==typeof e?"true"===e:Boolean(e),s=e=>e?(0,r.upperFirst)(e.toLowerCase()):e}}; //# sourceMappingURL=78070.06ebae9b4ebdb4749c29.bundle.js.map