discount per deploy, dashboard update, some small fixes

This commit is contained in:
deflax 2017-09-09 09:32:04 +03:00
parent 28ab707fca
commit e35835b29c
12 changed files with 114 additions and 85 deletions

View file

@ -210,8 +210,7 @@ def password_reset_request():
'auth/email/reset_password',
user=user, token=token,
next=request.args.get('next'))
flash('An email with instructions to reset your password has been '
'sent to you.')
flash('An email with instructions to reset your password has been sent to you.')
return redirect(url_for('auth.login'))
return render_template('auth/reset_password.html', form=form)

View file

@ -96,6 +96,6 @@ def dashboard():
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('[{}] Enabled deployments: {}, services: {}, domains: {}, addresses: {}'.format(current_user.email, inv_deployments_list, inv_services_list, inv_domains_list, inv_addresses_list ))
#current_app.logger.info('[{}] Enabled deployments: {}, services: {}, domains: {}, addresses: {}'.format(current_user.email, inv_deployments_list, inv_services_list, inv_domains_list, inv_addresses_list ))
return render_template('main/dashboard.html', rrd=rrd, status=statuses, inv_deployments=inv_deployments, inv_services=inv_services, inv_domains=inv_domains, inv_addresses=inv_addresses, region=regions)

View file

@ -230,15 +230,15 @@ class Deployment(db.Model):
warning = db.Column(db.Boolean, default=False)
enabled = db.Column(db.Boolean, default=True)
cancelled = db.Column(db.Boolean, default=False)
protected = db.Column(db.Boolean, default=False) #machines with this False will be autodeleted after the warning period is over.
connected = db.Column(db.Boolean, default=False) #requires: protected=True, indicate that a connection is enabled
machine_id = db.Column(db.BigInteger) #cubeid
machine_alias = db.Column(db.String) #dns name
machine_cpu = db.Column(db.Integer)
machine_mem = db.Column(db.Integer)
machine_hdd = db.Column(db.Integer)
machine_addresses = db.relationship('Address', backref='deployments', lazy='dynamic')
discount = db.Column(db.Integer)
class Service(db.Model):
__tablename__ = 'services'

View file

@ -65,7 +65,7 @@ def activate(itemid=0):
db.session.add(transaction)
db.session.commit()
owner.wallet = owner.wallet - price
owner.wallet = owner.wallet - total
db.session.commit()
if owner.is_administrator:

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 KiB

View file

@ -43,7 +43,11 @@
<td>{{ deploy.machine_mem }} MB</td>
<td>{{ deploy.machine_hdd }} GB</td>
<td>{{ deploy.price }}</td>
{% if deploy.date_last_charge == None %}
<td>Never</td>
{% else %}
<td>{{ moment(deploy.date_last_charge).format('lll') }} ({{ moment(deploy.date_last_charge).fromNow() }})</td>
{% endif %}
<td>{{ deploy.daysleft }}</td>
{% endfor %}
</tbody>

View file

