diff --git a/api/tacticalrmm/accounts/migrations/0011_user_default_agent_tbl_tab.py b/api/tacticalrmm/accounts/migrations/0011_user_default_agent_tbl_tab.py new file mode 100644 index 0000000000..65afbbefa0 --- /dev/null +++ b/api/tacticalrmm/accounts/migrations/0011_user_default_agent_tbl_tab.py @@ -0,0 +1,26 @@ +# Generated by Django 3.1.5 on 2021-01-18 09:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("accounts", "0010_user_agent_dblclick_action"), + ] + + operations = [ + migrations.AddField( + model_name="user", + name="default_agent_tbl_tab", + field=models.CharField( + choices=[ + ("server", "Servers"), + ("workstation", "Workstations"), + ("mixed", "Mixed"), + ], + default="server", + max_length=50, + ), + ), + ] diff --git a/api/tacticalrmm/accounts/models.py b/api/tacticalrmm/accounts/models.py index 41d6de8c6d..5bdeb9ec99 100644 --- a/api/tacticalrmm/accounts/models.py +++ b/api/tacticalrmm/accounts/models.py @@ -9,6 +9,12 @@ ("remotebg", "Remote Background"), ] +AGENT_TBL_TAB_CHOICES = [ + ("server", "Servers"), + ("workstation", "Workstations"), + ("mixed", "Mixed"), +] + class User(AbstractUser, BaseAuditModel): is_active = models.BooleanField(default=True) @@ -18,6 +24,9 @@ class User(AbstractUser, BaseAuditModel): agent_dblclick_action = models.CharField( max_length=50, choices=AGENT_DBLCLICK_CHOICES, default="editagent" ) + default_agent_tbl_tab = models.CharField( + max_length=50, choices=AGENT_TBL_TAB_CHOICES, default="server" + ) agent = models.OneToOneField( "agents.Agent", diff --git a/api/tacticalrmm/accounts/views.py b/api/tacticalrmm/accounts/views.py index c42cc35006..4d48ed24c6 100644 --- a/api/tacticalrmm/accounts/views.py +++ b/api/tacticalrmm/accounts/views.py @@ -189,16 +189,17 @@ class UserUI(APIView): def patch(self, request): user = request.user - if "dark_mode" in request.data: + if "dark_mode" in request.data.keys(): user.dark_mode = request.data["dark_mode"] user.save(update_fields=["dark_mode"]) - if "show_community_scripts" in request.data: + if "show_community_scripts" in request.data.keys(): user.show_community_scripts = request.data["show_community_scripts"] user.save(update_fields=["show_community_scripts"]) - if "agent_dblclick_action" in request.data: + if "userui" in request.data.keys(): user.agent_dblclick_action = request.data["agent_dblclick_action"] - user.save(update_fields=["agent_dblclick_action"]) + user.default_agent_tbl_tab = request.data["default_agent_tbl_tab"] + user.save(update_fields=["agent_dblclick_action", "default_agent_tbl_tab"]) return Response("ok") diff --git a/api/tacticalrmm/agents/serializers.py b/api/tacticalrmm/agents/serializers.py index 1365b454d4..abee653b20 100644 --- a/api/tacticalrmm/agents/serializers.py +++ b/api/tacticalrmm/agents/serializers.py @@ -42,11 +42,13 @@ class AgentTableSerializer(serializers.ModelSerializer): last_seen = serializers.SerializerMethodField() client_name = serializers.ReadOnlyField(source="client.name") site_name = serializers.ReadOnlyField(source="site.name") + logged_username = serializers.SerializerMethodField() + italic = serializers.SerializerMethodField() def get_pending_actions(self, obj): return obj.pendingactions.filter(status="pending").count() - def get_last_seen(self, obj): + def get_last_seen(self, obj) -> str: if obj.time_zone is not None: agent_tz = pytz.timezone(obj.time_zone) else: @@ -54,6 +56,17 @@ def get_last_seen(self, obj): return obj.last_seen.astimezone(agent_tz).strftime("%m %d %Y %H:%M:%S") + def get_logged_username(self, obj) -> str: + if obj.logged_in_username == "None" and obj.status == "online": + return obj.last_logged_in_user + elif obj.logged_in_username != "None": + return obj.logged_in_username + else: + return "-" + + def get_italic(self, obj) -> bool: + return obj.logged_in_username == "None" and obj.status == "online" + class Meta: model = Agent fields = [ @@ -73,9 +86,9 @@ class Meta: "last_seen", "boot_time", "checks", - "logged_in_username", - "last_logged_in_user", "maintenance_mode", + "logged_username", + "italic", ] depth = 2 diff --git a/api/tacticalrmm/core/views.py b/api/tacticalrmm/core/views.py index d1ff9ab87b..c6651ff30a 100644 --- a/api/tacticalrmm/core/views.py +++ b/api/tacticalrmm/core/views.py @@ -72,6 +72,7 @@ def dashboard_info(request): "dark_mode": request.user.dark_mode, "show_community_scripts": request.user.show_community_scripts, "dbl_click_action": request.user.agent_dblclick_action, + "default_agent_tbl_tab": request.user.default_agent_tbl_tab, } ) diff --git a/api/tacticalrmm/tacticalrmm/settings.py b/api/tacticalrmm/tacticalrmm/settings.py index b1d5d1a307..dd0c41cdf7 100644 --- a/api/tacticalrmm/tacticalrmm/settings.py +++ b/api/tacticalrmm/tacticalrmm/settings.py @@ -15,11 +15,11 @@ AUTH_USER_MODEL = "accounts.User" # latest release -TRMM_VERSION = "0.3.1" +TRMM_VERSION = "0.3.2" # bump this version everytime vue code is changed # to alert user they need to manually refresh their browser -APP_VER = "0.0.104" +APP_VER = "0.0.105" # https://github.com/wh1te909/salt LATEST_SALT_VER = "1.1.0" diff --git a/docs/migration-0.3.0.md b/docs/migration-0.3.0.md index fa6a793ca5..6141356d22 100644 --- a/docs/migration-0.3.0.md +++ b/docs/migration-0.3.0.md @@ -139,7 +139,7 @@ server { } ``` -4. Edit `/meshcentral/meshcentral-data/config.json` and change to match the example below. Replace `mesh.example.com` with your mesh domain. +4. Edit `/meshcentral/meshcentral-data/config.json` and change to match the example below. Replace `mesh.example.com` with your mesh domain. After editing, use a json linter like `https://jsonlint.com/` to verify no syntax errors, otherwise meshcentral will fail to start. ``` { "settings": { diff --git a/web/src/components/AgentTable.vue b/web/src/components/AgentTable.vue index fccd6e2f8b..e3895da5da 100644 --- a/web/src/components/AgentTable.vue +++ b/web/src/components/AgentTable.vue @@ -53,12 +53,6 @@ -