Skip to content

Commit

Permalink
Added tree view to configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Rossi committed Dec 28, 2015
1 parent d2bcee7 commit c512722
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 25 deletions.
26 changes: 21 additions & 5 deletions src/main/java/net/apachegui/web/ConfigurationController.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package net.apachegui.web;

import apache.conf.global.Utils;
import apache.conf.parser.File;

import java.nio.charset.Charset;

import apache.conf.parser.*;
import net.apachegui.conf.Configuration;
import net.apachegui.conf.ConfigurationTree;
import net.apachegui.db.SettingsDao;
import net.apachegui.global.Constants;
import net.apachegui.modules.SharedModuleHandler;

import net.apachegui.modules.StaticModuleHandler;
import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import org.json.JSONArray;
Expand All @@ -18,6 +17,8 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.nio.charset.Charset;


@RestController
@RequestMapping("/web/Configuration")
Expand Down Expand Up @@ -97,4 +98,19 @@ public String searchConfiguration(@RequestParam(value = "filter") String filter,
return result.toString();
}

@RequestMapping(method = RequestMethod.GET, params = "option=getConfigurationTree", produces = "application/json;charset=UTF-8")
public String getConfigurationTree(@RequestParam(value = "file") String file) throws NullPointerException, Exception {

Parser parser = new EnclosureParser(SettingsDao.getInstance().getSetting(Constants.CONF_FILE), SettingsDao.getInstance().getSetting(Constants.SERVER_ROOT),
StaticModuleHandler.getStaticModules(), SharedModuleHandler.getSharedModules());

ParsableLine parsableLines[] = parser.getFileParsableLines(file, true);

JSONObject tree = new JSONObject();
tree.put("tree", ConfigurationTree.toTreeJSON(parsableLines, file));

return tree.toString();

}

}
5 changes: 0 additions & 5 deletions src/main/java/net/apachegui/web/GlobalTreeController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.apachegui.web;

