Changelog: https://roxy-wi.org/changelog.py#6
pull/321/head
Pavel Loginov 3 years ago
parent c3ec003f69
commit d97f86e8fe

@ -484,10 +484,21 @@ class Services(BaseModel):
constraints = [SQL('UNIQUE (service_id, service)')] constraints = [SQL('UNIQUE (service_id, service)')]
class UserName(BaseModel):
UserName = CharField(null=True)
Status = IntegerField(constraints=[SQL('DEFAULT 0')])
Plan = CharField(null=True)
Method = CharField(null=True)
class Meta:
table_name = 'user_name'
primary_key = False
def create_tables(): def create_tables():
with conn: with conn:
conn.create_tables([User, Server, Role, Telegram, Slack, UUID, Token, ApiToken, Groups, UserGroups, ConfigVersion, conn.create_tables([User, Server, Role, Telegram, Slack, UUID, Token, ApiToken, Groups, UserGroups, ConfigVersion,
Setting, Cred, Backup, Metrics, WafMetrics, Version, Option, SavedServer, Waf, ActionHistory, Setting, Cred, Backup, Metrics, WafMetrics, Version, Option, SavedServer, Waf, ActionHistory,
PortScannerSettings, PortScannerPorts, PortScannerHistory, ProvidersCreds, ServiceSetting, PortScannerSettings, PortScannerPorts, PortScannerHistory, ProvidersCreds, ServiceSetting,
ProvisionedServers, MetricsHttpStatus, SMON, WafRules, Alerts, GeoipCodes, NginxMetrics, ProvisionedServers, MetricsHttpStatus, SMON, WafRules, Alerts, GeoipCodes, NginxMetrics,
SystemInfo, Services]) SystemInfo, Services, UserName])

@ -1528,7 +1528,8 @@ def check_new_version(**kwargs):
res = response.content.decode(encoding='UTF-8') res = response.content.decode(encoding='UTF-8')
try: try:
status = response_status.content.decode(encoding='UTF-8') status = response_status.content.decode(encoding='UTF-8')
sql.update_user_status(status) status = status.split(' ')
sql.update_user_status(status[0], status[1].strip(), status[2].strip())
except: except:
pass pass
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:

@ -807,6 +807,11 @@ if serv is not None and act == "stats":
haproxy_pass = sql.get_setting('nginx_stats_password') haproxy_pass = sql.get_setting('nginx_stats_password')
stats_port = sql.get_setting('nginx_stats_port') stats_port = sql.get_setting('nginx_stats_port')
stats_page = sql.get_setting('nginx_stats_page') stats_page = sql.get_setting('nginx_stats_page')
elif form.getvalue('service') == 'apache':
haproxy_user = sql.get_setting('apache_stats_user')
haproxy_pass = sql.get_setting('apache_stats_password')
stats_port = sql.get_setting('apache_stats_port')
stats_page = sql.get_setting('apache_stats_page')
else: else:
haproxy_user = sql.get_setting('stats_user') haproxy_user = sql.get_setting('stats_user')
haproxy_pass = sql.get_setting('stats_password') haproxy_pass = sql.get_setting('stats_password')
@ -4166,3 +4171,11 @@ if act == 'check_service':
print('down') print('down')
except Exception: except Exception:
print('down') print('down')
if form.getvalue('show_sub_ovw'):
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
template = env.get_template('ajax/show_sub_ovw.html')
template = template.render(sub=sql.select_user_all())
print(template)

