UNPKG

graphdb-workbench

Version:
2 lines 13.1 kB
export const __webpack_esm_id__=96367;export const __webpack_esm_ids__=[13853,15435,56139,69530,71156,96367];export const __webpack_esm_modules__={13853:(e,r,t)=>{t.d(r,{ls:()=>a,yF:()=>i});var s=t(69530);const a=e=>new s.K(e.id,e.name,e.startMode,e.owner,e.startQueryIncludeInferred,e.startQuerySameAs,e.startGraphQuery,e.startIRI,e.startIRILabel,e.expandQuery,e.resourceQuery,e.predicateLabelQuery,e.resourcePropertiesQuery,e.shared,e.description,e.hint),i=e=>e.map(e=>(e=>new s.K(e.id,e.name,e.startMode,e.owner,e.startQueryIncludeInferred,e.startQuerySameAs,e.startGraphQuery,e.startIRI,e.startIRILabel,e.expandQuery,e.resourceQuery,e.predicateLabelQuery,e.resourcePropertiesQuery,e.shared,e.description,e.hint,e.startGraphQueryDescription,e.expandQueryDescription,e.resourceQueryDescription,e.predicateLabelQueryDescription,e.resourcePropertiesQueryDescription))(e))},15435:(e,r,t)=>{t.d(r,{o:()=>s});const s={YASGUI:"mode-yasgui",YASQE:"mode-yasqe",YASR:"mode-yasr"}},56139:()=>{function e(e,r){return{showToastMessageWithDelay:function(t){return new Promise(s=>{e.success(r.instant(t)),setTimeout(s,300)})}}}angular.module("graphdb.framework.utils.notifications",[]).factory("Notifications",e),e.$inject=["toastr","$translate"]},69530:(e,r,t)=>{t.d(r,{K:()=>a,Y:()=>s});const s={QUERY:"query",NODE:"node",SEARCH:"search"};class a{constructor(e,r,t=s.SEARCH,a,i=!0,n=!0,o,u,p,c,d,h,y,g,l,Q,f,w,m,I,_){this._id=e,this._name=r,this._startMode=t,this._owner=a,this._startQueryIncludeInferred=i,this._startQuerySameAs=n,this._startGraphQuery=o,this._startIRI=u,this._startIRILabel=p,this._expandQuery=c,this._resourceQuery=d,this._predicateLabelQuery=h,this._resourcePropertiesQuery=y,this._shared=g,this._description=l,this._hint=Q,this._startGraphQueryDescription=f,this._expandQueryDescription=w,this._resourceQueryDescription=m,this._predicateLabelQueryDescription=I,this._resourcePropertiesQueryDescription=_}isStartMode(e){return this.startMode===e}isDefaultGraph(){return"Minimal"===this.name||"Advanced"===this.name}getPropertyDescription(e){return this[`${e}Description`]}getQueryType(e){let r;return this.isStartMode(s.QUERY)&&1===e?r=this.startGraphQuery:2===e?r=this.expandQuery:3===e?r=this.resourceQuery:4===e?r=this.predicateLabelQuery:5===e&&(r=this.resourcePropertiesQuery),r||""}updateModel(e,r){return this.isStartMode(s.QUERY)&&1===r?this.startGraphQuery=e:2===r?this.expandQuery=e:3===r?this.resourceQuery=e:4===r?this.predicateLabelQuery=e:5===r&&(this.resourcePropertiesQuery=e),this}toSavePayload(){return{id:this.id,name:this.name,startMode:this.startMode,owner:this.owner,startQueryIncludeInferred:this.startQueryIncludeInferred,startQuerySameAs:this.startQuerySameAs,startGraphQuery:this.startGraphQuery,startIRI:this.startIRI,startIRILabel:this.startIRILabel,expandQuery:this.expandQuery,resourceQuery:this.resourceQuery,predicateLabelQuery:this.predicateLabelQuery,resourcePropertiesQuery:this.resourcePropertiesQuery,shared:this.shared,description:this.description,hint:this.hint}}get id(){return this._id}set id(e){this._id=e}get name(){return this._name}set name(e){this._name=e}get startMode(){return this._startMode}set startMode(e){this._startMode=e}get owner(){return this._owner}set owner(e){this._owner=e}get startQueryIncludeInferred(){return this._startQueryIncludeInferred}set startQueryIncludeInferred(e){this._startQueryIncludeInferred=e}get startQuerySameAs(){return this._startQuerySameAs}set startQuerySameAs(e){this._startQuerySameAs=e}get startGraphQuery(){return this._startGraphQuery}set startGraphQuery(e){this._startGraphQuery=e}get startIRI(){return this._startIRI}set startIRI(e){this._startIRI=e}get startIRILabel(){return this._startIRILabel}set startIRILabel(e){this._startIRILabel=e}get expandQuery(){return this._expandQuery}set expandQuery(e){this._expandQuery=e}get resourceQuery(){return this._resourceQuery}set resourceQuery(e){this._resourceQuery=e}get predicateLabelQuery(){return this._predicateLabelQuery}set predicateLabelQuery(e){this._predicateLabelQuery=e}get resourcePropertiesQuery(){return this._resourcePropertiesQuery}set resourcePropertiesQuery(e){this._resourcePropertiesQuery=e}get shared(){return this._shared}set shared(e){this._shared=e}get description(){return this._description}set description(e){this._description=e}get hint(){return this._hint}set hint(e){this._hint=e}get startGraphQueryDescription(){return this._startGraphQueryDescription}set startGraphQueryDescription(e){this._startGraphQueryDescription=e}get expandQueryDescription(){return this._expandQueryDescription}set expandQueryDescription(e){this._expandQueryDescription=e}get resourceQueryDescription(){return this._resourceQueryDescription}set resourceQueryDescription(e){this._resourceQueryDescription=e}get predicateLabelQueryDescription(){return this._predicateLabelQueryDescription}set predicateLabelQueryDescription(e){this._predicateLabelQueryDescription=e}get resourcePropertiesQueryDescription(){return this._resourcePropertiesQueryDescription}set resourcePropertiesQueryDescription(e){this._resourcePropertiesQueryDescription=e}}},71156:(e,r,t)=>{t.d(r,{r:()=>s});const s={WRITE:"WRITE",READ:"READ",PROTECTED:"PROTECTED"}},96367:(e,r,t)=>{t(56139),t(32150),t(96e3);var s=t(71156),a=t(15435),i=t(85727),n=t(69530),o=t(13853),u=t(6418),p=t(57154);function c(e,r,t,c,d,h,y,g,l,Q,f,w,m,I,_,R,b){let C;r.newConfig=new n.K,r.revertConfig=void 0,r.page=1,r.totalPages=5,r.helpHidden=1===w.get(m.HIDE_GRAPH_CONFIG_HELP),r.isUpdate=!1,r.shared=!1,r.canEditActiveRepo=r.canWriteActiveRepo(),r.samples=[],r.tabConfig={inference:r.newConfig.startQueryIncludeInferred,sameAs:r.newConfig.startQuerySameAs},r.isAutocompleteEnabled=void 0,r.repositoryNamespaces=void 0,r.tabsViewModel=[];const E=Q.configName,D=h.getActiveRepository();r.toggleHelp=e=>{void 0===e&&(e=w.get(m.HIDE_GRAPH_CONFIG_HELP)),1!==e?(w.set(m.HIDE_GRAPH_CONFIG_HELP,1),r.helpHidden=!0):(w.set(m.HIDE_GRAPH_CONFIG_HELP,0),r.helpHidden=!1)},r.fixedVisualCallback=(e,t)=>{r.newConfig.startIRI=e,r.newConfig.startIRILabel=t,C=!0},r.isDefaultGraph=e=>e.isDefaultGraph(),r.isUserGraph=e=>!e.isDefaultGraph(),r.getSampleName=(e,r)=>{if(!e)return"";return e.getPropertyDescription(r)||(e.id?"Copy of "+e.name:e.name)},r.createGraphConfig=e=>{l.createGraphConfig(e).success(async function(){await f.showToastMessageWithDelay("graphexplore.saved.new.config"),c.url("graphs-visualizations")}).error(function(e){d.error(getError(e),I.instant("graphexplore.error.could.not.create"))})},r.updateGraphConfig=e=>{l.updateGraphConfig(e).success(async function(){await f.showToastMessageWithDelay("graphexplore.saved.config"),c.url("graphs-visualizations")}).error(function(e){d.error(getError(e),I.instant("graphexplore.error.could.not.save"))})},r.goToPage=e=>{r.page!==e&&M(()=>{r.showEditor(),r.page=e,r.$$phase||r.$root.$$phase||r.$apply()})},r.goToPreviousPage=()=>{r.page>1&&r.goToPage(r.page-1),q()&&(C=!1)},r.goToNextPage=()=>{Y(),r.newConfig.isStartMode(n.Y.NODE)&&!C||r.goToPage(r.page+1)},r.saveGraphConfig=()=>{Y(),q()&&!C||(r.newConfig.startQueryIncludeInferred=r.tabConfig.inference,r.newConfig.startQuerySameAs=r.tabConfig.sameAs,r.newConfig.name&&(r.newConfig.name=r.newConfig.name.replace(/\s+/g," ").trim()),M(()=>{r.newConfig.name?(r.queryEditorIsDirty=!1,r.isUpdate?r.updateGraphConfig(r.newConfig.toSavePayload()):r.createGraphConfig(r.newConfig.toSavePayload())):$(I.instant("graphexplore.provide.config.name"))}))},r.setQuery=async e=>{const t=e||" ";(await v()).setQuery(t),r.markDirty()},r.markDirty=async()=>{if(r.revertConfig){const e=r.revertConfig.getQueryType(r.page),t=await x();r.queryEditorIsDirty=e!==t}},r.showEditor=()=>{r.viewMode="yasr",G(),P()},r.showPreview=()=>{r.viewMode="editor",S()},r.revertEditor=()=>{r.setQuery(r.revertConfig.getQueryType(r.page)),r.queryEditorIsDirty=!1};const v=()=>i.p3.getOntotextYasguiElementAsync("#query-editor"),S=async(e,t)=>{const s=await v(),a=await s.getQueryType();t&&"SELECT"!==a&&"CONSTRUCT"!==a&&"DESCRIBE"!==a?d.warning(I.instant("query.editor.warning.msg")):"update"!==await s.getQueryMode()?r.queryIsRunning||(r.viewMode="editor",A()):d.warning(I.instant("cannot.execute.update.error"))},A=async()=>{(await v()).query(a.o.YASR)},P=async()=>(await v()).changeRenderMode(a.o.YASQE),x=async()=>(await v()).getQuery(),G=async()=>(await v()).abortQuery(),M=async e=>{const t=await(async()=>{const e=await v();let t=await e.getQuery();return t=t.trim(),r.newConfig.updateModel(t,r.page)})();1===r.page?t.isStartMode(n.Y.NODE)&&!t.startIRI?$(I.instant("graphexplore.select.start.node")):t.isStartMode(n.Y.QUERY)&&!t.startGraphQuery?$(I.instant("graphexplore.provide.query")):t.isStartMode(n.Y.QUERY)?T(e,t.startGraphQuery,"graph"):e():2===r.page?T(e,t.expandQuery,"construct",["node"]):3===r.page?T(e,t.resourceQuery,"tuple",["node"],[],["type","label","comment","rank"]):4===r.page?T(e,t.predicateLabelQuery,"tuple",["edge"],["label"]):5===r.page&&T(e,t.resourcePropertiesQuery,"tuple",["node"],["property","value"])},L=()=>{r.tabConfig.inference=r.newConfig.startQueryIncludeInferred,r.tabConfig.sameAs=r.newConfig.startQuerySameAs,r.setQuery(r.newConfig.getQueryType(r.page))},$=e=>{d.warning(e)},T=(e,r,t,s,a,i)=>{r?l.validateQuery(r,t,s,a,i).success(()=>{e()}).error(e=>{$(getError(e))}):e()},Y=()=>{q()&&r.$broadcast("addStartFixedNodeAutomatically",{startIRI:r.newConfig.startIRI})},q=()=>1===r.page&&r.newConfig.isStartMode(n.Y.NODE),N=()=>{l.getGraphConfigSamples().success(function(e){r.samples=(0,o.yF)(e).filter(e=>!e.id||r.newConfig.id!==e.id||(r.revertConfig=e,!1))}).error(function(e){d.error(getError(e),I.instant("graphexplore.error.graph.configs"))})},H={endpoint:()=>`repositories/${h.getActiveRepository()}`,showEditorTabs:!1,showToolbar:!1,showResultTabs:!1,showYasqeActionButtons:!1,yasqeActionButtons:i.Dg,showQueryButton:!1,initialQuery:" ",componentId:"graphs-config",render:a.o.YASQE,maxPersistentResponseSize:0,showYasqeResizer:!1,yasqeMode:s.r.READ,infer:r.newConfig.startQueryIncludeInferred,sameAs:r.newConfig.startQuerySameAs},U=(e,t,s)=>{r.queryIsRunning=e},k=()=>{window.removeEventListener("beforeunload",O),W.forEach(e=>e())},O=e=>{r.queryEditorIsDirty&&(e.returnValue=!0)},F=()=>{r.tabsViewModel=[{page:1,label:I.instant("starting.point.label"),type:"startGraphQuery"},{page:2,label:I.instant("graph.expansion"),type:"expandQuery"},{page:3,label:I.instant("node.basics"),type:"resourceQuery"},{page:4,label:I.instant("edge.basics"),type:"predicateLabelQuery"},{page:5,label:I.instant("node.extra"),type:"resourcePropertiesQuery"}]},W=[];W.push(p.ServiceProvider.get(p.RepositoryContextService).onSelectedRepositoryChanged(e=>{e?b.getNamespaces(e.id).then(e=>{r.repositoryNamespaces=e}).catch(e=>{const r=getError(e);d.error(r,I.instant("error.getting.namespaces.for.repo"))}):r.repositoryNamespaces=new u.u})),W.push(R.onAutocompleteEnabledUpdated(e=>{r.isAutocompleteEnabled=e})),W.push(r.$on("$locationChangeStart",(e,t)=>{var s,a,i,n;r.queryEditorIsDirty?(e.preventDefault(),s=I.instant("common.confirm"),a=I.instant("visual.config.warning.unsaved.changes"),i=()=>{k();const e=c.absUrl().length-c.url().length,r=t.substring(e);c.path(r)},_.openSimpleModal({title:s,message:a,warning:!0}).result.then(function(){angular.isFunction(i)&&i()},function(){angular.isFunction(n)&&n()})):k()})),W.push(r.$on("$destroy",k)),W.push(r.$watch(r.getActiveRepositoryObject,()=>{(r.newConfig.isStartMode(n.Y.QUERY)||r.page>1)&&(r.viewMode="yasr",G().then(P))})),W.push(e.$on("$translateChangeSuccess",()=>{F()})),window.addEventListener("beforeunload",O),r.$watch("newConfig.startMode",e=>{e===n.Y.QUERY&&L()}),r.$watch("page",e=>{(r.newConfig.isStartMode(n.Y.QUERY)||e>1)&&(r.showEditor(),L())}),F(),h.getPrefixes(D).then(e=>(e=>{const t=r.$watch(function(){return r.getActiveRepositoryObject()},function(a){if(a){r.canEditActiveRepo=r.canWriteActiveRepo();const a=angular.extend({},H,{prefixes:e,yasqeMode:r.canWriteActiveRepo()?s.r.WRITE:s.r.READ});r.yasguiConfig=a,t()}})})(e)).finally(()=>U(!1)),E?(r.isUpdate=!0,l.getConfig(E).then(function(e){r.newConfig=e,N()}).catch(e=>{d.error(getError(e),I.instant("created.connector",{name:E}))})):(r.isUpdate=!1,N()),r.getActiveRepository()&&(U(!0,I.instant("common.refreshing.namespaces"),I.instant("common.extra.message")),h.getPrefixes(h.getActiveRepository()).then(e=>{r.namespaces=e}).catch(function(e){r.repositoryError=getError(e)}).finally(function(){U(!1)}))}angular.module("graphdb.framework.graphexplore.controllers.graphviz.config",["graphdb.framework.utils.notifications","graphdb.framework.utils.localstorageadapter","graphdb.core.services.workbench-context","graphdb.framework.core.services.rdf4j.repositories"]).controller("GraphConfigCtrl",c),c.$inject=["$rootScope","$scope","$timeout","$location","toastr","$repositories","SparqlRestService","$filter","GraphConfigRestService","$routeParams","Notifications","LocalStorageAdapter","LSKeys","$translate","ModalService","WorkbenchContextService","RDF4JRepositoriesService"]}}; //# sourceMappingURL=96367.686b23fe2e636f75b864.bundle.js.map