graphdb-workbench
Version:
The web application for GraphDB APIs
2 lines • 8.97 kB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[34,103],{36:function(e,t){angular.module("graphdb.workbench.utils.filetypes",[]).value("FileTypes",[{name:"JSON",type:"application/rdf+json",extension:".json"},{name:"JSON-LD",type:"application/ld+json",extension:".jsonld"},{name:"RDF-XML",type:"application/rdf+xml",extension:".rdf"},{name:"N3",type:"text/rdf+n3",extension:".n3"},{name:"N-Triples",type:"text/plain",extension:".nt"},{name:"N-Quads",type:"text/x-nquads",extension:".nq"},{name:"Turtle",type:"text/turtle",extension:".ttl"},{name:"Turtle*",type:"application/x-turtlestar",extension:".ttls"},{name:"TriX",type:"application/trix",extension:".trix"},{name:"TriG",type:"application/x-trig",extension:".trig"},{name:"TriG*",type:"application/x-trigstar",extension:".trigs"},{name:"Binary RDF",type:"application/x-binary-rdf",extension:".brf"}])},48:function(e,t,r){"use strict";r.r(t);r(2),r(8),r(9),r(36);angular.module("graphdb.framework.impex.export.controllers",["ngCookies","ui.bootstrap","toastr","graphdb.framework.core.services.repositories","graphdb.framework.core.services.jwtauth","graphdb.workbench.utils.filetypes"]).controller("ExportCtrl",["$scope","$http","$location","$timeout","ModalService","filterFilter","$repositories","toastr","RDF4JRepositoriesRestService","FileTypes",function(e,t,r,o,n,a,i,s,p,l){e.getActiveRepository=function(){return i.getActiveRepository()},e.exportFormats=l,e.deleting={},e.showExportDDTooltip=!0,e.page=1,e.pageSize=10,e.pageSizeOptions=[10,20,50,100],e.displayGraphs=[],e.exportFilter="",e.export=!0,e.exportMultipleGraphs=!1,e.repoExportFormat={name:"TriG",type:"application/x-trig",extension:".trig"},e.selectedGraphs={exportGraphs:{}},e.$watch((function(){return i.getActiveRepository()}),(function(){e.exportFilter="",e.getGraphs(),e.selectedAll=!1,o((function(){e.changePageSize(10)}),100)})),e.isShacl=function(e){return"http%3A%2F%2Frdf4j.org%2Fschema%2Frdf4j%23SHACLShapeGraph"===e},e.getGraphs=function(){e.getActiveRepository()?(e.loader=!0,p.getGraphs(e.getActiveRepository()).success((function(t){t.results.bindings.unshift({contextID:{type:"default",value:"The default graph"}}),e.graphsByValue={},Object.keys(t.results.bindings).forEach((function(r){const o=t.results.bindings[r];"bnode"===o.contextID.type?o.contextID.value="_:"+o.contextID.value:"default"===o.contextID.type?(o.contextID.uri=encodeURIComponent("http://www.openrdf.org/schema/sesame#nil"),o.contextID.clearUri="DEFAULT",o.contextID.exportUri="null",o.contextID.longName="default graph"):(o.contextID.uri=encodeURIComponent(o.contextID.value),o.contextID.clearUri="GRAPH <"+o.contextID.value+">",o.contextID.exportUri=encodeURIComponent("<"+o.contextID.value+">"),o.contextID.longName="named graph "+o.contextID.value),e.graphsByValue[o.contextID.value]=o.contextID})),e.graphs=t.results.bindings,e.filteredGraphs=angular.copy(e.graphs),e.displayGraphs=e.filteredGraphs.slice(e.pageSize*(e.page-1),e.pageSize*e.page),e.loader=!1,e.selectedGraphs.exportGraphs={},e.matchedElements=e.graphs})).error((function(t,r){const o=getError(t,r);"There is no active location!"===o&&(i.setRepository(""),s.error(o,"Error")),e.loader=!1}))):e.loader=!1},e.onGraphSearch=function(){e.matchedElements=[],e.deselectAll(),e.filterResults()},e.filterResults=function(){angular.forEach(e.graphs,(function(t){-1!==t.contextID.value.indexOf(e.exportFilter)&&e.matchedElements.push(t)}))},e.downloadExport=function(e,t){let r=e+"&Accept="+encodeURIComponent(t.type);const o=localStorage.getItem("com.ontotext.graphdb.auth");o&&(r=r+"&authToken="+encodeURIComponent(o)),window.open(r)},e.openExportDDTooltip=function(){e.showExportDDTooltip&&(o((function(){$("#tooltipTarget").trigger("showExportDDTooltip")}),0),o((function(){$("#tooltipTarget").trigger("showExportDDTooltip")}),3e3),e.showExportDDTooltip=!1)},e.exportRepo=function(t,r){"application/rdf+xml"===t.type||"text/plain"===t.type||"text/turtle"===t.type||"application/x-turtlestar"===t.type||"text/rdf+n3"===t.type?n.openSimpleModal({title:"Warning",message:"This format does not support graphs.<br>Graph information will not be available in the export.",warning:!0}).result.then((function(){e.startDownload(t,r)})):e.startDownload(t,r)},e.startDownload=function(t,r){let o;o=r?"repositories/"+e.getActiveRepository()+"/statements?infer=false&context="+e.graphsByValue[r.value].exportUri:"repositories/"+e.getActiveRepository()+"/statements?infer=false",e.downloadExport(o,t)},e.hasMultipleSelected=function(){if(_.isEmpty(e.selectedGraphs.exportGraphs))return!_.isEmpty(e.selectedGraphs.exportGraphs);for(const t in e.selectedGraphs.exportGraphs)if(!0===e.selectedGraphs.exportGraphs[t])return!0;return!1},e.exportSelectedGraphs=function(t){let r="";for(const t in e.selectedGraphs.exportGraphs)e.selectedGraphs.exportGraphs[t]&&(r+="context="+e.graphsByValue[t].exportUri+"&");if(r){const o=function(){r=r.substring(0,r.length-1);const o="repositories/"+e.getActiveRepository()+"/statements?infer=false&"+r;e.downloadExport(o,t)};"application/rdf+xml"===t.type||"text/plain"===t.type||"text/turtle"===t.type||"application/x-turtlestar"===t.type||"text/rdf+n3"===t.type?n.openSimpleModal({title:"Warning",message:"This format does not support graphs.<br>Graph information will not be available in the export.",warning:!0}).result.then((function(){o()})):o()}else n.openSimpleModal({title:"Multiple graph export",message:"Check graphs you want to export first.",warning:!0})},e.$watch("exportFilter",(function(){if(e.filteredGraphs=a(e.graphs,e.exportFilter),e.getActiveRepository()&&angular.element(document).find(".btn.btn-secondary.btn-sm.dropdown-toggle span").length){const t=angular.element(document).find(".btn.btn-secondary.btn-sm.dropdown-toggle span")[0].innerHTML.trim();let r;"All"===t&&(r=e.filteredGraphs.length),e.filteredGraphs&&e.filteredGraphs.length>e.pageSize&&"All"!==t&&(r=e.pageSize),e.changePageSize(r),e.changePagination()}})),e.changePagination=function(){e.selectedAll=!1,angular.isDefined(e.filteredGraphs)&&(e.displayGraphs=e.filteredGraphs.slice(e.pageSize*(e.page-1),e.pageSize*e.page))},e.changePageSize=function(t){$(".ot-graph-page-size").removeClass("active"),e.page=1,t&&(e.pageSize=t,e.changePagination()),e.filteredGraphs&&""!==e.exportFilter&&(e.displayGraphs=e.filteredGraphs)},e.checkAll=function(){e.selectedAll=e.selectedAll||!1,angular.forEach(e.displayGraphs,(function(t){t.contextID.uri&&(e.selectedGraphs.exportGraphs[t.contextID.value]=e.selectedAll)}))},e.deselectAll=function(){e.selectedAll=!1,angular.forEach(e.displayGraphs,(function(t){t.contextID.uri&&(e.selectedGraphs.exportGraphs[t.contextID.value]=!1)}))},e.dropRepository=function(){e.canWriteActiveRepo()&&(e.deleting["*"]=!0,n.openSimpleModal({title:"Confirm clear repository",message:"Are you sure you want to clear repository "+i.getActiveRepository()+"?",warning:!0}).result.then((function(){o((function(){p.addStatements(i.getActiveRepository(),"update=CLEAR ALL").then((function(){e.deleting["*"]=!1,s.success("Cleared repository "+i.getActiveRepository()),e.getGraphs()}),(function(t){e.deleting["*"]=!1,"string"==typeof t.data&&t.data.indexOf("Clearing all statements in the repository is incompatible with collecting history")>-1?s.error(t.data):s.error("Failed to clear repository "+i.getActiveRepository(),t)}))}),100)})))},e.dropContext=function(t){e.canWriteActiveRepo()&&(angular.isDefined(t)?function(t){const r=t.contextID.longName;e.deleting[t]=!0,n.openSimpleModal({title:"Confirm clear graph",message:"Are you sure you want to clear the "+r+"?",warning:!0}).result.then((function(){o((function(){const o=`update=CLEAR ${t.contextID.clearUri}`;p.addStatements(i.getActiveRepository(),o).then((function(){e.deleting[t]=!1,s.success("Cleared the "+r),e.getGraphs(),e.exportFilter="",e.filteredGraphs.length=0,e.updateResults(),e.changePageSize(e.pageSize)}),(function(o){e.deleting[t]=!1,s.error("Failed to clear the "+r,getError(o,o.status))}))}),100)}),(function(){e.deleting[t]=!1}))}(t):function(t){const r=[];angular.forEach(e.selectedGraphs.exportGraphs,(function(e,t){e&&r.push(t)})),r.length>0&&(e.deleting[t]=!0,n.openSimpleModal({title:"Confirm clear graphs",message:"Are you sure you want to clear the selected graphs?",warning:!0}).result.then((function(){o((function(){let t=0;angular.forEach(r,(function(o){const n=`update=CLEAR ${e.graphsByValue[o].clearUri}`;p.addStatements(i.getActiveRepository(),n).then((function(){e.loader=!0,e.selectedGraphs.exportGraphs[o]=!1,delete e.selectedGraphs.exportGraphs[o],t++,r.length===t&&(e.selectedAll=!1,e.exportFilter="",e.filteredGraphs.length=0,e.getGraphs(),e.updateResults(),e.changePageSize(e.pageSize),s.success("Cleared the selected graphs"),e.loader=!1)}),(function(t){const r=e.graphsByValue[o].longName;s.error("Failed to clear the "+r,getError(t,t.status)),e.selectedAll=!1}))}))}),100)}),(function(){e.deleting[t]=!1})))}(t))}}])}}]);
//# sourceMappingURL=34.3ae0b76db7e885ec9e6b.bundle.js.map