Преглед на файлове

HUE-7598 [indexer] Prettify json config of a collection

Merge the XML highlighter together.
Romain Rigaux преди 8 години
родител
ревизия
687a15f

+ 4 - 4
apps/jobbrowser/src/jobbrowser/templates/job_browser.mako

@@ -1198,7 +1198,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
         </div>
 
         <div class="tab-pane" id="workflow-page-xml${ SUFFIX }">
-          <div data-bind="readonlyXML: properties['xml'], path: 'xml'"></div>
+          <div data-bind="readOnlyAce: properties['xml'], path: 'xml', type: 'xml'"></div>
         </div>
       </div>
     </div>
@@ -1280,7 +1280,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
         </div>
 
         <div class="tab-pane" id="workflow-action-page-xml${ SUFFIX }">
-          <div data-bind="readonlyXML: properties['conf']"></div>
+          <div data-bind="readOnlyAce: properties['conf'], type: 'xml'"></div>
         </div>
 
       </div>
@@ -1408,7 +1408,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
         </div>
 
         <div class="tab-pane" id="schedule-page-xml${ SUFFIX }">
-          <div data-bind="readonlyXML: properties['xml'], path: 'xml'"></div>
+          <div data-bind="readOnlyAce: properties['xml'], path: 'xml', type: 'xml'"></div>
         </div>
       </div>
     </div>
@@ -1516,7 +1516,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
         </div>
 
         <div class="tab-pane" id="bundle-page-xml${ SUFFIX }">
-          <div data-bind="readonlyXML: properties['xml'], path: 'xml'"></div>
+          <div data-bind="readOnlyAce: properties['xml'], path: 'xml', type: 'xml'"></div>
         </div>
       </div>
     </div>

+ 2 - 2
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -6085,7 +6085,7 @@
     }
   };
 
-  ko.bindingHandlers.readonlyXML = {
+  ko.bindingHandlers.readOnlyAce = {
     init: function (element, valueAccessor, allBindingsAccessor) {
       $(element).css({
         'min-height': '250px'
@@ -6096,12 +6096,12 @@
         maxLines: Infinity
       });
       editor.setTheme($.totalStorage("hue.ace.theme") || "ace/theme/hue");
-      editor.getSession().setMode("ace/mode/xml");
       $(element).data('aceEditor', editor);
     },
     update: function (element, valueAccessor, allBindingsAccessor) {
       var value = ko.unwrap(valueAccessor());
       var options = ko.unwrap(allBindingsAccessor());
+      $(element).data('aceEditor').getSession().setMode("ace/mode/" + options.type || 'xml'); // e.g. xml, json...
       if (typeof value !== 'undefined' && value !== '') { // allows highlighting static code
         if (options.path) {
           value = value[options.path];

+ 1 - 1
desktop/libs/indexer/src/indexer/solr_api.py

@@ -185,7 +185,7 @@ def config_index(request):
 
   client = SolrClient(user=request.user)
 
-  response['config'] = client.get_config(name)
+  response['config'] = json.dumps(client.get_config(name), indent=2)
   response['status'] = 0
 
   return JsonResponse(response)

+ 5 - 5
desktop/libs/indexer/src/indexer/templates/indexes.mako

@@ -317,18 +317,18 @@ ${ assist.assistPanel() }
         <!-- ko template: { if: $root.tab() == 'index-sample', name: 'indexes-index-sample', data: sample(), full: true }--><!-- /ko -->
       <!-- /ko -->
       <!-- ko if: !sample() || sample().length === 0 -->
-      <div class="margin-top-10 margin-left-10">${ _('The index does not contain any data.')}</div>
+        <div class="margin-top-10 margin-left-10">${ _('The index does not contain any data.')}</div>
       <!-- /ko -->
     </div>
 
     <div class="tab-pane" id="index-config">
       <!-- ko hueSpinner: { spin: $root.index().loadingConfig, center: true, size: 'xlarge' } --><!-- /ko -->
 
-      <!-- ko if: config() && config().length > 0 -->
-        <span data-bind="text: ko.mapping.toJSON(config)"></span>
+      <!-- ko if: config() -->
+        <div data-bind="readOnlyAce: config, type: 'json'"></div>
       <!-- /ko -->
-      <!-- ko if: !config() || config().length === 0 -->
-      <div class="margin-top-10 margin-left-10">${ _('The config could not be retrieved.')}</div>
+      <!-- ko if: !config() -->
+        <div class="margin-top-10 margin-left-10">${ _('The config could not be retrieved.')}</div>
       <!-- /ko -->
     </div>
   </div>