Skip to content

Commit

Permalink
bug fixes, add support for multiple trees
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Rossi committed Dec 24, 2015
1 parent fcc18d2 commit 7abfcac
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<input type="hidden" id="currentConfigurationTreeId" value=""/>
<div data-dojo-type="dijit/Dialog" id="editLineDialog" title="Edit " style="width: 700px; display: none">
<table>
<tr class="dijitDialogPaneContentArea">
Expand Down
35 changes: 29 additions & 6 deletions src/main/webapp/resources/net/apachegui/ConfigurationTree.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//TODO stub out this file into a re-usable widget for GlobalTree.js
//TODO VirtualHost js should end up using this widget (started)
//TODO disable menu on root node
//TODO must make this templated so you can use multiple trees
define([
"dojo/_base/declare",
"dojo/dom",
Expand Down Expand Up @@ -211,6 +212,10 @@ define([
},

//--- PRIVATE FUNCTIONS -----------------------------------------------------------//
_initializeTemplate: function() {

},

_getItemProperty : function(item,name) {
var val = item[name];

Expand Down Expand Up @@ -289,6 +294,8 @@ define([
return;
}

this._setCurrentWidgetId();

dom.byId('editLineType').innerHTML = type;
dom.byId('editLineValue').value = value;
dom.byId('editLineLineType').value = this._getItemProperty(item,'lineType');
Expand Down Expand Up @@ -418,6 +425,8 @@ define([
return;
}

this._setCurrentWidgetId();

var addLineType = dom.byId('addLineType');
addLineType.value = '';
domAttr.set(addLineType, "data-type", type);
Expand Down Expand Up @@ -482,24 +491,44 @@ define([

},

_checkIfCurrentWidget: function() {
return dom.byId('currentConfigurationTreeId').value == this.id;
},

_setCurrentWidgetId: function() {
dom.byId('currentConfigurationTreeId').value = this.id;
},

_addListeners: function() {
var that = this;

//todo implement tree line hover

on(registry.byId('editLineSubmit'), 'click', function() {
if(!that._checkIfCurrentWidget()) {
return;
}
that._submitEditLine();
});

on(registry.byId('editLineCancel'), 'click', function() {
if(!that._checkIfCurrentWidget()) {
return;
}
registry.byId('editLineDialog').hide();
});

on(registry.byId('addLineSubmit'), 'click', function() {
if(!that._checkIfCurrentWidget()) {
return;
}
that._submitAddLine();
});

on(registry.byId('addLineCancel'), 'click', function() {
if(!that._checkIfCurrentWidget()) {
return;
}
registry.byId('addLineDialog').hide();
});

Expand All @@ -512,12 +541,6 @@ define([

//--- EVENTS -----------------------------------------------------------//
// These will all be left empty, it will be used as the extension point
/**
configTree.on("menufocus", function() {
return true;
});
**/
onMenuFocus: function() {
return true;
},
Expand Down
68 changes: 39 additions & 29 deletions src/main/webapp/resources/net/apachegui/VirtualHosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ define([ "dojo/_base/declare",

/**
*
* @param success callback, hosts array will be passed in as a paramete
* @param success callback, json response will be passed in as a parameter
* @param error callback, message will be passed in as a parameter
*/
requestAllTreeHosts: function(success, error) {
Expand All @@ -435,23 +435,27 @@ define([ "dojo/_base/declare",
preventCache: true,
sync: false
}).response.then(function (response) {
success(response.data.hosts);
success(response.data);
}, function (response) {
error(response.response.data.message);
});

},

loadVirtualHostTreeJSON: function(callback) {
loadVirtualHostTreeJSON: function(callback, virtualHost) {
var that = this;

if(this.currentVirtualHost == null) {
return;
}

var thisdialog = net.apachegui.Util.noCloseDialog('Loading', 'Loading Tree Host...');
thisdialog.show();

var virtualHost = this.currentVirtualHost;

this.requestAllTreeHosts(
function (hosts) {
function (data) {

var hosts = data.hosts;
var host;
for (var i = 0; i < hosts.length; i++) {
host = hosts[i];
Expand All @@ -476,39 +480,42 @@ define([ "dojo/_base/declare",

buildTreeHost : function(host, container, pos) {
var that = this;

var id = "tree-" + this.currentTreeSummaryCount;

var virtualHost = (function(num) {
return {
number : num,
host : host,
lastModified : {
file : host.file,
lastModifiedTime : 0
}
};
})(this.currentTreeSummaryCount);

var virtualHostTree = new ConfigurationTree({
id: id + '_widget',
treeJSON: host.tree,
rootType: 'VirtualHost',
loadTreeJSON: this.loadVirtualHostTreeJSON.bind(this)
loadTreeJSON: function(callback) {
that.loadVirtualHostTreeJSON(callback, virtualHost);
}
});

virtualHostTree.startup();
virtualHost.tree = virtualHostTree.tree;
virtualHost.configTree = virtualHostTree;

this.virtualHosts.push(virtualHost);

var div = document.createElement('div');
div.id = id;
div.innerHTML = '<h4 id=heading-' + id + '>' + this.buildTreeHeadingFromHost(host) + '</h4>';
div.appendChild(virtualHostTree.domNode);

domConstruct.place(div, container, pos);

var virtualHost = (function(num) {
return {
number : num,
tree : virtualHostTree.tree,
configTree: virtualHostTree,
host : host,
lastModified : {
file : host.file,
lastModifiedTime : 0
}
};
})(this.currentTreeSummaryCount);

this.virtualHosts.push(virtualHost);
virtualHostTree.startup();

virtualHostTree.on("menufocus", function() {
that.currentVirtualHost = virtualHost;
Expand Down Expand Up @@ -597,6 +604,7 @@ define([ "dojo/_base/declare",
virtualHostTree.on("afterEditLine", function(type, value, response) {

var host = that.currentVirtualHost.host;
var NetworkInfo = that.buildNetworkInfoArrayFromValue(value);
if (type == "VirtualHost") {
host.NetworkInfo = NetworkInfo;

Expand Down Expand Up @@ -691,7 +699,8 @@ define([ "dojo/_base/declare",
thisdialog.show();

this.requestAllTreeHosts(
function (hosts) {
function (data) {
var hosts = data.hosts;
that.treeGlobalServerName = data.ServerName;

if(hosts.length == 0) {
Expand Down Expand Up @@ -1071,12 +1080,13 @@ define([ "dojo/_base/declare",
that.updateLastModifiedTime(file);
}

var thisdialog = net.apachegui.Util.noCloseDialog('Loading', 'Loading Tree Hosts...');
thisdialog = null;
thisdialog = net.apachegui.Util.noCloseDialog('Loading', 'Loading Tree Hosts...');
thisdialog.show();

this.requestAllTreeHosts(
function (hosts) {
that.reloadAllTreeHosts(hosts);
that.requestAllTreeHosts(
function (data) {
that.reloadAllTreeHosts(data.hosts);
thisdialog.remove();
},
function (message) {
Expand Down

0 comments on commit 7abfcac

Please sign in to comment.