diff --git a/app/classes/controllers/users_controller.py b/app/classes/controllers/users_controller.py index 933942c6..1a6575a7 100644 --- a/app/classes/controllers/users_controller.py +++ b/app/classes/controllers/users_controller.py @@ -72,6 +72,7 @@ class Users_Controller: up_data[key] = user_data[key] up_data["last_update"] = helper.get_time_as_string() up_data["lang"] = user_data["lang"] + up_data["hints"] = user_data["hints"] logger.debug(f"user: {user_data} +role:{added_roles} -role:{removed_roles}") for role in added_roles: users_helper.get_or_create(user_id=user_id, role_id=role) diff --git a/app/classes/models/users.py b/app/classes/models/users.py index b9dd1d81..f9e9f311 100644 --- a/app/classes/models/users.py +++ b/app/classes/models/users.py @@ -49,6 +49,7 @@ class Users(Model): valid_tokens_from = DateTimeField(default=datetime.datetime.now) server_order = CharField(default="") preparing = BooleanField(default=False) + hints = BooleanField(default=True) class Meta: table_name = "users" diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 7d0e77a7..a1071a21 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -769,6 +769,7 @@ class PanelHandler(BaseHandler): page_data["user"]["last_ip"] = "N/A" page_data["user"]["last_update"] = "N/A" page_data["user"]["roles"] = set() + page_data["user"]["hints"] = True if Enum_Permissions_Crafty.User_Config not in exec_user_crafty_permissions: self.redirect( @@ -1734,6 +1735,11 @@ class PanelHandler(BaseHandler): password1 = bleach.clean(self.get_argument("password1", None)) email = bleach.clean(self.get_argument("email", "default@example.com")) enabled = int(float(self.get_argument("enabled", "0"))) + try: + hints = int(bleach.clean(self.get_argument("hints"))) + hints = True + except: + hints = False lang = bleach.clean( self.get_argument("language"), helper.get_setting("language") ) @@ -1765,6 +1771,7 @@ class PanelHandler(BaseHandler): "password": password0, "email": email, "lang": lang, + "hints": hints, } self.controller.users.update_user(user_id, user_data=user_data) @@ -1806,6 +1813,7 @@ class PanelHandler(BaseHandler): "roles": roles, "lang": lang, "superuser": superuser, + "hints": hints, } user_crafty_data = { "permissions_mask": permissions_mask, @@ -1901,6 +1909,7 @@ class PanelHandler(BaseHandler): password1 = bleach.clean(self.get_argument("password1", None)) email = bleach.clean(self.get_argument("email", "default@example.com")) enabled = int(float(self.get_argument("enabled", "0"))) + hints = True lang = bleach.clean( self.get_argument("lang", helper.get_setting("language")) ) @@ -1942,10 +1951,7 @@ class PanelHandler(BaseHandler): enabled=enabled, superuser=new_superuser, ) - user_data = { - "roles": roles, - "lang": lang, - } + user_data = {"roles": roles, "lang": lang, "hints": True} user_crafty_data = { "permissions_mask": permissions_mask, "server_quantity": server_quantity, diff --git a/app/frontend/templates/panel/activity_logs.html b/app/frontend/templates/panel/activity_logs.html index c8717f38..389edaf5 100644 --- a/app/frontend/templates/panel/activity_logs.html +++ b/app/frontend/templates/panel/activity_logs.html @@ -9,7 +9,7 @@
- +
@@ -76,37 +81,37 @@ {% block js %} + {% end %} \ No newline at end of file diff --git a/app/frontend/templates/panel/dashboard.html b/app/frontend/templates/panel/dashboard.html index d58b43fb..0d8a3004 100644 --- a/app/frontend/templates/panel/dashboard.html +++ b/app/frontend/templates/panel/dashboard.html @@ -15,8 +15,9 @@
@@ -74,7 +75,8 @@

{{ data['num_players'] }}

-

0 {{ translate('dashboard', 'max', data['lang']) }}

+

0 {{ translate('dashboard', 'max', + data['lang']) }}

@@ -91,10 +93,12 @@

 {{ translate('dashboard', 'allServers', data['lang']) }}

{% if len(data['servers']) > 0 %} + {% if data['user_data']['hints'] %} {% end %} + {% end %}
  {{ translate('dashboard', 'newServer', data['lang']) }}
@@ -136,18 +140,18 @@ {% if server['user_command_permission'] %} {% if server['stats']['running'] %} - +   - +   - +   @@ -160,20 +164,21 @@ {{ translate('dashboard', 'starting', data['lang']) }} - {% elif server['stats']['downloading']%} - {{ translate('serverTerm', 'downloading', - data['lang']) }} + {% elif server['stats']['downloading']%} + + {{ translate('serverTerm', 'downloading', + data['lang']) }} {% else %} - +   - +   - +   {% end %} @@ -228,7 +233,9 @@ data['lang']) }}
{% if server['stats']['desc'] != 'False' %} -
{{ server['stats']['desc'] }}

