Skip to content

Commit bdd2902

Browse files
committed
set up manage application page for elasticsearch
1 parent b365d84 commit bdd2902

File tree

5 files changed

+230
-6
lines changed

5 files changed

+230
-6
lines changed

baseTemplate/templates/baseTemplate/index.html

+2
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,8 @@
901901
<div class="sidebar-submenu">
902902

903903
<ul>
904+
<li><a href="{% url 'manageApplications' %}"
905+
title="{% trans 'Manage Applications' %}"><span>{% trans "Applications" %}</span></a></li>
904906
<li><a href="{% url 'managePowerDNS' %}"
905907
title="{% trans 'Manage PowerDNS' %}"><span>{% trans "Manage PowerDNS" %}</span></a>
906908
</li>

manageServices/static/manageServices/manageServices.js

+63-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* Created by usman on 6/22/18.
33
*/
44

5-
65
/* Java script code */
76

87
app.controller('powerDNS', function ($scope, $http, $timeout, $window) {
@@ -163,11 +162,8 @@ app.controller('powerDNS', function ($scope, $http, $timeout, $window) {
163162

164163
});
165164

166-
167165
/* Java script code */
168166

169-
170-
171167
/* Java script code */
172168

173169
app.controller('postfix', function ($scope, $http, $timeout, $window) {
@@ -298,7 +294,6 @@ app.controller('postfix', function ($scope, $http, $timeout, $window) {
298294

299295
/* Java script code */
300296

301-
302297
/* Java script code */
303298

304299
app.controller('pureFTPD', function ($scope, $http, $timeout, $window) {
@@ -427,4 +422,67 @@ app.controller('pureFTPD', function ($scope, $http, $timeout, $window) {
427422

428423
});
429424

425+
/* Java script code */
426+
427+
/* Java script code */
428+
429+
app.controller('manageApplications', function ($scope, $http, $timeout, $window) {
430+
431+
432+
$scope.cyberpanelLoading = true;
433+
434+
$scope.saveStatus = function (service) {
435+
436+
$scope.cyberpanelLoading = false;
437+
438+
439+
url = "/manageservices/saveStatus";
440+
441+
var data = {
442+
status: serviceStatus,
443+
service: service
444+
};
445+
446+
var config = {
447+
headers: {
448+
'X-CSRFToken': getCookie('csrftoken')
449+
}
450+
};
451+
452+
453+
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
454+
455+
456+
function ListInitialDatas(response) {
457+
$scope.cyberpanelLoading = true;
458+
459+
if (response.data.status === 1) {
460+
461+
$scope.failedToFetch = true;
462+
$scope.couldNotConnect = true;
463+
$scope.changesApplied = false;
464+
465+
}
466+
else {
467+
$scope.errorMessage = response.data.error_message;
468+
469+
$scope.failedToFetch = false;
470+
$scope.couldNotConnect = true;
471+
$scope.changesApplied = true;
472+
}
473+
474+
}
475+
476+
function cantLoadInitialDatas(response) {
477+
$scope.serviceLoading = true;
478+
$scope.failedToFetch = true;
479+
$scope.couldNotConnect = false;
480+
$scope.changesApplied = true;
481+
}
482+
483+
484+
};
485+
486+
});
487+
430488
/* Java script code */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
{% extends "baseTemplate/index.html" %}
2+
{% load i18n %}
3+
{% block title %}{% trans "Manage Applications - CyberPanel" %}{% endblock %}
4+
{% block content %}
5+
6+
{% load static %}
7+
{% get_current_language as LANGUAGE_CODE %}
8+
<!-- Current language: {{ LANGUAGE_CODE }} -->
9+
10+
11+
<div class="container">
12+
<div id="page-title">
13+
<h2>{% trans "Manage Applications" %}</h2>
14+
<p>{% trans "Install/Remove Applications from your server." %}</p>
15+
</div>
16+
<div ng-controller="manageApplications" class="panel">
17+
<div class="panel-body">
18+
<h3 class="content-box-header">
19+
{% trans "Applications" %} <img ng-hide="cyberpanelLoading" src="{% static 'images/loading.gif' %}">
20+
</h3>
21+
<div class="example-box-wrapper">
22+
23+
<!------ List of records --------------->
24+
25+
<div class="form-group">
26+
27+
<div class="col-sm-12">
28+
29+
<table class="table">
30+
<thead>
31+
<tr>
32+
<th>{% trans "Username" %}</th>
33+
<th>{% trans "Websites Limit" %}</th>
34+
<th>{% trans "Disk Usage" %}</th>
35+
<th>{% trans "ACL" %}</th>
36+
<th>{% trans "Owner" %}</th>
37+
<th>{% trans "State" %}</th>
38+
<th>{% trans "Actions" %}</th>
39+
</tr>
40+
</thead>
41+
<tbody>
42+
<tr ng-repeat="record in records track by $index">
43+
<td ng-bind="record.name"></td>
44+
<td ng-bind="record.websites"></td>
45+
<td ng-bind="record.diskUsage"></td>
46+
<td ng-bind="record.acl"></td>
47+
<td ng-bind="record.owner"></td>
48+
<td ng-bind="record.state"></td>
49+
<td>
50+
<a ng-show="record.state=='ACTIVE'"
51+
class="btn btn-border btn-alt border-red btn-link font-red" href="#"
52+
ng-click="controlUserState(record.name, 'SUSPEND')" title=""><span>{% trans 'Suspend' %}</span></a>
53+
<a ng-show="record.state=='SUSPENDED'"
54+
class="btn btn-border btn-alt border-green btn-link font-green" href="#"
55+
ng-click="controlUserState(record.name, 'ACTIVATE')" title=""><span>{% trans 'Activate' %}</span></a>
56+
<a data-toggle="modal" data-target="#settings"
57+
ng-click="editInitial(record.name)"
58+
class="btn btn-border btn-alt border-purple btn-link font-purple" href="#"
59+
title=""><span>{% trans 'Edit' %}</span></a>
60+
<a ng-click="deleteUserFinal(record.name)"
61+
class="btn btn-border btn-alt border-red btn-link font-red" href="#"
62+
title=""><span>{% trans 'Delete' %}</span></a>
63+
64+
<!--- Modal --->
65+
<div id="settings" class="modal fade" role="dialog">
66+
<div class="modal-dialog">
67+
68+
<!-- Modal content-->
69+
<div class="modal-content">
70+
<div class="modal-header">
71+
<button type="button" class="close" data-dismiss="modal">&times;
72+
</button>
73+
<h4 class="modal-title">Edit User
74+
<img ng-hide="cyberpanelLoading"
75+
src="{% static 'images/loading.gif' %}">
76+
</h4>
77+
</div>
78+
<div class="modal-body">
79+
80+
<form name="containerSettingsForm" action="/"
81+
class="form-horizontal">
82+
<div ng-hide="installationDetailsForm" class="form-group">
83+
<label class="col-sm-3 control-label">{% trans "Name" %}</label>
84+
<div class="col-sm-6">
85+
<input name="name" type="text" class="form-control"
86+
ng-model="name" readonly>
87+
</div>
88+
</div>
89+
90+
<hr>
91+
<div class="form-group">
92+
<label class="col-sm-3 control-label">{% trans "New Owner" %} </label>
93+
<div class="col-sm-6">
94+
<select ng-change="saveResellerChanges()"
95+
ng-model="$parent.newOwner"
96+
class="form-control">
97+
{% for items in resellerPrivUsers %}
98+
<option>{{ items }}</option>
99+
{% endfor %}
100+
</select>
101+
</div>
102+
</div>
103+
104+
<hr>
105+
106+
<div class="form-group">
107+
<label class="col-sm-3 control-label">{% trans "Select ACL" %} </label>
108+
<div class="col-sm-6">
109+
<select ng-change="changeACLFunc()"
110+
ng-model="$parent.selectedACL"
111+
class="form-control">
112+
{% for items in aclNames %}
113+
<option>{{ items }}</option>
114+
{% endfor %}
115+
</select>
116+
</div>
117+
</div>
118+
119+
120+
</form>
121+
122+
</div>
123+
</div>
124+
</div>
125+
</div>
126+
<!--- Modal End--->
127+
</td>
128+
</tr>
129+
</tbody>
130+
</table>
131+
</div>
132+
</div>
133+
134+
<!------ List of records --------------->
135+
136+
</div>
137+
</div>
138+
</div>
139+
140+
141+
</div>
142+
143+
144+
{% endblock %}

manageServices/urls.py

+2
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99

1010
url(r'^fetchStatus$', views.fetchStatus, name='fetchStatus'),
1111
url(r'^saveStatus$', views.saveStatus, name='saveStatus'),
12+
13+
url(r'^manageApplications$', views.manageApplications, name='manageApplications'),
1214
]

manageServices/views.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -298,4 +298,22 @@ def saveStatus(request):
298298
logging.CyberCPLogFileWriter.writeToFile(str(msg))
299299
data_ret = {'status': 0, 'error_message': str(msg)}
300300
json_data = json.dumps(data_ret)
301-
return HttpResponse(json_data)
301+
return HttpResponse(json_data)
302+
303+
def manageApplications(request):
304+
try:
305+
userID = request.session['userID']
306+
currentACL = ACLManager.loadedACL(userID)
307+
308+
if currentACL['admin'] == 1:
309+
pass
310+
else:
311+
return ACLManager.loadError()
312+
try:
313+
return render(request, 'manageServices/applications.html', {})
314+
except BaseException as msg:
315+
logging.CyberCPLogFileWriter.writeToFile(str(msg))
316+
return HttpResponse("See CyberCP main log file.")
317+
318+
except KeyError:
319+
return redirect(loadLoginPage)

0 commit comments

Comments
 (0)