import apache.conf.parser.Enclosure;
import apache.conf.parser.EnclosureParser;
import apache.conf.parser.ParsableLine;
import apache.conf.parser.Parser;
Expand All @@ -21,10 +20,6 @@ public class GlobalTreeController {
@RequestMapping(method = RequestMethod.GET, params = "option=getGlobalTree", produces = "application/json;charset=UTF-8")
public String getGlobalTree() throws NullPointerException, Exception {

Enclosure globalEnclosure = new Enclosure();
globalEnclosure.setType("Configuration");
globalEnclosure.setValue("");

Parser parser = new EnclosureParser(SettingsDao.getInstance().getSetting(Constants.CONF_FILE), SettingsDao.getInstance().getSetting(Constants.SERVER_ROOT),
StaticModuleHandler.getStaticModules(), SharedModuleHandler.getSharedModules());

Expand Down
32 changes: 26 additions & 6 deletions src/main/webapp/WEB-INF/jsp/views/Configuration.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,40 @@

<jsp:include page="/jsp/Init.jsp" flush="true" />

<jsp:include page="/jsp/configuration_tree/Dialogs.jsp" flush="true" />

<div id="appLayout" class="demoLayout" data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design: 'headline'">

<jsp:include page="/jsp/Heading.jsp" flush="true" />

<jsp:include page="/jsp/Menu.jsp" flush="true" />

<div id="centerPanel" class="centerPanel" data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="region: 'center', tabPosition: 'top'">
<div id="centerPanel" class="centerPanel" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'center'">
<div data-dojo-type="dijit/layout/TabContainer" style="width: 100%; height: 100%;" id="configurationTabs">

<div data-dojo-type="dijit/layout/ContentPane" title="Editor View" id="editorTab">

<div class="centerPanel" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="region: 'center', tabPosition: 'top'">

<jsp:include page="/jsp/editor/EditorMenu.jsp" flush="true" >
<jsp:param name="option" value="Configuration" />
</jsp:include>

<div id="pane2" class="centerPanel" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'center', title:'Edit'" >
<div id="fileform"><textarea id="fileTextArea" name="fileTextArea">Loading File...</textarea></div>
</div>
</div>

</div>

<div data-dojo-type="dijit/layout/ContentPane" title="Tree View" id="treeTab">

<div class="tree_container" id="configuration_tree_container">

</div>

<jsp:include page="/jsp/editor/EditorMenu.jsp" flush="true" >
<jsp:param name="option" value="Configuration" />
</jsp:include>
</div>

<div id="pane2" class="centerPanel" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'center', title:'Edit'" >
<div id="fileform"><textarea id="fileTextArea" name="fileTextArea">Loading File...</textarea></div>
</div>
</div>
</div>
Expand Down
64 changes: 60 additions & 4 deletions src/main/webapp/resources/net/apachegui/Configuration.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,77 @@
//TODO add click handler for file links
//TODO monitor update times and refresh editor or tree accordingly

define([ "dojo/_base/declare",
"dojo/dom",
"dijit/registry",
"dojo/on",
"dojo/request",
"net/apachegui/Editor",
"dojo/_base/json"
], function(declare, dom, registry, on, request, Editor, json){
"dojo/_base/json",
"dojo/dom-construct",
"net/apachegui/ConfigurationTree"
], function(declare, dom, registry, on, request, Editor, json, domConstruct, ConfigurationTree){

declare("net.apachegui.Configuration", [net.apachegui.Editor], {

initialized: false,

loadedTabs: [],
file: '',
TABS: {
EDITOR: 'editorTab',
TREE: 'treeTab'
},

init: function() {

if(this.initialized===false) {
this.inherited(arguments);
this.addListeners();
this.loadTab(this.TABS.EDITOR);
this.initialized=true;
}
},


loadTab: function(tabId) {
if (this.loadedTabs.indexOf(tabId) != -1) {
return;
}

if(tabId==this.TABS.TREE) {
this.buildConfigurationTree();
}

this.loadedTabs.push(tabId);
},

loadConfigurationTreeJSON: function(callback) {

var file = net.apachegui.Util.getQueryParam('file');
request.get('../web/Configuration', {
query: {
option: 'getConfigurationTree',
file: file
},
handleAs: 'json',
preventCache: true,
sync: false
}).response.then(function (response) {
var data = response.data;
var tree = data.tree;
callback(tree);
});
},

buildConfigurationTree: function() {
this.configTree = new ConfigurationTree({
id: 'configuration_tree',
loadTreeJSON: this.loadConfigurationTreeJSON
});
this.configTree.startup();

domConstruct.place(this.configTree.domNode, dom.byId('configuration_tree_container'), 'last');
},

testConfiguration: function () {

var thisdialog = net.apachegui.Util.noCloseDialog('Loading', 'Loading ...');
Expand Down Expand Up @@ -154,6 +206,10 @@ define([ "dojo/_base/declare",
on(registry.byId('editorConfigurationSearch'), "click", function() {
registry.byId('searchConfigurationDialog').show();
});

registry.byId("configurationTabs").watch("selectedChildWidget", function(name, oval, nval){
that.loadTab(nval.id);
});
}

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ define([ "dojo/_base/declare",
declare("net.apachegui.globalsettings.GlobalSettings", null, {
initialized: false,
loadedTabs: [],
TABS: {
NETWORKING: 'networkingTab',
MIME: 'mimeTab',
MODULES: 'modulesTab'
},

init: function () {
if(this.initialized===false) {
this.addListeners();
this.loadTab("networkingTab");
this.loadTab(this.TABS.NETWORKING);

this.initialized=true;
}
Expand All @@ -30,23 +35,23 @@ define([ "dojo/_base/declare",
var jsp='';
var onLoad;

if(tabId=="networkingTab") {
if(tabId==this.TABS.NETWORKING) {
jsp='Networking.jsp';

onLoad=function() {
net.apachegui.globalsettings.Networking.getInstance().init();
};
}

if(tabId=="mimeTab") {
if(tabId==this.TABS.MIME) {
jsp='Mime.jsp';

onLoad=function() {
net.apachegui.globalsettings.Mime.getInstance().init();
};
}

if(tabId=="modulesTab") {
if(tabId==this.TABS.MODULES) {
jsp='Modules.jsp';

onLoad=function() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/resources/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ h1 {
}

#titleContainer {
height: 105px;
height: 70px;
}

#mainHeading {
Expand Down

0 comments on commit c512722

Please sign in to comment.