UNPKG

graphdb-workbench

Version:
2 lines 14.4 kB
export const __webpack_id__=12534;export const __webpack_ids__=[12534,13662,15435,50470,68766,72745,81639,88046];export const __webpack_modules__={13662:(e,t,o)=>{o.r(t),o.d(t,{ResourceInfo:()=>s});var r=o(68766),n=o(81639);class s{constructor(){this.role="subject",this.uri=void 0,this.triple=void 0,this.context=void 0,this.contextType=n.ContextTypes.EXPLICIT,this.sameAs=!0,this.details=new r.ResourceDetails,this.blanks=!0}}},15435:(e,t,o)=>{o.r(t),o.d(t,{RenderingMode:()=>r});const r={YASGUI:"mode-yasgui",YASQE:"mode-yasqe",YASR:"mode-yasr"}},50470:()=>{angular.module("graphdb.framework.rest.explore.rest.service",[]).factory("ExploreRestService",t),t.$inject=["$http"];const e="rest/explore";function t(t){return{getResourceDetails:(o,r,n,s)=>t.get(`${e}/details`,{params:{uri:o,triple:r,context:n},headers:{Accept:s||"application/json"}}),getGraph:(o,r,n)=>t.get(`${e}/graph`,{params:{uri:o.uri,triple:o.triple,inference:o.contextType.id,role:o.role,bnodes:o.blanks,sameAs:o.sameAs,context:o.context},headers:{Accept:r||"application/x-graphdb-table-results+json",Link:n?"<"+n+">":""}}).then(e=>e.data)}}},53291:()=>{},68766:(e,t,o)=>{o.r(t),o.d(t,{ResourceDetails:()=>r});class r{constructor(){this.image=void 0,this.uri=void 0,this.label=void 0,this.encodeURI=void 0,this.comment=void 0,this.context=void 0}}},72745:()=>{angular.module("graphdb.workbench.utils.filetypes",[]).value("FileTypes",[{name:"JSON",translateKey:"download.as.json",type:"application/rdf+json",extension:".json"},{name:"JSON-LD",translateKey:"download.as.jsonld",type:"application/ld+json",extension:".jsonld"},{name:"NDJSON-LD",translateKey:"download.as.ndjsonld",type:"application/x-ld+ndjson",extension:".ndjsonld"},{name:"RDF-XML",translateKey:"download.as.rdfxml",type:"application/rdf+xml",extension:".rdf"},{name:"N3",translateKey:"download.as.n3",type:"text/rdf+n3",extension:".n3"},{name:"N-Triples",translateKey:"download.as.ntriples",type:"text/plain",extension:".nt"},{name:"N-Quads",translateKey:"download.as.nquads",type:"text/x-nquads",extension:".nq"},{name:"Turtle",translateKey:"download.as.turtle",type:"text/turtle",extension:".ttl"},{name:"Turtle*",translateKey:"download.as.turtlestar",type:"application/x-turtlestar",extension:".ttls"},{name:"TriX",translateKey:"download.as.trix",type:"application/trix",extension:".trix"},{name:"TriG",translateKey:"download.as.trig",type:"application/x-trig",extension:".trig"},{name:"TriG*",translateKey:"download.as.trigstar",type:"application/x-trigstar",extension:".trigs"},{name:"Binary RDF",translateKey:"download.as.binaryrdf",type:"application/x-binary-rdf",extension:".brf"}])},74036:(e,t,o)=>{o.r(t),o(72745),o(50470);var r=o(76752),n=o(69937),s=o(13662),a=o(81639),i=o(88046),c=o(15435),l=o(85727),p=o(63222),u=o(64341);function d(e,t,o,n,d,f,m,x,g,h,y,w,R,T){let I;e.ContextTypes=a.ContextTypes,e.contextTypes=a.ContextType.getAllType(),e.currentContextTypeId=a.ContextTypes.EXPLICIT.id,e.roles=[i.RoleType.SUBJECT,i.RoleType.PREDICATE,i.RoleType.OBJECT,i.RoleType.CONTEXT,i.RoleType.ALL],e.resourceInfo=void 0,e.isLoading=!1,e.fileTypes=h,e.toggleSameAs=()=>{e.resourceInfo.sameAs=!e.resourceInfo.sameAs,e.exploreResource()},e.getActiveRepository=()=>d.getActiveRepository(),e.isTripleResource=()=>!!e.resourceInfo.triple,e.encodeURIComponent=e=>encodeURIComponent(e),e.getRdfStarLocalNames=e=>{let t=e.slice();return e.replace(/[<>]+/g,"").split(" ").forEach(e=>{t=t.replace(e,m.getLocalName(e))}),t},e.getLocalName=e=>m.getLocalName(e),e.loadResource=()=>{T.getResourceDetails(e.resourceInfo.uri,e.resourceInfo.triple,e.resourceInfo.context).success(t=>{e.resourceInfo.details=t,e.resourceInfo.context=e.resourceInfo.details.context,"object"!==e.resourceInfo.uri&&(e.resourceInfo.details.encodeURI=encodeURIComponent(e.resourceInfo.details.uri))}).error(e=>o.error(w.instant("explore.error.resource.details",{data:getError(e)}))),e.exploreResource()},e.isContextAvailable=()=>null!==e.resourceInfo.context&&"http://rdf4j.org/schema/rdf4j#SHACLShapeGraph"===e.resourceInfo.context,e.goToGraphsViz=()=>{t.path("graphs-visualizations").search("uri",e.resourceInfo.uri)},e.exploreResource=()=>{v(!0),null!=n.context&&(e.resourceInfo.context=n.context),t.search("role",e.resourceInfo.role),t.replace(),C()},e.downloadExport=t=>{T.getGraph(e.resourceInfo,t.type).then(e=>{t.type.indexOf("json")>-1&&(e=JSON.stringify(e));const o=navigator.userAgent.toLowerCase();if(-1!==o.indexOf("safari")&&-1===o.indexOf("chrome"))window.open('data:attachment/csv;filename="statements.'+t.extension+'",'+encodeURIComponent(e),"statements."+t.extension);else{const o=new Blob([e],{type:t.type});(0,r.saveAs)(o,"statements"+t.extension)}}).catch(e=>{o.error(getError(e),w.instant("common.error"))}).finally(()=>{v(!1)})},e.openJSONLDExportSettings=function(t){f.open({templateUrl:"js/angular/core/components/export-settings-modal/exportSettingsModal.html",controller:u.ExportSettingsCtrl,size:"lg",scope:e,resolve:{format:function(){return t.name}}}).result.then(function(o){e.downloadJSONLDExport(t,o.link,o.currentMode)})},e.downloadJSONLDExport=function(t,n,s){T.getGraph(e.resourceInfo,t.type,n).then(async function(e){if("JSON"===t.name&&(e=JSON.stringify(e)),"JSON-LD"===t.name)switch(s.name){case"expanded":e=await p.expand(e),e=JSON.stringify(e);break;case"flattened":e=await p.flatten(e,n),e=JSON.stringify(e);break;case"compacted":case"framed":e=await p.compact(e,n),e=JSON.stringify(e);break;case"context":e=await p.context(e,n),e=JSON.stringify(e);break;case"frame":e=await p.frame(e,n),e=JSON.stringify(e)}const o=navigator.userAgent.toLowerCase();if(-1!==o.indexOf("safari")&&-1===o.indexOf("chrome"))window.open('data:attachment/csv;filename="statements.'+t.extension+'",'+encodeURIComponent(e),"statements."+t.extension);else{const o=new Blob([e],{type:t.type});(0,r.saveAs)(o,"statements"+t.extension)}}).catch(function(e){const t=getError(e);o.error(t,w.instant("common.error"))})},e.changeRole=t=>{e.resourceInfo.role=t,e.resourceInfo.role===i.RoleType.CONTEXT&&(e.resourceInfo.contextType=a.ContextTypes.EXPLICIT),e.exploreResource()},e.changeInference=t=>{e.resourceInfo.contextType=a.ContextType.getContextType(t),e.exploreResource()},e.copyToClipboardResult=e=>{x.openCopyToClipboardModal(e)},window.Cypress&&(window.jsonld=p);const v=t=>{e.isLoading=!!t},C=()=>{T.getGraph(e.resourceInfo).then(t=>{((t={})=>{const o={};angular.extend(o,e.yasguiConfig||{showEditorTabs:!1,showToolbar:!1,showResultTabs:!1,showResultInfo:!0,downloadAsOn:!1,showQueryButton:!1,componentId:"resource-view-component",prefixes:I,maxPersistentResponseSize:0,render:c.RenderingMode.YASR,showYasqeActionButtons:!1,yasqeActionButtons:l.DISABLE_YASQE_BUTTONS_CONFIGURATION},t),e.yasguiConfig=o})({sparqlResponse:t})}).catch(e=>{o.error(w.instant("explore.error.resource",{data:getError(e)}))}).finally(()=>{v(!1)})};e.$on("$destroy",()=>{b.forEach(e=>e())});const b=[];b.push(e.$watch(function(){return e.getActiveRepositoryObject()},function(r){r&&Promise.all([y.getPrincipal(),d.getPrefixes(d.getActiveRepository())]).then(([o,r])=>{var c;e.resourceInfo||(e.resourceInfo=new s.ResourceInfo,c=e.resourceInfo,n.prefix&&n.localName&&I[n.prefix]?c.uri=I[n.prefix]+n.localName:t.search().uri?c.uri=t.search().uri+(t.hash()?"#"+t.hash():""):t.search().triple?c.triple=t.search().triple+(t.hash()?"#"+t.hash():""):c.uri=t.absUrl(),c.uri=c.uri&&c.uri.replace(/<|>/g,""),null!=n.context&&(e.resourceInfo.context=n.context),e.resourceInfo.role=t.search().role?t.search().role:i.RoleType.SUBJECT),(t=>{e.resourceInfo.contextType=t.appSettings.DEFAULT_INFERENCE&&!e.resourceInfo.role===i.RoleType.CONTEXT?a.ContextTypes.ALL:a.ContextTypes.EXPLICIT,e.resourceInfo.sameAs=t.appSettings.DEFAULT_INFERENCE&&t.appSettings.DEFAULT_SAMEAS})(o),I=r,e.loadResource()}).catch(e=>{o.error(w.instant("get.namespaces.error.msg",{error:getError(e)}))})}))}function f(e,t,o,r,s,a,i,c,l,p,u,d){function f(){c.checkAutocompleteStatus().success(function(t){if(!t){const e=(0,n.Gz)(d.instant("explore.autocomplete.warning.msg"));i.warning("",`<div class="autocomplete-toast"><a href="autocomplete">${e}</a></div>`,{allowHtml:!0})}e.autocompleteEnabled=t}).error(function(){i.error(d.instant("explore.error.autocomplete"))})}function m(){u.getNamespaces(r.getActiveRepository()).success(function(t){e.namespaces=t.results.bindings.map(function(e){return{prefix:e.prefix.value,uri:e.namespace.value}}),e.loader=!1}).error(function(t){const o=getError(t);i.error(o,d.instant("common.error")),e.loader=!1})}function x(e){const t=e.indexOf("<")>=0&&e.lastIndexOf(">")===e.length-1,o=-1===e.indexOf("<")&&-1===e.lastIndexOf(">"),r=/^<?[http|urn].*>?$/.test(e)&&(t||o);let n=!1;if(r)if(e.indexOf("http")>=0){const t=e.indexOf("//");n=t>4&&e.substring(t+2).length>0}else e.indexOf("urn")>=0&&(n=e.substring(4).length>0);return r&&n}let g,h;function y(t){function r(t){a(function(){e.form&&(e.form.$dirty=t)})}t||(t=document.getElementById("resources_finder_value").value),t&&x(t)?(r(!1),o.path("resource").search("uri",t)):(r(!0),t&&i.error(d.instant("explore.error.invalid.input")))}e.submit=y,e.getAutocompleteSuggestions=function(t){if(!/<|>/.test(t)&&":"===t.slice(-1)){const o=l.getNamespaceUriForPrefix(e.namespaces,t.slice(0,-1));h=o!==h?o:h,h&&$("#resources_finder_value").val(h)}let o;if(e.autocompleteEnabled){const e=t.replace(h,h+";");o=c.getAutocompleteSuggestions(e)}else o=s.when(e.autocompleteEnabled);return o},e.inputChangedFn=function(){g=document.getElementById("resources_finder_value").value,e.form.$dirty=!(g&&x(g))},e.selectedUriCallback=function(t){e.selectedUri={name:t.title},y(e.selectedUri.name)},e.selectedUri={name:""},e.autocompleteEnabled=!1,angular.isDefined(p.search)&&a(function(){$("#resources_finder_value").val(p.search),$(".search-button").click()},500),e.getActiveRepository()&&(f(),m()),e.$on("repositoryIsSet",function(){f(),m()})}function m(e,t,o,r,n,s,a,i,c,l,p){e.uriParam=o.search().uri,e.newRow={subject:e.uriParam,object:{type:"uri",datatype:""}},e.newResource=!1,e.datatypeOptions=c.getDatatypeOptions(),e.activeRepository=function(){return n.getActiveRepository()},e.getClassInstancesDetails=function(){l.getNamespaces(e.activeRepository()).success(function(t){e.namespaces=t.results.bindings.map(function(e){return{prefix:e.prefix.value,uri:e.namespace.value}}),e.loader=!1}).error(function(t){const o=getError(t);r.error(o,p.instant("common.error")),e.loader=!1}),i.getDetails(e.uriParam).success(function(t){e.details=t,e.details.encodeURI=encodeURIComponent(e.details.uri)}).error(function(e){r.error(p.instant("explore.error.resource.details",{data:getError(e)}))}),i.getGraph(e.uriParam).then(function(t){const o=c.buildStatements(t,e.uriParam);e.statements=o,e.newResource=!o.length})},e.addStatement=function(){e.newRowPredicate.$setSubmitted(),e.newRowObject.$setSubmitted(),e.newRowContext.$setSubmitted(),e.newRowPredicate.$valid&&e.newRowObject.$valid&&e.newRowContext.$valid&&(e.statements.push(_.cloneDeep(e.newRow)),e.newRow={subject:e.uriParam,object:{type:"uri",datatype:""}},e.newRowPredicate.$setPristine(),e.newRowPredicate.$setUntouched(),e.newRowObject.$setPristine(),e.newRowObject.$setUntouched(),e.newRowContext.$setPristine(),e.newRowContext.$setUntouched())},e.removeStatement=function(t){e.statements.splice(t,1)},e.getLocalName=function(e){return i.getLocalName(e)},e.checkValid=function(e){return!angular.isUndefined(e)||p.instant("explore.validation")},e.validEditRow=function(){return e.rowform.$valid},e.viewTrig=function(){s.open({templateUrl:"js/angular/explore/templates/viewTrig.html",controller:"ViewTrigCtrl",size:"lg",resolve:{data:function(){return c.transformToTrig(e.statements)}}})},e.save=function(){const n=e.newResource?"POST":"PUT";t({method:n,url:"rest/resource?uri="+encodeURIComponent(e.uriParam),headers:{"Content-Type":"application/x-trig"},data:c.transformToTrig(e.statements)}).success(function(){r.success(p.instant("explore.resource.saved"));const t=a(function(){o.path("resource").search("uri",e.uriParam)},500);e.$on("$destroy",function(){a.cancel(t)})}).error(function(e){r.error(getError(e))})},e.$watch(function(){return n.getActiveRepository()},function(){e.activeRepository()&&e.getClassInstancesDetails()}),e.validateUri=function(t){let o=!0;const r=t||"";if(-1===r.indexOf(":"))o=!1;else{const t=r.substring(0,r.indexOf(":"));if(""===i.getNamespaceUriForPrefix(e.namespaces,t)){!1===/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/.test(r)&&(o=!1);const e=r.match(/\//g);(void 0===e||e.length<3)&&(o=!1)}else r.substring(r.indexOf(":")+1).trim().length<1&&(o=!1)}return o}}function x(e,t,o){e.trig=o,e.cancel=function(){t.dismiss("cancel")}}angular.module("graphdb.framework.explore.controllers",["ngCookies","ngRoute","ui.bootstrap","toastr","graphdb.framework.core","graphdb.framework.core.services.repositories","graphdb.framework.explore.services","graphdb.workbench.utils.filetypes","graphdb.framework.rest.explore.rest.service"]).controller("FindResourceCtrl",f).controller("ExploreCtrl",d).controller("EditResourceCtrl",m).controller("ViewTrigCtrl",x),d.$inject=["$scope","$location","toastr","$routeParams","$repositories","$uibModal","ClassInstanceDetailsService","ModalService","RDF4JRepositoriesRestService","FileTypes","$jwtAuth","$translate","$q","ExploreRestService"],f.$inject=["$scope","$http","$location","$repositories","$q","$timeout","toastr","AutocompleteRestService","ClassInstanceDetailsService","$routeParams","RDF4JRepositoriesRestService","$translate"],m.$inject=["$scope","$http","$location","toastr","$repositories","$uibModal","$timeout","ClassInstanceDetailsService","StatementsService","RDF4JRepositoriesRestService","$translate"],x.$inject=["$scope","$uibModalInstance","data"]},81639:(e,t,o)=>{o.r(t),o.d(t,{ContextType:()=>r,ContextTypes:()=>n});class r{constructor(e,t){this.id=e,this.labelKey=t}static getAllType(){return[n.ALL,n.EXPLICIT,n.IMPLICIT]}static getContextType(e){return this.getAllType().find(t=>t.id===e)}}const n={ALL:new r("all","explore.explicit.implicit"),EXPLICIT:new r("explicit","explore.explicit"),IMPLICIT:new r("implicit","explore.implicit")}},88046:(e,t,o)=>{o.r(t),o.d(t,{RoleType:()=>r});const r={SUBJECT:"subject",PREDICATE:"predicate",OBJECT:"object",CONTEXT:"context",ALL:"all"}}}; //# sourceMappingURL=12534.7a5313a678e26232f755.bundle.js.map