mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Trying to fix stuff
This commit is contained in:
parent
18bf7ebd01
commit
f597a26e5b
@ -107,9 +107,7 @@ class ServerPermsController:
|
|||||||
)
|
)
|
||||||
|
|
||||||
for server in authorized_servers:
|
for server in authorized_servers:
|
||||||
srv: Server = ServersController().get_server_instance_by_id(
|
srv = ServersController().get_server_instance_by_id(server.get("server_id"))
|
||||||
server.get("server_id")
|
|
||||||
)
|
|
||||||
latest = srv.stats_helper.get_latest_server_stats()
|
latest = srv.stats_helper.get_latest_server_stats()
|
||||||
server_data.append(
|
server_data.append(
|
||||||
{
|
{
|
||||||
|
@ -225,7 +225,7 @@ class ServersController(metaclass=Singleton):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def refresh_server_settings(self, server_id: int):
|
def refresh_server_settings(self, server_id: int):
|
||||||
server_obj: Server = self.get_server_data_by_id(server_id)
|
server_obj = self.get_server_instance_by_id(server_id)
|
||||||
server_obj.reload_server_settings()
|
server_obj.reload_server_settings()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -287,7 +287,7 @@ class ServersController(metaclass=Singleton):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_authorized_servers_stats_api_key(api_key: ApiKeys):
|
def get_authorized_servers_stats_api_key(api_key: ApiKeys):
|
||||||
server_data = []
|
server_data = []
|
||||||
authorized_servers = ServersController.get_authorized_servers(
|
authorized_servers = ServersController().get_authorized_servers(
|
||||||
api_key.user_id # TODO: API key authorized servers?
|
api_key.user_id # TODO: API key authorized servers?
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -376,10 +376,13 @@ class ServersController(metaclass=Singleton):
|
|||||||
logger.warning(f"Unable to find server object for server id {server_id}")
|
logger.warning(f"Unable to find server object for server id {server_id}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
def list_defined_servers(self):
|
||||||
def list_defined_servers():
|
defined_servers = []
|
||||||
servers = HelperServers.get_all_defined_servers()
|
for server in self.servers_list:
|
||||||
return servers
|
defined_servers.append(
|
||||||
|
self.get_server_instance_by_id(server.get("server_id"))
|
||||||
|
)
|
||||||
|
return defined_servers
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_all_server_ids() -> t.List[int]:
|
def get_all_server_ids() -> t.List[int]:
|
||||||
|
@ -123,17 +123,11 @@ class HelperServerStats:
|
|||||||
server_data = []
|
server_data = []
|
||||||
try:
|
try:
|
||||||
for server in servers:
|
for server in servers:
|
||||||
latest = (
|
latest = self.get_latest_server_stats()
|
||||||
ServerStats.select()
|
|
||||||
.where(ServerStats.server_id == server.get("server_id"))
|
|
||||||
.order_by(ServerStats.created.desc())
|
|
||||||
.limit(1)
|
|
||||||
)
|
|
||||||
latest._database = self.database
|
|
||||||
server_data.append(
|
server_data.append(
|
||||||
{
|
{
|
||||||
"server_data": server,
|
"server_data": server,
|
||||||
"stats": DatabaseShortcuts.get_data_obj(latest),
|
"stats": latest,
|
||||||
"user_command_permission": True,
|
"user_command_permission": True,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -180,7 +180,7 @@ class BaseHandler(tornado.web.RequestHandler):
|
|||||||
|
|
||||||
exec_user_role = set()
|
exec_user_role = set()
|
||||||
if superuser:
|
if superuser:
|
||||||
authorized_servers = self.controller.servers.list_defined_servers()
|
authorized_servers = self.controller.servers.get_all_defined_servers()
|
||||||
exec_user_role.add("Super User")
|
exec_user_role.add("Super User")
|
||||||
exec_user_crafty_permissions = (
|
exec_user_crafty_permissions = (
|
||||||
self.controller.crafty_perms.list_defined_crafty_permissions()
|
self.controller.crafty_perms.list_defined_crafty_permissions()
|
||||||
|
@ -41,7 +41,7 @@ class PanelHandler(BaseHandler):
|
|||||||
|
|
||||||
def get_role_servers(self) -> t.List[RolesController.RoleServerJsonType]:
|
def get_role_servers(self) -> t.List[RolesController.RoleServerJsonType]:
|
||||||
servers = []
|
servers = []
|
||||||
for server in self.controller.servers.list_defined_servers():
|
for server in self.controller.servers.get_all_defined_servers():
|
||||||
argument = self.get_argument(f"server_{server['server_id']}_access", "0")
|
argument = self.get_argument(f"server_{server['server_id']}_access", "0")
|
||||||
if argument == "0":
|
if argument == "0":
|
||||||
continue
|
continue
|
||||||
@ -269,6 +269,7 @@ class PanelHandler(BaseHandler):
|
|||||||
page_servers.append(
|
page_servers.append(
|
||||||
DatabaseShortcuts.get_data_obj(server.server_object)
|
DatabaseShortcuts.get_data_obj(server.server_object)
|
||||||
)
|
)
|
||||||
|
|
||||||
for server_id in user_order[:]:
|
for server_id in user_order[:]:
|
||||||
# remove IDs in list that user no longer has access to
|
# remove IDs in list that user no longer has access to
|
||||||
if str(server_id) not in server_ids:
|
if str(server_id) not in server_ids:
|
||||||
@ -801,7 +802,7 @@ class PanelHandler(BaseHandler):
|
|||||||
|
|
||||||
page_data["roles_all"] = self.controller.roles.get_all_roles()
|
page_data["roles_all"] = self.controller.roles.get_all_roles()
|
||||||
page_data["servers"] = []
|
page_data["servers"] = []
|
||||||
page_data["servers_all"] = self.controller.servers.list_defined_servers()
|
page_data["servers_all"] = self.controller.servers.get_all_defined_servers()
|
||||||
page_data["role-servers"] = []
|
page_data["role-servers"] = []
|
||||||
page_data[
|
page_data[
|
||||||
"permissions_all"
|
"permissions_all"
|
||||||
@ -979,7 +980,7 @@ class PanelHandler(BaseHandler):
|
|||||||
page_data["servers"] = set()
|
page_data["servers"] = set()
|
||||||
page_data["role-servers"] = page_role_servers
|
page_data["role-servers"] = page_role_servers
|
||||||
page_data["roles_all"] = self.controller.roles.get_all_roles()
|
page_data["roles_all"] = self.controller.roles.get_all_roles()
|
||||||
page_data["servers_all"] = self.controller.servers.list_defined_servers()
|
page_data["servers_all"] = self.controller.servers.get_all_defined_servers()
|
||||||
page_data["superuser"] = superuser
|
page_data["superuser"] = superuser
|
||||||
page_data[
|
page_data[
|
||||||
"permissions_all"
|
"permissions_all"
|
||||||
@ -1107,7 +1108,7 @@ class PanelHandler(BaseHandler):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
page_data["servers_all"] = self.controller.servers.list_defined_servers()
|
page_data["servers_all"] = self.controller.servers.get_all_defined_servers()
|
||||||
page_data[
|
page_data[
|
||||||
"permissions_all"
|
"permissions_all"
|
||||||
] = self.controller.server_perms.list_defined_permissions()
|
] = self.controller.server_perms.list_defined_permissions()
|
||||||
@ -1119,7 +1120,7 @@ class PanelHandler(BaseHandler):
|
|||||||
page_data["new_role"] = False
|
page_data["new_role"] = False
|
||||||
role_id = self.get_argument("id", None)
|
role_id = self.get_argument("id", None)
|
||||||
page_data["role"] = self.controller.roles.get_role_with_servers(role_id)
|
page_data["role"] = self.controller.roles.get_role_with_servers(role_id)
|
||||||
page_data["servers_all"] = self.controller.servers.list_defined_servers()
|
page_data["servers_all"] = self.controller.servers.get_all_defined_servers()
|
||||||
page_data[
|
page_data[
|
||||||
"permissions_all"
|
"permissions_all"
|
||||||
] = self.controller.server_perms.list_defined_permissions()
|
] = self.controller.server_perms.list_defined_permissions()
|
||||||
|
@ -10,6 +10,7 @@ import requests
|
|||||||
from app.classes.models.crafty_permissions import EnumPermissionsCrafty
|
from app.classes.models.crafty_permissions import EnumPermissionsCrafty
|
||||||
from app.classes.shared.helpers import Helpers
|
from app.classes.shared.helpers import Helpers
|
||||||
from app.classes.shared.file_helpers import FileHelpers
|
from app.classes.shared.file_helpers import FileHelpers
|
||||||
|
from app.classes.shared.main_models import DatabaseShortcuts
|
||||||
from app.classes.web.base_handler import BaseHandler
|
from app.classes.web.base_handler import BaseHandler
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -52,6 +53,14 @@ class ServerHandler(BaseHandler):
|
|||||||
exec_user_role.add(role["role_name"])
|
exec_user_role.add(role["role_name"])
|
||||||
list_roles.append(self.controller.roles.get_role(role["role_id"]))
|
list_roles.append(self.controller.roles.get_role(role["role_id"]))
|
||||||
|
|
||||||
|
page_servers = []
|
||||||
|
for server in defined_servers:
|
||||||
|
if server not in page_servers:
|
||||||
|
page_servers.append(
|
||||||
|
DatabaseShortcuts.get_data_obj(server.server_object)
|
||||||
|
)
|
||||||
|
defined_servers = page_servers
|
||||||
|
|
||||||
template = "public/404.html"
|
template = "public/404.html"
|
||||||
|
|
||||||
page_data = {
|
page_data = {
|
||||||
|
1
main.py
1
main.py
@ -152,7 +152,6 @@ if __name__ == "__main__":
|
|||||||
logger.info("Initializing all servers defined")
|
logger.info("Initializing all servers defined")
|
||||||
Console.info("Initializing all servers defined")
|
Console.info("Initializing all servers defined")
|
||||||
controller.servers.init_all_servers()
|
controller.servers.init_all_servers()
|
||||||
servers = controller.servers.list_defined_servers()
|
|
||||||
|
|
||||||
def tasks_starter():
|
def tasks_starter():
|
||||||
# start stats logging
|
# start stats logging
|
||||||
|
Loading…
Reference in New Issue
Block a user