From 75dbce93c0f4a7a745bf6169c3601c5bd68cb279 Mon Sep 17 00:00:00 2001 From: deflax Date: Fri, 15 Sep 2017 03:28:26 +0300 Subject: [PATCH] dashboard update --- app/admin/routes.py | 8 ++-- app/main/routes.py | 11 +++-- app/smanager/forms.py | 2 +- app/templates/admin/list_transactions.html | 7 +-- app/templates/main/dashboard.html | 55 +++++++++++++--------- app/templates/uinvoice/transactions.html | 2 +- app/vmanager/forms.py | 2 +- app/vmanager/routes.py | 4 +- 8 files changed, 52 insertions(+), 39 deletions(-) diff --git a/app/admin/routes.py b/app/admin/routes.py index b39e77c..c62465f 100644 --- a/app/admin/routes.py +++ b/app/admin/routes.py @@ -156,26 +156,26 @@ def dashboard(user_pid=0): inv_deploycubeids = [] inv_deployments_list = [] for invcls in inv_deployments: - if invcls.user_id == cuser.pid and invcls.enabled == True: + if invcls.user_id == cuser.pid: inv_deploycubeids.extend([invcls.machine_id]) inv_deployments_list.extend([invcls.machine_alias]) inv_services = cuser.inv_services.filter_by(cancelled=False).order_by(Service.date_last_charge.asc()).all() inv_services_list = [] for invcls in inv_services: - if invcls.user_id == cuser.pid and invcls.enabled == True: + if invcls.user_id == cuser.pid: inv_services_list.extend([invcls.description]) inv_domains = cuser.inv_domains.filter_by(cancelled=False).order_by(Domain.date_created.desc()).all() inv_domains_list = [] for invcls in inv_domains: - if invcls.user_id == cuser.pid and invcls.enabled == True: + if invcls.user_id == cuser.pid: inv_domains_list.extend([invcls.fqdn]) inv_addresses = cuser.inv_addresses.order_by(Address.ip.asc()).all() inv_addresses_list = [] for invcls in inv_addresses: - if invcls.user_id == cuser.pid and invcls.enabled == True: + if invcls.user_id == cuser.pid: inv_addresses_list.extend([invcls.ip]) sys_regions = Region.query.all() diff --git a/app/main/routes.py b/app/main/routes.py index 4478cc1..049c73c 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -43,26 +43,26 @@ def dashboard(): inv_deploycubeids = [] inv_deployments_list = [] for invcls in inv_deployments: - if invcls.user_id == cuser.pid and invcls.enabled == True: + if invcls.user_id == cuser.pid: inv_deploycubeids.extend([invcls.machine_id]) inv_deployments_list.extend([invcls.machine_alias]) inv_services = cuser.inv_services.filter_by(cancelled=False).order_by(Service.date_last_charge.asc()).all() inv_services_list = [] for invcls in inv_services: - if invcls.user_id == cuser.pid and invcls.enabled == True: + if invcls.user_id == cuser.pid: inv_services_list.extend([invcls.description]) inv_domains = cuser.inv_domains.filter_by(cancelled=False).order_by(Domain.date_created.desc()).all() inv_domains_list = [] for invcls in inv_domains: - if invcls.user_id == cuser.pid and invcls.enabled == True: + if invcls.user_id == cuser.pid: inv_domains_list.extend([invcls.fqdn]) inv_addresses = cuser.inv_addresses.order_by(Address.ip.asc()).all() inv_addresses_list = [] for invcls in inv_addresses: - if invcls.user_id == cuser.pid and invcls.enabled == True: + if invcls.user_id == cuser.pid: inv_addresses_list.extend([invcls.ip]) sys_regions = Region.query.all() @@ -73,6 +73,7 @@ def dashboard(): #extract rrd and status from the deployments rrd = {} statuses = {} + current_app.logger.warning(str(inv_deploycubeids)) for cubeid in inv_deploycubeids: rrd[cubeid] = {} try: @@ -82,6 +83,8 @@ def dashboard(): flash('Deploy #{} unreachable. Support is notified'.format(str(cubeid))) send_email(current_app.config['MAIL_USERNAME'], 'Cube {} is unreachable'.format(cubeid), 'vmanager/email/adm_unreachable', user=current_user, cubeid=cubeid) + #current_app.logger.info('debug query:') + #current_app.logger.info(query) graphs_list = ['net', 'cpu', 'mem', 'hdd'] try: diff --git a/app/smanager/forms.py b/app/smanager/forms.py index edcb238..6204458 100644 --- a/app/smanager/forms.py +++ b/app/smanager/forms.py @@ -4,5 +4,5 @@ from wtforms import validators, ValidationError from wtforms.fields.html5 import EmailField class ActivateForm(FlaskForm): - period = SelectField('Service Period', choices=[(1, '1 Month'), (3, '3 Months'), (6, '6 Months'), (12, '1 Year'), (24, '2 Years')], coerce=int) + period = SelectField('Service Period', choices=[(1, '1 Month'), (2, '2 Months'), (3, '3 Months'), (6, '6 Months'), (12, '1 Year'), (24, '2 Years')], coerce=int) submit = SubmitField('Activate') diff --git a/app/templates/admin/list_transactions.html b/app/templates/admin/list_transactions.html index faf8ca4..ecc70e6 100644 --- a/app/templates/admin/list_transactions.html +++ b/app/templates/admin/list_transactions.html @@ -14,11 +14,10 @@ - - + @@ -26,14 +25,12 @@ {% for transaction in transactions %} {% if transaction.value > 0 %} - {% else %} - - + diff --git a/app/templates/main/dashboard.html b/app/templates/main/dashboard.html index 4709ac4..467c8e6 100644 --- a/app/templates/main/dashboard.html +++ b/app/templates/main/dashboard.html @@ -132,53 +132,60 @@ addEventListener("DOMContentLoaded", function() {
{% for deploy in inv_deployments %} {% if deploy.enabled == False %} -
- {% endif %} - {% if deploy.warning == True %} -
+
{% else %} -
- {% endif %} + {% if deploy.warning == True %} +
+ {% else %} + {% if deploy.enabled == False or deploy.warning == True %} -
+
{% else %} -
+
{% endif %}


