From 8e6bdaec65001371136becde02f32b561a6c5773 Mon Sep 17 00:00:00 2001 From: hkernbach Date: Tue, 24 Nov 2015 15:35:44 +0100 Subject: [PATCH] added example graphs to webui --- .../frontend/js/templates/modalGraphTable.ejs | 256 ++++++++++-------- .../frontend/js/views/graphManagementView.js | 38 +++ .../APP/frontend/scss/_collection.scss | 4 + 3 files changed, 188 insertions(+), 110 deletions(-) diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/templates/modalGraphTable.ejs b/js/apps/system/_admin/aardvark/APP/frontend/js/templates/modalGraphTable.ejs index f443791fbf..41c2cae136 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/templates/modalGraphTable.ejs +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/templates/modalGraphTable.ejs @@ -1,122 +1,158 @@ \ No newline at end of file + + diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphManagementView.js b/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphManagementView.js index 1ce8c4f746..8af18ae5f2 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphManagementView.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphManagementView.js @@ -26,6 +26,13 @@ "change #graphSortDesc" : "sorting" }, + toggleTab: function(e) { + var id = e.currentTarget.id; + id = id.replace('tab-', ''); + $('#tab-content-create-graph .tab-pane').removeClass('active'); + $('#tab-content-create-graph #' + id).addClass('active'); + }, + redirectToGraphViewer: function(e) { var name = $(e.currentTarget).attr("id"); name = name.substr(0, name.length - 5); @@ -125,6 +132,35 @@ this.render(); }, + createExampleGraphs: function(e) { + var graph = $(e.currentTarget).attr('graph-id'), self = this; + $.ajax({ + type: "POST", + url: "/_admin/aardvark/graph-examples/create/" + encodeURIComponent(graph), + success: function () { + window.modalView.hide(); + self.updateGraphManagementView(); + arangoHelper.arangoNotification('Example Graphs', 'Graph: ' + graph + ' created.'); + }, + error: function (err) { + window.modalView.hide(); + console.log(err); + if (err.responseText) { + try { + var msg = JSON.parse(err.responseText); + arangoHelper.arangoError('Example Graphs', msg.errorMessage); + } + catch (e) { + arangoHelper.arangoError('Example Graphs', 'Could not create example graph: ' + graph); + } + } + else { + arangoHelper.arangoError('Example Graphs', 'Could not create example graph: ' + graph); + } + } + }); + }, + render: function() { this.collection.fetch({ async: false @@ -147,6 +183,8 @@ this.events["click .tableRow"] = this.showHideDefinition.bind(this); this.events['change tr[id*="newEdgeDefinitions"]'] = this.setFromAndTo.bind(this); this.events["click .graphViewer-icon-button"] = this.addRemoveDefinition.bind(this); + this.events["click #graphTab a"] = this.toggleTab.bind(this); + this.events["click .createExampleGraphs"] = this.createExampleGraphs.bind(this); arangoHelper.setCheckboxStatus("#graphManagementDropdown"); return this; diff --git a/js/apps/system/_admin/aardvark/APP/frontend/scss/_collection.scss b/js/apps/system/_admin/aardvark/APP/frontend/scss/_collection.scss index b94c705809..c601a99b12 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/scss/_collection.scss +++ b/js/apps/system/_admin/aardvark/APP/frontend/scss/_collection.scss @@ -111,6 +111,7 @@ } #infoTab, +#graphTab, #collectionTab { border-bottom: 0; margin-bottom: 1px; @@ -119,11 +120,13 @@ } #infoTab li, +#graphTab li, #collectionTab li { float: right; } #infoTab a, +#graphTab a, #collectionTab a { background-color: $c-new-grey; border-bottom: 1px solid $c-darker-grey; @@ -138,6 +141,7 @@ } #infoTab .active > a, +#graphTab .active > a, #collectionTab .active > a { background-color: $c-modal-header; border-color: $c-collection-tab-border-bottom $c-collection-tab-border-bottom transparent !important;