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 45717c67a2..891d950381 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 @@ -8,7 +8,7 @@ edgeDefintionTemplate:templateEngine.createTemplate("edgeDefinitionTable.ejs"),e 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(){if(this.currentGraph&&this.currentGraph.renderers)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}),b.graphSettingsView.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){this.updateNodeLabel(a)}.bind(this);arangoHelper.openDocEditor(a,"doc",b)},updateNodeLabel:function(a){var b=a[0]._id;if(this.graphConfig.nodeLabel){var c=this.currentGraph.graph.nodes(b).label;if(c!==a[0][this.graphConfig.nodeLabel]){var d=a[0]["new"][this.graphConfig.nodeLabel];"string"==typeof d?this.currentGraph.graph.nodes(b).label=d:this.currentGraph.graph.nodes(b).label=JSON.stringify(d),this.currentGraph.refresh({skipIndexation:!0})}}},editEdge:function(a){var b=function(a){this.updateEdgeLabel(a)}.bind(this);arangoHelper.openDocEditor(a,"edge",b)},updateEdgeLabel:function(a){var b=a[0]._id;if(this.graphConfig.edgeLabel){var c=this.currentGraph.graph.edges(b).label;if(c!==a[0][this.graphConfig.edgeLabel]){var d=a[0]["new"][this.graphConfig.edgeLabel];"string"==typeof d?this.currentGraph.graph.edges(b).label=d:this.currentGraph.graph.edges(b).label=JSON.stringify(d),this.currentGraph.refresh({skipIndexation:!0})}}},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(""+arangoHelper.escapeHtml(c)+""+arangoHelper.escapeHtml(a.type)+""+arangoHelper.escapeHtml(a.unique)+""+arangoHelper.escapeHtml(h)+""+arangoHelper.escapeHtml(i)+""+arangoHelper.escapeHtml(g)+""+arangoHelper.escapeHtml(e)+""+f+"")})}this.bindIndexEvents()},selectIndexType:function(){$(".newIndexClass").hide();var a=$("#newIndexType").val();null===a&&(a=$("#newIndexType").children().first().attr("value"),$("#newIndexType").val(arangoHelper.escapeHtml(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.ServiceInstallGitHubView=Backbone.View.extend({el:"#content",readOnly:!1,template:templateEngine.createTemplate("serviceInstallGitHubView.ejs"),remove:function(){return this.$el.empty().off(),this.stopListening(),this.unbind(),delete this.el,this},initialize:function(){window.App.replaceApp&&(this._upgrade=!0)},events:{"click #installGitHubService":"installGitHubService","keydown input":"checkValidators"},checkValidators:function(){1!==window.modalView._validators.length&&(window.modalView.clearValidators(),this.setGithubValidators())},render:function(){return $(this.el).html(this.template.render({services:this.collection,upgrade:this._upgrade})),this.breadcrumb(),this.setGithubValidators(),arangoHelper.createTooltips(".modalTooltips"),this},breadcrumb:function(){var a=this;if(window.App.naviView){var b="New";this._upgrade&&(b="Replace ("+window.App.replaceAppData.mount+")"),$("#subNavigationBar .breadcrumb").html('Services: '+b),arangoHelper.buildServicesSubNav("GitHub")}else window.setTimeout(function(){a.breadcrumb()},100)},installGitHubService:function(){arangoHelper.createMountPointModal(this.installFoxxFromGithub.bind(this))},installFoxxFromGithub:function(){if(window.modalView.modalTestAll()){var a,b,c,d,e;this._upgrade?(c=window.App.replaceAppData.mount,d=arangoHelper.getFoxxFlag()):(c=window.arangoHelper.escapeHtml($("#new-app-mount").val()),"/"!==c.charAt(0)&&(c="/"+c)),a=window.arangoHelper.escapeHtml($("#repository").val()),b=window.arangoHelper.escapeHtml($("#tag").val()),""===b&&(b="master");var f={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(g){return}e=Boolean($("#github-app-islegacy").prop("checked")),this.collection.installFromGithub(f,c,this.installCallback.bind(this),e,d)}},installCallback:function(a){window.App.navigate("#services",{trigger:!0}),window.App.applicationsView.installCallback(a)},setGithubValidators: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."}]}}),window.modalView.modalTestAll()}})}(),function(){"use strict";window.ServiceInstallNewView=Backbone.View.extend({el:"#content",readOnly:!1,template:templateEngine.createTemplate("serviceInstallNewView.ejs"),remove:function(){return this.$el.empty().off(),this.stopListening(),this.unbind(),delete this.el,this},events:{"click #installNewService":"installNewService","keydown input":"checkValidators"},checkValidators:function(){4!==window.modalView._validators.length&&(window.modalView.clearValidators(),this.setNewAppValidators())},initialize:function(){window.App.replaceApp&&(this._upgrade=!0)},render:function(){return $(this.el).html(this.template.render({services:this.collection,upgrade:this._upgrade})),this.renderSelects(),this.breadcrumb(),this.setNewAppValidators(),arangoHelper.createTooltips(".modalTooltips"),this},installNewService:function(){arangoHelper.createMountPointModal(this.generateNewFoxxApp.bind(this))},generateNewFoxxApp:function(){if(window.modalView.modalTestAll()){var a,b;this._upgrade?(a=window.App.replaceAppData.mount,b=arangoHelper.getFoxxFlag()):(a=window.arangoHelper.escapeHtml($("#new-app-mount").val()),"/"!==a.charAt(0)&&(a="/"+a));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,this.installCallback.bind(this),b)}window.modalView.hide()},checkValidation:function(){window.modalView.modalTestAll()},installCallback:function(a){window.App.navigate("#services",{trigger:!0}),window.App.applicationsView.installCallback(a)},renderSelects:function(){$("#new-app-document-collections").select2({tags:[],showSearchBox:!1,minimumResultsForSearch:-1,width:"336px"}),$("#new-app-edge-collections").select2({tags:[],showSearchBox:!1,minimumResultsForSearch:-1,width:"336px"})},setNewAppValidators: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()},breadcrumb:function(){var a=this;if(window.App.naviView){var b="New";this._upgrade&&(b="Replace ("+window.App.replaceAppData.mount+")"),$("#subNavigationBar .breadcrumb").html('Services: '+b),arangoHelper.buildServicesSubNav("New")}else window.setTimeout(function(){a.breadcrumb()},100)}})}(),function(){"use strict";window.ServiceInstallView=Backbone.View.extend({el:"#content",readOnly:!1,foxxStoreRetry:0,template:templateEngine.createTemplate("serviceInstallView.ejs"),remove:function(){return this.$el.empty().off(),this.stopListening(),this.unbind(),delete this.el,this},events:{"click #categorySelection":"renderCategories","click #foxxFilters":"resetFilters","keyup #foxxSearch":"search"},initialize:function(a){this.functionsCollection=a.functionsCollection,window.App.replaceApp&&(this._upgrade=!0)},fetchStore:function(){var a=this;this.foxxStoreRetry=1,this.collection.fetch({cache:!1,success:function(){"#services/install"===window.location.hash&&a.render()}})},search:function(){this._installedSubViews[Object.keys(this._installedSubViews)[0]].applyFilter();var a=$("#foxxSearch").val();a?_.each(this._installedSubViews,function(b){b.model.get("name").includes(a)?"true"===$(b.el).attr("shown")&&$(b.el).show():$(b.el).hide()}):this._installedSubViews[Object.keys(this._installedSubViews)[0]].applyFilter()},createSubViews:function(){var a=this;this._installedSubViews={},a.collection.each(function(b){var c=new window.FoxxRepoView({collection:a.functionsCollection,model:b,appsView:a,upgrade:a._upgrade});a._installedSubViews[b.get("name")]=c})},renderCategories:function(a){this._installedSubViews[Object.keys(this._installedSubViews)[0]].renderCategories(a)},resetFilters:function(){$("#foxxSearch").val(""),this._installedSubViews[Object.keys(this._installedSubViews)[0]].resetFilters()},render:function(){return $(this.el).html(this.template.render({services:this.collection})),arangoHelper.buildServicesSubNav("Store"),this.breadcrumb(),0===this.collection.length&&0===this.foxxStoreRetry?void this.fetchStore():(this.collection.sort(),this.createSubViews(),_.each(this._installedSubViews,function(a){$("#availableFoxxes").append(a.render())}),this)},breadcrumb:function(){var a="New";this._upgrade&&(a="Replace ("+window.App.replaceAppData.mount+")"),$("#subNavigationBar .breadcrumb").html('Services: '+a)}})}(),function(){"use strict";window.ServiceInstallUploadView=Backbone.View.extend({el:"#content",readOnly:!1,template:templateEngine.createTemplate("serviceInstallUploadView.ejs"),remove:function(){return this.$el.empty().off(),this.stopListening(),this.unbind(),delete this.el,this},initialize:function(){window.App.replaceApp&&(this._upgrade=!0)},events:{"click #installUploadService":"installFromUpload"},render:function(){return $(this.el).html(this.template.render({services:this.collection,upgrade:this._upgrade})),this.prepareUpload(),this.breadcrumb(),arangoHelper.createTooltips(".modalTooltips"),this},installFromUpload:function(){arangoHelper.createMountPointModal(this.installFoxxFromZip.bind(this))},testFunction:function(a,b){window.foxxData||(window.foxxData={}),window.foxxData.files=a,window.foxxData.data=b,$("#installUploadService").attr("disabled",!1)},prepareUpload:function(){var a=this;$("#upload-foxx-zip").uploadFile({url:arangoHelper.databaseUrl("/_api/upload?multipart=true"),allowedTypes:"zip,js",multiple:!1,onSuccess:a.testFunction})},installFoxxFromZip:function(){if(void 0===window.foxxData.data?window.foxxData.data=this._uploadData:this._uploadData=window.foxxData.data,window.foxxData.data&&window.modalView.modalTestAll()){var a,b,c;this._upgrade?(a=window.App.replaceAppData.mount,b=arangoHelper.getFoxxFlag()):(a=window.arangoHelper.escapeHtml($("#new-app-mount").val()),"/"!==a.charAt(0)&&(a="/"+a)),c=Boolean($("#zip-app-islegacy").prop("checked")),this.collection.installFromZip(window.foxxData.data.filename,a,this.installCallback.bind(this),c,b)}window.modalView.hide()},installCallback:function(a){window.App.navigate("#services",{trigger:!0}),window.App.applicationsView.installCallback(a)},breadcrumb:function(){var a=this;if(window.App.naviView){var b="New";this._upgrade&&(b="Replace ("+window.App.replaceAppData.mount+")"),$("#subNavigationBar .breadcrumb").html('Services: '+b),arangoHelper.buildServicesSubNav("Upload")}else window.setTimeout(function(){a.breadcrumb()},100)}})}(),function(){"use strict";window.ServiceInstallUrlView=Backbone.View.extend({el:"#content",readOnly:!1,template:templateEngine.createTemplate("serviceInstallUrlView.ejs"),remove:function(){return this.$el.empty().off(),this.stopListening(),this.unbind(),delete this.el,this},initialize:function(){window.App.replaceApp&&(this._upgrade=!0)},events:{"click #installUrlService":"installUrlService"},render:function(){return $(this.el).html(this.template.render({services:this.collection,upgrade:this._upgrade})),this.breadcrumb(),this.setUrlValidators(),arangoHelper.createTooltips(".modalTooltips"),this},breadcrumb:function(){var a=this;if(window.App.naviView){var b="New";this._upgrade&&(b="Replace ("+window.App.replaceAppData.mount+")"),$("#subNavigationBar .breadcrumb").html('Services: '+b),arangoHelper.buildServicesSubNav("Remote")}else window.setTimeout(function(){a.breadcrumb()},100)},installUrlService:function(){arangoHelper.createMountPointModal(this.installFoxxFromUrl.bind(this))},installFoxxFromUrl:function(){if(window.modalView.modalTestAll()){var a,b,c;this._upgrade?(b=window.App.replaceAppData.mount,c=arangoHelper.getFoxxFlag()):(b=window.arangoHelper.escapeHtml($("#new-app-mount").val()),"/"!==b.charAt(0)&&(b="/"+b)),a=window.arangoHelper.escapeHtml($("#repository").val());var d={url:a,version:"master"};this.collection.installFromUrl(d,b,this.installCallback.bind(this),null,c)}},setUrlValidators:function(){window.modalView.modalBindValidation({id:"repository",validateInput:function(){return[{rule:Joi.string().required().regex(/^(http)|^(https)/),msg:"No valid http or https url."}]}}),window.modalView.modalTestAll()},installCallback:function(a){window.App.navigate("#services",{trigger:!0}),window.App.applicationsView.installCallback(a)}})}(),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","keyup #databaseInputName":"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){if($("#loginDatabase").html(""),Object.keys(a.result).length>0){$("#loginDatabase").show(),$(".fa-database").show(),$("#databaseInputName").remove();var c=_.pairs(a.result);c.sort(),c=_.object(c),_.each(c,function(a,b){frontendConfig.authenticationEnabled?$("#loginDatabase").append(""):$("#loginDatabase").append("")})}else $("#loginDatabase").hide(),$(".fa-database").hide(),$("#loginDatabase").after('');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){if($("#loginForm").hide(),$(".login-window #databases").show(),$("#loginDatabase").html(""),Object.keys(a.result).length>0){$("#loginDatabase").show(),$(".fa-database").show(),$("#databaseInputName").remove();var c=_.pairs(a.result);c.sort(),c=_.object(c),_.each(c,function(a,b){frontendConfig.authenticationEnabled?$("#loginDatabase").append(""):$("#loginDatabase").append("")})}else $("#loginDatabase").hide(),$(".fa-database").hide(),$("#loginDatabase").after('');b.renderDBS()}).error(function(){$(".wrong-credentials").show()})},renderDBS:function(){var a="Select DB: ";$("#noAccess").hide(),0===$("#loginDatabase").children().length?$("#loginDatabase").is(":visible")?($("#dbForm").remove(),$(".login-window #databases").prepend('
You do not have permission to a database.
'),a+=$("#loginDatabase").val(),window.setTimeout(function(){$("#goToDatabase").focus()},150)):a+=$("#databaseInputName").val():(a+=$("#loginDatabase").val(),window.setTimeout(function(){$("#goToDatabase").focus()},150)),$("#goToDatabase").html(a)},logout:function(){this.collection.logout()},goTo:function(a){a.preventDefault();var b,c=$("#loginUsername").val();b=$("#databaseInputName").is(":visible")?$("#databaseInputName").val():$("#loginDatabase").val(),window.App.dbSet=b;var d=function(a){a&&arangoHelper.arangoError("User","Could not fetch user settings")},e=window.location.protocol+"//"+window.location.host+frontendConfig.basePath+"/_db/"+b+"/_admin/aardvark/index.html",f=function(){window.location.href=e,$(this.el2).show(),$(this.el3).show(),$(".bodyWrapper").show(),$(".navbar").show(),$("#currentUser").text(c),this.collection.loadUserSettings(d)};$.ajax({url:e,success:function(a){f()},error:function(a){a.responseJSON&&a.responseJSON.errorMessage?$("#noAccess").html("Error (DB: "+b+"): "+a.responseJSON.errorMessage):$("#noAccess").html("Error (DB: "+b+"): "+a.statusText),$("#noAccess").show()}})}})}(),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-dialog .modal-body .collectionTh > input").unbind("keydown"),$("#modal-dialog .modal-body .collectionTh > input").unbind("return"),$("#modal-dialog .modal-body .collectionTh > input",$(this.el)).bind("keydown","return",function(){$("#modal-dialog .modal-footer .button-success").is(":disabled")||$("#modal-dialog .modal-footer .button-success").click()}),$("#modal-dialog .modal-body .collectionTh > select").unbind("keydown"),$("#modal-dialog .modal-body .collectionTh > select").unbind("return"),$("#modal-dialog .modal-body .collectionTh > select",$(this.el)).bind("keydown","return",function(){$("#modal-dialog .modal-footer .button-success").is(":disabled")||$("#modal-dialog .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+"

"),$("#modal-dialog").is(":visible")?$("#modal-dialog .modal-footer .button-success").prop("disabled",!0).addClass("disabled"):$(".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?$("#modal-dialog").is(":visible")?$("#modal-dialog .modal-footer .button-success").prop("disabled",!0).addClass("disabled"):$(".createModalDialog .modal-footer .button-success").prop("disabled",!0).addClass("disabled"):$("#modal-dialog").is(":visible")?$("#modal-dialog .modal-footer .button-success").prop("disabled",!1).removeClass("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(){arangoHelper.checkDatabasePermissions(this.continueRender.bind(this),this.continueRender.bind(this))},continueRender:function(a){var b=this;$(this.el).html(this.template.render({currentDB:this.currentDB,isCluster:this.isCluster,readOnly:a})),"_system"!==this.currentDB.get("name")&&$("#dashboard").parent().remove(),$(this.subEl).html(this.templateSub.render({currentDB:this.currentDB.toJSON()})),this.dbSelectionView.render($("#dbSelect"));var c=function(a){a||this.userBarView.render()}.bind(this);return this.userCollection.whoAmI(c),this.renderFirst&&(this.renderFirst=!1,this.selectMenuItem(),$(".arangodbLogo").on("click",function(){b.selectMenuItem()}),$("#dbStatus").on("click",function(){b.changeDB()})),b.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}],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('