github.com/rohankumardubey/aresdb@v0.0.2-0.20190517170215-e54e3ca06b9c/api/ui/debug/js/summary.js (about) 1 // Copyright (c) 2017-2018 Uber Technologies, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 function resetToggleButton() { 16 // Init health togggle. 17 $.ajax({ 18 url: "/dbg/health", 19 success: function (body) { 20 $('#health-toggle').bootstrapToggle(body); 21 }, 22 error: function (xhr) { 23 alert(xhr.responseText); 24 }, 25 async: true 26 }); 27 } 28 29 function initSummaryViewer() { 30 resetToggleButton(); 31 $('#health-toggle').change(function () { 32 var status = $(this).prop('checked') ? "on" : "off"; 33 $.ajax({ 34 url: "/dbg/health/{0}".format(status), 35 success: function () { 36 }, 37 error: function (xhr) { 38 alert(xhr.responseText); 39 }, 40 method: "POST" 41 }); 42 }); 43 44 // Init table selector. 45 $('#table-selector').select2({ 46 ajax: { 47 url: "/schema/tables", 48 dataType: 'json', 49 quietMillis: 50, 50 processResults: function (data) { 51 return { 52 results: $.map(data, function (item, idx) { 53 return { 54 text: item, 55 id: idx + 1, 56 }; 57 }) 58 }; 59 } 60 }, 61 width: 'resolve' 62 }).on('change', function () { 63 refreshShardViewer(); 64 }); 65 66 // Init shard selector. 67 $('#shard-selector').select2({ 68 data: [ 69 { 70 "id": 0, 71 "text": 0, 72 } 73 ] 74 }).on('change', function (e) { 75 refreshShardViewer(); 76 }); 77 } 78 79 function refreshShardViewer() { 80 var table = $("#table-selector").select2('data')[0].text; 81 var shard = $("#shard-selector").select2('data')[0].text; 82 83 // Get shard info. 84 $.ajax({ 85 url: "/dbg/{0}/{1}".format(table, shard), 86 success: function (body) { 87 $("#shard-json-renderer").jsonViewer(body); 88 }, 89 error: function (xhr) { 90 alert(xhr.responseText); 91 }, 92 async: true 93 }); 94 }