Added Services Page, Bug fix to Website Creation!

This commit is contained in:
usmannasir
2018-01-13 21:41:22 +05:00
parent f86a4e3c5c
commit 625f1d7218
30 changed files with 723 additions and 36 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -618,6 +618,7 @@
<li><a href="{% url 'litespeedStatus' %}" title="{% trans 'LiteSpeed Status' %}"><span>{% trans "LiteSpeed Status" %}</span></a></li>
<li><a href="{% url 'cyberCPMainLogFile' %}" title="{% trans 'CyberPanel Main Log File' %}"><span>{% trans "CyberPanel Main Log File" %}</span></a></li>
<li><a href="{% url 'services' %}" title="{% trans 'Services Status' %}"><span>{% trans "Services Status" %}</span></a></li>
</ul>

1
cyberpanel.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -277,6 +277,7 @@ app.controller('deleteDatabase', function($scope,$http) {
});
/* Java script code to delete database ends here */

View File

@@ -681,7 +681,7 @@ class preFlightsChecks:
cmd = []
cmd.append("wget")
cmd.append("http://cyberpanel.net/CyberPanel.1.6.0.tar.gz")
cmd.append("http://cyberpanel.net/CyberPanelTemp.tar.gz")
res = subprocess.call(cmd)
@@ -700,7 +700,7 @@ class preFlightsChecks:
cmd.append("tar")
cmd.append("zxf")
cmd.append("CyberPanel.1.6.0.tar.gz")
cmd.append("CyberPanelTemp.tar.gz")
res = subprocess.call(cmd)

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View File

@@ -277,3 +277,164 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
/* Java script code to read log file ends here */
/* Java script code to read log file ends here */
/* Services */
app.controller('servicesManager', function($scope,$http) {
$scope.services = false;
$scope.btnDisable = false;
$scope.actionLoader = false;
function getServiceStatus(){
$scope.btnDisable = true;
url = "/serverstatus/servicesStatus";
$http.post(url).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.status.litespeed) {
$scope.olsStatus = "Running";
$scope.olsStats = true;
$scope.olsStart = false;
$scope.olsStop = true;
$scope.olsMem = Math.round(parseInt(response.data.memUsage.litespeed) / 1048576) + " MB";
}
else {
$scope.olsStatus = "Stopped";
$scope.olsStats = false;
$scope.olsStart = true;
$scope.olsStop = false;
}
// Update SQL stats
if (response.data.status.mysql) {
$scope.sqlStatus = "Running";
$scope.sqlStats = true;
$scope.sqlStart = false;
$scope.sqlStop = true;
$scope.sqlMem = Math.round(parseInt(response.data.memUsage.mysql) / 1048576) + " MB";
}
else {
$scope.sqlStatus = "Stopped";
$scope.sqlStats = false;
$scope.sqlStart = true;
$scope.sqlStop = false;
}
// Update DNS stats
if (response.data.status.powerdns) {
$scope.dnsStatus = "Running";
$scope.dnsStats = true;
$scope.dnsStart = false;
$scope.dnsStop = true;
$scope.dnsMem = Math.round(parseInt(response.data.memUsage.powerdns) / 1048576) + " MB";
}
else {
$scope.dnsStatus = "Stopped";
$scope.dnsStats = false;
$scope.dnsStart = true;
$scope.dnsStop = false;
}
// Update FTP stats
if (response.data.status.pureftp) {
$scope.ftpStatus = "Running";
$scope.ftpStats = true;
$scope.ftpStart = false;
$scope.ftpStop = true;
$scope.ftpMem = Math.round(parseInt(response.data.memUsage.pureftp) / 1048576) + " MB";
}
else {
$scope.ftpStatus = "Stopped";
$scope.ftpStats = false;
$scope.ftpStart = true;
$scope.ftpStop = false;
}
$scope.services = true;
$scope.btnDisable = false;
}
function cantLoadInitialDatas(response) {
$scope.couldNotConnect = true;
}
};
getServiceStatus();
$scope.serviceAction = function(serviceName, action){
$scope.ActionProgress = true;
$scope.btnDisable = true;
$scope.ActionSuccessfull = false;
$scope.ActionFailed = false;
$scope.couldNotConnect = false;
$scope.actionLoader = true;
url = "/serverstatus/servicesAction";
var data = {
service:serviceName,
action:action
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
console.log(response.data);
if(response.data.serviceAction == 1){
setTimeout(function() {
getServiceStatus();
setTimeout(function() {
$scope.ActionSuccessfull = true;
$scope.ActionFailed = false;
$scope.couldNotConnect = false;
$scope.actionLoader = false;
$scope.btnDisable = false;
},1000)
}, 3000);
}
else{
setTimeout(function() {
getServiceStatus();
setTimeout(function() {
$scope.ActionSuccessfull = false;
$scope.ActionFailed = true;
$scope.couldNotConnect = false;
$scope.actionLoader = false;
$scope.btnDisable = false;
},1000)
}, 5000);
}
}
function cantLoadInitialDatas(response) {
$scope.ActionSuccessfull = false;
$scope.ActionFailed = false;
$scope.couldNotConnect = true;
$scope.actionLoader = false;
$scope.btnDisable = false;
}
}
});

