mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-06 12:06:24 +02:00
MySQL Manager: fix empty status/processes, error messages, deploy-safe
This commit is contained in:
@@ -683,7 +683,11 @@ app.controller('phpMyAdmin', function ($scope, $http, $window) {
|
||||
|
||||
app.controller('Mysqlmanager', function ($scope, $http, $compile, $window, $timeout) {
|
||||
$scope.cyberPanelLoading = false;
|
||||
$scope.mysql_status = 'test'
|
||||
$scope.mysql_status = 'test';
|
||||
$scope.uptime = '—';
|
||||
$scope.connections = '—';
|
||||
$scope.Slow_queries = '—';
|
||||
$scope.processes = [];
|
||||
|
||||
|
||||
$scope.getstatus = function () {
|
||||
@@ -706,12 +710,27 @@ app.controller('Mysqlmanager', function ($scope, $http, $compile, $window, $time
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = false;
|
||||
if (response.data.status === 1) {
|
||||
$scope.uptime = response.data.uptime;
|
||||
$scope.connections = response.data.connections;
|
||||
$scope.Slow_queries = response.data.Slow_queries;
|
||||
$scope.processes = JSON.parse(response.data.processes);
|
||||
$timeout($scope.showStatus, 3000);
|
||||
var data = response.data;
|
||||
if (typeof data === 'string') {
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
} catch (e) {
|
||||
new PNotify({ title: 'Error!', text: 'Invalid response from server.', type: 'error' });
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (data && data.status === 1) {
|
||||
$scope.uptime = data.uptime || '—';
|
||||
$scope.connections = data.connections != null ? data.connections : '—';
|
||||
$scope.Slow_queries = data.Slow_queries != null ? data.Slow_queries : '—';
|
||||
try {
|
||||
$scope.processes = typeof data.processes === 'string' ? JSON.parse(data.processes || '[]') : (data.processes || []);
|
||||
} catch (e) {
|
||||
$scope.processes = [];
|
||||
}
|
||||
if (typeof $scope.showStatus === 'function') {
|
||||
$timeout($scope.showStatus, 3000);
|
||||
}
|
||||
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
@@ -721,7 +740,7 @@ app.controller('Mysqlmanager', function ($scope, $http, $compile, $window, $time
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
text: (data && data.error_message) || 'Could not load MySQL status.',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
@@ -730,15 +749,25 @@ app.controller('Mysqlmanager', function ($scope, $http, $compile, $window, $time
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = false;
|
||||
var msg = (response.data && response.data.error_message) || (response.statusText || 'Cannot load MySQL status.');
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: "cannot load",
|
||||
text: msg,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$scope.refreshProcesses = function () {
|
||||
var icon = document.querySelector('.refresh-btn i');
|
||||
if (icon) {
|
||||
icon.style.animation = 'spin 1s linear';
|
||||
setTimeout(function () { icon.style.animation = ''; }, 1000);
|
||||
}
|
||||
$scope.getstatus();
|
||||
};
|
||||
|
||||
$scope.getstatus();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user