@ -3148,8 +3148,7 @@ def insert_user_name(user_name):
def select_user_name(): def select_user_name():
try: try:
query_res = UserName.get().UserName query_res = UserName.get().UserName
except Exception as e: except Exception:
out_error(e)
return False return False
else: else:
return query_res return query_res
@ -3166,12 +3165,11 @@ def update_user_name(user_name):
return True return True
def update_user_status(status): def update_user_status(status, plan, method):
user_update = UserName.update(Status=status) user_update = UserName.update(Status=status, Method=method, Plan=plan)
try: try:
user_update.execute() user_update.execute()
except Exception as e: except Exception:
out_error(e)
return False return False
else: else:
return True return True
@ -3180,8 +3178,16 @@ def update_user_status(status):
def select_user_status(): def select_user_status():
try: try:
query_res = UserName.get().Status query_res = UserName.get().Status
except Exception as e: except Exception:
out_error(e) return False
else:
return query_res
def select_user_all():
try:
query_res = UserName.select()
except Exception:
return False return False
else: else:
return query_res return query_res

@ -0,0 +1,42 @@
{% for s in sub %}
{% if s.Plan == 'user' %}
{% set plan = 'Home' %}
{% elif s.Plan == 'company' %}
{% set plan = 'Enterprise' %}
{% elif s.Plan == 'support' %}
{% set plan = 'Premium' %}
{% else %}
{% set plan = 'Free' %}
{% endif %}
<tr class="odd">
<td class="padding10 first-collumn-wi">Subscription plan</td>
<td>{{plan}}</td>
</tr>
<tr class="even">
<td class="padding10 first-collumn-wi">Subscription status</td>
<td>
{% if plan == 'Free' %}
N/A
{% else %}
<span
{% if s.Status|int() == 1 %}
style="color: var(--green-color); font-weight: bold">Active
{% else %}
style="color: var(--red-color); font-weight: bold">Blocked
{% endif %}
</span>
{% endif %}
</td>
</tr>
<tr class="odd">
<td class="padding10 first-collumn-wi">Pay method</td>
<td>
{% if plan == 'Free' %}
N/A
{% else %}
{{s.Method}}
{% endif %}
</td>
</tr>
{% endfor %}

@ -429,7 +429,16 @@
{% endfor %} {% endfor %}
</tr> </tr>
</table> </table>
{% endif %}
{% if role <= 1 %}
<table class="overview-wi">
<tr class="overviewHead" style="height: 30px;">
<td class="padding10 first-collumn-wi" colspan="2">
<a href="https://roxy-wi.org/cabinet.py" title="Personal cabinet" class="logs_link" target="_blank">Subscription</a>
</td>
</tr>
<tbody id="sub-table"></tbody>
</table>
{% endif %} {% endif %}
<div id="dialog-confirm" style="display: none;"> <div id="dialog-confirm" style="display: none;">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:3px 12px 20px 0;"></span>Are you sure?</p> <p><span class="ui-icon ui-icon-alert" style="float:left; margin:3px 12px 20px 0;"></span>Are you sure?</p>

@ -64,6 +64,7 @@ function showOverview(serv, hostnamea) {
for (i = 0; i < serv.length; i++) { for (i = 0; i < serv.length; i++) {
showOverviewCallBack(serv[i], hostnamea[i]) showOverviewCallBack(serv[i], hostnamea[i])
} }
showSubOverview();
} }
function showOverviewCallBack(serv, hostnamea) { function showOverviewCallBack(serv, hostnamea) {
$.ajax( { $.ajax( {
@ -501,6 +502,27 @@ function showUsersOverview() {
} }
} ); } );
} }
function showSubOverview() {
$.ajax( {
url: "options.py",
data: {
show_sub_ovw: 1,
token: $('#token').val()
},
type: "POST",
beforeSend: function() {
$("#sub-table").html('<img class="loading_small_bin_bout" style="padding-left: 40%;padding-top: 40px;padding-bottom: 40px;" src="/inc/images/loading.gif" />');
},
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error:') != '-1') {
toastr.error(data);
} else {
$("#sub-table").html(data);
}
}
} );
}
function serverSettings(id, name) { function serverSettings(id, name) {
var service = $('#service').val(); var service = $('#service').val();
$.ajax({ $.ajax({

Loading…
Cancel
Save