mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-14 17:26:17 +01:00
changes in update mysql
This commit is contained in:
@@ -842,11 +842,23 @@ app.controller('OptimizeMysql', function ($scope, $http) {
|
||||
app.controller('mysqlupdate', function ($scope, $http, $timeout) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
$scope.dbLoading = true;
|
||||
$scope.installlogs = true;
|
||||
$scope.modeSecInstallBox = true;
|
||||
$scope.modsecLoading = true;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
$scope.Upgardemysql = function () {
|
||||
$scope.dbLoading = false;
|
||||
$scope.installform = true;
|
||||
$scope.modSecNotifyBox = true;
|
||||
$scope.modeSecInstallBox = false;
|
||||
$scope.modsecLoading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
|
||||
url = "/dataBases/upgrademysqlnow";
|
||||
@@ -867,16 +879,27 @@ app.controller('mysqlupdate', function ($scope, $http, $timeout) {
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberhosting = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.installlogs = false;
|
||||
$scope.modSecNotifyBox = true;
|
||||
$scope.modeSecInstallBox = false;
|
||||
$scope.modsecLoading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
$scope.statusfile = response.data.tempStatusPath
|
||||
|
||||
$timeout(getRequestStatus, 1000);
|
||||
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
$scope.modSecNotifyBox = false;
|
||||
$scope.modeSecInstallBox = true;
|
||||
$scope.modsecLoading = true;
|
||||
$scope.failedToStartInallation = false;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -892,5 +915,84 @@ app.controller('mysqlupdate', function ($scope, $http, $timeout) {
|
||||
}
|
||||
|
||||
|
||||
$scope.getRequestStatus
|
||||
function getRequestStatus() {
|
||||
|
||||
$scope.modSecNotifyBox = true;
|
||||
$scope.modeSecInstallBox = false;
|
||||
$scope.modsecLoading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
url = "/dataBases/upgrademysqlstatus";
|
||||
|
||||
var data = {
|
||||
statusfile: $scope.statusfile
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.abort === 0) {
|
||||
|
||||
$scope.modSecNotifyBox = true;
|
||||
$scope.modeSecInstallBox = false;
|
||||
$scope.modsecLoading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
$timeout(getRequestStatus, 1000);
|
||||
} else {
|
||||
// Notifications
|
||||
$timeout.cancel();
|
||||
$scope.modSecNotifyBox = false;
|
||||
$scope.modeSecInstallBox = false;
|
||||
$scope.modsecLoading = true;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
|
||||
if (response.data.installed === 0) {
|
||||
$scope.installationFailed = false;
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
} else {
|
||||
$scope.modSecSuccessfullyInstalled = false;
|
||||
$timeout(function () {
|
||||
$window.location.reload();
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.modSecNotifyBox = false;
|
||||
$scope.modeSecInstallBox = false;
|
||||
$scope.modsecLoading = true;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.modSecSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
@@ -46,9 +46,45 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="installlogs" class="form-group">
|
||||
<textarea rows="30" style="width: 100%"></textarea>
|
||||
<div ng-hide="modSecNotifyBox" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-6">
|
||||
|
||||
<div ng-hide="failedToStartInallation" class="alert alert-danger">
|
||||
<p>{% trans "Failed to start installation, Error message: " %} {$ errorMessage
|
||||
$}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||
<p>{% trans "Could not connect. Please refresh this page." %} </p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationFailed" class="alert alert-danger">
|
||||
<p>{% trans "Installation failed." %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="modSecSuccessfullyInstalled" class="alert alert-success">
|
||||
<p>{% trans "CSF successfully installed, refreshing page in 3 seconds.." %}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="modeSecInstallBox" class="col-md-12">
|
||||
|
||||
<form action="/" id="" class="form-horizontal bordered-row">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 text-center">
|
||||
<h3><img
|
||||
src="{% static 'firewall/icons/firewall.png' %}"> {% trans "In winter we must protect each other.." %}
|
||||
<img ng-hide="modsecLoading" src="/static/images/loading.gif"></h3>
|
||||
</div>
|
||||
<div style="margin-top: 2%;" class="col-sm-12">
|
||||
<textarea ng-model="requestData" rows="15"
|
||||
class="form-control">{{ requestData }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -11,6 +11,7 @@ urlpatterns = [
|
||||
url(r'^OptimizeMySQL', views.OptimizeMySQL, name='OptimizeMySQL'),
|
||||
url(r'^upgrademysqlnow', views.upgrademysqlnow, name='upgrademysqlnow'),
|
||||
url(r'^UpgradeMySQL', views.UpgradeMySQL, name='UpgradeMySQL'),
|
||||
url(r'^upgrademysqlstatus', views.upgrademysqlstatus, name='upgrademysqlstatus'),
|
||||
url(r'^getMysqlstatus', views.getMysqlstatus, name='getMysqlstatus'),
|
||||
url(r'^restartMySQL', views.restartMySQL, name='restartMySQL'),
|
||||
url(r'^generateRecommendations', views.generateRecommendations, name='generateRecommendations'),
|
||||
|
||||
@@ -474,7 +474,6 @@ def applyMySQLChanges(request):
|
||||
def upgrademysqlnow(request):
|
||||
try:
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
logging.writeToFile("----------------------habbi")
|
||||
userID = request.session['userID']
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
@@ -500,3 +499,43 @@ def upgrademysqlnow(request):
|
||||
return HttpResponse(json_data)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def upgrademysqlstatus(request):
|
||||
try:
|
||||
data = json.loads(request.body)
|
||||
statusfile = data['statusfile']
|
||||
installStatus = ProcessUtilities.outputExecutioner("sudo cat " + statusfile)
|
||||
|
||||
if installStatus.find("[200]") > -1:
|
||||
|
||||
command = 'sudo rm -f ' + statusfile
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
final_json = json.dumps({
|
||||
'error_message': "None",
|
||||
'requestStatus': installStatus,
|
||||
'abort': 1,
|
||||
'installed': 1,
|
||||
})
|
||||
return HttpResponse(final_json)
|
||||
elif installStatus.find("[404]") > -1:
|
||||
command = 'sudo rm -f ' + statusfile
|
||||
ProcessUtilities.executioner(command)
|
||||
final_json = json.dumps({
|
||||
'abort': 1,
|
||||
'installed': 0,
|
||||
'error_message': "None",
|
||||
'requestStatus': installStatus,
|
||||
})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
else:
|
||||
final_json = json.dumps({
|
||||
'abort': 0,
|
||||
'error_message': "None",
|
||||
'requestStatus': installStatus,
|
||||
})
|
||||
return HttpResponse(final_json)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
Reference in New Issue
Block a user