graphdb-workbench
Version:
The web application for GraphDB APIs
2 lines • 10.3 kB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[39,104],{31:function(e,n){function t(e){return{showToastMessageWithDelay:function(n){return new Promise(t=>{e.success(n),setTimeout(t,200)})}}}angular.module("graphdb.framework.utils.notifications",[]).factory("Notifications",t),t.$inject=["toastr"]},67:function(e,n,t){"use strict";t.r(n);t(2),t(8),t(11),t(31);function r(e,n,t,r,o){e.getSqlConfigurations=function(){!n.getActiveRepository()||n.isActiveRepoOntopType()||n.isActiveRepoFedXType()?e.jdbcConfigurations=[]:t.getJdbcConfigurations().success((function(n){e.jdbcConfigurations=n})).error((function(e){const n=getError(e);r.error(n,"Could not get SQL table configurations")}))},e.$watch((function(){return n.getActiveRepository()}),(function(){e.getSqlConfigurations()})),e.deleteConfiguration=function(n){o.openSimpleModal({title:"Warning",message:"Are you sure you want to delete the SQL table configuration '"+n+"'?",warning:!0}).result.then((function(){t.deleteJdbcConfiguration(n).success((function(){e.getSqlConfigurations()})).error((function(e){r.error(getError(e),"Could not delete SQL table")}))}))}}function o(e,n,t,r,o,i,u,s,c,a){e.name=n.search().name||"",e.getNamespaces=function(){p(!0,"Refreshing namespaces","Normally this is a fast operation but it may take longer if a bigger repository needs to be initialised first."),s.getRepositoryNamespaces().success((function(n){const t={};n.results.bindings.forEach((function(e){t[e.prefix.value]=e.namespace.value})),e.namespaces=t})).error((function(n){e.repositoryError=getError(n)})).finally((function(){p(!1),m()}))},e.setLoader=p,e.addKnownPrefixes=b,e.page=1,e.noPadding={paddingRight:0,paddingLeft:0},e.sqlTypes=["string","iri","boolean","byte","short","int","long","float","double","decimal","date","time","timestamp","Get suggestion..."],e.currentTabConfig={},e.orientationViewMode=!0,e.currentQuery={},e.$watch((function(){return r.getActiveRepository()}),(function(e,t){e!==t&&n.path("jdbc")}));let l=null;e.goBack=function(){l=i((function(){o.history.back()}),1e3)};const f=e.$on("$locationChangeStart",(function(n){!function(n){e.currentQuery.isPristine||(confirm("You have unsaved changes. Are you sure that you want to exit?")?(window.removeEventListener("beforeunload",g),f(),i.cancel(l)):n.preventDefault())}(n)}));function g(n){e.currentQuery.isPristine||(n.returnValue=!0)}window.addEventListener("beforeunload",g),e.$on("$destroy",(function(e){window.removeEventListener("beforeunload",g),f(),i.cancel(l)}));const d={id:"1",name:"",query:"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\n# Selects two variables to use as columns\nSELECT ?id ?label {\n ?id rdfs:label ?label\n # The following placeholder must be present in the query\n #!filter\n}",inference:!0,sameAs:!0,isNewConfiguration:!0,isPristine:!0};var y;function p(n,t,r){const o=angular.element(document.getElementById("yasr-inner"));e.queryIsRunning=n,n?(e.queryStartTime=Date.now(),e.countTimeouted=!1,e.progressMessage=t,e.extraMessage=r,o.addClass("hide")):(e.progressMessage="",e.extraMessage="",o.removeClass("hide")),null===e.$$phase&&e.$apply()}function m(){e.tabsData=[e.currentQuery];const n=e.currentQuery;e.currentQuery.query?window.editor.setValue(e.currentQuery.query):window.editor.setValue(" "),i((function(){e.currentTabConfig={},e.currentTabConfig.queryType=n.queryType,e.currentTabConfig.resultsCount=n.resultsCount,e.currentTabConfig.offset=n.offset,e.currentTabConfig.allResultsCount=n.allResultsCount,e.currentTabConfig.page=n.page,e.currentTabConfig.pageSize=n.pageSize,e.currentTabConfig.timeFinished=n.timeFinished,e.currentTabConfig.timeTook=n.timeTook,e.currentTabConfig.sizeDelta=n.sizeDelta,e.$apply()}),0),e.canWriteActiveRepo()||(window.editor.options.readOnly=!0)}function w(){e.tabsData=e.tabs=[d],e.currentQuery=angular.copy(d),h(),window.editor&&(e.setQuery(e.currentQuery.query),m()),e.$watch((function(){return e.currentQuery.query}),(function(n,t){n!==t&&e.setDirty()}))}function b(){c.addKnownPrefixes(JSON.stringify(window.editor.getValue())).success((function(e){angular.isDefined(window.editor)&&angular.isDefined(e)&&e!==window.editor.getValue()&&window.editor.setValue(e)})).error((function(e){const n=getError(e);return t.error(n,"Error! Could not add known prefixes"),!0}))}function C(){T()&&u.getColumnNames(e.currentQuery.query).success((function(n){u.getColumnsTypeSuggestion(e.currentQuery.query,n).success((function(t){const r=[];_.forEach(n,(function(e){r.push({column_name:e,column_type:t[e].column_type,nullable:!0,sparql_type:t[e].sparql_type})})),e.currentQuery.columns=r,e.setDirty()})).error((function(e){t.error(getError(e),"Could not suggest column types")}))})).error((function(e){t.error(getError(e),"Could not suggest column names")}))}function h(){2===e.page?e.viewMode="editor":e.viewMode="none"}function Q(e,n,t,r,o){let i=t[r].value;return i=i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"<div class = 'literal-cell'>"+("<p class='nonUri' style='border: none; background-color: transparent; padding: 0; margin: 0'>"+i+"</p>")+"</div>"}function S(){return window.editor&&"SELECT"===window.editor.getQueryType()}function v(){return T()&&function(){if(!e.currentQuery.columns||!e.currentQuery.columns.length)return t.error("Please define at least one column","Invalid columns"),!1;if(e.containsUnknownColumns())return t.error("Please select SQL type for all columns","Invalid columns"),!1;return!0}()}function T(){return!!S()||(t.error("The data query must be a SELECT query","Invalid query"),!1)}e.resetCurrentTabConfig=function(){e.currentTabConfig={pageSize:100,page:1,allResultsCount:0,resultsCount:0,queryType:""}},e.saveTab=function(){},e.setQuery=function(e){window.editor.setValue(e||" ")},e.name?(y=e.name,u.getJdbcConfiguration(y).success((function(e){d.query=e.query,d.name=e.name,d.columns=e.columns,d.isNewConfiguration=!e.name,w()})).error((function(e){const n=getError(e);t.error(n,"Could not get SQL table configuration")}))):w(),e.goToPage=function(n){e.page=n;const t=e.currentQuery.columns;2!==n||t&&0!==t.length||!S()||e.getColumnsSuggestions(),h()},e.save=function(){v()&&(e.currentQuery.name?e.currentQuery.isNewConfiguration?u.createNewJdbcConfiguration(e.currentQuery).success((function(){e.currentQuery.isPristine=!0,e.currentQuery.isNewConfiguration=!1,t.success("SQL table configuration saved"),e.goBack()})).error((function(e){const n=getError(e);t.error(n,"Could not save SQL table configuration")})):u.updateJdbcConfiguration(e.currentQuery).success((function(){e.currentQuery.isPristine=!0,e.currentQuery.isNewConfiguration=!1,t.success("SQL table configuration updated"),e.goBack()})).error((function(e){const n=getError(e);t.error(n,"Could not save SQL table configuration")})):t.error("SQL configuration name is required"))},e.hasPrecision=function(e){return"iri"===e||"string"===e||"decimal"===e},e.containsColumnsWithPrecision=function(n){return n&&n.some(n=>e.hasPrecision(n.column_type))},e.hasScale=function(e){return"decimal"===e},e.containsColumnsWithScale=function(n){return n&&n.some(n=>e.hasScale(n.column_type))},e.isLiteral=function(e){return"iri"!==e&&"unknown"!==e},e.containsNonLiteralColumnsOnly=function(n){return n&&n.every(n=>!e.isLiteral(n.column_type))},e.containsUnknownColumns=function(){return e.currentQuery.columns&&e.currentQuery.columns.find(e=>"unknown"===e.column_type)},$("textarea").on("paste",(function(){i((function(){b()}),0)})),e.selectColumnType=function(n,r){const o=_.find(e.currentQuery.columns,(function(e){return e.column_name===n}));"Get suggestion..."===o.column_type&&u.getColumnsTypeSuggestion(e.currentQuery.query,[n]).success((function(e){o.column_type=e[n].column_type,o.column_type===r?t.info("SQL type is the same after suggest: <b>"+o.column_type+"</b>","Suggest SQL type",{allowHtml:!0}):t.success("SQL type set to: <b>"+o.column_type+"</b>","Suggest SQL type",{allowHtml:!0}),o.sparql_type=e[n].sparql_type})).error((function(e){t.error(getError(e),"Could not suggest column type")})),e.setDirty()},e.getColumnsSuggestions=function(){e.currentQuery.columns&&e.currentQuery.columns.length>0?a.openSimpleModal({title:"Warning",message:"Are you sure you want to get suggestions for all columns? This action will overwrite all column type mappings!",warning:!0}).result.then((function(){C()})):C()},e.deleteColumn=function(n,t){a.openSimpleModal({title:"Warning",message:"Are you sure you want to delete the column '"+n+"'?",warning:!0}).result.then((function(){e.currentQuery.columns.splice(t,1),e.setDirty()}))},e.getPreview=function(){if(v()&&(e.executedQueryTab=e.currentQuery,!e.queryIsRunning)){e.currentQuery.outputType="table",e.resetCurrentTabConfig(),p(!0,"Preview of first 100 rows of table "+e.name,"Normally this is a fast operation but it may take longer if a bigger repository needs to be initialised first.");const n=function(n,r,o){!function(n,r,o){n.results&&n.results.bindings&&n.results.bindings.length?(window.yasr.plugins.table.options.getCellContent=Q,e.currentTabConfig.queryType="SELECT",window.yasr.setResponse(r,o,null)):t.info("The table definition produced no results","Preview SQL")}(n,o,r),p(!1)},r=function(e){p(!1),t.error(getError(e,0,100),"Could not show preview")};if(e.canWriteActiveRepo()){const t=JSON.stringify({name:e.currentQuery.name,query:e.currentQuery.query,columns:e.currentQuery.columns||[]});u.getNewSqlTablePreview(t).done(n).fail(r)}else u.getExistingSqlTablePreview(e.currentQuery.name).done(n).fail(r)}},e.setDirty=function(){e.currentQuery.isPristine=!1},e.getTypeLabel=function(e){switch(e){case"iri":return"VARCHAR: IRI";case"string":return"VARCHAR: String";default:return e.indexOf(" ")>0?e:e.toUpperCase()}}}angular.module("graphdb.framework.jdbc.controllers",["ui.bootstrap","graphdb.framework.core.services.repositories","graphdb.framework.rest.monitoring.service","toastr"],["graphdb.framework.utils.notifications"]).controller("JdbcListCtrl",r).controller("JdbcCreateCtrl",o),r.$inject=["$scope","$repositories","JdbcRestService","toastr","ModalService"],o.$inject=["$scope","$location","toastr","$repositories","$window","$timeout","JdbcRestService","RDF4JRepositoriesRestService","SparqlRestService","ModalService"]}}]);
//# sourceMappingURL=39.4a9263c70508d7b06a32.bundle.js.map