dns replication

This commit is contained in:
usmannasir
2019-02-04 01:03:18 +05:00
parent 095fa6743b
commit 75c9ef9da9
51 changed files with 1230 additions and 634 deletions

View File

@@ -15,6 +15,7 @@ from models import Domains,Records
from re import match,I,M from re import match,I,M
from plogical.mailUtilities import mailUtilities from plogical.mailUtilities import mailUtilities
from plogical.acl import ACLManager from plogical.acl import ACLManager
from manageServices.models import PDNSStatus
class DNSManager: class DNSManager:
@@ -56,7 +57,16 @@ class DNSManager:
secondNSIP = data['secondNSIP'] secondNSIP = data['secondNSIP']
if Domains.objects.filter(name=domainForNS).count() == 0: if Domains.objects.filter(name=domainForNS).count() == 0:
newZone = Domains(admin=admin, name=domainForNS, type="NATIVE")
try:
pdns = PDNSStatus.objects.get(pk=1)
if pdns.type == 'MASTER':
newZone = Domains(admin=admin, name=domainForNS, type="MASTER")
else:
newZone = Domains(admin=admin, name=domainForNS, type="NATIVE")
except:
newZone = Domains(admin=admin, name=domainForNS, type="NATIVE")
newZone.save() newZone.save()
content = "ns1." + domainForNS + " hostmaster." + domainForNS + " 1 10800 3600 604800 3600" content = "ns1." + domainForNS + " hostmaster." + domainForNS + " 1 10800 3600 604800 3600"

View File

@@ -1,10 +1,3 @@
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Make sure each ForeignKey has `on_delete` set to the desired behavior.
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import models from django.db import models
@@ -91,10 +84,3 @@ class Tsigkeys(models.Model):
class Meta: class Meta:
db_table = 'tsigkeys' db_table = 'tsigkeys'
unique_together = (('name', 'algorithm'),) unique_together = (('name', 'algorithm'),)
class DNSMaster:
type = models.CharField(max_length=5, default='NATIVE')
allow_axfr_ips = models.CharField(max_length=500, default='')
also_notify = models.CharField(max_length=500, default='')

View File

@@ -12,7 +12,7 @@ def preDockerRun(function):
def wrap(request, *args, **kwargs): def wrap(request, *args, **kwargs):
try: try:
userID = request.session['userID'] userID = request.session['userID']
except KeyError: except KeyError:
return redirect(loadLoginPage) return redirect(loadLoginPage)

View File

@@ -4,3 +4,9 @@ from __future__ import unicode_literals
from django.db import models from django.db import models
# Create your models here. # Create your models here.
class PDNSStatus(models.Model):
serverStatus = models.IntegerField(default=1)
type = models.CharField(max_length=6, default='NATIVE')
allow_axfr_ips = models.CharField(max_length=500, default='')
also_notify = models.CharField(max_length=500, default='')

View File

@@ -0,0 +1,87 @@
import subprocess, shlex
from random import randint
from plogical.processUtilities import ProcessUtilities
class ServiceManager:
def __init__(self, extraArgs):
self.extraArgs = extraArgs
def managePDNS(self):
type = self.extraArgs['type']
path = '/etc/pdns/pdns.conf'
data = subprocess.check_output(shlex.split('sudo cat ' + path)).splitlines()
if type == 'MASTER':
counter = 0
slaveIPData = self.extraArgs['slaveIPData']
ipsString = slaveIPData.replace(',', '/32,')
for items in data:
if items.find('allow-axfr-ips') > -1:
data[counter] = '#' + data[counter]
if items.find('also-notify') > -1:
data[counter] = '#' + data[counter]
if items.find('daemon=') > -1:
data[counter] = '#' + data[counter]
if items.find('disable-axfr') > -1:
data[counter] = '#' + data[counter]
if items.find('slave') > -1:
data[counter] = '#' + data[counter]
counter = counter + 1
tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
writeToFile = open(tempPath, 'w')
for items in data:
writeToFile.writelines(items + '\n')
writeToFile.writelines('allow-axfr-ips=' + ipsString + '\n')
writeToFile.writelines('also-notify=' + slaveIPData + '\n')
writeToFile.writelines('daemon=no\n')
writeToFile.writelines('disable-axfr=no\n')
writeToFile.writelines('master=yes\n')
writeToFile.close()
else:
counter = 0
for items in data:
if items.find('allow-axfr-ips') > -1:
data[counter] = '#' + data[counter]
if items.find('also-notify') > -1:
data[counter] = '#' + data[counter]
if items.find('daemon=') > -1:
data[counter] = '#' + data[counter]
if items.find('disable-axfr') > -1:
data[counter] = '#' + data[counter]
if items.find('slave') > -1:
data[counter] = '#' + data[counter]
counter = counter + 1
tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
writeToFile = open(tempPath, 'w')
for items in data:
writeToFile.writelines(items + '\n')
writeToFile.writelines('slave=yes\n')
writeToFile.writelines('daemon=no\n')
writeToFile.close()
command = 'sudo mv ' + tempPath + ' ' + path
ProcessUtilities.executioner(command)

View File