+
{{ + server['stats']['desc'] }}

{% end %} {% if server['stats']['version'] != 'False' %} @@ -239,17 +246,19 @@ {% if server['stats']['running'] %} - {{ translate('dashboard', 'online', + {{ translate('dashboard', 'online', data['lang']) }} {% elif server['stats']['crashed'] %} - {{ translate('dashboard', 'crashed', - data['lang']) }} + {{ translate('dashboard', + 'crashed', + data['lang']) }} {% else %} - {{ translate('dashboard', 'offline', + {{ translate('dashboard', 'offline', data['lang']) }} {% end %} - + {% end %} @@ -271,15 +280,19 @@ color: white !important; ; } - #desc_id { - -ms-overflow-style: none; /* for Internet Explorer, Edge */ - scrollbar-width: none; /* for Firefox */ - overflow-y: scroll; -} -#desc_id::-webkit-scrollbar { - display: none; /* for Chrome, Safari, and Opera */ -} + #desc_id { + -ms-overflow-style: none; + /* for Internet Explorer, Edge */ + scrollbar-width: none; + /* for Firefox */ + overflow-y: scroll; + } + + #desc_id::-webkit-scrollbar { + display: none; + /* for Chrome, Safari, and Opera */ + } @@ -296,20 +309,20 @@ }; } - $(document).ready(function() { + $(document).ready(function () { $('[data-toggle="popover"]').popover(); if ($(window).width() < 1000) { $('.too_small').popover("show"); } }); - $(window).ready(function() { - $('body').click(function() { + $(window).ready(function () { + $('body').click(function () { $('.too_small').popover("hide"); }); }); - $(window).resize(function() { + $(window).resize(function () { // This will execute whenever the window is resized if ($(window).width() < 1000) { $('.too_small').popover("show"); @@ -379,7 +392,7 @@ cpu_status = "bg-warning"; } - server_cpu.innerHTML = `
`+ server.cpu +`%`; + server_cpu.innerHTML = `
` + server.cpu + `%`; /* Update Memory */ @@ -396,7 +409,7 @@ total_mem = server.mem; } - server_mem.innerHTML = `
`+ server.mem_percent +`% - ` + total_mem; + server_mem.innerHTML = `
` + server.mem_percent + `% - ` + total_mem; /* Update World Infos */ server_world.innerHTML = server.world_size @@ -412,7 +425,7 @@ let servers = document.getElementsByClassName("server-player-totals"); let all_total_players = 0; let all_total_max_players = 0; - for(let i = 0; i < servers.length; i++) { + for (let i = 0; i < servers.length; i++) { try { all_total_players += parseInt(servers[i].getAttribute('data-players')); all_total_max_players += parseInt(servers[i].getAttribute('data-max')); @@ -459,17 +472,17 @@ function update_servers_status(data) { try { - update_one_server_status(data[0]); + update_one_server_status(data[0]); } catch (e) { - console.log ('Failed to update server stats', e) + console.log('Failed to update server stats', e) } display_motd(); } - $(document).ready(function() { + $(document).ready(function () { console.log('ready for JS!') - $(".play_button").click(function() { + $(".play_button").click(function () { server_id = $(this).attr("data-id"); send_command(server_id, 'start_server'); bootbox.alert({ @@ -479,7 +492,7 @@ }); }); - $(".stop_button").click(function() { + $(".stop_button").click(function () { console.log("stopping server"); server_id = $(this).attr("data-id"); send_command(server_id, 'stop_server'); @@ -490,7 +503,7 @@ }); }); - $(".restart_button").click(function() { + $(".restart_button").click(function () { server_id = $(this).attr("data-id"); send_command(server_id, 'restart_server'); bootbox.alert({ @@ -499,7 +512,7 @@ message: '
  {% raw translate("dashboard", "bePatientRestart", data["lang"]) %}
' }); }); - $(".kill_button").click(function() { + $(".kill_button").click(function () { server_id = $(this).attr("data-id"); bootbox.confirm({ message: "This will kill the server process and all it's subprocesses. Killing a process can potentially corrupt files. Only do this in extreme circumstances. Are you sure you would like to continue?", @@ -513,7 +526,7 @@ className: 'btn-secondary' } }, - callback: function(result) { + callback: function (result) { if (result) { send_kill(server_id); let dialog = bootbox.dialog({ @@ -521,8 +534,8 @@ message: '

Loading...

' }); - dialog.init(function() { - setTimeout(function() { + dialog.init(function () { + setTimeout(function () { location.reload(); }, 15000); }); @@ -537,7 +550,7 @@ mem_percent = document.getElementById('mem_percent'); - webSocket.on('update_host_stats', function(hostStats) { + webSocket.on('update_host_stats', function (hostStats) { let cpuDataTitle = `{% raw translate('dashboard', 'cpuCores', data['lang']) %}: ${hostStats.cpu_cores}
{% raw translate("dashboard", "cpuCurFreq", data['lang']) %}: ${hostStats.cpu_cur_freq}
{% raw translate("dashboard", "cpuMaxFreq", data['lang']) %}: ${hostStats.cpu_max_freq}`; cpu_data.setAttribute('data-original-title', cpuDataTitle); cpu_usage.textContent = hostStats.cpu_usage; @@ -547,13 +560,13 @@ } if (webSocket) { - webSocket.on('send_start_reload', function() { + webSocket.on('send_start_reload', function () { location.reload() }); } if (webSocket) { - webSocket.on('update_button_status', function(updateButton) { + webSocket.on('update_button_status', function (updateButton) { let serverId = updateButton.server_id; let message = updateButton.string; let updating = updateButton.isUpdating; @@ -572,7 +585,7 @@ webSocket.on('update_server_status', update_servers_status); } - $(".clone_button").click(function() { + $(".clone_button").click(function () { server_id = $(this).attr("data-id"); send_command(server_id, 'clone_server'); bootbox.alert({ @@ -589,21 +602,25 @@ -{% end %} +{% end %} \ No newline at end of file diff --git a/app/frontend/templates/panel/panel_config.html b/app/frontend/templates/panel/panel_config.html index 1fadb840..94d5c0f1 100644 --- a/app/frontend/templates/panel/panel_config.html +++ b/app/frontend/templates/panel/panel_config.html @@ -9,11 +9,11 @@
- +
@@ -30,11 +30,16 @@
-

{{ translate('panelConfig', 'users', data['lang']) }}

- - +

{{ translate('panelConfig', 'users', data['lang']) + }}

+ {% if data['user_data']['hints'] %} + + {% end %} - +
@@ -50,38 +55,38 @@ - {% for user in data['users'] %} + {% for user in data['users'] %} {{ user.username }} {% if user.enabled %} - - Yes - + + Yes + {% else %} - - No - + + No + {% end %} -
    +
      {% for item in data['auth-servers'][user.user_id] %} -
    • {{item}}
    • +
    • {{item}}
    • {% end %}
      - {% for item in data['user-roles'][user.user_id] %} + {% for item in data['user-roles'][user.user_id] %}
    • {{item}}
    • - {% end %} + {% end %}
    - {% end %} + {% end %}
@@ -93,9 +98,15 @@
-

{{ translate('panelConfig', 'roles', data['lang']) }}

- - +

{{ translate('panelConfig', 'roles', + data['lang']) }}

+ {% if data['user_data']['hints'] %} + + {% end %} +
@@ -110,7 +121,7 @@ - {% for role in data['roles'] %} + {% for role in data['roles'] %} {{ role.role_name }} @@ -120,19 +131,20 @@ {% end %} -
    - {% for user in data['users'] %} + +
      + {% for user in data['users'] %} {% for ruser in data['user-roles'][user.user_id] %} - {% if ruser == role.role_name %} -
    • {{ user.username }}
    • - {% end %} - {% end %} - {% end %} -
    + {% if ruser == role.role_name %} +
  • {{ user.username }}
  • + {% end %} + {% end %} + {% end %} +
- {% end %} + {% end %} @@ -146,10 +158,12 @@
-

{{ translate('panelConfig', 'adminControls', data['lang']) }}

+

{{ translate('panelConfig', 'adminControls', + data['lang']) }}

- +
@@ -165,9 +179,10 @@
@@ -175,46 +190,46 @@ {% block js %} {% end %} \ No newline at end of file diff --git a/app/frontend/templates/panel/panel_edit_user.html b/app/frontend/templates/panel/panel_edit_user.html index e255349d..1e42bf17 100644 --- a/app/frontend/templates/panel/panel_edit_user.html +++ b/app/frontend/templates/panel/panel_edit_user.html @@ -224,6 +224,16 @@ {% end %} + +
-
-
- - - - - - - - - - - - - - {% for schedule in data['schedules'] %} - - - - - - - +
IDActionCommandIntervalStart TimeEnabledEdit
-

{{schedule.schedule_id}}

-
-

{{schedule.action}}

-
-

{{schedule.command}}

-
- {% if schedule.interval != '' %} -

Every

-

{{schedule.interval}} {{schedule.interval_type}}

- {% elif schedule.interval_type == 'reaction' %} -

{{schedule.interval_type}}

child of ID: {{ schedule.parent }}

- {% else %} -

Cron String:

-

{{schedule.cron_string}}

- {% end %} -
-

{{schedule.start_time}}

-
+
+
+
+
+

Scheduled Tasks

+ {% if data['user_data']['hints'] %} + + {% end %} +
+
+
+ + + + + + + + + + + + + + {% for schedule in data['schedules'] %} + + + + + + + - + - + + + + {% end %} + +
IDActionCommandIntervalStart TimeEnabledEdit
+

{{schedule.schedule_id}}

+
+

{{schedule.action}}

+
+

{{schedule.command}}

+
+ {% if schedule.interval != '' %} +

Every

+

{{schedule.interval}} {{schedule.interval_type}}

+ {% elif schedule.interval_type == 'reaction' %} +

{{schedule.interval_type}}

child of ID: {{ schedule.parent }}

+ {% else %} +

Cron String:

+

{{schedule.cron_string}}

+ {% end %} +
+

{{schedule.start_time}}

+
{% if schedule.enabled %} Yes {% else %} - No + No {% end %} - - + +

-
+
+ + + + + + + + + + {% for schedule in data['schedules'] %} + + + + -
ActionCommandEnabled
+

{{schedule.action}}

+
+

{{schedule.command}}

+
+ {% if schedule.enabled %} + + Yes + + {% else %} + + No + {% end %} -
-
- - - - - - - - - - {% for schedule in data['schedules'] %} - - - - - - - -
ActionCommandEnabled
-

{{schedule.action}}

-
-

{{schedule.command}}

-
- {% if schedule.enabled %} - - Yes - - {% else %} - - No - - {% end %} -
+
-
+ {% end %} +
+
+
@@ -235,140 +259,140 @@ td { + -{% end %} +{% end %} \ No newline at end of file diff --git a/app/migrations/20210915205501_waiting_start_1 copy.py b/app/migrations/20210915205501_waiting_start_1 copy.py new file mode 100644 index 00000000..d7016cd7 --- /dev/null +++ b/app/migrations/20210915205501_waiting_start_1 copy.py @@ -0,0 +1,16 @@ +# Generated by database migrator +import peewee + + +def migrate(migrator, database, **kwargs): + migrator.add_columns("users", hints=peewee.BooleanField(default=True)) + """ + Write your migrations here. + """ + + +def rollback(migrator, database, **kwargs): + migrator.drop_columns("users", ["hints"]) + """ + Write your rollback migrations here. + """