druid/web-console/old-console/js/handlers-0.0.2.js
Vadim Ogievetsky 7f1b19bfb1 Adding a Unified web console. (#6923)
* Adding new web console.

* fixed css

* fix form height

* fix typo

* do import custom react-table css

* added repo field so npm does not complain

* ask travis for node 10

* move indexing-service/src/main/resources/indexer_static into web-console

* fix resource names and paths

* add licenses

* fix exclude file

* add licenses to misc files and tidy up

* remove rebase marker

* fix link

* updated env variable name

* tidy up licenses and surface errors

* cleanup

* remove unused code, fix missing await

* TeamCity does not like the name aux

* add more links to tasks view

* rm pages

* update gitignore

* update readme to be accurate

* make clean script

* removed old console dependancy

* update Jetty routes

* add a comment for welcome files for coordinator

* do not show inital notifaction for now

* renamed overlord console back to console.html

* fix coordinator console

* rename coordinator-console.html to index.html
2019-01-31 17:26:41 -08:00

131 lines
3.6 KiB
JavaScript

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// requires jQuery, druidTable, tablehelper
$(document).ready(function() {
var basePath = "/druid/coordinator/v1/";
var type = $('#select_type').val() + '';
var view = $('#select_view').val() + '';
function handleTable(dontDisplay)
{
$.get(basePath + type + '?full', function(data) {
buildTable(data, $('#result_table'), dontDisplay);
$('.loading').hide();
$('#table_wrapper').show();
});
}
function handleList(hasSegments)
{
$('#selected_data').html('');
$.get(basePath + type, function(data) {
var appendStr = '<ul>';
_.each(data, function(entry) {
entry += '';
appendStr += '<li class="has_raw';
if (hasSegments === true) {
appendStr += ' has_segments';
}
appendStr += '"><a class="val">' + entry + '</a><span class="links"></span></li>';
});
appendStr += '</ul>';
$('#selected_data').html(appendStr);
$('.val').click(function(event) {
var el = $(event.target);
var links = el.siblings('.links');
var linksStr = "";
var rawJsonPath = type + "/" + el.text();
$('.links').empty();
if (hasSegments) {
type += "/" + el.text() + "/segments";
linksStr += '[<a class="segments_table">View Segments Table</a>]';
linksStr += '[<a class="segments_list">View Segments List</a>]';
linksStr += '<a target="_blank" href="' + basePath + type + '?full">[View Segment Raw JSON]</a>';
}
linksStr += '<a target="_blank" href="' + basePath + rawJsonPath + '">[Raw JSON]</a>';
links.html(linksStr);
$('.segments_table').click(function() {
resetViews();
handleTable();
})
$('.segments_list').click(function() {
resetViews();
handleList(false);
})
});
$('.loading').hide();
$('#selected_data').show();
});
}
function handleRaw() {
var htmlStr = '<a target="_blank" href="' + basePath + type + '?full' + '">Go to Raw JSON</a>';
$('#selected_data').html(htmlStr);
$('.loading').hide();
$('#selected_data').show();
}
$('#view_button').click(function() {
type = $('#select_type').val() + '';
view = $('#select_view').val() + '';
resetViews();
switch (view) {
case "table":
var dontDisplay;
switch (type) {
case "servers":
case "datasources":
dontDisplay = ["segments"];
break;
case "segments":
dontDisplay = ["shardSpec"];
break;
}
handleTable(dontDisplay);
break;
case "list":
handleList(type.indexOf("segments") == -1);
break;
case "raw":
handleRaw();
break;
}
});
function resetViews() {
$('.loading').show();
$('#selected_data').hide();
$('#table_wrapper').hide();
}
});