separate services
This commit is contained in:
parent
a43d2104ef
commit
8753a380ba
5 changed files with 89 additions and 22 deletions
|
@ -7,6 +7,7 @@ from flask_login import LoginManager
|
||||||
from flask_wtf.csrf import CSRFProtect, CSRFError
|
from flask_wtf.csrf import CSRFProtect, CSRFError
|
||||||
from flask_babel import Babel, lazy_gettext
|
from flask_babel import Babel, lazy_gettext
|
||||||
from flask_moment import Moment
|
from flask_moment import Moment
|
||||||
|
#from flask_httpauth import import import HTTPBasicAuth
|
||||||
|
|
||||||
from werkzeug.contrib.fixers import ProxyFix
|
from werkzeug.contrib.fixers import ProxyFix
|
||||||
from config import config
|
from config import config
|
||||||
|
@ -18,6 +19,7 @@ app.wsgi_app = ProxyFix(app.wsgi_app)
|
||||||
|
|
||||||
db = SQLAlchemy(session_options = { "autoflush": False })
|
db = SQLAlchemy(session_options = { "autoflush": False })
|
||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
|
#apiauth = HTTPBasicAuth()
|
||||||
lm = LoginManager()
|
lm = LoginManager()
|
||||||
lm.init_app(app)
|
lm.init_app(app)
|
||||||
lm.login_view = 'auth.login'
|
lm.login_view = 'auth.login'
|
||||||
|
|
|
@ -81,27 +81,6 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% for server in servers %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<div class="panel panel-primary panel-transparent">
|
|
||||||
<div class="panel-body">
|
|
||||||
<div class="col-md-8">
|
|
||||||
<img src="../../static/images/server.png" width="80%"><br /><br />
|
|
||||||
<a href="/chat"><button type="button" class="btn btn-lg btn-success">Order VPS</button></a>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
Alias: <b>{{ server.name }}</b><br />
|
|
||||||
Processor: <b>{{ server.cpu }}</b><br />
|
|
||||||
Memory: <b>{{ server.mem }}</b><br />
|
|
||||||
Storage: <b>{{ server.hdd }}</b><br />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
<div class="container-fluid-index">
|
<div class="container-fluid-index">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
|
|
21
app/templates/main/serverlist.html
Normal file
21
app/templates/main/serverlist.html
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{% for server in servers %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="panel panel-primary panel-transparent">
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<img src="../../static/images/server.png" width="80%"><br /><br />
|
||||||
|
<a href="/chat"><button type="button" class="btn btn-lg btn-success">Order VPS</button></a>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
Alias: <b>{{ server.name }}</b><br />
|
||||||
|
Processor: <b>{{ server.cpu }}</b><br />
|
||||||
|
Memory: <b>{{ server.mem }}</b><br />
|
||||||
|
Storage: <b>{{ server.hdd }}</b><br />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
51
app/templates/panel/services.html
Normal file
51
app/templates/panel/services.html
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
{% block services %}
|
||||||
|
{% if inv_services != [] %}
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="panel panel-info" id="services">
|
||||||
|
<div class="panel-heading">Services</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<div id="no-more-tables">
|
||||||
|
<table class="table table-hover table-striped table-condensed cf">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Category</th>
|
||||||
|
<th>Description</th>
|
||||||
|
<th>Last Charged</th>
|
||||||
|
<th>Time Left</th>
|
||||||
|
</tr>
|
||||||
|
<tbody>
|
||||||
|
{% for service in inv_services %}
|
||||||
|
{% if service.enabled == False %}
|
||||||
|
<tr class="danger">
|
||||||
|
{% else %}
|
||||||
|
{% if service.warning == True %}
|
||||||
|
<tr class="warning">
|
||||||
|
{% else %}
|
||||||
|
<tr>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
<td data-title="Category">{{ service.category }}</td>
|
||||||
|
<td data-title="Description" >{{ service.description }}</td>
|
||||||
|
<td data-title="Last Charged">{{ moment(service.date_last_charge).format('lll') }} ({{ moment(service.date_last_charge).fromNow() }})</td>
|
||||||
|
{% if service.enabled == False %}
|
||||||
|
<td data-title="Time Left"><button class="btn btn-default btn-success" onclick="window.open('/smanager/activate/{{ service.pid }}','_self');"><span class="glyphicon glyphicon-bell" aria-hidden="true"></span> Activate</button></td>
|
||||||
|
{% else %}
|
||||||
|
{% if service.warning == True %}
|
||||||
|
<td data-title="Time Left"><button class="btn btn-default btn-success" onclick="window.open('/smanager/activate/{{ service.pid }}','_self');"><span class="glyphicon glyphicon-bell" aria-hidden="true"></span> Renew ({{ service.daysleft }} days left)</button></td>
|
||||||
|
{% else %}
|
||||||
|
<td data-title="Time Left">{{ service.daysleft }} day(s)</td>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</tr >
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<!-- <button class="btn btn-default" onclick="window.open('{{ url_for('smanager.requestservice') }}','_self')"><img class="icon icons8-Key-2" width="32" height="32" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAADwUlEQVRYhdXYz0/bVhwA8Bz4I/Yn9A/gwKGHHApxiENwo8IG2rSqh/XUw267cRmJY8dOQpIGOq2cdtguFZNoUQQeiOBnm7h4iB+TRkJwkiJtdZ0GQzPLeTtU0bIQ0qQ8wP1K30sU6X3y/X7fs18cjk89Bsn1fjwEAgQj7nhpQXMFeeilBY1gpV2cFkgsCG7fCAwL8E5fWBQ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u91pyNygAAAABJRU5ErkJggg==">Request</button>-->
|
||||||
|
{% else %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -1,4 +1,4 @@
|
||||||
from flask import render_template, abort, redirect, url_for, abort, flash, request, current_app, make_response, g
|
from flask import jsonify, render_template, abort, redirect, url_for, abort, flash, request, current_app, make_response, g
|
||||||
from flask_login import login_required, login_user, logout_user, current_user
|
from flask_login import login_required, login_user, logout_user, current_user
|
||||||
from flask_sqlalchemy import get_debug_queries
|
from flask_sqlalchemy import get_debug_queries
|
||||||
|
|
||||||
|
@ -27,6 +27,20 @@ def after_request(response):
|
||||||
current_app.logger.warning('Slow query: %s\nParameters: %s\nDuration: %fs\nContext: %s\n' % (query.statement, query.parameters, query.duration, query.context))
|
current_app.logger.warning('Slow query: %s\nParameters: %s\nDuration: %fs\nContext: %s\n' % (query.statement, query.parameters, query.duration, query.context))
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@vmanager.route('/slavetables/<int:regionid>', methods=['GET'])
|
||||||
|
def slavetables(regionid):
|
||||||
|
selected_region = Region.query.filter_by(pid=int(regionid)).first()
|
||||||
|
if selected_region == None:
|
||||||
|
return jsonify({})
|
||||||
|
addresses = selected_region.inv_addresses.filter_by(enabled=True).all()
|
||||||
|
regionlist = {}
|
||||||
|
for address in addresses:
|
||||||
|
regionlist[str(address.pid)] = { 'ipv4': str(address.ip), 'mac': str(address.mac) }
|
||||||
|
|
||||||
|
data = { 'region_id': str(selected_region.pid),
|
||||||
|
'addresses': regionlist }
|
||||||
|
return jsonify(data)
|
||||||
|
|
||||||
|
|
||||||
@vmanager.route('/createvm', methods=['GET', 'POST'])
|
@vmanager.route('/createvm', methods=['GET', 'POST'])
|
||||||
@login_required
|
@login_required
|
||||||
|
|
Loading…
Reference in a new issue