From 204e983d2229e44848c24516f4c019467a5a6123 Mon Sep 17 00:00:00 2001 From: ArangoDB Release Bot Date: Sat, 25 Nov 2017 00:58:01 +0000 Subject: [PATCH] nightly frontend build --- .../aardvark/APP/frontend/build/app.min.js | 14 +++++++------- .../aardvark/APP/frontend/build/app.min.js.gz | Bin 121368 -> 121416 bytes .../APP/frontend/build/index-min.html | 2 +- .../APP/frontend/build/index-min.html.gz | Bin 35200 -> 35196 bytes 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/js/apps/system/_admin/aardvark/APP/frontend/build/app.min.js b/js/apps/system/_admin/aardvark/APP/frontend/build/app.min.js index fc4a82d3de..38c9761e6f 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/build/app.min.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/build/app.min.js @@ -4,10 +4,10 @@ window.modalView.show("modalTable.ejs",'Result of script "'+b+'"',void 0,void 0, this},refetchCollections:function(){var a=this;this.collection.fetch({cache:!1,success:function(){a.checkLockedCollections()}})},checkLockedCollections:function(){var a=function(a,b){var c=this;a?console.log("Could not check locked collections"):(this.collection.each(function(a){a.set("locked",!1)}),_.each(b,function(a){var b=c.collection.findWhere({id:a.collection});b.set("locked",!0),b.set("lockType",a.type),b.set("desc",a.desc)}),this.collection.each(function(a){a.get("locked")||($("#collection_"+a.get("name")).find(".corneredBadge").removeClass("loaded unloaded"),$("#collection_"+a.get("name")+" .corneredBadge").text(a.get("status")),$("#collection_"+a.get("name")+" .corneredBadge").addClass(a.get("status"))),a.get("locked")||"loading"===a.get("status")?($("#collection_"+a.get("name")).addClass("locked"),a.get("locked")?($("#collection_"+a.get("name")).find(".corneredBadge").removeClass("loaded unloaded"),$("#collection_"+a.get("name")).find(".corneredBadge").addClass("inProgress"),$("#collection_"+a.get("name")+" .corneredBadge").text(a.get("desc"))):$("#collection_"+a.get("name")+" .corneredBadge").text(a.get("status"))):($("#collection_"+a.get("name")).removeClass("locked"),$("#collection_"+a.get("name")+" .corneredBadge").text(a.get("status")),$("#collection_"+a.get("name")+" .corneredBadge").hasClass("inProgress")&&($("#collection_"+a.get("name")+" .corneredBadge").text(a.get("status")),$("#collection_"+a.get("name")+" .corneredBadge").removeClass("inProgress"),$("#collection_"+a.get("name")+" .corneredBadge").addClass("loaded")),"unloaded"===a.get("status")&&$("#collection_"+a.get("name")+" .icon_arangodb_info").addClass("disabled"))}))}.bind(this);window.arangoHelper.syncAndReturnUninishedAardvarkJobs("index",a)},initialize:function(){var a=this;window.setInterval(function(){"#collections"===window.location.hash&&window.VISIBLE&&a.refetchCollections()},a.refreshRate)},render:function(){this.checkLockedCollections();var a=!1;$("#collectionsDropdown").is(":visible")&&(a=!0),$(this.el).html(this.template.render({})),this.setFilterValues(),a===!0&&$("#collectionsDropdown2").show();var b=this.collection.searchOptions;this.collection.getFiltered(b).forEach(function(a){$("#collectionsThumbnailsIn",this.el).append(new window.CollectionListItemView({model:a,collectionsView:this}).render().el)},this),"none"===$("#collectionsDropdown2").css("display")?$("#collectionsToggle").removeClass("activated"):$("#collectionsToggle").addClass("activated");var c;arangoHelper.setCheckboxStatus("#collectionsDropdown");try{c=b.searchPhrase.length}catch(d){}return $("#searchInput").val(b.searchPhrase),$("#searchInput").focus(),$("#searchInput")[0].setSelectionRange(c,c),arangoHelper.fixTooltips(".icon_arangodb, .arangoicon","left"),arangoHelper.checkDatabasePermissions(this.setReadOnly.bind(this)),this},setReadOnly:function(){this.readOnly=!0,$("#createCollection").parent().parent().addClass("disabled")},events:{"click #createCollection":"createCollection","keydown #searchInput":"restrictToSearchPhraseKey","change #searchInput":"restrictToSearchPhrase","click #searchSubmit":"restrictToSearchPhrase","click .checkSystemCollections":"checkSystem","click #checkLoaded":"checkLoaded","click #checkUnloaded":"checkUnloaded","click #checkDocument":"checkDocument","click #checkEdge":"checkEdge","click #sortName":"sortName","click #sortType":"sortType","click #sortOrder":"sortOrder","click #collectionsToggle":"toggleView","click .css-label":"checkBoxes"},updateCollectionsView:function(){var a=this;this.collection.fetch({cache:!1,success:function(){a.render()}})},toggleView:function(){$("#collectionsToggle").toggleClass("activated"),$("#collectionsDropdown2").slideToggle(200)},checkBoxes:function(a){var b=a.currentTarget.id;$("#"+b).click()},checkSystem:function(){var a=this.collection.searchOptions,b=a.includeSystem;a.includeSystem=$(".checkSystemCollections").is(":checked")===!0,b!==a.includeSystem&&this.render()},checkEdge:function(){var a=this.collection.searchOptions,b=a.includeEdge;a.includeEdge=$("#checkEdge").is(":checked")===!0,b!==a.includeEdge&&this.render()},checkDocument:function(){var a=this.collection.searchOptions,b=a.includeDocument;a.includeDocument=$("#checkDocument").is(":checked")===!0,b!==a.includeDocument&&this.render()},checkLoaded:function(){var a=this.collection.searchOptions,b=a.includeLoaded;a.includeLoaded=$("#checkLoaded").is(":checked")===!0,b!==a.includeLoaded&&this.render()},checkUnloaded:function(){var a=this.collection.searchOptions,b=a.includeUnloaded;a.includeUnloaded=$("#checkUnloaded").is(":checked")===!0,b!==a.includeUnloaded&&this.render()},sortName:function(){var a=this.collection.searchOptions,b=a.sortBy;a.sortBy=$("#sortName").is(":checked")===!0?"name":"type",b!==a.sortBy&&this.render()},sortType:function(){var a=this.collection.searchOptions,b=a.sortBy;a.sortBy=$("#sortType").is(":checked")===!0?"type":"name",b!==a.sortBy&&this.render()},sortOrder:function(){var a=this.collection.searchOptions,b=a.sortOrder;a.sortOrder=$("#sortOrder").is(":checked")===!0?-1:1,b!==a.sortOrder&&this.render()},setFilterValues:function(){var a=this.collection.searchOptions;$("#checkLoaded").attr("checked",a.includeLoaded),$("#checkUnloaded").attr("checked",a.includeUnloaded),$(".checkSystemCollections").attr("checked",a.includeSystem),$("#checkEdge").attr("checked",a.includeEdge),$("#checkDocument").attr("checked",a.includeDocument),$("#sortName").attr("checked","type"!==a.sortBy),$("#sortType").attr("checked","type"===a.sortBy),$("#sortOrder").attr("checked",1!==a.sortOrder)},search:function(){var a=this.collection.searchOptions,b=$("#searchInput").val();b!==a.searchPhrase&&(a.searchPhrase=b,this.render())},resetSearch:function(){this.searchTimeout&&(clearTimeout(this.searchTimeout),this.searchTimeout=null);var a=this.collection.searchOptions;a.searchPhrase=null},restrictToSearchPhraseKey:function(){var a=this;this.resetSearch(),a.searchTimeout=setTimeout(function(){a.search()},200)},restrictToSearchPhrase:function(){this.resetSearch(),this.search()},createCollection:function(a){if(!this.readOnly){a.preventDefault();var b=this;$.ajax({type:"GET",cache:!1,url:arangoHelper.databaseUrl("/_api/engine"),contentType:"application/json",processData:!1,success:function(a){b.engine=a,b.createNewCollectionModal(a)},error:function(){arangoHelper.arangoError("Engine","Could not fetch ArangoDB Engine details.")}})}},submitCreateCollection:function(){var a=this,b=function(b,c){if(b)arangoHelper.arangoError("DB","Could not check coordinator state");else{var d=$("#new-collection-name").val(),e=$("#new-collection-size").val(),f=$("#new-replication-factor").val(),g=$("#new-collection-type").val(),h=$("#new-collection-sync").val(),i=1,j=[];if(""===f&&(f=1),"true"===$("#is-satellite-collection").val()&&(f="satellite"),c){if(i=$("#new-collection-shards").val(),""===i&&(i=1),i=parseInt(i,10),i<1)return arangoHelper.arangoError("Number of shards has to be an integer value greater or equal 1"),0;j=_.pluck($("#new-collection-shardBy").select2("data"),"text"),0===j.length&&j.push("_key")}if("_"===d.substr(0,1))return arangoHelper.arangoError('No "_" allowed as first character!'),0;var k=!1,l="true"===h;if(e>0)try{e=1024*JSON.parse(e)*1024}catch(m){return arangoHelper.arangoError("Please enter a valid number"),0}if(""===d)return arangoHelper.arangoError("No collection name entered!"),0;var n=function(a,b){if(a)try{b=JSON.parse(b.responseText),arangoHelper.arangoError("Error",b.errorMessage)}catch(c){}else this.updateCollectionsView();window.modalView.hide()}.bind(this),o={collName:d,wfs:l,isSystem:k,replicationFactor:f,collType:g,shards:i,shardBy:j};"rocksdb"!==a.engine.name&&(o.journalSize=e),this.collection.newCollection(o,n)}}.bind(this);window.isCoordinator(b)},createNewCollectionModal:function(){var a=this,b=function(b,c){if(b)arangoHelper.arangoError("DB","Could not check coordinator state");else{var d=[],e=[],f={},g=[];e.push(window.modalView.createTextEntry("new-collection-name","Name","",!1,"",!0,[{rule:Joi.string().regex(/^[a-zA-Z]/),msg:"Collection name must always start with a letter."},{rule:Joi.string().regex(/^[a-zA-Z0-9\-_]*$/),msg:'Only symbols, "_" and "-" are allowed.'},{rule:Joi.string().required(),msg:"No collection name given."}])),e.push(window.modalView.createSelectEntry("new-collection-type","Type","","The type of the collection to create.",[{value:2,label:"Document"},{value:3,label:"Edge"}])),c&&(e.push(window.modalView.createTextEntry("new-collection-shards","Shards","","The number of shards to create. You cannot change this afterwards. Recommended: DBServers squared","",!0)),e.push(window.modalView.createSelect2Entry("new-collection-shardBy","shardBy","","The keys used to distribute documents on shards. Type the key and press return to add it.","_key",!1))),d.push(window.modalView.createSuccessButton("Save",this.submitCreateCollection.bind(this))),window.App.isCluster&&(frontendConfig.isEnterprise&&g.push(window.modalView.createSelectEntry("is-satellite-collection","Satellite collection","","Create satellite collection? This will disable replication factor.",[{value:!1,label:"No"},{value:!0,label:"Yes"}])),g.push(window.modalView.createTextEntry("new-replication-factor","Replication factor","","Numeric value. Must be at least 1. Total number of copies of the data in the cluster","",!1,[{rule:Joi.string().allow("").optional().regex(/^[0-9]*$/),msg:"Must be a number."}]))),"rocksdb"!==a.engine.name&&g.push(window.modalView.createTextEntry("new-collection-size","Journal size","","The maximal size of a journal or datafile (in MB). Must be at least 1.","",!1,[{rule:Joi.string().allow("").optional().regex(/^[0-9]*$/),msg:"Must be a number."}])),g.push(window.modalView.createSelectEntry("new-collection-sync","Wait for sync","","Synchronize to disk before returning from a create or update of a document.",[{value:!1,label:"No"},{value:!0,label:"Yes"}])),f.header="Advanced",f.content=g,window.modalView.show("modalTable.ejs","New Collection",d,e,f),$("#s2id_new-collection-shardBy .select2-search-field input").on("focusout",function(a){$(".select2-drop").is(":visible")&&($("#select2-search-field input").is(":focus")||window.setTimeout(function(){$(a.currentTarget).parent().parent().parent().select2("close")},200))}),window.App.isCluster&&frontendConfig.isEnterprise&&$("#is-satellite-collection").on("change",function(a){"true"===$("#is-satellite-collection").val()?$("#new-replication-factor").prop("disabled",!0):$("#new-replication-factor").prop("disabled",!1),$("#new-replication-factor").val("").focus().focusout()})}}.bind(this);window.isCoordinator(b)}})}(),function(){"use strict";function a(a,b){return void 0!==a&&null!==a||(a=0),a.toFixed(b)}window.DashboardView=Backbone.View.extend({el:"#content",interval:1e4,defaultTimeFrame:12e5,defaultDetailFrame:1728e5,reRender:!0,reRenderDistribution:!0,isVisible:!0,distributionCharts:{totalTimeDistribution:null,dataTransferDistribution:null},residentChart:null,history:{},graphs:{},events:{"click .subViewNavbar .subMenuEntry":"toggleViews"},tendencies:{asyncPerSecondCurrent:["asyncPerSecondCurrent","asyncPerSecondPercentChange"],syncPerSecondCurrent:["syncPerSecondCurrent","syncPerSecondPercentChange"],clientConnectionsCurrent:["clientConnectionsCurrent","clientConnectionsPercentChange"],clientConnectionsAverage:["clientConnections15M","clientConnections15MPercentChange"],numberOfThreadsCurrent:["numberOfThreadsCurrent","numberOfThreadsPercentChange"],numberOfThreadsAverage:["numberOfThreads15M","numberOfThreads15MPercentChange"],virtualSizeCurrent:["virtualSizeCurrent","virtualSizePercentChange"],virtualSizeAverage:["virtualSize15M","virtualSize15MPercentChange"]},barCharts:{totalTimeDistribution:["queueTimeDistributionPercent","requestTimeDistributionPercent"],dataTransferDistribution:["bytesSentDistributionPercent","bytesReceivedDistributionPercent"]},barChartsElementNames:{queueTimeDistributionPercent:"Queue",requestTimeDistributionPercent:"Computation",bytesSentDistributionPercent:"Bytes sent",bytesReceivedDistributionPercent:"Bytes received"},getDetailFigure:function(a){var b=$(a.currentTarget).attr("id").replace(/ChartButton/g,"");return b},showDetail:function(a){var b,c=this,d=this.getDetailFigure(a);b=this.dygraphConfig.getDetailChartConfig(d),this.getHistoryStatistics(d),this.detailGraphFigure=d,window.modalView.hideFooter=!0,window.modalView.hide(),window.modalView.show("modalGraph.ejs",b.header,void 0,void 0,void 0,void 0,this.events),window.modalView.hideFooter=!1,$("#modal-dialog").on("hidden",function(){c.hidden()}),$("#modal-dialog").toggleClass("modal-chart-detail",!0),b.height=.7*$(window).height(),b.width=$(".modal-inner-detail").width(),b.labelsDiv=$(b.labelsDiv)[0],this.detailGraph=new Dygraph(document.getElementById("lineChartDetail"),this.history[this.server][d],b)},hidden:function(){this.detailGraph.destroy(),delete this.detailGraph,delete this.detailGraphFigure},getCurrentSize:function(a){"#"!==a.substr(0,1)&&(a="#"+a);var b,c;return $(a).attr("style",""),b=$(a).height(),c=$(a).width(),{height:b,width:c}},prepareDygraphs:function(){var a,b=this;this.dygraphConfig.getDashBoardFigures().forEach(function(c){a=b.dygraphConfig.getDefaultConfig(c);var d=b.getCurrentSize(a.div);a.height=d.height,a.width=d.width,b.graphs[c]=new Dygraph(document.getElementById(a.div),b.history[b.server][c]||[],a)})},initialize:function(a){this.options=a,this.dygraphConfig=a.dygraphConfig,this.d3NotInitialized=!0,this.events["click .dashboard-sub-bar-menu-sign"]=this.showDetail.bind(this),this.events["mousedown .dygraph-rangesel-zoomhandle"]=this.stopUpdating.bind(this),this.events["mouseup .dygraph-rangesel-zoomhandle"]=this.startUpdating.bind(this),void 0===a.serverToShow&&(a.serverToShow={}),void 0===a.serverToShow.target&&0===window.location.hash.indexOf("#node/")&&(a.serverToShow.target=window.location.hash.split("/")[1]),this.serverInfo=a.serverToShow,this.serverInfo?this.server=this.serverInfo.target:this.server="-local-",this.history[this.server]={}},toggleViews:function(a){var b=a.currentTarget.id.split("-")[0],c=this,d=["replication","requests","system"];_.each(d,function(a){b!==a?$("#"+a).hide():($("#"+a).show(),c.resize(),$(window).resize())}),$(".subMenuEntries").children().removeClass("active"),$("#"+b+"-statistics").addClass("active"),window.setTimeout(function(){c.resize(),$(window).resize()},200)},updateCharts:function(){var a=this;return this.detailGraph?void this.updateLineChart(this.detailGraphFigure,!0):(this.prepareD3Charts(this.isUpdating),this.prepareResidentSize(this.isUpdating),this.updateTendencies(),void Object.keys(this.graphs).forEach(function(b){a.updateLineChart(b,!1)}))},updateTendencies:function(){var a=this,b=this.tendencies,c="";Object.keys(b).forEach(function(b){var d="",e=0;a.history.hasOwnProperty(a.server)&&a.history[a.server].hasOwnProperty(b)&&(e=a.history[a.server][b][1]),e<0?c="#d05448":(c="#77DB99",d="+"),a.history.hasOwnProperty(a.server)&&a.history[a.server].hasOwnProperty(b)?$("#"+b).html(a.history[a.server][b][0]+'
'+d+e+"%"):$("#"+b).html('

data not ready yet

')})},updateDateWindow:function(a,b){var c,d,e=(new Date).getTime();return b&&a.dateWindow_?(c=a.dateWindow_[0],d=e-a.dateWindow_[1]-5*this.interval>0?a.dateWindow_[1]:e,[c,d]):[e-this.defaultTimeFrame,e]},updateLineChart:function(a,b){var c=b?this.detailGraph:this.graphs[a],d={file:this.history[this.server][a],dateWindow:this.updateDateWindow(c,b)},e=0,f=[];_.each(d.file,function(a){var b=a[0].getSeconds()-a[0].getSeconds()%10;d.file[e][0].setSeconds(b),f.push(d.file[e][0]),e++});for(var g=new Date(Math.max.apply(null,f)),h=new Date(Math.min.apply(null,f)),i=new Date(h.getTime()),j=[],k=[];i1)){var f=0,g=0;9===c.length&&(f+=c[1],f+=c[6],f+=c[7],f+=c[8],g+=c[2],g+=c[3],g+=c[4],g+=c[5],c=[c[0],f,g]),d.history[d.server][e].unshift(c)}})},cutOffHistory:function(a,b){for(var c=this,d=c.history[c.server][a];0!==d.length&&!(d[d.length-1][0]>=b);)d.pop()},cutOffDygraphHistory:function(a){var b=this,c=new Date(a);this.dygraphConfig.getDashBoardFigures(!0).forEach(function(a){b.dygraphConfig.mapStatToFigure[a]&&b.history[b.server][a]&&b.cutOffHistory(a,c)})},mergeHistory:function(b){var c,d=this;for(c=0;c=0;--c)d.values.push({label:this.getLabel(b[a[0]].cuts,c),value:b[a[0]].values[c]}),e.values.push({label:this.getLabel(b[a[1]].cuts,c),value:b[a[1]].values[c]});return[d,e]},getLabel:function(a,b){return a[b]?0===b?"0 - "+a[b]:a[b-1]+" - "+a[b]:">"+a[b-1]},renderReplicationStatistics:function(a){$("#repl-numbers table tr:nth-child(1) > td:nth-child(2)").html(a.state.totalEvents),$("#repl-numbers table tr:nth-child(2) > td:nth-child(2)").html(a.state.totalRequests),$("#repl-numbers table tr:nth-child(3) > td:nth-child(2)").html(a.state.totalFailedConnects),a.state.lastAppliedContinuousTick?$("#repl-ticks table tr:nth-child(1) > td:nth-child(2)").html(a.state.lastAppliedContinuousTick):$("#repl-ticks table tr:nth-child(1) > td:nth-child(2)").html("no data available").addClass("no-data"),a.state.lastProcessedContinuousTick?$("#repl-ticks table tr:nth-child(2) > td:nth-child(2)").html(a.state.lastProcessedContinuousTick):$("#repl-ticks table tr:nth-child(2) > td:nth-child(2)").html("no data available").addClass("no-data"),a.state.lastAvailableContinuousTick?$("#repl-ticks table tr:nth-child(3) > td:nth-child(2)").html(a.state.lastAvailableContinuousTick):$("#repl-ticks table tr:nth-child(3) > td:nth-child(2)").html("no data available").addClass("no-data"),$("#repl-progress table tr:nth-child(1) > td:nth-child(2)").html(a.state.progress.message),$("#repl-progress table tr:nth-child(2) > td:nth-child(2)").html(a.state.progress.time),$("#repl-progress table tr:nth-child(3) > td:nth-child(2)").html(a.state.progress.failedConnects)},getReplicationStatistics:function(){var a=this;$.ajax(arangoHelper.databaseUrl("/_api/replication/applier-state"),{async:!0}).done(function(b){if(b.hasOwnProperty("state")){var c;c=b.state.running?"active":"inactive",c=''+c+"",$("#replication-chart .dashboard-sub-bar").html("Replication "+c),a.renderReplicationStatistics(b)}})},checkState:function(){var a=this;"#dashboard"===window.location.hash||"#node"===window.location.hash.substr(0,5)?a.isVisible=!0:(a.residentChart=null,a.isVisible=!1,a.reRender=!0,a.reRenderDistribution=!1)},renderStatisticBox:function(a,b,c,d){if($("#node-info #nodeattribute-"+a).length)$("#node-info #nodeattribute-"+a).html(b);else{var e="";e+=6===d?'
':'
',e+='
',e+=c?'
'+b+"
":'
'+b+"
",e+='
'+a+"
",e+="
",e+="
",$("#node-info").append(e)}},getNodeInfo:function(){var a=this;frontendConfig.isCluster?(this.serverInfo.isDBServer?this.renderStatisticBox("Role","DBServer",void 0,6):this.renderStatisticBox("Role","Coordinator",void 0,6),this.renderStatisticBox("Host",this.serverInfo.raw,this.serverInfo.raw,6),$.ajax({type:"GET",cache:!1,url:arangoHelper.databaseUrl("/_admin/clusterNodeVersion?ServerID="+this.serverInfo.target),contentType:"application/json",processData:!1,success:function(b){a.renderStatisticBox("Version",frontendConfig.version.version,void 0,6),a.renderStatisticBox("Edition",frontendConfig.version.license,void 0,6)},error:function(b){a.renderStatisticBox("Version","Error"),a.renderStatisticBox("Edition","Error")}}),$.ajax({type:"GET",cache:!1,url:arangoHelper.databaseUrl("/_admin/clusterNodeEngine?ServerID="+this.serverInfo.target),contentType:"application/json",processData:!1,success:function(b){a.renderStatisticBox("Engine",b.name,void 0,6)},error:function(b){a.renderStatisticBox("Engine","Error",void 0,6)}}),$.ajax({type:"GET",cache:!1,url:arangoHelper.databaseUrl("/_admin/clusterNodeStats?ServerID="+this.serverInfo.target),contentType:"application/json",processData:!1,success:function(b){a.renderStatisticBox("Uptime",moment.duration(b.server.uptime,"seconds").humanize(),void 0,6)},error:function(b){a.renderStatisticBox("Uptime","Error",void 0,6)}})):(this.renderStatisticBox("Version",frontendConfig.version.version),this.renderStatisticBox("Edition",frontendConfig.version.license),this.renderStatisticBox("Engine",frontendConfig.engine),$.ajax({type:"GET",cache:!1,url:arangoHelper.databaseUrl("/_admin/statistics"),contentType:"application/json",processData:!1,success:function(b){a.renderStatisticBox("Uptime",moment.duration(b.server.uptime,"seconds").humanize())},error:function(){a.renderStatisticBox("Uptime","Error")}})),arangoHelper.createTooltips()},getStatistics:function(a,b){var c=this;c.checkState();var d=arangoHelper.databaseUrl("/_admin/aardvark/statistics/short","_system"),e="?start=";e+=c.nextStart?c.nextStart:((new Date).getTime()-c.defaultTimeFrame)/1e3,"-local-"!==c.server&&(e+="&type=short",c.serverInfo.target&&(e+="&DBserver="+c.serverInfo.target),c.history.hasOwnProperty(c.server)||(c.history[c.server]={})),$.ajax(d+e,{async:!0,xhrFields:{withCredentials:!0},crossDomain:!0}).done(function(d){d.times.length>0&&(c.isUpdating=!0,c.mergeHistory(d)),c.isUpdating!==!1&&(a&&a(d.enabled,b),c.updateCharts())}).error(function(a){console.log("stat fetch req error:"+a)}),this.getReplicationStatistics()},getHistoryStatistics:function(a){var b=this,c="statistics/long",d="?filter="+this.dygraphConfig.mapStatToFigure[a].join();"-local-"!==b.server&&(c=b.server.endpoint+arangoHelper.databaseUrl("/_admin/aardvark/statistics/cluster"),d+="&type=long&DBserver="+b.server.target,b.history.hasOwnProperty(b.server)||(b.history[b.server]={}));var e=window.location.href.split("/"),f=e[0]+"//"+e[2]+"/"+e[3]+"/_system/"+e[5]+"/"+e[6]+"/";$.ajax(f+c+d,{async:!0}).done(function(c){var d;for(b.history[b.server][a]=[],d=0;d data not ready yet

'),$("#totalTimeDistribution").prepend('

data not ready yet

'),$(".dashboard-bar-chart-title").append('

data not ready yet

'))},removeEmptyDataLabels:function(){$(".dataNotReadyYet").remove()},prepareResidentSize:function(b){var c=this,d=this.getCurrentSize("#residentSizeChartContainer"),e=c.history[c.server].residentSizeCurrent/1024/1024,f="";f=e<1025?a(e,2)+" MB":a(e/1024,2)+" GB";var g,h=a(100*c.history[c.server].residentSizePercent,2);return c.history[c.server].physicalMemory?(this.removeEmptyDataLabels(),g=[prettyBytes(c.history[c.server].physicalMemory)],void 0===c.history[c.server].residentSizeChart?void this.addEmptyDataLabels():(this.removeEmptyDataLabels(),void(c.reRender&&c.isVisible?(nv.addGraph(function(){return c.residentChart=nv.models.multiBarHorizontalChart().x(function(a){return a.label}).y(function(a){return a.value}).width(d.width).height(d.height).margin({top:($("residentSizeChartContainer").outerHeight()-$("residentSizeChartContainer").height())/2,right:1,bottom:($("residentSizeChartContainer").outerHeight()-$("residentSizeChartContainer").height())/2,left:1}).showValues(!1).showYAxis(!1).showXAxis(!1).showLegend(!1).showControls(!1).stacked(!0),c.residentChart.yAxis.tickFormat(function(a){return a+"%"}).showMaxMin(!1),c.residentChart.xAxis.showMaxMin(!1),d3.select("#residentSizeChart svg").datum(c.history[c.server].residentSizeChart).call(c.residentChart),d3.select("#residentSizeChart svg").select(".nv-zeroLine").remove(),b&&(d3.select("#residentSizeChart svg").select("#total").remove(),d3.select("#residentSizeChart svg").select("#percentage").remove()),d3.select(".dashboard-bar-chart-title .percentage").html(f+" ("+h+" %)"),d3.select(".dashboard-bar-chart-title .absolut").html(g[0]),nv.utils.windowResize(c.residentChart.update),c.residentChart},function(){d3.selectAll("#residentSizeChart .nv-bar").on("click",function(){})}),c.reRender=!1):c.residentChart&&c.isVisible&&(c.residentChart.width(d.width),c.residentChart.height(d.height),d3.select(".dashboard-bar-chart-title .percentage").html(f+" ("+h+" %)"),d3.select(".dashboard-bar-chart-title .absolut").html(g[0]),d3.select("#residentSizeChart svg").datum(c.history[c.server].residentSizeChart).call(c.residentChart),nv.utils.windowResize(c.residentChart.update))))):void this.addEmptyDataLabels()},prepareD3Charts:function(b){var c=this,d={totalTimeDistribution:["queueTimeDistributionPercent","requestTimeDistributionPercent"],dataTransferDistribution:["bytesSentDistributionPercent","bytesReceivedDistributionPercent"]};this.d3NotInitialized&&(b=!1,this.d3NotInitialized=!1),_.each(Object.keys(d),function(b){var d=c.getCurrentSize("#"+b+"Container .dashboard-interior-chart"),e="#"+b+"Container svg";void 0===c.history[c.server].residentSizeChart?c.addEmptyDataLabels():c.removeEmptyDataLabels(),c.reRenderDistribution&&c.isVisible?($("#"+b+"Container").append('
Bytes sent
Bytes received
'),nv.addGraph(function(){var f=[0,.25,.5,.75,1],g=75,h=23,i=6;return d.width<219?(f=[0,.5,1],g=72,h=21,i=5):d.width<299?(f=[0,.3334,.6667,1],g=77):d.width<379?g=87:d.width<459?g=95:d.width<539?g=100:d.width<619&&(g=105),c.distributionCharts[b]=nv.models.multiBarHorizontalChart().x(function(a){return a.label}).y(function(a){return a.value}).width(d.width).height(d.height).margin({top:5,right:20,bottom:h,left:g}).showValues(!1).showYAxis(!0).showXAxis(!0).showLegend(!1).showControls(!1).forceY([0,1]),c.distributionCharts[b].yAxis.showMaxMin(!1),d3.select(".nv-y.nv-axis").selectAll("text").attr("transform","translate (0, "+i+")"),c.distributionCharts[b].yAxis.tickValues(f).tickFormat(function(b){return a(100*b*100/100,0)+"%"}),c.history[c.server][b]?d3.select(e).datum(c.history[c.server][b]).call(c.distributionCharts[b]):d3.select(e).datum([]).call(c.distributionCharts[b]),nv.utils.windowResize(c.distributionCharts[b].update),c.distributionCharts[b]},function(){d3.selectAll(e+" .nv-bar").on("click",function(){})})):c.distributionCharts[b]&&c.isVisible&&(c.distributionCharts[b].width(d.width),c.distributionCharts[b].height(d.height),c.history[c.server][b]?d3.select(e).datum(c.history[c.server][b]).call(c.distributionCharts[b]):d3.select(e).datum([]).call(c.distributionCharts[b]),nv.utils.windowResize(c.distributionCharts[b].update))}),c.reRenderDistribution&&c.isVisible&&(c.reRenderDistribution=!1)},stopUpdating:function(){this.isUpdating=!1},startUpdating:function(){var a=this;a.timer||(a.timer=window.setInterval(function(){window.App.isCluster?window.location.hash.indexOf(a.serverInfo.target)>-1&&a.getStatistics():a.getStatistics()},a.interval))},resize:function(){if(this.isUpdating){var a,b=this;_.each(this.graphs,function(c){a=b.getCurrentSize(c.maindiv_.id),c.resize(a.width,a.height)}),this.detailGraph&&(a=this.getCurrentSize(this.detailGraph.maindiv_.id),this.detailGraph.resize(a.width,a.height)),this.prepareD3Charts(!0),this.prepareResidentSize(!0)}},template:templateEngine.createTemplate("dashboardView.ejs"),render:function(a){if(void 0===this.serverInfo&&(this.serverInfo={isDBServer:!1}),this.serverInfo.isDBServer!==!0){this.delegateEvents(this.events);var b=function(a,b){return b||($(this.el).html(this.template.render({hideStatistics:!1})),this.getNodeInfo()),a&&"_system"===frontendConfig.db?(this.prepareDygraphs(),this.isUpdating&&(this.prepareD3Charts(),this.prepareResidentSize(),this.updateTendencies(),$(window).trigger("resize")),this.startUpdating(),void $(window).resize()):($(this.el).html(""),void(this.server?$(this.el).append('
Server statistics ('+this.server+") are disabled.
"):$(this.el).append('
Server statistics are disabled.
')))}.bind(this),c=function(){$(this.el).html(""),$(".contentDiv").remove(),$(".headerBar").remove(),$(".dashboard-headerbar").remove(),$(".dashboard-row").remove(),$(this.el).append('
You do not have permission to view this page.
'),$(this.el).append("
You can switch to '_system' to see the dashboard.
")}.bind(this);if("_system"!==frontendConfig.db)return void c();var d=function(d,e){d||(e?this.getStatistics(b,a):c())}.bind(this);void 0===window.App.currentDB.get("name")?window.setTimeout(function(){return"_system"!==window.App.currentDB.get("name")?void c():void this.options.database.hasSystemAccess(d)}.bind(this),300):this.options.database.hasSystemAccess(d)}else $(this.el).html(this.template.render({hideStatistics:!0})),$(".subMenuEntry").remove(),this.getNodeInfo()}})}(),function(){"use strict";window.DatabaseView=Backbone.View.extend({users:null,el:"#content",template:templateEngine.createTemplate("databaseView.ejs"),dropdownVisible:!1,currentDB:"",events:{"click #createDatabase":"createDatabase","click #submitCreateDatabase":"submitCreateDatabase","click .editDatabase":"editDatabase", "click #userManagementView .icon":"editDatabase","click #selectDatabase":"updateDatabase","click #submitDeleteDatabase":"submitDeleteDatabase","click .contentRowInactive a":"changeDatabase","keyup #databaseSearchInput":"search","click #databaseSearchSubmit":"search","click #databaseToggle":"toggleSettingsDropdown","click .css-label":"checkBoxes","click #dbSortDesc":"sorting"},sorting:function(){$("#dbSortDesc").is(":checked")?this.collection.setSortingDesc(!0):this.collection.setSortingDesc(!1),$("#databaseDropdown").is(":visible")?this.dropdownVisible=!0:this.dropdownVisible=!1,this.render()},initialize:function(){this.collection.fetch({async:!0,cache:!1})},checkBoxes:function(a){var b=a.currentTarget.id;$("#"+b).click()},render:function(){var a=this,b=function(b,c){b?arangoHelper.arangoError("DB","Could not get current db properties"):(a.currentDB=c,a.collection.fetch({success:function(){a.collection.sort(),$(a.el).html(a.template.render({collection:a.collection,searchString:"",currentDB:a.currentDB})),a.dropdownVisible===!0&&($("#dbSortDesc").attr("checked",a.collection.sortOptions.desc),$("#databaseToggle").toggleClass("activated"),$("#databaseDropdown2").show()),arangoHelper.setCheckboxStatus("#databaseDropdown"),a.replaceSVGs()}}))};return this.collection.getCurrentDatabase(b),this},toggleSettingsDropdown:function(){$("#dbSortDesc").attr("checked",this.collection.sortOptions.desc),$("#databaseToggle").toggleClass("activated"),$("#databaseDropdown2").slideToggle(200)},selectedDatabase:function(){return $("#selectDatabases").val()},handleError:function(a,b,c){return 409===a?void arangoHelper.arangoError("DB","Database "+c+" already exists."):400===a?void arangoHelper.arangoError("DB","Invalid Parameters"):403===a?void arangoHelper.arangoError("DB","Insufficent rights. Execute this from _system database"):void 0},validateDatabaseInfo:function(a,b){return""===b?(arangoHelper.arangoError("DB","You have to define an owner for the new database"),!1):""===a?(arangoHelper.arangoError("DB","You have to define a name for the new database"),!1):0===a.indexOf("_")?(arangoHelper.arangoError("DB ","Databasename should not start with _"),!1):!!a.match(/^[a-zA-Z][a-zA-Z0-9_-]*$/)||(arangoHelper.arangoError("DB","Databasename may only contain numbers, letters, _ and -"),!1)},createDatabase:function(a){a.preventDefault(),this.createAddDatabaseModal()},switchDatabase:function(a){if(!$(a.target).parent().hasClass("iconSet")){var b=$(a.currentTarget).find("h5").text();if(""!==b){var c=this.collection.createDatabaseURL(b);window.location.replace(c)}}},submitCreateDatabase:function(){var a=this,b=$("#newDatabaseName").val(),c=$("#newUser").val(),d={name:b};this.collection.create(d,{error:function(c,d){a.handleError(d.status,d.statusText,b)},success:function(d){"root"!==c&&$.ajax({type:"PUT",url:arangoHelper.databaseUrl("/_api/user/"+encodeURIComponent(c)+"/database/"+encodeURIComponent(b)),contentType:"application/json",data:JSON.stringify({grant:"rw"})}),$.ajax({type:"PUT",url:arangoHelper.databaseUrl("/_api/user/root/database/"+encodeURIComponent(b)),contentType:"application/json",data:JSON.stringify({grant:"rw"})}),"#databases"===window.location.hash&&a.updateDatabases(),arangoHelper.arangoNotification("Database "+d.get("name")+" created.")}}),arangoHelper.arangoNotification("Database creation in progress."),window.modalView.hide()},submitDeleteDatabase:function(a){var b=this.collection.where({name:a});b[0].destroy({wait:!0,url:arangoHelper.databaseUrl("/_api/database/"+a)}),this.updateDatabases(),window.App.naviView.dbSelectionView.render($("#dbSelect")),window.modalView.hide()},changeDatabase:function(a){var b=$(a.currentTarget).attr("id"),c=this.collection.createDatabaseURL(b);window.location.replace(c)},updateDatabases:function(){var a=this;this.collection.fetch({cache:!1,success:function(){a.render(),window.App.handleSelectDatabase()}})},editDatabase:function(a){var b=this.evaluateDatabaseName($(a.currentTarget).attr("id"),"_edit-database"),c=!0;b===this.currentDB&&(c=!1),this.createEditDatabaseModal(b,c)},search:function(){var a,b,c,d;a=$("#databaseSearchInput"),b=$("#databaseSearchInput").val(),d=this.collection.filter(function(a){return a.get("name").indexOf(b)!==-1}),$(this.el).html(this.template.render({collection:d,searchString:b,currentDB:this.currentDB})),this.replaceSVGs(),a=$("#databaseSearchInput"),c=a.val().length,a.focus(),a[0].setSelectionRange(c,c)},replaceSVGs:function(){$(".svgToReplace").each(function(){var a=$(this),b=a.attr("id"),c=a.attr("src");$.get(c,function(c){var d=$(c).find("svg");d.attr("id",b).attr("class","tile-icon-svg").removeAttr("xmlns:a"),a.replaceWith(d)},"xml")})},remove:function(){return this.$el.empty().off(),this.stopListening(),this.unbind(),delete this.el,this},evaluateDatabaseName:function(a,b){var c=a.lastIndexOf(b);return a.substring(0,c)},createEditDatabaseModal:function(a,b){var c=[],d=[];d.push(window.modalView.createReadOnlyEntry("id_name","Name",a,"")),b?c.push(window.modalView.createDeleteButton("Delete",this.submitDeleteDatabase.bind(this,a))):c.push(window.modalView.createDisabledButton("Delete")),window.modalView.show("modalTable.ejs","Delete database",c,d)},createAddDatabaseModal:function(){var a=[],b=[];b.push(window.modalView.createTextEntry("newDatabaseName","Name","",!1,"Database Name",!0,[{rule:Joi.string().regex(/^[a-zA-Z]/),msg:"Database name must start with a letter."},{rule:Joi.string().regex(/^[a-zA-Z0-9\-_]*$/),msg:'Only Symbols "_" and "-" are allowed.'},{rule:Joi.string().required(),msg:"No database name given."}]));var c=[];window.App.userCollection.each(function(a){c.push({value:a.get("user"),label:a.get("user")})}),b.push(window.modalView.createSelectEntry("newUser","Username",null!==this.users?this.users.whoAmI():"root","Please define the owner of this database. This will be the only user having initial access to this database if authentication is turned on. Please note that if you specify a username different to your account you will not be able to access the database with your account after having creating it. Specifying a username is mandatory even with authentication turned off. If there is a failure you will be informed.",c)),a.push(window.modalView.createSuccessButton("Create",this.submitCreateDatabase.bind(this))),window.modalView.show("modalTable.ejs","Create Database",a,b),$("#useDefaultPassword").change(function(){"true"===$("#useDefaultPassword").val()?$("#row_newPassword").hide():$("#row_newPassword").show()}),$("#row_newPassword").hide()}})}(),function(){"use strict";window.DBSelectionView=Backbone.View.extend({template:templateEngine.createTemplate("dbSelectionView.ejs"),events:{"click .dbSelectionLink":"changeDatabase"},initialize:function(a){this.current=a.current},changeDatabase:function(a){var b=$(a.currentTarget).closest(".dbSelectionLink.tab").attr("id"),c=this.collection.createDatabaseURL(b);window.location.replace(c)},render:function(a){var b=function(b,c){b?arangoHelper.arangoError("DB","Could not fetch databases"):(this.$el=a,this.$el.html(this.template.render({list:c,current:this.current.get("name")})),this.delegateEvents())}.bind(this);return this.collection.getDatabasesForUser(b),this.el}})}(),function(){"use strict";window.DocumentsView=window.PaginationView.extend({filters:{0:!0},filterId:0,paginationDiv:"#documentsToolbarF",idPrefix:"documents",addDocumentSwitch:!0,activeFilter:!1,lastCollectionName:void 0,restoredFilters:[],editMode:!1,allowUpload:!1,el:"#content",table:"#documentsTableID",template:templateEngine.createTemplate("documentsView.ejs"),collectionContext:{prev:null,next:null},unbindEvents:function(){this.$el.empty().off(),this.stopListening(),this.unbind()},editButtons:["#deleteSelected","#moveSelected"],initialize:function(a){this.documentStore=a.documentStore,this.collectionsStore=a.collectionsStore,this.tableView=new window.TableView({el:this.table,collection:this.collection}),this.tableView.setRowClick(this.clicked.bind(this)),this.tableView.setRemoveClick(this.remove.bind(this))},resize:function(){var a=!1;_.each($(".documentsDropdown").first().children(),function(b){$(b).is(":visible")&&(a=!0)}),a?($("#docPureTable").height($(".centralRow").height()-210-57),$("#docPureTable .pure-table-body").css("max-height",$("#docPureTable").height()-47)):($("#docPureTable").height($(".centralRow").height()-210),$("#docPureTable .pure-table-body").css("max-height",$("#docPureTable").height()-47))},setCollectionId:function(a,b){this.collection.setCollection(a),this.collection.setPage(b),this.page=b;var c=function(b,c){b?arangoHelper.arangoError("Error","Could not get collection properties."):(this.type=c,this.collection.getDocuments(this.getDocsCallback.bind(this)),this.collectionModel=this.collectionsStore.get(a))}.bind(this);arangoHelper.collectionApiType(a,null,c)},getDocsCallback:function(a){$("#documents_last").css("visibility","hidden"),$("#documents_first").css("visibility","hidden"),a?(window.progressView.hide(),arangoHelper.arangoError("Document error","Could not fetch requested documents.")):a&&void 0===a||(window.progressView.hide(),this.drawTable(),this.renderPaginationElements(),arangoHelper.checkCollectionPermissions(this.collection.collectionID,this.changeViewToReadOnly))},events:{"click #collectionPrev":"prevCollection","click #collectionNext":"nextCollection","click #filterCollection":"filterCollection","click #markDocuments":"editDocuments","click #importCollection":"importCollection","click #exportCollection":"exportCollection","click #filterSend":"sendFilter","click #addFilterItem":"addFilterItem","click .removeFilterItem":"removeFilterItem","click #deleteSelected":"deleteSelectedDocs","click #moveSelected":"moveSelectedDocs","click #addDocumentButton":"addDocumentModal","click #documents_first":"firstDocuments","click #documents_last":"lastDocuments","click #documents_prev":"prevDocuments","click #documents_next":"nextDocuments","click #confirmDeleteBtn":"confirmDelete","click .key":"nop",keyup:"returnPressedHandler","keydown .queryline input":"filterValueKeydown","click #importModal":"showImportModal","click #resetView":"resetView","click #confirmDocImport":"startUpload","click #exportDocuments":"startDownload","change #documentSize":"setPagesize","change #docsSort":"setSorting"},showSpinner:function(){$(".upload-indicator").show()},hideSpinner:function(){$(".upload-indicator").hide()},showImportModal:function(){$("#docImportModal").modal("show")},hideImportModal:function(){$("#docImportModal").modal("hide")},setPagesize:function(){var a=$("#documentSize").find(":selected").val();this.collection.setPagesize(a),this.collection.getDocuments(this.getDocsCallback.bind(this))},setSorting:function(){var a=$("#docsSort").val();""!==a&&void 0!==a&&null!==a||(a="_key"),this.collection.setSort(a)},returnPressedHandler:function(a){13===a.keyCode&&$(a.target).is($("#docsSort"))&&this.collection.getDocuments(this.getDocsCallback.bind(this)),13===a.keyCode&&$("#confirmDeleteBtn").attr("disabled")===!1&&this.confirmDelete()},nop:function(a){a.stopPropagation()},resetView:function(){var a=function(a){a&&arangoHelper.arangoError("Document","Could not fetch documents count")};$("input").val(""),$("select").val("=="),this.removeAllFilterItems(),$("#documentSize").val(this.collection.getPageSize()),$("#documents_last").css("visibility","visible"),$("#documents_first").css("visibility","visible"),this.addDocumentSwitch=!0,this.collection.resetFilter(),this.collection.loadTotal(a),this.restoredFilters=[],this.allowUpload=!1,this.files=void 0,this.file=void 0,$("#confirmDocImport").attr("disabled",!0),this.markFilterToggle(),this.collection.getDocuments(this.getDocsCallback.bind(this))},startDownload:function(){var a=this.collection.buildDownloadDocumentQuery();if(""!==a||void 0!==a||null!==a){var b="query/result/download/"+btoa(JSON.stringify(a));arangoHelper.download(b)}else arangoHelper.arangoError("Document error","could not download documents")},startUpload:function(){var a=function(a,b){a?arangoHelper.arangoError("Upload",b):(this.hideImportModal(),this.resetView()),this.hideSpinner()}.bind(this);this.allowUpload===!0&&(this.showSpinner(),this.collection.uploadDocuments(this.file,a))},uploadSetup:function(){var a=this;$("#importDocuments").change(function(b){a.files=b.target.files||b.dataTransfer.files,a.file=a.files[0],$("#confirmDocImport").attr("disabled",!1),a.allowUpload=!0})},buildCollectionLink:function(a){return"collection/"+encodeURIComponent(a.get("name"))+"/documents/1"},markFilterToggle:function(){this.restoredFilters.length>0?$("#filterCollection").addClass("activated"):$("#filterCollection").removeClass("activated")},editDocuments:function(a){if(!$(a.currentTarget).hasClass("disabled")){$("#importCollection").removeClass("activated"),$("#exportCollection").removeClass("activated"),this.markFilterToggle(),$("#markDocuments").toggleClass("activated"),this.changeEditMode(),$("#filterHeader").hide(),$("#importHeader").hide(),$("#editHeader").slideToggle(1),$("#exportHeader").hide();var b=this;window.setTimeout(function(){b.resize()},50)}},filterCollection:function(){$("#importCollection").removeClass("activated"),$("#exportCollection").removeClass("activated"),$("#markDocuments").removeClass("activated"),this.changeEditMode(!1),this.markFilterToggle(),this.activeFilter=!0,$("#importHeader").hide(),$("#editHeader").hide(),$("#exportHeader").hide(),$("#filterHeader").slideToggle(1);var a=this;window.setTimeout(function(){a.resize()},50);var b;for(b in this.filters)if(this.filters.hasOwnProperty(b))return void $("#attribute_name"+b).focus()},exportCollection:function(){$("#importCollection").removeClass("activated"),$("#filterHeader").removeClass("activated"),$("#markDocuments").removeClass("activated"),this.changeEditMode(!1),$("#exportCollection").toggleClass("activated"),this.markFilterToggle(),$("#exportHeader").slideToggle(1),$("#importHeader").hide(),$("#filterHeader").hide(),$("#editHeader").hide();var a=this;window.setTimeout(function(){a.resize()},50)},importCollection:function(a){if(!$(a.currentTarget).hasClass("disabled")){this.markFilterToggle(),$("#markDocuments").removeClass("activated"),this.changeEditMode(!1),$("#importCollection").toggleClass("activated"),$("#exportCollection").removeClass("activated"),$("#importHeader").slideToggle(1),$("#filterHeader").hide(),$("#editHeader").hide(),$("#exportHeader").hide();var b=this;window.setTimeout(function(){b.resize()},50)}},changeEditMode:function(a){a===!1||this.editMode===!0?($("#docPureTable .pure-table-body .pure-table-row").css("cursor","default"),$(".deleteButton").fadeIn(),$(".addButton").fadeIn(),$(".selected-row").removeClass("selected-row"),this.editMode=!1,this.tableView.setRowClick(this.clicked.bind(this))):($("#docPureTable .pure-table-body .pure-table-row").css("cursor","copy"),$(".deleteButton").fadeOut(),$(".addButton").fadeOut(),$(".selectedCount").text(0),this.editMode=!0,this.tableView.setRowClick(this.editModeClick.bind(this)))},getFilterContent:function(){var a,b,c=[];for(a in this.filters)if(this.filters.hasOwnProperty(a)){b=$("#attribute_value"+a).val();try{b=JSON.parse(b)}catch(d){b=String(b)}""!==$("#attribute_name"+a).val()&&c.push({attribute:$("#attribute_name"+a).val(),operator:$("#operator"+a).val(),value:b})}return c},sendFilter:function(){this.restoredFilters=this.getFilterContent();var a=this;this.collection.resetFilter(),this.addDocumentSwitch=!1,_.each(this.restoredFilters,function(b){void 0!==b.operator&&a.collection.addFilter(b.attribute,b.operator,b.value)}),this.collection.setToFirst(),this.collection.getDocuments(this.getDocsCallback.bind(this)),this.markFilterToggle()},restoreFilter:function(){var a=this,b=0;this.filterId=0,$("#docsSort").val(this.collection.getSort()),_.each(this.restoredFilters,function(c){0!==b&&a.addFilterItem(),void 0!==c.operator&&($("#attribute_name"+b).val(c.attribute),$("#operator"+b).val(c.operator),$("#attribute_value"+b).val(c.value)),b++,a.collection.addFilter(c.attribute,c.operator,c.value)}),a.rerender()},addFilterItem:function(){var a=++this.filterId;$("#filterHeader").append('
'),this.filters[a]=!0,this.checkFilterState()},filterValueKeydown:function(a){13===a.keyCode&&this.sendFilter()},checkFilterState:function(){var a=$("#filterHeader .queryline").length;if(1===a)$("#filterHeader .removeFilterItem").remove();else if(0===$("#filterHeader .queryline").first().find(".removeFilterItem").length){var b=$("#filterHeader .queryline").first().children().first().attr("id"),c=b.substr(14,b.length);$("#filterHeader .queryline").first().find(".add-filter-item").after(' ')}0===$("#filterHeader .queryline").first().find(".add-filter-item").length&&$("#filterHeader .queryline").first().find(".filterValue").after('')},removeFilterItem:function(a){var b=a.currentTarget,c=b.id.replace(/^removeFilter/,"");delete this.filters[c],delete this.restoredFilters[c],$(b.parentElement).remove(),this.checkFilterState()},removeAllFilterItems:function(){var a,b=$("#filterHeader").children().length;for(a=1;a<=b;a++)$("#removeFilter"+a).parent().remove();this.filters={0:!0},this.filterId=0},addDocumentModal:function(a){if(!$(a.currentTarget).hasClass("disabled")){var b=window.location.hash.split("/")[1],c=[],d=[],e=function(a,b){a?arangoHelper.arangoError("Error","Could not fetch collection type"):"edge"===b?(d.push(window.modalView.createTextEntry("new-edge-from-attr","_from","","document _id: document handle of the linked vertex (incoming relation)",void 0,!1,[{rule:Joi.string().required(),msg:"No _from attribute given."}])),d.push(window.modalView.createTextEntry("new-edge-to","_to","","document _id: document handle of the linked vertex (outgoing relation)",void 0,!1,[{rule:Joi.string().required(),msg:"No _to attribute given."}])),d.push(window.modalView.createTextEntry("new-edge-key-attr","_key",void 0,"the edges unique key(optional attribute, leave empty for autogenerated key","is optional: leave empty for autogenerated key",!1,[{rule:Joi.string().allow("").optional(),msg:""}])),c.push(window.modalView.createSuccessButton("Create",this.addEdge.bind(this))),window.modalView.show("modalTable.ejs","Create edge",c,d)):(d.push(window.modalView.createTextEntry("new-document-key-attr","_key",void 0,"the documents unique key(optional attribute, leave empty for autogenerated key","is optional: leave empty for autogenerated key",!1,[{rule:Joi.string().allow("").optional(),msg:""}])),c.push(window.modalView.createSuccessButton("Create",this.addDocument.bind(this))),window.modalView.show("modalTable.ejs","Create document",c,d))}.bind(this);arangoHelper.collectionApiType(b,!0,e)}},addEdge:function(){var a,b=window.location.hash.split("/")[1],c=$(".modal-body #new-edge-from-attr").last().val(),d=$(".modal-body #new-edge-to").last().val(),e=$(".modal-body #new-edge-key-attr").last().val(),f=function(b,c,d){if(b)arangoHelper.arangoError("Error",d.errorMessage);else{window.modalView.hide(),c=c._id.split("/");try{a="collection/"+c[0]+"/"+c[1],decodeURI(a)}catch(e){a="collection/"+c[0]+"/"+encodeURIComponent(c[1])}window.location.hash=a}};""!==e||void 0!==e?this.documentStore.createTypeEdge(b,c,d,e,f):this.documentStore.createTypeEdge(b,c,d,null,f)},addDocument:function(){var a,b=window.location.hash.split("/")[1],c=$(".modal-body #new-document-key-attr").last().val(),d=function(b,c,d){if(b)arangoHelper.arangoError("Error",d.errorMessage);else{window.modalView.hide(),c=c.split("/");try{a="collection/"+c[0]+"/"+c[1],decodeURI(a)}catch(e){a="collection/"+c[0]+"/"+encodeURIComponent(c[1])}window.location.hash=a}};""!==c||void 0!==c?this.documentStore.createTypeDocument(b,c,d):this.documentStore.createTypeDocument(b,null,d)},moveSelectedDocs:function(){var a=[],b=[],c=this.getSelectedDocs();0!==c.length&&(b.push(window.modalView.createTextEntry("move-documents-to","Move to","",!1,"collection-name",!0,[{rule:Joi.string().regex(/^[a-zA-Z]/),msg:"Collection name must always start with a letter."},{rule:Joi.string().regex(/^[a-zA-Z0-9\-_]*$/),msg:'Only Symbols "_" and "-" are allowed.'},{rule:Joi.string().required(),msg:"No collection name given."}])),a.push(window.modalView.createSuccessButton("Move",this.confirmMoveSelectedDocs.bind(this))),window.modalView.show("modalTable.ejs","Move documents",a,b))},confirmMoveSelectedDocs:function(){var a=this.getSelectedDocs(),b=this,c=$("#move-documents-to").val(),d=function(){this.collection.getDocuments(this.getDocsCallback.bind(this)),$("#markDocuments").click(),window.modalView.hide()}.bind(this);_.each(a,function(a){b.collection.moveDocument(a,b.collection.collectionID,c,d)})},deleteSelectedDocs:function(){var a=[],b=[],c=this.getSelectedDocs();0!==c.length&&(b.push(window.modalView.createReadOnlyEntry(void 0,c.length+" documents selected","Do you want to delete all selected documents?",void 0,void 0,!1,void 0)),a.push(window.modalView.createDeleteButton("Delete",this.confirmDeleteSelectedDocs.bind(this))),window.modalView.show("modalTable.ejs","Delete documents",a,b))},confirmDeleteSelectedDocs:function(){var a=this.getSelectedDocs(),b=[],c=this;_.each(a,function(a){if("document"===c.type){var d=function(a){a?(b.push(!1),arangoHelper.arangoError("Document error","Could not delete document.")):(b.push(!0),c.collection.setTotalMinusOne(),c.collection.getDocuments(this.getDocsCallback.bind(this)),$("#markDocuments").click(),window.modalView.hide())}.bind(c);c.documentStore.deleteDocument(c.collection.collectionID,a,d)}else if("edge"===c.type){var e=function(a){a?(b.push(!1),arangoHelper.arangoError("Edge error","Could not delete edge")):(c.collection.setTotalMinusOne(),b.push(!0),c.collection.getDocuments(this.getDocsCallback.bind(this)),$("#markDocuments").click(),window.modalView.hide())}.bind(c);c.documentStore.deleteEdge(c.collection.collectionID,a,e)}})},getSelectedDocs:function(){var a=[];return _.each($("#docPureTable .pure-table-body .pure-table-row"),function(b){$(b).hasClass("selected-row")&&a.push($($(b).children()[1]).find(".key").text())}),a},remove:function(a){$(a.currentTarget).hasClass("disabled")||(this.docid=$(a.currentTarget).parent().parent().prev().find(".key").text(),$("#confirmDeleteBtn").attr("disabled",!1),$("#docDeleteModal").modal("show"))},confirmDelete:function(){$("#confirmDeleteBtn").attr("disabled",!0);var a=window.location.hash.split("/"),b=a[3];"source"!==b&&this.reallyDelete()},reallyDelete:function(){if("document"===this.type){var a=function(a){a?arangoHelper.arangoError("Error","Could not delete document"):(this.collection.setTotalMinusOne(),this.collection.getDocuments(this.getDocsCallback.bind(this)),$("#docDeleteModal").modal("hide"))}.bind(this);this.documentStore.deleteDocument(this.collection.collectionID,this.docid,a)}else if("edge"===this.type){var b=function(a){a?arangoHelper.arangoError("Edge error","Could not delete edge"):(this.collection.setTotalMinusOne(),this.collection.getDocuments(this.getDocsCallback.bind(this)),$("#docDeleteModal").modal("hide"))}.bind(this);this.documentStore.deleteEdge(this.collection.collectionID,this.docid,b)}},editModeClick:function(a){var b=$(a.currentTarget);b.hasClass("selected-row")?b.removeClass("selected-row"):b.addClass("selected-row");var c=this.getSelectedDocs();$(".selectedCount").text(c.length),_.each(this.editButtons,function(a){c.length>0?($(a).prop("disabled",!1),$(a).removeClass("button-neutral"),$(a).removeClass("disabled"),"#moveSelected"===a?$(a).addClass("button-success"):$(a).addClass("button-danger")):($(a).prop("disabled",!0),$(a).addClass("disabled"),$(a).addClass("button-neutral"),"#moveSelected"===a?$(a).removeClass("button-success"):$(a).removeClass("button-danger"))})},clicked:function(a){var b,c=a.currentTarget,d=$(c).attr("id").substr(4);try{b="collection/"+this.collection.collectionID+"/"+d,decodeURI(d)}catch(e){b="collection/"+this.collection.collectionID+"/"+encodeURIComponent(d)}window.location.hash=b},drawTable:function(){this.tableView.setElement($("#docPureTable")).render(),arangoHelper.fixTooltips(".icon_arangodb, .arangoicon","top"),$(".prettify").snippet("javascript",{style:"nedit",menu:!1,startText:!1,transparent:!0,showNum:!1}),this.resize()},checkCollectionState:function(){this.lastCollectionName===this.collectionName?this.activeFilter&&(this.filterCollection(),this.restoreFilter()):void 0!==this.lastCollectionName&&(this.collection.resetFilter(),this.collection.setSort(""),this.restoredFilters=[],this.activeFilter=!1)},render:function(){return $(this.el).html(this.template.render({})),2===this.type?this.type="document":3===this.type&&(this.type="edge"),this.tableView.setElement($(this.table)).drawLoading(),this.collectionContext=this.collectionsStore.getPosition(this.collection.collectionID),this.collectionName=window.location.hash.split("/")[1],this.checkCollectionState(),this.lastCollectionName=this.collectionName,this.uploadSetup(),arangoHelper.fixTooltips([".icon_arangodb",".arangoicon","top","[data-toggle=tooltip]",".upload-info"]),this.renderPaginationElements(),this.selectActivePagesize(),this.markFilterToggle(),this.resize(),this.breadcrumb(),this},changeViewToReadOnly:function(){$(".breadcrumb").html($(".breadcrumb").html()+" (read-only)"),$("#importCollection").addClass("disabled"),$("#markDocuments").addClass("disabled"),$("#addDocumentButton").addClass("disabled"),$("#addDocumentButton .fa-plus-circle").css("color","#d3d3d3"),$("#addDocumentButton .fa-plus-circle").css("cursor","not-allowed"),$(".deleteButton").addClass("disabled"),$(".deleteButton .fa-minus-circle").css("color","#d3d3d3"),$(".deleteButton .fa-minus-circle").css("cursor","not-allowed")},rerender:function(){this.collection.getDocuments(this.getDocsCallback.bind(this)),this.resize()},selectActivePagesize:function(){$("#documentSize").val(this.collection.getPageSize())},renderPaginationElements:function(){this.renderPagination();var a=$("#totalDocuments");0===a.length&&($("#documentsToolbarFL").append(''),a=$("#totalDocuments")),"document"===this.type&&a.html(numeral(this.collection.getTotal()).format("0,0")+" doc(s)"),"edge"===this.type&&a.html(numeral(this.collection.getTotal()).format("0,0")+" edge(s)"),this.collection.getTotal()>this.collection.MAX_SORT?($("#docsSort").attr("disabled",!0),$("#docsSort").attr("placeholder","Sort limit reached (docs count)")):($("#docsSort").attr("disabled",!1),$("#docsSort").attr("placeholder","Sort by attribute"))},breadcrumb:function(){var a=this;window.App.naviView?($("#subNavigationBar .breadcrumb").html("Collection: "+this.collectionName),window.arangoHelper.buildCollectionSubNav(this.collectionName,"Content")):window.setTimeout(function(){a.breadcrumb()},100)}})}(),function(){"use strict";var a=function(a){var b=a.split("/");return"collection/"+encodeURIComponent(b[0])+"/"+encodeURIComponent(b[1])};window.DocumentView=Backbone.View.extend({el:"#content",readOnly:!1,colid:0,docid:0,customView:!1,defaultMode:"tree",template:templateEngine.createTemplate("documentView.ejs"),events:{"click #saveDocumentButton":"saveDocument","click #deleteDocumentButton":"deleteDocumentModal","click #confirmDeleteDocument":"deleteDocument","click #document-from":"navigateToDocument","click #document-to":"navigateToDocument","keydown #documentEditor .ace_editor":"keyPress","keyup .jsoneditor .search input":"checkSearchBox","click .jsoneditor .modes":"storeMode","click #addDocument":"addDocument"},remove:function(){return this.$el.empty().off(),this.stopListening(),this.unbind(),delete this.el,this},checkSearchBox:function(a){""===$(a.currentTarget).val()&&this.editor.expandAll()},initialize:function(){var a=localStorage.getItem("JSONEditorMode");a&&(this.defaultMode=a)},addDocument:function(a){this.readOnly||window.App.documentsView.addDocumentModal(a)},storeMode:function(){var a=this;$(".type-modes").on("click",function(b){var c=$(b.currentTarget).text().toLowerCase();localStorage.setItem("JSONEditorMode",c),a.defaultMode=c})},keyPress:function(a){a.ctrlKey&&13===a.keyCode?(a.preventDefault(),this.saveDocument()):a.metaKey&&13===a.keyCode&&(a.preventDefault(),this.saveDocument())},editor:0,setType:function(){var a=function(a,b,c){a?arangoHelper.arangoError("Error","Could not fetch data."):(this.type=c,this.breadcrumb(),this.fillInfo(),this.fillEditor(),arangoHelper.checkCollectionPermissions(this.colid,this.changeViewToReadOnly.bind(this)))}.bind(this);this.collection.getDocument(this.colid,this.docid,a)},deleteDocumentModal:function(){if(!this.readOnly){var a=[],b=[];b.push(window.modalView.createReadOnlyEntry("doc-delete-button","Confirm delete, document id is",this.type._id,void 0,void 0,!1,/[<>&'"]/)),a.push(window.modalView.createDeleteButton("Delete",this.deleteDocument.bind(this))),window.modalView.show("modalTable.ejs","Delete Document",a,b)}},deleteDocument:function(){var a=function(){if(this.customView)this.customDeleteFunction();else{var a="collection/"+encodeURIComponent(this.colid)+"/documents/1";window.modalView.hide(),window.App.navigate(a,{trigger:!0})}}.bind(this);if(this.type._from&&this.type._to){var b=function(b){b?arangoHelper.arangoError("Edge error","Could not delete edge"):a()};this.collection.deleteEdge(this.colid,this.docid,b)}else{var c=function(b){b?arangoHelper.arangoError("Error","Could not delete document"):a()};this.collection.deleteDocument(this.colid,this.docid,c)}},navigateToDocument:function(a){var b=$(a.target).attr("documentLink"),c=(b.split("%").length-1)%3;decodeURIComponent(b)!==b&&0!==c&&(b=decodeURIComponent(b)),b&&window.App.navigate(b,{trigger:!0})},fillInfo:function(){var b=this.collection.first(),c=b.get("_id"),d=b.get("_key"),e=b.get("_rev"),f=b.get("_from"),g=b.get("_to");if($("#document-type").css("margin-left","10px"),$("#document-type").text("_id:"),$("#document-id").css("margin-left","0"),$("#document-id").text(c),$("#document-key").text(d),$("#document-rev").text(e),f&&g){var h=a(f),i=a(g);$("#document-from").text(f),$("#document-from").attr("documentLink",h),$("#document-to").text(g),$("#document-to").attr("documentLink",i)}else $(".edge-info-container").hide()},fillEditor:function(){var a=this.removeReadonlyKeys(this.collection.first().attributes);$(".disabledBread").last().text(this.collection.first().get("_key")),this.editor.set(a),$(".ace_content").attr("font-size","11pt")},jsonContentChanged:function(){this.enableSaveButton()},resize:function(){$("#documentEditor").height($(".centralRow").height()-300)},render:function(){$(this.el).html(this.template.render({})),$("#documentEditor").height($(".centralRow").height()-300),this.disableSaveButton();var a=this,b=document.getElementById("documentEditor"),c={onChange:function(){a.jsonContentChanged()},search:!0,mode:"tree",modes:["tree","code"],ace:window.ace};return this.editor=new JSONEditor(b,c),this.defaultMode&&this.editor.setMode(this.defaultMode),this},changeViewToReadOnly:function(){this.readOnly=!0,$(".breadcrumb").find("a").html($(".breadcrumb").find("a").html()+" (read-only)"),this.editor.setMode("view"),$(".jsoneditor-modes").hide(),$(".bottomButtonBar button").addClass("disabled"), $(".bottomButtonBar button").unbind("click"),$("#addDocument").addClass("disabled")},cleanupEditor:function(){this.editor&&this.editor.destroy()},removeReadonlyKeys:function(a){return _.omit(a,["_key","_id","_from","_to","_rev"])},saveDocument:function(){if(void 0===$("#saveDocumentButton").attr("disabled"))if("_"===this.collection.first().attributes._id.substr(0,1)){var a=[],b=[];b.push(window.modalView.createReadOnlyEntry("doc-save-system-button","Caution","You are modifying a system collection. Really continue?",void 0,void 0,!1,/[<>&'"]/)),a.push(window.modalView.createSuccessButton("Save",this.confirmSaveDocument.bind(this))),window.modalView.show("modalTable.ejs","Modify System Collection",a,b)}else this.confirmSaveDocument()},confirmSaveDocument:function(){window.modalView.hide();var a;try{a=this.editor.get()}catch(b){return this.errorConfirmation(b),void this.disableSaveButton()}if(a=JSON.stringify(a),"edge"===this.type||this.type._from){var c=function(a,b){a?arangoHelper.arangoError("Error",b.responseJSON.errorMessage):(this.successConfirmation(),this.disableSaveButton())}.bind(this);this.collection.saveEdge(this.colid,this.docid,$("#document-from").html(),$("#document-to").html(),a,c)}else{var d=function(a,b){a?arangoHelper.arangoError("Error",b.responseJSON.errorMessage):(this.successConfirmation(),this.disableSaveButton())}.bind(this);this.collection.saveDocument(this.colid,this.docid,a,d)}},successConfirmation:function(){arangoHelper.arangoNotification("Document saved.")},errorConfirmation:function(a){arangoHelper.arangoError("Document editor: ",a)},enableSaveButton:function(){$("#saveDocumentButton").prop("disabled",!1),$("#saveDocumentButton").addClass("button-success"),$("#saveDocumentButton").removeClass("button-close")},disableSaveButton:function(){$("#saveDocumentButton").prop("disabled",!0),$("#saveDocumentButton").addClass("button-close"),$("#saveDocumentButton").removeClass("button-success")},breadcrumb:function(){var a=window.location.hash.split("/");$("#subNavigationBar .breadcrumb").html('Collection: '+a[1]+''+this.type.charAt(0).toUpperCase()+this.type.slice(1)+": "+a[2])},escaped:function(a){return a.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}})}(),function(){"use strict";window.FilterSelectView=Backbone.View.extend({el:"#filterSelectDiv",filterOptionsEl:".filterOptions",initialize:function(a){this.name=a.name,this.options=a.options,this.position=a.position,this.callback=a.callback,this.multiple=a.multiple},template:templateEngine.createTemplate("filterSelect.ejs"),events:{"click .filterOptions .inactive":"changeState","click .filterOptions .active":"changeState","click #showAll":"showAll","click #closeFilter":"hide","keyup .filterInput input":"filter"},remove:function(){return this.$el.empty().off(),this.stopListening(),this.unbind(),delete this.el,this},changeState:function(a){var b=this,c=$(a.currentTarget).attr("name");$(a.currentTarget).hasClass("active")?(b.options[c].active=!1,$(a.currentTarget).removeClass("active").addClass("inactive"),$(a.currentTarget).find(".marked").css("visibility","hidden")):(b.options[c].active=!0,$(a.currentTarget).removeClass("inactive").addClass("active"),$(a.currentTarget).find(".marked").css("visibility","visible")),this.callback&&this.callback(this.options)},filter:function(){var a=$("#"+this.name+"-filter").val();_.each(this.options,function(b){b.name.search(a)>-1?$("#"+b.name+"-option").css("display","block"):$("#"+b.name+"-option").css("display","none")})},clearFilter:function(){$("#"+this.name+"-filter").val(""),this.filter()},showAll:function(){this.clearFilter(),_.each(this.options,function(a){a.active=!1,$("#"+a.name+"-option").removeClass("active").addClass("inactive"),$("#"+a.name+"-option").find(".marked").css("visibility","hidden")}),this.callback(this.options)},render:function(){var a=this;$("#filterSelectDiv").on("click",function(b){"filterSelectDiv"===b.target.id&&a.hide()}),_.each(a.options,function(a){a.color||(a.color=arangoHelper.alphabetColors[a.name.charAt(0).toLowerCase()])}),this.$el.html(this.template.render({name:a.name,options:a.options})),$("#filterSelectDiv > div").css("right",this.position.right+"px"),$("#filterSelectDiv > div").css("top",this.position.top+30),this.show(),$("#"+this.name+"-filter").focus()},show:function(){$(this.el).show()},hide:function(){$("#filterSelectDiv").unbind("click"),$(this.el).hide(),this.remove()}})}(),function(){"use strict";window.FooterView=Backbone.View.extend({el:"#footerBar",system:{},isOffline:!0,isOfflineCounter:0,firstLogin:!0,timer:15e3,lap:0,timerFunction:null,events:{"click .footer-center p":"showShortcutModal"},initialize:function(){var a=this;window.setInterval(function(){a.getVersion()},a.timer),a.getVersion(),window.VISIBLE=!0,document.addEventListener("visibilitychange",function(){window.VISIBLE=!window.VISIBLE}),$("#offlinePlaceholder button").on("click",function(){a.getVersion()}),window.setTimeout(function(){window.frontendConfig.isCluster===!0&&($(".health-state").css("cursor","pointer"),$(".health-state").on("click",function(){window.App.navigate("#nodes",{trigger:!0})}))},1e3)},template:templateEngine.createTemplate("footerView.ejs"),showServerStatus:function(a){window.App.isCluster?this.renderClusterState(a):a===!0?($("#healthStatus").removeClass("negative"),$("#healthStatus").addClass("positive"),$(".health-state").html("GOOD"),$(".health-icon").html(''),$("#offlinePlaceholder").hide()):($("#healthStatus").removeClass("positive"),$("#healthStatus").addClass("negative"),$(".health-state").html("UNKNOWN"),$(".health-icon").html(''),window.modalView.hide(),$("#offlinePlaceholder").show(),$.noty.clearQueue(),$.noty.closeAll(),this.reconnectAnimation(0))},reconnectAnimation:function(a){var b=this;0===a&&(b.lap=a,$("#offlineSeconds").text(b.timer/1e3),clearTimeout(b.timerFunction)),b.lap0?($("#healthStatus").removeClass("positive"),$("#healthStatus").addClass("negative"),1===b?$(".health-state").html(b+" NODE ERROR"):$(".health-state").html(b+" NODES ERROR"),$(".health-icon").html('')):($("#healthStatus").removeClass("negative"),$("#healthStatus").addClass("positive"),$(".health-state").html("NODES OK"),$(".health-icon").html(''))):($(".health-state").html("HEALTH ERROR"),$("#healthStatus").removeClass("positive"),$("#healthStatus").addClass("negative"),$(".health-icon").html(''))};$.ajax({type:"GET",cache:!1,url:arangoHelper.databaseUrl("/_admin/cluster/health"),contentType:"application/json",processData:!1,async:!0,success:function(a){b(a)}})}else $("#healthStatus").removeClass("positive"),$("#healthStatus").addClass("negative"),$(".health-state").html(window.location.host+" OFFLINE"),$(".health-icon").html(''),$("#offlinePlaceholder").show(),this.reconnectAnimation(0)},showShortcutModal:function(){window.arangoHelper.hotkeysFunctions.showHotkeysModal()},getVersion:function(){var a=this;$.ajax({type:"GET",cache:!1,url:arangoHelper.databaseUrl("/_api/version"),contentType:"application/json",processData:!1,async:!0,success:function(b){frontendConfig.version=b,a.showServerStatus(!0),a.isOffline===!0&&(a.isOffline=!1,a.isOfflineCounter=0,a.firstLogin?a.firstLogin=!1:window.setTimeout(function(){a.showServerStatus(!0)},1e3),a.system.name=b.server,a.system.version=b.version,a.render())},error:function(b){401===b.status?(a.showServerStatus(!0),window.App.navigate("login",{trigger:!0})):(a.isOffline=!0,a.isOfflineCounter++,a.isOfflineCounter>=1&&a.showServerStatus(!1))}}),a.system.hasOwnProperty("database")||$.ajax({type:"GET",cache:!1,url:arangoHelper.databaseUrl("/_api/database/current"),contentType:"application/json",processData:!1,async:!0,success:function(b){var c=b.result.name;a.system.database=c;var d=window.setInterval(function(){var b=$("#databaseNavi");b&&(window.clearTimeout(d),d=null,a.render())},50)}})},renderVersion:function(){this.system.hasOwnProperty("database")&&this.system.hasOwnProperty("name")&&$(this.el).html(this.template.render({name:this.system.name,version:this.system.version,database:this.system.database}))},render:function(){return this.system.version||this.getVersion(),$(this.el).html(this.template.render({name:this.system.name,version:this.system.version})),this}})}(),function(){"use strict";window.FoxxActiveView=Backbone.View.extend({tagName:"div",className:"tile pure-u-1-1 pure-u-sm-1-2 pure-u-md-1-3 pure-u-lg-1-4 pure-u-xl-1-6",template:templateEngine.createTemplate("foxxActiveView.ejs"),_show:!0,events:{click:"openAppDetailView"},openAppDetailView:function(){window.App.navigate("service/"+encodeURIComponent(this.model.get("mount")),{trigger:!0})},toggle:function(a,b){switch(a){case"devel":this.model.isDevelopment()&&(this._show=b);break;case"production":this.model.isDevelopment()||this.model.isSystem()||(this._show=b);break;case"system":this.model.isSystem()&&(this._show=b)}this._show?$(this.el).show():$(this.el).hide()},render:function(){return this.model.fetchThumbnail(function(){$(this.el).html(this.template.render({model:this.model}));var a=function(){this.model.needsConfiguration()&&($(this.el).find(".warning-icons").length>0?$(this.el).find(".warning-icons").append(''):$(this.el).find("img").after(''))}.bind(this),b=function(){this.model.hasUnconfiguredDependencies()&&($(this.el).find(".warning-icons").length>0?$(this.el).find(".warning-icons").append(''):$(this.el).find("img").after(''))}.bind(this);this.model.getConfiguration(a),this.model.getDependencies(b)}.bind(this)),$(this.el)}})}(),function(){"use strict";var a={ERROR_SERVICE_DOWNLOAD_FAILED:{code:1752,message:"service download failed"}},b=templateEngine.createTemplate("applicationListView.ejs"),c=function(a){this.collection=a.collection},d=function(b){var c=this;if(b.error===!1)this.collection.fetch({success:function(){window.modalView.hide(),c.reload(),arangoHelper.arangoNotification("Services","Service "+b.name+" installed.")}});else{var d=b;switch(b.hasOwnProperty("responseJSON")&&(d=b.responseJSON),d.errorNum){case a.ERROR_SERVICE_DOWNLOAD_FAILED.code:arangoHelper.arangoError("Services","Unable to download application from the given repository.");break;default:arangoHelper.arangoError("Services",d.errorNum+". "+d.errorMessage)}}},e=function(){window.modalView.modalBindValidation({id:"new-app-mount",validateInput:function(){return[{rule:Joi.string().regex(/^(\/(APP[^\/]+|(?!APP)[a-zA-Z0-9_\-%]+))+$/i),msg:"May not contain /APP"},{rule:Joi.string().regex(/^(\/[a-zA-Z0-9_\-%]+)+$/),msg:"Can only contain [a-zA-Z0-9_-%]"},{rule:Joi.string().regex(/^\/([^_]|_open\/)/),msg:"Mountpoints with _ are reserved for internal use"},{rule:Joi.string().regex(/[^\/]$/),msg:"May not end with /"},{rule:Joi.string().regex(/^\//),msg:"Has to start with /"},{rule:Joi.string().required().min(2),msg:"Has to be non-empty"}]}})},f=function(){window.modalView.modalBindValidation({id:"repository",validateInput:function(){return[{rule:Joi.string().required().regex(/^[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+$/),msg:"No valid Github account and repository."}]}})},g=function(){window.modalView.modalBindValidation({id:"new-app-author",validateInput:function(){return[{rule:Joi.string().required().min(1),msg:"Has to be non empty."}]}}),window.modalView.modalBindValidation({id:"new-app-name",validateInput:function(){return[{rule:Joi.string().required().regex(/^[a-zA-Z\-_][a-zA-Z0-9\-_]*$/),msg:"Can only contain a to z, A to Z, 0-9, '-' and '_'."}]}}),window.modalView.modalBindValidation({id:"new-app-description",validateInput:function(){return[{rule:Joi.string().required().min(1),msg:"Has to be non empty."}]}}),window.modalView.modalBindValidation({id:"new-app-license",validateInput:function(){return[{rule:Joi.string().required().regex(/^[a-zA-Z0-9 .,;-]+$/),msg:"Has to be non empty."}]}}),window.modalView.modalTestAll()},h=function(a){window.modalView.clearValidators();var b=$("#modalButton1");switch(this._upgrade||e(),a){case"newApp":b.html("Generate"),b.prop("disabled",!1),g();break;case"appstore":b.html("Install"),b.prop("disabled",!0);break;case"github":f(),b.html("Install"),b.prop("disabled",!1);break;case"zip":b.html("Install"),b.prop("disabled",!1)}b.prop("disabled")||window.modalView.modalTestAll()||b.prop("disabled",!0)},i=function(a){var b=$(a.currentTarget).attr("href").substr(1);h.call(this,b)},j=function(a){if(h.call(this,"appstore"),window.modalView.modalTestAll()){var b,c;this._upgrade?(b=this.mount,c=$("#new-app-teardown").prop("checked")):b=window.arangoHelper.escapeHtml($("#new-app-mount").val());var e=$(a.currentTarget).attr("appId"),f=$(a.currentTarget).attr("appVersion");void 0!==c?this.collection.installFromStore({name:e,version:f},b,d.bind(this),c):this.collection.installFromStore({name:e,version:f},b,d.bind(this)),window.modalView.hide(),arangoHelper.arangoNotification("Services","Installing "+e+".")}},k=function(a,b){if(void 0===b?b=this._uploadData:this._uploadData=b,b&&window.modalView.modalTestAll()){var c,e,f;this._upgrade?(c=this.mount,e=Boolean($("#new-app-teardown").prop("checked"))):c=window.arangoHelper.escapeHtml($("#new-app-mount").val()),f=Boolean($("#zip-app-islegacy").prop("checked")),this.collection.installFromZip(b.filename,c,d.bind(this),f,e)}},l=function(){if(window.modalView.modalTestAll()){var a,b,c,e,f;this._upgrade?(c=this.mount,e=$("#new-app-teardown").prop("checked")):c=window.arangoHelper.escapeHtml($("#new-app-mount").val()),a=window.arangoHelper.escapeHtml($("#repository").val()),b=window.arangoHelper.escapeHtml($("#tag").val()),""===b&&(b="master");var g={url:window.arangoHelper.escapeHtml($("#repository").val()),version:window.arangoHelper.escapeHtml($("#tag").val())};try{Joi.assert(a,Joi.string().regex(/^[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+$/))}catch(h){return}f=Boolean($("#github-app-islegacy").prop("checked")),this.collection.installFromGithub(g,c,d.bind(this),f,e)}},m=function(){if(window.modalView.modalTestAll()){var a,b;this._upgrade?(a=this.mount,b=$("#new-app-teardown").prop("checked")):a=window.arangoHelper.escapeHtml($("#new-app-mount").val());var c={name:window.arangoHelper.escapeHtml($("#new-app-name").val()),documentCollections:_.map($("#new-app-document-collections").select2("data"),function(a){return window.arangoHelper.escapeHtml(a.text)}),edgeCollections:_.map($("#new-app-edge-collections").select2("data"),function(a){return window.arangoHelper.escapeHtml(a.text)}),author:window.arangoHelper.escapeHtml($("#new-app-author").val()),license:window.arangoHelper.escapeHtml($("#new-app-license").val()),description:window.arangoHelper.escapeHtml($("#new-app-description").val())};this.collection.generate(c,a,d.bind(this),b)}},n=function(){var a=$(".modal-body .tab-pane.active").attr("id");switch(a){case"newApp":m.apply(this);break;case"github":l.apply(this);break;case"zip":k.apply(this)}},o=function(a,c){var d=[],e={"click #infoTab a":i.bind(a),"click .install-app":j.bind(a)};d.push(window.modalView.createSuccessButton("Generate",n.bind(a))),window.modalView.show("modalApplicationMount.ejs","Install Service",d,c,void 0,void 0,e),$("#new-app-document-collections").select2({tags:[],showSearchBox:!1,minimumResultsForSearch:-1,width:"336px"}),$("#new-app-edge-collections").select2({tags:[],showSearchBox:!1,minimumResultsForSearch:-1,width:"336px"});var f=function(){var a=$("#modalButton1");a.prop("disabled")||window.modalView.modalTestAll()?a.prop("disabled",!1):a.prop("disabled",!0)};$(".select2-search-field input").focusout(function(){f(),window.setTimeout(function(){$(".select2-drop").is(":visible")&&($("#select2-search-field input").is(":focus")||($("#s2id_new-app-document-collections").select2("close"),$("#s2id_new-app-edge-collections").select2("close"),f()))},200)}),$(".select2-search-field input").focusin(function(){if($(".select2-drop").is(":visible")){var a=$("#modalButton1");a.prop("disabled",!0)}}),$("#upload-foxx-zip").uploadFile({url:arangoHelper.databaseUrl("/_api/upload?multipart=true"),allowedTypes:"zip,js",multiple:!1,onSuccess:k.bind(a)}),$.get("foxxes/fishbowl",function(a){var c=$("#appstore-content");c.html(""),_.each(_.sortBy(a,"name"),function(a){c.append(b.render(a))})}).fail(function(){var a=$("#appstore-content");a.append("Store is not available. ArangoDB is not able to connect to github.com")})};c.prototype.install=function(a){this.reload=a,this._upgrade=!1,this._uploadData=void 0,delete this.mount,o(this,!1),window.modalView.clearValidators(),e(),g()},c.prototype.upgrade=function(a,b){this.reload=b,this._upgrade=!0,this._uploadData=void 0,this.mount=a,o(this,!0),window.modalView.clearValidators(),g()},window.FoxxInstallView=c}(),function(){"use strict";window.GraphManagementView=Backbone.View.extend({el:"#content",template:templateEngine.createTemplate("graphManagementView.ejs"),edgeDefintionTemplate:templateEngine.createTemplate("edgeDefinitionTable.ejs"),eCollList:[],removedECollList:[],readOnly:!1,dropdownVisible:!1,initialize:function(a){this.options=a},events:{"click #deleteGraph":"deleteGraph","click .icon_arangodb_settings2.editGraph":"editGraph","click #createGraph":"addNewGraph","keyup #graphManagementSearchInput":"search","click #graphManagementSearchSubmit":"search","click .tile-graph":"redirectToGraphViewer","click #graphManagementToggle":"toggleGraphDropdown","click .css-label":"checkBoxes","change #graphSortDesc":"sorting"},toggleTab:function(a){var b=a.currentTarget.id;b=b.replace("tab-",""),$("#tab-content-create-graph .tab-pane").removeClass("active"),$("#tab-content-create-graph #"+b).addClass("active"),"exampleGraphs"===b?$("#modal-dialog .modal-footer .button-success").css("display","none"):$("#modal-dialog .modal-footer .button-success").css("display","initial"),"smartGraph"===b?(this.toggleSmartGraph(),$("#createGraph").addClass("active"),this.showSmartGraphOptions()):(this.toggleSmartGraph(),this.hideSmartGraphOptions())},hideSmartGraphOptions:function(){$("#row_general-numberOfShards").show(),$("#row_general-replicationFactor").show(),$("#smartGraphInfo").hide(),$("#row_new-numberOfShards").hide(),$("#row_new-replicationFactor").hide(),$("#row_new-smartGraphAttribute").hide()},showSmartGraphOptions:function(){$("#row_general-numberOfShards").hide(),$("#row_general-replicationFactor").hide(),$("#smartGraphInfo").show(),$("#row_new-numberOfShards").show(),$("#row_new-replicationFactor").show(),$("#row_new-smartGraphAttribute").show()},redirectToGraphViewer:function(a){var b=$(a.currentTarget).attr("id");b=b.substr(0,b.length-5),window.location.hash=window.location.hash.substr(0,window.location.hash.length-1)+"/"+encodeURIComponent(b)},loadGraphViewer:function(a,b){var c=function(b){if(b)arangoHelper.arangoError("","");else{var c=this.collection.get(a).get("edgeDefinitions");if(!c||0===c.length)return;var d={type:"gharial",graphName:a,baseUrl:arangoHelper.databaseUrl("/")},e=$("#content").width()-75;$("#content").html("");var f=arangoHelper.calculateCenterDivHeight();this.ui=new GraphViewerUI($("#content")[0],d,e,$(".centralRow").height()-135,{nodeShaper:{label:"_key",color:{type:"attribute",key:"_key"}}},(!0)),$(".contentDiv").height(f)}}.bind(this);b?this.collection.fetch({cache:!1,success:function(){c()}}):c()},handleResize:function(a){this.width&&this.width===a||(this.width=a,this.ui&&this.ui.changeWidth(a))},addNewGraph:function(a){a.preventDefault(),this.readOnly||(frontendConfig.isCluster&&frontendConfig.isEnterprise?this.createEditGraphModal():(this.createEditGraphModal(),$("#tab-smartGraph").parent().remove()))},deleteGraph:function(){var a=this,b=$("#editGraphName")[0].value;if($("#dropGraphCollections").is(":checked")){var c=function(c){c?(a.collection.remove(a.collection.get(b)),a.updateGraphManagementView(),window.modalView.hide()):(window.modalView.hide(),arangoHelper.arangoError("Graph","Could not delete Graph."))};this.collection.dropAndDeleteGraph(b,c)}else this.collection.get(b).destroy({success:function(){a.updateGraphManagementView(),window.modalView.hide()},error:function(a,b){var c=JSON.parse(b.responseText),d=c.errorMessage;arangoHelper.arangoError(d),window.modalView.hide()}})},checkBoxes:function(a){var b=a.currentTarget.id;$("#"+b).click()},toggleGraphDropdown:function(){$("#graphSortDesc").attr("checked",this.collection.sortOptions.desc),$("#graphManagementToggle").toggleClass("activated"),$("#graphManagementDropdown2").slideToggle(200)},sorting:function(){$("#graphSortDesc").is(":checked")?this.collection.setSortingDesc(!0):this.collection.setSortingDesc(!1),$("#graphManagementDropdown").is(":visible")?this.dropdownVisible=!0:this.dropdownVisible=!1,this.render()},createExampleGraphs:function(a){var b=$(a.currentTarget).attr("graph-id"),c=this;$.ajax({type:"POST",url:arangoHelper.databaseUrl("/_admin/aardvark/graph-examples/create/"+encodeURIComponent(b)),success:function(){window.modalView.hide(),c.updateGraphManagementView(),arangoHelper.arangoNotification("Example Graphs","Graph: "+b+" created.")},error:function(a){if(window.modalView.hide(),a.responseText)try{var c=JSON.parse(a.responseText);arangoHelper.arangoError("Example Graphs",c.errorMessage)}catch(d){arangoHelper.arangoError("Example Graphs","Could not create example graph: "+b)}else arangoHelper.arangoError("Example Graphs","Could not create example graph: "+b)}})},toggleSmartGraph:function(){var a,b=this;if($("#tab-smartGraph").parent().hasClass("active")){var c=[],d=this.options.collectionCollection.models;for(d.forEach(function(a){a.get("isSystem")||c.push(a.id)}),a=0;a0&&(j.options={numberOfShards:$("#general-numberOfShards").val()}),$("#general-replicationFactor").val().length>0&&(j.options?j.options.replicationFactor=$("#general-replicationFactor").val():j.options={replicationFactor:$("#general-replicationFactor").val()}));this.collection.create(j,{success:function(){i.updateGraphManagementView(),window.modalView.hide()},error:function(a,b){var c=JSON.parse(b.responseText),d=c.errorMessage;d=d.replace("<",""),d=d.replace(">",""),arangoHelper.arangoError(d)}})},createEditGraphModal:function(a,b){var c,d=[],e=[],f=[],g=this.options.collectionCollection.models,h=this,i="",j=[{collection:"",from:"",to:""}],k="",l=function(a,b){return a=a.toLowerCase(),b=b.toLowerCase(),ab?1:0};if(this.eCollList=[],this.removedECollList=[],g.forEach(function(a){a.get("isSystem")||("edge"===a.get("type")?h.eCollList.push(a.id):e.push(a.id))}),window.modalView.enableHotKeys=!1,this.counter=0,a?(c=b?"Edit Smart Graph":"Edit Graph",i=a.get("_key"),j=a.get("edgeDefinitions"), -j&&0!==j.length||(j=[{collection:"",from:"",to:""}]),k=a.get("orphanCollections"),f.push(window.modalView.createReadOnlyEntry("editGraphName","Name",i,"The name to identify the graph. Has to be unique")),b&&f.push(window.modalView.createReadOnlyEntry("smartGraphAttribute","Smart Graph Attribute",a.get("smartGraphAttribute"),"The attribute name that is used to smartly shard the vertices of a graph. \nEvery vertex in this Graph has to have this attribute. \n")),a.get("numberOfShards")&&f.push(window.modalView.createReadOnlyEntry("numberOfShards","Shards",a.get("numberOfShards"),"Number of shards the graph is using.")),a.get("replicationFactor")&&f.push(window.modalView.createReadOnlyEntry("replicationFactor","Replication factor",a.get("replicationFactor"),"Total number of copies of the data in the cluster.")),d.push(window.modalView.createDeleteButton("Delete",this.deleteGraph.bind(this))),d.push(window.modalView.createNotificationButton("Reset display settings",this.resetDisplaySettings.bind(this))),d.push(window.modalView.createSuccessButton("Save",this.saveEditedGraph.bind(this)))):(c="Create Graph",f.push(window.modalView.createTextEntry("createNewGraphName","Name","","The name to identify the graph. Has to be unique.","graphName",!0)),d.push(window.modalView.createSuccessButton("Create",this.createNewGraph.bind(this)))),j.forEach(function(b){frontendConfig.isEnterprise===!0&&frontendConfig.isCluster&&(f.push(window.modalView.createTextEntry("new-numberOfShards","Shards*","","Number of shards the smart graph is using.","",!1,[{rule:Joi.string().allow("").optional().regex(/^[0-9]*$/),msg:"Must be a number."}])),f.push(window.modalView.createTextEntry("new-replicationFactor","Replication factor","","Numeric value. Must be at least 1. Total number of copies of the data in the cluster.","",!1,[{rule:Joi.string().allow("").optional().regex(/^[0-9]*$/),msg:"Must be a number."}])),f.push(window.modalView.createTextEntry("new-smartGraphAttribute","Smart Graph Attribute*","","The attribute name that is used to smartly shard the vertices of a graph. \nEvery vertex in this Graph has to have this attribute. \nCannot be modified later.","",!1,[{rule:Joi.string().allow("").optional(),msg:"Must be a string."}]))),frontendConfig.isCluster&&!a&&(f.push(window.modalView.createTextEntry("general-numberOfShards","Shards","","Number of shards the graph is using.","",!1,[{rule:Joi.string().allow("").optional().regex(/^[0-9]*$/),msg:"Must be a number."}])),f.push(window.modalView.createTextEntry("general-replicationFactor","Replication factor","","Numeric value. Must be at least 1. Total number of copies of the data in the cluster.","",!1,[{rule:Joi.string().allow("").optional().regex(/^[0-9]*$/),msg:"Must be a number."}]))),0===h.counter?(b.collection&&(h.removedECollList.push(b.collection),h.eCollList.splice(h.eCollList.indexOf(b.collection),1)),f.push(window.modalView.createSelect2Entry("newEdgeDefinitions"+h.counter,"Edge definitions",b.collection,"An edge definition defines a relation of the graph","Edge definitions",!0,!1,!0,1,h.eCollList.sort(l)))):f.push(window.modalView.createSelect2Entry("newEdgeDefinitions"+h.counter,"Edge definitions",b.collection,"An edge definition defines a relation of the graph","Edge definitions",!1,!0,!1,1,h.eCollList.sort(l))),f.push(window.modalView.createSelect2Entry("fromCollections"+h.counter,"fromCollections",b.from,"The collections that contain the start vertices of the relation.","fromCollections",!0,!1,!1,null,e.sort(l))),f.push(window.modalView.createSelect2Entry("toCollections"+h.counter,"toCollections",b.to,"The collections that contain the end vertices of the relation.","toCollections",!0,!1,!1,null,e.sort(l))),h.counter++}),f.push(window.modalView.createSelect2Entry("newVertexCollections","Vertex collections",k,"Collections that are part of a graph but not used in an edge definition","Vertex Collections",!1,!1,!1,null,e.sort(l))),window.modalView.show("modalGraphTable.ejs",c,d,f,void 0,void 0,this.events),$("#tab-createGraph").parent().hasClass("active")&&h.hideSmartGraphOptions(),a){$(".modal-body table").css("border-collapse","separate");var m;for($(".modal-body .spacer").remove(),m=0;m<=this.counter;m++)$("#row_fromCollections"+m).show(),$("#row_toCollections"+m).show(),$("#row_newEdgeDefinitions"+m).addClass("first"),$("#row_fromCollections"+m).addClass("middle"),$("#row_toCollections"+m).addClass("last"),$("#row_toCollections"+m).after('');$("#graphTab").hide(),$("#modal-dialog .modal-delete-confirmation").append('
')}},resetDisplaySettings:function(){var a=$("#editGraphName").val(),b=new window.GraphSettingsView({name:a,userConfig:window.App.userConfig});b.setDefaults(!0,!0),b.remove(),window.modalView.hide(),arangoHelper.arangoNotification("Graph","Reset successful.")},addRemoveDefinition:function(a){var b=[],c=this.options.collectionCollection.models;c.forEach(function(a){a.get("isSystem")||b.push(a.id)}),a.stopPropagation();var d,e=$(a.currentTarget).attr("id");if(e.indexOf("addAfter_newEdgeDefinitions")===-1)e.indexOf("remove_newEdgeDefinitions")!==-1&&(d=e.split("remove_newEdgeDefinitions")[1],$("#row_newEdgeDefinitions"+d).remove(),$("#row_fromCollections"+d).remove(),$("#row_toCollections"+d).remove(),$("#spacer"+d).remove());else{this.counter++,$("#row_newVertexCollections").before(this.edgeDefintionTemplate.render({number:this.counter})),$("#newEdgeDefinitions"+this.counter).select2({tags:this.eCollList,showSearchBox:!1,minimumResultsForSearch:-1,width:"336px",maximumSelectionSize:1}),$("#fromCollections"+this.counter).select2({tags:b,showSearchBox:!1,minimumResultsForSearch:-1,width:"336px"}),$("#toCollections"+this.counter).select2({tags:b,showSearchBox:!1,minimumResultsForSearch:-1,width:"336px"}),window.modalView.undelegateEvents(),window.modalView.delegateEvents(this.events);var f;for($(".modal-body .spacer").remove(),f=0;f<=this.counter;f++)$("#row_fromCollections"+f).show(),$("#row_toCollections"+f).show(),$("#row_newEdgeDefinitions"+f).addClass("first"),$("#row_fromCollections"+f).addClass("middle"),$("#row_toCollections"+f).addClass("last"),$("#row_toCollections"+f).after('')}},calculateEdgeDefinitionMap:function(){var a={};return this.collection.models.forEach(function(b){b.get("edgeDefinitions").forEach(function(b){a[b.collection]={from:b.from,to:b.to}})}),a}})}(),function(){"use strict";window.GraphSettingsView=Backbone.View.extend({el:"#graphSettingsContent",remove:function(){return this.$el.empty().off(),this.stopListening(),this},general:{graph:{type:"divider",name:"Graph"},nodeStart:{type:"string",name:"Startnode",desc:"A valid node id or space seperated list of id's. If empty, a random node will be chosen.",value:2},layout:{type:"select",name:"Layout",desc:"Different graph algorithms. No overlap is very fast (more than 5000 nodes), force is slower (less than 5000 nodes) and fruchtermann is the slowest (less than 500 nodes).",noverlap:{name:"No overlap",val:"noverlap"},force:{name:"Force",val:"force"},fruchtermann:{name:"Fruchtermann",val:"fruchtermann"}},renderer:{type:"select",name:"Renderer",desc:"Canvas enables editing, WebGL is only for displaying a graph but much faster.",canvas:{name:"Canvas",val:"canvas"},webgl:{name:"WebGL (experimental)",val:"webgl"}},depth:{desc:"Search depth, starting from your start node.",type:"number",name:"Search Depth",value:2},limit:{desc:"Limit nodes count. If empty or zero, no limit is set.",type:"number",name:"Limit",value:250}},specific:{nodes:{type:"divider",name:"Nodes"},nodeLabel:{type:"string",name:"Label",desc:"Node label. Please choose a valid and available node attribute.","default":"_key"},nodeLabelByCollection:{type:"select",name:"Add Collection Name",desc:"Append collection name to the label?",yes:{name:"Yes",val:"true"},no:{name:"No",val:"false"}},nodeColorByCollection:{type:"select",name:"Color By Collections",no:{name:"No",val:"false"},yes:{name:"Yes",val:"true"},desc:"Should nodes be colorized by their collection? If enabled, node color and node color attribute will be ignored."},nodeColor:{type:"color",name:"Color",desc:"Default node color. RGB or HEX value.","default":"#2ecc71"},nodeColorAttribute:{type:"string",name:"Color Attribute",desc:"If an attribute is given, nodes will then be colorized by the attribute. This setting ignores default node color if set."},nodeSizeByEdges:{type:"select",name:"Size By Connections",yes:{name:"Yes",val:"true"},no:{name:"No",val:"false"},desc:"Should nodes be sized by their edges count? If enabled, node sizing attribute will be ignored."},nodeSize:{type:"string",name:"Sizing Attribute",desc:"Default node size. Numeric value > 0."},edges:{type:"divider",name:"Edges"},edgeLabel:{type:"string",name:"Label",desc:"Default edge label."},edgeLabelByCollection:{type:"select",name:"Add Collection Name",desc:"Set label text by collection. If activated edge label attribute will be ignored.",yes:{name:"Yes",val:"true"},no:{name:"No",val:"false"}},edgeColorByCollection:{type:"select",name:"Color By Collections",no:{name:"No",val:"false"},yes:{name:"Yes",val:"true"},desc:"Should edges be colorized by their collection? If enabled, edge color and edge color attribute will be ignored."},edgeColor:{type:"color",name:"Color",desc:"Default edge color. RGB or HEX value.","default":"#cccccc"},edgeColorAttribute:{type:"string",name:"Color Attribute",desc:"If an attribute is given, edges will then be colorized by the attribute. This setting ignores default edge color if set."},edgeEditable:{type:"select",hide:"true",name:"Editable",yes:{name:"Yes",val:"true"},no:{name:"No",val:"false"},desc:"Should edges be editable?"},edgeType:{type:"select",name:"Type",desc:"The type of the edge",line:{name:"Line",val:"line"},arrow:{name:"Arrow",val:"arrow"},curve:{name:"Curve",val:"curve"},dotted:{name:"Dotted",val:"dotted"},dashed:{name:"Dashed",val:"dashed"},tapered:{name:"Tapered",val:"tapered"}}},template:templateEngine.createTemplate("graphSettingsView.ejs"),initialize:function(a){this.name=a.name,this.userConfig=a.userConfig,this.saveCallback=a.saveCallback,a.noDefinedGraph&&(this.noDefinedGraph=a.noDefinedGraph)},events:{"click #saveGraphSettings":"saveGraphSettings","click #restoreGraphSettings":"setDefaults","keyup #graphSettingsView input":"checkEnterKey","keyup #graphSettingsView select":"checkEnterKey",'change input[type="range"]':"saveGraphSettings",'change input[type="color"]':"checkColor","change select":"saveGraphSettings","focus #graphSettingsView input":"lastFocus","focus #graphSettingsView select":"lastFocus",'focusout #graphSettingsView input[type="text"]':"checkinput"},lastFocus:function(a){this.lastFocussed=a.currentTarget.id,this.lastFocussedValue=$(a.currentTarget).val()},checkinput:function(a){new Date-this.lastSaved>500&&a.currentTarget.id===this.lastFocussed&&this.lastFocussedValue!==$(a.currentTarget).val()&&this.saveGraphSettings()},checkEnterKey:function(a){13===a.keyCode&&this.saveGraphSettings(a)},getGraphSettings:function(a){var b=this,c=frontendConfig.db+"_"+this.name;this.userConfig.fetch({success:function(d){b.graphConfig=d.toJSON().graphs[c],a&&b.continueRender()}})},checkColor:function(){this.saveGraphSettings(null,!0)},saveGraphSettings:function(a,b,c,d,e,f){var g=this,h=function(){var a=!$("#g_nodeColor").is(":disabled"),b=!$("#g_edgeColor").is(":disabled");window.App.graphViewer.updateColors(a,b,$("#g_nodeColor").val(),$("#g_edgeColor").val())};if(this.noDefinedGraph){var i;b?h():"g_layout"===a.currentTarget.id?window.App.graphViewer.rerenderAQL($("#g_layout").val(),null):"g_nodeColorByCollection"===a.currentTarget.id?(i=$("#g_nodeColorByCollection").val(),"true"===i?window.App.graphViewer.switchNodeColorByCollection(!0):window.App.graphViewer.switchNodeColorByCollection(!1)):"g_edgeColorByCollection"===a.currentTarget.id?(i=$("#g_edgeColorByCollection").val(),"true"===i?window.App.graphViewer.switchEdgeColorByCollection(!0):window.App.graphViewer.switchEdgeColorByCollection(!1)):"g_nodeSizeByEdges"===a.currentTarget.id?(i=$("#g_nodeSizeByEdges").val(),"true"===i?window.App.graphViewer.switchNodeSizeByCollection(!0):window.App.graphViewer.switchNodeSizeByCollection(!1)):"g_edgeType"===a.currentTarget.id&&window.App.graphViewer.switchEdgeType($("#g_edgeType").val())}else{g.lastSaved=new Date;var j=frontendConfig.db+"_"+this.name,k={};if(d)k[j]=d;else{var l,m={};$("#graphSettingsView select").each(function(a,b){l=b.id,m[l.substr(2,b.id.length)]=$(b).val()}),$("#graphSettingsView input").each(function(a,b){l=b.id,m[l.substr(2,b.id.length)]=$(b).val()}),k[j]=m}c&&(k[j].nodeStart=c);var n=function(){if(window.App.graphViewer){var c;if(a){if("g_layout"===a.currentTarget.id)return void window.App.graphViewer.switchLayout($("#g_layout").val());if("g_nodeColorByCollection"===a.currentTarget.id)return c=$("#g_nodeColorByCollection").val(),void("true"===c?window.App.graphViewer.switchNodeColorByCollection(!0):$("#g_nodeColorAttribute").is(":disabled")?window.App.graphViewer.switchNodeColorByCollection(!1):window.App.graphViewer.switchNodeColorByCollection(!1,!0));if("g_edgeColorByCollection"===a.currentTarget.id)return c=$("#g_edgeColorByCollection").val(),void("true"===c?window.App.graphViewer.switchEdgeColorByCollection(!0):$("#g_nodeColorAttribute").is(":disabled")?window.App.graphViewer.switchEdgeColorByCollection(!1):window.App.graphViewer.switchEdgeColorByCollection(!1,!0))}""!==b&&void 0!==b?h():window.App.graphViewer.render(g.lastFocussed)}else e||arangoHelper.arangoNotification("Graph "+this.name,"Configuration saved.");f&&f()}.bind(this);this.userConfig.setItem("graphs",k,n)}this.handleDependencies()},setDefaults:function(a,b,c){var d={layout:"force",renderer:"canvas",depth:"2",limit:"250",nodeColor:"#2ecc71",nodeColorAttribute:"",nodeColorByCollection:"true",edgeColor:"#cccccc",edgeColorAttribute:"",edgeColorByCollection:"false",nodeLabel:"_key",edgeLabel:"",edgeType:"arrow",nodeSize:"",nodeSizeByEdges:"true",edgeEditable:"true",nodeLabelByCollection:"false",edgeLabelByCollection:"false",nodeStart:"",barnesHutOptimize:!0};a===!0?b?this.saveGraphSettings(null,null,null,d,b,c):this.saveGraphSettings(null,null,null,d):(this.saveGraphSettings(null,null,null,d,null),this.render(),window.App.graphViewer.render(this.lastFocussed))},toggle:function(){$(this.el).is(":visible")?this.hide():this.show()},show:function(){$(this.el).show("slide",{direction:"right"},250)},hide:function(){$(this.el).hide("slide",{direction:"right"},250)},render:function(){this.noDefinedGraph?this.continueRender():(this.getGraphSettings(!0),this.lastSaved=new Date)},handleDependencies:function(){"true"===$("#g_nodeSizeByEdges").val()?$("#g_nodeSize").prop("disabled",!0):$("#g_nodeSize").removeAttr("disabled"),"true"===$("#g_nodeColorByCollection").val()?($("#g_nodeColorAttribute").prop("disabled",!0),$("#g_nodeColor").prop("disabled",!0)):($("#g_nodeColorAttribute").removeAttr("disabled"),$("#g_nodeColor").removeAttr("disabled")),this.noDefinedGraph||""!==$("#g_nodeColorAttribute").val()&&$("#g_nodeColor").prop("disabled",!0),"true"===$("#g_edgeColorByCollection").val()?($("#g_edgeColorAttribute").prop("disabled",!0),$("#g_edgeColor").prop("disabled",!0)):($("#g_edgeColorAttribute").removeAttr("disabled"),$("#g_edgeColor").removeAttr("disabled")),this.noDefinedGraph||""!==$("#g_edgeColorAttribute").val()&&$("#g_edgeColor").prop("disabled",!0)},continueRender:function(){$(this.el).html(this.template.render({general:this.general,specific:this.specific})),arangoHelper.fixTooltips(".gv-tooltips","top"),this.graphConfig?_.each(this.graphConfig,function(a,b){$("#g_"+b).val(a)}):this.noDefinedGraph?this.fitSettingsAQLMode():this.setDefaults(!0),this.handleDependencies()},fitSettingsAQLMode:function(){var a=["g_nodeStart","g_depth","g_limit","g_renderer","g_nodeLabel","g_nodeLabelByCollection","g_nodeColorAttribute","g_nodeSize","g_edgeLabel","g_edgeColorAttribute","g_edgeLabelByCollection"];_.each(a,function(a){$("#"+a).parent().prev().remove(),$("#"+a).parent().remove()}),$("#saveGraphSettings").remove(),$("#restoreGraphSettings").remove(),$("#g_nodeColorByCollection").val("false"),$("#g_edgeColorByCollection").val("false"),$("#g_nodeSizeByEdges").val("false"),$("#g_edgeType").val("arrow"),$("#g_layout").val("force")}})}(),function(){"use strict";window.GraphViewer=Backbone.View.extend({el:"#content",remove:function(){return this.$el.empty().off(),this.stopListening(),this.unbind(),delete this.el,this},template:templateEngine.createTemplate("graphViewer2.ejs"),initialize:function(a){var b=this;a.id&&(this.setElement(a.id),this.graphData=a.data,this.aqlMode=!0),a.noDefinedGraph&&(this.noDefinedGraph=a.noDefinedGraph,this.graphData=a.data),this.name=a.name,this.userConfig=a.userConfig,this.documentStore=a.documentStore,void 0!==this.name&&this.collection.fetch({cache:!1,success:function(c){b.model=b.collection.findWhere({_key:a.name}).toJSON()}})},colors:{hotaru:["#364C4A","#497C7F","#92C5C0","#858168","#CCBCA5"],random1:["#292F36","#4ECDC4","#F7FFF7","#DD6363","#FFE66D"],jans:["rgba(166, 109, 161, 1)","rgba(64, 74, 83, 1)","rgba(90, 147, 189, 1)","rgba(153,63,0,1)","rgba(76,0,92,1)","rgba(25,25,25,1)","rgba(0,92,49,1)","rgba(43,206,72,1)","rgba(255,204,153,1)","rgba(128,128,128,1)","rgba(148,255,181,1)","rgba(143,124,0,1)","rgba(157,204,0,1)","rgba(194,0,136,1)","rgba(0,51,128,1)","rgba(255,164,5,1)","rgba(255,168,187,1)","rgba(66,102,0,1)","rgba(255,0,16,1)","rgba(94,241,242,1)","rgba(0,153,143,1)","rgba(224,255,102,1)","rgba(116,10,255,1)","rgba(153,0,0,1)","rgba(255,255,128,1)","rgba(255,255,0,1)","rgba(255,80,5,1)"],gv:["#68BDF6","#6DCE9E","#FF756E","#DE9BF9","#FB95AF","#FFD86E","#A5ABB6"]},activeNodes:[],selectedNodes:{},aqlMode:!1,events:{"click #downloadPNG":"downloadPNG","click #loadFullGraph":"loadFullGraphModal","click #reloadGraph":"reloadGraph","click #settingsMenu":"toggleSettings","click #toggleForce":"toggleLayout","click #selectNodes":"toggleLasso"},cursorX:0,cursorY:0,layouting:!1,model:null,viewStates:{captureMode:!1},graphConfig:null,graphSettings:null,downloadPNG:function(){var a=parseInt($("#graph-container").width(),10);sigma.plugins.image(this.currentGraph,this.currentGraph.renderers[0],{download:!0,size:a,clip:!0,labels:!0,background:"white",zoom:!1})},loadFullGraphModal:function(){var a=[],b=[];b.push(window.modalView.createReadOnlyEntry("load-full-graph-a","Caution","Really load full graph? If no limit is set, your result set could be too big.")),a.push(window.modalView.createSuccessButton("Load full graph",this.loadFullGraph.bind(this))),window.modalView.show("modalTable.ejs","Load full graph",a,b)},loadFullGraph:function(){var a=this,b={};this.graphConfig&&(b=_.clone(this.graphConfig),delete b.layout,delete b.edgeType,delete b.renderer),b.mode="all",$.ajax({type:"GET",url:arangoHelper.databaseUrl("/_admin/aardvark/graph/"+encodeURIComponent(this.name)),contentType:"application/json",data:b,success:function(b){a.killCurrentGraph(),a.renderGraph(b)},error:function(a){console.log(a),arangoHelper.arangoError("Graph","Could not load full graph.")}}),window.modalView.hide()},resize:function(){$("#graph-container").width($(".centralContent").width()),$("#graph-container").height($(".centralRow").height()-155)},toggleSettings:function(){this.graphSettingsView.toggle()},render:function(a){this.$el.html(this.template.render({})),$("#subNavigationBar .breadcrumb").html("Graph: "+this.name),this.resize(),this.fetchGraph(a),this.initFullscreen()},initFullscreen:function(){var a=this;if(window.App.initializedFullscreen===!1||void 0===window.App.initializedFullscreen){window.App.initializedFullscreen=!0,this.isFullscreen=!1;var b=function(b){(document.webkitIsFullScreen||document.mozFullScreen||null!==document.msFullscreenElement)&&(a.isFullscreen===!1?(a.isFullscreen=!0,$("#toggleForce").css("bottom","10px"),$("#toggleForce").css("right","10px"),$("#objectCount").css("bottom","10px"),$("#objectCount").css("left","10px"),$(".nodeInfoDiv").css("top","10px"),$(".nodeInfoDiv").css("left","10px")):(a.isFullscreen=!1,$("#toggleForce").css("bottom","40px"),$("#toggleForce").css("right","40px"),$("#objectCount").css("bottom","50px"),$("#objectCount").css("left","25px"),$(".nodeInfoDiv").css("top",""),$(".nodeInfoDiv").css("left","165px")))};document.addEventListener&&(document.addEventListener("webkitfullscreenchange",b,!1),document.addEventListener("mozfullscreenchange",b,!1),document.addEventListener("fullscreenchange",b,!1),document.addEventListener("MSFullscreenChange",b,!1))}},renderAQLPreview:function(a){this.$el.html(this.template.render({})),this.$el.find(".headerBar").remove();var b=$(".centralRow").height()-250;this.$el.find("#graph-container").css("height",b),this.graphData.modified=this.parseData(this.graphData.original,this.graphData.graphInfo);var c=!1;try{this.renderGraph(this.graphData.modified,null,!0),c=!0}catch(d){}return c},renderAQL:function(a){this.$el.html(this.template.render({})),$("#subNavigationBar .breadcrumb").html("AQL Graph"),$("#subNavigationBar .bottom").html(""),$(".queries-menu").removeClass("active"),this.resize(),this.graphData.modified=this.parseData(this.graphData.original,this.graphData.graphInfo),this.renderGraph(this.graphData.modified,null,!1),this.initFullscreen(),this.graphSettingsView=new window.GraphSettingsView({name:this.name,userConfig:void 0,saveCallback:void 0,noDefinedGraph:!0}),this.graphSettingsView.render()},killCurrentGraph:function(){for(var a in this.currentGraph.renderers)try{this.currentGraph.renderers[a].clear(),this.currentGraph.kill(a)}catch(b){}},rerenderAQL:function(a,b){this.killCurrentGraph(),this.renderGraph(this.graphData.modified,null,!1,a,"canvas"),"true"===$("#g_nodeColorByCollection").val()?this.switchNodeColorByCollection(!0):$("#g_nodeColor").is(":disabled")?this.updateColors(!0,!0,null,null,!0):this.ncolor?this.updateColors(!0,!0,this.ncolor,this.ecolor):this.updateColors(!0,!0,"#2ecc71","#2ecc71"),"true"===$("#g_edgeColorByCollection").val()?this.switchEdgeColorByCollection(!0):$("#g_edgeColor").is(":disabled")?this.updateColors(!0,!0,null,null,!0):this.ecolor?this.updateColors(!0,!0,this.ncolor,this.ecolor):this.updateColors(!0,!0,"#2ecc71","#2ecc71")},buildCollectionColors:function(){var a=this;if(!a.collectionColors){a.collectionColors={};var b=0,c={},d={};_.each(this.currentGraph.graph.nodes(),function(a){c[a.id]=void 0}),_.each(a.currentGraph.graph.edges(),function(a){d[a.id]=void 0}),_.each(c,function(c,d){void 0===a.collectionColors[d.split("/")[0]]&&(a.collectionColors[d.split("/")[0]]={color:a.colors.jans[b]},b++)}),b=0,_.each(d,function(c,d){void 0===a.collectionColors[d.split("/")[0]]&&(a.collectionColors[d.split("/")[0]]={color:a.colors.jans[b]},b++)})}},switchNodeColorByCollection:function(a,b){var c=this;c.buildCollectionColors(),a?(c.currentGraph.graph.nodes().forEach(function(a){a.color=c.collectionColors[a.id.split("/")[0]].color}),c.currentGraph.refresh()):b?this.updateColors(!0,null,null,null,b):this.ncolor?this.updateColors(!0,null,this.ncolor,this.ecolor):this.updateColors(!0,null,"#2ecc71","#2ecc71")},switchEdgeColorByCollection:function(a,b){var c=this;c.buildCollectionColors(),a?(c.currentGraph.graph.edges().forEach(function(a){a.color=c.collectionColors[a.id.split("/")[0]].color}),c.currentGraph.refresh()):b?this.updateColors(!0,null,null,null,b):this.ecolor?this.updateColors(null,!0,this.ncolor,this.ecolor):this.updateColors(null,!0,"#2ecc71","#2ecc71")},buildCollectionSizes:function(){var a=this;if(!a.nodeEdgesCount){a.nodeEdgesCount={};var b={};_.each(this.currentGraph.graph.edges(),function(c){void 0===b[c.id]&&(b[c.id]=!0,void 0===a.nodeEdgesCount[c.source]?a.nodeEdgesCount[c.source]=1:a.nodeEdgesCount[c.source]+=1,void 0===a.nodeEdgesCount[c.target]?a.nodeEdgesCount[c.target]=1:a.nodeEdgesCount[c.target]+=1)})}},switchNodeSizeByCollection:function(a){var b=this;a?(b.buildCollectionSizes(),b.currentGraph.graph.nodes().forEach(function(a){a.size=b.nodeEdgesCount[a.id]})):b.currentGraph.graph.nodes().forEach(function(a){a.size=15}),b.currentGraph.refresh()},switchEdgeType:function(a){var b={nodes:this.currentGraph.graph.nodes(),edges:this.currentGraph.graph.edges(),settings:{}};this.killCurrentGraph(),this.renderGraph(b,null,!1,null,null,a)},switchLayout:function(a){var b={nodes:this.currentGraph.graph.nodes(),edges:this.currentGraph.graph.edges(),settings:{}};this.killCurrentGraph(),this.renderGraph(b,null,!1,a),"true"===$("#g_nodeColorByCollection").val()&&this.switchNodeColorByCollection(!0),"true"===$("#g_edgeColorByCollection").val()?this.switchEdgeColorByCollection(!0):this.switchEdgeColorByCollection(!1)},parseData:function(a,b){var c={},d={},e="#2ecc71",f={nodes:[],edges:[],settings:{}};if(this.ncolor&&(e=this.ncolor),"object"===b){_.each(a,function(a){a.edges&&a.vertices&&(_.each(a.edges,function(a){null!==a&&(d[a._id]={id:a._id,source:a._from,color:"#cccccc",target:a._to})}),_.each(a.vertices,function(a){null!==a&&(c[a._id]={id:a._id,label:a._key,size:.3,color:e,x:Math.random(),y:Math.random()})}))});var g=[];_.each(c,function(a){f.nodes.push(a),g.push(a.id)}),_.each(d,function(a){g.includes(a.source)&&g.includes(a.target)&&f.edges.push(a)})}else"array"===b&&(_.each(a,function(a){c[a._from]=null,c[a._to]=null,f.edges.push({id:a._id,source:a._from,color:"#cccccc",target:a._to})}),_.each(c,function(a,b){f.nodes.push({id:b,label:b,size:.3,color:e,x:Math.random(),y:Math.random()})}));return f},rerender:function(){this.fetchGraph()},fetchGraph:function(a){var b=this;$(this.el).append('
Fetching graph data. Please wait ...


If it`s taking too much time to draw the graph, please navigate to: Graphs View
Click the settings icon and reset the display settings.It is possible that the graph is too big to be handled by the browser.
');var c=function(){var c={};b.graphConfig&&(c=_.clone(b.graphConfig),delete c.layout,delete c.edgeType,delete c.renderer),b.tmpStartNode&&(b.graphConfig?0===b.graphConfig.nodeStart.length&&(c.nodeStart=b.tmpStartNode):c.nodeStart=b.tmpStartNode),b.setupSigma(),b.fetchStarted=new Date,$.ajax({type:"GET",url:arangoHelper.databaseUrl("/_admin/aardvark/graph/"+encodeURIComponent(b.name)),contentType:"application/json",data:c,success:function(c){c.empty===!0?b.renderGraph(c,a):(c.settings&&c.settings.startVertex&&void 0===b.graphConfig.startNode&&void 0===b.tmpStartNode&&(b.tmpStartNode=c.settings.startVertex._id),b.fetchFinished=new Date,b.calcStart=b.fetchFinished,$("#calcText").html("Server response took "+Math.abs(b.fetchFinished.getTime()-b.fetchStarted.getTime())+" ms. Initializing graph engine. Please wait ... "),window.setTimeout(function(){b.renderGraph(c,a)},50))},error:function(a){try{var c;if(a.responseJSON.exception){c=a.responseJSON.exception;var d=a.responseJSON.exception.search("1205");if(d!==-1){var e='Starting point: '+b.graphConfig.nodeStart+" is invalid";$("#calculatingGraph").html('
Stopped.

'+e+'. Please choose a different start node.
')}else $("#calculatingGraph").html("Failed to fetch graph information.")}else c=a.responseJSON.errorMessage,$("#calculatingGraph").html("Failed to fetch graph information: "+a.responseJSON.errorMessage);arangoHelper.arangoError("Graph",c)}catch(f){}}})};void 0===b.graphConfig||null===b.graphConfig?b.userConfig.fetch({success:function(a){var d=frontendConfig.db+"_"+b.name;try{b.graphConfig=a.toJSON().graphs[d],b.getGraphSettings(c),void 0===b.graphConfig||null===b.graphConfig?(b.graphSettingsView=new window.GraphSettingsView({name:b.name,userConfig:b.userConfig,saveCallback:b.render}),b.graphSettingsView.setDefaults(!0,!0)):(b.graphSettingsView&&b.graphSettingsView.remove(),b.graphSettingsView=new window.GraphSettingsView({name:b.name,userConfig:b.userConfig,saveCallback:b.render}))}catch(e){b.getGraphSettings(c)}}}):this.getGraphSettings(c)},setupSigma:function(){if(this.graphConfig&&this.graphConfig.edgeLabel){sigma.utils.pkg("sigma.settings");var a={defaultEdgeLabelColor:"#000",defaultEdgeLabelActiveColor:"#000",defaultEdgeLabelSize:12,edgeLabelSize:"fixed",edgeLabelThreshold:1,edgeLabelSizePowRatio:1};sigma.settings=sigma.utils.extend(sigma.settings||{},a),sigma.settings.drawEdgeLabels=!0,sigma.settings.clone=!0}},contextState:{createEdge:!1,_from:!1,_to:!1,fromX:!1,fromY:!1},clearOldContextMenu:function(a){var b=this;$("#nodeContextMenu").remove();var c='
';$("#graph-container").append(c),a&&_.each(this.contextState,function(a,c){b.contextState[c]=!1});var d=document.getElementsByClassName("sigma-mouse")[0];d.removeEventListener("mousemove",b.drawLine.bind(this),!1)},trackCursorPosition:function(a){this.cursorX=a.x,this.cursorY=a.y},deleteNode:function(a,b){var c,d,e,f=this;c=b?b:$("#delete-node-attr-id").text(),d=c.split("/")[0],e=c.split("/")[1];var g=arangoHelper.databaseUrl("/_api/gharial/"+encodeURIComponent(f.name)+"/vertex/"+encodeURIComponent(c.split("/")[0])+"/"+encodeURIComponent(c.split("/")[1]));if("yes"===$("#delete-node-edges-attr").val())$.ajax({cache:!1,type:"DELETE",contentType:"application/json",url:g,success:function(a){f.currentGraph.graph.dropNode(c),f.currentGraph.refresh()},error:function(){arangoHelper.arangoError("Graph","Could not delete node.")}});else{var h=function(a){a?arangoHelper.arangoError("Graph","Could not delete node."):(f.currentGraph.graph.dropNode(c),f.currentGraph.refresh())};this.documentStore.deleteDocument(d,e,h)}window.modalView.hide()},deleteNodes:function(){var a=this;try{var b=JSON.parse($("#delete-nodes-arr-id").text());_.each(b,function(b){a.deleteNode(null,b)})}catch(c){}},deleteNodesModal:function(){var a=[];if(_.each(this.selectedNodes,function(b){a.push(b)}),0===a.length)return void arangoHelper.arangoNotification("Graph","No nodes selected.");var b=[],c=[];c.push(window.modalView.createReadOnlyEntry("delete-nodes-arr-id","Really delete nodes",JSON.stringify(a))),b.push(window.modalView.createDeleteButton("Delete",this.deleteNodes.bind(this))),window.modalView.show("modalTable.ejs","Delete nodes",b,c)},deleteNodeModal:function(a){var b=[],c=[];c.push(window.modalView.createReadOnlyEntry("delete-node-attr-id","Really delete node",a)),this.noDefinedGraph||c.push(window.modalView.createSelectEntry("delete-node-edges-attr","Also delete edges?",void 0,void 0,[{value:"yes",label:"Yes"},{value:"no",label:"No"}])),b.push(window.modalView.createDeleteButton("Delete",this.deleteNode.bind(this))),window.modalView.show("modalTable.ejs","Delete node",b,c)},addNode:function(){var a=this,b=$(".modal-body #new-node-collection-attr").val(),c=$(".modal-body #new-node-key-attr").last().val(),d=function(b,c,d){b?arangoHelper.arangoError("Could not create node",d):($("#emptyGraph").remove(),a.currentGraph.graph.addNode({id:c,label:c.split("/")[1]||"",size:a.graphConfig.nodeSize||15,color:a.graphConfig.nodeColor||a.ncolor||"#2ecc71",originalColor:a.graphConfig.nodeColor||a.ncolor||"#2ecc71",x:a.addNodeX+a.currentGraph.camera.x,y:a.addNodeY+a.currentGraph.camera.y}),window.modalView.hide(),a.currentGraph.refresh(),a.cameraToNode(a.currentGraph.graph.nodes(c)))},e={};if(""!==c&&void 0!==c&&(e._key=c),this.graphSettings.isSmart){var f=$("#new-smart-key-attr").val();""!==f&&void 0!==f?e[this.graphSettings.smartGraphAttribute]=f:e[this.graphSettings.smartGraphAttribute]=null; -}this.collection.createNode(a.name,b,e,d)},deleteEdgeModal:function(a){var b=[],c=[];c.push(window.modalView.createReadOnlyEntry("delete-edge-attr-id","Really delete edge",a)),b.push(window.modalView.createDeleteButton("Delete",this.deleteEdge.bind(this))),window.modalView.show("modalTable.ejs","Delete edge",b,c)},deleteEdge:function(){var a=this,b=$("#delete-edge-attr-id").text(),c=b.split("/")[0],d=b.split("/")[1],e=function(c){c?arangoHelper.arangoError("Graph","Could not delete edge."):(a.currentGraph.graph.dropEdge(b),a.currentGraph.refresh())};this.documentStore.deleteDocument(c,d,e),window.modalView.hide()},addNodeModal:function(){if(0!==this.graphSettings.vertexCollections){var a=[],b=[],c=[];_.each(this.graphSettings.vertexCollections,function(a){c.push({label:a.name,value:a.name})}),b.push(window.modalView.createTextEntry("new-node-key-attr","_key",void 0,"The nodes unique key(optional attribute, leave empty for autogenerated key","is optional: leave empty for autogenerated key",!1,[{rule:Joi.string().allow("").optional(),msg:""}])),this.graphSettings.isSmart&&b.push(window.modalView.createTextEntry("new-smart-key-attr",this.graphSettings.smartGraphAttribute+"*",void 0,"The attribute value that is used to smartly shard the vertices of a graph. \nEvery vertex in this Graph has to have this attribute. \nCannot be modified later.","Cannot be modified later.",!1,[{rule:Joi.string().allow("").optional(),msg:""}])),b.push(window.modalView.createSelectEntry("new-node-collection-attr","Collection",void 0,"Please select the destination for the new node.",c)),a.push(window.modalView.createSuccessButton("Create",this.addNode.bind(this))),window.modalView.show("modalTable.ejs","Create node",a,b)}else arangoHelper.arangoError("Graph","No valid vertex collections found.")},addEdge:function(){var a,b=this,c=b.contextState._from,d=b.contextState._to;a=""===$(".modal-body #new-edge-collection-attr").val()?$(".modal-body #new-edge-collection-attr").text():$(".modal-body #new-edge-collection-attr").val();var e=$(".modal-body #new-edge-key-attr").last().val(),f=function(a,e,f){if(a)arangoHelper.arangoError("Could not create edge",f);else{var g={source:c,target:d,id:e,color:b.graphConfig.edgeColor||b.ecolor};"true"===b.graphConfig.edgeEditable&&(g.size=1),b.currentGraph.graph.addEdge(g),b.graphConfig&&"curve"===b.graphConfig.edgeType&&sigma.canvas.edges.autoCurve(b.currentGraph),b.currentGraph.refresh()}b.clearOldContextMenu(!0),window.modalView.hide()},g={_from:c,_to:d};""!==e&&void 0!==e&&(g._key=e),this.collection.createEdge(b.name,a,g,f)},addEdgeModal:function(a){if(0!==a){var b=[],c=[];if(c.push(window.modalView.createTextEntry("new-edge-key-attr","_key",void 0,"The edges unique key(optional attribute, leave empty for autogenerated key","is optional: leave empty for autogenerated key",!1,[{rule:Joi.string().allow("").optional(),msg:""}])),a.length>1){var d=[];_.each(a,function(a){d.push({label:a,value:a})}),c.push(window.modalView.createSelectEntry("new-edge-collection-attr","Edge collection",void 0,"Please select the destination for the new edge.",d))}else c.push(window.modalView.createReadOnlyEntry("new-edge-collection-attr","Edge collection",a[0],"The edge collection to be used."));b.push(window.modalView.createSuccessButton("Create",this.addEdge.bind(this))),window.modalView.show("modalTable.ejs","Create edge",b,c)}else arangoHelper.arangoError("Graph","No valid edge definitions found.")},updateColors:function(a,b,c,d,e){var f=frontendConfig.db+"_"+this.name,g=this;c&&(g.ncolor=c),d&&(g.ecolor=d),this.userConfig.fetch({success:function(h){if(a===!0){g.graphConfig=h.toJSON().graphs[f];try{g.currentGraph.graph.nodes().forEach(function(a){e?a.color=a.sortColor:a.color=c})}catch(i){g.graphNotInitialized=!0,g.tmpGraphArray=[a,b,c,d]}}if(b===!0)try{g.currentGraph.graph.edges().forEach(function(a){e?a.color=a.sortColor:a.color=d})}catch(j){g.graphNotInitialized=!0,g.tmpGraphArray=[a,b,c,d]}g.currentGraph&&g.currentGraph.refresh()}})},nodesContextMenuCheck:function(a){this.nodesContextEventState=a,this.openNodesDate=new Date},createContextMenu:function(a){var b=this,c=b.cursorX-50,d=b.cursorY-50;this.clearOldContextMenu();var e=function(a){var c=wheelnav,d=new c("nodeContextMenu");d.maxPercent=1,d.wheelRadius=50,d.clockwise=!1,d.colors=b.colors.hotaru,d.multiSelect=!0,d.clickModeRotate=!1,d.slicePathFunction=slicePath().DonutSlice,d.createWheel([icon.plus,icon.arrowleft2]),d.navItems[0].selected=!1,d.navItems[0].hovered=!1,d.navItems[0].navigateFunction=function(a){b.clearOldContextMenu(),b.addNodeModal()},d.navItems[1].navigateFunction=function(a){b.clearOldContextMenu()},d.navItems[0].selected=!1,d.navItems[0].hovered=!1};$("#nodeContextMenu").css("position","fixed"),$("#nodeContextMenu").css("left",c),$("#nodeContextMenu").css("top",d),$("#nodeContextMenu").width(100),$("#nodeContextMenu").height(100),e(a)},createEdgeContextMenu:function(a,b){var c=this,d=this.cursorX-165,e=this.cursorY-120;this.clearOldContextMenu();var f=function(a,b){var d=["#364C4A","#497C7F","#92C5C0","#858168","#CCBCA5"],e=wheelnav,f=new e("nodeContextMenu");f.maxPercent=1,f.wheelRadius=50,f.clockwise=!1,f.colors=d,f.multiSelect=!0,f.clickModeRotate=!1,f.slicePathFunction=slicePath().DonutSlice,f.createWheel([icon.edit,icon.trash]),f.navItems[0].selected=!1,f.navItems[0].hovered=!1,f.navItems[0].navigateFunction=function(a){c.clearOldContextMenu(),c.editEdge(b)},f.navItems[1].navigateFunction=function(a){c.clearOldContextMenu(),c.deleteEdgeModal(b)},f.navItems[0].selected=!1,f.navItems[0].hovered=!1};$("#nodeContextMenu").css("left",d+115),$("#nodeContextMenu").css("top",e+72),$("#nodeContextMenu").width(100),$("#nodeContextMenu").height(100),f(b,a)},createNodeContextMenu:function(a,b){var c,d,e,f=this;_.each(b.data.node,function(a,b){"renderer"===b.substr(0,8)&&"x"===b.charAt(b.length-1)&&(c=a),"renderer"===b.substr(0,8)&&"y"===b.charAt(b.length-1)&&(d=a),"renderer"===b.substr(0,8)&&"e"===b.charAt(b.length-1)&&(e=a)}),void 0===c&&void 0===d&&_.each(b.data.node,function(a,b){"read_cam"===b.substr(0,8)&&"x"===b.charAt(b.length-1)&&(c=a+$("#graph-container").width()/2),"read_cam"===b.substr(0,8)&&"y"===b.charAt(b.length-1)&&(d=a+$("#graph-container").height()/2)});var g=2.5*e;g<75&&(g=75),this.clearOldContextMenu();var h=function(a,b){var e=["#364C4A","#497C7F","#92C5C0","#858168","#CCBCA5"],h=wheelnav,i=new h("nodeContextMenu");i.maxPercent=1,i.wheelRadius=g,i.clockwise=!1,i.colors=e,i.multiSelect=!1,i.clickModeRotate=!1,i.sliceHoverAttr={stroke:"#fff","stroke-width":2},i.slicePathFunction=slicePath().DonutSlice,f.noDefinedGraph?i.createWheel(["imgsrc:img/gv_edit.png","imgsrc:img/gv_trash.png"]):i.createWheel(["imgsrc:img/gv_edit.png","imgsrc:img/gv_trash.png","imgsrc:img/gv_flag.png","imgsrc:img/gv_link.png","imgsrc:img/gv_expand.png"]),$("#nodeContextMenu").addClass("animated bounceIn"),window.setTimeout(function(){i.navItems[0].navigateFunction=function(a){f.clearOldContextMenu(),f.editNode(b),f.removeHelp()},i.navItems[1].navigateFunction=function(a){f.clearOldContextMenu(),f.deleteNodeModal(b),f.removeHelp()},f.noDefinedGraph||(i.navItems[2].navigateFunction=function(a){f.clearOldContextMenu(),f.setStartNode(b),f.removeHelp()},i.navItems[3].navigateFunction=function(a){f.contextState.createEdge=!0,f.contextState._from=b,f.contextState.fromX=c,f.contextState.fromY=d;var e=document.getElementsByClassName("sigma-mouse")[0];f.drawHelp("Now click destination node, or click background to cancel."),e.addEventListener("mousemove",f.drawLine.bind(this),!1),f.clearOldContextMenu(),f.removeHelp()},i.navItems[4].navigateFunction=function(a){f.clearOldContextMenu(),f.expandNode(b),f.removeHelp()});var a=["Edit the node.","Delete node."];f.noDefinedGraph||(a.push("Set as startnode."),a.push("Draw edge."),a.push("Expand the node.")),_.each(a,function(a,b){i.navItems[b].navTitle.mouseover(function(){f.drawHelp(a)}),i.navItems[b].navTitle.mouseout(function(){f.removeHelp()})}),i.navItems[0].selected=!1,i.navItems[0].hovered=!1},300)},i=$("#graph-container").offset();$("#nodeContextMenu").width(2*g),$("#nodeContextMenu").height(2*g),$("#nodeContextMenu").css("left",c+i.left-g),$("#nodeContextMenu").css("top",d+i.top-g),h(b,a)},drawHelp:function(a){null===document.getElementById("helpTooltip")?$(this.el).append('
'+a+"
"):$("#helpTooltip span").text(a),$("#helpTooltip").show()},removeHelp:function(){$("#helpTooltip").remove()},clearMouseCanvas:function(){var a=document.getElementsByClassName("sigma-mouse")[0],b=a.getContext("2d");b.clearRect(0,0,$(a).width(),$(a).height())},expandNode:function(a){var b=this,c={};this.graphConfig&&(c=_.clone(this.graphConfig),delete c.layout,delete c.edgeType,delete c.renderer),c.query='FOR v, e, p IN 1..1 ANY "'+a+'" GRAPH "'+b.name+'" RETURN p',$.ajax({type:"GET",url:arangoHelper.databaseUrl("/_admin/aardvark/graph/"+encodeURIComponent(this.name)),contentType:"application/json",data:c,success:function(c){b.checkExpand(c,a)},error:function(b){arangoHelper.arangoError("Graph","Could not expand node: "+a+".")}}),b.removeHelp()},checkExpand:function(a,b){var c,d=this,e=a.nodes,f=a.edges,g=this.currentGraph.graph.nodes(),h=0,i=0;_.each(e,function(a){c=!1,_.each(g,function(d){c===!1&&(a.id===d.id?(d.id===b&&(d.label=d.label+" (expanded)"),c=!0):c=!1)}),c===!1&&(a.originalColor=a.color,d.currentGraph.graph.addNode(a),h++)}),_.each(f,function(a){void 0===d.currentGraph.graph.edges(a.id)&&(a.originalColor=a.color,d.currentGraph.graph.addEdge(a),i++)}),$("#nodesCount").text(parseInt($("#nodesCount").text(),10)+h),$("#edgesCount").text(parseInt($("#edgesCount").text(),10)+i),(h>0||i>0)&&("force"===d.algorithm?d.startLayout(!0,b):"fruchtermann"===d.algorithm?(sigma.layouts.fruchtermanReingold.start(d.currentGraph),d.currentGraph.refresh(),d.cameraToNode(b,1e3)):"noverlap"===d.algorithm&&d.startLayout(!0,b))},cameraToNode:function(a,b){var c=this;"string"==typeof a&&(a=c.currentGraph.graph.nodes(a));var d=function(a){sigma.misc.animation.camera(c.currentGraph.camera,{x:a.x,y:a.y},{duration:1e3})};b?window.setTimeout(function(){d(a)},b):d(a)},drawLine:function(a){var b=window.App.graphViewer.contextState;if(b.createEdge){var c=b.fromX,d=b.fromY,e=a.offsetX,f=a.offsetY,g=document.getElementsByClassName("sigma-mouse")[0],h=g.getContext("2d");h.clearRect(0,0,$(g).width(),$(g).height()),h.beginPath(),h.moveTo(c,d),h.lineTo(e,f),h.strokeStyle=this.newEdgeColor,h.stroke()}},getGraphSettings:function(a){var b=this;this.userConfig.fetch({success:function(c){var d=frontendConfig.db+"_"+b.name;b.graphConfig=c.toJSON().graphs[d],b.graphSettingsView&&b.graphSettingsView.remove(),b.graphSettingsView=new window.GraphSettingsView({name:b.name,userConfig:b.userConfig,saveCallback:b.render});var e=function(){b.graphSettingsView.render(),a&&a(b.graphConfig)};void 0===b.graphConfig?(b.graphSettingsView.setDefaults(!0,!0),b.userConfig.fetch({success:function(a){b.graphConfig=a.toJSON().graphs[d],e()}})):e()}})},setStartNode:function(a){this.graphConfig.nodeStart=a,this.graphSettingsView.saveGraphSettings(void 0,void 0,a)},editNode:function(a){var b=function(a,b){};arangoHelper.openDocEditor(a,"doc",b)},editEdge:function(a){var b=function(){};arangoHelper.openDocEditor(a,"edge",b)},reloadGraph:function(){Backbone.history.loadUrl(Backbone.history.fragment)},getEdgeDefinitionCollections:function(a,b){var c=[];return _.each(this.model.edgeDefinitions,function(d){_.each(d.from,function(e){e===a&&_.each(d.to,function(a){a===b&&c.push(d.collection)})})}),c},initializeGraph:function(a,b){a.refresh()},renderGraph:function(a,b,c,d,e,f){var g=this;this.graphSettings=a.settings;var h="#2ecc71";if(g.ncolor&&(h=g.ncolor),a.edges&&a.nodes){0===a.nodes.length&&0===a.edges.length&&a.nodes.push({id:a.settings.startVertex._id,label:a.settings.startVertex._key,size:10,color:h,x:Math.random(),y:Math.random()});var i="position: absolute; left: 25px; bottom: 50px;";this.aqlMode||$("#graph-container").append('
'+a.nodes.length+' nodes'+a.edges.length+" edges
")}this.Sigma=sigma,d?g.algorithm=d:g.algorithm="force",e?g.renderer=e:g.renderer="canvas",this.graphConfig&&(this.graphConfig.layout&&(d||(g.algorithm=this.graphConfig.layout)),this.graphConfig.renderer&&(e||(g.renderer=this.graphConfig.renderer))),"canvas"===g.renderer&&(g.isEditable=!0);var j={scalingMode:"inside",borderSize:3,defaultNodeBorderColor:"#8c8c8c",doubleClickEnabled:!1,minNodeSize:5,labelThreshold:9,maxNodeSize:15,batchEdgesDrawing:!0,minEdgeSize:1,maxEdgeSize:1,enableEdgeHovering:!0,edgeHoverColor:"#8c8c8c",defaultEdgeHoverColor:"#8c8c8c",defaultEdgeType:"arrow",edgeHoverSizeRatio:2.5,edgeHoverExtremities:!0,nodesPowRatio:.5,autoRescale:!0,mouseEnabled:!0,touchEnabled:!0,approximateLabelWidth:!0,font:"Roboto"};j.nodeHaloColor="rgba(146,197,192, 0.8)",j.nodeHaloStroke=!1,j.nodeHaloStrokeColor="#000",j.nodeHaloStrokeWidth=0,j.nodeHaloSize=25,j.nodeHaloClustering=!1,j.nodeHaloClusteringMaxRadius=1e3,j.edgeHaloColor="#fff",j.edgeHaloSize=10,j.drawHalo=!0,"canvas"===g.renderer&&(j.autoCurveSortByDirection=!0),a.nodes&&a.nodes.length>250&&(j.hideEdgesOnMove=!0),this.graphConfig&&this.graphConfig.edgeType&&(j.defaultEdgeType=this.graphConfig.edgeType),f&&(j.defaultEdgeType=f),"arrow"===j.defaultEdgeType&&(j.minArrowSize=7),c&&(g.renderer="canvas",a.nodes.length<500?g.algorithm="fruchtermann":j.scalingMode="outside",j.drawEdgeLabels=!1,j.minNodeSize=2,j.maxNodeSize=8),"webgl"===g.renderer&&(j.enableEdgeHovering=!1);var k=new this.Sigma({graph:a,container:"graph-container",renderer:{container:document.getElementById("graph-container"),type:g.renderer},settings:j});if(this.currentGraph=k,this.aqlMode||sigma.plugins.fullScreen({container:"graph-container",btnId:"graph-fullscreen-btn"}),k.graph.nodes().forEach(function(a){a.originalColor=a.color}),k.graph.edges().forEach(function(a){a.originalColor=a.color}),"noverlap"===g.algorithm){var l=k.configNoverlap({nodeMargin:.1,scaleNodes:1.05,gridSize:75,easing:"quadraticInOut",duration:1500});l.bind("start stop interpolate",function(a){"start"===a.type,"interpolate"===a.type})}else if("fruchtermann"===g.algorithm){var m=sigma.layouts.fruchtermanReingold.configure(k,{iterations:100,easing:"quadraticInOut",duration:1500});m.bind("start stop interpolate",function(a){})}if(!g.aqlMode){var n=function(a,b){if($(".nodeInfoDiv").remove(),g.contextState.createEdge===!1&&window.location.hash.indexOf("graph")>-1){var c=function(a,b,c){if(a)g.currentGraph.graph.dropNode(c),g.currentGraph.refresh();else{var d="";d+='ID '+b.documents[0]._id+"",Object.keys(b.documents[0]).length>3&&(d+='ATTRIBUTES '),_.each(b.documents[0],function(a,b){"_key"!==b&&"_id"!==b&&"_rev"!==b&&"_from"!==b&&"_to"!==b&&(d+=''+b+"")});var e='";$("#graph-container").append(e),g.isFullscreen&&($(".nodeInfoDiv").css("top","10px"),$(".nodeInfoDiv").css("left","10px")),$("#nodeInfoDiv").fadeIn("slow")}};b?g.documentStore.getDocument(a.data.node.id.split("/")[0],a.data.node.id.split("/")[1],c):g.documentStore.getDocument(a.data.edge.id.split("/")[0],a.data.edge.id.split("/")[1],c)}};k.bind("clickNode",function(a){if(g.contextState.createEdge===!0){g.clearMouseCanvas(),g.removeHelp(),g.contextState._to=a.data.node.id;var b=g.contextState._from.split("/")[0],c=g.contextState._to.split("/")[0],d=g.getEdgeDefinitionCollections(b,c);0===d.length?arangoHelper.arangoNotification("Graph","No valid edge definition found."):(g.addEdgeModal(d,g.contextState._from,g.contextState._to),g.clearOldContextMenu(!1))}else g.dragging||(g.contextState.createEdge===!0?g.newEdgeColor="#ff0000":g.newEdgeColor="#000000","canvas"===g.renderer&&g.currentGraph.renderers[0].halo({nodes:g.currentGraph.graph.nodes(),nodeHaloColor:"#DF0101",nodeHaloSize:100}),n(a,!0),g.activeNodes=[a.data.node],"canvas"===g.renderer&&k.renderers[0].halo({nodes:[a.data.node]}),g.createNodeContextMenu(a.data.node.id,a))}),g.noDefinedGraph?k.bind("clickStage",function(a){g.clearOldContextMenu(!0),g.clearMouseCanvas(),g.removeHelp()}):k.bind("clickStage",function(a){a.data.captor.isDragging?(g.clearOldContextMenu(!0),g.clearMouseCanvas()):g.contextState.createEdge===!0?(g.clearOldContextMenu(!0),g.clearMouseCanvas(),g.removeHelp()):($("#nodeContextMenu").is(":visible")?(g.clearOldContextMenu(!0),g.clearMouseCanvas()):(g.addNodeX=a.data.captor.x,g.addNodeY=a.data.captor.y,g.createContextMenu(a),g.clearMouseCanvas()),k.renderers[0].halo({nodes:g.activeNodes}))})}if("canvas"===g.renderer){this.graphConfig&&"curve"===this.graphConfig.edgeType&&sigma.canvas.edges.autoCurve(k),k.bind("clickEdge",function(a){n(a,!1)}),k.renderers[0].bind("render",function(a){k.renderers[0].halo({nodes:g.activeNodes})});var o=function(){g.nodeHighlighted=!1,g.activeNodes=[],k.graph.nodes().forEach(function(a){a.color=a.originalColor}),k.graph.edges().forEach(function(a){a.color=a.originalColor}),$(".nodeInfoDiv").remove(),k.refresh({skipIndexation:!0})};k.bind("rightClickStage",function(a){g.nodeHighlighted="undefinedid",o()}),k.bind("rightClickNode",function(a){if(g.nodeHighlighted!==a.data.node.id){var b=a.data.node.id,c=k.graph.neighbors(b);c[b]=a.data.node,k.graph.nodes().forEach(function(a){c[a.id]?a.color=a.originalColor:a.color="#eee"}),k.graph.edges().forEach(function(a){c[a.source]&&c[a.target]?a.color="rgb(64, 74, 83)":a.color="#eee"}),g.nodeHighlighted=!0,k.refresh({skipIndexation:!0})}else o()}),this.graphConfig&&this.graphConfig.edgeEditable&&k.bind("clickEdge",function(a){var b=a.data.edge.id;g.createEdgeContextMenu(b,a)})}if("noverlap"===g.algorithm)k.startNoverlap();else if("force"===g.algorithm){var p="color: rgb(64, 74, 83); cursor: pointer; position: absolute; right: 30px; bottom: 40px; z-index: 9999;";g.aqlMode&&(p="color: rgb(64, 74, 83); cursor: pointer; position: absolute; right: 30px; margin-top: 10px; margin-right: -15px"),$("#graph-container").after('
Stop layout
'),g.startLayout();var q=250,r=500;a.nodes&&(q=a.nodes.length,c?q<250?q=250:q+=r:(q<=250&&(q=500),q+=r)),a.empty&&arangoHelper.arangoNotification("Graph","Your graph is empty. Click inside the white window to create your first node."),window.setTimeout(function(){g.stopLayout()},q)}else"fruchtermann"===g.algorithm&&sigma.layouts.fruchtermanReingold.start(k);"force"!==g.algorithm&&g.reInitDragListener();var s=document.getElementsByClassName("sigma-mouse")[0];s.addEventListener("mousemove",g.trackCursorPosition.bind(this),!1),b&&($("#"+b).focus(),$("#graphSettingsContent").animate({scrollTop:$("#"+b).offset().top},2e3)),$("#calculatingGraph").fadeOut("slow"),c||g.graphConfig&&"false"===g.graphConfig.nodeSizeByEdges,g.calcFinished=new Date,a.empty===!0&&$(".sigma-background").before('The graph is empty. Please right-click to add a node.'),g.graphNotInitialized===!0&&(g.updateColors(g.tmpGraphArray),g.graphNotInitialized=!1,g.tmpGraphArray=[]),"force"===g.algorithm?$("#toggleForce").fadeIn("fast"):$("#toggleForce").fadeOut("fast")},reInitDragListener:function(){var a=this;void 0!==this.dragListener&&(sigma.plugins.killDragNodes(this.currentGraph),this.dragListener={}),this.dragListener=sigma.plugins.dragNodes(this.currentGraph,this.currentGraph.renderers[0]),this.dragListener.bind("drag",function(b){a.dragging=!0}),this.dragListener.bind("drop",function(b){window.setTimeout(function(){a.dragging=!1},400)})},keyUpFunction:function(a){var b=this;switch(a.keyCode){case 76:a.altKey&&b.toggleLasso()}},toggleLayout:function(){this.layouting?this.stopLayout():this.startLayout()},startLayout:function(a,b){var c=this;this.currentGraph.settings("drawLabels",!1),this.currentGraph.settings("drawEdgeLabels",!1),sigma.plugins.killDragNodes(this.currentGraph),a===!0&&(this.currentGraph.killForceAtlas2(),window.setTimeout(function(){c.stopLayout(),b&&c.currentGraph.refresh({skipIndexation:!0})},500)),$("#toggleForce .fa").removeClass("fa-play").addClass("fa-pause"),$("#toggleForce span").html("Stop layout"),this.layouting=!0,this.aqlMode?this.currentGraph.startForceAtlas2({worker:!0}):this.currentGraph.startForceAtlas2({worker:!0})},stopLayout:function(){$("#toggleForce .fa").removeClass("fa-pause").addClass("fa-play"),$("#toggleForce span").html("Resume layout"),this.layouting=!1,this.currentGraph.stopForceAtlas2(),this.currentGraph.settings("drawLabels",!0),this.currentGraph.settings("drawEdgeLabels",!0),this.currentGraph.refresh({skipIndexation:!0}),this.reInitDragListener()}})}(),function(){"use strict";window.HelpUsView=Backbone.View.extend({el:"#content",template:templateEngine.createTemplate("helpUsView.ejs"),render:function(){this.$el.html(this.template.render({}))}})}(),function(){"use strict";window.IndicesView=Backbone.View.extend({el:"#content",initialize:function(a){this.collectionName=a.collectionName,this.model=this.collection},template:templateEngine.createTemplate("indicesView.ejs"),events:{},render:function(){var a=this;$.ajax({type:"GET",cache:!1,url:arangoHelper.databaseUrl("/_api/engine"),contentType:"application/json",processData:!1,success:function(b){$(a.el).html(a.template.render({model:a.model,supported:b.supports.indexes})),a.breadcrumb(),window.arangoHelper.buildCollectionSubNav(a.collectionName,"Indexes"),a.getIndex(),arangoHelper.checkCollectionPermissions(a.collectionName,a.changeViewToReadOnly)},error:function(){arangoHelper.arangoNotification("Index","Could not fetch index information.")}})},changeViewToReadOnly:function(){$(".breadcrumb").html($(".breadcrumb").html()+" (read-only)"),$("#addIndex").addClass("disabled"),$("#addIndex").css("color","rgba(0,0,0,.5)"),$("#addIndex").css("cursor","not-allowed")},breadcrumb:function(){$("#subNavigationBar .breadcrumb").html("Collection: "+this.collectionName)},getIndex:function(){var a=function(a,b,c){a?window.arangoHelper.arangoError("Index",b.errorMessage):this.renderIndex(b,c)}.bind(this);this.model.getIndex(a)},createIndex:function(){var a,b,c,d,e=this,f=$("#newIndexType").val(),g={};switch(f){case"Geo":a=$("#newGeoFields").val();var h=e.checkboxToValue("#newGeoJson");g={type:"geo",fields:e.stringToArray(a),geoJson:h};break;case"Persistent":a=$("#newPersistentFields").val(),b=e.checkboxToValue("#newPersistentUnique"),c=e.checkboxToValue("#newPersistentSparse"),d=e.checkboxToValue("#newPersistentDeduplicate"),g={type:"persistent",fields:e.stringToArray(a),unique:b,sparse:c,deduplicate:d};break;case"Hash":a=$("#newHashFields").val(),b=e.checkboxToValue("#newHashUnique"),c=e.checkboxToValue("#newHashSparse"),d=e.checkboxToValue("#newHashDeduplicate"),g={type:"hash",fields:e.stringToArray(a),unique:b,sparse:c,deduplicate:d};break;case"Fulltext":a=$("#newFulltextFields").val();var i=parseInt($("#newFulltextMinLength").val(),10)||0;g={type:"fulltext",fields:e.stringToArray(a),minLength:i};break;case"Skiplist":a=$("#newSkiplistFields").val(),b=e.checkboxToValue("#newSkiplistUnique"),c=e.checkboxToValue("#newSkiplistSparse"),d=e.checkboxToValue("#newSkiplistDeduplicate"),g={type:"skiplist",fields:e.stringToArray(a),unique:b,sparse:c,deduplicate:d}}var j=function(a,b){if(a)if(b){var c=JSON.parse(b.responseText);arangoHelper.arangoError("Document error",c.errorMessage)}else arangoHelper.arangoError("Document error","Could not create index.");e.toggleNewIndexView(),e.render()};this.model.createIndex(g,j)},bindIndexEvents:function(){this.unbindIndexEvents();var a=this;$("#indexEditView #addIndex").bind("click",function(){a.toggleNewIndexView(),$("#cancelIndex").unbind("click"),$("#cancelIndex").bind("click",function(){a.toggleNewIndexView(),a.render()}),$("#createIndex").unbind("click"),$("#createIndex").bind("click",function(){a.createIndex()})}),$("#newIndexType").bind("change",function(){a.selectIndexType()}),$(".deleteIndex").bind("click",function(b){a.prepDeleteIndex(b)}),$("#infoTab a").bind("click",function(a){if($("#indexDeleteModal").remove(),"Indexes"!==$(a.currentTarget).html()||$(a.currentTarget).parent().hasClass("active")||($("#newIndexView").hide(),$("#indexEditView").show(),$("#indexHeaderContent #modal-dialog .modal-footer .button-danger").hide(),$("#indexHeaderContent #modal-dialog .modal-footer .button-success").hide(),$("#indexHeaderContent #modal-dialog .modal-footer .button-notification").hide()),"General"===$(a.currentTarget).html()&&!$(a.currentTarget).parent().hasClass("active")){$("#indexHeaderContent #modal-dialog .modal-footer .button-danger").show(),$("#indexHeaderContent #modal-dialog .modal-footer .button-success").show(),$("#indexHeaderContent #modal-dialog .modal-footer .button-notification").show();var b=$(".index-button-bar2")[0];$("#cancelIndex").is(":visible")&&($("#cancelIndex").detach().appendTo(b),$("#createIndex").detach().appendTo(b))}})},prepDeleteIndex:function(a){var b=this;this.lastTarget=a,this.lastId=$(this.lastTarget.currentTarget).parent().parent().first().children().first().text(),$("#content #modal-dialog .modal-footer").after(''),$("#indexHeaderContent #indexConfirmDelete").unbind("click"),$("#indexHeaderContent #indexConfirmDelete").bind("click",function(){$("#indexHeaderContent #indexDeleteModal").remove(),b.deleteIndex()}),$("#indexHeaderContent #indexAbortDelete").unbind("click"),$("#indexHeaderContent #indexAbortDelete").bind("click",function(){$("#indexHeaderContent #indexDeleteModal").remove()})},unbindIndexEvents:function(){$("#indexHeaderContent #indexEditView #addIndex").unbind("click"),$("#indexHeaderContent #newIndexType").unbind("change"),$("#indexHeaderContent #infoTab a").unbind("click"),$("#indexHeaderContent .deleteIndex").unbind("click")},deleteIndex:function(){var a=function(a){a?(arangoHelper.arangoError("Could not delete index"),$("tr th:contains('"+this.lastId+"')").parent().children().last().html(''),this.model.set("locked",!1)):a||void 0===a||($("tr th:contains('"+this.lastId+"')").parent().remove(),this.model.set("locked",!1))}.bind(this);this.model.set("locked",!0),this.model.deleteIndex(this.lastId,a),$("tr th:contains('"+this.lastId+"')").parent().children().last().html('')},renderIndex:function(a,b){this.index=a;var c=function(a,c){if(a)arangoHelper.arangoError("Jobs","Could not read pending jobs.");else{var d=function(a,b,c){a?404===b.responseJSON.code?arangoHelper.deleteAardvarkJob(c):400===b.responseJSON.code?(arangoHelper.arangoError("Index creation failed",b.responseJSON.errorMessage),arangoHelper.deleteAardvarkJob(c)):204===b.responseJSON.code&&arangoHelper.arangoMessage("Index","There is at least one new index in the queue or in the process of being created."):arangoHelper.deleteAardvarkJob(c)};_.each(c,function(a){a.collection===b&&$.ajax({type:"PUT",cache:!1,url:arangoHelper.databaseUrl("/_api/job/"+a.id),contentType:"application/json",success:function(b,c,e){d(!1,b,a.id)},error:function(b){d(!0,b,a.id)}})})}};arangoHelper.getAardvarkJobs(c);var d="collectionInfoTh modal-text";if(this.index){var e="",f="";_.each(this.index.indexes,function(a){f="primary"===a.type||"edge"===a.type?'':'',void 0!==a.fields&&(e=a.fields.join(", "));var b=a.id.indexOf("/"),c=a.id.substr(b+1,a.id.length),g=a.hasOwnProperty("selectivityEstimate")?(100*a.selectivityEstimate).toFixed(2)+"%":"n/a",h=a.hasOwnProperty("sparse")?a.sparse:"n/a",i=a.hasOwnProperty("deduplicate")?a.deduplicate:"n/a";$("#collectionEditIndexTable").append(""+c+""+a.type+""+a.unique+""+h+""+i+""+g+""+e+""+f+"")})}this.bindIndexEvents()},selectIndexType:function(){$(".newIndexClass").hide();var a=$("#newIndexType").val();null===a&&(a=$("#newIndexType").children().first().attr("value"),$("#newIndexType").val(a)),$("#newIndexType"+a).show()},resetIndexForms:function(){$("#indexHeader input").val("").prop("checked",!1),$("#newIndexType").val("unknown").prop("selected",!0),this.selectIndexType()},toggleNewIndexView:function(){if(!$("#addIndex").hasClass("disabled")){var a=$(".index-button-bar2")[0];$("#indexEditView").is(":visible")?($("#indexEditView").hide(),$("#newIndexView").show(),$("#cancelIndex").detach().appendTo("#indexHeaderContent #modal-dialog .modal-footer"),$("#createIndex").detach().appendTo("#indexHeaderContent #modal-dialog .modal-footer")):($("#indexEditView").show(),$("#newIndexView").hide(),$("#cancelIndex").detach().appendTo(a),$("#createIndex").detach().appendTo(a)),arangoHelper.createTooltips(".index-tooltip"),arangoHelper.fixTooltips(".icon_arangodb, .arangoicon","right"),this.resetIndexForms()}},stringToArray:function(a){var b=[];return a.split(",").forEach(function(a){a=a.replace(/(^\s+|\s+$)/g,""),""!==a&&b.push(a)}),b},checkboxToValue:function(a){return $(a).prop("checked")}})}(),function(){"use strict";window.InfoView=Backbone.View.extend({el:"#content",initialize:function(a){this.collectionName=a.collectionName,this.model=this.collection},events:{},render:function(){this.breadcrumb(),window.arangoHelper.buildCollectionSubNav(this.collectionName,"Info"),this.renderInfoView(),arangoHelper.checkCollectionPermissions(this.collectionName,this.changeViewToReadOnly)},changeViewToReadOnly:function(){$(".breadcrumb").html($(".breadcrumb").html()+" (read-only)")},breadcrumb:function(){$("#subNavigationBar .breadcrumb").html("Collection: "+this.collectionName)},renderInfoView:function(){if(this.model.get("locked"))return 0;var a=function(a,b,c){if(a)arangoHelper.arangoError("Figures","Could not get revision.");else{var d=[];frontendConfig.isCluster&&0===c.figures.alive.size&&0===c.figures.alive.count&&0===c.figures.datafiles.count&&0===c.figures.datafiles.fileSize&&0===c.figures.journals.count&&0===c.figures.journals.fileSize&&0===c.figures.compactors.count&&0===c.figures.compactors.fileSize&&0===c.figures.dead.size&&0===c.figures.dead.count&&(c.walMessage=" - not ready yet - ");var e={figures:c,revision:b,model:this.model};window.modalView.show("modalCollectionInfo.ejs","Collection: "+this.model.get("name"),d,e,null,null,null,null,null,"content")}}.bind(this),b=function(b,c){if(b)arangoHelper.arangoError("Figures","Could not get figures.");else{var d=c;this.model.getRevision(a,d)}}.bind(this);this.model.getFigures(b)}})}(),function(){"use strict";window.LoggerView=Backbone.View.extend({el:"#content",logsel:"#logEntries",id:"#logContent",initDone:!1,pageSize:20,currentPage:0,logTopics:{},logLevels:[],remove:function(){return this.$el.empty().off(),this.stopListening(),this.unbind(),delete this.el,this},initialize:function(a){var b=this;a&&(this.options=a),this.collection.setPageSize(this.pageSize),this.initDone||$.ajax({type:"GET",cache:!1,url:arangoHelper.databaseUrl("/_admin/log/level"),contentType:"application/json", -processData:!1,success:function(a){b.logTopics=a,_.each(["fatal","error","warning","info","debug"],function(a){b.logLevels.push(a)}),b.initDone=!0}})},currentLoglevel:void 0,defaultLoglevel:"info",events:{"click #logLevelSelection":"renderLogLevel","click #logTopicSelection":"renderLogTopic","click #logFilters":"resetFilters","click #loadMoreEntries":"loadMoreEntries"},template:templateEngine.createTemplate("loggerView.ejs"),templateEntries:templateEngine.createTemplate("loggerViewEntries.ejs"),renderLogTopic:function(a){var b=this;this.logTopicOptions||(this.logTopicOptions={});var c;_.each(this.logTopics,function(a,d){b.logTopicOptions[d]&&(c=b.logTopicOptions[d].active),b.logTopicOptions[d]={name:d,active:c||!1}});var d=$(a.currentTarget).position();d.right="30",this.logTopicView=new window.FilterSelectView({name:"Topic",options:b.logTopicOptions,position:d,callback:b.logTopicCallbackFunction.bind(this),multiple:!0}),this.logTopicView.render()},loadMoreEntries:function(){this.convertModelToJSON()},logTopicCallbackFunction:function(a){this.logTopicOptions=a,this.applyFilter()},logLevelCallbackFunction:function(a){this.logLevelOptions=a,this.applyFilter()},resetFilters:function(){_.each(this.logTopicOptions,function(a){a.active=!1}),_.each(this.logLevelOptions,function(a){a.active=!1}),this.applyFilter()},isFilterActive:function(a){var b=!1;return _.each(a,function(a){a.active&&(b=!0)}),b},changeButton:function(a){a?("level"===a?($("#logLevelSelection").addClass("button-success").removeClass("button-default"),$("#logTopicSelection").addClass("button-default").removeClass("button-success"),$("#filterDesc").html(a)):"topic"===a?($("#logTopicSelection").addClass("button-success").removeClass("button-default"),$("#logLevelSelection").addClass("button-default").removeClass("button-success"),$("#filterDesc").html(a)):"both"===a&&($("#logTopicSelection").addClass("button-success").removeClass("button-default"),$("#logLevelSelection").addClass("button-success").removeClass("button-default"),$("#filterDesc").html("level, topic")),$("#logFilters").show()):($("#logTopicSelection").addClass("button-default").removeClass("button-success"),$("#logLevelSelection").addClass("button-default").removeClass("button-success"),$("#logFilters").hide(),$("#filterDesc").html(""))},applyFilter:function(){var a=this,b=this.isFilterActive(this.logLevelOptions),c=this.isFilterActive(this.logTopicOptions);b&&c?(_.each($("#logEntries").children(),function(b){a.logLevelOptions[$(b).attr("level")].active===!1||a.logTopicOptions[$(b).attr("topic")].active===!1?$(b).hide():a.logLevelOptions[$(b).attr("level")].active&&a.logTopicOptions[$(b).attr("topic")].active&&$(b).show()}),this.changeButton("both")):b&&!c?(_.each($("#logEntries").children(),function(b){a.logLevelOptions[$(b).attr("level")].active===!1?$(b).hide():$(b).show()}),this.changeButton("level")):!b&&c?(_.each($("#logEntries").children(),function(b){a.logTopicOptions[$(b).attr("topic")].active===!1?$(b).hide():$(b).show()}),this.changeButton("topic")):b||c||(_.each($("#logEntries").children(),function(a){$(a).show()}),this.changeButton());var d=0;_.each($("#logEntries").children(),function(a){"block"===$(a).css("display")&&d++}),1===d?($(".logBorder").css("visibility","hidden"),$("#noLogEntries").hide()):0===d?$("#noLogEntries").show():($(".logBorder").css("visibility","visible"),$("#noLogEntries").hide())},renderLogLevel:function(a){var b=this;this.logLevelOptions||(this.logLevelOptions={});var c;_.each(this.logLevels,function(a){b.logLevelOptions[a]&&(c=b.logLevelOptions[a].active),b.logLevelOptions[a]={name:a,active:c||!1};var d=arangoHelper.statusColors[a];d&&(b.logLevelOptions[a].color=d)});var d=$(a.currentTarget).position();d.right="115",this.logLevelView=new window.FilterSelectView({name:"Level",options:b.logLevelOptions,position:d,callback:b.logLevelCallbackFunction.bind(this),multiple:!1}),this.logLevelView.render()},setActiveLoglevel:function(a){},initTotalAmount:function(){var a=this;this.collection.fetch({data:$.param({test:!0}),success:function(){a.convertModelToJSON()}}),this.fetchedAmount=!0},invertArray:function(a){var b,c=[],d=0;for(b=a.length-1;b>=0;b--)c[d]=a[b],d++;return c},convertModelToJSON:function(){if(!this.fetchedAmount)return void this.initTotalAmount();this.collection.page=this.currentPage,this.currentPage++;var a,b=this,c=[];this.collection.fetch({success:function(d){b.collection.each(function(b){a=new Date(1e3*b.get("timestamp")),c.push({status:b.getLogStatus(),date:arangoHelper.formatDT(a),timestamp:b.get("timestamp"),msg:b.get("text"),topic:b.get("topic")})}),b.renderLogs(b.invertArray(c),d.lastInverseOffset)}})},render:function(){var a=this;return this.currentPage=0,this.initDone?($(this.el).html(this.template.render({})),this.convertModelToJSON()):window.setTimeout(function(){a.render()},100),this},renderLogs:function(a,b){_.each(a,function(a){a.msg.indexOf("{"+a.topic+"}")>-1&&(a.msg=a.msg.replace("{"+a.topic+"}",""))}),0===this.currentPage?$(this.logsel).html(this.templateEntries.render({entries:a})):$(this.logsel).append(this.templateEntries.render({entries:a})),b<=0?$("#loadMoreEntries").attr("disabled",!0):$("#loadMoreEntries").attr("disabled",!1),arangoHelper.createTooltips(),this.applyFilter()}})}(),function(){"use strict";window.LoginView=Backbone.View.extend({el:"#content",el2:".header",el3:".footer",loggedIn:!1,loginCounter:0,events:{"keyPress #loginForm input":"keyPress","click #submitLogin":"validate","submit #dbForm":"goTo","click #logout":"logout","change #loginDatabase":"renderDBS"},template:templateEngine.createTemplate("loginView.ejs"),render:function(a){var b=this;$(this.el).html(this.template.render({})),$(this.el2).hide(),$(this.el3).hide();var c=function(a,c,d){var e;e=a?arangoHelper.databaseUrl("/_api/user/"+encodeURIComponent(a)+"/database","_system"):arangoHelper.databaseUrl("/_api/database/user"),frontendConfig.authenticationEnabled===!1&&($("#logout").hide(),$(".login-window #databases").css("height","90px")),$("#loginForm").hide(),$(".login-window #databases").show(),$.ajax(e).success(function(a){$("#loginDatabase").html(""),_.each(a.result,function(a,b){frontendConfig.authenticationEnabled?$("#loginDatabase").append(""):$("#loginDatabase").append("")}),b.renderDBS()}).error(function(){c?c():location.reload(!0)})};if(frontendConfig.authenticationEnabled&&a!==!0){var d=arangoHelper.getCurrentJwtUsername();if(null!==d&&"undefined"!==d&&void 0!==d){var e=function(){b.collection.logout(),window.setTimeout(function(){$("#loginUsername").focus()},300)};c(arangoHelper.getCurrentJwtUsername(),e)}else window.setTimeout(function(){$("#loginUsername").focus()},300)}else frontendConfig.authenticationEnabled&&a?c(arangoHelper.getCurrentJwtUsername(),null,4):c(null,null,3);return $(".bodyWrapper").show(),b.checkVersion(),this},checkVersion:function(){var a=this;window.setTimeout(function(){var b,c=document.getElementById("loginSVG"),d=c.contentDocument;void 0!==frontendConfig.isEnterprise?(b=frontendConfig.isEnterprise?d.getElementById("logo-enterprise"):d.getElementById("logo-community"),b.setAttribute("visibility","visible")):a.checkVersion()},150)},clear:function(){$("#loginForm input").removeClass("form-error"),$(".wrong-credentials").hide()},keyPress:function(a){a.ctrlKey&&13===a.keyCode?(a.preventDefault(),this.validate()):a.metaKey&&13===a.keyCode&&(a.preventDefault(),this.validate())},validate:function(a){a.preventDefault(),this.clear();var b=$("#loginUsername").val(),c=$("#loginPassword").val();b&&this.collection.login(b,c,this.loginCallback.bind(this,b,c))},loginCallback:function(a,b,c){var d=this;if(c){if(0===d.loginCounter)return d.loginCounter++,void d.collection.login(a,b,this.loginCallback.bind(this,a));d.loginCounter=0,$(".wrong-credentials").show(),$("#loginDatabase").html(""),$("#loginDatabase").append("")}else d.renderDBSelection(a)},renderDBSelection:function(a){var b=this,c=arangoHelper.databaseUrl("/_api/user/"+encodeURIComponent(a)+"/database","_system");frontendConfig.authenticationEnabled===!1&&(c=arangoHelper.databaseUrl("/_api/database/user")),$(".wrong-credentials").hide(),b.loggedIn=!0,$.ajax(c).success(function(a){$("#loginForm").hide(),$(".login-window #databases").show(),$("#loginDatabase").html(""),_.each(a.result,function(a,b){frontendConfig.authenticationEnabled?$("#loginDatabase").append(""):$("#loginDatabase").append("")}),b.renderDBS()}).error(function(){$(".wrong-credentials").show()})},renderDBS:function(){if(0===$("#loginDatabase").children().length)$("#dbForm").remove(),$(".login-window #databases").prepend('
You do not have permission to a database.
');else{var a=$("#loginDatabase").val();$("#goToDatabase").html("Select DB: "+a),window.setTimeout(function(){$("#goToDatabase").focus()},300)}},logout:function(){this.collection.logout()},goTo:function(a){a.preventDefault();var b=$("#loginUsername").val(),c=$("#loginDatabase").val();window.App.dbSet=c;var d=function(a){a&&arangoHelper.arangoError("User","Could not fetch user settings")},e=window.location.protocol+"//"+window.location.host+frontendConfig.basePath+"/_db/"+c+"/_admin/aardvark/index.html";window.location.href=e,$(this.el2).show(),$(this.el3).show(),$(".bodyWrapper").show(),$(".navbar").show(),$("#currentUser").text(b),this.collection.loadUserSettings(d)}})}(),function(){"use strict";var a=function(a,b,c,d){return{type:a,title:b,callback:c,confirm:d}},b=function(a,b,c,d,e,f,g,h,i,j,k){var l={type:a,label:b};return void 0!==c&&(l.value=c),void 0!==d&&(l.info=d),void 0!==e&&(l.placeholder=e),void 0!==f&&(l.mandatory=f),void 0!==h&&(l.addDelete=h),void 0!==i&&(l.addAdd=i),void 0!==j&&(l.maxEntrySize=j),void 0!==k&&(l.tags=k),g&&(l.validateInput=function(){return g}),l};window.ModalView=Backbone.View.extend({_validators:[],_validateWatchers:[],baseTemplate:templateEngine.createTemplate("modalBase.ejs"),tableTemplate:templateEngine.createTemplate("modalTable.ejs"),el:"#modalPlaceholder",contentEl:"#modalContent",hideFooter:!1,confirm:{list:"#modal-delete-confirmation",yes:"#modal-confirm-delete",no:"#modal-abort-delete"},enabledHotkey:!1,enableHotKeys:!0,buttons:{SUCCESS:"success",NOTIFICATION:"notification",DELETE:"danger",NEUTRAL:"neutral",DISABLED:"disabled",CLOSE:"close"},tables:{READONLY:"readonly",TEXT:"text",BLOB:"blob",PASSWORD:"password",SELECT:"select",SELECT2:"select2",CHECKBOX:"checkbox"},initialize:function(){Object.freeze(this.buttons),Object.freeze(this.tables)},createModalHotkeys:function(){$(this.el).unbind("keydown"),$(this.el).unbind("return"),$(".modal-body input").unbind("keydown"),$(".modal-body input").unbind("return"),$(".modal-body input",$(this.el)).bind("keydown","return",function(){$(".createModalDialog .modal-footer .button-success").click()}),$(".modal-body select").unbind("keydown"),$(".modal-body select").unbind("return"),$(".modal-body select",$(this.el)).bind("keydown","return",function(){$(".createModalDialog .modal-footer .button-success").click()})},createInitModalHotkeys:function(){var a=this;$(this.el).bind("keydown","left",function(){a.navigateThroughButtons("left")}),$(this.el).bind("keydown","right",function(){a.navigateThroughButtons("right")})},navigateThroughButtons:function(a){var b=$(".createModalDialog .modal-footer button").is(":focus");b===!1?"left"===a?$(".createModalDialog .modal-footer button").first().focus():"right"===a&&$(".createModalDialog .modal-footer button").last().focus():b===!0&&("left"===a?$(":focus").prev().focus():"right"===a&&$(":focus").next().focus())},createCloseButton:function(b,c){var d=this;return a(this.buttons.CLOSE,b,function(){d.hide(),c&&c()})},createSuccessButton:function(b,c){return a(this.buttons.SUCCESS,b,c)},createNotificationButton:function(b,c){return a(this.buttons.NOTIFICATION,b,c)},createDeleteButton:function(b,c,d){return a(this.buttons.DELETE,b,c,d)},createNeutralButton:function(b,c){return a(this.buttons.NEUTRAL,b,c)},createDisabledButton:function(b){var c=a(this.buttons.DISABLED,b);return c.disabled=!0,c},createReadOnlyEntry:function(a,c,d,e,f,g){var h=b(this.tables.READONLY,c,d,e,void 0,void 0,void 0,f,g);return h.id=a,h},createTextEntry:function(a,c,d,e,f,g,h){var i=b(this.tables.TEXT,c,d,e,f,g,h);return i.id=a,i},createBlobEntry:function(a,c,d,e,f,g,h){var i=b(this.tables.BLOB,c,d,e,f,g,h);return i.id=a,i},createSelect2Entry:function(a,c,d,e,f,g,h,i,j,k){var l=b(this.tables.SELECT2,c,d,e,f,g,void 0,h,i,j,k);return l.id=a,l},createPasswordEntry:function(a,c,d,e,f,g,h){var i=b(this.tables.PASSWORD,c,d,e,f,g,h);return i.id=a,i},createCheckboxEntry:function(a,c,d,e,f){var g=b(this.tables.CHECKBOX,c,d,e);return g.id=a,f&&(g.checked=f),d&&(g.checked=d),g},createSelectEntry:function(a,c,d,e,f){var g=b(this.tables.SELECT,c,null,e);return g.id=a,d&&(g.selected=d),g.options=f,g},createOptionEntry:function(a,b){return{label:a,value:b||a}},show:function(a,b,c,d,e,f,g,h,i,j){var k,l,m=this,n=!1;c=c||[],h=Boolean(h),this.clearValidators(),c.length>0?(c.forEach(function(a){a.type===m.buttons.CLOSE&&(n=!0),a.type===m.buttons.DELETE&&(l=l||a.confirm)}),n||(k=c.pop(),c.push(m.createCloseButton("Cancel")),c.push(k))):c.push(m.createCloseButton("Close")),j?($("#"+j).html(this.baseTemplate.render({title:b,buttons:c,hideFooter:this.hideFooter,confirm:l,tabBar:i})),$("#"+j+" #modal-dialog").removeClass("fade hide modal"),$("#"+j+" .modal-header").remove(),$("#"+j+" .modal-tabbar").remove(),$("#"+j+" .modal-tabbar").remove(),$("#"+j+" .button-close").remove(),0===$("#"+j+" .modal-footer").children().length&&$("#"+j+" .modal-footer").remove()):$(this.el).html(this.baseTemplate.render({title:b,buttons:c,hideFooter:this.hideFooter,confirm:l,tabBar:i})),_.each(c,function(a,b){if(a.disabled||"disabled"===a.type||!a.callback)return void(j?$("#"+j+" #modalButton"+b).attr("disabled",!0):$("#modalButton"+b).attr("disabled",!0));if(a.type===m.buttons.DELETE&&!h){var c="#modalButton"+b;return j&&(c="#"+j+" #modalButton"+b),void $(c).bind("click",function(){j?($("#"+j+" "+m.confirm.yes).unbind("click"),$("#"+j+" "+m.confirm.yes).bind("click",a.callback),$("#"+j+" "+m.confirm.list).css("display","block")):($(m.confirm.yes).unbind("click"),$(m.confirm.yes).bind("click",a.callback),$(m.confirm.list).css("display","block"))})}j?$("#"+j+" #modalButton"+b).bind("click",a.callback):$("#modalButton"+b).bind("click",a.callback)}),j?$("#"+j+" "+this.confirm.no).bind("click",function(){$("#"+j+" "+m.confirm.list).css("display","none")}):$(this.confirm.no).bind("click",function(){$(m.confirm.list).css("display","none")});var o;if("string"==typeof a)o=templateEngine.createTemplate(a),j?$("#"+j+" .createModalDialog .modal-body").html(o.render({content:d,advancedContent:e,info:f})):$("#modalPlaceholder .createModalDialog .modal-body").html(o.render({content:d,advancedContent:e,info:f}));else{var p=0;_.each(a,function(a){o=templateEngine.createTemplate(a),$(".createModalDialog .modal-body .tab-content #"+i[p]).html(o.render({content:d,advancedContent:e,info:f})),p++})}arangoHelper.createTooltips(".createModalDialog .modalTooltips","left");var q=d||[];e&&e.content&&(q=q.concat(e.content)),_.each(q,function(a){if(m.modalBindValidation(a),a.type===m.tables.SELECT2){var b={tags:a.tags||[],showSearchBox:!1,minimumResultsForSearch:-1,width:"336px"};a.maxEntrySize&&(b.maximumSelectionSize=a.maxEntrySize),$("#"+a.id).select2(b)}}),g&&(this.events=g,this.delegateEvents()),$("#accordion2")&&($("#accordion2 .accordion-toggle").bind("click",function(){$("#collapseOne").is(":visible")?($("#collapseOne").hide(),setTimeout(function(){$(".accordion-toggle").addClass("collapsed")},100)):($("#collapseOne").show(),setTimeout(function(){$(".accordion-toggle").removeClass("collapsed")},100))}),$("#collapseOne").hide(),setTimeout(function(){$(".accordion-toggle").addClass("collapsed")},100)),j||$("#modal-dialog").modal("show"),this.enabledHotkey===!1&&(this.createInitModalHotkeys(),this.enabledHotkey=!0),this.enableHotKeys&&this.createModalHotkeys();var r;r=j?$("#"+j+" #modal-dialog").find("input"):$("#modal-dialog").find("input"),r&&setTimeout(function(){r=j?$("#"+j+" #modal-dialog"):$("#modal-dialog"),r.length>0&&(r=r.find("input"),r.length>0&&$(r[0]).focus())},400)},modalBindValidation:function(a){var b=this;if(a.hasOwnProperty("id")&&a.hasOwnProperty("validateInput")){var c=function(){var b=$("#"+a.id),c=a.validateInput(b),d=!1;if(_.each(c,function(a){var c=b.val();if(a.rule||(a={rule:a}),"function"==typeof a.rule)try{a.rule(c)}catch(e){d=a.msg||e.message}else{var f=Joi.validate(c,a.rule);f.error&&(d=a.msg||f.error.message)}if(d)return!1}),d)return d},d=$("#"+a.id);d.on("keyup focusout",function(){var a=c(),e=d.next()[0];a?(d.addClass("invalid-input"),e?$(e).text(a):d.after('

'+a+"

"),$(".createModalDialog .modal-footer .button-success").prop("disabled",!0).addClass("disabled")):(d.removeClass("invalid-input"),e&&$(e).remove(),b.modalTestAll())}),this._validators.push(c),this._validateWatchers.push(d)}},modalTestAll:function(){var a=_.map(this._validators,function(a){return a()}),b=_.any(a);return b?$(".createModalDialog .modal-footer .button-success").prop("disabled",!0).addClass("disabled"):$(".createModalDialog .modal-footer .button-success").prop("disabled",!1).removeClass("disabled"),!b},clearValidators:function(){this._validators=[],_.each(this._validateWatchers,function(a){a.unbind("keyup focusout")}),this._validateWatchers=[]},hide:function(){this.clearValidators(),$("#modal-dialog").modal("hide")}})}(),function(){"use strict";window.NavigationView=Backbone.View.extend({el:"#navigationBar",subEl:"#subNavigationBar",events:{"change #arangoCollectionSelect":"navigateBySelect","click .tab":"navigateByTab","click li":"switchTab","click .arangodbLogo":"selectMenuItem","mouseenter .dropdown > *":"showDropdown","click .shortcut-icons p":"showShortcutModal","mouseleave .dropdown":"hideDropdown"},renderFirst:!0,activeSubMenu:void 0,changeDB:function(){window.location.hash="#login"},initialize:function(a){var b=this;this.userCollection=a.userCollection,this.currentDB=a.currentDB,this.dbSelectionView=new window.DBSelectionView({collection:a.database,current:this.currentDB}),this.userBarView=new window.UserBarView({userCollection:this.userCollection}),this.notificationView=new window.NotificationView({collection:a.notificationCollection}),this.statisticBarView=new window.StatisticBarView({currentDB:this.currentDB}),this.isCluster=a.isCluster,this.handleKeyboardHotkeys(),Backbone.history.on("all",function(){b.selectMenuItem()})},showShortcutModal:function(){arangoHelper.hotkeysFunctions.showHotkeysModal()},handleSelectDatabase:function(){this.dbSelectionView.render($("#dbSelect"))},template:templateEngine.createTemplate("navigationView.ejs"),templateSub:templateEngine.createTemplate("subNavigationView.ejs"),render:function(){var a=this;$(this.el).html(this.template.render({currentDB:this.currentDB,isCluster:this.isCluster})),"_system"!==this.currentDB.get("name")&&$("#dashboard").parent().remove(),$(this.subEl).html(this.templateSub.render({currentDB:this.currentDB.toJSON()})),this.dbSelectionView.render($("#dbSelect"));var b=function(a){a||this.userBarView.render()}.bind(this);return this.userCollection.whoAmI(b),this.renderFirst&&(this.renderFirst=!1,this.selectMenuItem(),$(".arangodbLogo").on("click",function(){a.selectMenuItem()}),$("#dbStatus").on("click",function(){a.changeDB()})),a.resize(),window.frontendConfig.isEnterprise===!0?($("#ArangoDBLogo").after(''),$("#enterpriseLabel").fadeIn("slow")):($("#ArangoDBLogo").after(''),$("#communityLabel").fadeIn("slow"),$(".enterprise-menu").show()),this},resize:function(){var a=$(window).height()-$(".subMenuEntries").first().height();$("#navigationBar").css("min-height",a),$("#navigationBar").css("height",a)},navigateBySelect:function(){var a=$("#arangoCollectionSelect").find("option:selected").val();window.App.navigate(a,{trigger:!0})},handleKeyboardHotkeys:function(){arangoHelper.enableKeyboardHotkeys(!0)},navigateByTab:function(a){var b=a.target||a.srcElement,c=b.id,d=!1;"enterprise"!==c&&($(b).hasClass("fa")||(""===c&&(c=$(b).attr("class")),"links"===c?(d=!0,$("#link_dropdown").slideToggle(1),a.preventDefault()):"tools"===c?(d=!0,$("#tools_dropdown").slideToggle(1),a.preventDefault()):"dbselection"===c&&(d=!0,$("#dbs_dropdown").slideToggle(1),a.preventDefault()),d||(window.App.navigate(c,{trigger:!0}),a.preventDefault())))},handleSelectNavigation:function(){var a=this;$("#arangoCollectionSelect").change(function(){a.navigateBySelect()})},subViewConfig:{documents:"collections",collection:"collections"},subMenuConfig:{cluster:[{name:"Dashboard",view:void 0,active:!0},{name:"Logs",view:void 0,disabled:!0}],collections:[{name:"",view:void 0,active:!1}],queries:[{name:"Editor",route:"query",active:!0},{name:"Running Queries",route:"queryManagement",params:{active:!0},active:void 0},{name:"Slow Query History",route:"queryManagement",params:{active:!1},active:void 0}]},renderSubMenu:function(a){var b=this;if(void 0===a&&(a=window.isCluster?"cluster":"dashboard"),this.subMenuConfig[a]){$(this.subEl+" .bottom").html("");var c="";_.each(this.subMenuConfig[a],function(a){c=a.active?"active":"",a.disabled&&(c="disabled"),$(b.subEl+" .bottom").append('"),a.disabled||$(b.subEl+" .bottom").children().last().bind("click",function(c){$("#subNavigationBar .breadcrumb").html(""),b.activeSubMenu=a,b.renderSubView(a,c)})})}else $(b.subEl+" .bottom").append('
');var e=$(c+" .queryProfile").first();e.hide(),e.css("position","absolute").css("left",215).css("top",55);var f=590,g=["A","B","C","D","E","F","G","H"],h=["rgb(48, 125, 153)","rgb(241, 124, 176)","rgb(137, 110, 37)","rgb(93, 165, 218)","rgb(250, 164, 58)","rgb(64, 74, 83)","rgb(96, 189, 104)","rgb(221, 224, 114)"],i=["startup time for query engine","query parsing","abstract syntax tree optimizations","loading collections","instanciation of initial execution plan","execution plan optimization and permutation","query execution","query finalization"];e.append('Profiling information
');var j=0;_.each(b,function(a,b){"finished"!==b&&(j+=1e3*a)});var k,l=0,m=0,n="";_.each(b,function(a,b){"finished"!==b&&(a>1?(n=numeral(a).format("0.000"),n+=" s"):(n=numeral(1e3*a).format("0.000"),n+=" ms"),e.find(".pure-g").append('

'+g[l]+'

'+n+'
'+b+'
'+i[l]+"
"),k=Math.floor(1e3*a/j*100),0===k&&(k=1,m++),7!==l?(e.find(".prof-progress").append('
'),k>1?e.find(".prof-progress-label").append('
'+g[l]+"
"):e.find(".prof-progress-label").append('
'+g[l]+"
")):(m>0&&(k-=m),e.find(".prof-progress").append('
'),k>1?e.find(".prof-progress-label").append('
'+g[l]+"
"):e.find(".prof-progress-label").append('
'+g[l]+"
")),l++)}),e.width(f),e.height("auto"),e.fadeIn("fast")}})},analyseQuery:function(a){var b={defaultType:null,original:a,modified:null},c=!1;if(!Array.isArray(a))return b.defaultType="json",b;if(a[0])if(a[0].vertices&&a[0].edges){var d=0,e=0;_.each(a,function(a){a.edges&&_.each(a.edges,function(a){null!==a&&(a._from&&a._to&&d++,e++)})});var f=0;e>0&&(f=d/e*100),f>=95&&(c=!0,b.defaultType="graph",b.graphInfo="object")}else{var g=0,h=a.length;_.each(a,function(a){a&&a._from&&a._to&&a._id&&g++});var i=0;h>0&&(i=g/h*100),i>=95&&(c=!0,b.defaultType="graph",b.graphInfo="array")}if(!c){var j=!0,k={};if(a.length<=1&&(j=!1),j){_.each(a,function(a){"object"!=typeof a||null===a||Array.isArray(a)||_.each(a,function(a,b){k.hasOwnProperty(b)?++k[b]:k[b]=1})});var l=0;_.each(k,function(b,c){j!==!1&&(l=b/a.length*100,l<=95&&(j=!1))}),l<=95&&(j=!1)}j&&(c=!0,b.defaultType="table")}return c||(b.defaultType="json"),b},markPositionError:function(a,b){var c;b&&(c=b.split(":")[0],a=a.substr(1,a.length-2));var d=this.aqlEditor.find(a);!d&&b&&(this.aqlEditor.selection.moveCursorToPosition({row:c,column:0}),this.aqlEditor.selection.selectLine()),window.setTimeout(function(){$(".ace_start").first().css("background","rgba(255, 129, 129, 0.7)")},100)},refreshAQL:function(){var a=this,b=function(b){b?arangoHelper.arangoError("Query","Could not reload queries"):(a.updateLocalQueries(),a.updateQueryTable())},c=function(){a.getSystemQueries(b)};this.getAQL(c)},getSystemQueries:function(a){var b=this;$.ajax({type:"GET",cache:!1,url:"js/arango/aqltemplates.json",contentType:"application/json",processData:!1,success:function(c){a&&a(!1),b.queries=c},error:function(){a&&a(!0),arangoHelper.arangoNotification("Query","Error while loading system templates")}})},updateLocalQueries:function(){var a=this;this.customQueries=[],this.collection.each(function(b){a.customQueries.push({name:b.get("name"),value:b.get("value"),parameter:b.get("parameter")})})},renderOutputTable:function(a,b){var c={id:"outputTableData"+b,titles:[],rows:[]},d=!0,e={},f=0;_.each(a.original,function(a){d===!0&&(c.titles=Object.keys(a),c.titles.forEach(function(a){e[String(a)]=f++}),d=!1);var b=Array(f);_.each(a,function(a,c){e.hasOwnProperty(c)&&("object"==typeof a&&(a=JSON.stringify(a)),b[e[c]]=a)}),c.rows.push(b)}),$("#outputTable"+b).append(this.table.render({content:c}))},renderOutputGraph:function(a,b){this.graphViewers[b]=new window.GraphViewer({name:void 0,documentStore:window.App.arangoDocumentStore,collection:new window.GraphCollection,userConfig:window.App.userConfig,id:"#outputGraph"+b,data:a});var c=this.graphViewers[b].renderAQLPreview();return c},showResultInGraphViewer:function(a,b){window.location.hash="#aql_graph",window.App.graphViewer&&(window.App.graphViewer.graphSettingsView&&window.App.graphViewer.graphSettingsView.remove(),window.App.graphViewer.remove()),window.App.graphViewer=new window.GraphViewer({name:void 0,documentStore:window.App.arangoDocumentStore,collection:new window.GraphCollection,userConfig:window.App.userConfig,noDefinedGraph:!0,data:a}),window.App.graphViewer.renderAQL()},getAQL:function(a){var b=this;this.collection.fetch({success:function(){b.getCachedQueryAfterRender();var c=localStorage.getItem("customQueries");if(c){var d=JSON.parse(c);_.each(d,function(a){b.collection.add({value:a.value,name:a.name})});var e=function(a){a?arangoHelper.arangoError("Custom Queries","Could not import old local storage queries"):localStorage.removeItem("customQueries")};b.collection.saveCollectionQueries(e)}b.updateLocalQueries(),a&&a()}})},checkCSV:function(a){var b,c=ace.edit("outputEditor"+a),d=c.getValue(),e=!1;try{d=JSON.parse(d),e=!0,_.each(d,function(a,c){_.each(a,function(a,c){try{b=JSON.parse(a),"object"==typeof b&&(e=!1)}catch(d){}})})}catch(f){}e&&$("#outputEditorWrapper"+a+" #downloadCsvResult").show()},doCSV:function(a){var b=this.arrayFrom(a),c=[];for(var d in b)c[c.length]=this.parse_object(b[d]);return $.csv.fromObjects(c)},downloadCsvResult:function(a){var b,c=$(a.currentTarget).attr("counter"),d=ace.edit("outputEditor"+c),e=d.getValue();e=JSON.parse(e),b=$.csv.fromObjects(e,{justArrays:!0}),b.length>0?arangoHelper.downloadLocalBlob(b,"csv"):arangoHelper.arangoError("Query error","Could not download the result.")}})}(),function(){"use strict";window.ScaleView=Backbone.View.extend({el:"#content",template:templateEngine.createTemplate("scaleView.ejs"),interval:1e4,knownServers:[],events:{"click #addCoord":"addCoord","click #removeCoord":"removeCoord","click #addDBs":"addDBs","click #removeDBs":"removeDBs"},setCoordSize:function(a){var b=this,c={numberOfCoordinators:a};$.ajax({type:"PUT",url:arangoHelper.databaseUrl("/_admin/cluster/numberOfServers"),contentType:"application/json",data:JSON.stringify(c),success:function(){b.updateTable(c)},error:function(){arangoHelper.arangoError("Scale","Could not set coordinator size.")}})},setDBsSize:function(a){var b=this,c={numberOfDBServers:a};$.ajax({type:"PUT",url:arangoHelper.databaseUrl("/_admin/cluster/numberOfServers"),contentType:"application/json",data:JSON.stringify(c),success:function(){b.updateTable(c)},error:function(){arangoHelper.arangoError("Scale","Could not set coordinator size.")}})},addCoord:function(){this.setCoordSize(this.readNumberFromID("#plannedCoords",!0))},removeCoord:function(){this.setCoordSize(this.readNumberFromID("#plannedCoords",!1,!0))},addDBs:function(){this.setDBsSize(this.readNumberFromID("#plannedDBs",!0))},removeDBs:function(){this.setDBsSize(this.readNumberFromID("#plannedDBs",!1,!0))},readNumberFromID:function(a,b,c){var d=$(a).html(),e=!1;try{e=JSON.parse(d)}catch(f){}return b&&e++,c&&1!==e&&e--,e},initialize:function(a){var b=this;clearInterval(this.intervalFunction),window.App.isCluster&&(this.dbServers=a.dbServers,this.coordinators=a.coordinators,this.updateServerTime(),this.intervalFunction=window.setInterval(function(){"#sNodes"===window.location.hash&&b.coordinators.fetch({success:function(){b.dbServers.fetch({success:function(){b.continueRender(!0)}})}})},this.interval))},render:function(){var a=this,b=function(){var b=function(){a.continueRender()};this.waitForDBServers(b)}.bind(this);this.initDoneCoords?b():this.waitForCoordinators(b),window.arangoHelper.buildNodesSubNav("scale")},continueRender:function(a){var b,c,d=this;b=this.coordinators.toJSON(),c=this.dbServers.toJSON(),this.$el.html(this.template.render({runningCoords:b.length,runningDBs:c.length,plannedCoords:void 0,plannedDBs:void 0,initialized:a})),$.ajax({type:"GET",cache:!1,url:arangoHelper.databaseUrl("/_admin/cluster/numberOfServers"),contentType:"application/json",processData:!1,success:function(a){d.updateTable(a)}})},updateTable:function(a){var b='scaling in progress ',c='no scaling process active';a.numberOfCoordinators&&($("#plannedCoords").html(a.numberOfCoordinators),this.coordinators.toJSON().length===a.numberOfCoordinators?$("#statusCoords").html(c):$("#statusCoords").html(b)),a.numberOfDBServers&&($("#plannedDBs").html(a.numberOfDBServers),this.dbServers.toJSON().length===a.numberOfDBServers?$("#statusDBs").html(c):$("#statusDBs").html(b))},waitForDBServers:function(a){var b=this;0===this.dbServers.length?window.setInterval(function(){b.waitForDBServers(a)},300):a()},waitForCoordinators:function(a){var b=this;window.setTimeout(function(){0===b.coordinators.length?b.waitForCoordinators(a):(b.initDoneCoords=!0,a())},200)},updateServerTime:function(){this.serverTime=(new Date).getTime()}})}(),function(){"use strict";window.SettingsView=Backbone.View.extend({el:"#content",readOnly:!1,initialize:function(a){this.collectionName=a.collectionName,this.model=this.collection},events:{},render:function(){this.breadcrumb(),arangoHelper.buildCollectionSubNav(this.collectionName,"Settings"),this.renderSettings()},breadcrumb:function(){$("#subNavigationBar .breadcrumb").html("Collection: "+this.collectionName)},unloadCollection:function(){if(!this.readOnly){var a=function(a){a?arangoHelper.arangoError("Collection error",this.model.get("name")+" could not be unloaded."):void 0===a?(this.model.set("status","unloading"),this.render()):"#collections"===window.location.hash?(this.model.set("status","unloaded"),this.render()):arangoHelper.arangoNotification("Collection "+this.model.get("name")+" unloaded.")}.bind(this);this.model.unloadCollection(a),window.modalView.hide()}},loadCollection:function(){if(!this.readOnly){var a=function(a){a?arangoHelper.arangoError("Collection error",this.model.get("name")+" could not be loaded."):void 0===a?(this.model.set("status","loading"),this.render()):"#collections"===window.location.hash?(this.model.set("status","loaded"),this.render()):arangoHelper.arangoNotification("Collection "+this.model.get("name")+" loaded.")}.bind(this);this.model.loadCollection(a),window.modalView.hide()}},truncateCollection:function(){this.readOnly||(this.model.truncateCollection(),$(".modal-delete-confirmation").hide(),window.modalView.hide())},warmupCollection:function(){this.readOnly||(this.model.warmupCollection(),$(".modal-delete-confirmation").hide(),window.modalView.hide())},deleteCollection:function(){this.readOnly||this.model.destroy({error:function(){arangoHelper.arangoError("Could not delete collection.")},success:function(){window.App.navigate("#collections",{trigger:!0})}})},saveModifiedCollection:function(){if(!this.readOnly){var a=function(a,b){if(a)arangoHelper.arangoError("Error","Could not get coordinator info");else{var c;c=b?this.model.get("name"):$("#change-collection-name").val();var d=this.model.get("status");if("loaded"===d){var e;if("rocksdb"!==frontendConfig.engine)try{e=JSON.parse(1024*$("#change-collection-size").val()*1024)}catch(f){return arangoHelper.arangoError("Please enter a valid journal size number."),0}var g;if("rocksdb"!==frontendConfig.engine)try{if(g=JSON.parse($("#change-index-buckets").val()),g<1||parseInt(g,10)!==Math.pow(2,Math.log2(g)))throw new Error("invalid indexBuckets value")}catch(f){return arangoHelper.arangoError("Please enter a valid number of index buckets."),0}var h=this,i=function(a,b){a?(h.render(),arangoHelper.arangoError("Collection error: "+b.responseJSON.errorMessage)):(arangoHelper.arangoNotification("Collection: Successfully changed."),window.App.navigate("#cSettings/"+c,{trigger:!0}))},j=function(a){if(a)arangoHelper.arangoError("Collection error: "+a.responseText);else{var b,c=$("#change-collection-sync").val();frontendConfig.isCluster&&(b=$("#change-replication-factor").val()),this.model.changeCollection(c,e,g,b,i)}}.bind(this);frontendConfig.isCluster===!1?this.model.renameCollection(c,j):j()}else if("unloaded"===d)if(this.model.get("name")!==c){var k=function(a,b){a?arangoHelper.arangoError("Collection"+b.responseText):(arangoHelper.arangoNotification("CollectionSuccessfully changed."),window.App.navigate("#cSettings/"+c,{trigger:!0}))};frontendConfig.isCluster===!1?this.model.renameCollection(c,k):k()}else window.modalView.hide()}}.bind(this);window.isCoordinator(a)}},changeViewToReadOnly:function(){window.App.settingsView.readOnly=!0,$(".breadcrumb").html($(".breadcrumb").html()+" (read-only)"),$(".modal-body input").prop("disabled","true"),$(".modal-body select").prop("disabled","true"),$(".modal-footer button").addClass("disabled"),$(".modal-footer button").unbind("click")},renderSettings:function(){var a=this,b=function(b,c){if(b)arangoHelper.arangoError("Error","Could not get coordinator info");else{var d=!1;"loaded"===this.model.get("status")&&(d=!0);var e=[],f=[];c||f.push(window.modalView.createTextEntry("change-collection-name","Name",this.model.get("name"),!1,"",!0,[{rule:Joi.string().regex(/^[a-zA-Z]/),msg:"Collection name must always start with a letter."},{rule:Joi.string().regex(/^[a-zA-Z0-9\-_]*$/),msg:'Only Symbols "_" and "-" are allowed.'},{rule:Joi.string().required(),msg:"No collection name given."}]));var g=function(){f.push(window.modalView.createReadOnlyEntry("change-collection-id","ID",this.model.get("id"),"")),f.push(window.modalView.createReadOnlyEntry("change-collection-type","Type",this.model.get("type"),"")),f.push(window.modalView.createReadOnlyEntry("change-collection-status","Status",this.model.get("status"),"")),e.push(window.modalView.createDeleteButton("Delete",this.deleteCollection.bind(this))),e.push(window.modalView.createDeleteButton("Truncate",this.truncateCollection.bind(this))),"rocksdb"===frontendConfig.engine&&e.push(window.modalView.createNotificationButton("Load Indexes into Memory",this.warmupCollection.bind(this))),d?e.push(window.modalView.createNotificationButton("Unload",this.unloadCollection.bind(this))):e.push(window.modalView.createNotificationButton("Load",this.loadCollection.bind(this))),e.push(window.modalView.createSuccessButton("Save",this.saveModifiedCollection.bind(this)));var a=["General","Indexes"],b=["modalTable.ejs","indicesView.ejs"];window.modalView.show(b,"Modify Collection",e,f,null,null,this.events,null,a,"content"),$($("#infoTab").children()[1]).remove()}.bind(this);if(d){var h=function(b,c){if(b)arangoHelper.arangoError("Collection","Could not fetch properties");else{if(c.journalSize){var d=c.journalSize/1048576,e=c.indexBuckets,h=c.waitForSync;f.push(window.modalView.createTextEntry("change-collection-size","Journal size",d,"The maximal size of a journal or datafile (in MB). Must be at least 1.","",!0,[{rule:Joi.string().allow("").optional().regex(/^[0-9]*$/),msg:"Must be a number."}]))}e&&f.push(window.modalView.createTextEntry("change-index-buckets","Index buckets",e,"The number of index buckets for this collection. Must be at least 1 and a power of 2.","",!0,[{rule:Joi.string().allow("").optional().regex(/^[1-9][0-9]*$/),msg:"Must be a number greater than 1 and a power of 2."}])),c.replicationFactor&&frontendConfig.isCluster&&f.push(window.modalView.createTextEntry("change-replication-factor","Replication factor",c.replicationFactor,"The replicationFactor parameter is the total number of copies being kept, that is, it is one plus the number of followers. Must be a number.","",!0,[{rule:Joi.string().allow("").optional().regex(/^[0-9]*$/),msg:"Must be a number." -}])),f.push(window.modalView.createSelectEntry("change-collection-sync","Wait for sync",h,"Synchronize to disk before returning from a create or update of a document.",[{value:!1,label:"No"},{value:!0,label:"Yes"}]))}g(),arangoHelper.checkCollectionPermissions(a.collectionName,a.changeViewToReadOnly.bind(this))};this.model.getProperties(h)}else g(),arangoHelper.checkCollectionPermissions(a.collectionName,a.changeViewToReadOnly.bind(this))}}.bind(this);window.isCoordinator(b)}})}(),function(){"use strict";window.ShardsView=Backbone.View.extend({el:"#content",template:templateEngine.createTemplate("shardsView.ejs"),interval:1e4,knownServers:[],events:{"click #shardsContent .shardLeader span":"moveShard","click #shardsContent .shardFollowers span":"moveShardFollowers","click #rebalanceShards":"rebalanceShards"},initialize:function(a){var b=this;b.dbServers=a.dbServers,clearInterval(this.intervalFunction),window.App.isCluster&&(this.updateServerTime(),this.intervalFunction=window.setInterval(function(){"#shards"===window.location.hash&&b.render(!1)},this.interval))},remove:function(){return clearInterval(this.intervalFunction),this.$el.empty().off(),this.stopListening(),this.unbind(),delete this.el,this},render:function(a){if("#shards"===window.location.hash){var b=this;$.ajax({type:"GET",cache:!1,url:arangoHelper.databaseUrl("/_admin/cluster/shardDistribution"),contentType:"application/json",processData:!1,async:!0,success:function(a){var c=!1;b.shardDistribution=a.results,_.each(a.results,function(a,b){"error"!==b&&"code"!==b&&("_"!==b.substring(0,1)&&(c=!0),(b.startsWith("_local_")||b.startsWith("_to_")||b.startsWith("_from_"))&&(c=!0))}),c?b.continueRender(a.results):arangoHelper.renderEmpty("No collections and no shards available")},error:function(a){0!==a.readyState&&arangoHelper.arangoError("Cluster","Could not fetch sharding information.")}}),a!==!1&&arangoHelper.buildNodesSubNav("Shards")}},moveShardFollowers:function(a){var b=$(a.currentTarget).html();this.moveShard(a,b)},moveShard:function(a,b){var c,d,e,f,g=this,h=window.App.currentDB.get("name");d=$(a.currentTarget).parent().parent().attr("collection"),e=$(a.currentTarget).parent().parent().attr("shard"),b?(f=$(a.currentTarget).parent().parent().attr("leader"),f=arangoHelper.getDatabaseServerId(f),c=arangoHelper.getDatabaseServerId(b)):(c=$(a.currentTarget).parent().parent().attr("leader"),c=arangoHelper.getDatabaseServerId(c));var i=[],j=[],k={},l=[];g.dbServers[0].fetch({success:function(){return g.dbServers[0].each(function(a){a.get("id")!==c&&(k[a.get("name")]={value:a.get("id"),label:a.get("name")})}),_.each(g.shardDistribution[d].Plan[e].followers,function(a){delete k[a]}),b&&delete k[f],_.each(k,function(a){l.push(a)}),l=l.reverse(),0===l.length?void arangoHelper.arangoMessage("Shards","No database server for moving the shard is available."):(j.push(window.modalView.createSelectEntry("toDBServer","Destination",void 0,"Please select the target database server. The selected database server will be the new leader of the shard.",l)),i.push(window.modalView.createSuccessButton("Move",g.confirmMoveShards.bind(this,h,d,e,c))),void window.modalView.show("modalTable.ejs","Move shard: "+e,i,j))}})},confirmMoveShards:function(a,b,c,d){var e=$("#toDBServer").val(),f={database:a,collection:b,shard:c,fromServer:d,toServer:e};$.ajax({type:"POST",cache:!1,url:arangoHelper.databaseUrl("/_admin/cluster/moveShard"),contentType:"application/json",processData:!1,data:JSON.stringify(f),async:!0,success:function(a){a.id&&(arangoHelper.arangoNotification("Shard "+c+" will be moved to "+arangoHelper.getDatabaseShortName(e)+"."),window.setTimeout(function(){window.App.shardsView.render()},3e3))},error:function(){arangoHelper.arangoError("Shard "+c+" could not be moved to "+arangoHelper.getDatabaseShortName(e)+".")}}),window.modalView.hide()},rebalanceShards:function(){var a=this;$.ajax({type:"POST",cache:!1,url:arangoHelper.databaseUrl("/_admin/cluster/rebalanceShards"),contentType:"application/json",processData:!1,data:JSON.stringify({}),async:!0,success:function(b){b===!0&&(window.setTimeout(function(){a.render(!1)},3e3),arangoHelper.arangoNotification("Started rebalance process."))},error:function(){arangoHelper.arangoError("Could not start rebalance process.")}}),window.modalView.hide()},continueRender:function(a){var b=this;delete a.code,delete a.error,_.each(a,function(b,c){var d={Plan:{},Current:{}};if(c.startsWith("_local_")){var e=c.substr(7,c.length-1),f=["_local_"+e,"_from_"+e,"_to_"+e,e],g=0;_.each(f,function(b,c){_.each(a[f[g]].Current,function(a,b){d.Current[b]=a}),_.each(a[f[g]].Plan,function(a,b){d.Plan[b]=a}),delete a[f[g]],a[e]=d,g++})}});var c={};Object.keys(a).sort().forEach(function(b){c[b]=a[b]}),this.$el.html(this.template.render({collections:c}));var d=!1;_.each(a,function(a){_.each(a.Plan,function(a,b){a.progress&&(d=!0)})}),d&&window.setTimeout(function(){b.render()},3e3)},updateServerTime:function(){this.serverTime=(new Date).getTime()}})}(),function(){"use strict";window.ShowClusterView=Backbone.View.extend({detailEl:"#modalPlaceholder",el:"#content",defaultFrame:12e5,template:templateEngine.createTemplate("showCluster.ejs"),modal:templateEngine.createTemplate("waitModal.ejs"),detailTemplate:templateEngine.createTemplate("detailView.ejs"),events:{"change #selectDB":"updateCollections","change #selectCol":"updateShards","click .dbserver.success":"dashboard","click .coordinator.success":"dashboard"},replaceSVGs:function(){$(".svgToReplace").each(function(){var a=$(this),b=a.attr("id"),c=a.attr("src");$.get(c,function(c){var d=$(c).find("svg");d.attr("id",b).attr("class","icon").removeAttr("xmlns:a"),a.replaceWith(d)},"xml")})},updateServerTime:function(){this.serverTime=(new Date).getTime()},setShowAll:function(){this.graphShowAll=!0},resetShowAll:function(){this.graphShowAll=!1,this.renderLineChart()},initialize:function(a){this.options=a,this.interval=1e4,this.isUpdating=!1,this.timer=null,this.knownServers=[],this.graph=void 0,this.graphShowAll=!1,this.updateServerTime(),this.dygraphConfig=this.options.dygraphConfig,this.dbservers=new window.ClusterServers([],{interval:this.interval}),this.coordinators=new window.ClusterCoordinators([],{interval:this.interval}),this.documentStore=new window.ArangoDocuments,this.statisticsDescription=new window.StatisticsDescription,this.statisticsDescription.fetch({async:!1}),this.dbs=new window.ClusterDatabases([],{interval:this.interval}),this.cols=new window.ClusterCollections,this.shards=new window.ClusterShards,this.startUpdating()},listByAddress:function(a){var b={},c=this;this.dbservers.byAddress(b,function(b){c.coordinators.byAddress(b,a)})},updateCollections:function(){var a=this,b=$("#selectCol"),c=$("#selectDB").find(":selected").attr("id");if(c){var d=b.find(":selected").attr("id");b.html(""),this.cols.getList(c,function(c){_.each(_.pluck(c,"name"),function(a){b.append('")});var e=$("#"+d,b);1===e.length&&e.prop("selected",!0),a.updateShards()})}},updateShards:function(){var a=$("#selectDB").find(":selected").attr("id"),b=$("#selectCol").find(":selected").attr("id");this.shards.getList(a,b,function(a){$(".shardCounter").html("0"),_.each(a,function(a){$("#"+a.server+"Shards").html(a.shards.length)})})},updateServerStatus:function(a){var b=this,c=function(a,b,c){var d,e,f=c;f=f.replace(/\./g,"-"),f=f.replace(/:/g,"_"),e=$("#id"+f),e.length<1||(d=e.attr("class").split(/\s+/)[1],e.attr("class",a+" "+d+" "+b),"coordinator"===a&&("success"===b?$(".button-gui",e.closest(".tile")).toggleClass("button-gui-disabled",!1):$(".button-gui",e.closest(".tile")).toggleClass("button-gui-disabled",!0)))};this.coordinators.getStatuses(c.bind(this,"coordinator"),function(){b.dbservers.getStatuses(c.bind(b,"dbserver")),a()})},updateDBDetailList:function(){var a=this,b=$("#selectDB"),c=b.find(":selected").attr("id");b.html(""),this.dbs.getList(function(d){_.each(_.pluck(d,"name"),function(a){b.append('")});var e=$("#"+c,b);1===e.length&&e.prop("selected",!0),a.updateCollections()})},rerender:function(){var a=this;this.updateServerStatus(function(){a.getServerStatistics(function(){a.updateServerTime(),a.data=a.generatePieData(),a.renderPieChart(a.data),a.renderLineChart(),a.updateDBDetailList()})})},render:function(){this.knownServers=[],delete this.hist;var a=this;this.listByAddress(function(b){1===Object.keys(b).length?a.type="testPlan":a.type="other",a.updateDBDetailList(),a.dbs.getList(function(c){$(a.el).html(a.template.render({dbs:_.pluck(c,"name"),byAddress:b,type:a.type})),$(a.el).append(a.modal.render({})),a.replaceSVGs(),a.getServerStatistics(function(){a.data=a.generatePieData(),a.renderPieChart(a.data),a.renderLineChart(),a.updateDBDetailList(),a.startUpdating()})})})},generatePieData:function(){var a=[],b=this;return this.data.forEach(function(c){a.push({key:c.get("name"),value:c.get("system").virtualSize,time:b.serverTime})}),a},addStatisticsItem:function(a,b,c,d){var e=this;e.hasOwnProperty("hist")||(e.hist={}),e.hist.hasOwnProperty(a)||(e.hist[a]=[]);var f=e.hist[a],g=f.length;if(0===g)f.push({time:b,snap:d,requests:c,requestsPerSecond:0});else{var h=f[g-1].time,i=f[g-1].requests;if(i0&&(k=(c-i)/j),f.push({time:b,snap:d,requests:c,requestsPerSecond:k})}}},getServerStatistics:function(a){var b=this,c=Math.round(b.serverTime/1e3);this.data=void 0;var d=new window.ClusterStatisticsCollection,e=this.coordinators.first();this.dbservers.forEach(function(a){if("ok"===a.get("status")){b.knownServers.indexOf(a.id)===-1&&b.knownServers.push(a.id);var c=new window.Statistics({name:a.id});c.url=e.get("protocol")+"://"+e.get("address")+"/_admin/clusterStatistics?DBserver="+a.get("name"),d.add(c)}}),this.coordinators.forEach(function(a){if("ok"===a.get("status")){b.knownServers.indexOf(a.id)===-1&&b.knownServers.push(a.id);var c=new window.Statistics({name:a.id});c.url=a.get("protocol")+"://"+a.get("address")+"/_admin/statistics",d.add(c)}});var f=d.size();this.data=[];var g=function(d){f--;var e=d.get("time"),g=d.get("name"),h=d.get("http").requestsTotal;b.addStatisticsItem(g,e,h,c),b.data.push(d),0===f&&a()},h=function(){f--,0===f&&a()};d.fetch(g,h)},renderPieChart:function(a){var b=$("#clusterGraphs svg").width(),c=$("#clusterGraphs svg").height(),d=Math.min(b,c)/2,e=this.dygraphConfig.colors,f=d3.svg.arc().outerRadius(d-20).innerRadius(0),g=d3.layout.pie().sort(function(a){return a.value}).value(function(a){return a.value});d3.select("#clusterGraphs").select("svg").remove();var h=d3.select("#clusterGraphs").append("svg").attr("class","clusterChart").append("g").attr("transform","translate("+b/2+","+(c/2-10)+")"),i=d3.svg.arc().outerRadius(d-2).innerRadius(d-2),j=h.selectAll(".arc").data(g(a)).enter().append("g").attr("class","slice");j.append("path").attr("d",f).style("fill",function(a,b){return e[b%e.length]}).style("stroke",function(a,b){return e[b%e.length]}),j.append("text").attr("transform",function(a){return"translate("+f.centroid(a)+")"}).style("text-anchor","middle").text(function(a){var b=a.data.value/1024/1024/1024;return b.toFixed(2)}),j.append("text").attr("transform",function(a){return"translate("+i.centroid(a)+")"}).style("text-anchor","middle").text(function(a){return a.data.key})},renderLineChart:function(){var a,b,c,d,e,f,g=this,h=1200,i=[],j=[],k=Math.round((new Date).getTime()/1e3)-h,l=g.knownServers,m=function(){return null};for(c=0;c";return b&&(d+=''),c&&(d+=''+c.toUpperCase()+""),d+=""};$(this.el).html(this.template.render({})),$(this.el).show(),"aql"===c?this.typeahead=$("#spotlight .typeahead").typeahead({hint:!0,highlight:!0,minLength:1},{name:"Functions",source:d.substringMatcher(d.aqlBuiltinFunctionsArray),limit:d.displayLimit,templates:{header:a("Functions","fa-code","aql")}},{name:"Keywords",source:d.substringMatcher(d.aqlKeywordsArray),limit:d.displayLimit,templates:{header:a("Keywords","fa-code","aql")}},{name:"Documents",source:d.substringMatcher(d.collections.doc),limit:d.displayLimit,templates:{header:a("Documents","fa-file-text-o","Collection")}},{name:"Edges",source:d.substringMatcher(d.collections.edge),limit:d.displayLimit,templates:{header:a("Edges","fa-share-alt","Collection")}},{name:"System",limit:d.displayLimit,source:d.substringMatcher(d.collections.system),templates:{header:a("System","fa-cogs","Collection")}}):this.typeahead=$("#spotlight .typeahead").typeahead({hint:!0,highlight:!0,minLength:1},{name:"Documents",source:d.substringMatcher(d.collections.doc),limit:d.displayLimit,templates:{header:a("Documents","fa-file-text-o","Collection")}},{name:"Edges",source:d.substringMatcher(d.collections.edge),limit:d.displayLimit,templates:{header:a("Edges","fa-share-alt","Collection")}},{name:"System",limit:d.displayLimit,source:d.substringMatcher(d.collections.system),templates:{header:a("System","fa-cogs","Collection")}}),$("#spotlight .typeahead").focus()}.bind(this);0===d.aqlBuiltinFunctionsArray.length?this.fetchKeywords(e):e()}})}(),function(){"use strict";window.StatisticBarView=Backbone.View.extend({el:"#statisticBar",events:{"change #arangoCollectionSelect":"navigateBySelect","click .tab":"navigateByTab"},template:templateEngine.createTemplate("statisticBarView.ejs"),initialize:function(a){this.currentDB=a.currentDB},replaceSVG:function(a){var b=a.attr("id"),c=a.attr("class"),d=a.attr("src");$.get(d,function(d){var e=$(d).find("svg");void 0===b&&(e=e.attr("id",b)),void 0===c&&(e=e.attr("class",c+" replaced-svg")),e=e.removeAttr("xmlns:a"),a.replaceWith(e)},"xml")},render:function(){var a=this;return $(this.el).html(this.template.render({isSystem:this.currentDB.get("isSystem")})),$("img.svg").each(function(){a.replaceSVG($(this))}),this},navigateBySelect:function(){var a=$("#arangoCollectionSelect").find("option:selected").val();window.App.navigate(a,{trigger:!0})},navigateByTab:function(a){var b=a.target||a.srcElement,c=b.id;return"links"===c?($("#link_dropdown").slideToggle(200),void a.preventDefault()):"tools"===c?($("#tools_dropdown").slideToggle(200),void a.preventDefault()):(window.App.navigate(c,{trigger:!0}),void a.preventDefault())},handleSelectNavigation:function(){$("#arangoCollectionSelect").change(function(){var a=$(this).find("option:selected").val();window.App.navigate(a,{trigger:!0})})},selectMenuItem:function(a){$(".navlist li").removeClass("active"),a&&$("."+a).addClass("active")}})}(),function(){"use strict";window.SupportView=Backbone.View.extend({el:"#content",template:templateEngine.createTemplate("supportView.ejs"),events:{"click .subViewNavbar .subMenuEntry":"toggleViews"},render:function(){this.$el.html(this.template.render({}))},resize:function(a){a?$(".innerContent").css("height","auto"):$(".innerContent").height($(".centralRow").height()-170)},renderSwagger:function(){var a=window.location.pathname.split("/"),b=window.location.protocol+"//"+window.location.hostname+":"+window.location.port+"/"+a[1]+"/"+a[2]+"/_admin/aardvark/api/index.html";$("#swagger").html(""),$("#swagger").append('')},toggleViews:function(a){var b=this,c=a.currentTarget.id.split("-")[0],d=["community","documentation","swagger"];_.each(d,function(a){c!==a?$("#"+a).hide():("swagger"===c?(b.renderSwagger(),$("#swagger iframe").css("height","100%"),$("#swagger iframe").css("width","100%"),$("#swagger iframe").css("margin-top","-13px"),b.resize()):b.resize(!0),$("#"+a).show())}),$(".subMenuEntries").children().removeClass("active"),$("#"+c+"-support").addClass("active")}})}(),function(){"use strict";window.TableView=Backbone.View.extend({template:templateEngine.createTemplate("tableView.ejs"),loading:templateEngine.createTemplate("loadingTableView.ejs"),initialize:function(a){this.rowClickCallback=a.rowClick},events:{"click .pure-table-body .pure-table-row":"rowClick","click .deleteButton":"removeClick"},rowClick:function(a){this.hasOwnProperty("rowClickCallback")&&this.rowClickCallback(a)},removeClick:function(a){this.hasOwnProperty("removeClickCallback")&&(this.removeClickCallback(a),a.stopPropagation())},setRowClick:function(a){this.rowClickCallback=a},setRemoveClick:function(a){this.removeClickCallback=a},render:function(){$(this.el).html(this.template.render({docs:this.collection}))},drawLoading:function(){$(this.el).html(this.loading.render({}))}})}(),function(){"use strict";window.UserBarView=Backbone.View.extend({events:{"change #userBarSelect":"navigateBySelect","click .tab":"navigateByTab","mouseenter .dropdown":"showDropdown","mouseleave .dropdown":"hideDropdown","click #userLogoutIcon":"userLogout","click #userLogout":"userLogout"},initialize:function(a){this.userCollection=a.userCollection,this.userCollection.fetch({cache:!1,async:!0}),this.userCollection.bind("change:extra",this.render.bind(this))},template:templateEngine.createTemplate("userBarView.ejs"),navigateBySelect:function(){var a=$("#arangoCollectionSelect").find("option:selected").val();window.App.navigate(a,{trigger:!0})},navigateByTab:function(a){var b=a.target||a.srcElement;b=$(b).closest("a");var c=b.attr("id");return"user"===c?($("#user_dropdown").slideToggle(200),void a.preventDefault()):(window.App.navigate(c,{trigger:!0}),void a.preventDefault())},toggleUserMenu:function(){$("#userBar .subBarDropdown").toggle()},showDropdown:function(){$("#user_dropdown").fadeIn(1)},hideDropdown:function(){$("#user_dropdown").fadeOut(1)},render:function(){if(frontendConfig.authenticationEnabled!==!1){var a=this,b=function(b,c){if(b)arangoHelper.arangoErro("User","Could not fetch user.");else{var d=null,e=null,f=!1,g=null;if(c!==!1){var h=function(){return g=a.userCollection.findWhere({user:c}),g.set({loggedIn:!0}),e=g.get("extra").name,d=g.get("extra").img,f=g.get("active"),d=d?"https://s.gravatar.com/avatar/"+d+"?s=80":"img/default_user.png",e||(e=""),a.$el=$("#userBar"),a.$el.html(a.template.render({img:d,name:e,username:c,active:f})),a.delegateEvents(),a.$el};0===a.userCollection.models.length?a.userCollection.fetch({success:function(){h(b,c)}}):h(b,c)}}};$("#userBar").on("click",function(){a.toggleUserMenu()}),this.userCollection.whoAmI(b)}},userLogout:function(){var a=function(a){a?arangoHelper.arangoError("User","Logout error"):this.userCollection.logout()}.bind(this);this.userCollection.whoAmI(a)}})}(),function(){"use strict";window.UserManagementView=Backbone.View.extend({el:"#content",el2:"#userManagementThumbnailsIn",template:templateEngine.createTemplate("userManagementView.ejs"),remove:function(){return this.$el.empty().off(),this.stopListening(),this.unbind(),delete this.el,this},events:{"click #createUser":"createUser","click #submitCreateUser":"submitCreateUser","click #userManagementThumbnailsIn .tile":"editUser","click #submitEditUser":"submitEditUser","click #userManagementToggle":"toggleView","keyup #userManagementSearchInput":"search","click #userManagementSearchSubmit":"search","click #callEditUserPassword":"editUserPassword","click #submitEditUserPassword":"submitEditUserPassword","click #submitEditCurrentUserProfile":"submitEditCurrentUserProfile","click .css-label":"checkBoxes","change #userSortDesc":"sorting"},dropdownVisible:!1,initialize:function(){var a=this,b=function(a,b){frontendConfig.authenticationEnabled===!0&&(a||null===b?arangoHelper.arangoError("User","Could not fetch user data"):this.currentUser=this.collection.findWhere({user:b}))}.bind(this);this.collection.fetch({cache:!1,success:function(){a.collection.whoAmI(b)}})},checkBoxes:function(a){var b=a.currentTarget.id;$("#"+b).click()},sorting:function(){$("#userSortDesc").is(":checked")?this.collection.setSortingDesc(!0):this.collection.setSortingDesc(!1),$("#userManagementDropdown").is(":visible")?this.dropdownVisible=!0:this.dropdownVisible=!1,this.render()},render:function(a){var b=!1;$("#userManagementDropdown").is(":visible")&&(b=!0);var c=function(){this.collection.sort(),$(this.el).html(this.template.render({collection:this.collection,searchString:""})),b===!0&&($("#userManagementDropdown2").show(),$("#userSortDesc").attr("checked",this.collection.sortOptions.desc),$("#userManagementToggle").toggleClass("activated"),$("#userManagementDropdown").show()),a&&this.editCurrentUser(),arangoHelper.setCheckboxStatus("#userManagementDropdown")}.bind(this);return this.collection.fetch({cache:!1,success:function(){c()}}),this},search:function(){var a,b,c,d;a=$("#userManagementSearchInput"),b=$("#userManagementSearchInput").val(),d=this.collection.filter(function(a){return a.get("user").indexOf(b)!==-1}),$(this.el).html(this.template.render({collection:d,searchString:b})),a=$("#userManagementSearchInput"),c=a.val().length,a.focus(),a[0].setSelectionRange(c,c)},createUser:function(a){a.preventDefault(),this.createCreateUserModal()},submitCreateUser:function(){var a=this,b=$("#newUsername").val(),c=$("#newName").val(),d=$("#newPassword").val(),e=$("#newStatus").is(":checked");if(this.validateUserInfo(c,b,d,e)){var f={user:b,passwd:d,active:e,extra:{name:c}};frontendConfig.isEnterprise&&$("#newRole").is(":checked")&&(f.user=":role:"+b,delete f.passwd),this.collection.create(f,{wait:!0,error:function(a,b){arangoHelper.parseError("User",b,a)},success:function(){a.updateUserManagement(),window.modalView.hide()}})}},validateUserInfo:function(a,b,c,d){return""!==b||(arangoHelper.arangoError("You have to define an username"),$("#newUsername").closest("th").css("backgroundColor","red"),!1)},updateUserManagement:function(){var a=this;this.collection.fetch({cache:!1,success:function(){a.render()}})},editUser:function(a){if("createUser"!==$(a.currentTarget).find("a").attr("id")){$(a.currentTarget).hasClass("tile")&&(a.currentTarget=$(a.currentTarget).find(".fa")),this.collection.fetch({cache:!1});var b=this.evaluateUserName($(a.currentTarget).attr("id"),"_edit-user");""===b&&(b=$(a.currentTarget).attr("id")),window.App.navigate("user/"+encodeURIComponent(b),{trigger:!0})}},toggleView:function(){$("#userSortDesc").attr("checked",this.collection.sortOptions.desc),$("#userManagementToggle").toggleClass("activated"),$("#userManagementDropdown2").slideToggle(200)},createCreateUserModal:function(){var a=[],b=[];b.push(window.modalView.createTextEntry("newUsername","Username","",!1,"Username",!0,[{rule:Joi.string().regex(/^[a-zA-Z0-9\-_]*$/),msg:'Only symbols, "_" and "-" are allowed.'},{rule:Joi.string().required(),msg:"No username given."}])),b.push(window.modalView.createTextEntry("newName","Name","",!1,"Name",!1)),b.push(window.modalView.createPasswordEntry("newPassword","Password","",!1,"",!1)),frontendConfig.isEnterprise&&b.push(window.modalView.createCheckboxEntry("newRole","Role",!1,!1,!1)),b.push(window.modalView.createCheckboxEntry("newStatus","Active","active",!1,!0)),a.push(window.modalView.createSuccessButton("Create",this.submitCreateUser.bind(this))),window.modalView.show("modalTable.ejs","Create New User",a,b),frontendConfig.isEnterprise&&$("#newRole").on("change",function(){$("#newRole").is(":checked")?$("#newPassword").attr("disabled",!0):$("#newPassword").attr("disabled",!1)})},evaluateUserName:function(a,b){if(a){var c=a.lastIndexOf(b);return a.substring(0,c)}},updateUserProfile:function(){var a=this;this.collection.fetch({cache:!1,success:function(){a.render()}})}})}(),function(){"use strict";window.UserPermissionView=Backbone.View.extend({el:"#content",template:templateEngine.createTemplate("userPermissionView.ejs"),initialize:function(a){this.username=a.username},remove:function(){return this.$el.empty().off(),this.stopListening(),this.unbind(),delete this.el,this},events:{"click #userPermissionView .dbCheckbox":"setDBPermission","click #userPermissionView .collCheckbox":"setCollPermission","click .db-row":"toggleAccordion"},render:function(a,b){var c=this;this.collection.fetch({success:function(){c.continueRender(a,b)}})},toggleAccordion:function(a){if(!($(a.target).attr("type")||$(a.target).parent().hasClass("noAction")||$(a.target).hasClass("inner")||$(a.target).is("span"))){var b=$(a.currentTarget).find(".collection-row").is(":visible"),c=$(a.currentTarget).attr("id").split("-")[0];$(".collection-row").hide(),$(".db-label").css("font-weight",200),$(".db-label").css("color","#8a969f"),$(a.currentTarget).find(".collection-row").children().length>4?($(".db-row .fa-caret-down").hide(),$(".db-row .fa-caret-right").show(),b?$(a.currentTarget).find(".collection-row").hide():($(a.currentTarget).find(".collection-row").fadeIn("fast"),$(a.currentTarget).find(".db-label").css("font-weight",600),$(a.currentTarget).find(".db-label").css("color","rgba(64, 74, 83, 1)"),$(a.currentTarget).find(".fa-caret-down").show(),$(a.currentTarget).find(".fa-caret-right").hide())):($(".db-row .fa-caret-down").hide(),$(".db-row .fa-caret-right").show(),arangoHelper.arangoNotification("Permissions",'No collections in "'+c+'" available.'))}},setCollPermission:function(a){var b,c=$(a.currentTarget).attr("db"),d=$(a.currentTarget).attr("collection");b=$(a.currentTarget).hasClass("readOnly")?"ro":$(a.currentTarget).hasClass("readWrite")?"rw":$(a.currentTarget).hasClass("noAccess")?"none":"undefined",this.sendCollPermission(this.currentUser.get("user"),c,d,b)},setDBPermission:function(a){var b,c=$(a.currentTarget).attr("name");if(b=$(a.currentTarget).hasClass("readOnly")?"ro":$(a.currentTarget).hasClass("readWrite")?"rw":$(a.currentTarget).hasClass("noAccess")?"none":"undefined","_system"===c){var d=[],e=[];e.push(window.modalView.createReadOnlyEntry("db-system-revoke-button","Caution","You are changing the _system database permission. Really continue?",void 0,void 0,!1)),d.push(window.modalView.createSuccessButton("Ok",this.sendDBPermission.bind(this,this.currentUser.get("user"),c,b))),d.push(window.modalView.createCloseButton("Cancel",this.rollbackInputButton.bind(this,c))),window.modalView.show("modalTable.ejs","Change _system Database Permission",d,e)}else this.sendDBPermission(this.currentUser.get("user"),c,b)},rollbackInputButton:function(a,b){var c;_.each($(".collection-row"),function(a,b){$(a).is(":visible")&&(c=$(a).parent().attr("id"))}),c?this.render(c,b):this.render(),window.modalView.hide()},sendCollPermission:function(a,b,c,d){var e=this;"undefined"===d?this.revokeCollPermission(a,b,c):$.ajax({type:"PUT",url:arangoHelper.databaseUrl("/_api/user/"+encodeURIComponent(a)+"/database/"+encodeURIComponent(b)+"/"+encodeURIComponent(c)),contentType:"application/json",data:JSON.stringify({grant:d})}).success(function(a){e.styleDefaultRadios(null,!0)}).error(function(a){e.rollbackInputButton(null,a)})},revokeCollPermission:function(a,b,c){var d=this;$.ajax({type:"DELETE",url:arangoHelper.databaseUrl("/_api/user/"+encodeURIComponent(a)+"/database/"+encodeURIComponent(b)+"/"+encodeURIComponent(c)),contentType:"application/json"}).success(function(a){d.styleDefaultRadios(null,!0)}).error(function(a){d.rollbackInputButton(null,a)})},sendDBPermission:function(a,b,c){var d=this;"undefined"===c?this.revokeDBPermission(a,b):$.ajax({type:"PUT",url:arangoHelper.databaseUrl("/_api/user/"+encodeURIComponent(a)+"/database/"+encodeURIComponent(b)),contentType:"application/json",data:JSON.stringify({grant:c})}).success(function(a){d.styleDefaultRadios(null,!0)}).error(function(a){d.rollbackInputButton(null,a)})},revokeDBPermission:function(a,b){var c=this;$.ajax({type:"DELETE",url:arangoHelper.databaseUrl("/_api/user/"+encodeURIComponent(a)+"/database/"+encodeURIComponent(b)),contentType:"application/json"}).success(function(a){c.styleDefaultRadios(null,!0)}).error(function(a){c.rollbackInputButton(null,a)})},continueRender:function(a,b){var c=this;this.currentUser=this.collection.findWhere({user:this.username}),this.breadcrumb();var d=arangoHelper.databaseUrl("/_api/user/"+encodeURIComponent(c.currentUser.get("user"))+"/database?full=true");$.ajax({type:"GET",url:d,contentType:"application/json",success:function(d){c.finishRender(d.result,a,b)},error:function(a){arangoHelper.arangoError("User","Could not fetch user permissions")}})},finishRender:function(a,b,c){$(this.el).html(this.template.render({permissions:a})),$(".pure-table-body").height(window.innerHeight-200),b&&$("#"+b).click(),c&&c.responseJSON&&c.responseJSON.errorMessage&&arangoHelper.arangoError("User",c.responseJSON.errorMessage),this.styleDefaultRadios(a),arangoHelper.createTooltips(),this.checkRoot()},checkRoot:function(){ -"root"===this.currentUser.get("user")&&$("#_system-db #___-collection input").attr("disabled","true")},styleDefaultRadios:function(a,b){var c=this,d=function(a){$(".db-row input").css("box-shadow","none");var b="rgba(0, 0, 0, 0.3) 0px 1px 4px 4px";_.each(a,function(a,c){if(a.collections){var d=a.collections["*"];_.each(a.collections,function(a,e){"_"!==e.charAt(0)&&"*"!==e.charAt(0)&&"undefined"===a&&("rw"===d?$("#"+c+"-db #"+e+"-collection .readWrite").css("box-shadow",b):"ro"===d?$("#"+c+"-db #"+e+"-collection .readOnly").css("box-shadow",b):"none"===d&&$("#"+c+"-db #"+e+"-collection .noAccess").css("box-shadow",b))})}})};if(b){var e=arangoHelper.databaseUrl("/_api/user/"+encodeURIComponent(c.currentUser.get("user"))+"/database?full=true");$.ajax({type:"GET",url:e,contentType:"application/json",success:function(a){d(a.result)},error:function(a){arangoHelper.arangoError("User","Could not fetch user permissions")}})}else d(a);window.modalView.hide()},breadcrumb:function(){var a=this;window.App.naviView?($("#subNavigationBar .breadcrumb").html("User: "+this.currentUser.get("user")),arangoHelper.buildUserSubNav(a.currentUser.get("user"),"Permissions")):window.setTimeout(function(){a.breadcrumb()},100)}})}(),function(){"use strict";window.UserView=Backbone.View.extend({el:"#content",initialize:function(a){this.username=a.username},render:function(){var a=this;this.collection.fetch({success:function(){a.continueRender()}})},editCurrentUser:function(){this.createEditCurrentUserModal(this.currentUser.get("user"),this.currentUser.get("extra").name,this.currentUser.get("extra").img)},continueRender:function(){this.currentUser=this.collection.findWhere({user:this.username}),this.breadcrumb(),this.currentUser.get("loggedIn")?this.editCurrentUser():this.createEditUserModal(this.currentUser.get("user"),this.currentUser.get("extra").name,this.currentUser.get("active"))},createEditUserPasswordModal:function(){var a=[],b=[];b.push(window.modalView.createPasswordEntry("newCurrentPassword","New Password","",!1,"new password",!1)),b.push(window.modalView.createPasswordEntry("confirmCurrentPassword","Confirm New Password","",!1,"confirm new password",!1)),a.push(window.modalView.createSuccessButton("Save",this.submitEditUserPassword.bind(this))),window.modalView.show("modalTable.ejs","Edit User Password",a,b)},createEditCurrentUserModal:function(a,b,c){var d=[],e=[];e.push(window.modalView.createReadOnlyEntry("id_username","Username",a)),e.push(window.modalView.createTextEntry("editCurrentName","Name",b,!1,"Name",!1)),e.push(window.modalView.createTextEntry("editCurrentUserProfileImg","Gravatar account (Mail)",c,"Mailaddress or its md5 representation of your gravatar account.The address will be converted into a md5 string. Only the md5 string will be stored, not the mailaddress.","myAccount(at)gravatar.com")),":role:"===this.username.substring(0,6)?d.push(window.modalView.createDisabledButton("Change Password")):d.push(window.modalView.createNotificationButton("Change Password",this.editUserPassword.bind(this))),d.push(window.modalView.createSuccessButton("Save",this.submitEditCurrentUserProfile.bind(this))),window.modalView.show("modalTable.ejs","Edit User Profile",d,e,null,null,this.events,null,null,"content")},parseImgString:function(a){return a.indexOf("@")===-1?a:CryptoJS.MD5(a).toString()},createEditUserModal:function(a,b,c){var d,e;e=[{type:window.modalView.tables.READONLY,label:"Username",value:_.escape(a)},{type:window.modalView.tables.TEXT,label:"Name",value:b,id:"editName",placeholder:"Name"},{type:window.modalView.tables.CHECKBOX,label:"Active",value:"active",checked:c,id:"editStatus"}],d=[],d.push({title:"Delete",type:window.modalView.buttons.DELETE,callback:this.submitDeleteUser.bind(this,a)}),":role:"===this.username.substring(0,6)?d.push({title:"Change Password",type:window.modalView.buttons.DISABLED,callback:this.createEditUserPasswordModal.bind(this,a)}):d.push({title:"Change Password",type:window.modalView.buttons.NOTIFICATION,callback:this.createEditUserPasswordModal.bind(this,a)}),d.push({title:"Save",type:window.modalView.buttons.SUCCESS,callback:this.submitEditUser.bind(this,a)}),window.modalView.show("modalTable.ejs","Edit User",d,e,null,null,this.events,null,null,"content")},validateStatus:function(a){return""!==a},submitDeleteUser:function(a){var b=this.collection.findWhere({user:a});b.destroy({wait:!0}),window.App.navigate("#users",{trigger:!0})},submitEditCurrentUserProfile:function(){var a=$("#editCurrentName").val(),b=$("#editCurrentUserProfileImg").val();b=this.parseImgString(b);var c=function(a){a?arangoHelper.arangoError("User","Could not edit user settings"):(arangoHelper.arangoNotification("User","Changes confirmed."),this.updateUserProfile())}.bind(this);this.currentUser.setExtras(a,b,c),window.modalView.hide()},submitEditUserPassword:function(){var a=$("#newCurrentPassword").val(),b=$("#confirmCurrentPassword").val();$("#newCurrentPassword").val(""),$("#confirmCurrentPassword").val(""),$("#newCurrentPassword").closest("th").css("backgroundColor","white"),$("#confirmCurrentPassword").closest("th").css("backgroundColor","white");var c=!1;a!==b&&(arangoHelper.arangoError("User","New passwords do not match."),c=!0),c||(this.currentUser.setPassword(a),arangoHelper.arangoNotification("User","Password changed."),window.modalView.hide())},editUserPassword:function(){window.modalView.hide(),this.createEditUserPasswordModal()},submitEditUser:function(a){var b=$("#editName").val(),c=$("#editStatus").is(":checked");if(!this.validateStatus(c))return void $("#editStatus").closest("th").css("backgroundColor","red");var d=this.collection.findWhere({user:a});d.save({extra:{name:b},active:c},{type:"PATCH",success:function(){arangoHelper.arangoNotification("User",d.get("user")+" updated.")},error:function(){arangoHelper.arangoError("User","Could not update "+d.get("user")+".")}})},breadcrumb:function(){var a=this;window.App.naviView?($("#subNavigationBar .breadcrumb").html("User: "+this.username),arangoHelper.buildUserSubNav(a.currentUser.get("user"),"General")):window.setTimeout(function(){a.breadcrumb()},100)}})}(),function(){"use strict";window.WorkMonitorView=Backbone.View.extend({el:"#content",id:"#workMonitorContent",template:templateEngine.createTemplate("workMonitorView.ejs"),table:templateEngine.createTemplate("arangoTable.ejs"),initialize:function(){},events:{},tableDescription:{id:"workMonitorTable",titles:["Type","Database","Task ID","Started","Url","User","Description","Method"],rows:[],unescaped:[!1,!1,!1,!1,!1,!1,!1,!1]},render:function(){var a=this;this.$el.html(this.template.render({})),this.collection.fetch({success:function(){a.parseTableData(),$(a.id).append(a.table.render({content:a.tableDescription}))}})},parseTableData:function(){var a=this;this.collection.each(function(b){if("AQL query"===b.get("type")){var c=b.get("parent");if(c)try{a.tableDescription.rows.push([b.get("type"),"(p) "+c.database,"(p) "+c.taskId,"(p) "+c.startTime,"(p) "+c.url,"(p) "+c.user,b.get("description"),"(p) "+c.method])}catch(d){console.log("some parse error")}}else"thread"!==b.get("type")&&a.tableDescription.rows.push([b.get("type"),b.get("database"),b.get("taskId"),b.get("startTime"),b.get("url"),b.get("user"),b.get("description"),b.get("method")])})}})}(),function(){"use strict";window.Router=Backbone.Router.extend({toUpdate:[],dbServers:[],isCluster:void 0,lastRoute:void 0,routes:{"":"cluster",dashboard:"dashboard",collections:"collections","new":"newCollection",login:"login","collection/:colid/documents/:pageid":"documents","cIndices/:colname":"cIndices","cSettings/:colname":"cSettings","cInfo/:colname":"cInfo","collection/:colid/:docid":"document",shell:"shell",queries:"query",workMonitor:"workMonitor",databases:"databases",settings:"databases",services:"applications","service/:mount":"applicationDetail",graphs:"graphManagement","graphs/:name":"showGraph",users:"userManagement","user/:name":"userView","user/:name/permission":"userPermission",userProfile:"userProfile",cluster:"cluster",nodes:"nodes",shards:"shards","node/:name":"node","nodeInfo/:id":"nodeInfo",logs:"logger",helpus:"helpUs","graph/:name":"graph","graph/:name/settings":"graphSettings",support:"support"},execute:function(a,b){"#queries"===this.lastRoute&&(this.queryView.removeInputEditors(),this.queryView.cleanupGraphs(),this.queryView.removeResults()),this.lastRoute&&("#collection"===this.lastRoute.substr(0,11)&&3===this.lastRoute.split("/").length&&this.documentView.cleanupEditor(),"#dasboard"!==this.lastRoute&&"#node"!==window.location.hash.substr(0,5)||d3.selectAll("svg > *").remove(),"#logger"===this.lastRoute&&(this.loggerView.logLevelView&&this.loggerView.logLevelView.remove(),this.loggerView.logTopicView&&this.loggerView.logTopicView.remove())),this.lastRoute=window.location.hash,$("#subNavigationBar .breadcrumb").html(""),$("#subNavigationBar .bottom").html(""),$("#loadingScreen").hide(),$("#content").show(),a&&a.apply(this,b),this.graphViewer&&this.graphViewer.graphSettingsView&&this.graphViewer.graphSettingsView.hide(),this.queryView&&this.queryView.graphViewer&&this.queryView.graphViewer.graphSettingsView&&this.queryView.graphViewer.graphSettingsView.hide()},listenerFunctions:{},listener:function(a){_.each(window.App.listenerFunctions,function(b,c){b(a)})},checkUser:function(){var a=this;if("#login"!==window.location.hash){var b=function(){this.initOnce(),$(".bodyWrapper").show(),$(".navbar").show()}.bind(this),c=function(c,d){frontendConfig.authenticationEnabled?(a.currentUser=d,c||null===d?"#login"!==window.location.hash&&this.navigate("login",{trigger:!0}):b()):b()}.bind(this);frontendConfig.authenticationEnabled?this.userCollection.whoAmI(c):(this.initOnce(),$(".bodyWrapper").show(),$(".navbar").show())}},waitForInit:function(a,b,c){this.initFinished?(b||a(!0),b&&!c&&a(b,!0),b&&c&&a(b,c,!0)):setTimeout(function(){b||a(!1),b&&!c&&a(b,!1),b&&c&&a(b,c,!1)},350)},initFinished:!1,initialize:function(){frontendConfig.isCluster===!0&&(this.isCluster=!0),document.addEventListener("keyup",this.listener,!1),window.modalView=new window.ModalView,this.foxxList=new window.FoxxCollection,window.foxxInstallView=new window.FoxxInstallView({collection:this.foxxList}),window.progressView=new window.ProgressView;var a=this;this.userCollection=new window.ArangoUsers,this.initOnce=function(){this.initOnce=function(){};var b=function(b,c){a=this,c===!0&&a.coordinatorCollection.fetch({success:function(){a.fetchDBS()}}),b&&console.log(b)}.bind(this);window.isCoordinator(b),frontendConfig.isCluster===!1&&(this.initFinished=!0),this.arangoDatabase=new window.ArangoDatabase,this.currentDB=new window.CurrentDatabase,this.arangoCollectionsStore=new window.ArangoCollections,this.arangoDocumentStore=new window.ArangoDocument,this.coordinatorCollection=new window.ClusterCoordinators,arangoHelper.setDocumentStore(this.arangoDocumentStore),this.arangoCollectionsStore.fetch({cache:!1}),window.spotlightView=new window.SpotlightView({collection:this.arangoCollectionsStore}),this.footerView=new window.FooterView({collection:a.coordinatorCollection}),this.notificationList=new window.NotificationCollection,this.currentDB.fetch({cache:!1,success:function(){a.naviView=new window.NavigationView({database:a.arangoDatabase,currentDB:a.currentDB,notificationCollection:a.notificationList,userCollection:a.userCollection,isCluster:a.isCluster}),a.naviView.render()}}),this.queryCollection=new window.ArangoQueries,this.footerView.render(),window.checkVersion(),this.userConfig=new window.UserConfig,this.userConfig.fetch(),this.documentsView=new window.DocumentsView({collection:new window.ArangoDocuments,documentStore:this.arangoDocumentStore,collectionsStore:this.arangoCollectionsStore}),arangoHelper.initSigma()}.bind(this),$(window).resize(function(){a.handleResize()}),$(window).scroll(function(){})},handleScroll:function(){$(window).scrollTop()>50?($(".navbar > .secondary").css("top",$(window).scrollTop()),$(".navbar > .secondary").css("position","absolute"),$(".navbar > .secondary").css("z-index","10"),$(".navbar > .secondary").css("width",$(window).width())):($(".navbar > .secondary").css("top","0"),$(".navbar > .secondary").css("position","relative"),$(".navbar > .secondary").css("width",""))},cluster:function(a){return this.checkUser(),a?this.isCluster===!1||void 0===this.isCluster?void("_system"===this.currentDB.get("name")?(this.routes[""]="dashboard",this.navigate("#dashboard",{trigger:!0})):(this.routes[""]="collections",this.navigate("#collections",{trigger:!0}))):(this.clusterView||(this.clusterView=new window.ClusterView({coordinators:this.coordinatorCollection,dbServers:this.dbServers})),void this.clusterView.render()):void this.waitForInit(this.cluster.bind(this))},node:function(a,b){return this.checkUser(),b&&void 0!==this.isCluster?this.isCluster===!1?(this.routes[""]="dashboard",void this.navigate("#dashboard",{trigger:!0})):(this.nodeView&&this.nodeView.remove(),this.nodeView=new window.NodeView({coordid:a,coordinators:this.coordinatorCollection,dbServers:this.dbServers}),void this.nodeView.render()):void this.waitForInit(this.node.bind(this),a)},nodeInfo:function(a,b){return this.checkUser(),b&&void 0!==this.isCluster?this.isCluster===!1?(this.routes[""]="dashboard",void this.navigate("#dashboard",{trigger:!0})):(this.nodeInfoView&&this.nodeInfoView.remove(),this.nodeInfoView=new window.NodeInfoView({nodeId:a,coordinators:this.coordinatorCollection,dbServers:this.dbServers[0]}),void this.nodeInfoView.render()):void this.waitForInit(this.nodeInfo.bind(this),a)},shards:function(a){return this.checkUser(),a&&void 0!==this.isCluster?this.isCluster===!1?(this.routes[""]="dashboard",void this.navigate("#dashboard",{trigger:!0})):(this.shardsView&&this.shardsView.remove(),this.shardsView=new window.ShardsView({dbServers:this.dbServers}),void this.shardsView.render()):void this.waitForInit(this.shards.bind(this))},nodes:function(a){return this.checkUser(),a&&void 0!==this.isCluster?this.isCluster===!1?(this.routes[""]="dashboard",void this.navigate("#dashboard",{trigger:!0})):(this.nodesView&&this.nodesView.remove(),this.nodesView=new window.NodesView({}),void this.nodesView.render()):void this.waitForInit(this.nodes.bind(this))},cNodes:function(a){return this.checkUser(),a&&void 0!==this.isCluster?this.isCluster===!1?(this.routes[""]="dashboard",void this.navigate("#dashboard",{trigger:!0})):(this.nodesView=new window.NodesView({coordinators:this.coordinatorCollection,dbServers:this.dbServers[0],toRender:"coordinator"}),void this.nodesView.render()):void this.waitForInit(this.cNodes.bind(this))},dNodes:function(a){return this.checkUser(),a&&void 0!==this.isCluster?this.isCluster===!1?(this.routes[""]="dashboard",void this.navigate("#dashboard",{trigger:!0})):0===this.dbServers.length?void this.navigate("#cNodes",{trigger:!0}):(this.nodesView=new window.NodesView({coordinators:this.coordinatorCollection,dbServers:this.dbServers[0],toRender:"dbserver"}),void this.nodesView.render()):void this.waitForInit(this.dNodes.bind(this))},sNodes:function(a){return this.checkUser(),a&&void 0!==this.isCluster?this.isCluster===!1?(this.routes[""]="dashboard",void this.navigate("#dashboard",{trigger:!0})):(this.scaleView=new window.ScaleView({coordinators:this.coordinatorCollection,dbServers:this.dbServers[0]}),void this.scaleView.render()):void this.waitForInit(this.sNodes.bind(this))},addAuth:function(a){var b=this.clusterPlan.get("user");if(!b)return a.abort(),void(this.isCheckingUser||this.requestAuth());var c=b.name,d=b.passwd,e=c.concat(":",d);a.setRequestHeader("Authorization","Basic "+btoa(e))},logger:function(a,b){if(this.checkUser(),!b)return void this.waitForInit(this.logger.bind(this),a);if(!this.loggerView){var c=new window.ArangoLogs({upto:!0,loglevel:4});this.loggerView=new window.LoggerView({collection:c})}this.loggerView.render()},applicationDetail:function(a,b){if(this.checkUser(),!b)return void this.waitForInit(this.applicationDetail.bind(this),a);var c=function(){this.hasOwnProperty("applicationDetailView")&&this.applicationDetailView.remove(),this.applicationDetailView=new window.ApplicationDetailView({model:this.foxxList.get(decodeURIComponent(a))}),this.applicationDetailView.model=this.foxxList.get(decodeURIComponent(a)),this.applicationDetailView.render("swagger")}.bind(this);0===this.foxxList.length?this.foxxList.fetch({cache:!1,success:function(){c()}}):c()},login:function(){var a=function(a,b){this.loginView||(this.loginView=new window.LoginView({collection:this.userCollection})),a||null===b?this.loginView.render():this.loginView.render(!0)}.bind(this);this.userCollection.whoAmI(a)},collections:function(a){if(this.checkUser(),!a)return void this.waitForInit(this.collections.bind(this));var b=this;this.collectionsView&&this.collectionsView.remove(),this.collectionsView=new window.CollectionsView({collection:this.arangoCollectionsStore}),this.arangoCollectionsStore.fetch({cache:!1,success:function(){b.collectionsView.render()}})},cIndices:function(a,b){var c=this;return this.checkUser(),b?void this.arangoCollectionsStore.fetch({cache:!1,success:function(){c.indicesView=new window.IndicesView({collectionName:a,collection:c.arangoCollectionsStore.findWhere({name:a})}),c.indicesView.render()}}):void this.waitForInit(this.cIndices.bind(this),a)},cSettings:function(a,b){var c=this;return this.checkUser(),b?void this.arangoCollectionsStore.fetch({cache:!1,success:function(){c.settingsView=new window.SettingsView({collectionName:a,collection:c.arangoCollectionsStore.findWhere({name:a})}),c.settingsView.render()}}):void this.waitForInit(this.cSettings.bind(this),a)},cInfo:function(a,b){var c=this;return this.checkUser(),b?void this.arangoCollectionsStore.fetch({cache:!1,success:function(){c.infoView=new window.InfoView({collectionName:a,collection:c.arangoCollectionsStore.findWhere({name:a})}),c.infoView.render()}}):void this.waitForInit(this.cInfo.bind(this),a)},documents:function(a,b,c){return this.checkUser(),c?(this.documentsView&&this.documentsView.unbindEvents(),this.documentsView||(this.documentsView=new window.DocumentsView({collection:new window.ArangoDocuments,documentStore:this.arangoDocumentStore,collectionsStore:this.arangoCollectionsStore})),this.documentsView.setCollectionId(a,b),this.documentsView.render(),void this.documentsView.delegateEvents()):void this.waitForInit(this.documents.bind(this),a,b)},document:function(a,b,c){if(this.checkUser(),!c)return void this.waitForInit(this.document.bind(this),a,b);var d;this.documentView&&(this.documentView.defaultMode&&(d=this.documentView.defaultMode),this.documentView.remove()),this.documentView=new window.DocumentView({collection:this.arangoDocumentStore}),this.documentView.colid=a,this.documentView.defaultMode=d;var e=window.location.hash.split("/")[2],f=(e.split("%").length-1)%3;decodeURI(e)!==e&&0!==f&&(e=decodeURIComponent(e)),this.documentView.docid=e,this.documentView.render();var g=function(a,b){a?console.log("Error","Could not fetch collection type"):this.documentView.setType()}.bind(this);arangoHelper.collectionApiType(a,null,g)},query:function(a){return this.checkUser(),a?(this.queryView||(this.queryView=new window.QueryView({collection:this.queryCollection})),void this.queryView.render()):void this.waitForInit(this.query.bind(this))},graph:function(a,b){return this.checkUser(),b?(this.graphViewer&&(this.graphViewer.graphSettingsView&&this.graphViewer.graphSettingsView.remove(),this.graphViewer.killCurrentGraph(),this.graphViewer.unbind(),this.graphViewer.remove()),this.graphViewer=new window.GraphViewer({name:a,documentStore:this.arangoDocumentStore,collection:new window.GraphCollection,userConfig:this.userConfig}),void this.graphViewer.render()):void this.waitForInit(this.graph.bind(this),a)},graphSettings:function(a,b){return this.checkUser(),b?(this.graphSettingsView&&this.graphSettingsView.remove(),this.graphSettingsView=new window.GraphSettingsView({name:a,userConfig:this.userConfig}),void this.graphSettingsView.render()):void this.waitForInit(this.graphSettings.bind(this),a)},helpUs:function(a){return this.checkUser(),a?(this.testView||(this.helpUsView=new window.HelpUsView({})),void this.helpUsView.render()):void this.waitForInit(this.helpUs.bind(this))},support:function(a){return this.checkUser(),a?(this.testView||(this.supportView=new window.SupportView({})),void this.supportView.render()):void this.waitForInit(this.support.bind(this))},workMonitor:function(a){return this.checkUser(),a?(this.workMonitorCollection||(this.workMonitorCollection=new window.WorkMonitorCollection),this.workMonitorView||(this.workMonitorView=new window.WorkMonitorView({collection:this.workMonitorCollection})),void this.workMonitorView.render()):void this.waitForInit(this.workMonitor.bind(this))},queryManagement:function(a){return this.checkUser(),a?(this.queryManagementView||(this.queryManagementView=new window.QueryManagementView({collection:void 0})),void this.queryManagementView.render()):void this.waitForInit(this.queryManagement.bind(this))},databases:function(a){if(this.checkUser(),!a)return void this.waitForInit(this.databases.bind(this));var b=function(a){a?(arangoHelper.arangoError("DB","Could not get list of allowed databases"),this.navigate("#",{trigger:!0}),$("#databaseNavi").css("display","none"),$("#databaseNaviSelect").css("display","none")):(this.databaseView&&this.databaseView.remove(),this.databaseView=new window.DatabaseView({users:this.userCollection,collection:this.arangoDatabase}),this.databaseView.render())}.bind(this);arangoHelper.databaseAllowed(b)},dashboard:function(a){return this.checkUser(),a?(void 0===this.dashboardView&&(this.dashboardView=new window.DashboardView({dygraphConfig:window.dygraphConfig,database:this.arangoDatabase})),void this.dashboardView.render()):void this.waitForInit(this.dashboard.bind(this))},graphManagement:function(a){return this.checkUser(),a?(this.graphManagementView&&this.graphManagementView.undelegateEvents(),this.graphManagementView=new window.GraphManagementView({collection:new window.GraphCollection,collectionCollection:this.arangoCollectionsStore}),void this.graphManagementView.render()):void this.waitForInit(this.graphManagement.bind(this))},showGraph:function(a,b){return this.checkUser(),b?void(this.graphManagementView?this.graphManagementView.loadGraphViewer(a):(this.graphManagementView=new window.GraphManagementView({collection:new window.GraphCollection,collectionCollection:this.arangoCollectionsStore}),this.graphManagementView.render(a,!0))):void this.waitForInit(this.showGraph.bind(this),a)},applications:function(a){return this.checkUser(),a?(void 0===this.applicationsView&&(this.applicationsView=new window.ApplicationsView({collection:this.foxxList})),void this.applicationsView.reload()):void this.waitForInit(this.applications.bind(this))},handleSelectDatabase:function(a){return this.checkUser(),a?void this.naviView.handleSelectDatabase():void this.waitForInit(this.handleSelectDatabase.bind(this))},handleResize:function(){this.dashboardView&&this.dashboardView.resize(),this.graphManagementView&&"graphs"===Backbone.history.getFragment()&&this.graphManagementView.handleResize($("#content").width()),this.queryView&&"queries"===Backbone.history.getFragment()&&this.queryView.resize(),this.naviView&&this.naviView.resize(),this.graphViewer&&Backbone.history.getFragment().indexOf("graph")>-1&&this.graphViewer.resize(),this.documentsView&&Backbone.history.getFragment().indexOf("documents")>-1&&this.documentsView.resize(),this.documentView&&Backbone.history.getFragment().indexOf("collection")>-1&&this.documentView.resize()},userPermission:function(a,b){if(this.checkUser(),b||null===b)this.userPermissionView&&this.userPermissionView.remove(),this.userPermissionView=new window.UserPermissionView({collection:this.userCollection,databases:this.arangoDatabase,username:a}),this.userPermissionView.render();else if(b===!1)return void this.waitForInit(this.userPermissionView.bind(this),a)},userView:function(a,b){this.checkUser(),b||null===b?(this.userView=new window.UserView({collection:this.userCollection,username:a}),this.userView.render()):b===!1&&this.waitForInit(this.userView.bind(this),a)},userManagement:function(a){return this.checkUser(),a?(this.userManagementView&&this.userManagementView.remove(),this.userManagementView=new window.UserManagementView({collection:this.userCollection}),void this.userManagementView.render()):void this.waitForInit(this.userManagement.bind(this))},userProfile:function(a){return this.checkUser(),a?(this.userManagementView||(this.userManagementView=new window.UserManagementView({collection:this.userCollection})),void this.userManagementView.render(!0)):void this.waitForInit(this.userProfile.bind(this))},fetchDBS:function(a){var b=this,c=!1;this.coordinatorCollection.each(function(a){b.dbServers.push(new window.ClusterServers([],{host:a.get("address")}))}),this.initFinished=!0,_.each(this.dbServers,function(b){b.fetch({success:function(){c===!1&&a&&(a(),c=!0)}})})},getNewRoute:function(a){return"http://"+a},registerForUpdate:function(a){this.toUpdate.push(a),a.updateUrl()}})}(),function(){"use strict";var a=function(a,b){var c=[];c.push(window.modalView.createSuccessButton("Download Page",function(){window.open("https://www.arangodb.com/download","_blank"),window.modalView.hide()}));var d=[],e=window.modalView.createReadOnlyEntry.bind(window.modalView);d.push(e("current","Current",a.toString())),b.major&&d.push(e("major","Major",b.major.version)),b.minor&&d.push(e("minor","Minor",b.minor.version)),b.bugfix&&d.push(e("bugfix","Bugfix",b.bugfix.version)),window.modalView.show("modalTable.ejs","New Version Available",c,d)};window.checkVersion=function(){$.ajax({type:"GET",cache:!1,url:arangoHelper.databaseUrl("/_api/version"),contentType:"application/json",processData:!1,async:!0,success:function(b){var c=window.versionHelper.fromString(b.version);$(".navbar #currentVersion").html(b.version.substr(0,7)+''),window.parseVersions=function(b){return _.isEmpty(b)?void $("#currentVersion").addClass("up-to-date"):($("#currentVersion").addClass("out-of-date"),$("#currentVersion .fa").removeClass("fa-check-circle").addClass("fa-exclamation-circle"),void $("#currentVersion").click(function(){a(c,b)}))},$.ajax({type:"GET",async:!0,crossDomain:!0,timeout:3e3,dataType:"jsonp",url:"https://www.arangodb.com/repositories/versions.php?jsonp=parseVersions&version="+encodeURIComponent(c.toString())})}})}}(),function(){"use strict";window.hasOwnProperty("TEST_BUILD")||($(document).ajaxSend(function(a,b,c){var d=window.arangoHelper.getCurrentJwt();d&&b.setRequestHeader("Authorization","bearer "+d)}),$.ajaxSetup({error:function(a,b,c){401===a.status&&arangoHelper.checkJwt()}}),$(document).ready(function(){window.App=new window.Router,Backbone.history.start(),window.App.handleResize()}),$(document).click(function(a){a.stopPropagation(),$(a.target).hasClass("subBarDropdown")||$(a.target).hasClass("dropdown-header")||$(a.target).hasClass("dropdown-footer")||$(a.target).hasClass("toggle")||$("#userInfo").is(":visible")&&$(".subBarDropdown").hide()}))}(); \ No newline at end of file +j&&0!==j.length||(j=[{collection:"",from:"",to:""}]),k=a.get("orphanCollections"),f.push(window.modalView.createReadOnlyEntry("editGraphName","Name",i,"The name to identify the graph. Has to be unique")),b&&f.push(window.modalView.createReadOnlyEntry("smartGraphAttribute","Smart Graph Attribute",a.get("smartGraphAttribute"),"The attribute name that is used to smartly shard the vertices of a graph. \nEvery vertex in this Graph has to have this attribute. \n")),a.get("numberOfShards")&&f.push(window.modalView.createReadOnlyEntry("numberOfShards","Shards",a.get("numberOfShards"),"Number of shards the graph is using.")),a.get("replicationFactor")&&f.push(window.modalView.createReadOnlyEntry("replicationFactor","Replication factor",a.get("replicationFactor"),"Total number of copies of the data in the cluster.")),d.push(window.modalView.createDeleteButton("Delete",this.deleteGraph.bind(this))),d.push(window.modalView.createNotificationButton("Reset display settings",this.resetDisplaySettings.bind(this))),d.push(window.modalView.createSuccessButton("Save",this.saveEditedGraph.bind(this)))):(c="Create Graph",f.push(window.modalView.createTextEntry("createNewGraphName","Name","","The name to identify the graph. Has to be unique.","graphName",!0)),d.push(window.modalView.createSuccessButton("Create",this.createNewGraph.bind(this)))),j.forEach(function(b){frontendConfig.isEnterprise===!0&&frontendConfig.isCluster&&(f.push(window.modalView.createTextEntry("new-numberOfShards","Shards*","","Number of shards the smart graph is using.","",!1,[{rule:Joi.string().allow("").optional().regex(/^[0-9]*$/),msg:"Must be a number."}])),f.push(window.modalView.createTextEntry("new-replicationFactor","Replication factor","","Numeric value. Must be at least 1. Total number of copies of the data in the cluster.","",!1,[{rule:Joi.string().allow("").optional().regex(/^[0-9]*$/),msg:"Must be a number."}])),f.push(window.modalView.createTextEntry("new-smartGraphAttribute","Smart Graph Attribute*","","The attribute name that is used to smartly shard the vertices of a graph. \nEvery vertex in this Graph has to have this attribute. \nCannot be modified later.","",!1,[{rule:Joi.string().allow("").optional(),msg:"Must be a string."}]))),frontendConfig.isCluster&&!a&&(f.push(window.modalView.createTextEntry("general-numberOfShards","Shards","","Number of shards the graph is using.","",!1,[{rule:Joi.string().allow("").optional().regex(/^[0-9]*$/),msg:"Must be a number."}])),f.push(window.modalView.createTextEntry("general-replicationFactor","Replication factor","","Numeric value. Must be at least 1. Total number of copies of the data in the cluster.","",!1,[{rule:Joi.string().allow("").optional().regex(/^[0-9]*$/),msg:"Must be a number."}]))),0===h.counter?(b.collection&&(h.removedECollList.push(b.collection),h.eCollList.splice(h.eCollList.indexOf(b.collection),1)),f.push(window.modalView.createSelect2Entry("newEdgeDefinitions"+h.counter,"Edge definitions",b.collection,"An edge definition defines a relation of the graph","Edge definitions",!0,!1,!0,1,h.eCollList.sort(l)))):f.push(window.modalView.createSelect2Entry("newEdgeDefinitions"+h.counter,"Edge definitions",b.collection,"An edge definition defines a relation of the graph","Edge definitions",!1,!0,!1,1,h.eCollList.sort(l))),f.push(window.modalView.createSelect2Entry("fromCollections"+h.counter,"fromCollections",b.from,"The collections that contain the start vertices of the relation.","fromCollections",!0,!1,!1,null,e.sort(l))),f.push(window.modalView.createSelect2Entry("toCollections"+h.counter,"toCollections",b.to,"The collections that contain the end vertices of the relation.","toCollections",!0,!1,!1,null,e.sort(l))),h.counter++}),f.push(window.modalView.createSelect2Entry("newVertexCollections","Vertex collections",k,"Collections that are part of a graph but not used in an edge definition","Vertex Collections",!1,!1,!1,null,e.sort(l))),window.modalView.show("modalGraphTable.ejs",c,d,f,void 0,void 0,this.events),$("#tab-createGraph").parent().hasClass("active")&&h.hideSmartGraphOptions(),a){$(".modal-body table").css("border-collapse","separate");var m;for($(".modal-body .spacer").remove(),m=0;m<=this.counter;m++)$("#row_fromCollections"+m).show(),$("#row_toCollections"+m).show(),$("#row_newEdgeDefinitions"+m).addClass("first"),$("#row_fromCollections"+m).addClass("middle"),$("#row_toCollections"+m).addClass("last"),$("#row_toCollections"+m).after('');$("#graphTab").hide(),$("#modal-dialog .modal-delete-confirmation").append('
')}},resetDisplaySettings:function(){var a=$("#editGraphName").val(),b=new window.GraphSettingsView({name:a,userConfig:window.App.userConfig});b.setDefaults(!0,!0),b.remove(),window.modalView.hide(),arangoHelper.arangoNotification("Graph","Reset successful.")},addRemoveDefinition:function(a){var b=[],c=this.options.collectionCollection.models;c.forEach(function(a){a.get("isSystem")||b.push(a.id)}),a.stopPropagation();var d,e=$(a.currentTarget).attr("id");if(e.indexOf("addAfter_newEdgeDefinitions")===-1)e.indexOf("remove_newEdgeDefinitions")!==-1&&(d=e.split("remove_newEdgeDefinitions")[1],$("#row_newEdgeDefinitions"+d).remove(),$("#row_fromCollections"+d).remove(),$("#row_toCollections"+d).remove(),$("#spacer"+d).remove());else{this.counter++,$("#row_newVertexCollections").before(this.edgeDefintionTemplate.render({number:this.counter})),$("#newEdgeDefinitions"+this.counter).select2({tags:this.eCollList,showSearchBox:!1,minimumResultsForSearch:-1,width:"336px",maximumSelectionSize:1}),$("#fromCollections"+this.counter).select2({tags:b,showSearchBox:!1,minimumResultsForSearch:-1,width:"336px"}),$("#toCollections"+this.counter).select2({tags:b,showSearchBox:!1,minimumResultsForSearch:-1,width:"336px"}),window.modalView.undelegateEvents(),window.modalView.delegateEvents(this.events);var f;for($(".modal-body .spacer").remove(),f=0;f<=this.counter;f++)$("#row_fromCollections"+f).show(),$("#row_toCollections"+f).show(),$("#row_newEdgeDefinitions"+f).addClass("first"),$("#row_fromCollections"+f).addClass("middle"),$("#row_toCollections"+f).addClass("last"),$("#row_toCollections"+f).after('')}},calculateEdgeDefinitionMap:function(){var a={};return this.collection.models.forEach(function(b){b.get("edgeDefinitions").forEach(function(b){a[b.collection]={from:b.from,to:b.to}})}),a}})}(),function(){"use strict";window.GraphSettingsView=Backbone.View.extend({el:"#graphSettingsContent",remove:function(){return this.$el.empty().off(),this.stopListening(),this},general:{graph:{type:"divider",name:"Graph"},nodeStart:{type:"string",name:"Startnode",desc:"A valid node id or space seperated list of id's. If empty, a random node will be chosen.",value:2},layout:{type:"select",name:"Layout",desc:"Different graph algorithms. No overlap is very fast (more than 5000 nodes), force is slower (less than 5000 nodes) and fruchtermann is the slowest (less than 500 nodes).",noverlap:{name:"No overlap",val:"noverlap"},force:{name:"Force",val:"force"},fruchtermann:{name:"Fruchtermann",val:"fruchtermann"}},renderer:{type:"select",name:"Renderer",desc:"Canvas enables editing, WebGL is only for displaying a graph but much faster.",canvas:{name:"Canvas",val:"canvas"},webgl:{name:"WebGL (experimental)",val:"webgl"}},depth:{desc:"Search depth, starting from your start node.",type:"number",name:"Search Depth",value:2},limit:{desc:"Limit nodes count. If empty or zero, no limit is set.",type:"number",name:"Limit",value:250}},specific:{nodes:{type:"divider",name:"Nodes"},nodeLabel:{type:"string",name:"Label",desc:"Node label. Please choose a valid and available node attribute.","default":"_key"},nodeLabelByCollection:{type:"select",name:"Add Collection Name",desc:"Append collection name to the label?",yes:{name:"Yes",val:"true"},no:{name:"No",val:"false"}},nodeColorByCollection:{type:"select",name:"Color By Collections",no:{name:"No",val:"false"},yes:{name:"Yes",val:"true"},desc:"Should nodes be colorized by their collection? If enabled, node color and node color attribute will be ignored."},nodeColor:{type:"color",name:"Color",desc:"Default node color. RGB or HEX value.","default":"#2ecc71"},nodeColorAttribute:{type:"string",name:"Color Attribute",desc:"If an attribute is given, nodes will then be colorized by the attribute. This setting ignores default node color if set."},nodeSizeByEdges:{type:"select",name:"Size By Connections",yes:{name:"Yes",val:"true"},no:{name:"No",val:"false"},desc:"Should nodes be sized by their edges count? If enabled, node sizing attribute will be ignored."},nodeSize:{type:"string",name:"Sizing Attribute",desc:"Default node size. Numeric value > 0."},edges:{type:"divider",name:"Edges"},edgeLabel:{type:"string",name:"Label",desc:"Default edge label."},edgeLabelByCollection:{type:"select",name:"Add Collection Name",desc:"Set label text by collection. If activated edge label attribute will be ignored.",yes:{name:"Yes",val:"true"},no:{name:"No",val:"false"}},edgeColorByCollection:{type:"select",name:"Color By Collections",no:{name:"No",val:"false"},yes:{name:"Yes",val:"true"},desc:"Should edges be colorized by their collection? If enabled, edge color and edge color attribute will be ignored."},edgeColor:{type:"color",name:"Color",desc:"Default edge color. RGB or HEX value.","default":"#cccccc"},edgeColorAttribute:{type:"string",name:"Color Attribute",desc:"If an attribute is given, edges will then be colorized by the attribute. This setting ignores default edge color if set."},edgeEditable:{type:"select",hide:"true",name:"Editable",yes:{name:"Yes",val:"true"},no:{name:"No",val:"false"},desc:"Should edges be editable?"},edgeType:{type:"select",name:"Type",desc:"The type of the edge",line:{name:"Line",val:"line"},arrow:{name:"Arrow",val:"arrow"},curve:{name:"Curve",val:"curve"},dotted:{name:"Dotted",val:"dotted"},dashed:{name:"Dashed",val:"dashed"},tapered:{name:"Tapered",val:"tapered"}}},template:templateEngine.createTemplate("graphSettingsView.ejs"),initialize:function(a){this.name=a.name,this.userConfig=a.userConfig,this.saveCallback=a.saveCallback,a.noDefinedGraph&&(this.noDefinedGraph=a.noDefinedGraph)},events:{"click #saveGraphSettings":"saveGraphSettings","click #restoreGraphSettings":"setDefaults","keyup #graphSettingsView input":"checkEnterKey","keyup #graphSettingsView select":"checkEnterKey",'change input[type="range"]':"saveGraphSettings",'change input[type="color"]':"checkColor","change select":"saveGraphSettings","focus #graphSettingsView input":"lastFocus","focus #graphSettingsView select":"lastFocus",'focusout #graphSettingsView input[type="text"]':"checkinput"},lastFocus:function(a){this.lastFocussed=a.currentTarget.id,this.lastFocussedValue=$(a.currentTarget).val()},checkinput:function(a){new Date-this.lastSaved>500&&a.currentTarget.id===this.lastFocussed&&this.lastFocussedValue!==$(a.currentTarget).val()&&this.saveGraphSettings()},checkEnterKey:function(a){13===a.keyCode&&this.saveGraphSettings(a)},getGraphSettings:function(a){var b=this,c=frontendConfig.db+"_"+this.name;this.userConfig.fetch({success:function(d){b.graphConfig=d.toJSON().graphs[c],a&&b.continueRender()}})},checkColor:function(){this.lastConfigChange?new Date-this.lastConfigChange>750&&this.saveGraphSettings(null,!0):this.saveGraphSettings(null,!0)},saveGraphSettings:function(a,b,c,d,e,f){var g=this,h=function(){var a=!$("#g_nodeColor").is(":disabled"),b=!$("#g_edgeColor").is(":disabled");window.App.graphViewer.updateColors(a,b,$("#g_nodeColor").val(),$("#g_edgeColor").val())};if(this.noDefinedGraph){var i;b?h():"g_layout"===a.currentTarget.id?window.App.graphViewer.rerenderAQL($("#g_layout").val(),null):"g_nodeColorByCollection"===a.currentTarget.id?(i=$("#g_nodeColorByCollection").val(),"true"===i?window.App.graphViewer.switchNodeColorByCollection(!0):window.App.graphViewer.switchNodeColorByCollection(!1)):"g_edgeColorByCollection"===a.currentTarget.id?(i=$("#g_edgeColorByCollection").val(),"true"===i?window.App.graphViewer.switchEdgeColorByCollection(!0):window.App.graphViewer.switchEdgeColorByCollection(!1)):"g_nodeSizeByEdges"===a.currentTarget.id?(i=$("#g_nodeSizeByEdges").val(),"true"===i?window.App.graphViewer.switchNodeSizeByCollection(!0):window.App.graphViewer.switchNodeSizeByCollection(!1)):"g_edgeType"===a.currentTarget.id&&window.App.graphViewer.switchEdgeType($("#g_edgeType").val())}else{g.lastSaved=new Date;var j=frontendConfig.db+"_"+this.name,k={};if(d)k[j]=d;else{var l,m={};$("#graphSettingsView select").each(function(a,b){l=b.id,m[l.substr(2,b.id.length)]=$(b).val()}),$("#graphSettingsView input").each(function(a,b){l=b.id,m[l.substr(2,b.id.length)]=$(b).val()}),k[j]=m}c&&(k[j].nodeStart=c);var n=function(){if(g.lastConfigChange=new Date,window.App.graphViewer){var c;if(a){if("g_layout"===a.currentTarget.id)return void window.App.graphViewer.switchLayout($("#g_layout").val());if("g_nodeColorByCollection"===a.currentTarget.id)return c=$("#g_nodeColorByCollection").val(),void("true"===c?window.App.graphViewer.switchNodeColorByCollection(!0):$("#g_nodeColorAttribute").is(":disabled")?window.App.graphViewer.switchNodeColorByCollection(!1):window.App.graphViewer.switchNodeColorByCollection(!1,!0));if("g_edgeColorByCollection"===a.currentTarget.id)return c=$("#g_edgeColorByCollection").val(),void("true"===c?window.App.graphViewer.switchEdgeColorByCollection(!0):$("#g_nodeColorAttribute").is(":disabled")?window.App.graphViewer.switchEdgeColorByCollection(!1):window.App.graphViewer.switchEdgeColorByCollection(!1,!0))}""!==b&&void 0!==b?h():window.App.graphViewer.render(g.lastFocussed)}else e||arangoHelper.arangoNotification("Graph "+this.name,"Configuration saved.");f&&f()}.bind(this);this.userConfig.setItem("graphs",k,n)}this.handleDependencies()},setDefaults:function(a,b,c){var d={layout:"force",renderer:"canvas",depth:"2",limit:"250",nodeColor:"#2ecc71",nodeColorAttribute:"",nodeColorByCollection:"true",edgeColor:"#cccccc",edgeColorAttribute:"",edgeColorByCollection:"false",nodeLabel:"_key",edgeLabel:"",edgeType:"arrow",nodeSize:"",nodeSizeByEdges:"true",edgeEditable:"true",nodeLabelByCollection:"false",edgeLabelByCollection:"false",nodeStart:"",barnesHutOptimize:!0};a===!0?b?this.saveGraphSettings(null,null,null,d,b,c):this.saveGraphSettings(null,null,null,d):(this.saveGraphSettings(null,null,null,d,null),this.render(),window.App.graphViewer.render(this.lastFocussed))},toggle:function(){$(this.el).is(":visible")?this.hide():this.show()},show:function(){$(this.el).show("slide",{direction:"right"},250)},hide:function(){$(this.el).hide("slide",{direction:"right"},250)},render:function(){this.noDefinedGraph?this.continueRender():(this.getGraphSettings(!0),this.lastSaved=new Date)},handleDependencies:function(){"true"===$("#g_nodeSizeByEdges").val()?$("#g_nodeSize").prop("disabled",!0):$("#g_nodeSize").removeAttr("disabled"),"true"===$("#g_nodeColorByCollection").val()?($("#g_nodeColorAttribute").prop("disabled",!0),$("#g_nodeColor").prop("disabled",!0)):($("#g_nodeColorAttribute").removeAttr("disabled"),$("#g_nodeColor").removeAttr("disabled")),this.noDefinedGraph||""!==$("#g_nodeColorAttribute").val()&&$("#g_nodeColor").prop("disabled",!0),"true"===$("#g_edgeColorByCollection").val()?($("#g_edgeColorAttribute").prop("disabled",!0),$("#g_edgeColor").prop("disabled",!0)):($("#g_edgeColorAttribute").removeAttr("disabled"),$("#g_edgeColor").removeAttr("disabled")),this.noDefinedGraph||""!==$("#g_edgeColorAttribute").val()&&$("#g_edgeColor").prop("disabled",!0)},continueRender:function(){$(this.el).html(this.template.render({general:this.general,specific:this.specific})),arangoHelper.fixTooltips(".gv-tooltips","top"),this.graphConfig?_.each(this.graphConfig,function(a,b){$("#g_"+b).val(a)}):this.noDefinedGraph?this.fitSettingsAQLMode():this.setDefaults(!0),this.handleDependencies()},fitSettingsAQLMode:function(){var a=["g_nodeStart","g_depth","g_limit","g_renderer","g_nodeLabel","g_nodeLabelByCollection","g_nodeColorAttribute","g_nodeSize","g_edgeLabel","g_edgeColorAttribute","g_edgeLabelByCollection"];_.each(a,function(a){$("#"+a).parent().prev().remove(),$("#"+a).parent().remove()}),$("#saveGraphSettings").remove(),$("#restoreGraphSettings").remove(),$("#g_nodeColorByCollection").val("false"),$("#g_edgeColorByCollection").val("false"),$("#g_nodeSizeByEdges").val("false"),$("#g_edgeType").val("arrow"),$("#g_layout").val("force")}})}(),function(){"use strict";window.GraphViewer=Backbone.View.extend({el:"#content",remove:function(){return this.$el.empty().off(),this.stopListening(),this.unbind(),delete this.el,this},template:templateEngine.createTemplate("graphViewer2.ejs"),initialize:function(a){var b=this;a.id&&(this.setElement(a.id),this.graphData=a.data,this.aqlMode=!0),a.noDefinedGraph&&(this.noDefinedGraph=a.noDefinedGraph,this.graphData=a.data),this.name=a.name,this.userConfig=a.userConfig,this.documentStore=a.documentStore,void 0!==this.name&&this.collection.fetch({cache:!1,success:function(c){b.model=b.collection.findWhere({_key:a.name}).toJSON()}})},colors:{hotaru:["#364C4A","#497C7F","#92C5C0","#858168","#CCBCA5"],random1:["#292F36","#4ECDC4","#F7FFF7","#DD6363","#FFE66D"],jans:["rgba(166, 109, 161, 1)","rgba(64, 74, 83, 1)","rgba(90, 147, 189, 1)","rgba(153,63,0,1)","rgba(76,0,92,1)","rgba(25,25,25,1)","rgba(0,92,49,1)","rgba(43,206,72,1)","rgba(255,204,153,1)","rgba(128,128,128,1)","rgba(148,255,181,1)","rgba(143,124,0,1)","rgba(157,204,0,1)","rgba(194,0,136,1)","rgba(0,51,128,1)","rgba(255,164,5,1)","rgba(255,168,187,1)","rgba(66,102,0,1)","rgba(255,0,16,1)","rgba(94,241,242,1)","rgba(0,153,143,1)","rgba(224,255,102,1)","rgba(116,10,255,1)","rgba(153,0,0,1)","rgba(255,255,128,1)","rgba(255,255,0,1)","rgba(255,80,5,1)"],gv:["#68BDF6","#6DCE9E","#FF756E","#DE9BF9","#FB95AF","#FFD86E","#A5ABB6"]},activeNodes:[],selectedNodes:{},aqlMode:!1,events:{"click #downloadPNG":"downloadPNG","click #loadFullGraph":"loadFullGraphModal","click #reloadGraph":"reloadGraph","click #settingsMenu":"toggleSettings","click #toggleForce":"toggleLayout","click #selectNodes":"toggleLasso"},cursorX:0,cursorY:0,layouting:!1,model:null,viewStates:{captureMode:!1},graphConfig:null,graphSettings:null,downloadPNG:function(){var a=parseInt($("#graph-container").width(),10);sigma.plugins.image(this.currentGraph,this.currentGraph.renderers[0],{download:!0,size:a,clip:!0,labels:!0,background:"white",zoom:!1})},loadFullGraphModal:function(){var a=[],b=[];b.push(window.modalView.createReadOnlyEntry("load-full-graph-a","Caution","Really load full graph? If no limit is set, your result set could be too big.")),a.push(window.modalView.createSuccessButton("Load full graph",this.loadFullGraph.bind(this))),window.modalView.show("modalTable.ejs","Load full graph",a,b)},loadFullGraph:function(){var a=this,b={};this.graphConfig&&(b=_.clone(this.graphConfig),delete b.layout,delete b.edgeType,delete b.renderer),b.mode="all",$.ajax({type:"GET",url:arangoHelper.databaseUrl("/_admin/aardvark/graph/"+encodeURIComponent(this.name)),contentType:"application/json",data:b,success:function(b){a.killCurrentGraph(),a.renderGraph(b)},error:function(a){console.log(a),arangoHelper.arangoError("Graph","Could not load full graph.")}}),window.modalView.hide()},resize:function(){$("#graph-container").width($(".centralContent").width()),$("#graph-container").height($(".centralRow").height()-155)},toggleSettings:function(){this.graphSettingsView.toggle()},render:function(a){this.$el.html(this.template.render({})),$("#subNavigationBar .breadcrumb").html("Graph: "+this.name),this.resize(),this.fetchGraph(a),this.initFullscreen()},initFullscreen:function(){var a=this;if(window.App.initializedFullscreen===!1||void 0===window.App.initializedFullscreen){window.App.initializedFullscreen=!0,this.isFullscreen=!1;var b=function(b){(document.webkitIsFullScreen||document.mozFullScreen||null!==document.msFullscreenElement)&&(a.isFullscreen===!1?(a.isFullscreen=!0,$("#toggleForce").css("bottom","10px"),$("#toggleForce").css("right","10px"),$("#objectCount").css("bottom","10px"),$("#objectCount").css("left","10px"),$(".nodeInfoDiv").css("top","10px"),$(".nodeInfoDiv").css("left","10px")):(a.isFullscreen=!1,$("#toggleForce").css("bottom","40px"),$("#toggleForce").css("right","40px"),$("#objectCount").css("bottom","50px"),$("#objectCount").css("left","25px"),$(".nodeInfoDiv").css("top",""),$(".nodeInfoDiv").css("left","165px")))};document.addEventListener&&(document.addEventListener("webkitfullscreenchange",b,!1),document.addEventListener("mozfullscreenchange",b,!1),document.addEventListener("fullscreenchange",b,!1),document.addEventListener("MSFullscreenChange",b,!1))}},renderAQLPreview:function(a){this.$el.html(this.template.render({})),this.$el.find(".headerBar").remove();var b=$(".centralRow").height()-250;this.$el.find("#graph-container").css("height",b),this.graphData.modified=this.parseData(this.graphData.original,this.graphData.graphInfo);var c=!1;try{this.renderGraph(this.graphData.modified,null,!0),c=!0}catch(d){}return c},renderAQL:function(a){this.$el.html(this.template.render({})),$("#subNavigationBar .breadcrumb").html("AQL Graph"),$("#subNavigationBar .bottom").html(""),$(".queries-menu").removeClass("active"),this.resize(),this.graphData.modified=this.parseData(this.graphData.original,this.graphData.graphInfo),this.renderGraph(this.graphData.modified,null,!1),this.initFullscreen(),this.graphSettingsView=new window.GraphSettingsView({name:this.name,userConfig:void 0,saveCallback:void 0,noDefinedGraph:!0}),this.graphSettingsView.render()},killCurrentGraph:function(){for(var a in this.currentGraph.renderers)try{this.currentGraph.renderers[a].clear(),this.currentGraph.kill(a)}catch(b){}},rerenderAQL:function(a,b){this.killCurrentGraph(),this.renderGraph(this.graphData.modified,null,!1,a,"canvas"),"true"===$("#g_nodeColorByCollection").val()?this.switchNodeColorByCollection(!0):$("#g_nodeColor").is(":disabled")?this.updateColors(!0,!0,null,null,!0):this.ncolor?this.updateColors(!0,!0,this.ncolor,this.ecolor):this.updateColors(!0,!0,"#2ecc71","#2ecc71"),"true"===$("#g_edgeColorByCollection").val()?this.switchEdgeColorByCollection(!0):$("#g_edgeColor").is(":disabled")?this.updateColors(!0,!0,null,null,!0):this.ecolor?this.updateColors(!0,!0,this.ncolor,this.ecolor):this.updateColors(!0,!0,"#2ecc71","#2ecc71")},buildCollectionColors:function(){var a=this;if(!a.collectionColors){a.collectionColors={};var b=0,c={},d={};_.each(this.currentGraph.graph.nodes(),function(a){c[a.id]=void 0}),_.each(a.currentGraph.graph.edges(),function(a){d[a.id]=void 0}),_.each(c,function(c,d){void 0===a.collectionColors[d.split("/")[0]]&&(a.collectionColors[d.split("/")[0]]={color:a.colors.jans[b]},b++)}),b=0,_.each(d,function(c,d){void 0===a.collectionColors[d.split("/")[0]]&&(a.collectionColors[d.split("/")[0]]={color:a.colors.jans[b]},b++)})}},switchNodeColorByCollection:function(a,b){var c=this;c.buildCollectionColors(),a?(c.currentGraph.graph.nodes().forEach(function(a){a.color=c.collectionColors[a.id.split("/")[0]].color}),c.currentGraph.refresh()):b?this.updateColors(!0,null,null,null,b):this.ncolor?this.updateColors(!0,null,this.ncolor,this.ecolor):this.updateColors(!0,null,"#2ecc71","#2ecc71")},switchEdgeColorByCollection:function(a,b){var c=this;c.buildCollectionColors(),a?(c.currentGraph.graph.edges().forEach(function(a){a.color=c.collectionColors[a.id.split("/")[0]].color}),c.currentGraph.refresh()):b?this.updateColors(!0,null,null,null,b):this.ecolor?this.updateColors(null,!0,this.ncolor,this.ecolor):this.updateColors(null,!0,"#2ecc71","#2ecc71")},buildCollectionSizes:function(){var a=this;if(!a.nodeEdgesCount){a.nodeEdgesCount={};var b={};_.each(this.currentGraph.graph.edges(),function(c){void 0===b[c.id]&&(b[c.id]=!0,void 0===a.nodeEdgesCount[c.source]?a.nodeEdgesCount[c.source]=1:a.nodeEdgesCount[c.source]+=1,void 0===a.nodeEdgesCount[c.target]?a.nodeEdgesCount[c.target]=1:a.nodeEdgesCount[c.target]+=1)})}},switchNodeSizeByCollection:function(a){var b=this;a?(b.buildCollectionSizes(),b.currentGraph.graph.nodes().forEach(function(a){a.size=b.nodeEdgesCount[a.id]})):b.currentGraph.graph.nodes().forEach(function(a){a.size=15}),b.currentGraph.refresh()},switchEdgeType:function(a){var b={nodes:this.currentGraph.graph.nodes(),edges:this.currentGraph.graph.edges(),settings:{}};this.killCurrentGraph(),this.renderGraph(b,null,!1,null,null,a)},switchLayout:function(a){var b={nodes:this.currentGraph.graph.nodes(),edges:this.currentGraph.graph.edges(),settings:{}};this.killCurrentGraph(),this.renderGraph(b,null,!1,a),"true"===$("#g_nodeColorByCollection").val()&&this.switchNodeColorByCollection(!0),"true"===$("#g_edgeColorByCollection").val()?this.switchEdgeColorByCollection(!0):this.switchEdgeColorByCollection(!1)},parseData:function(a,b){var c={},d={},e="#2ecc71",f={nodes:[],edges:[],settings:{}};if(this.ncolor&&(e=this.ncolor),"object"===b){_.each(a,function(a){a.edges&&a.vertices&&(_.each(a.edges,function(a){null!==a&&(d[a._id]={id:a._id,source:a._from,color:"#cccccc",target:a._to})}),_.each(a.vertices,function(a){null!==a&&(c[a._id]={id:a._id,label:a._key,size:.3,color:e,x:Math.random(),y:Math.random()})}))});var g=[];_.each(c,function(a){f.nodes.push(a),g.push(a.id)}),_.each(d,function(a){g.includes(a.source)&&g.includes(a.target)&&f.edges.push(a)})}else"array"===b&&(_.each(a,function(a){c[a._from]=null,c[a._to]=null,f.edges.push({id:a._id,source:a._from,color:"#cccccc",target:a._to})}),_.each(c,function(a,b){f.nodes.push({id:b,label:b,size:.3,color:e,x:Math.random(),y:Math.random()})}));return f},rerender:function(){this.fetchGraph()},fetchGraph:function(a){var b=this;$(this.el).append('
Fetching graph data. Please wait ...


If it`s taking too much time to draw the graph, please navigate to: Graphs View
Click the settings icon and reset the display settings.It is possible that the graph is too big to be handled by the browser.
');var c=function(){var c={};b.graphConfig&&(c=_.clone(b.graphConfig),delete c.layout,delete c.edgeType,delete c.renderer),b.tmpStartNode&&(b.graphConfig?0===b.graphConfig.nodeStart.length&&(c.nodeStart=b.tmpStartNode):c.nodeStart=b.tmpStartNode),b.setupSigma(),b.fetchStarted=new Date,$.ajax({type:"GET",url:arangoHelper.databaseUrl("/_admin/aardvark/graph/"+encodeURIComponent(b.name)),contentType:"application/json",data:c,success:function(c){c.empty===!0?b.renderGraph(c,a):(c.settings&&c.settings.startVertex&&void 0===b.graphConfig.startNode&&void 0===b.tmpStartNode&&(b.tmpStartNode=c.settings.startVertex._id),b.fetchFinished=new Date,b.calcStart=b.fetchFinished,$("#calcText").html("Server response took "+Math.abs(b.fetchFinished.getTime()-b.fetchStarted.getTime())+" ms. Initializing graph engine. Please wait ... "),window.setTimeout(function(){b.renderGraph(c,a)},50))},error:function(a){try{var c;if(a.responseJSON.exception){c=a.responseJSON.exception;var d=a.responseJSON.exception.search("1205");if(d!==-1){var e='Starting point: '+b.graphConfig.nodeStart+" is invalid";$("#calculatingGraph").html('
Stopped.

'+e+'. Please choose a different start node.
')}else $("#calculatingGraph").html("Failed to fetch graph information.")}else c=a.responseJSON.errorMessage,$("#calculatingGraph").html("Failed to fetch graph information: "+a.responseJSON.errorMessage);arangoHelper.arangoError("Graph",c)}catch(f){}}})};void 0===b.graphConfig||null===b.graphConfig?b.userConfig.fetch({success:function(a){var d=frontendConfig.db+"_"+b.name;try{b.graphConfig=a.toJSON().graphs[d],b.getGraphSettings(c),void 0===b.graphConfig||null===b.graphConfig?(b.graphSettingsView=new window.GraphSettingsView({name:b.name,userConfig:b.userConfig,saveCallback:b.render}),b.graphSettingsView.setDefaults(!0,!0)):(b.graphSettingsView&&b.graphSettingsView.remove(),b.graphSettingsView=new window.GraphSettingsView({name:b.name,userConfig:b.userConfig,saveCallback:b.render}))}catch(e){b.getGraphSettings(c)}}}):this.getGraphSettings(c)},setupSigma:function(){if(this.graphConfig&&this.graphConfig.edgeLabel){sigma.utils.pkg("sigma.settings");var a={defaultEdgeLabelColor:"#000",defaultEdgeLabelActiveColor:"#000",defaultEdgeLabelSize:12,edgeLabelSize:"fixed",edgeLabelThreshold:1,edgeLabelSizePowRatio:1};sigma.settings=sigma.utils.extend(sigma.settings||{},a),sigma.settings.drawEdgeLabels=!0,sigma.settings.clone=!0}},contextState:{createEdge:!1,_from:!1,_to:!1,fromX:!1,fromY:!1},clearOldContextMenu:function(a){var b=this;$("#nodeContextMenu").remove();var c='
';$("#graph-container").append(c),a&&_.each(this.contextState,function(a,c){b.contextState[c]=!1});var d=document.getElementsByClassName("sigma-mouse")[0];d.removeEventListener("mousemove",b.drawLine.bind(this),!1)},trackCursorPosition:function(a){this.cursorX=a.x,this.cursorY=a.y},deleteNode:function(a,b){var c,d,e,f=this;c=b?b:$("#delete-node-attr-id").text(),d=c.split("/")[0],e=c.split("/")[1];var g=arangoHelper.databaseUrl("/_api/gharial/"+encodeURIComponent(f.name)+"/vertex/"+encodeURIComponent(c.split("/")[0])+"/"+encodeURIComponent(c.split("/")[1]));if("yes"===$("#delete-node-edges-attr").val())$.ajax({cache:!1,type:"DELETE",contentType:"application/json",url:g,success:function(a){f.currentGraph.graph.dropNode(c),f.currentGraph.refresh()},error:function(){arangoHelper.arangoError("Graph","Could not delete node.")}});else{var h=function(a){a?arangoHelper.arangoError("Graph","Could not delete node."):(f.currentGraph.graph.dropNode(c),f.currentGraph.refresh())};this.documentStore.deleteDocument(d,e,h)}window.modalView.hide()},deleteNodes:function(){var a=this;try{var b=JSON.parse($("#delete-nodes-arr-id").text());_.each(b,function(b){a.deleteNode(null,b)})}catch(c){}},deleteNodesModal:function(){var a=[];if(_.each(this.selectedNodes,function(b){a.push(b)}),0===a.length)return void arangoHelper.arangoNotification("Graph","No nodes selected.");var b=[],c=[];c.push(window.modalView.createReadOnlyEntry("delete-nodes-arr-id","Really delete nodes",JSON.stringify(a))),b.push(window.modalView.createDeleteButton("Delete",this.deleteNodes.bind(this))),window.modalView.show("modalTable.ejs","Delete nodes",b,c)},deleteNodeModal:function(a){var b=[],c=[];c.push(window.modalView.createReadOnlyEntry("delete-node-attr-id","Really delete node",a)),this.noDefinedGraph||c.push(window.modalView.createSelectEntry("delete-node-edges-attr","Also delete edges?",void 0,void 0,[{value:"yes",label:"Yes"},{value:"no",label:"No"}])),b.push(window.modalView.createDeleteButton("Delete",this.deleteNode.bind(this))),window.modalView.show("modalTable.ejs","Delete node",b,c)},addNode:function(){var a=this,b=$(".modal-body #new-node-collection-attr").val(),c=$(".modal-body #new-node-key-attr").last().val(),d=function(b,c,d){b?arangoHelper.arangoError("Could not create node",d):($("#emptyGraph").remove(),a.currentGraph.graph.addNode({id:c,label:c.split("/")[1]||"",size:a.graphConfig.nodeSize||15,color:a.graphConfig.nodeColor||a.ncolor||"#2ecc71",originalColor:a.graphConfig.nodeColor||a.ncolor||"#2ecc71",x:a.addNodeX+a.currentGraph.camera.x,y:a.addNodeY+a.currentGraph.camera.y}),window.modalView.hide(),a.currentGraph.refresh(),a.cameraToNode(a.currentGraph.graph.nodes(c)))},e={};if(""!==c&&void 0!==c&&(e._key=c), +this.graphSettings.isSmart){var f=$("#new-smart-key-attr").val();""!==f&&void 0!==f?e[this.graphSettings.smartGraphAttribute]=f:e[this.graphSettings.smartGraphAttribute]=null}this.collection.createNode(a.name,b,e,d)},deleteEdgeModal:function(a){var b=[],c=[];c.push(window.modalView.createReadOnlyEntry("delete-edge-attr-id","Really delete edge",a)),b.push(window.modalView.createDeleteButton("Delete",this.deleteEdge.bind(this))),window.modalView.show("modalTable.ejs","Delete edge",b,c)},deleteEdge:function(){var a=this,b=$("#delete-edge-attr-id").text(),c=b.split("/")[0],d=b.split("/")[1],e=function(c){c?arangoHelper.arangoError("Graph","Could not delete edge."):(a.currentGraph.graph.dropEdge(b),a.currentGraph.refresh())};this.documentStore.deleteDocument(c,d,e),window.modalView.hide()},addNodeModal:function(){if(0!==this.graphSettings.vertexCollections){var a=[],b=[],c=[];_.each(this.graphSettings.vertexCollections,function(a){c.push({label:a.name,value:a.name})}),b.push(window.modalView.createTextEntry("new-node-key-attr","_key",void 0,"The nodes unique key(optional attribute, leave empty for autogenerated key","is optional: leave empty for autogenerated key",!1,[{rule:Joi.string().allow("").optional(),msg:""}])),this.graphSettings.isSmart&&b.push(window.modalView.createTextEntry("new-smart-key-attr",this.graphSettings.smartGraphAttribute+"*",void 0,"The attribute value that is used to smartly shard the vertices of a graph. \nEvery vertex in this Graph has to have this attribute. \nCannot be modified later.","Cannot be modified later.",!1,[{rule:Joi.string().allow("").optional(),msg:""}])),b.push(window.modalView.createSelectEntry("new-node-collection-attr","Collection",void 0,"Please select the destination for the new node.",c)),a.push(window.modalView.createSuccessButton("Create",this.addNode.bind(this))),window.modalView.show("modalTable.ejs","Create node",a,b)}else arangoHelper.arangoError("Graph","No valid vertex collections found.")},addEdge:function(){var a,b=this,c=b.contextState._from,d=b.contextState._to;a=""===$(".modal-body #new-edge-collection-attr").val()?$(".modal-body #new-edge-collection-attr").text():$(".modal-body #new-edge-collection-attr").val();var e=$(".modal-body #new-edge-key-attr").last().val(),f=function(a,e,f){if(a)arangoHelper.arangoError("Could not create edge",f);else{var g={source:c,target:d,id:e,color:b.graphConfig.edgeColor||b.ecolor};"true"===b.graphConfig.edgeEditable&&(g.size=1),b.currentGraph.graph.addEdge(g),b.graphConfig&&"curve"===b.graphConfig.edgeType&&sigma.canvas.edges.autoCurve(b.currentGraph),b.currentGraph.refresh()}b.clearOldContextMenu(!0),window.modalView.hide()},g={_from:c,_to:d};""!==e&&void 0!==e&&(g._key=e),this.collection.createEdge(b.name,a,g,f)},addEdgeModal:function(a){if(0!==a){var b=[],c=[];if(c.push(window.modalView.createTextEntry("new-edge-key-attr","_key",void 0,"The edges unique key(optional attribute, leave empty for autogenerated key","is optional: leave empty for autogenerated key",!1,[{rule:Joi.string().allow("").optional(),msg:""}])),a.length>1){var d=[];_.each(a,function(a){d.push({label:a,value:a})}),c.push(window.modalView.createSelectEntry("new-edge-collection-attr","Edge collection",void 0,"Please select the destination for the new edge.",d))}else c.push(window.modalView.createReadOnlyEntry("new-edge-collection-attr","Edge collection",a[0],"The edge collection to be used."));b.push(window.modalView.createSuccessButton("Create",this.addEdge.bind(this))),window.modalView.show("modalTable.ejs","Create edge",b,c)}else arangoHelper.arangoError("Graph","No valid edge definitions found.")},updateColors:function(a,b,c,d,e){var f=frontendConfig.db+"_"+this.name,g=this;c&&(g.ncolor=c),d&&(g.ecolor=d),this.userConfig.fetch({success:function(h){if(a===!0){g.graphConfig=h.toJSON().graphs[f];try{g.currentGraph.graph.nodes().forEach(function(a){e?a.color=a.sortColor:a.color=c})}catch(i){g.graphNotInitialized=!0,g.tmpGraphArray=[a,b,c,d]}}if(b===!0)try{g.currentGraph.graph.edges().forEach(function(a){e?a.color=a.sortColor:a.color=d})}catch(j){g.graphNotInitialized=!0,g.tmpGraphArray=[a,b,c,d]}g.currentGraph&&g.currentGraph.refresh()}})},nodesContextMenuCheck:function(a){this.nodesContextEventState=a,this.openNodesDate=new Date},createContextMenu:function(a){var b=this,c=b.cursorX-50,d=b.cursorY-50;this.clearOldContextMenu();var e=function(a){var c=wheelnav,d=new c("nodeContextMenu");d.maxPercent=1,d.wheelRadius=50,d.clockwise=!1,d.colors=b.colors.hotaru,d.multiSelect=!0,d.clickModeRotate=!1,d.slicePathFunction=slicePath().DonutSlice,d.createWheel([icon.plus,icon.arrowleft2]),d.navItems[0].selected=!1,d.navItems[0].hovered=!1,d.navItems[0].navigateFunction=function(a){b.clearOldContextMenu(),b.addNodeModal()},d.navItems[1].navigateFunction=function(a){b.clearOldContextMenu()},d.navItems[0].selected=!1,d.navItems[0].hovered=!1};$("#nodeContextMenu").css("position","fixed"),$("#nodeContextMenu").css("left",c),$("#nodeContextMenu").css("top",d),$("#nodeContextMenu").width(100),$("#nodeContextMenu").height(100),e(a)},createEdgeContextMenu:function(a,b){var c=this,d=this.cursorX-165,e=this.cursorY-120;this.clearOldContextMenu();var f=function(a,b){var d=["#364C4A","#497C7F","#92C5C0","#858168","#CCBCA5"],e=wheelnav,f=new e("nodeContextMenu");f.maxPercent=1,f.wheelRadius=50,f.clockwise=!1,f.colors=d,f.multiSelect=!0,f.clickModeRotate=!1,f.slicePathFunction=slicePath().DonutSlice,f.createWheel([icon.edit,icon.trash]),f.navItems[0].selected=!1,f.navItems[0].hovered=!1,f.navItems[0].navigateFunction=function(a){c.clearOldContextMenu(),c.editEdge(b)},f.navItems[1].navigateFunction=function(a){c.clearOldContextMenu(),c.deleteEdgeModal(b)},f.navItems[0].selected=!1,f.navItems[0].hovered=!1};$("#nodeContextMenu").css("left",d+115),$("#nodeContextMenu").css("top",e+72),$("#nodeContextMenu").width(100),$("#nodeContextMenu").height(100),f(b,a)},createNodeContextMenu:function(a,b){var c,d,e,f=this;_.each(b.data.node,function(a,b){"renderer"===b.substr(0,8)&&"x"===b.charAt(b.length-1)&&(c=a),"renderer"===b.substr(0,8)&&"y"===b.charAt(b.length-1)&&(d=a),"renderer"===b.substr(0,8)&&"e"===b.charAt(b.length-1)&&(e=a)}),void 0===c&&void 0===d&&_.each(b.data.node,function(a,b){"read_cam"===b.substr(0,8)&&"x"===b.charAt(b.length-1)&&(c=a+$("#graph-container").width()/2),"read_cam"===b.substr(0,8)&&"y"===b.charAt(b.length-1)&&(d=a+$("#graph-container").height()/2)});var g=2.5*e;g<75&&(g=75),this.clearOldContextMenu();var h=function(a,b){var e=["#364C4A","#497C7F","#92C5C0","#858168","#CCBCA5"],h=wheelnav,i=new h("nodeContextMenu");i.maxPercent=1,i.wheelRadius=g,i.clockwise=!1,i.colors=e,i.multiSelect=!1,i.clickModeRotate=!1,i.sliceHoverAttr={stroke:"#fff","stroke-width":2},i.slicePathFunction=slicePath().DonutSlice,f.noDefinedGraph?i.createWheel(["imgsrc:img/gv_edit.png","imgsrc:img/gv_trash.png"]):i.createWheel(["imgsrc:img/gv_edit.png","imgsrc:img/gv_trash.png","imgsrc:img/gv_flag.png","imgsrc:img/gv_link.png","imgsrc:img/gv_expand.png"]),$("#nodeContextMenu").addClass("animated bounceIn"),window.setTimeout(function(){i.navItems[0].navigateFunction=function(a){f.clearOldContextMenu(),f.editNode(b),f.removeHelp()},i.navItems[1].navigateFunction=function(a){f.clearOldContextMenu(),f.deleteNodeModal(b),f.removeHelp()},f.noDefinedGraph||(i.navItems[2].navigateFunction=function(a){f.clearOldContextMenu(),f.setStartNode(b),f.removeHelp()},i.navItems[3].navigateFunction=function(a){f.contextState.createEdge=!0,f.contextState._from=b,f.contextState.fromX=c,f.contextState.fromY=d;var e=document.getElementsByClassName("sigma-mouse")[0];f.drawHelp("Now click destination node, or click background to cancel."),e.addEventListener("mousemove",f.drawLine.bind(this),!1),f.clearOldContextMenu(),f.removeHelp()},i.navItems[4].navigateFunction=function(a){f.clearOldContextMenu(),f.expandNode(b),f.removeHelp()});var a=["Edit the node.","Delete node."];f.noDefinedGraph||(a.push("Set as startnode."),a.push("Draw edge."),a.push("Expand the node.")),_.each(a,function(a,b){i.navItems[b].navTitle.mouseover(function(){f.drawHelp(a)}),i.navItems[b].navTitle.mouseout(function(){f.removeHelp()})}),i.navItems[0].selected=!1,i.navItems[0].hovered=!1},300)},i=$("#graph-container").offset();$("#nodeContextMenu").width(2*g),$("#nodeContextMenu").height(2*g),$("#nodeContextMenu").css("left",c+i.left-g),$("#nodeContextMenu").css("top",d+i.top-g),h(b,a)},drawHelp:function(a){null===document.getElementById("helpTooltip")?$(this.el).append('
'+a+"
"):$("#helpTooltip span").text(a),$("#helpTooltip").show()},removeHelp:function(){$("#helpTooltip").remove()},clearMouseCanvas:function(){var a=document.getElementsByClassName("sigma-mouse")[0],b=a.getContext("2d");b.clearRect(0,0,$(a).width(),$(a).height())},expandNode:function(a){var b=this,c={};this.graphConfig&&(c=_.clone(this.graphConfig),delete c.layout,delete c.edgeType,delete c.renderer),c.query='FOR v, e, p IN 1..1 ANY "'+a+'" GRAPH "'+b.name+'" RETURN p',$.ajax({type:"GET",url:arangoHelper.databaseUrl("/_admin/aardvark/graph/"+encodeURIComponent(this.name)),contentType:"application/json",data:c,success:function(c){b.checkExpand(c,a)},error:function(b){arangoHelper.arangoError("Graph","Could not expand node: "+a+".")}}),b.removeHelp()},checkExpand:function(a,b){var c,d=this,e=a.nodes,f=a.edges,g=this.currentGraph.graph.nodes(),h=0,i=0;_.each(e,function(a){c=!1,_.each(g,function(d){c===!1&&(a.id===d.id?(d.id===b&&(d.label=d.label+" (expanded)"),c=!0):c=!1)}),c===!1&&(a.originalColor=a.color,d.currentGraph.graph.addNode(a),h++)}),_.each(f,function(a){void 0===d.currentGraph.graph.edges(a.id)&&(a.originalColor=a.color,d.currentGraph.graph.addEdge(a),i++)}),$("#nodesCount").text(parseInt($("#nodesCount").text(),10)+h),$("#edgesCount").text(parseInt($("#edgesCount").text(),10)+i),(h>0||i>0)&&("force"===d.algorithm?d.startLayout(!0,b):"fruchtermann"===d.algorithm?(sigma.layouts.fruchtermanReingold.start(d.currentGraph),d.currentGraph.refresh(),d.cameraToNode(b,1e3)):"noverlap"===d.algorithm&&d.startLayout(!0,b))},cameraToNode:function(a,b){var c=this;"string"==typeof a&&(a=c.currentGraph.graph.nodes(a));var d=function(a){sigma.misc.animation.camera(c.currentGraph.camera,{x:a.x,y:a.y},{duration:1e3})};b?window.setTimeout(function(){d(a)},b):d(a)},drawLine:function(a){var b=window.App.graphViewer.contextState;if(b.createEdge){var c=b.fromX,d=b.fromY,e=a.offsetX,f=a.offsetY,g=document.getElementsByClassName("sigma-mouse")[0],h=g.getContext("2d");h.clearRect(0,0,$(g).width(),$(g).height()),h.beginPath(),h.moveTo(c,d),h.lineTo(e,f),h.strokeStyle=this.newEdgeColor,h.stroke()}},getGraphSettings:function(a){var b=this;this.userConfig.fetch({success:function(c){var d=frontendConfig.db+"_"+b.name;b.graphConfig=c.toJSON().graphs[d],b.graphSettingsView&&b.graphSettingsView.remove(),b.graphSettingsView=new window.GraphSettingsView({name:b.name,userConfig:b.userConfig,saveCallback:b.render});var e=function(){b.graphSettingsView.render(),a&&a(b.graphConfig)};void 0===b.graphConfig?(b.graphSettingsView.setDefaults(!0,!0),b.userConfig.fetch({success:function(a){b.graphConfig=a.toJSON().graphs[d],e()}})):e()}})},setStartNode:function(a){this.graphConfig.nodeStart=a,this.graphSettingsView.saveGraphSettings(void 0,void 0,a)},editNode:function(a){var b=function(a,b){};arangoHelper.openDocEditor(a,"doc",b)},editEdge:function(a){var b=function(){};arangoHelper.openDocEditor(a,"edge",b)},reloadGraph:function(){Backbone.history.loadUrl(Backbone.history.fragment)},getEdgeDefinitionCollections:function(a,b){var c=[];return _.each(this.model.edgeDefinitions,function(d){_.each(d.from,function(e){e===a&&_.each(d.to,function(a){a===b&&c.push(d.collection)})})}),c},initializeGraph:function(a,b){a.refresh()},renderGraph:function(a,b,c,d,e,f){var g=this;this.graphSettings=a.settings;var h="#2ecc71";if(g.ncolor&&(h=g.ncolor),a.edges&&a.nodes){0===a.nodes.length&&0===a.edges.length&&a.nodes.push({id:a.settings.startVertex._id,label:a.settings.startVertex._key,size:10,color:h,x:Math.random(),y:Math.random()});var i="position: absolute; left: 25px; bottom: 50px;";this.aqlMode||$("#graph-container").append('
'+a.nodes.length+' nodes'+a.edges.length+" edges
")}this.Sigma=sigma,d?g.algorithm=d:g.algorithm="force",e?g.renderer=e:g.renderer="canvas",this.graphConfig&&(this.graphConfig.layout&&(d||(g.algorithm=this.graphConfig.layout)),this.graphConfig.renderer&&(e||(g.renderer=this.graphConfig.renderer))),"canvas"===g.renderer&&(g.isEditable=!0);var j={scalingMode:"inside",borderSize:3,defaultNodeBorderColor:"#8c8c8c",doubleClickEnabled:!1,minNodeSize:5,labelThreshold:9,maxNodeSize:15,batchEdgesDrawing:!0,minEdgeSize:1,maxEdgeSize:1,enableEdgeHovering:!0,edgeHoverColor:"#8c8c8c",defaultEdgeHoverColor:"#8c8c8c",defaultEdgeType:"arrow",edgeHoverSizeRatio:2.5,edgeHoverExtremities:!0,nodesPowRatio:.5,autoRescale:!0,mouseEnabled:!0,touchEnabled:!0,approximateLabelWidth:!0,font:"Roboto"};j.nodeHaloColor="rgba(146,197,192, 0.8)",j.nodeHaloStroke=!1,j.nodeHaloStrokeColor="#000",j.nodeHaloStrokeWidth=0,j.nodeHaloSize=25,j.nodeHaloClustering=!1,j.nodeHaloClusteringMaxRadius=1e3,j.edgeHaloColor="#fff",j.edgeHaloSize=10,j.drawHalo=!0,"canvas"===g.renderer&&(j.autoCurveSortByDirection=!0),a.nodes&&a.nodes.length>250&&(j.hideEdgesOnMove=!0),this.graphConfig&&this.graphConfig.edgeType&&(j.defaultEdgeType=this.graphConfig.edgeType),f&&(j.defaultEdgeType=f),"arrow"===j.defaultEdgeType&&(j.minArrowSize=7),c&&(g.renderer="canvas",a.nodes.length<500?g.algorithm="fruchtermann":j.scalingMode="outside",j.drawEdgeLabels=!1,j.minNodeSize=2,j.maxNodeSize=8),"webgl"===g.renderer&&(j.enableEdgeHovering=!1);var k=new this.Sigma({graph:a,container:"graph-container",renderer:{container:document.getElementById("graph-container"),type:g.renderer},settings:j});if(this.currentGraph=k,this.aqlMode||sigma.plugins.fullScreen({container:"graph-container",btnId:"graph-fullscreen-btn"}),k.graph.nodes().forEach(function(a){a.originalColor=a.color}),k.graph.edges().forEach(function(a){a.originalColor=a.color}),"noverlap"===g.algorithm){var l=k.configNoverlap({nodeMargin:.1,scaleNodes:1.05,gridSize:75,easing:"quadraticInOut",duration:1500});l.bind("start stop interpolate",function(a){"start"===a.type,"interpolate"===a.type})}else if("fruchtermann"===g.algorithm){var m=sigma.layouts.fruchtermanReingold.configure(k,{iterations:100,easing:"quadraticInOut",duration:1500});m.bind("start stop interpolate",function(a){})}if(!g.aqlMode){var n=function(a,b){if($(".nodeInfoDiv").remove(),g.contextState.createEdge===!1&&window.location.hash.indexOf("graph")>-1){var c=function(a,b,c){if(a)g.currentGraph.graph.dropNode(c),g.currentGraph.refresh();else{var d="";d+='ID '+b.documents[0]._id+"",Object.keys(b.documents[0]).length>3&&(d+='ATTRIBUTES '),_.each(b.documents[0],function(a,b){"_key"!==b&&"_id"!==b&&"_rev"!==b&&"_from"!==b&&"_to"!==b&&(d+=''+b+"")});var e='";$("#graph-container").append(e),g.isFullscreen&&($(".nodeInfoDiv").css("top","10px"),$(".nodeInfoDiv").css("left","10px")),$("#nodeInfoDiv").fadeIn("slow")}};b?g.documentStore.getDocument(a.data.node.id.split("/")[0],a.data.node.id.split("/")[1],c):g.documentStore.getDocument(a.data.edge.id.split("/")[0],a.data.edge.id.split("/")[1],c)}};k.bind("clickNode",function(a){if(g.contextState.createEdge===!0){g.clearMouseCanvas(),g.removeHelp(),g.contextState._to=a.data.node.id;var b=g.contextState._from.split("/")[0],c=g.contextState._to.split("/")[0],d=g.getEdgeDefinitionCollections(b,c);0===d.length?arangoHelper.arangoNotification("Graph","No valid edge definition found."):(g.addEdgeModal(d,g.contextState._from,g.contextState._to),g.clearOldContextMenu(!1))}else g.dragging||(g.contextState.createEdge===!0?g.newEdgeColor="#ff0000":g.newEdgeColor="#000000","canvas"===g.renderer&&g.currentGraph.renderers[0].halo({nodes:g.currentGraph.graph.nodes(),nodeHaloColor:"#DF0101",nodeHaloSize:100}),n(a,!0),g.activeNodes=[a.data.node],"canvas"===g.renderer&&k.renderers[0].halo({nodes:[a.data.node]}),g.createNodeContextMenu(a.data.node.id,a))}),g.noDefinedGraph?k.bind("clickStage",function(a){g.clearOldContextMenu(!0),g.clearMouseCanvas(),g.removeHelp()}):k.bind("clickStage",function(a){a.data.captor.isDragging?(g.clearOldContextMenu(!0),g.clearMouseCanvas()):g.contextState.createEdge===!0?(g.clearOldContextMenu(!0),g.clearMouseCanvas(),g.removeHelp()):($("#nodeContextMenu").is(":visible")?(g.clearOldContextMenu(!0),g.clearMouseCanvas()):(g.addNodeX=a.data.captor.x,g.addNodeY=a.data.captor.y,g.createContextMenu(a),g.clearMouseCanvas()),k.renderers[0].halo({nodes:g.activeNodes}))})}if("canvas"===g.renderer){this.graphConfig&&"curve"===this.graphConfig.edgeType&&sigma.canvas.edges.autoCurve(k),k.bind("clickEdge",function(a){n(a,!1)}),k.renderers[0].bind("render",function(a){k.renderers[0].halo({nodes:g.activeNodes})});var o=function(){g.nodeHighlighted=!1,g.activeNodes=[],k.graph.nodes().forEach(function(a){a.color=a.originalColor}),k.graph.edges().forEach(function(a){a.color=a.originalColor}),$(".nodeInfoDiv").remove(),k.refresh({skipIndexation:!0})};k.bind("rightClickStage",function(a){g.nodeHighlighted="undefinedid",o()}),k.bind("rightClickNode",function(a){if(g.nodeHighlighted!==a.data.node.id){var b=a.data.node.id,c=k.graph.neighbors(b);c[b]=a.data.node,k.graph.nodes().forEach(function(a){c[a.id]?a.color=a.originalColor:a.color="#eee"}),k.graph.edges().forEach(function(a){c[a.source]&&c[a.target]?a.color="rgb(64, 74, 83)":a.color="#eee"}),g.nodeHighlighted=!0,k.refresh({skipIndexation:!0})}else o()}),this.graphConfig&&this.graphConfig.edgeEditable&&k.bind("clickEdge",function(a){var b=a.data.edge.id;g.createEdgeContextMenu(b,a)})}if("noverlap"===g.algorithm)k.startNoverlap();else if("force"===g.algorithm){var p="color: rgb(64, 74, 83); cursor: pointer; position: absolute; right: 30px; bottom: 40px; z-index: 9999;";g.aqlMode&&(p="color: rgb(64, 74, 83); cursor: pointer; position: absolute; right: 30px; margin-top: 10px; margin-right: -15px"),$("#graph-container").after('
Stop layout
'),g.startLayout();var q=250,r=500;a.nodes&&(q=a.nodes.length,c?q<250?q=250:q+=r:(q<=250&&(q=500),q+=r)),a.empty&&arangoHelper.arangoNotification("Graph","Your graph is empty. Click inside the white window to create your first node."),window.setTimeout(function(){g.stopLayout()},q)}else"fruchtermann"===g.algorithm&&sigma.layouts.fruchtermanReingold.start(k);"force"!==g.algorithm&&g.reInitDragListener();var s=document.getElementsByClassName("sigma-mouse")[0];s.addEventListener("mousemove",g.trackCursorPosition.bind(this),!1),b&&($("#"+b).focus(),$("#graphSettingsContent").animate({scrollTop:$("#"+b).offset().top},2e3)),$("#calculatingGraph").fadeOut("slow"),c||g.graphConfig&&"false"===g.graphConfig.nodeSizeByEdges,g.calcFinished=new Date,a.empty===!0&&$(".sigma-background").before('The graph is empty. Please right-click to add a node.'),g.graphNotInitialized===!0&&(g.updateColors(g.tmpGraphArray),g.graphNotInitialized=!1,g.tmpGraphArray=[]),"force"===g.algorithm?$("#toggleForce").fadeIn("fast"):$("#toggleForce").fadeOut("fast")},reInitDragListener:function(){var a=this;void 0!==this.dragListener&&(sigma.plugins.killDragNodes(this.currentGraph),this.dragListener={}),this.dragListener=sigma.plugins.dragNodes(this.currentGraph,this.currentGraph.renderers[0]),this.dragListener.bind("drag",function(b){a.dragging=!0}),this.dragListener.bind("drop",function(b){window.setTimeout(function(){a.dragging=!1},400)})},keyUpFunction:function(a){var b=this;switch(a.keyCode){case 76:a.altKey&&b.toggleLasso()}},toggleLayout:function(){this.layouting?this.stopLayout():this.startLayout()},startLayout:function(a,b){var c=this;this.currentGraph.settings("drawLabels",!1),this.currentGraph.settings("drawEdgeLabels",!1),sigma.plugins.killDragNodes(this.currentGraph),a===!0&&(this.currentGraph.killForceAtlas2(),window.setTimeout(function(){c.stopLayout(),b&&c.currentGraph.refresh({skipIndexation:!0})},500)),$("#toggleForce .fa").removeClass("fa-play").addClass("fa-pause"),$("#toggleForce span").html("Stop layout"),this.layouting=!0,this.aqlMode?this.currentGraph.startForceAtlas2({worker:!0}):this.currentGraph.startForceAtlas2({worker:!0})},stopLayout:function(){$("#toggleForce .fa").removeClass("fa-pause").addClass("fa-play"),$("#toggleForce span").html("Resume layout"),this.layouting=!1,this.currentGraph.stopForceAtlas2(),this.currentGraph.settings("drawLabels",!0),this.currentGraph.settings("drawEdgeLabels",!0),this.currentGraph.refresh({skipIndexation:!0}),this.reInitDragListener()}})}(),function(){"use strict";window.HelpUsView=Backbone.View.extend({el:"#content",template:templateEngine.createTemplate("helpUsView.ejs"),render:function(){this.$el.html(this.template.render({}))}})}(),function(){"use strict";window.IndicesView=Backbone.View.extend({el:"#content",initialize:function(a){this.collectionName=a.collectionName,this.model=this.collection},template:templateEngine.createTemplate("indicesView.ejs"),events:{},render:function(){var a=this;$.ajax({type:"GET",cache:!1,url:arangoHelper.databaseUrl("/_api/engine"),contentType:"application/json",processData:!1,success:function(b){$(a.el).html(a.template.render({model:a.model,supported:b.supports.indexes})),a.breadcrumb(),window.arangoHelper.buildCollectionSubNav(a.collectionName,"Indexes"),a.getIndex(),arangoHelper.checkCollectionPermissions(a.collectionName,a.changeViewToReadOnly)},error:function(){arangoHelper.arangoNotification("Index","Could not fetch index information.")}})},changeViewToReadOnly:function(){$(".breadcrumb").html($(".breadcrumb").html()+" (read-only)"),$("#addIndex").addClass("disabled"),$("#addIndex").css("color","rgba(0,0,0,.5)"),$("#addIndex").css("cursor","not-allowed")},breadcrumb:function(){$("#subNavigationBar .breadcrumb").html("Collection: "+this.collectionName)},getIndex:function(){var a=function(a,b,c){a?window.arangoHelper.arangoError("Index",b.errorMessage):this.renderIndex(b,c)}.bind(this);this.model.getIndex(a)},createIndex:function(){var a,b,c,d,e=this,f=$("#newIndexType").val(),g={};switch(f){case"Geo":a=$("#newGeoFields").val();var h=e.checkboxToValue("#newGeoJson");g={type:"geo",fields:e.stringToArray(a),geoJson:h};break;case"Persistent":a=$("#newPersistentFields").val(),b=e.checkboxToValue("#newPersistentUnique"),c=e.checkboxToValue("#newPersistentSparse"),d=e.checkboxToValue("#newPersistentDeduplicate"),g={type:"persistent",fields:e.stringToArray(a),unique:b,sparse:c,deduplicate:d};break;case"Hash":a=$("#newHashFields").val(),b=e.checkboxToValue("#newHashUnique"),c=e.checkboxToValue("#newHashSparse"),d=e.checkboxToValue("#newHashDeduplicate"),g={type:"hash",fields:e.stringToArray(a),unique:b,sparse:c,deduplicate:d};break;case"Fulltext":a=$("#newFulltextFields").val();var i=parseInt($("#newFulltextMinLength").val(),10)||0;g={type:"fulltext",fields:e.stringToArray(a),minLength:i};break;case"Skiplist":a=$("#newSkiplistFields").val(),b=e.checkboxToValue("#newSkiplistUnique"),c=e.checkboxToValue("#newSkiplistSparse"),d=e.checkboxToValue("#newSkiplistDeduplicate"),g={type:"skiplist",fields:e.stringToArray(a),unique:b,sparse:c,deduplicate:d}}var j=function(a,b){if(a)if(b){var c=JSON.parse(b.responseText);arangoHelper.arangoError("Document error",c.errorMessage)}else arangoHelper.arangoError("Document error","Could not create index.");e.toggleNewIndexView(),e.render()};this.model.createIndex(g,j)},bindIndexEvents:function(){this.unbindIndexEvents();var a=this;$("#indexEditView #addIndex").bind("click",function(){a.toggleNewIndexView(),$("#cancelIndex").unbind("click"),$("#cancelIndex").bind("click",function(){a.toggleNewIndexView(),a.render()}),$("#createIndex").unbind("click"),$("#createIndex").bind("click",function(){a.createIndex()})}),$("#newIndexType").bind("change",function(){a.selectIndexType()}),$(".deleteIndex").bind("click",function(b){a.prepDeleteIndex(b)}),$("#infoTab a").bind("click",function(a){if($("#indexDeleteModal").remove(),"Indexes"!==$(a.currentTarget).html()||$(a.currentTarget).parent().hasClass("active")||($("#newIndexView").hide(),$("#indexEditView").show(),$("#indexHeaderContent #modal-dialog .modal-footer .button-danger").hide(),$("#indexHeaderContent #modal-dialog .modal-footer .button-success").hide(),$("#indexHeaderContent #modal-dialog .modal-footer .button-notification").hide()),"General"===$(a.currentTarget).html()&&!$(a.currentTarget).parent().hasClass("active")){$("#indexHeaderContent #modal-dialog .modal-footer .button-danger").show(),$("#indexHeaderContent #modal-dialog .modal-footer .button-success").show(),$("#indexHeaderContent #modal-dialog .modal-footer .button-notification").show();var b=$(".index-button-bar2")[0];$("#cancelIndex").is(":visible")&&($("#cancelIndex").detach().appendTo(b),$("#createIndex").detach().appendTo(b))}})},prepDeleteIndex:function(a){var b=this;this.lastTarget=a,this.lastId=$(this.lastTarget.currentTarget).parent().parent().first().children().first().text(),$("#content #modal-dialog .modal-footer").after(''),$("#indexHeaderContent #indexConfirmDelete").unbind("click"),$("#indexHeaderContent #indexConfirmDelete").bind("click",function(){$("#indexHeaderContent #indexDeleteModal").remove(),b.deleteIndex()}),$("#indexHeaderContent #indexAbortDelete").unbind("click"),$("#indexHeaderContent #indexAbortDelete").bind("click",function(){$("#indexHeaderContent #indexDeleteModal").remove()})},unbindIndexEvents:function(){$("#indexHeaderContent #indexEditView #addIndex").unbind("click"),$("#indexHeaderContent #newIndexType").unbind("change"),$("#indexHeaderContent #infoTab a").unbind("click"),$("#indexHeaderContent .deleteIndex").unbind("click")},deleteIndex:function(){var a=function(a){a?(arangoHelper.arangoError("Could not delete index"),$("tr th:contains('"+this.lastId+"')").parent().children().last().html(''),this.model.set("locked",!1)):a||void 0===a||($("tr th:contains('"+this.lastId+"')").parent().remove(),this.model.set("locked",!1))}.bind(this);this.model.set("locked",!0),this.model.deleteIndex(this.lastId,a),$("tr th:contains('"+this.lastId+"')").parent().children().last().html('')},renderIndex:function(a,b){this.index=a;var c=function(a,c){if(a)arangoHelper.arangoError("Jobs","Could not read pending jobs.");else{var d=function(a,b,c){a?404===b.responseJSON.code?arangoHelper.deleteAardvarkJob(c):400===b.responseJSON.code?(arangoHelper.arangoError("Index creation failed",b.responseJSON.errorMessage),arangoHelper.deleteAardvarkJob(c)):204===b.responseJSON.code&&arangoHelper.arangoMessage("Index","There is at least one new index in the queue or in the process of being created."):arangoHelper.deleteAardvarkJob(c)};_.each(c,function(a){a.collection===b&&$.ajax({type:"PUT",cache:!1,url:arangoHelper.databaseUrl("/_api/job/"+a.id),contentType:"application/json",success:function(b,c,e){d(!1,b,a.id)},error:function(b){d(!0,b,a.id)}})})}};arangoHelper.getAardvarkJobs(c);var d="collectionInfoTh modal-text";if(this.index){var e="",f="";_.each(this.index.indexes,function(a){f="primary"===a.type||"edge"===a.type?'':'',void 0!==a.fields&&(e=a.fields.join(", "));var b=a.id.indexOf("/"),c=a.id.substr(b+1,a.id.length),g=a.hasOwnProperty("selectivityEstimate")?(100*a.selectivityEstimate).toFixed(2)+"%":"n/a",h=a.hasOwnProperty("sparse")?a.sparse:"n/a",i=a.hasOwnProperty("deduplicate")?a.deduplicate:"n/a";$("#collectionEditIndexTable").append(""+c+""+a.type+""+a.unique+""+h+""+i+""+g+""+e+""+f+"")})}this.bindIndexEvents()},selectIndexType:function(){$(".newIndexClass").hide();var a=$("#newIndexType").val();null===a&&(a=$("#newIndexType").children().first().attr("value"),$("#newIndexType").val(a)),$("#newIndexType"+a).show()},resetIndexForms:function(){$("#indexHeader input").val("").prop("checked",!1),$("#newIndexType").val("unknown").prop("selected",!0),this.selectIndexType()},toggleNewIndexView:function(){if(!$("#addIndex").hasClass("disabled")){var a=$(".index-button-bar2")[0];$("#indexEditView").is(":visible")?($("#indexEditView").hide(),$("#newIndexView").show(),$("#cancelIndex").detach().appendTo("#indexHeaderContent #modal-dialog .modal-footer"),$("#createIndex").detach().appendTo("#indexHeaderContent #modal-dialog .modal-footer")):($("#indexEditView").show(),$("#newIndexView").hide(),$("#cancelIndex").detach().appendTo(a),$("#createIndex").detach().appendTo(a)),arangoHelper.createTooltips(".index-tooltip"),arangoHelper.fixTooltips(".icon_arangodb, .arangoicon","right"),this.resetIndexForms()}},stringToArray:function(a){var b=[];return a.split(",").forEach(function(a){a=a.replace(/(^\s+|\s+$)/g,""),""!==a&&b.push(a)}),b},checkboxToValue:function(a){return $(a).prop("checked")}})}(),function(){"use strict";window.InfoView=Backbone.View.extend({el:"#content",initialize:function(a){this.collectionName=a.collectionName,this.model=this.collection},events:{},render:function(){this.breadcrumb(),window.arangoHelper.buildCollectionSubNav(this.collectionName,"Info"),this.renderInfoView(),arangoHelper.checkCollectionPermissions(this.collectionName,this.changeViewToReadOnly)},changeViewToReadOnly:function(){$(".breadcrumb").html($(".breadcrumb").html()+" (read-only)")},breadcrumb:function(){$("#subNavigationBar .breadcrumb").html("Collection: "+this.collectionName)},renderInfoView:function(){if(this.model.get("locked"))return 0;var a=function(a,b,c){if(a)arangoHelper.arangoError("Figures","Could not get revision.");else{var d=[];frontendConfig.isCluster&&0===c.figures.alive.size&&0===c.figures.alive.count&&0===c.figures.datafiles.count&&0===c.figures.datafiles.fileSize&&0===c.figures.journals.count&&0===c.figures.journals.fileSize&&0===c.figures.compactors.count&&0===c.figures.compactors.fileSize&&0===c.figures.dead.size&&0===c.figures.dead.count&&(c.walMessage=" - not ready yet - ");var e={figures:c,revision:b,model:this.model};window.modalView.show("modalCollectionInfo.ejs","Collection: "+this.model.get("name"),d,e,null,null,null,null,null,"content")}}.bind(this),b=function(b,c){if(b)arangoHelper.arangoError("Figures","Could not get figures.");else{var d=c;this.model.getRevision(a,d)}}.bind(this);this.model.getFigures(b)}})}(),function(){"use strict";window.LoggerView=Backbone.View.extend({el:"#content",logsel:"#logEntries",id:"#logContent",initDone:!1,pageSize:20,currentPage:0,logTopics:{},logLevels:[],remove:function(){return this.$el.empty().off(),this.stopListening(),this.unbind(),delete this.el,this},initialize:function(a){ +var b=this;a&&(this.options=a),this.collection.setPageSize(this.pageSize),this.initDone||$.ajax({type:"GET",cache:!1,url:arangoHelper.databaseUrl("/_admin/log/level"),contentType:"application/json",processData:!1,success:function(a){b.logTopics=a,_.each(["fatal","error","warning","info","debug"],function(a){b.logLevels.push(a)}),b.initDone=!0}})},currentLoglevel:void 0,defaultLoglevel:"info",events:{"click #logLevelSelection":"renderLogLevel","click #logTopicSelection":"renderLogTopic","click #logFilters":"resetFilters","click #loadMoreEntries":"loadMoreEntries"},template:templateEngine.createTemplate("loggerView.ejs"),templateEntries:templateEngine.createTemplate("loggerViewEntries.ejs"),renderLogTopic:function(a){var b=this;this.logTopicOptions||(this.logTopicOptions={});var c;_.each(this.logTopics,function(a,d){b.logTopicOptions[d]&&(c=b.logTopicOptions[d].active),b.logTopicOptions[d]={name:d,active:c||!1}});var d=$(a.currentTarget).position();d.right="30",this.logTopicView=new window.FilterSelectView({name:"Topic",options:b.logTopicOptions,position:d,callback:b.logTopicCallbackFunction.bind(this),multiple:!0}),this.logTopicView.render()},loadMoreEntries:function(){this.convertModelToJSON()},logTopicCallbackFunction:function(a){this.logTopicOptions=a,this.applyFilter()},logLevelCallbackFunction:function(a){this.logLevelOptions=a,this.applyFilter()},resetFilters:function(){_.each(this.logTopicOptions,function(a){a.active=!1}),_.each(this.logLevelOptions,function(a){a.active=!1}),this.applyFilter()},isFilterActive:function(a){var b=!1;return _.each(a,function(a){a.active&&(b=!0)}),b},changeButton:function(a){a?("level"===a?($("#logLevelSelection").addClass("button-success").removeClass("button-default"),$("#logTopicSelection").addClass("button-default").removeClass("button-success"),$("#filterDesc").html(a)):"topic"===a?($("#logTopicSelection").addClass("button-success").removeClass("button-default"),$("#logLevelSelection").addClass("button-default").removeClass("button-success"),$("#filterDesc").html(a)):"both"===a&&($("#logTopicSelection").addClass("button-success").removeClass("button-default"),$("#logLevelSelection").addClass("button-success").removeClass("button-default"),$("#filterDesc").html("level, topic")),$("#logFilters").show()):($("#logTopicSelection").addClass("button-default").removeClass("button-success"),$("#logLevelSelection").addClass("button-default").removeClass("button-success"),$("#logFilters").hide(),$("#filterDesc").html(""))},applyFilter:function(){var a=this,b=this.isFilterActive(this.logLevelOptions),c=this.isFilterActive(this.logTopicOptions);b&&c?(_.each($("#logEntries").children(),function(b){a.logLevelOptions[$(b).attr("level")].active===!1||a.logTopicOptions[$(b).attr("topic")].active===!1?$(b).hide():a.logLevelOptions[$(b).attr("level")].active&&a.logTopicOptions[$(b).attr("topic")].active&&$(b).show()}),this.changeButton("both")):b&&!c?(_.each($("#logEntries").children(),function(b){a.logLevelOptions[$(b).attr("level")].active===!1?$(b).hide():$(b).show()}),this.changeButton("level")):!b&&c?(_.each($("#logEntries").children(),function(b){a.logTopicOptions[$(b).attr("topic")].active===!1?$(b).hide():$(b).show()}),this.changeButton("topic")):b||c||(_.each($("#logEntries").children(),function(a){$(a).show()}),this.changeButton());var d=0;_.each($("#logEntries").children(),function(a){"block"===$(a).css("display")&&d++}),1===d?($(".logBorder").css("visibility","hidden"),$("#noLogEntries").hide()):0===d?$("#noLogEntries").show():($(".logBorder").css("visibility","visible"),$("#noLogEntries").hide())},renderLogLevel:function(a){var b=this;this.logLevelOptions||(this.logLevelOptions={});var c;_.each(this.logLevels,function(a){b.logLevelOptions[a]&&(c=b.logLevelOptions[a].active),b.logLevelOptions[a]={name:a,active:c||!1};var d=arangoHelper.statusColors[a];d&&(b.logLevelOptions[a].color=d)});var d=$(a.currentTarget).position();d.right="115",this.logLevelView=new window.FilterSelectView({name:"Level",options:b.logLevelOptions,position:d,callback:b.logLevelCallbackFunction.bind(this),multiple:!1}),this.logLevelView.render()},setActiveLoglevel:function(a){},initTotalAmount:function(){var a=this;this.collection.fetch({data:$.param({test:!0}),success:function(){a.convertModelToJSON()}}),this.fetchedAmount=!0},invertArray:function(a){var b,c=[],d=0;for(b=a.length-1;b>=0;b--)c[d]=a[b],d++;return c},convertModelToJSON:function(){if(!this.fetchedAmount)return void this.initTotalAmount();this.collection.page=this.currentPage,this.currentPage++;var a,b=this,c=[];this.collection.fetch({success:function(d){b.collection.each(function(b){a=new Date(1e3*b.get("timestamp")),c.push({status:b.getLogStatus(),date:arangoHelper.formatDT(a),timestamp:b.get("timestamp"),msg:b.get("text"),topic:b.get("topic")})}),b.renderLogs(b.invertArray(c),d.lastInverseOffset)}})},render:function(){var a=this;return this.currentPage=0,this.initDone?($(this.el).html(this.template.render({})),this.convertModelToJSON()):window.setTimeout(function(){a.render()},100),this},renderLogs:function(a,b){_.each(a,function(a){a.msg.indexOf("{"+a.topic+"}")>-1&&(a.msg=a.msg.replace("{"+a.topic+"}",""))}),0===this.currentPage?$(this.logsel).html(this.templateEntries.render({entries:a})):$(this.logsel).append(this.templateEntries.render({entries:a})),b<=0?$("#loadMoreEntries").attr("disabled",!0):$("#loadMoreEntries").attr("disabled",!1),arangoHelper.createTooltips(),this.applyFilter()}})}(),function(){"use strict";window.LoginView=Backbone.View.extend({el:"#content",el2:".header",el3:".footer",loggedIn:!1,loginCounter:0,events:{"keyPress #loginForm input":"keyPress","click #submitLogin":"validate","submit #dbForm":"goTo","click #logout":"logout","change #loginDatabase":"renderDBS"},template:templateEngine.createTemplate("loginView.ejs"),render:function(a){var b=this;$(this.el).html(this.template.render({})),$(this.el2).hide(),$(this.el3).hide();var c=function(a,c,d){var e;e=a?arangoHelper.databaseUrl("/_api/user/"+encodeURIComponent(a)+"/database","_system"):arangoHelper.databaseUrl("/_api/database/user"),frontendConfig.authenticationEnabled===!1&&($("#logout").hide(),$(".login-window #databases").css("height","90px")),$("#loginForm").hide(),$(".login-window #databases").show(),$.ajax(e).success(function(a){$("#loginDatabase").html(""),_.each(a.result,function(a,b){frontendConfig.authenticationEnabled?$("#loginDatabase").append(""):$("#loginDatabase").append("")}),b.renderDBS()}).error(function(){c?c():location.reload(!0)})};if(frontendConfig.authenticationEnabled&&a!==!0){var d=arangoHelper.getCurrentJwtUsername();if(null!==d&&"undefined"!==d&&void 0!==d){var e=function(){b.collection.logout(),window.setTimeout(function(){$("#loginUsername").focus()},300)};c(arangoHelper.getCurrentJwtUsername(),e)}else window.setTimeout(function(){$("#loginUsername").focus()},300)}else frontendConfig.authenticationEnabled&&a?c(arangoHelper.getCurrentJwtUsername(),null,4):c(null,null,3);return $(".bodyWrapper").show(),b.checkVersion(),this},checkVersion:function(){var a=this;window.setTimeout(function(){var b,c=document.getElementById("loginSVG"),d=c.contentDocument;void 0!==frontendConfig.isEnterprise?(b=frontendConfig.isEnterprise?d.getElementById("logo-enterprise"):d.getElementById("logo-community"),b.setAttribute("visibility","visible")):a.checkVersion()},150)},clear:function(){$("#loginForm input").removeClass("form-error"),$(".wrong-credentials").hide()},keyPress:function(a){a.ctrlKey&&13===a.keyCode?(a.preventDefault(),this.validate()):a.metaKey&&13===a.keyCode&&(a.preventDefault(),this.validate())},validate:function(a){a.preventDefault(),this.clear();var b=$("#loginUsername").val(),c=$("#loginPassword").val();b&&this.collection.login(b,c,this.loginCallback.bind(this,b,c))},loginCallback:function(a,b,c){var d=this;if(c){if(0===d.loginCounter)return d.loginCounter++,void d.collection.login(a,b,this.loginCallback.bind(this,a));d.loginCounter=0,$(".wrong-credentials").show(),$("#loginDatabase").html(""),$("#loginDatabase").append("")}else d.renderDBSelection(a)},renderDBSelection:function(a){var b=this,c=arangoHelper.databaseUrl("/_api/user/"+encodeURIComponent(a)+"/database","_system");frontendConfig.authenticationEnabled===!1&&(c=arangoHelper.databaseUrl("/_api/database/user")),$(".wrong-credentials").hide(),b.loggedIn=!0,$.ajax(c).success(function(a){$("#loginForm").hide(),$(".login-window #databases").show(),$("#loginDatabase").html(""),_.each(a.result,function(a,b){frontendConfig.authenticationEnabled?$("#loginDatabase").append(""):$("#loginDatabase").append("")}),b.renderDBS()}).error(function(){$(".wrong-credentials").show()})},renderDBS:function(){if(0===$("#loginDatabase").children().length)$("#dbForm").remove(),$(".login-window #databases").prepend('
You do not have permission to a database.
');else{var a=$("#loginDatabase").val();$("#goToDatabase").html("Select DB: "+a),window.setTimeout(function(){$("#goToDatabase").focus()},300)}},logout:function(){this.collection.logout()},goTo:function(a){a.preventDefault();var b=$("#loginUsername").val(),c=$("#loginDatabase").val();window.App.dbSet=c;var d=function(a){a&&arangoHelper.arangoError("User","Could not fetch user settings")},e=window.location.protocol+"//"+window.location.host+frontendConfig.basePath+"/_db/"+c+"/_admin/aardvark/index.html";window.location.href=e,$(this.el2).show(),$(this.el3).show(),$(".bodyWrapper").show(),$(".navbar").show(),$("#currentUser").text(b),this.collection.loadUserSettings(d)}})}(),function(){"use strict";var a=function(a,b,c,d){return{type:a,title:b,callback:c,confirm:d}},b=function(a,b,c,d,e,f,g,h,i,j,k){var l={type:a,label:b};return void 0!==c&&(l.value=c),void 0!==d&&(l.info=d),void 0!==e&&(l.placeholder=e),void 0!==f&&(l.mandatory=f),void 0!==h&&(l.addDelete=h),void 0!==i&&(l.addAdd=i),void 0!==j&&(l.maxEntrySize=j),void 0!==k&&(l.tags=k),g&&(l.validateInput=function(){return g}),l};window.ModalView=Backbone.View.extend({_validators:[],_validateWatchers:[],baseTemplate:templateEngine.createTemplate("modalBase.ejs"),tableTemplate:templateEngine.createTemplate("modalTable.ejs"),el:"#modalPlaceholder",contentEl:"#modalContent",hideFooter:!1,confirm:{list:"#modal-delete-confirmation",yes:"#modal-confirm-delete",no:"#modal-abort-delete"},enabledHotkey:!1,enableHotKeys:!0,buttons:{SUCCESS:"success",NOTIFICATION:"notification",DELETE:"danger",NEUTRAL:"neutral",DISABLED:"disabled",CLOSE:"close"},tables:{READONLY:"readonly",TEXT:"text",BLOB:"blob",PASSWORD:"password",SELECT:"select",SELECT2:"select2",CHECKBOX:"checkbox"},initialize:function(){Object.freeze(this.buttons),Object.freeze(this.tables)},createModalHotkeys:function(){$(this.el).unbind("keydown"),$(this.el).unbind("return"),$(".modal-body input").unbind("keydown"),$(".modal-body input").unbind("return"),$(".modal-body input",$(this.el)).bind("keydown","return",function(){$(".createModalDialog .modal-footer .button-success").click()}),$(".modal-body select").unbind("keydown"),$(".modal-body select").unbind("return"),$(".modal-body select",$(this.el)).bind("keydown","return",function(){$(".createModalDialog .modal-footer .button-success").click()})},createInitModalHotkeys:function(){var a=this;$(this.el).bind("keydown","left",function(){a.navigateThroughButtons("left")}),$(this.el).bind("keydown","right",function(){a.navigateThroughButtons("right")})},navigateThroughButtons:function(a){var b=$(".createModalDialog .modal-footer button").is(":focus");b===!1?"left"===a?$(".createModalDialog .modal-footer button").first().focus():"right"===a&&$(".createModalDialog .modal-footer button").last().focus():b===!0&&("left"===a?$(":focus").prev().focus():"right"===a&&$(":focus").next().focus())},createCloseButton:function(b,c){var d=this;return a(this.buttons.CLOSE,b,function(){d.hide(),c&&c()})},createSuccessButton:function(b,c){return a(this.buttons.SUCCESS,b,c)},createNotificationButton:function(b,c){return a(this.buttons.NOTIFICATION,b,c)},createDeleteButton:function(b,c,d){return a(this.buttons.DELETE,b,c,d)},createNeutralButton:function(b,c){return a(this.buttons.NEUTRAL,b,c)},createDisabledButton:function(b){var c=a(this.buttons.DISABLED,b);return c.disabled=!0,c},createReadOnlyEntry:function(a,c,d,e,f,g){var h=b(this.tables.READONLY,c,d,e,void 0,void 0,void 0,f,g);return h.id=a,h},createTextEntry:function(a,c,d,e,f,g,h){var i=b(this.tables.TEXT,c,d,e,f,g,h);return i.id=a,i},createBlobEntry:function(a,c,d,e,f,g,h){var i=b(this.tables.BLOB,c,d,e,f,g,h);return i.id=a,i},createSelect2Entry:function(a,c,d,e,f,g,h,i,j,k){var l=b(this.tables.SELECT2,c,d,e,f,g,void 0,h,i,j,k);return l.id=a,l},createPasswordEntry:function(a,c,d,e,f,g,h){var i=b(this.tables.PASSWORD,c,d,e,f,g,h);return i.id=a,i},createCheckboxEntry:function(a,c,d,e,f){var g=b(this.tables.CHECKBOX,c,d,e);return g.id=a,f&&(g.checked=f),d&&(g.checked=d),g},createSelectEntry:function(a,c,d,e,f){var g=b(this.tables.SELECT,c,null,e);return g.id=a,d&&(g.selected=d),g.options=f,g},createOptionEntry:function(a,b){return{label:a,value:b||a}},show:function(a,b,c,d,e,f,g,h,i,j){var k,l,m=this,n=!1;c=c||[],h=Boolean(h),this.clearValidators(),c.length>0?(c.forEach(function(a){a.type===m.buttons.CLOSE&&(n=!0),a.type===m.buttons.DELETE&&(l=l||a.confirm)}),n||(k=c.pop(),c.push(m.createCloseButton("Cancel")),c.push(k))):c.push(m.createCloseButton("Close")),j?($("#"+j).html(this.baseTemplate.render({title:b,buttons:c,hideFooter:this.hideFooter,confirm:l,tabBar:i})),$("#"+j+" #modal-dialog").removeClass("fade hide modal"),$("#"+j+" .modal-header").remove(),$("#"+j+" .modal-tabbar").remove(),$("#"+j+" .modal-tabbar").remove(),$("#"+j+" .button-close").remove(),0===$("#"+j+" .modal-footer").children().length&&$("#"+j+" .modal-footer").remove()):$(this.el).html(this.baseTemplate.render({title:b,buttons:c,hideFooter:this.hideFooter,confirm:l,tabBar:i})),_.each(c,function(a,b){if(a.disabled||"disabled"===a.type||!a.callback)return void(j?$("#"+j+" #modalButton"+b).attr("disabled",!0):$("#modalButton"+b).attr("disabled",!0));if(a.type===m.buttons.DELETE&&!h){var c="#modalButton"+b;return j&&(c="#"+j+" #modalButton"+b),void $(c).bind("click",function(){j?($("#"+j+" "+m.confirm.yes).unbind("click"),$("#"+j+" "+m.confirm.yes).bind("click",a.callback),$("#"+j+" "+m.confirm.list).css("display","block")):($(m.confirm.yes).unbind("click"),$(m.confirm.yes).bind("click",a.callback),$(m.confirm.list).css("display","block"))})}j?$("#"+j+" #modalButton"+b).bind("click",a.callback):$("#modalButton"+b).bind("click",a.callback)}),j?$("#"+j+" "+this.confirm.no).bind("click",function(){$("#"+j+" "+m.confirm.list).css("display","none")}):$(this.confirm.no).bind("click",function(){$(m.confirm.list).css("display","none")});var o;if("string"==typeof a)o=templateEngine.createTemplate(a),j?$("#"+j+" .createModalDialog .modal-body").html(o.render({content:d,advancedContent:e,info:f})):$("#modalPlaceholder .createModalDialog .modal-body").html(o.render({content:d,advancedContent:e,info:f}));else{var p=0;_.each(a,function(a){o=templateEngine.createTemplate(a),$(".createModalDialog .modal-body .tab-content #"+i[p]).html(o.render({content:d,advancedContent:e,info:f})),p++})}arangoHelper.createTooltips(".createModalDialog .modalTooltips","left");var q=d||[];e&&e.content&&(q=q.concat(e.content)),_.each(q,function(a){if(m.modalBindValidation(a),a.type===m.tables.SELECT2){var b={tags:a.tags||[],showSearchBox:!1,minimumResultsForSearch:-1,width:"336px"};a.maxEntrySize&&(b.maximumSelectionSize=a.maxEntrySize),$("#"+a.id).select2(b)}}),g&&(this.events=g,this.delegateEvents()),$("#accordion2")&&($("#accordion2 .accordion-toggle").bind("click",function(){$("#collapseOne").is(":visible")?($("#collapseOne").hide(),setTimeout(function(){$(".accordion-toggle").addClass("collapsed")},100)):($("#collapseOne").show(),setTimeout(function(){$(".accordion-toggle").removeClass("collapsed")},100))}),$("#collapseOne").hide(),setTimeout(function(){$(".accordion-toggle").addClass("collapsed")},100)),j||$("#modal-dialog").modal("show"),this.enabledHotkey===!1&&(this.createInitModalHotkeys(),this.enabledHotkey=!0),this.enableHotKeys&&this.createModalHotkeys();var r;r=j?$("#"+j+" #modal-dialog").find("input"):$("#modal-dialog").find("input"),r&&setTimeout(function(){r=j?$("#"+j+" #modal-dialog"):$("#modal-dialog"),r.length>0&&(r=r.find("input"),r.length>0&&$(r[0]).focus())},400)},modalBindValidation:function(a){var b=this;if(a.hasOwnProperty("id")&&a.hasOwnProperty("validateInput")){var c=function(){var b=$("#"+a.id),c=a.validateInput(b),d=!1;if(_.each(c,function(a){var c=b.val();if(a.rule||(a={rule:a}),"function"==typeof a.rule)try{a.rule(c)}catch(e){d=a.msg||e.message}else{var f=Joi.validate(c,a.rule);f.error&&(d=a.msg||f.error.message)}if(d)return!1}),d)return d},d=$("#"+a.id);d.on("keyup focusout",function(){var a=c(),e=d.next()[0];a?(d.addClass("invalid-input"),e?$(e).text(a):d.after('

'+a+"

"),$(".createModalDialog .modal-footer .button-success").prop("disabled",!0).addClass("disabled")):(d.removeClass("invalid-input"),e&&$(e).remove(),b.modalTestAll())}),this._validators.push(c),this._validateWatchers.push(d)}},modalTestAll:function(){var a=_.map(this._validators,function(a){return a()}),b=_.any(a);return b?$(".createModalDialog .modal-footer .button-success").prop("disabled",!0).addClass("disabled"):$(".createModalDialog .modal-footer .button-success").prop("disabled",!1).removeClass("disabled"),!b},clearValidators:function(){this._validators=[],_.each(this._validateWatchers,function(a){a.unbind("keyup focusout")}),this._validateWatchers=[]},hide:function(){this.clearValidators(),$("#modal-dialog").modal("hide")}})}(),function(){"use strict";window.NavigationView=Backbone.View.extend({el:"#navigationBar",subEl:"#subNavigationBar",events:{"change #arangoCollectionSelect":"navigateBySelect","click .tab":"navigateByTab","click li":"switchTab","click .arangodbLogo":"selectMenuItem","mouseenter .dropdown > *":"showDropdown","click .shortcut-icons p":"showShortcutModal","mouseleave .dropdown":"hideDropdown"},renderFirst:!0,activeSubMenu:void 0,changeDB:function(){window.location.hash="#login"},initialize:function(a){var b=this;this.userCollection=a.userCollection,this.currentDB=a.currentDB,this.dbSelectionView=new window.DBSelectionView({collection:a.database,current:this.currentDB}),this.userBarView=new window.UserBarView({userCollection:this.userCollection}),this.notificationView=new window.NotificationView({collection:a.notificationCollection}),this.statisticBarView=new window.StatisticBarView({currentDB:this.currentDB}),this.isCluster=a.isCluster,this.handleKeyboardHotkeys(),Backbone.history.on("all",function(){b.selectMenuItem()})},showShortcutModal:function(){arangoHelper.hotkeysFunctions.showHotkeysModal()},handleSelectDatabase:function(){this.dbSelectionView.render($("#dbSelect"))},template:templateEngine.createTemplate("navigationView.ejs"),templateSub:templateEngine.createTemplate("subNavigationView.ejs"),render:function(){var a=this;$(this.el).html(this.template.render({currentDB:this.currentDB,isCluster:this.isCluster})),"_system"!==this.currentDB.get("name")&&$("#dashboard").parent().remove(),$(this.subEl).html(this.templateSub.render({currentDB:this.currentDB.toJSON()})),this.dbSelectionView.render($("#dbSelect"));var b=function(a){a||this.userBarView.render()}.bind(this);return this.userCollection.whoAmI(b),this.renderFirst&&(this.renderFirst=!1,this.selectMenuItem(),$(".arangodbLogo").on("click",function(){a.selectMenuItem()}),$("#dbStatus").on("click",function(){a.changeDB()})),a.resize(),window.frontendConfig.isEnterprise===!0?($("#ArangoDBLogo").after(''),$("#enterpriseLabel").fadeIn("slow")):($("#ArangoDBLogo").after(''),$("#communityLabel").fadeIn("slow"),$(".enterprise-menu").show()),this},resize:function(){var a=$(window).height()-$(".subMenuEntries").first().height();$("#navigationBar").css("min-height",a),$("#navigationBar").css("height",a)},navigateBySelect:function(){var a=$("#arangoCollectionSelect").find("option:selected").val();window.App.navigate(a,{trigger:!0})},handleKeyboardHotkeys:function(){arangoHelper.enableKeyboardHotkeys(!0)},navigateByTab:function(a){var b=a.target||a.srcElement,c=b.id,d=!1;"enterprise"!==c&&($(b).hasClass("fa")||(""===c&&(c=$(b).attr("class")),"links"===c?(d=!0,$("#link_dropdown").slideToggle(1),a.preventDefault()):"tools"===c?(d=!0,$("#tools_dropdown").slideToggle(1),a.preventDefault()):"dbselection"===c&&(d=!0,$("#dbs_dropdown").slideToggle(1),a.preventDefault()),d||(window.App.navigate(c,{trigger:!0}),a.preventDefault())))},handleSelectNavigation:function(){var a=this;$("#arangoCollectionSelect").change(function(){a.navigateBySelect()})},subViewConfig:{documents:"collections",collection:"collections"},subMenuConfig:{cluster:[{name:"Dashboard",view:void 0,active:!0},{name:"Logs",view:void 0,disabled:!0}],collections:[{name:"",view:void 0,active:!1}],queries:[{name:"Editor",route:"query",active:!0},{name:"Running Queries",route:"queryManagement",params:{active:!0},active:void 0},{name:"Slow Query History",route:"queryManagement",params:{active:!1},active:void 0}]},renderSubMenu:function(a){var b=this;if(void 0===a&&(a=window.isCluster?"cluster":"dashboard"),this.subMenuConfig[a]){$(this.subEl+" .bottom").html("");var c="";_.each(this.subMenuConfig[a],function(a){c=a.active?"active":"",a.disabled&&(c="disabled"),$(b.subEl+" .bottom").append('"),a.disabled||$(b.subEl+" .bottom").children().last().bind("click",function(c){$("#subNavigationBar .breadcrumb").html(""),b.activeSubMenu=a,b.renderSubView(a,c)})})}else $(b.subEl+" .bottom").append('