@ -128,70 +128,79 @@ addEventListener("DOMContentLoaded", function() {
<div class="panel panel-info" id="deployments">
<div class="panel-heading">Deployments</div>
<div class="panel-body"><p>
<!-- Individual Server icon by Icons8 -->
<div id="no-more-tables">
<table class="table table-hover table-striped table-condensed cf">
<thead>
<tr>
<th><!-- Computer icon by Icons8 -->
<img class="icon icons8-Computer" width="32" height="32" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACCklEQVRYhe3XzWvaYADHcf+MHXrYP9XLLuuhyNBFYXQuKwYfoezg20Z8UruWBuu0o25gYc6i2FGGynC+LWw6a22X6tJuYVA8SFk7frula7F1LUZa8IHvIQSSD8/zBPIYDNdhmB66bjFEmGMI3WccVNU7C6HipI0f0wAMEeZ84upRqd6C1FR0rVRvIbCcOLYQIfoPgO6X6i3IamcoVRptMA6qngAcVM1XdyCrHXiiFTD+jC55ohXIagdSU4HJznd7Aqw0AyNfwFRwc6AZ+QIYf6Y/4NH8B0wFN+FeOxhobHh7BBgBRoARYAS4IQArzWCcpHBnJj3QxkkKVvofgGx1D+lyS5ey1b3eAIszUNsofh3aD0lO2oLFKWxrAKPNc9fE8YeP3eLvabd4pHdmzn9o4p7d1wAmzs+yLrEbW8/jzUZR12Lredh9oa6Z470ne4BQOSdtDW0JCjUZDBG+99yEelT+JiP9paxdX/gVvPtYvfS0NpRfF758YpGFOeLEi9xaf8DLRAY0HNfyiTHYvUE8mHkO1rWIJ4GVU/dpOI7a7s9zAanPRZgjBNOrbniTof6As+38OEAk/h7uhdeYX0mi0mhfegmWsm/hTYbwSd49H3CVB181qamcOZgQYSmwnDiuNNq6H82kpoKFaOqP1Tkb1wCTNn7MQgKvhnEwZRxUtTpn4/fYp7cN12H8BeroKDHKz3I9AAAAAElFTkSuQmCC"></th>
<th><!-- Flow Chart icon by Icons8 -->
<img class="icon icons8-Flow-Chart" width="32" height="32" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABlElEQVRYhe2Xz0vCUBzA35/g0T/Bo3+Ah13UIWQgSzQhjE4RHhPq5EHdENSGGkqEdAnpINhliNBOOnU/aBhlp4qIYTA2vNc6JfJ46gQLqX3hA9vjw9vn3d4AMDG+TN+OkxxmFk+64zCzr+nBSS4aLMl69HyoLCJcHqibebGx8oDj65FRFj4WkmxpRoCWGCvACvh7AbHas5FsaQs5rL/9QADVdQVoiYHx53getb6RF2IrDZg1Xopjf+VDVsD/CvBSHGsWD9XRlvHdqbZzpada0q3iJIdZAVbA+gV40h1HsCA2IiWJiZQkhjjh+ckzLdRhn6CFOsoNFsQGfBveosXk1F7dcFG8+X7Hqa4LAAAATnLYfnWgNu91A2b7VFLhgFBRfEe5Bxd3Y/iEoYL4gHJzzRcDJ7noJCBeGypP+qcBs1uRFThgp3L7inKPrh5VVADKveyNrAArYM0CCFrQ4rWhAuPP9sZwgD/bG6NcghY0OICgBRnl7p3J+iQAS7C2eb/acMA8F0uwtmnXnWo7Z7m+TN8OAABf+SW5Q83GlOAAAAAASUVORK5CYII="></th>
<th><!-- Electronics icon by Icons8 -->
<img class="icon icons8-Electronics" width="32" height="32" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABPUlEQVRYheWXMWuDQBiG/Tn+DCdxNFpdBDtLh0L2rjrW4yIEF+lPcJJMnapL7jy4krXQpN2E0KUuyXUSQlNpGr1+lL5wwze9D7zHx/cqSo/0sFSNqNKMqNL0sFSHzn0+vXIxyYOMN0HGGxeTfOh8FsBitRWL1VZ4CS2Gzn8HwET1tRXTzQVmrZ9y4adcODPWDp3NmLxOEJ1+C2DFdDNf7oSMZ6F6fWSoh6XqYpJ7CS28hBYOZu+yAJwZazsfF5NcD0tVMaJKCzLedHldplyK+Xy5E37KRedzdff4ZkSVBg8AHgE4AHgEpwDcP+3FT/XwvB/vD4wFcPYfkAoAHgE4AHgE4ADgEYAvIvBVDA4AHgE4AHgEnzVB9EUWgI3Z8VH6BcDURvXoZ7mN2dq8pTenlQPlPzejQwDQcvpb9fwDkojR+HkAxLYAAAAASUVORK5CYII="></th>
<th><!-- Memory Slot icon by Icons8 -->
<!-- Memory Slot icon by Icons8 -->
<img class="icon icons8-Memory-Slot" width="32" height="32" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABpklEQVRYhe2XzUsCURTF35/Ssj/DVQ20c9EXBrrJNrVokdQyoUHcRGUfkAViIbbIbNEyF+VDsKmsqVG0RIhxGgdKUCyYOS3MbPogRJhmMRcOD8595/JbXHg8QqyyihDiCHDLjlVOdG1cGqKxtQtxNHAeJoQQwrC0x711Jd4/aTBSkyG+3LeQ7CUMS20zEcFwgNloVmFYajMfwHpa1anlH+X1fqLYHnZS0ucOs+3cb/MsAAvAArAAzAtwUtKr5XNlvc/L7R4v63tcWQ/30zzzvgXGA/iofXj5rD5/kIeRGglwDcZH7YTxUfvgykV9Li7BSA0FMu8ALLU5g4L4dVv/0hJ9wUS4II2H8o+LyUZH2fW0CmdQED92wBkUxERRQ6UGhC5VVF+AeFbDtaThVtawf6ui9grsZFRUasBpScNkpPjM+OhUP0sn3OGC0mn+G0BG0gAAezcqgOalhypQqQHH981ePNs8hYoG15agMCy1dZs3B8CAP1Wd3hVkb+xOcW1el72xO8W9zUueaE72RHOye5uXPvemdwV5wJ+qtgC6yf/vh8QqM9QbwskG2n58EgAAAAAASUVORK5CYII="></th>
<th><!-- HDD icon by Icons8 -->
<!-- SSD icon by Icons8 -->
<img class="icon icons8-SSD" width="32" height="32" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAADMElEQVRYhcWXy0/TcADHe/DgwQNHDhz8Izx44LCD0gHycBiDjygcFjV6UfFCohKdrAPdA4JMkZfxrcEgvkdcjLiOrSuPAQ4HTAQdMLYOcWRutF8PphOyTUlc6y/5HLvPp02/yUoQKY6ixrpJSdlzlVpakREoe66ixro5lSvpkFR/4dGOsdnGN3PhTHKkfXSuWO8s/2vAweah6Y9BAb5wZpnkBFS2uGf+KFdq6a2655+DmZaLNPR+DSu19Na0AXm1tl03+4PfpAp4NLgUyau17UobUKJnzr30rMSlCrBORgWVia1NG7DbyHb3z8QlkfvCAlj/KsoaBl6lDVCZXBNjAV6yAG9IwMHmoem0AUc7RkJSyUWq7n4MpJQX1DmyL/Z8kmwBIobXs6GUSyC19I52OrAkdcA9lltOuYRiveP0s9HvMakDeieiq6UG5kJSQKnRdc82HZNU7gsLYL6sQmVyPU2eoIEZGV2QbgEi40EB5U0DU0kB6taRgNRykZO3x+fXyRU11qzzj32SL0Ck7sVMsKDOkZ0IyNfZt1/vWwjLFXDLEfpGam3KNQH9J7rd36NyBbzyrMSL9K7q3y+gaaDt3acfssh9YQGO2ThUJlfX7wAj63DPS78AkQ+LAsoa2IlEQGXL8MIUJ49c5FjHaFBcwJbqhxOcnHJfWMClp9O/lrBT17ft1P3JQM84DzmpejC1oNTSCkKppRUVrR6/meEhJ5VtnmDKAI2FQ/3bCMwMD511GTrrMswMj/q3EWgsHMwMD6MtCo2FQ6M9hkZ7DBoLB6MtmnT9WjoGNxhAUjTUnV6YGR4Hro1gb9MQzAyP43d8ICkaZoZH9ZN5kBQNjYWDzroMkqJxputL0vUiPk4AAAz4hY0FqEws1J1eFOsZFF1xQt3pxZ7GwcSP7ze7QVI0DrWM4fCNDyApGuVXh6Hu9IKkaOxrdidEN4d4iCcSw8YC/hWViV33BAbnBERiwPvPqZ4AZc/9Hy9hRavHr9TSCkJRY80qvOxYanLEZZM3O1dRYmAW83X2HIIgCKJI7zxZdIUJVbR6/HJQoncGSw3s2XX/CfJ19pyMfY7/hcSdEwTxE6x7GguhLb0ZAAAAAElFTkSuQmCC"></th>
<th><!-- Services icon by Icons8 -->
<img class="icon icons8-Services" width="32" height="32" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAFzUlEQVRYhb1XS1ATWRTtBQsWLFi4cOHChQuXLq2aTS9GCJFfPoQg4t8aP+PM1FRpzYyfyoxKhJB0vsCgiNEpRR20ECal4tCKRQLdrztAQAIGI78Q8qOBIBhC31k47QSFKfnorXpVXe/dvufc++697z0M+0wiUjtwkdqBZ5S0bfpcGMsKriJTMsvap/ZddoUlBNJ8afAk0aXW3Ueu9Y5dpaYgW0sjcSm18XMCJuMqMgnDMEx8qS0nl6D9P9Z6IlYUhYa+OBQ/9M0pLc6g3MjU4Soy5d9/UtaNQC5BEzk6KizRo4a9Va5wXU8MbB4e6t3zcMc1BzYPDzYPD5on47O5OrpPokfOLC3lx1Vk6prBM0raNmWVUdH7vfOgaw5A48sFuOOag/3V3SGZAQ3kmZg2qQGFSh/7F2weHmroabjZ8QbO1g/NZ2mp9cmNbC31867yjgnBa6XF6csoadsurOMqMllmYBrUD8diNg8P2r8DMQmButa1OhQmdszm4eHXxpFoVhld9OE6riKTpQYm0PhyATRNftipoX9YN/B0tX3Loeoen83Dw4Er3b7l9jbPxD61oihUOTiQGZnadSOQVYY27Pm9c9Tm4eHYdfdIutq+ZSk9hZl13nHNgeV5BPJNzqvrRgBXkUm5Ojpo8/BANAdjEj2q+lAnrdi+tcDSEbF5eDj/18hcutpxZEUgSjN7V2liepUmpleqp78R5sWl1EYJgTrP1g9OCuV27Lo7JCFoa7ravgVXkak7yyip1MD4rCgKNg8PVhQFhYkN5WqpfZ9MoKicHfJyPDx6wUFhOXstwfvkHIIe1TUH4PgN9+TNjjcgROLQ1Rdj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CX46HJPQkFZrb+i4JjGIblGZD3VK177GiNKyw3fOHHJoZh2I6LrduE57ZI7di8nrb/AXpojF9YV2bgAAAAAElFTkSuQmCC"></th>
<th><!-- Time icon by Icons8 -->
<img class="icon icons8-Time" width="32" height="32" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAGLklEQVRYhd2W3VNTZx7Hc+FFL3rRy73Yi170sv9Bd2ZzsaPUrQVJECnaZtVKUXTa7jK12tq0YkMtkJwEkCiEABaV5UUEDmtXG4pCMOckJ68kIQ/E8CIvSQgEDIlJzncv3DhgCS/pzF7sd+Y3c87MOb/P5zzPM2d+AsEuc1DOWgtrLbOvVnYV8zRLpn9zt/12nYIa8xRNeLxaJTfcwSyZXvj/L5AjZ8YLarh4Qa15Q71fySz9T7YgS6YXShpcs3VsEqk6f3ceWTK9JL00W3ug0jC+/4rhD79b4F3ZyF6Rkls5c9OHomaCklYvJA0uZMlGTqWDf36LrFwfWU7myBmSscT+8pHsPKXpfi7FLn3S5AqXtk1ELt6dxLlOb/R0s2v1kIoLiZSsPbuSOS2U6l5LvXewipmtH1kGTXhkJHHkmuV9MWUcL7kxNp9qlK5azRF82ekN5SrYhQ/VtvP7rzwuEKssgQ+uWpF696s7vmi2gt10tX4TscIoP6FxhFvNEdCExy3rGi7T0zjTMooijQ05VQYUa+34uMEG6V3fS0iXM44v2r1rOXI2KR+KQjEcRZ7SlPzqji+ZXcWYhFLd69vCRZTx/rn2J6u9niR6PUl82jqGkiY77tv9iMQSAIDSVgcAIBZPYmgsiIsdbpyot+En7oWwQrfAi5TGxHGtJ/TXSkPLgUoDtSP40TrrjS/avbM04dHEruJkgw2faKxgJ0JYnwu3nRvulyNxSNQcPlJbQOnmQRMe1Q8XY2KlaVEo1e3Z0bIfqGCOntQ6wzThoTGEUdxow2QgAn84Bjk9vgEYiyc33PdycxgaC2IlGse3nWO41DcFmvAo65+JipSm1m3hQqluT67C+LTdHkOPO4GTGhv84RgySSL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ienn45eNCEh2owmDhcbZ7LqTRIMoanIpTq9mQrmM9EStP8+a4ny+tB66vNFkVZ/0z0cA3nF1NGjVCqe+N3w18V2SfT/0VMme6IKJbkV3PewlrLbH415xOrjOMiyjj43o+Gv+1o6l2X/wCiI4hGh4OMCwAAAABJRU5ErkJggg=="></th>
</tr>
</thead>
<tbody>
<div class="panel-group" id="deploycubes" role="tablist" aria-multiselectable="true">
{% for deploy in inv_deployments %}
<div class="panel panel-default">
<div class="panel-heading" data-toggle="collapse" data-parent="#deploycubes" href="#cube{{ deploy.machine_id }}" aria-expanded="false" aria-controls="cube{{ deploy.machine_id }}" role="tab" id="dpanel{{ deploy.machine_id }}">
{% if deploy.enabled == False %}
<tr class="danger">
<td data-title="Name"><b>{% if deploy.enabled == True %}<font color="green">{% else %}<font color="red">{% endif %} {{ deploy.machine_alias }}</font></b></td>
<td data-title="CPU">{{ deploy.machine_cpu }} {% if deploy.machine_cpu > 1 %}cores{% else %}core{% endif %}</td>
<td data-title="Memory">{{ deploy.machine_mem }} MB</td>
<td data-title="Disk">{{ deploy.machine_hdd }} GB</td>
<td data-title="Control"> </td>
<td data-title="Time Left"><button class="btn btn-default btn-success" onclick="window.open('/vmanager/activate/{{ deploy.machine_id }}','_self');"><span class="glyphicon glyphicon-bell" aria-hidden="true"></span> Activate</td>
{% else %}
{% if deploy.warning == True %}
<tr class="warning">
{% else %}
<tr>
disabled
{% endif %}
<td data-title="Name"><a class="rrd" data-toggle="tooltip" title="Protected: {{ deploy.protected }}<br />Online: {{ deploy.connected }}<br />State: {{ status[deploy.machine_id] }}<br />ID: {{ deploy.machine_id }}"><b>{% if deploy.protected == True %}<font color="green">{% else %}<font color="red">{% endif %}{{ deploy.machine_alias }}</font></b></a></td>
<td data-title="Network">{% for addr in deploy.machine_addresses %}<a class="rrd" data-toggle="tooltip" title="<img src='data:image/png;base64,{{ rrd[deploy.machine_id]['net'] }}' />"><img class="icon icons8-GPS-Signal" width="24" height="24" src="data:image/png;base64,iVBOR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dwbUtKFADXn+C3XNwol9uoH24AjfdO1++q2ro6TjxzlDgX3R5GqDX868cy3q0IWjXZGaWo+4/t34Bumd2CItX06QC92TpNLRrSY2ibM/vmnjpFnaFanRXT0bL09eGUxkBqd2yODUDrkdf0TYuwli5UTS+u1vD8uFqolNcuWH6bTFK643XY1er+i1RwMvXzzz+dji7fgjogG1BhEmFo9wmfGJaUdQXnXdmt4aUNPk5/g/RHtUG5/fItKfa+TOgwwJDs1uN3eOZWo94gbjE27WeqQXdMMAyL6WqPOKK13R1adwGlD7Lt0ePmH24E/sAQWf8stxGyclIcKE8YnL9bw0eyogR+s8gtfEYsqwe3GDXxlu7Z1J7YXbDTyU2ALKSXtAju1ele3X7IEn17oHmsYOJd4/uljWH743miKO4JNLyQMLRFjXdHFoXf2fAOpthwJ8XvMve9hz7NcDU4IAAAAASUVORK5CYII="></a> {% endfor %}</td>
<td data-title="CPU"><a class="rrd" data-toggle="tooltip" title="<img src='data:image/png;base64,{{ rrd[deploy.machine_id]['cpu'] }}' />">{{ deploy.machine_cpu }} {% if deploy.machine_cpu > 1 %}cores{% else %}core{% endif %}</a></td>
<td data-title="Memory"><a class="rrd" data-toggle="tooltip" title="<img src='data:image/png;base64,{{ rrd[deploy.machine_id]['mem'] }}' />">{{ deploy.machine_mem }} MB</a></td>
<td data-title="Disk"><a class="rrd" data-toggle="tooltip" title="<img src='data:image/png;base64,{{ rrd[deploy.machine_id]['hdd'] }}' />">{{ deploy.machine_hdd }} GB</a></td>
<td data-title="Control">{% if status[deploy.machine_id] == 'running' %}
{% if deploy.warning == True %}
warning
{% else %}
ok
{% endif %}
{% if deploy.protected == True %}<img class="icon icons8-Security-Checked" width="24" height="24" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAADr0lEQVRYheXYzWrbWBQHcD1CHiGPkEfwxtaXm05baDclCels0kWbTRbuJl0EJF1JdnHo1DQQOgstSgqBiJIygY4XwVdXFnUIuKA0H1BIiVrTG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hBi8Yx/Pr7jsdJxtG1fwqOZUojLDLejmesxhPdgSe6A+MZq8Ei4+3AurWXMAKOJVVrK6laW0Nrhn9D/gYrB5WUx8IwEwAAAABJRU5ErkJggg==">{% endif %} <a class="rrd" data-toggle="tooltip" title="Protected: {{ deploy.protected }}<br />State: {{ status[deploy.machine_id] }}<br />ID: {{ deploy.machine_id }}"><b>{% if status[deploy.machine_id] == 'running' %}<font color="green">{% else %}<font color="red">{% endif %}{{ deploy.machine_alias }}</font></b></a>
</div></div> <!-- end of heading -->
<!-- START OF HIDDEN PANEL -->
<div id="cube{{ deploy.machine_id }}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading{{ deploy.machine_id }}">
<div class="panel-body">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#control{{ deploy.machine_id }}">Control</a></li>
<li><a data-toggle="tab" href="#graphs{{ deploy.machine_id }}">Graphs</a></li>
<li><a data-toggle="tab" href="#properties{{ deploy.machine_id }}">Properties</a></li>
</ul>
<div class="tab-content">
<div id="control{{ deploy.machine_id }}" class="tab-pane fade in active">
<br /><p>
{% if status[deploy.machine_id] == 'running' %}
<button class="confirm command command-vmshutdown btn btn-default btn-warning" value="vmshutdown" vmid="{{ deploy.machine_id }}"><span class="glyphicon glyphicon-off" aria-hidden="true"></span> Shutdown</button>
<button class="confirm command command-vmstop btn btn-default btn-danger" value="vmstop" vmid="{{ deploy.machine_id }}"><span class="glyphicon glyphicon-alert" aria-hidden="true"></span> Force Stop</button>
{% else %}
<button class="command command-vmstart btn btn-default btn-success" value="vmstart" vmid="{{ deploy.machine_id }}"><span class="glyphicon glyphicon-play" aria-hidden="true"></span> Start</button>
{% endif %}
{% if status[deploy.machine_id] == 'running' %}<button class="btn btn-default btn-info" onclick="window.open('/vmanager/vmvnc/{{ deploy.machine_id }}', '_blank');"><span class="glyphicon glyphicon-console" aria-hidden="true"></span> Console</button>{% endif %}</td>
{% if deploy.warning == True %}
<td data-title="Time Left"><button class="btn btn-default btn-success" onclick="window.open('/vmanager/activate/{{ deploy.machine_id }}');"><span class="glyphicon glyphicon-bell" aria-hidden="true"></span> Activate ({{ deploy.daysleft }} days left)</button></td>
{% else %}
<td data-title="Time Left">{{ deploy.daysleft }} day(s)</td>
{% endif %}
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
{% if status[deploy.machine_id] == 'running' %}<button class="btn btn-default btn-info" onclick="window.open('/vmanager/vmvnc/{{ deploy.machine_id }}', '_blank');"><span class="glyphicon glyphicon-console" aria-hidden="true"></span> Console</button>{% endif %}
</p>
</div>
<div id="graphs{{ deploy.machine_id }}" class="tab-pane fade">
<br /><p>
CPU {{ deploy.machine_cpu }} {% if deploy.machine_cpu > 1 %}cores{% else %}core{% endif %}<br />
<img class="img-responsive" src='data:image/png;base64,{{ rrd[deploy.machine_id]['cpu'] }}'><br /><br />
Memory {{ deploy.machine_mem }} MB:<br />
<img class="img-responsive" src='data:image/png;base64,{{ rrd[deploy.machine_id]['mem'] }}'><br /><br />
{% for addr in deploy.machine_addresses %}
Network {{ addr.ip }}:<br />
<img class="img-responsive" src='data:image/png;base64,{{ rrd[deploy.machine_id]['net'] }}'><br /><br />
{% endfor %}
Hard Disk IOPS: {{ deploy.machine_hdd }} GB<br />
<img class="img-responsive" src='data:image/png;base64,{{ rrd[deploy.machine_id]['hdd'] }}'><br />
</p>
</div>
<div id="properties{{ deploy.machine_id }}" class="tab-pane fade">
<br /><p>
{% if deploy.enabled == False %}
<button class="btn btn-default btn-success" onclick="window.open('/vmanager/activate/{{ deploy.machine_id }}');"><span class="glyphicon glyphicon-bell" aria-hidden="true"></span> Activate</button>
{% endif %}
{% if deploy.warning == True %}
<button class="btn btn-default btn-success" onclick="window.open('/vmanager/activate/{{ deploy.machine_id }}');"><span class="glyphicon glyphicon-bell" aria-hidden="true"></span> Activate ({{ deploy.daysleft }} days left)</button>
{% else %}
Time Left: {{ deploy.daysleft }} day(s)
{% endif %}
</p>
</div>
</div>
</div>
</div>
<!-- END OF HIDDEN PANEL -->
</div>
{% endfor %}
</div>
<!-- Cloud Storage icon by Icons8 -->
<button class="btn btn-default" onclick="window.open('{{ url_for('vmanager.createvm') }}','_self')"><img class="icon icons8-Cloud-Storage" width="32" height="32" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAEEklEQVRYhe3Xy0/bBhwHcA6btEMP0077A3boYYdK23EHLiQ0hQBtVC1S9zjs0L069TCkSUWNpgZCshDYItZOI+tKH7Cibgw6Wu2RAXWMYyc8mpAoUAIEp6VuTR5OwAnJd5dBEbYJKDSA1J/0PfjgXz6y5W/ssrKDNm9dYl4+aqYeq00kSpnK5pGUusX1WkGgxux+/ePLvmQ4lkcp88nPfkHV6DpcEFhpGnnH2D8XKzXwQv98UtXoqioIVDeRH/1IcKlSAzsIbqXSTJ0tCKy2uNt/uy+slhrYez8JrY25XhCotdKDgzNiSXHhWB5DYRFaK+0tfAWt9Pzow9WSA8cereKYheILAo/bGDHE72z5n8E46rsC0LXR0LXRqO8K4O5kbEc7pvg8TrQxuXKD8xVFnLrJ9canVyYTO1k84FvCe+1eXCcWwPLLYPlldJMsPrg4ipsMtyPkmasBQWUk3twKWGm8PRff7kImsoxT7V5MLwrYPPNP0tDbPfh3KrltoGkgIqgaXbVbAT9zuLi00oIHfA6O4ShOOyZQZaFQZ3Pjbx8nwa3NcPAp1CYSersH529NwcuubAn8iXya0VjcXykCtVa6o9cn5JVwZzr9OHcziNBDAWI2hzCXwmourwgEAF7IgEuI6CJZ6FppMJFlRWCfX0BNq6dLEVjdQlODYfmK6RiK4twvwS0xheYasYCGnpAi8N6sCK2V8SsCq76hFsce5WRPPu2YQIBNFgXkEiL0do8icGIxB42Fisviyg3Ol463MtkpmYoZj4qoslAQs7migACgNpFo7Hsge6unl/I4+Z0nW25wHpIAVY2uw593BiQVMx4V8eGlMVwZjhSNA4B4OgtL/zROfsvIIs/eCAoVRuKIHLC26Y+IBGjqn0GHc25XcBvnh39mcaF3WgK03F1IqZoJnQR41EzVO1xPVjaf8P73o2D55V0HTi8K0LXREmAnxWe1VtogrZgW+sbvPkFygt7uAZcQdx2o9MDcnkyh1sb8KgNkvEMyFXP+1hS6SXbXgd0kK1s5rrkMalqYSQlQY6HichXjZVdwqt2LHioKXsgUDeMSIrpJFnU2N9xzacnv+R7noDFTwuaKOXSizSPKVcwasqEnhDqbu+iPI73dg4aekCwuHMtjZikPvd2TLTc4X10HVhiJI19cDe7oLeZ55suukFDRfO/tZxXTTOhMdxZK/iWnFNtf0bTKRLy7DjxmcX99meLFvYat5RodW61uYZo2PsH9fX5pxexV7gTTqGn1DGzswODwbGbPYWsZiWSgtTGhZxVjpoTxRfm3mL2In8tBY6ZS60C1icRFJrevojaReAF8bkAykkcqAxDz+W0dFxOlXVsCU///5aYy2NZxMVHadbCv4H7IC+CuA/djyg7C/AeJ36h1J+7ehgAAAABJRU5ErkJggg=="> Create</button>
</div>
</div>
</div>

View file

@ -30,7 +30,7 @@
{% block scripts %}
{{ super() }}
<script type="text/javascript" src="/static/js/better-simple-slideshow.js" charset="UTF-8"></script>
<script type="text/javascript" src="/static/js/_better-simple-slideshow.js" charset="UTF-8"></script>
<script type="text/javascript">
var opts = {
auto : {
@ -57,16 +57,23 @@
<img src="/static/slideshow/robot.png" class="img-responsive"></img>
</div>
-->
<div class="row">
<div class="row">
<div class="col-md-12">
<div class="panel panel-primary panel-transparent">
<div class="panel-body">
<img src="../../static/images/serverroom.jpg" width="100%" />
<!--
<div class="bss-slides">
<figure>
<img src="/static/slideshow/robot.png" width="100%" />
</figure>
<figure>
<img src="/static/slideshow/robot2.png" width="100%" />
</figure>
</div>
-->
</div>
</div>
</div>
</div>
<div class="container-fluid-index">
<div class="row">

View file

@ -3,7 +3,7 @@
{% block head %}
{{ super() }}
<script type="text/javascript">
function getPricePerMonth()
function getPeriod()
{
var period = 0;
var periodselect = document.getElementById('period');
@ -13,12 +13,21 @@ function getPricePerMonth()
function calculateTotal()
{
var period = getPricePerMonth();
var period = getPeriod();
var ppm = {{ ppm }};
var total = 0;
total = period * ppm;
var divobj = document.getElementById('totalPrice');
divobj.innerHTML = "Total Price: "+total+" {{ currency }}";
var discount = {{ discount }};
var pricetotal = 0;
pricetotal = period * ppm;
var priceselect = document.getElementById('totalPrice');
priceselect.innerHTML = "Total Price: "+pricetotal+" {{ currency }}";
var discounttotal = 0;
discounttotal = period * discount;
var discountselect = document.getElementById('totalDiscount');
discountselect.innerHTML = "Discount <font color=#ff0000>-{{ deploy.discount }}%</font>: "+discounttotal+" {{ currency }}";
}
</script>
{% endblock %}
@ -34,7 +43,7 @@ function calculateTotal()
<div class="panel-heading">Activate deployment {{ deploy.machine_alias }}</div>
<div class="panel-body">
<form method="POST" action"{{ url_for('vmanager.activate', itemid=deploy.machine_id) }}">
<form method="POST" action="{{ url_for('vmanager.activate', itemid=deploy.machine_id) }}">
<h3>
CPU: {{ deploy.machine_cpu }} cores<br />
Memory: {{ deploy.machine_mem }} MB<br />
@ -44,6 +53,9 @@ Storage: {{ deploy.machine_hdd }} GB<br />
{{ error }}<br />
{% endfor %}
---<br />
{% if deploy.discount != 0 %}
<div id="totalDiscount">Discount <font color=#ff0000>-{{ deploy.discount }}%</font>: {{ discount }} {{ currency }}</div>
{% endif %}
<div id="totalPrice">Previous Period: {{ total }} {{ currency }}</div>
</h3>
@ -56,5 +68,7 @@ Storage: {{ deploy.machine_hdd }} GB<br />
</div>
</div>
</div>
{% endblock %}

View file

@ -91,8 +91,11 @@ def activate(itemid=0):
cpu_cost = deploy.machine_cpu * current_app.config['CPU_RATIO']
mem_cost = ( deploy.machine_mem / 1024 ) * current_app.config['MEM_RATIO']
hdd_cost = deploy.machine_hdd * current_app.config['HDD_RATIO']
ppm = round(cpu_cost + mem_cost + hdd_cost)
ppm = cpu_cost + mem_cost + hdd_cost
discount = round(( ppm * deploy.discount ) / 100)
ppm = round(ppm - discount)
#default period = 1 for virgin deployments
if deploy.period is None:
form = ActivateForm(period=1)
total = ppm * 1
@ -129,7 +132,7 @@ def activate(itemid=0):
return redirect(url_for('admin.list_deployments'))
else:
return redirect(url_for('main.dashboard'))
return render_template('vmanager/activate.html', form=form, deploy=deploy, cpu_cost=cpu_cost, mem_cost=mem_cost, hdd_cost=hdd_cost, ppm=ppm, total=total, currency=owner.currency)
return render_template('vmanager/activate.html', form=form, deploy=deploy, cpu_cost=cpu_cost, mem_cost=mem_cost, hdd_cost=hdd_cost, ppm=ppm, discount=discount, total=total, currency=owner.currency)
@vmanager.route('/<cmd>/<int:vmid>')

View file

@ -113,9 +113,6 @@ def autowarn():
print('Deployment "' + deploy.machine_alias + '" is ' + str(daysleft.days) + ' days until expiration. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c'))
deploy.warning = True
db.session.commit()
else:
deploy.warning = False
db.session.commit()
services_ena = Service.query.filter_by(cancelled=False).filter_by(enabled=True).all()
for service in services_ena:
@ -129,9 +126,6 @@ def autowarn():
print('Service "' + service.description + '" is ' + str(daysleft.days) + ' days until expiration. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c'))
service.warning = True
db.session.commit()
else:
service.warning = False
db.session.commit()
domains_ena = Domain.query.filter_by(cancelled=False).filter_by(enabled=True).all()
for domain in domains_ena:
@ -139,8 +133,7 @@ def autowarn():
daysleft = expiry - today
domain.daysleft = daysleft.days + 1
db.session.commit()
warndays = service.period * 5
warndays = domain.period * 5
if daysleft.days < warndays:
print('Domain "' + domain.fqdn + '" is ' + str(daysleft.days)+ ' days until expiration. Expiry date: ' + expiry.strftime('%c'))
domain.warning = True