+ {% if deploy.enabled == True %} + + {% if status[deploy.machine_id] == 'running' %} + + +

+

- {% if status[deploy.machine_id] == 'running' %} - - - {% else %} - - {% endif %} - {% if status[deploy.machine_id] == 'running' %}{% endif %} + + {% else %} + + {% endif %} + {% endif %}

- {% if deploy.enabled == False %} - + {% else %} {% if deploy.warning == True %} {% else %}

{% endif %} - {% endif %} + {% endif %}

@@ -207,7 +214,13 @@ addEventListener("DOMContentLoaded", function() {

-
+
+
+

+ ID: {{ deploy.machine_id }}
+ State: {{ status[deploy.machine_id] }}
+ Protected: {{ deploy.protected }}
+

diff --git a/app/templates/uinvoice/transactions.html b/app/templates/uinvoice/transactions.html index f043929..d23f59b 100644 --- a/app/templates/uinvoice/transactions.html +++ b/app/templates/uinvoice/transactions.html @@ -76,7 +76,7 @@ var myChart = new Chart(ctx, {
{% for transaction in transactions %} {% if transaction.value < 0 %} - + diff --git a/app/vmanager/forms.py b/app/vmanager/forms.py index feea6c4..d98c5aa 100644 --- a/app/vmanager/forms.py +++ b/app/vmanager/forms.py @@ -17,6 +17,6 @@ class CreateForm(FlaskForm): submit = SubmitField('Create') class ActivateForm(FlaskForm): - period = SelectField('Deploy Period', choices=[(1, '1 Month'), (3, '3 Months'), (6, '6 Months'), (12, '1 Year'), (24, '2 Years')], coerce=int) + period = SelectField('Deploy Period', choices=[(1, '1 Month'), (2, '2 Months'), (3, '3 Months'), (6, '6 Months'), (12, '1 Year'), (24, '2 Years')], coerce=int) submit = SubmitField('Activate') diff --git a/app/vmanager/routes.py b/app/vmanager/routes.py index ed198b8..42fd8fe 100644 --- a/app/vmanager/routes.py +++ b/app/vmanager/routes.py @@ -151,14 +151,14 @@ def command(cmd=None, vmid=0): inventory.extend([invcls.machine_id]) if current_user.is_administrator(): - current_app.logger.warning('[ADMIN] Access override for cube id:{}'.format(vmid)) + #current_app.logger.warning('[ADMIN] Access override for cube id:{}'.format(vmid)) db_result = contact_proxmaster({}, cmd, vmid) if cmd == 'vmvnc': return redirect(db_result['url']) else: #checks if current user owns this vmid if not vmid in inventory: - current_app.logger.error('[{}] Access violation with cube id: {}'.format(current_user.email, vmid)) + current_app.logger.warning('[{}] Access violation with cube id: {}'.format(current_user.email, vmid)) #TODO: log ips else: db_result = contact_proxmaster({}, cmd, vmid)
Description Amount DateUser
{{ transaction.description }} {{ transaction.value }} {{ transaction.currency }} {{ moment(transaction.date_created).format('lll') }} {{ transaction.owner.email }}
{{ transaction.description }} {{ transaction.value }} {{ transaction.currency }} {{ moment(transaction.date_created).format('lll') }}{{ deploy.daysleft }} day(s)
{{ moment(transaction.date_created).format('lll') }} {{ transaction.description }} {{ transaction.value|abs }} {{ transaction.currency }}