graphdb-workbench
Version:
The web application for GraphDB APIs
2 lines • 13.5 kB
JavaScript
export const __webpack_id__=96367;export const __webpack_ids__=[13853,15435,56139,69530,71156,96367];export const __webpack_modules__={13853:(e,r,t)=>{t.r(r),t.d(r,{mapGraphConfigSampleToGraphConfig:()=>i,mapGraphConfigSamplesToGraphConfigs:()=>o,mapGraphsConfigResponseToModel:()=>a});var s=t(69530);const a=e=>new s.GraphsConfig(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=>new s.GraphsConfig(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),o=e=>e.map(e=>i(e))},15435:(e,r,t)=>{t.r(r),t.d(r,{RenderingMode:()=>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.r(r),t.d(r,{GraphsConfig:()=>a,StartMode:()=>s});const s={QUERY:"query",NODE:"node",SEARCH:"search"};class a{constructor(e,r,t=s.SEARCH,a,i=!0,o=!0,n,u,p,c,d,h,g,y,l,Q,f,m,w,I,_){this._id=e,this._name=r,this._startMode=t,this._owner=a,this._startQueryIncludeInferred=i,this._startQuerySameAs=o,this._startGraphQuery=n,this._startIRI=u,this._startIRILabel=p,this._expandQuery=c,this._resourceQuery=d,this._predicateLabelQuery=h,this._resourcePropertiesQuery=g,this._shared=y,this._description=l,this._hint=Q,this._startGraphQueryDescription=f,this._expandQueryDescription=m,this._resourceQueryDescription=w,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.r(r),t.d(r,{YasqeMode:()=>s});const s={WRITE:"WRITE",READ:"READ",PROTECTED:"PROTECTED"}},96367:(e,r,t)=>{t.r(r),t(56139),t(32150),t(96e3);var s=t(71156),a=t(15435),i=t(85727),o=t(69530),n=t(13853),u=t(6418),p=t(57154);function c(e,r,t,c,d,h,g,y,l,Q,f,m,w,I,_,C,R){let b;r.newConfig=new o.GraphsConfig,r.revertConfig=void 0,r.page=1,r.totalPages=5,r.helpHidden=1===m.get(w.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 S=Q.configName,E=h.getActiveRepository();r.toggleHelp=e=>{void 0===e&&(e=m.get(w.HIDE_GRAPH_CONFIG_HELP)),1!==e?(m.set(w.HIDE_GRAPH_CONFIG_HELP,1),r.helpHidden=!0):(m.set(w.HIDE_GRAPH_CONFIG_HELP,0),r.helpHidden=!1)},r.fixedVisualCallback=(e,t)=>{r.newConfig.startIRI=e,r.newConfig.startIRILabel=t,b=!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&&x(()=>{r.showEditor(),r.page=e,r.$$phase||r.$root.$$phase||r.$apply()})},r.goToPreviousPage=()=>{r.page>1&&r.goToPage(r.page-1),q()&&(b=!1)},r.goToNextPage=()=>{N(),r.newConfig.isStartMode(o.StartMode.NODE)&&!b||r.goToPage(r.page+1)},r.saveGraphConfig=()=>{N(),q()&&!b||(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()),x(()=>{r.newConfig.name?(r.queryEditorIsDirty=!1,r.isUpdate?r.updateGraphConfig(r.newConfig.toSavePayload()):r.createGraphConfig(r.newConfig.toSavePayload())):T(I.instant("graphexplore.provide.config.name"))}))},r.setQuery=async e=>{const t=e||" ";(await D()).setQuery(t),r.markDirty()},r.markDirty=async()=>{if(r.revertConfig){const e=r.revertConfig.getQueryType(r.page),t=await G();r.queryEditorIsDirty=e!==t}},r.showEditor=()=>{r.viewMode="yasr",P(),A()},r.showPreview=()=>{r.viewMode="editor",v()},r.revertEditor=()=>{r.setQuery(r.revertConfig.getQueryType(r.page)),r.queryEditorIsDirty=!1};const D=()=>i.YasguiComponentDirectiveUtil.getOntotextYasguiElementAsync("#query-editor"),v=async(e,t)=>{const s=await D(),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",M()):d.warning(I.instant("cannot.execute.update.error"))},M=async()=>{(await D()).query(a.RenderingMode.YASR)},A=async()=>(await D()).changeRenderMode(a.RenderingMode.YASQE),G=async()=>(await D()).getQuery(),P=async()=>(await D()).abortQuery(),x=async e=>{const t=await(async()=>{const e=await D();let t=await e.getQuery();return t=t.trim(),r.newConfig.updateModel(t,r.page)})();1===r.page?t.isStartMode(o.StartMode.NODE)&&!t.startIRI?T(I.instant("graphexplore.select.start.node")):t.isStartMode(o.StartMode.QUERY)&&!t.startGraphQuery?T(I.instant("graphexplore.provide.query")):t.isStartMode(o.StartMode.QUERY)?$(e,t.startGraphQuery,"graph"):e():2===r.page?$(e,t.expandQuery,"construct",["node"]):3===r.page?$(e,t.resourceQuery,"tuple",["node"],[],["type","label","comment","rank"]):4===r.page?$(e,t.predicateLabelQuery,"tuple",["edge"],["label"]):5===r.page&&$(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))},T=e=>{d.warning(e)},$=(e,r,t,s,a,i)=>{r?l.validateQuery(r,t,s,a,i).success(()=>{e()}).error(e=>{T(getError(e))}):e()},N=()=>{q()&&r.$broadcast("addStartFixedNodeAutomatically",{startIRI:r.newConfig.startIRI})},q=()=>1===r.page&&r.newConfig.isStartMode(o.StartMode.NODE),Y=()=>{l.getGraphConfigSamples().success(function(e){r.samples=(0,n.mapGraphConfigSamplesToGraphConfigs)(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"))})},U={endpoint:()=>`repositories/${h.getActiveRepository()}`,showEditorTabs:!1,showToolbar:!1,showResultTabs:!1,showYasqeActionButtons:!1,yasqeActionButtons:i.INFERRED_AND_SAME_AS_BUTTONS_CONFIGURATION,showQueryButton:!1,initialQuery:" ",componentId:"graphs-config",render:a.RenderingMode.YASQE,maxPersistentResponseSize:0,showYasqeResizer:!1,yasqeMode:s.YasqeMode.READ,infer:r.newConfig.startQueryIncludeInferred,sameAs:r.newConfig.startQuerySameAs},H=(e,t,s)=>{r.queryIsRunning=e},O=()=>{window.removeEventListener("beforeunload",k),W.forEach(e=>e())},k=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?R.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.NamespacesListModel})),W.push(C.onAutocompleteEnabledUpdated(e=>{r.isAutocompleteEnabled=e})),W.push(r.$on("$locationChangeStart",(e,t)=>{var s,a,i,o;r.queryEditorIsDirty?(e.preventDefault(),s=I.instant("common.confirm"),a=I.instant("visual.config.warning.unsaved.changes"),i=()=>{O();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(o)&&o()})):O()})),W.push(r.$on("$destroy",O)),W.push(r.$watch(r.getActiveRepositoryObject,()=>{(r.newConfig.isStartMode(o.StartMode.QUERY)||r.page>1)&&(r.viewMode="yasr",P().then(A))})),W.push(e.$on("$translateChangeSuccess",()=>{F()})),window.addEventListener("beforeunload",k),r.$watch("newConfig.startMode",e=>{e===o.StartMode.QUERY&&L()}),r.$watch("page",e=>{(r.newConfig.isStartMode(o.StartMode.QUERY)||e>1)&&(r.showEditor(),L())}),F(),h.getPrefixes(E).then(e=>(e=>{const t=r.$watch(function(){return r.getActiveRepositoryObject()},function(a){if(a){r.canEditActiveRepo=r.canWriteActiveRepo();const a=angular.extend({},U,{prefixes:e,yasqeMode:r.canWriteActiveRepo()?s.YasqeMode.WRITE:s.YasqeMode.READ});r.yasguiConfig=a,t()}})})(e)).finally(()=>H(!1)),S?(r.isUpdate=!0,l.getConfig(S).then(function(e){r.newConfig=e,Y()}).catch(e=>{d.error(getError(e),I.instant("created.connector",{name:S}))})):(r.isUpdate=!1,Y()),r.getActiveRepository()&&(H(!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(){H(!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.7cf90e4a446119fed05e.bundle.js.map