graphdb-workbench
Version:
The web application for GraphDB APIs
2 lines • 8.31 kB
JavaScript
export const __webpack_esm_id__=99893;export const __webpack_esm_ids__=[15204,15435,56139,71156,88864,99893];export const __webpack_esm_modules__={15204:(e,t,a)=>{a.d(t,{T:()=>s,y:()=>r});const s="PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\nPREFIX ex: <http://example.com#>\nDELETE {\n ?subject ex:myPredicate ?oldValue .\n} INSERT {\n ?subject ex:myPredicate ?newValue .\n} WHERE {\n ?id rdf:type ex:MyType .\n ?subject ex:isRelatedTo ?id .\n}\n";class r{constructor(e=s,t=!0,a=void 0){this.query=e,this.templateID=a,this.isNewTemplate=t,this.templateExist=!1,this.isValidTemplateId=!0,this.isValidQuery=!0,this.isValidQueryMode=!0}}},15435:(e,t,a)=>{a.d(t,{o:()=>s});const s={YASGUI:"mode-yasgui",YASQE:"mode-yasqe",YASR:"mode-yasr"}},56139:()=>{function e(e,t){return{showToastMessageWithDelay:function(a){return new Promise(s=>{e.success(t.instant(a)),setTimeout(s,300)})}}}angular.module("graphdb.framework.utils.notifications",[]).factory("Notifications",e),e.$inject=["toastr","$translate"]},71156:(e,t,a)=>{a.d(t,{r:()=>s});const s={WRITE:"WRITE",READ:"READ",PROTECTED:"PROTECTED"}},88864:(e,t,a)=>{a.d(t,{i:()=>s});class s extends Error{}},99893:(e,t,a)=>{a(82493),a(76933),a(83351),a(56139),a(85369),a(81655);var s=a(60529),r=a(15204),n=a(88864),i=a(71156),o=a(15435),l=a(85727),p=a(57154);const c=a(304).I.logger;function m(e,t,a,s,r,n){const i=(0,p.service)(p.LicenseContextService);e.pluginName="sparql-template",e.setPluginIsActive=function(t){e.pluginIsActive=t},e.getSparqlTemplates=function(){i.getLicenseSnapshot().valid&&t.getActiveRepository()&&!t.isActiveRepoOntopType()&&!t.isActiveRepoFedXType()?a.getSparqlTemplates(t.getActiveRepository()).success(function(t){e.sparqlTemplateIds=t}).error(function(e){const t=getError(e);s.error(t,n.instant("sparql.template.get.templates.error"))}):e.sparqlTemplateIds=[]},e.deleteTemplate=function(i){r.openSimpleModal({title:n.instant("common.warning"),message:n.instant("sparql.template.delete.template.warning",{templateID:i}),warning:!0}).result.then(function(){a.deleteSparqlTemplate(i,t.getActiveRepository()).success(function(){s.success(i,n.instant("sparql.template.delete.template.success")),e.getSparqlTemplates()}).error(function(e){s.error(getError(e),n.instant("sparql.template.delete.template.failure",{templateID:i}))})})};const o=[],l=(0,p.service)(p.RepositoryContextService).onSelectedRepositoryChanged(()=>e.getSparqlTemplates());o.push(l),o.push(e.$on("$destroy",()=>{o.forEach(e=>e())}))}function u(e,t,a,m,u,d,g,f,h,y,T,q,I,v,w,D){e.initialQuery=r.T,e.sparqlTemplateInfo=new r.y(e.initialQuery),e.title="",e.saveOrUpdateExecuted=!1,e.isDirty=!1,e.language=D.getLanguage(),e.canEditActiveRepo=!1;let E,R=!0,S=!0;e.saveTemplate=function(){e.saveOrUpdateExecuted=!0,b()||L();const t=e.sparqlTemplateInfo.isNewTemplate?x:V;j(e.sparqlTemplateInfo).then(k).then(P).then(C).then(t).then(M).catch(e=>{e instanceof n.i||c.error(e)})},e.isTemplateIdValid=e=>T.isValidIri(e,e.toString()),e.markDirty=()=>{e.isDirty=!0},e.markPristine=()=>{e.isDirty=!1};const $=(t,a=r.T)=>{e.sparqlTemplateInfo.query=a,e.sparqlTemplateInfo.templateID=N(),e.sparqlTemplateInfo.isNewTemplate=!e.sparqlTemplateInfo.templateID,F(),e.yasguiConfig={showEditorTabs:!1,showToolbar:!1,showResultTabs:!1,showYasqeActionButtons:!1,showYasqeResizer:!1,yasqeActionButtons:l._f,showQueryButton:!1,initialQuery:e.sparqlTemplateInfo.query,componentId:"sparql-template",prefixes:t,render:o.o.YASQE,maxPersistentResponseSize:0,yasqeMode:e.canEditActiveRepo?i.r.WRITE:i.r.READ}},x=e=>A(e).then(_).then(Q),A=t=>h.getSparqlTemplates(u.getActiveRepository()).then(function(a){return t.templateExist=a.data.find(t=>t===e.sparqlTemplateInfo.templateID),t}).catch(function(e){const t=getError(e);return m.error(t,I.instant("sparql.template.get.templates.error")),Promise.reject(new n.i("Failed to retrieve sparql templates."))}),P=e=>Y().isQueryValid().then(t=>(e.isValidQuery=t,e.isValidQuery?e:Promise.reject(new n.i("Invalid query.")))),b=()=>e.sparqlTemplateInfo.isNewTemplate||e.isDirty,_=e=>new Promise((t,a)=>{if(e.templateExist){const r=(0,s.Gz)(I.instant("sparql.template.existing.template.error",{templateID:e.templateID})),i=I.instant("common.confirm.save");U(i,r,()=>t(e),()=>a(new n.i("Save not confirmed.")))}else t(e)});function Q(t){return h.createSparqlTemplate(t,u.getActiveRepository()).then(function(){return t.isNewTemplate=!1,e.markPristine(),m.success(t.templateID,I.instant("save.sparql.template.success.msg")),t}).catch(function(e){const a=getError(e);return m.error(a,I.instant("save.sparql.template.failure.msg",{templateID:t.templateID})),Promise.reject(new n.i(`Failed to save the new template: ${t.templateID}`))})}const V=t=>h.updateSparqlTemplate(t,u.getActiveRepository()).then(function(){return t.isNewTemplate=!1,e.markPristine(),m.success(e.sparqlTemplateInfo.templateID,I.instant("update.sparql.template.success.msg")),t}).catch(function(e){const a=getError(e);return m.error(a,I.instant("save.sparql.template.failure.msg",{templateID:t.templateID})),Promise.reject(new n.i(`Failed to update the template: ${t.templateID}`))}),k=e=>Y().getQuery().then(t=>(e.query=t,e)),C=e=>Y().getQueryMode().then(t=>(e.isValidQueryMode="update"===t,e.isValidQueryMode?e:Promise.reject(new n.i("Query mode is not valid.")))),j=t=>new Promise((a,s)=>{t.templateID?(t.isValidTemplateId=e.isTemplateIdValid(t.templateID),t.isValidTemplateId?a(t):s(new n.i("Template identifier is not valid."))):s(new n.i("A required template identifier is missing."))}),M=()=>{setTimeout(function(){L()},1e3)},N=()=>{const e=a.hash()||"";return(a.search().templateID||"")+(e?`#${e}`:"")},F=()=>{e.title=(e.sparqlTemplateInfo.templateID?I.instant("edit"):I.instant("common.create.btn"))+" "+I.instant("view.sparql.template.title")},L=()=>{a.url("/sparql-templates")},O=(t,a)=>{e.queryIsRunning=t,e.loaderMessage=e.queryIsRunning?a:""},Y=()=>l.p3.getOntotextYasguiElement("#query-editor"),U=(e,t,a,s)=>{q.openSimpleModal({title:e,message:t,warning:!0}).result.then(function(){angular.isFunction(a)&&a()},function(){angular.isFunction(s)&&s()})},W=()=>{window.removeEventListener("beforeunload",z),B.forEach(e=>e())},z=t=>{e.isDirty&&(t.returnValue=!0)},B=[],X=(0,p.service)(p.RepositoryContextService).onSelectedRepositoryChanged(e=>{e&&(S?(S=!1,E=e.id):e.id!==E&&L())},()=>new Promise(function(t){if(e.sparqlTemplateInfo.isNewTemplate)return void t(!0);const a=()=>{e.isDirty=!1,t(!0)};if(e.isDirty){const e=()=>{t(!1)},s=I.instant("common.confirm"),r=I.instant("common.unsaved.changes");U(s,r,a,e)}else a()}));B.push(X),B.push(e.$on("queryChanged",(t,a)=>{a.dirty?e.markDirty():e.markPristine()})),B.push(t.$on("$translateChangeSuccess",()=>{e.language=D.getLanguage(),F()})),B.push(e.$on("$locationChangeStart",(t,s)=>{if(e.isDirty){t.preventDefault();const e=I.instant("common.confirm"),r=I.instant("common.unsaved.changes");U(e,r,()=>{W();const e=a.absUrl().length-a.url().length,t=s.substring(e);a.path(t)})}else W()})),B.push(e.$on("$destroy",W)),window.addEventListener("beforeunload",z);B.push(e.$watch(e.getActiveRepositoryObject,t=>{t&&(e.canEditActiveRepo=e.canWriteActiveRepo(),R&&((()=>{const t=`${I.instant("common.refreshing.namespaces")}. ${I.instant("common.extra.message")}`;O(!0,t),e.sparqlTemplateInfo.templateID=N();const a=u.getActiveRepository();e.sparqlTemplateInfo.templateID?Promise.all([u.getPrefixes(a),h.getSparqlTemplate(e.sparqlTemplateInfo.templateID,a)]).then(([e,t])=>$(e,t.data)).finally(()=>O(!1)):u.getPrefixes(a).then(e=>$(e)).finally(()=>O(!1))})(),R=!1))}))}angular.module("graphdb.framework.sparql-template.controllers",["ui.bootstrap","graphdb.framework.core.services.repositories","graphdb.framework.rest.monitoring.service","toastr","graphdb.framework.utils.event-emitter-service"],["graphdb.framework.utils.notifications"]).controller("SparqlTemplatesCtrl",m).controller("SparqlTemplateCreateCtrl",u),m.$inject=["$scope","$repositories","SparqlTemplatesRestService","toastr","ModalService","$translate"],u.$inject=["$scope","$rootScope","$location","toastr","$repositories","$window","$timeout","$interval","SparqlTemplatesRestService","RDF4JRepositoriesRestService","UriUtils","ModalService","$translate","$q","EventEmitterService","$languageService"]}};
//# sourceMappingURL=99893.53866b33b6c34ec48175.bundle.js.map