@@ -5,128 +5,148 @@
/* Java script code */ /* Java script code */
app.controller('powerDNS', function($scope, $http, $timeout, $window) { app.controller('powerDNS', function ($scope, $http, $timeout, $window) {
$scope.pdnsLoading = true; $scope.pdnsLoading = true;
$scope.failedToFetch = true; $scope.failedToFetch = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = true; $scope.changesApplied = true;
$scope.slaveIPs = true;
var pdnsStatus = false; var pdnsStatus = false;
$('#pdnsStatus').change(function() { $('#pdnsStatus').change(function () {
pdnsStatus = $(this).prop('checked'); pdnsStatus = $(this).prop('checked');
}); });
fetchPDNSStatus('powerdns'); fetchPDNSStatus('powerdns');
function fetchPDNSStatus(service){ function fetchPDNSStatus(service) {
$scope.pdnsLoading = false; $scope.pdnsLoading = false;
$('#pdnsStatus').bootstrapToggle('off'); $('#pdnsStatus').bootstrapToggle('off');
url = "/manageservices/fetchStatus"; url = "/manageservices/fetchStatus";
var data = { var data = {
'service' : service 'service': service
}; };
var config = { var config = {
headers : { headers: {
'X-CSRFToken': getCookie('csrftoken') 'X-CSRFToken': getCookie('csrftoken')
} }
}; };
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
$scope.pdnsLoading = true; $scope.pdnsLoading = true;
if(response.data.status === 1){ if (response.data.status === 1) {
if (response.data.installCheck === 1) { if (response.data.installCheck === 1) {
$('#pdnsStatus').bootstrapToggle('on'); $('#pdnsStatus').bootstrapToggle('on');
}
}else{
$scope.failedToFetch = false;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.pdnsLoading = true;
$scope.failedToFetch = true;
$scope.couldNotConnect = false;
$scope.changesApplied = true;
} }
} $scope.slaveIPData = response.data.slaveIPData;
} else {
$scope.failedToFetch = false;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.pdnsLoading = true;
$scope.failedToFetch = true;
$scope.couldNotConnect = false;
$scope.changesApplied = true;
}
}
$scope.saveStatus = function (service) {
$scope.pdnsLoading = false;
$scope.failedToFetch = true;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
$scope.saveStatus = function (service) { url = "/manageservices/saveStatus";
$scope.pdnsLoading = false; if (service === 'powerdns') {
$scope.failedToFetch = true; var data = {
$scope.couldNotConnect = true; status: pdnsStatus,
$scope.changesApplied = true; service: service,
dnsMode: $scope.dnsMode,
slaveIPData: $scope.slaveIPData
};
}else {
var data = {
status: pdnsStatus,
service: service
};
}
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
url = "/manageservices/saveStatus";
var data = {
status:pdnsStatus,
service: service
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
function ListInitialDatas(response) {
$scope.pdnsLoading = true;
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); 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.policyServerLoading = true;
$scope.failedToFetch = true;
$scope.couldNotConnect = false;
$scope.changesApplied = true;
}
function ListInitialDatas(response) { };
$scope.pdnsLoading = true;
if(response.data.status === 1){ $scope.modeChange = function () {
if ($scope.dnsMode === 'MASTER') {
$scope.slaveIPs = false;
$scope.failedToFetch = true; } else {
$scope.couldNotConnect = true; $scope.slaveIPs = true;
$scope.changesApplied = false; }
}
}
else{
$scope.errorMessage = response.data.error_message;
$scope.failedToFetch = false;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
}
}
function cantLoadInitialDatas(response) {
$scope.policyServerLoading = true;
$scope.failedToFetch = true;
$scope.couldNotConnect = false;
$scope.changesApplied = true;
}
};
}); });
@@ -137,129 +157,129 @@ app.controller('powerDNS', function($scope, $http, $timeout, $window) {
/* Java script code */ /* Java script code */
app.controller('postfix', function($scope, $http, $timeout, $window) { app.controller('postfix', function ($scope, $http, $timeout, $window) {
$scope.serviceLoading = true; $scope.serviceLoading = true;
$scope.failedToFetch = true; $scope.failedToFetch = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = true; $scope.changesApplied = true;
var serviceStatus = false; var serviceStatus = false;
$('#serviceStatus').change(function() { $('#serviceStatus').change(function () {
serviceStatus = $(this).prop('checked'); serviceStatus = $(this).prop('checked');
}); });
fetchPDNSStatus('postfix'); fetchPDNSStatus('postfix');
function fetchPDNSStatus(service){ function fetchPDNSStatus(service) {
$scope.serviceLoading = false; $scope.serviceLoading = false;
$('#serviceStatus').bootstrapToggle('off'); $('#serviceStatus').bootstrapToggle('off');
url = "/manageservices/fetchStatus"; url = "/manageservices/fetchStatus";
var data = { var data = {
'service' : service 'service': service
}; };
var config = { var config = {
headers : { headers: {
'X-CSRFToken': getCookie('csrftoken') 'X-CSRFToken': getCookie('csrftoken')
} }
}; };
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
$scope.serviceLoading = true; $scope.serviceLoading = true;
if(response.data.status === 1){ if (response.data.status === 1) {
if (response.data.installCheck === 1) { if (response.data.installCheck === 1) {
$('#serviceStatus').bootstrapToggle('on'); $('#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;
} }
} } 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.saveStatus = function (service) {
$scope.serviceLoading = false; $scope.serviceLoading = false;
$scope.failedToFetch = true; $scope.failedToFetch = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = true; $scope.changesApplied = true;
url = "/manageservices/saveStatus";
url = "/manageservices/saveStatus"; var data = {
status: serviceStatus,
service: service
};
var data = { var config = {
status:serviceStatus, headers: {
service: service 'X-CSRFToken': getCookie('csrftoken')
}; }
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
$scope.serviceLoading = true; $scope.serviceLoading = true;
if(response.data.status === 1){ if (response.data.status === 1) {
$scope.failedToFetch = true; $scope.failedToFetch = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = false; $scope.changesApplied = false;
} }
else{ else {
$scope.errorMessage = response.data.error_message; $scope.errorMessage = response.data.error_message;
$scope.failedToFetch = false; $scope.failedToFetch = false;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = true; $scope.changesApplied = true;
} }
} }
function cantLoadInitialDatas(response) {
$scope.serviceLoading = true; function cantLoadInitialDatas(response) {
$scope.failedToFetch = true; $scope.serviceLoading = true;
$scope.couldNotConnect = false; $scope.failedToFetch = true;
$scope.changesApplied = true; $scope.couldNotConnect = false;
} $scope.changesApplied = true;
}
}; };
}); });
@@ -268,129 +288,129 @@ app.controller('postfix', function($scope, $http, $timeout, $window) {
/* Java script code */ /* Java script code */
app.controller('pureFTPD', function($scope, $http, $timeout, $window) { app.controller('pureFTPD', function ($scope, $http, $timeout, $window) {
$scope.serviceLoading = true; $scope.serviceLoading = true;
$scope.failedToFetch = true; $scope.failedToFetch = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = true; $scope.changesApplied = true;
var serviceStatus = false; var serviceStatus = false;
$('#serviceStatus').change(function() { $('#serviceStatus').change(function () {
serviceStatus = $(this).prop('checked'); serviceStatus = $(this).prop('checked');
}); });
fetchPDNSStatus('pureftpd'); fetchPDNSStatus('pureftpd');
function fetchPDNSStatus(service){ function fetchPDNSStatus(service) {
$scope.serviceLoading = false; $scope.serviceLoading = false;
$('#serviceStatus').bootstrapToggle('off'); $('#serviceStatus').bootstrapToggle('off');
url = "/manageservices/fetchStatus"; url = "/manageservices/fetchStatus";
var data = { var data = {
'service' : service 'service': service
}; };
var config = { var config = {
headers : { headers: {
'X-CSRFToken': getCookie('csrftoken') 'X-CSRFToken': getCookie('csrftoken')
} }
}; };
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
$scope.serviceLoading = true; $scope.serviceLoading = true;
if(response.data.status === 1){ if (response.data.status === 1) {
if (response.data.installCheck === 1) { if (response.data.installCheck === 1) {
$('#serviceStatus').bootstrapToggle('on'); $('#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;
} }
} } 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.saveStatus = function (service) {
$scope.serviceLoading = false; $scope.serviceLoading = false;
$scope.failedToFetch = true; $scope.failedToFetch = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = true; $scope.changesApplied = true;
url = "/manageservices/saveStatus";
url = "/manageservices/saveStatus"; var data = {
status: serviceStatus,
service: service
};
var data = { var config = {
status:serviceStatus, headers: {
service: service 'X-CSRFToken': getCookie('csrftoken')
}; }
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
$scope.serviceLoading = true; $scope.serviceLoading = true;
if(response.data.status === 1){ if (response.data.status === 1) {
$scope.failedToFetch = true; $scope.failedToFetch = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = false; $scope.changesApplied = false;
} }
else{ else {
$scope.errorMessage = response.data.error_message; $scope.errorMessage = response.data.error_message;
$scope.failedToFetch = false; $scope.failedToFetch = false;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = true; $scope.changesApplied = true;
} }
} }
function cantLoadInitialDatas(response) {
$scope.serviceLoading = true; function cantLoadInitialDatas(response) {
$scope.failedToFetch = true; $scope.serviceLoading = true;
$scope.couldNotConnect = false; $scope.failedToFetch = true;
$scope.changesApplied = true; $scope.couldNotConnect = false;
} $scope.changesApplied = true;
}
}; };
}); });

View File

@@ -3,86 +3,107 @@
{% block title %}{% trans "Manage PowerDNS - CyberPanel" %}{% endblock %} {% block title %}{% trans "Manage PowerDNS - CyberPanel" %}{% endblock %}
{% block content %} {% block content %}
{% load static %} {% load static %}
{% get_current_language as LANGUAGE_CODE %} {% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} --> <!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container"> <div class="container">
<div id="page-title"> <div id="page-title">
<h2>{% trans "Manage PowerDNS!" %} - <a target="_blank" href="https://go.cyberpanel.net/manage-services" style="height: 23px;line-height: 21px;" class="btn btn-border btn-alt border-red btn-link font-red" title=""><span>{% trans "Services Docs" %}</span></a> </h2> <h2>{% trans "Manage PowerDNS!" %} - <a target="_blank" href="https://go.cyberpanel.net/manage-services"
<p>{% trans "Enable or disable DNS services. " %}</p> style="height: 23px;line-height: 21px;"
</div> class="btn btn-border btn-alt border-red btn-link font-red"
title=""><span>{% trans "Services Docs" %}</span></a></h2>
<p>{% trans "Enable or disable DNS services. " %}</p>
</div>
{% if status %} {% if status %}
<div ng-controller="powerDNS" class="example-box-wrapper"> <div ng-controller="powerDNS" class="example-box-wrapper">
<div class="panel panel-body"> <div class="panel panel-body">
<h3 class="content-box-header"> <h3 class="content-box-header">
{% trans "Manage PowerDNS" %} <img ng-hide="pdnsLoading" src="/static/images/loading.gif"> {% trans "Manage PowerDNS" %} <img ng-hide="pdnsLoading" src="/static/images/loading.gif">
</h3> </h3>
<div class="content-box-wrapper"> <div class="content-box-wrapper">
<div class="row"> <div class="row">
<div style="padding: 2%" class="col-md-12"> <div style="padding: 2%" class="col-md-12">
<form action="/" id="createPackages" class="form-horizontal bordered-row"> <form action="/" id="createPackages" class="form-horizontal bordered-row">
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">PowerDNS Status</label> <label class="col-sm-3 control-label">PowerDNS Status</label>
<div class="col-sm-6"> <div class="col-sm-6">
<input type="checkbox" id="pdnsStatus" data-toggle="toggle"> <input type="checkbox" id="pdnsStatus" data-toggle="toggle">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label"></label> <label class="col-sm-3 control-label">{% trans "Select Function Mode" %}</label>
<div class="col-sm-4"> <div class="col-sm-6">
<button type="button" ng-click="saveStatus('powerdns')" class="btn btn-primary btn-lg">{% trans "Save changes" %}</button> <select ng-change="modeChange()" ng-model="dnsMode" class="form-control">
<option>MASTER</option>
<option>SLAVE</option>
</select>
</div>
<div class="current-pack">{% trans 'Default is Slave Mode' %}</div>
</div>
</div> <div ng-hide="slaveIPs" class="form-group">
</div> <label class="col-sm-3 control-label">{% trans "Slave IPs" %}</label>
<div class="col-sm-6">
<input placeholder="Comma separated listed of Slave Server IPs." type="text" class="form-control" ng-model="slaveIPData" required>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label"></label> <label class="col-sm-3 control-label"></label>
<div class="col-sm-4"> <div class="col-sm-4">
<button type="button" ng-click="saveStatus('powerdns')"
class="btn btn-primary btn-lg">{% trans "Save changes" %}</button>
<div ng-hide="failedToFetch" class="alert alert-danger"> </div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<div ng-hide="failedToFetch" class="alert alert-danger">
<p>{% trans "Error message: " %} {$ errorMessage $}</p> <p>{% trans "Error message: " %} {$ errorMessage $}</p>
</div> </div>
<div ng-hide="changesApplied" class="alert alert-success"> <div ng-hide="changesApplied" class="alert alert-success">
<p>{% trans "Changes successfully applied." %}</p> <p>{% trans "Changes successfully applied." %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect. Please refresh this page." %} </p>
</div>
</div>
</div> </div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect. Please refresh this page." %} </p>
</div>
</form>
</div> </div>
</div> </div>
</div>
</form>
</div>
</div> </div>
</div> </div>
</div>
{% else %}
<div class="alert alert-danger">
<p>{% trans "Only administrator can manage services." %}</p>
</div>
{% endif %}
</div> </div>
{% else %}
<div class="alert alert-danger">
<p>{% trans "Only administrator can manage services." %}</p>
</div>
{% endif %}
</div>
{% endblock %} {% endblock %}

View File

@@ -10,11 +10,11 @@ import json
from plogical.mailUtilities import mailUtilities from plogical.mailUtilities import mailUtilities
import subprocess, shlex import subprocess, shlex
from plogical.acl import ACLManager from plogical.acl import ACLManager
from models import PDNSStatus
from .serviceManager import ServiceManager
# Create your views here. # Create your views here.
# Create your views here.
def managePowerDNS(request): def managePowerDNS(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -90,14 +90,20 @@ def fetchStatus(request):
service = data['service'] service = data['service']
if service == 'powerdns': if service == 'powerdns':
if os.path.exists('/home/cyberpanel/powerdns'): data_ret = {}
data_ret = {'status': 1, 'error_message': 'None', 'installCheck': 1} data_ret['status'] = 1
json_data = json.dumps(data_ret)
return HttpResponse(json_data) try:
else: pdns = PDNSStatus.objects.get(pk=1)
data_ret = {'status': 1, 'error_message': 'None', 'installCheck': 0} data_ret['installCheck'] = pdns.serverStatus
json_data = json.dumps(data_ret) data_ret['slaveIPData'] = pdns.also_notify
return HttpResponse(json_data) except:
PDNSStatus(serverStatus=1).save()
data_ret['installCheck'] = 0
data_ret['slaveIPData'] = ''
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
elif service == 'postfix': elif service == 'postfix':
if os.path.exists('/home/cyberpanel/postfix'): if os.path.exists('/home/cyberpanel/postfix'):
@@ -151,26 +157,40 @@ def saveStatus(request):
if service == 'powerdns': if service == 'powerdns':
servicePath = '/home/cyberpanel/powerdns'
if status == True: if status == True:
writeToFile = open(servicePath, 'w+')
writeToFile.close() pdns = PDNSStatus.objects.get(pk=1)
pdns.serverStatus = 1
pdns.allow_axfr_ips = data['slaveIPData'].replace(',', '/32,')
pdns.also_notify = data['slaveIPData']
pdns.type = data['dnsMode']
pdns.save()
extraArgs = {}
extraArgs['type'] = data['dnsMode']
extraArgs['slaveIPData'] = data['slaveIPData']
sm = ServiceManager(extraArgs)
sm.managePDNS()
command = 'sudo systemctl start pdns' command = 'sudo systemctl start pdns'
subprocess.call(shlex.split(command)) subprocess.call(shlex.split(command))
command = 'sudo systemctl enable pdns'
subprocess.call(shlex.split(command))
else: else:
pdns = PDNSStatus.objects.get(pk=1)
pdns.serverStatus = 0
pdns.save()
command = 'sudo systemctl stop pdns' command = 'sudo systemctl stop pdns'
subprocess.call(shlex.split(command)) subprocess.call(shlex.split(command))
command = 'sudo systemctl disable pdns' command = 'sudo systemctl disable pdns'
subprocess.call(shlex.split(command)) subprocess.call(shlex.split(command))
try:
os.remove(servicePath)
except:
pass
elif service == 'postfix': elif service == 'postfix':

View File

@@ -9,6 +9,7 @@ import subprocess
import shlex import shlex
from dns.models import Domains,Records from dns.models import Domains,Records
from processUtilities import ProcessUtilities from processUtilities import ProcessUtilities
from manageServices.models import PDNSStatus
class DNS: class DNS:
@@ -36,7 +37,16 @@ class DNS:
if len(subDomain) == 0: if len(subDomain) == 0:
if Domains.objects.filter(name=topLevelDomain).count() == 0: if Domains.objects.filter(name=topLevelDomain).count() == 0:
zone = Domains(admin=admin, name=topLevelDomain, type="NATIVE") try:
pdns = PDNSStatus.objects.get(pk=1)
if pdns.type == 'MASTER':
zone = Domains(admin=admin, name=topLevelDomain, type="MASTER")
else:
zone = Domains(admin=admin, name=topLevelDomain, type="NATIVE")
except:
zone = Domains(admin=admin, name=topLevelDomain, type="NATIVE")
zone.save() zone.save()
content = "ns1." + topLevelDomain + " hostmaster." + topLevelDomain + " 1 10800 3600 604800 3600" content = "ns1." + topLevelDomain + " hostmaster." + topLevelDomain + " 1 10800 3600 604800 3600"
@@ -155,8 +165,14 @@ class DNS:
record.save() record.save()
else: else:
if Domains.objects.filter(name=topLevelDomain).count() == 0: if Domains.objects.filter(name=topLevelDomain).count() == 0:
zone = Domains(admin=admin, name=topLevelDomain, type="NATIVE") try:
zone.save() pdns = PDNSStatus.objects.get(pk=1)
if pdns.type == 'MASTER':
zone = Domains(admin=admin, name=topLevelDomain, type="MASTER")
else:
zone = Domains(admin=admin, name=topLevelDomain, type="NATIVE")
except:
zone = Domains(admin=admin, name=topLevelDomain, type="NATIVE")
content = "ns1." + topLevelDomain + " hostmaster." + topLevelDomain + " 1 10800 3600 604800 3600" content = "ns1." + topLevelDomain + " hostmaster." + topLevelDomain + " 1 10800 3600 604800 3600"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -169,9 +169,13 @@ app.controller('runContainer', function ($scope, $http) {
}; };
$.each($scope.portType, function (port, protocol) { try {
data[port + "/" + protocol] = $scope.eport[port]; $.each($scope.portType, function (port, protocol) {
}); data[port + "/" + protocol] = $scope.eport[port];
});
}
catch (err) {
}
var config = { var config = {
headers: { headers: {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -2,12 +2,21 @@
width: 25%; width: 25%;
} }
#navBar{ /*#navBar{
background: -moz-linear-gradient(#a4dbf5, #8cc5e0); background: -moz-linear-gradient(#a4dbf5, #8cc5e0);
background: -webkit-linear-gradient(#a4dbf5, #8cc5e0); background: -webkit-linear-gradient(#a4dbf5, #8cc5e0);
background: -o-linear-gradient(#a4dbf5, #8cc5e0); background: -o-linear-gradient(#a4dbf5, #8cc5e0);
}*/
#navBar {
background: #0daeff; /* Old browsers */
background: -moz-linear-gradient(-45deg, #0daeff 0%,#3939ad 30%); /* FF3.6-15 */
background: -webkit-linear-gradient(-45deg, #0daeff 0%,#3939ad 30%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(-45deg, #0daeff 0%,#3939ad 30%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3939ad', endColorstr='#0daeff',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
}
.navbar-brand {
margin: 0 1rem 0 1rem;
} }
#mainRow{ #mainRow{
margin: 1%; margin: 1%;
} }
@@ -42,3 +51,126 @@
margin-bottom: 2%; margin-bottom: 2%;
margin-top: 2%; margin-top: 2%;
} }
.flex-wrap {
display: flex;
flex-wrap: wrap;
}
.mt-5 {
margin-top: 5px !important;
}
.mt-10 {
margin-top: 10px;
}
.mt-20 {
margin-top: 20px;
}
.mt-30 {
margin-top: 30px;
}
.mr-10 {
margin-right: 10px;
}
.mb-10 {
margin-bottom: 10px;
}
.ml-10 {
margin-left: 10px;
}
.my-10 {
margin-top: 10px;
margin-bottom: 10px;
}
.mx-5 {
margin-left: 5px;
margin-right: 5px;
}
.mx-10 {
margin-left: 10px;
margin-right: 10px;
}
.header-logo {
width: 315px;
/* text-align: center;*/
font-size: 16px;
float: left;
position: relative;
}
a.nav-link {
color: #add8e6;
}
a.nav-link:hover {
color: #E4F2F7;
}
.point-events {
pointer-events: all;
}
.card-header {
padding: .75rem 1.25rem;
margin-bottom: 0;
background-color: transparent;
border-bottom: none;
}
.form-control {
padding: 0 .5rem;
border: 1px solid #eeeeee;
color: #777;
font-size: .95em;
}
.form-control[readonly] {
background-color: transparent;
}
a {
color: #6C6CA4;
text-decoration: none;
background-color: transparent;
-webkit-text-decoration-skip: objects;
}
a:hover {
color: #8989B6;
text-decoration: none;
background-color: transparent;
-webkit-text-decoration-skip: objects;
}
#tableHead {
background: #8989B6;
color: #E1E1EC;
}
.table td, .table th {
padding: .15em;
vertical-align: top;
border-top: 1px solid #e9ecef;
}
.table thead th {
vertical-align: bottom;
border-bottom: 1px solid #e9ecef;
font-weight: 400;
}
.table td {
font-size: 14px;
color: #666666;
}
.list-group-item {
padding: .2em 1.25rem;
}
i.fa.fa-file {
color: #6C6CA4 !important;
}
i.fa.fa-minus {
color: #6C6CA4 !important;
}
i.fa.fa-plus {
color: #6C6CA4 !important;
}
.list-group-item {
background-color: transparent;
}
.bg-lightgray {
background: #F9F9FA;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -711,6 +711,7 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader,
function findFileExtension(fileName) { function findFileExtension(fileName) {
return (/[.]/.exec(fileName)) ? /[^.]+$/.exec(fileName) : undefined; return (/[.]/.exec(fileName)) ? /[^.]+$/.exec(fileName) : undefined;
} }
$scope.fetchForTableSecondary(null, "startPoint");
// html editor // html editor
@@ -1569,5 +1570,3 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader,
}); });

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 877 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 834 B

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 888 B

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@@ -17,8 +17,6 @@ app.controller('sslIssueCtrl', function($scope,$http) {
$scope.issueSSLBtn = false; $scope.issueSSLBtn = false;
}; };
$scope.issueSSL = function(){ $scope.issueSSL = function(){
$scope.manageSSLLoading = false; $scope.manageSSLLoading = false;

View File

@@ -5,128 +5,148 @@
/* Java script code */ /* Java script code */
app.controller('powerDNS', function($scope, $http, $timeout, $window) { app.controller('powerDNS', function ($scope, $http, $timeout, $window) {
$scope.pdnsLoading = true; $scope.pdnsLoading = true;
$scope.failedToFetch = true; $scope.failedToFetch = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = true; $scope.changesApplied = true;
$scope.slaveIPs = true;
var pdnsStatus = false; var pdnsStatus = false;
$('#pdnsStatus').change(function() { $('#pdnsStatus').change(function () {
pdnsStatus = $(this).prop('checked'); pdnsStatus = $(this).prop('checked');
}); });
fetchPDNSStatus('powerdns'); fetchPDNSStatus('powerdns');
function fetchPDNSStatus(service){ function fetchPDNSStatus(service) {
$scope.pdnsLoading = false; $scope.pdnsLoading = false;
$('#pdnsStatus').bootstrapToggle('off'); $('#pdnsStatus').bootstrapToggle('off');
url = "/manageservices/fetchStatus"; url = "/manageservices/fetchStatus";
var data = { var data = {
'service' : service 'service': service
}; };
var config = { var config = {
headers : { headers: {
'X-CSRFToken': getCookie('csrftoken') 'X-CSRFToken': getCookie('csrftoken')
} }
}; };
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
$scope.pdnsLoading = true; $scope.pdnsLoading = true;
if(response.data.status === 1){ if (response.data.status === 1) {
if (response.data.installCheck === 1) { if (response.data.installCheck === 1) {
$('#pdnsStatus').bootstrapToggle('on'); $('#pdnsStatus').bootstrapToggle('on');
}
}else{
$scope.failedToFetch = false;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.pdnsLoading = true;
$scope.failedToFetch = true;
$scope.couldNotConnect = false;
$scope.changesApplied = true;
} }
} $scope.slaveIPData = response.data.slaveIPData;
} else {
$scope.failedToFetch = false;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.pdnsLoading = true;
$scope.failedToFetch = true;
$scope.couldNotConnect = false;
$scope.changesApplied = true;
}
}
$scope.saveStatus = function (service) {
$scope.pdnsLoading = false;
$scope.failedToFetch = true;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
$scope.saveStatus = function (service) { url = "/manageservices/saveStatus";
$scope.pdnsLoading = false; if (service === 'powerdns') {
$scope.failedToFetch = true; var data = {
$scope.couldNotConnect = true; status: pdnsStatus,
$scope.changesApplied = true; service: service,
dnsMode: $scope.dnsMode,
slaveIPData: $scope.slaveIPData
};
}else {
var data = {
status: pdnsStatus,
service: service
};
}
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
url = "/manageservices/saveStatus";
var data = {
status:pdnsStatus,
service: service
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
function ListInitialDatas(response) {
$scope.pdnsLoading = true;
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); 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.policyServerLoading = true;
$scope.failedToFetch = true;
$scope.couldNotConnect = false;
$scope.changesApplied = true;
}
function ListInitialDatas(response) { };
$scope.pdnsLoading = true;
if(response.data.status === 1){ $scope.modeChange = function () {
if ($scope.dnsMode === 'MASTER') {
$scope.slaveIPs = false;
$scope.failedToFetch = true; } else {
$scope.couldNotConnect = true; $scope.slaveIPs = true;
$scope.changesApplied = false; }
}
}
else{
$scope.errorMessage = response.data.error_message;
$scope.failedToFetch = false;
$scope.couldNotConnect = true;
$scope.changesApplied = true;
}
}
function cantLoadInitialDatas(response) {
$scope.policyServerLoading = true;
$scope.failedToFetch = true;
$scope.couldNotConnect = false;
$scope.changesApplied = true;
}
};
}); });
@@ -137,129 +157,129 @@ app.controller('powerDNS', function($scope, $http, $timeout, $window) {
/* Java script code */ /* Java script code */
app.controller('postfix', function($scope, $http, $timeout, $window) { app.controller('postfix', function ($scope, $http, $timeout, $window) {
$scope.serviceLoading = true; $scope.serviceLoading = true;
$scope.failedToFetch = true; $scope.failedToFetch = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = true; $scope.changesApplied = true;
var serviceStatus = false; var serviceStatus = false;
$('#serviceStatus').change(function() { $('#serviceStatus').change(function () {
serviceStatus = $(this).prop('checked'); serviceStatus = $(this).prop('checked');
}); });
fetchPDNSStatus('postfix'); fetchPDNSStatus('postfix');
function fetchPDNSStatus(service){ function fetchPDNSStatus(service) {
$scope.serviceLoading = false; $scope.serviceLoading = false;
$('#serviceStatus').bootstrapToggle('off'); $('#serviceStatus').bootstrapToggle('off');
url = "/manageservices/fetchStatus"; url = "/manageservices/fetchStatus";
var data = { var data = {
'service' : service 'service': service
}; };
var config = { var config = {
headers : { headers: {
'X-CSRFToken': getCookie('csrftoken') 'X-CSRFToken': getCookie('csrftoken')
} }
}; };
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
$scope.serviceLoading = true; $scope.serviceLoading = true;
if(response.data.status === 1){ if (response.data.status === 1) {
if (response.data.installCheck === 1) { if (response.data.installCheck === 1) {
$('#serviceStatus').bootstrapToggle('on'); $('#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;
} }
} } 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.saveStatus = function (service) {
$scope.serviceLoading = false; $scope.serviceLoading = false;
$scope.failedToFetch = true; $scope.failedToFetch = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = true; $scope.changesApplied = true;
url = "/manageservices/saveStatus";
url = "/manageservices/saveStatus"; var data = {
status: serviceStatus,
service: service
};
var data = { var config = {
status:serviceStatus, headers: {
service: service 'X-CSRFToken': getCookie('csrftoken')
}; }
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
$scope.serviceLoading = true; $scope.serviceLoading = true;
if(response.data.status === 1){ if (response.data.status === 1) {
$scope.failedToFetch = true; $scope.failedToFetch = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = false; $scope.changesApplied = false;
} }
else{ else {
$scope.errorMessage = response.data.error_message; $scope.errorMessage = response.data.error_message;
$scope.failedToFetch = false; $scope.failedToFetch = false;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = true; $scope.changesApplied = true;
} }
} }
function cantLoadInitialDatas(response) {
$scope.serviceLoading = true; function cantLoadInitialDatas(response) {
$scope.failedToFetch = true; $scope.serviceLoading = true;
$scope.couldNotConnect = false; $scope.failedToFetch = true;
$scope.changesApplied = true; $scope.couldNotConnect = false;
} $scope.changesApplied = true;
}
}; };
}); });
@@ -268,129 +288,129 @@ app.controller('postfix', function($scope, $http, $timeout, $window) {
/* Java script code */ /* Java script code */
app.controller('pureFTPD', function($scope, $http, $timeout, $window) { app.controller('pureFTPD', function ($scope, $http, $timeout, $window) {
$scope.serviceLoading = true; $scope.serviceLoading = true;
$scope.failedToFetch = true; $scope.failedToFetch = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = true; $scope.changesApplied = true;
var serviceStatus = false; var serviceStatus = false;
$('#serviceStatus').change(function() { $('#serviceStatus').change(function () {
serviceStatus = $(this).prop('checked'); serviceStatus = $(this).prop('checked');
}); });
fetchPDNSStatus('pureftpd'); fetchPDNSStatus('pureftpd');
function fetchPDNSStatus(service){ function fetchPDNSStatus(service) {
$scope.serviceLoading = false; $scope.serviceLoading = false;
$('#serviceStatus').bootstrapToggle('off'); $('#serviceStatus').bootstrapToggle('off');
url = "/manageservices/fetchStatus"; url = "/manageservices/fetchStatus";
var data = { var data = {
'service' : service 'service': service
}; };
var config = { var config = {
headers : { headers: {
'X-CSRFToken': getCookie('csrftoken') 'X-CSRFToken': getCookie('csrftoken')
} }
}; };
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
$scope.serviceLoading = true; $scope.serviceLoading = true;
if(response.data.status === 1){ if (response.data.status === 1) {
if (response.data.installCheck === 1) { if (response.data.installCheck === 1) {
$('#serviceStatus').bootstrapToggle('on'); $('#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;
} }
} } 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.saveStatus = function (service) {
$scope.serviceLoading = false; $scope.serviceLoading = false;
$scope.failedToFetch = true; $scope.failedToFetch = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = true; $scope.changesApplied = true;
url = "/manageservices/saveStatus";
url = "/manageservices/saveStatus"; var data = {
status: serviceStatus,
service: service
};
var data = { var config = {
status:serviceStatus, headers: {
service: service 'X-CSRFToken': getCookie('csrftoken')
}; }
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) { function ListInitialDatas(response) {
$scope.serviceLoading = true; $scope.serviceLoading = true;
if(response.data.status === 1){ if (response.data.status === 1) {
$scope.failedToFetch = true; $scope.failedToFetch = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = false; $scope.changesApplied = false;
} }
else{ else {
$scope.errorMessage = response.data.error_message; $scope.errorMessage = response.data.error_message;
$scope.failedToFetch = false; $scope.failedToFetch = false;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.changesApplied = true; $scope.changesApplied = true;
} }
} }
function cantLoadInitialDatas(response) {
$scope.serviceLoading = true; function cantLoadInitialDatas(response) {
$scope.failedToFetch = true; $scope.serviceLoading = true;
$scope.couldNotConnect = false; $scope.failedToFetch = true;
$scope.changesApplied = true; $scope.couldNotConnect = false;
} $scope.changesApplied = true;
}
}; };
}); });

View File

@@ -10,3 +10,230 @@
border-radius: 25px; border-radius: 25px;
border-color:#3498db border-color:#3498db
} }
.table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>th {
color: #777777;
font-weight: 400;
border-color: #cccccc;
border-width: 1px;
background-color: transparent;
}
.table {
font-size: 14px;
width: 100%;
border-spacing: 0;
border-collapse: separate;
border-radius: 5px;
background: #fdfdfd;
padding: 0px 12px;
margin: 10px 12px;
}
.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th {
/* padding: 10px; */
border-top-width: 1px;
border-top-style: solid;
text-align: left;
}
.mt-5 {
margin-top: 5px;
}
.mt-10 {
margin-top: 10px;
}
.mt-20 {
margin-top: 20px;
}
.mt-30 {
margin-top: 30px;
}
.mr-10 {
margin-right: 10px;
}
.mb-10 {
margin-bottom: 10px;
}
.ml-10 {
margin-left: 10px;
}
.my-10 {
margin-top: 10px;
margin-bottom: 10px;
}
.mx-5 {
margin-left: 5px;
margin-right: 5px;
}
.mx-10 {
margin-left: 10px;
margin-right: 10px;
}
.title-hero {
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
margin: 0 0 15px;
padding: 0;
text-transform: none;
font-size: 14px;
opacity: 1;
color: #777777;
font-weight: 400;
}
.bs-badge {
font-size: 11px;
font-weight: 400;
line-height: 19px;
display: inline-block;
min-width: 20px;
padding: 0 5px 0 4px;
border-radius: 2px;
}
.row-title {
color: #778899;
}
/*span.h4 {
white-space: nowrap;
}*/
.panel-body {
white-space: nowrap;
}
.bg-gradient-9 {
background: #0daeff; /* Old browsers */
background: -moz-linear-gradient(-45deg, #0daeff 0%,#3939ad 30%); /* FF3.6-15 */
background: -webkit-linear-gradient(-45deg, #0daeff 0%,#3939ad 30%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(-45deg, #0daeff 0%,#3939ad 30%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3939ad', endColorstr='#0daeff',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
}
#page-header .user-account-btn>a.user-profile .glyph-icon, .logo-bg {
background-color: rgba(0,0,0,.15);
}
a:hover {
text-decoration: none;
}
.text-success {
color: #29A329 !important;
}
.alert-success, .alert-success a, .parsley-success {
color: #1e620f;
border-color: #7cd362;
background: #E4FFE4;
}
.flex {
display: flex;
}
.align-center {
margin: 0 auto;
}
.text-bold {
font-weight: 600;
}
.tile-box-shortcut .tile-header {
background: 0 0;
padding: 25px;
position: absolute;
font-size: 18px;
font-weight: 400;
left: 3em;
bottom: 0px;
}
.tile-box-shortcut .tile-content-wrapper>.glyph-icon {
position: absolute;
left: 25px;
top: 40px;
}
.fa {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: 2.25em;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
position: absolute;
left: 25px;
top: 28px;
}
.bs-badge {
font-size: 18px;
font-weight: 100;
line-height: 19px;
display: inline-block;
min-width: 20px;
padding: 0 5px 0 4px;
border-radius: 2px;
color: #afeeee;
}
.tile-box-shortcut .bs-badge {
left: auto;
right: 10px;
top: 30px;
background: transparent;
}
#sidebar-menu {
background: #EAEAF1;
}
#page-sidebar ul li a .glyph-icon {
color: #191970;
}
#header-logo .logo-content-big, .logo-content-small {
height: 40px;
left: 15px;
}
#mobile-navigation .logo-content-small {
width: 50px;
display: block;
left: 75px;
}
#header-nav-left {
margin: 0 20px;
}
#page-content {
background: #ffffff;
}
.service-panel {
background: #A1BDC6 !important;
}
.serviceImg img {
box-shadow: 0 0 2px 1px rgba(0,0,0,.05);
}
.btn-icon {
top: 0px;
left: 0px;
margin: 0px auto;
position: relative;
font-size: 16px;
}
.tab-mod {
color: #777777;
background: transparent;
border-color: #dddddd;
}
.btn-primary {
background: #33ADFF;
border-color: #0099FF;
}
.btn-primary:hover,.btn-primary:focus {
background: #5CBDFF;
border-color: #33ADFF;
}
.btn-min-width {
min-width: 350px;
}

View File

@@ -247,10 +247,8 @@ app.controller('listWebsites', function ($scope, $http) {
} }
function cantLoadInitialData(response) { function cantLoadInitialData(response) {
console.log("not good");
} }
$scope.getFurtherWebsitesFromDB = function (pageNumber) { $scope.getFurtherWebsitesFromDB = function (pageNumber) {
var config = { var config = {
@@ -287,6 +285,58 @@ app.controller('listWebsites', function ($scope, $http) {
} }
};
$scope.cyberPanelLoading = true;
$scope.issueSSL = function (virtualHost) {
$scope.cyberPanelLoading = false;
var url = "/manageSSL/issueSSL";
var data = {
virtualHost: virtualHost
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.cyberPanelLoading = true;
if (response.data.SSL === 1) {
new PNotify({
title: 'Success!',
text: 'SSL successfully issued.',
type: 'success'
});
}
else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
}; };
}); });