forked from jrossi227/ApacheGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to edit tree lines, added input auto suggest to trees
- Loading branch information
Showing
6 changed files
with
415 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/net/apachegui/web/ConfigurationTreeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package net.apachegui.web; | ||
|
||
import apache.conf.parser.File; | ||
import net.apachegui.conf.ConfFiles; | ||
import net.apachegui.conf.Configuration; | ||
import org.json.JSONObject; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/web/ConfigurationTree") | ||
public class ConfigurationTreeController { | ||
|
||
private final String LINE_TYPE_ENCLOSURE = "enclosure"; | ||
|
||
private JSONObject populateFileModifiedResponse(String file) { | ||
|
||
JSONObject result = new JSONObject(); | ||
result.put("result", "success"); | ||
result.put("lastModifiedTime", new File(file).lastModified()); | ||
result.put("file", file); | ||
|
||
return result; | ||
|
||
} | ||
|
||
@RequestMapping(method = RequestMethod.POST, params = "option=editLine", produces = "application/json;charset=UTF-8") | ||
public String editLine(@RequestParam(value = "type") String type, | ||
@RequestParam(value = "value") String value, | ||
@RequestParam(value = "lineType") String lineType, | ||
@RequestParam(value = "file") String file, | ||
@RequestParam(value = "lineOfStart") int lineOfStart, | ||
@RequestParam(value = "lineOfEnd") int lineOfEnd) throws Exception { | ||
|
||
String line; | ||
if(lineType.equals(LINE_TYPE_ENCLOSURE)) { | ||
line = "<" + type + " " + value + ">"; | ||
} else { | ||
line = type + " " + value; | ||
} | ||
|
||
String originalContents = ConfFiles.replaceLinesInConfigFile(new File(file), new String[]{line}, lineOfStart, lineOfEnd); | ||
|
||
Configuration.testChanges(file, originalContents); | ||
|
||
JSONObject result = populateFileModifiedResponse(file); | ||
|
||
return result.toString(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> | ||
|
||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> | ||
|
||
<div data-dojo-type="dijit/Dialog" id="editLineDialog" title="Edit " style="width: 700px; display: none"> | ||
<table> | ||
<tr class="dijitDialogPaneContentArea"> | ||
<td> | ||
<label for='editLineType'> | ||
Type: | ||
</label> | ||
</td> | ||
<td> | ||
<span id="editLineType" class="directive_type"></span> | ||
</td> | ||
</tr> | ||
<tr class="dijitDialogPaneContentArea"> | ||
<td> | ||
<label for='editLineValue'> | ||
Value: | ||
</label> | ||
</td> | ||
<td> | ||
<input data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props="required: true" id="editLineValue" style="width: 630px;" /> | ||
</td> | ||
</tr> | ||
</table> | ||
|
||
<input type="hidden" id="editLineLineType" value=""/> | ||
<input type="hidden" id="editLineLineOfStart" value=""/> | ||
<input type="hidden" id="editLineFile" value=""/> | ||
<input type="hidden" id="editLineLineOfEnd" value=""/> | ||
|
||
<div class="dijitDialogPaneActionBar"> | ||
<button id="editLineSubmit" data-dojo-type="dijit.form.Button" type="button"> | ||
Submit | ||
</button> | ||
<button id="editLineCancel" data-dojo-type="dijit.form.Button" type="button"> | ||
Cancel | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<div data-dojo-type="dijit/Dialog" id="addLineDialog" title="Add " style="width: 700px; display: none"> | ||
<table> | ||
<tr class="dijitDialogPaneContentArea"> | ||
<td> | ||
<label for='addLineType'> | ||
Type: | ||
</label> | ||
</td> | ||
<td> | ||
<input data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props="required: true" id="addLineType" style="width: 630px;" /> | ||
</td> | ||
</tr> | ||
<tr class="dijitDialogPaneContentArea"> | ||
<td> | ||
<label for='addLineValue'> | ||
Value: | ||
</label> | ||
</td> | ||
<td> | ||
<input data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props="required: true" id="addLineValue" style="width: 630px;" /> | ||
</td> | ||
</tr> | ||
</table> | ||
|
||
<input type="hidden" id="addLineBeforeLineType" value=""/> | ||
<input type="hidden" id="addLineLineType" value=""/> | ||
<input type="hidden" id="addLineLineOfStart" value=""/> | ||
|
||
<div class="dijitDialogPaneActionBar"> | ||
<button id="addLineSubmit" data-dojo-type="dijit.form.Button" type="button"> | ||
Submit | ||
</button> | ||
<button id="addLineCancel" data-dojo-type="dijit.form.Button" type="button"> | ||
Cancel | ||
</button> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.