arina-ielchiieva commented on a change in pull request #1692: DRILL-6562:
Plugin Management improvements
URL: https://github.com/apache/drill/pull/1692#discussion_r265068364
##########
File path: exec/java-exec/src/main/resources/rest/storage/list.ftl
##########
@@ -58,38 +89,208 @@
${plugin.getName()}
</td>
<td style="border:none;">
- <a class="btn btn-primary"
href="/storage/${plugin.getName()}">Update</a>
- <a class="btn btn-primary"
onclick="doEnable('${plugin.getName()}', true)">Enable</a>
+ <button type="button" class="btn btn-primary"
onclick="location.href='/storage/${plugin.getName()}'">
+ Update
+ </button>
+ <button type="button" class="btn btn-primary"
onclick="doEnable('${plugin.getName()}', true)">
+ Enable
+ </button>
+ <button type="button" class="btn btn-primary"
name="${plugin.getName()}" data-toggle="modal"
+ data-target="#pluginsModal">
+ Export
+ </button>
</td>
</tr>
</#if>
</#list>
</tbody>
</table>
</div>
- <div class="page-header">
+
+
+ <#-- Modal window for exporting plugin config (including group plugins
modal) -->
+ <div class="modal fade" id="pluginsModal" tabindex="-1" role="dialog"
aria-labelledby="exportPlugin" aria-hidden="true">
+ <div class="modal-dialog modal-sm" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
+ <h4 class="modal-title" id="exportPlugin">Export Plugin config</h4>
+ </div>
+ <div class="modal-body">
+ <div id="format" style="display: inline-block; position: relative;">
+ <label for="format">Format</label>
+ <div class="radio">
+ <label>
+ <input type="radio" name="format" id="json" value="json"
checked="checked">
+ JSON
+ </label>
+ </div>
+ <div class="radio">
+ <label>
+ <input type="radio" name="format" id="hocon" value="conf">
+ HOCON
+ </label>
+ </div>
+ </div>
+
+ <div id="plugin-set" class="" style="display: inline-block;
position: relative; float: right;">
+ <label for="format">Plugin group</label>
+ <div class="radio">
+ <label>
+ <input type="radio" name="number" id="all" value="all"
checked="checked">
+ ALL
+ </label>
+ </div>
+ <div class="radio">
+ <label>
+ <input type="radio" name="number" id="enabled" value="enabled">
+ ENABLED
+ </label>
+ </div>
+ <div class="radio">
+ <label>
+ <input type="radio" name="number" id="disabled"
value="disabled">
+ DISABLED
+ </label>
+ </div>
+ </div>
+ </div>
+
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default"
data-dismiss="modal">Close</button>
+ <button type="button" id="export" class="btn
btn-primary">Export</button>
+ </div>
+ </div>
+ </div>
</div>
- <div>
- <h4>New Storage Plugin</h4>
- <form class="form-inline" id="newStorage" role="form" action="/"
method="GET">
- <div class="form-group">
- <input type="text" class="form-control" id="storageName"
placeholder="Storage Name">
+ <#-- Modal window for exporting plugin config (including group plugins
modal) -->
+
+ <#-- Modal window for creating plugin -->
+ <div class="modal fade" id="new-plugin-modal" role="dialog"
aria-labelledby="configuration">
+ <div class="modal-dialog" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
+ <h4 class="modal-title" id="configuration">New Storage Plugin</h4>
+ </div>
+ <div class="modal-body">
+
+ <form id="createForm" role="form" action="/storage/create_new"
method="POST">
+ <input type="text" class="form-control" name="name"
placeholder="Storage Name">
+ <h3>Configuration</h3>
+ <div class="form-group">
+ <div id="editor" class="form-control"></div>
+ <textarea class="form-control" id="config" name="config"
data-editor="json" style="display: none;">
+ </textarea>
+ </div>
+ <div style="text-align: right; margin: 10px">
+ <button type="button" class="btn btn-default"
data-dismiss="modal">Close</button>
+ <button type="submit" class="btn btn-primary"
onclick="doCreate()">Create</button>
+ </div>
+ </form>
+
+ <div id="message" class="hidden alert alert-info">
+ </div>
+ </div>
</div>
- <button type="submit" class="btn btn-default"
onclick="doSubmit()">Create</button>
- </form>
+ </div>
</div>
+ <#-- Modal window for creating plugin -->
+
<script>
- function doSubmit() {
- var name = document.getElementById("storageName");
- var form = document.getElementById("newStorage");
- form.action = "/storage/" + name.value;
- form.submit();
- };
function doEnable(name, flag) {
- $.get("/storage/" + name + "/enable/" + flag, function(data) {
+ $.get("/storage/" + name + "/enable/" + flag, function() {
location.reload();
});
- };
+ }
+
+ function doCreate() {
+ $("#createForm").ajaxForm(function(data) {
+ // alert("ajax works");
+ const messageEl = $("#message");
+ if (data.result === "success") {
+ messageEl.removeClass("hidden")
+ .removeClass("alert-danger")
+ .addClass("alert-info")
+ .text(data.result).alert();
+ setTimeout(function() { location.reload(); }, 800);
+ } else {
+ messageEl.addClass("hidden");
+ // Wait a fraction of a second before showing the message again. This
+ // makes it clear if a second attempt gives the same error as
+ // the first that a "new" message came back from the server
+ setTimeout(function() {
+ messageEl.removeClass("hidden")
+ .removeClass("alert-info")
+ .addClass("alert-danger")
+ .text("Please retry: " + data.result).alert();
+ }, 200);
+ }
+ });
+ }
+
+ // Formatting create plugin textarea
+ $('#new-plugin-modal').on('show.bs.modal', function() {
+ const editor = ace.edit("editor");
+ const textarea = $('textarea[name="config"]');
+
+ editor.setAutoScrollEditorIntoView(true);
+ editor.setOption("maxLines", 25);
+ editor.setOption("minLines", 10);
+ editor.renderer.setShowGutter(true);
+ editor.renderer.setOption('showLineNumbers', true);
+ editor.renderer.setOption('showPrintMargin', false);
+ editor.getSession().setMode("ace/mode/json");
+ editor.setTheme("ace/theme/eclipse");
+
+ // copy back to textarea on form submit...
+ editor.getSession().on('change', function(){
+ textarea.val(editor.getSession().getValue());
+ });
+ });
+
+ // Modal windows management
+ let exportInstance; // global variable
+ $('#pluginsModal').on('show.bs.modal', function(event) {
+ console.log("alarm");
+ const button = $(event.relatedTarget); // Button that triggered the modal
+ const modal = $(this);
+ exportInstance = button.attr("name");
+
+ const optionalBlock = modal.find('#plugin-set');
+ if (exportInstance === "all") {
+ optionalBlock.removeClass('hide');
+ modal.find('.modal-title').text('Export all Plugin configs');
Review comment:
```suggestion
modal.find('.modal-title').text('Export all Plugins configs');
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services