View File

@@ -0,0 +1,145 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "Services - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<style>
.serviceImg { text-align:center; }
.serviceImg img { bottom: 63px; width: 100px; margin-top: -65px; background: white; padding: 10px; height: 100px;}
.service-panel { margin-top: 63px; border: 0; background: #38b4bf; }
.service-panel .panel-body { height: 188px; }
.serviceDetails { color: white; text-align:center; margin-top: 15px;}
.serviceActionBtn { margin: 10px; }
</style>
<div ng-controller="servicesManager" class="container">
<div id="page-title">
<h2>Services <img ng-show="actionLoader" src="/static/images/loading.gif"></h2>
<p>Show stats for services and actions (Start, Stop, Restart)</p>
</div>
<div >
<div class="row">
<div class="col-sm-6 col-md-6">
<div class="panel panel-default service-panel">
<div class="panel-body">
<div class="serviceImg">
<img src="{% static 'images/litespeed.png' %}" alt="OpenLitespeed" class="img-circle">
</div>
<div class="serviceDetails">
<div class="serviceHeading">
<h5><b>OpenLitespeed</b></h5>
<span class="help-block" ng-bind="olsStatus">Stopped</span>
</div>
<div class="serviceActionBtn">
<button type="button" class="btn btn-success" ng-disabled="btnDisable" ng-show="olsStart" ng-click="serviceAction('lsws','start')" data-toggle="tooltip" title="Start!"><i class="glyph-icon icon-play" aria-hidden="true"></i></button>
<button type="button" class="btn btn-warning" ng-disabled="btnDisable" ng-show="olsStop" ng-click="serviceAction('lsws','stop')" data-toggle="tooltip" title="Stop!"><i class="glyph-icon icon-pause" aria-hidden="true"></i></button>
<button type="button" class="btn btn-default" ng-disabled="btnDisable" ng-click="serviceAction('lsws','restart')" data-toggle="tooltip" title="Restart!"><i class="glyph-icon icon-refresh" aria-hidden="true"></i></button>
</div>
<div ng-show="olsStats">
<p>Memory Usage: <span ng-bind="olsMem"></span></p>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-6">
<div class="panel panel-default service-panel">
<div class="panel-body">
<div class="serviceImg">
<img src="{% static 'images/mariadb.png' %}" alt="MariaDB" class="img-circle">
</div>
<div class="serviceDetails">
<div class="serviceHeading">
<h5><b>MariaDB</b></h5>
<span class="help-block" ng-bind="sqlStatus">Stopped</span>
</div>
<div class="serviceActionBtn">
<button type="button" class="btn btn-success" ng-disabled="btnDisable" ng-show="sqlStart" ng-click="serviceAction('mysql','start')" data-toggle="tooltip" title="Start!"><i class="glyph-icon icon-play" aria-hidden="true"></i></button>
<button type="button" class="btn btn-warning" ng-disabled="btnDisable" ng-show="sqlStop" ng-click="serviceAction('mysql','stop')" data-toggle="tooltip" title="Stop!"><i class="glyph-icon icon-pause" aria-hidden="true"></i></button>
<button type="button" class="btn btn-default" ng-disabled="btnDisable" ng-click="serviceAction('mysql','restart')" data-toggle="tooltip" title="Restart!"><i class="glyph-icon icon-refresh" aria-hidden="true"></i></button>
</div>
<div ng-show="sqlStats">
<p>Memory Usage: <span ng-bind="sqlMem"></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-md-6">
<div class="panel panel-default service-panel">
<div class="panel-body">
<div class="serviceImg">
<img src="{% static 'images/powerdns.png' %}" alt="PowerDNS" class="img-circle">
</div>
<div class="serviceDetails">
<div class="serviceHeading">
<h5><b>PowerDNS</b></h5>
<span class="help-block" ng-bind="dnsStatus">Stopped</span>
</div>
<div class="serviceActionBtn">
<button type="button" class="btn btn-success" ng-disabled="btnDisable" ng-show="dnsStart" ng-click="serviceAction('pdns','start')" data-toggle="tooltip" title="Start!"><i class="glyph-icon icon-play" aria-hidden="true"></i></button>
<button type="button" class="btn btn-warning" ng-disabled="btnDisable" ng-show="dnsStop" ng-click="serviceAction('pdns','stop')" data-toggle="tooltip" title="Stop!"><i class="glyph-icon icon-pause" aria-hidden="true"></i></button>
<button type="button" class="btn btn-default" ng-disabled="btnDisable" ng-click="serviceAction('pdns','restart')" data-toggle="tooltip" title="Restart!"><i class="glyph-icon icon-refresh" aria-hidden="true"></i></button>
</div>
<div ng-show="dnsStats">
<p>Memory Usage: <span ng-bind="dnsMem"></span></p>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-6">
<div class="panel panel-default service-panel">
<div class="panel-body">
<div class="serviceImg">
<img src="{% static 'images/pureftpd.png' %}" alt="PureFTPd" class="img-circle">
</div>
<div class="serviceDetails">
<div class="serviceHeading">
<h5><b>PureFTPd</b></h5>
<span class="help-block" ng-bind="dnsStatus">Stopped</span>
</div>
<div class="serviceActionBtn">
<button type="button" class="btn btn-success" ng-disabled="btnDisable" ng-show="ftpStart" ng-click="serviceAction('pure-ftpd','start')" data-toggle="tooltip" title="Start!"><i class="glyph-icon icon-play" aria-hidden="true"></i></button>
<button type="button" class="btn btn-warning" ng-disabled="btnDisable" ng-show="ftpStop" ng-click="serviceAction('pure-ftpd','stop')" data-toggle="tooltip" title="Stop!"><i class="glyph-icon icon-pause" aria-hidden="true"></i></button>
<button type="button" class="btn btn-default" ng-disabled="btnDisable" ng-click="serviceAction('pure-ftpd','restart')" data-toggle="tooltip" title="Restart!"><i class="glyph-icon icon-refresh" aria-hidden="true"></i></button>
</div>
<div ng-show="ftpStats">
<p>Memory Usage: <span ng-bind="ftpMem"></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<div ng-show="ActionFailed" class="alert alert-danger">
<p class="ng-binding">Action Failed</p>
</div>
<div ng-show="ActionSuccessfull" class="alert alert-success ng-hide">
<p class="ng-binding">Action Completed</p>
</div>
<div ng-show="couldNotConnect" class="alert alert-danger ng-hide">
<p>Could not connect to server. Please refresh this page.</p>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -8,6 +8,8 @@ urlpatterns = [
url(r'^cyberCPMainLogFile', views.cyberCPMainLogFile, name='cyberCPMainLogFile'),
url(r'^getFurtherDataFromLogFile',views.getFurtherDataFromLogFile,name='getFurtherDataFromLogFile'),
url(r'^servicesStatus', views.servicesStatus, name='servicesStatus'),
url(r'^servicesAction', views.servicesAction, name='servicesAction'),
url(r'^services', views.services, name='services'),
]

View File

@@ -9,6 +9,9 @@ from loginSystem.views import loadLoginPage
import json
import subprocess
from loginSystem.models import Administrator
import psutil
import shlex
import socket
# Create your views here.
@@ -150,3 +153,168 @@ def getFurtherDataFromLogFile(request):
status = {"logstatus":0,"error":"Could not fetch data from log file, please see CyberCP main log file through command line."}
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getFurtherDataFromLogFile]")
return HttpResponse("Not Logged in as admin")
def services(request):
try:
userID = request.session['userID']
admin = Administrator.objects.get(pk=userID)
if admin.type == 3:
return HttpResponse("You don't have enough priviliges to access this page.")
return render(request, 'serverStatus/services.html')
except KeyError:
return redirect(loadLoginPage)
def servicesStatus(request):
try:
userID = request.session['userID']
admin = Administrator.objects.get(pk=userID)
if admin.type == 3:
final = {'error': 1, "error_message": "Not enough privilege"}
final_json = json.dumps(final)
return HttpResponse(final_json)
lsStatus = []
sqlStatus = []
dnsStatus = []
ftpStatus = []
mailStatus = []
processlist = subprocess.check_output(['ps', '-A'])
def getServiceStats(service):
if service in processlist:
return 1
else:
return 0
def getMemStats(service):
memCount = 0
for proc in psutil.process_iter():
if service in proc.name():
process = psutil.Process(proc.pid)
memCount += process.memory_info().rss
return memCount
### [1] status [2] mem
lsStatus.append(getServiceStats('litespeed'))
if getServiceStats('litespeed'):
lsStatus.append(getMemStats('litespeed'))
else:
lsStatus.append(0)
# mysql status
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = s.connect_ex(('127.0.0.1', 3306))
if result == 0:
sqlStatus.append(1)
else:
sqlStatus.append(0)
s.close()
if getServiceStats('mysql'):
sqlStatus.append(getMemStats('mysql'))
else:
sqlStatus.append(0)
dnsStatus.append(getServiceStats('pdns'))
if getServiceStats('pdns'):
dnsStatus.append(getMemStats('pdns'))
else:
dnsStatus.append(0)
ftpStatus.append(getServiceStats('pure-ftpd'))
if getServiceStats('pure-ftpd'):
ftpStatus.append(getMemStats('pure-ftpd'))
else:
ftpStatus.append(0)
mailStatus.append(getServiceStats('postfix'))
if getServiceStats('postfix'):
mailStatus.append(getMemStats('postfix'))
else:
mailStatus.append(0)
json_data = {'status':
{'litespeed': lsStatus[0],
'mysql': sqlStatus[0],
'powerdns': dnsStatus[0],
'pureftp': ftpStatus[0],
'postfix': mailStatus[0]},
'memUsage':
{'litespeed': lsStatus[1],
'mysql': sqlStatus[1],
'powerdns': dnsStatus[1],
'pureftp': ftpStatus[1],
'postfix': mailStatus[1]}}
return HttpResponse(json.dumps(json_data))
except KeyError:
return redirect(loadLoginPage)
def servicesAction(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
if admin.type == 3:
final = {'serviceAction': 0, "error_message": "Not enough privilege"}
final_json = json.dumps(final)
return HttpResponse(final_json)
try:
if request.method == 'POST':
data = json.loads(request.body)
service = data['service']
action = data['action']
if action not in ["stop", "start", "restart"]:
final_dic = {'serviceAction': 0, "error_message": "Invalid Action"}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
else:
pass
if service not in ["lsws", "mysql", "pdns", "pure-ftpd"]:
final_dic = {'serviceAction': 0, "error_message": "Invalid Service"}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
else:
command = 'sudo systemctl %s %s' % (action, service)
cmd = shlex.split(command)
res = subprocess.call(cmd)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
result = p.communicate()[0]
if res != 0:
final_dic = {'serviceAction': 0, "error_message": "Error while performing action"}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
else:
final_dic = {'serviceAction': 1, "error_message": 0}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException, msg:
final_dic = {'serviceAction': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError, msg:
final_dic = {'serviceAction': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -277,6 +277,7 @@ app.controller('deleteDatabase', function($scope,$http) {
});
/* Java script code to delete database ends here */

BIN
static/images/litespeed.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
static/images/mariadb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
static/images/powerdns.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
static/images/pureftpd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View File

@@ -277,3 +277,164 @@ app.controller('readCyberCPLogFile', function($scope,$http) {
/* Java script code to read log file ends here */
/* Java script code to read log file ends here */
/* Services */
app.controller('servicesManager', function($scope,$http) {
$scope.services = false;
$scope.btnDisable = false;
$scope.actionLoader = false;
function getServiceStatus(){
$scope.btnDisable = true;
url = "/serverstatus/servicesStatus";
$http.post(url).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.status.litespeed) {
$scope.olsStatus = "Running";
$scope.olsStats = true;
$scope.olsStart = false;
$scope.olsStop = true;
$scope.olsMem = Math.round(parseInt(response.data.memUsage.litespeed) / 1048576) + " MB";
}
else {
$scope.olsStatus = "Stopped";
$scope.olsStats = false;
$scope.olsStart = true;
$scope.olsStop = false;
}
// Update SQL stats
if (response.data.status.mysql) {
$scope.sqlStatus = "Running";
$scope.sqlStats = true;
$scope.sqlStart = false;
$scope.sqlStop = true;
$scope.sqlMem = Math.round(parseInt(response.data.memUsage.mysql) / 1048576) + " MB";
}
else {
$scope.sqlStatus = "Stopped";
$scope.sqlStats = false;
$scope.sqlStart = true;
$scope.sqlStop = false;
}
// Update DNS stats
if (response.data.status.powerdns) {
$scope.dnsStatus = "Running";
$scope.dnsStats = true;
$scope.dnsStart = false;
$scope.dnsStop = true;
$scope.dnsMem = Math.round(parseInt(response.data.memUsage.powerdns) / 1048576) + " MB";
}
else {
$scope.dnsStatus = "Stopped";
$scope.dnsStats = false;
$scope.dnsStart = true;
$scope.dnsStop = false;
}
// Update FTP stats
if (response.data.status.pureftp) {
$scope.ftpStatus = "Running";
$scope.ftpStats = true;
$scope.ftpStart = false;
$scope.ftpStop = true;
$scope.ftpMem = Math.round(parseInt(response.data.memUsage.pureftp) / 1048576) + " MB";
}
else {
$scope.ftpStatus = "Stopped";
$scope.ftpStats = false;
$scope.ftpStart = true;
$scope.ftpStop = false;
}
$scope.services = true;
$scope.btnDisable = false;
}
function cantLoadInitialDatas(response) {
$scope.couldNotConnect = true;
}
};
getServiceStatus();
$scope.serviceAction = function(serviceName, action){
$scope.ActionProgress = true;
$scope.btnDisable = true;
$scope.ActionSuccessfull = false;
$scope.ActionFailed = false;
$scope.couldNotConnect = false;
$scope.actionLoader = true;
url = "/serverstatus/servicesAction";
var data = {
service:serviceName,
action:action
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
console.log(response.data);
if(response.data.serviceAction == 1){
setTimeout(function() {
getServiceStatus();
setTimeout(function() {
$scope.ActionSuccessfull = true;
$scope.ActionFailed = false;
$scope.couldNotConnect = false;
$scope.actionLoader = false;
$scope.btnDisable = false;
},1000)
}, 3000);
}
else{
setTimeout(function() {
getServiceStatus();
setTimeout(function() {
$scope.ActionSuccessfull = false;
$scope.ActionFailed = true;
$scope.couldNotConnect = false;
$scope.actionLoader = false;
$scope.btnDisable = false;
},1000)
}, 5000);
}
}
function cantLoadInitialDatas(response) {
$scope.ActionSuccessfull = false;
$scope.ActionFailed = false;
$scope.couldNotConnect = true;
$scope.actionLoader = false;
$scope.btnDisable = false;
}
}
});

View File

@@ -51,7 +51,7 @@
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Domain Name" %}</label>
<div class="col-sm-6">
<input ng-pattern="/([\da-z\.-]+\.[a-z\.]{2,6}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?$/i" name="dom" type="text" class="form-control" ng-model="domainNameCreate" placeholder="{% trans "Do not enter WWW, it will be auto created!" %}" required>
<input ng-pattern="/*/i" name="dom" type="text" class="form-control" ng-model="domainNameCreate" placeholder="{% trans "Do not enter WWW, it will be auto created!" %}" required>
</div>
<div ng-show="websiteCreationForm.dom.$error.pattern" class="current-pack">{% trans "Invalid Domain (Note: You don't need to add 'http' or 'https')" %}</div>
</div>

View File

@@ -16,11 +16,58 @@
<div class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "Available Functions" %}
</h3>
<div class="example-box-wrapper">
{% if type == 3 %}
<div class="row">
<div class="col-md-4">
<a href="{% url 'listWebsites' %}" title="{% trans 'List Websites' %}" class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header">
{% trans "List Websites" %}
</div>
<div class="tile-content-wrapper">
<i class="glyph-icon icon-dashboard"></i>
</div>
</a>
</div>
<div class="col-md-4">
<a href="{% url 'modifyWebsite' %}" title="{% trans 'Modify Website' %}" class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header">
{% trans "Modify Website" %}
</div>
<div class="tile-content-wrapper">
<i class="glyph-icon icon-dashboard"></i>
</div>
</a>
</div>
<div class="col-md-4">
<a href="{% url 'deleteWebsite' %}" title="{% trans 'Delete Website' %}" class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header">
{% trans "Delete Website" %}
</div>
<div class="tile-content-wrapper">
<i class="glyph-icon icon-dashboard"></i>
</div>
</a>
</div>
</div>
{% else %}
<div class="row">
<div class="col-md-4">
<a href="{% url 'createWebsite' %}" title="{% trans 'Create Website' %}" class="tile-box tile-box-shortcut btn-primary">
@@ -60,12 +107,8 @@
</div>
<div class="row">
{% if viewStatus == 1 %}
<div class="col-md-4">
<a href="{% url 'siteState' %}" title="{% trans 'Suspend/Unsuspend Website' %}" class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header">
@@ -77,7 +120,6 @@
</a>
</div>
{% endif %}
<div class="col-md-4">
@@ -95,6 +137,8 @@
</div>
{% endif %}
</div>
</div>
</div>

View File

@@ -32,12 +32,7 @@ def loadWebsitesHome(request):
admin = Administrator.objects.get(pk=val)
viewStatus = 1
if admin.type == 3:
viewStatus = 0
return render(request,'websiteFunctions/index.html',{"viewStatus":viewStatus})
return render(request,'websiteFunctions/index.html',{"type":admin.type})
except KeyError:
return redirect(loadLoginPage)
@@ -50,6 +45,12 @@ def createWebsite(request):
packages = admin.package_set.all()
packagesName = []
if admin.type == 3:
final = {'error': 1, "error_message": "Not enough privilege"}
final_json = json.dumps(final)
return HttpResponse(final_json)
for items in packages:
packagesName.append(items.packageName)