jaime 9d16b972ea
feat: add tasks page into management WebUI (#37002)
issue: #36621

1. Add API to access task runtime metrics, including:
  - build index task
  - compaction task
  - import task
- balance (including load/release of segments/channels and some leader
tasks on querycoord)
  - sync task
2. Add a debug model to the webpage by using debug=true or debug=false
in the URL query parameters to enable or disable debug mode.

Signed-off-by: jaime <yun.zhang@zilliz.com>
2024-10-28 10:13:29 +08:00

54 lines
1.7 KiB
JavaScript

var DEBUG_MODE = false; // Set this to false to disable debug mode
var MILVUS_URI = "http://127.0.0.1:9091/api/v1"
// Function to check URL for "debug" parameter and switch debug mode
function toggleDebugMode() {
// Get the current URL's query parameters
const urlParams = new URLSearchParams(window.location.search);
// Check if "debug" parameter is present and its value
if (urlParams.has('debug')) {
if (urlParams.get('debug') === 'true') {
console.log("Debug mode is ON");
// Enable debug mode: Add any additional debug functionality here
localStorage.setItem('debug', 'true');
} else {
console.log("Debug mode is OFF");
localStorage.setItem('debug', 'false');
}
}
// Check if debug mode is enabled
DEBUG_MODE = localStorage.getItem('debug') === 'true';
}
// Call the function to check the URL and apply debug mode
toggleDebugMode();
const handleError = (error) => {
console.error('Error fetching data:', error);
const errorMessage = encodeURIComponent(error.message || 'Unknown error');
window.location.href = `5xx.html?error=${errorMessage}`;
};
const fetchData = (url, localData) => {
if (DEBUG_MODE) {
return new Promise((resolve) => {
resolve(JSON.parse(localData));
});
} else {
return fetch(url)
.then(response => response.json())
}
};
function getQueryParams() {
const params = {};
const queryString = window.location.search.substring(1);
const queryArray = queryString.split('&');
queryArray.forEach(param => {
const [key, value] = param.split('=');
params[decodeURIComponent(key)] = decodeURIComponent(value || '');
});
return params;
}