Files
CyberPanel/static/manageServices/manageServices.js

397 lines
11 KiB
JavaScript
Raw Normal View History

2018-07-23 02:09:33 +05:00
/**
* Created by usman on 6/22/18.
*/
2018-07-23 16:41:59 +05:00
/* Java script code */
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
app.controller('powerDNS', function($scope, $http, $timeout, $window) {
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
$scope.pdnsLoading = true;
$scope.failedToFetch = true;
2018-07-23 02:09:33 +05:00
$scope.couldNotConnect = true;
2018-07-23 16:41:59 +05:00
$scope.changesApplied = true;
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
var pdnsStatus = false;
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
$('#pdnsStatus').change(function() {
pdnsStatus = $(this).prop('checked');
2018-07-23 02:09:33 +05:00
});
2018-07-23 16:41:59 +05:00
fetchPDNSStatus('powerdns');
function fetchPDNSStatus(service){
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
$scope.pdnsLoading = false;
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
$('#pdnsStatus').bootstrapToggle('off');
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
url = "/manageservices/fetchStatus";
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
var data = {
'service' : service
};
2018-07-23 02:09:33 +05:00
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
2018-07-23 16:41:59 +05:00
$scope.pdnsLoading = true;
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
if(response.data.status === 1){
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
if (response.data.installCheck === 1) {
$('#pdnsStatus').bootstrapToggle('on');
2018-07-23 02:09:33 +05:00
}
2018-07-23 16:41:59 +05:00
}else{
$scope.failedToFetch = false;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
$scope.errorMessage = response.data.error_message;
2018-07-23 02:09:33 +05:00
}
}
function cantLoadInitialDatas(response) {
2018-07-23 16:41:59 +05:00
$scope.pdnsLoading = true;
$scope.failedToFetch = true;
$scope.couldNotConnect = false;
$scope.changesApplied = true;
2018-07-23 02:09:33 +05:00
}
}
2018-07-23 16:41:59 +05:00
$scope.saveStatus = function (service) {
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
$scope.pdnsLoading = false;
$scope.failedToFetch = true;
2018-07-23 02:09:33 +05:00
$scope.couldNotConnect = true;
2018-07-23 16:41:59 +05:00
$scope.changesApplied = true;
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
url = "/manageservices/saveStatus";
2018-07-23 02:09:33 +05:00
var data = {
2018-07-23 16:41:59 +05:00
status:pdnsStatus,
service: service
2018-07-23 02:09:33 +05:00
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
2018-07-23 16:41:59 +05:00
$scope.pdnsLoading = true;
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
if(response.data.status === 1){
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
$scope.failedToFetch = true;
2018-07-23 02:09:33 +05:00
$scope.couldNotConnect = true;
2018-07-23 16:41:59 +05:00
$scope.changesApplied = false;
2018-07-23 02:09:33 +05:00
}
else{
$scope.errorMessage = response.data.error_message;
2018-07-23 16:41:59 +05:00
$scope.failedToFetch = false;
2018-07-23 02:09:33 +05:00
$scope.couldNotConnect = true;
2018-07-23 16:41:59 +05:00
$scope.changesApplied = true;
2018-07-23 02:09:33 +05:00
}
}
function cantLoadInitialDatas(response) {
2018-07-23 16:41:59 +05:00
$scope.policyServerLoading = true;
$scope.failedToFetch = true;
$scope.couldNotConnect = false;
$scope.changesApplied = true;
2018-07-23 02:09:33 +05:00
}
};
});
2018-07-23 16:41:59 +05:00
/* Java script code */
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
/* Java script code */
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
app.controller('postfix', function($scope, $http, $timeout, $window) {
$scope.serviceLoading = true;
2018-07-23 02:09:33 +05:00
$scope.failedToFetch = true;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
2018-07-23 16:41:59 +05:00
var serviceStatus = false;
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
$('#serviceStatus').change(function() {
serviceStatus = $(this).prop('checked');
2018-07-23 02:09:33 +05:00
});
2018-07-23 16:41:59 +05:00
fetchPDNSStatus('postfix');
2018-07-23 02:09:33 +05:00
function fetchPDNSStatus(service){
2018-07-23 16:41:59 +05:00
$scope.serviceLoading = false;
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
$('#serviceStatus').bootstrapToggle('off');
2018-07-23 02:09:33 +05:00
url = "/manageservices/fetchStatus";
var data = {
'service' : service
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
2018-07-23 16:41:59 +05:00
$scope.serviceLoading = true;
2018-07-23 02:09:33 +05:00
if(response.data.status === 1){
if (response.data.installCheck === 1) {
2018-07-23 16:41:59 +05:00
$('#serviceStatus').bootstrapToggle('on');
2018-07-23 02:09:33 +05:00
}
}else{
$scope.failedToFetch = false;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
2018-07-23 16:41:59 +05:00
$scope.serviceLoading = true;
2018-07-23 02:09:33 +05:00
$scope.failedToFetch = true;
$scope.couldNotConnect = false;
$scope.changesApplied = true;
}
}
$scope.saveStatus = function (service) {
2018-07-23 16:41:59 +05:00
$scope.serviceLoading = false;
2018-07-23 02:09:33 +05:00
$scope.failedToFetch = true;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
url = "/manageservices/saveStatus";
var data = {
2018-07-23 16:41:59 +05:00
status:serviceStatus,
2018-07-23 02:09:33 +05:00
service: service
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
2018-07-23 16:41:59 +05:00
$scope.serviceLoading = true;
2018-07-23 02:09:33 +05:00
if(response.data.status === 1){
$scope.failedToFetch = true;
$scope.couldNotConnect = true;
$scope.changesApplied = false;
}
else{
$scope.errorMessage = response.data.error_message;
$scope.failedToFetch = false;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
}
}
function cantLoadInitialDatas(response) {
2018-07-23 16:41:59 +05:00
$scope.serviceLoading = true;
2018-07-23 02:09:33 +05:00
$scope.failedToFetch = true;
$scope.couldNotConnect = false;
$scope.changesApplied = true;
}
};
});
2018-07-23 22:11:42 +05:00
/* Java script code */
/* Java script code */
app.controller('pureFTPD', function($scope, $http, $timeout, $window) {
$scope.serviceLoading = true;
$scope.failedToFetch = true;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
var serviceStatus = false;
$('#serviceStatus').change(function() {
serviceStatus = $(this).prop('checked');
});
fetchPDNSStatus('pureftpd');
function fetchPDNSStatus(service){
$scope.serviceLoading = false;
$('#serviceStatus').bootstrapToggle('off');
url = "/manageservices/fetchStatus";
var data = {
'service' : service
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.serviceLoading = true;
if(response.data.status === 1){
if (response.data.installCheck === 1) {
$('#serviceStatus').bootstrapToggle('on');
}
}else{
$scope.failedToFetch = false;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.serviceLoading = true;
$scope.failedToFetch = true;
$scope.couldNotConnect = false;
$scope.changesApplied = true;
}
}
$scope.saveStatus = function (service) {
$scope.serviceLoading = false;
$scope.failedToFetch = true;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
url = "/manageservices/saveStatus";
var data = {
status:serviceStatus,
service: service
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.serviceLoading = true;
if(response.data.status === 1){
$scope.failedToFetch = true;
$scope.couldNotConnect = true;
$scope.changesApplied = false;
}
else{
$scope.errorMessage = response.data.error_message;
$scope.failedToFetch = false;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
}
}
function cantLoadInitialDatas(response) {
$scope.serviceLoading = true;
$scope.failedToFetch = true;
$scope.couldNotConnect = false;
$scope.changesApplied = true;
}
};
});
2018-07-23 02:09:33 +05:00
2018-07-23 16:41:59 +05:00
/* Java script code */