diff --git a/api/tacticalrmm/accounts/migrations/0010_user_agent_dblclick_action.py b/api/tacticalrmm/accounts/migrations/0010_user_agent_dblclick_action.py new file mode 100644 index 00000000..460ccdb1 --- /dev/null +++ b/api/tacticalrmm/accounts/migrations/0010_user_agent_dblclick_action.py @@ -0,0 +1,26 @@ +# Generated by Django 3.1.4 on 2021-01-14 01:23 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("accounts", "0009_user_show_community_scripts"), + ] + + operations = [ + migrations.AddField( + model_name="user", + name="agent_dblclick_action", + field=models.CharField( + choices=[ + ("editagent", "Edit Agent"), + ("takecontrol", "Take Control"), + ("remotebg", "Remote Background"), + ], + default="editagent", + max_length=50, + ), + ), + ] diff --git a/api/tacticalrmm/accounts/models.py b/api/tacticalrmm/accounts/models.py index 565fa0cc..41d6de8c 100644 --- a/api/tacticalrmm/accounts/models.py +++ b/api/tacticalrmm/accounts/models.py @@ -3,12 +3,21 @@ from django.contrib.auth.models import AbstractUser from logs.models import BaseAuditModel +AGENT_DBLCLICK_CHOICES = [ + ("editagent", "Edit Agent"), + ("takecontrol", "Take Control"), + ("remotebg", "Remote Background"), +] + class User(AbstractUser, BaseAuditModel): is_active = models.BooleanField(default=True) totp_key = models.CharField(max_length=50, null=True, blank=True) dark_mode = models.BooleanField(default=True) show_community_scripts = models.BooleanField(default=True) + agent_dblclick_action = models.CharField( + max_length=50, choices=AGENT_DBLCLICK_CHOICES, default="editagent" + ) agent = models.OneToOneField( "agents.Agent", diff --git a/api/tacticalrmm/accounts/tests.py b/api/tacticalrmm/accounts/tests.py index 339bf987..720bc3f5 100644 --- a/api/tacticalrmm/accounts/tests.py +++ b/api/tacticalrmm/accounts/tests.py @@ -278,6 +278,18 @@ class TestUserAction(TacticalTestCase): r = self.client.patch(url, data, format="json") self.assertEqual(r.status_code, 200) + data = {"agent_dblclick_action": "editagent"} + r = self.client.patch(url, data, format="json") + self.assertEqual(r.status_code, 200) + + data = {"agent_dblclick_action": "remotebg"} + r = self.client.patch(url, data, format="json") + self.assertEqual(r.status_code, 200) + + data = {"agent_dblclick_action": "takecontrol"} + r = self.client.patch(url, data, format="json") + self.assertEqual(r.status_code, 200) + self.check_not_authenticated("patch", url) diff --git a/api/tacticalrmm/accounts/views.py b/api/tacticalrmm/accounts/views.py index 6ff02c99..c42cc350 100644 --- a/api/tacticalrmm/accounts/views.py +++ b/api/tacticalrmm/accounts/views.py @@ -197,4 +197,8 @@ class UserUI(APIView): user.show_community_scripts = request.data["show_community_scripts"] user.save(update_fields=["show_community_scripts"]) + if "agent_dblclick_action" in request.data: + user.agent_dblclick_action = request.data["agent_dblclick_action"] + user.save(update_fields=["agent_dblclick_action"]) + return Response("ok") diff --git a/api/tacticalrmm/core/views.py b/api/tacticalrmm/core/views.py index 21629bf1..dd79d5a8 100644 --- a/api/tacticalrmm/core/views.py +++ b/api/tacticalrmm/core/views.py @@ -75,6 +75,7 @@ def dashboard_info(request): "trmm_version": settings.TRMM_VERSION, "dark_mode": request.user.dark_mode, "show_community_scripts": request.user.show_community_scripts, + "dbl_click_action": request.user.agent_dblclick_action, } ) diff --git a/web/src/components/AgentTable.vue b/web/src/components/AgentTable.vue index 1f278e6b..fccd6e2f 100644 --- a/web/src/components/AgentTable.vue +++ b/web/src/components/AgentTable.vue @@ -473,7 +473,17 @@ export default { // give time for store to change active row setTimeout(() => { this.$q.loading.hide(); - this.showEditAgentModal = true; + switch (this.agentDblClickAction) { + case "editagent": + this.showEditAgentModal = true; + break; + case "takecontrol": + this.takeControl(pk); + break; + case "remotebg": + this.remoteBG(pk); + break; + } }, 500); }, runFavScript(scriptpk, agentpk) { @@ -694,6 +704,9 @@ export default { }, computed: { ...mapGetters(["selectedAgentPk", "agentTableHeight"]), + agentDblClickAction() { + return this.$store.state.agentDblClickAction; + }, selectedRow() { return this.$store.state.selectedRow; }, diff --git a/web/src/components/modals/coresettings/UserPreferences.vue b/web/src/components/modals/coresettings/UserPreferences.vue new file mode 100644 index 00000000..ba87ee1e --- /dev/null +++ b/web/src/components/modals/coresettings/UserPreferences.vue @@ -0,0 +1,94 @@ + + + \ No newline at end of file diff --git a/web/src/store/index.js b/web/src/store/index.js index 5e1641fb..aa4ac07c 100644 --- a/web/src/store/index.js +++ b/web/src/store/index.js @@ -33,7 +33,8 @@ export default function () { needrefresh: false, tableHeight: "35vh", tabHeight: "35vh", - showCommunityScripts: false + showCommunityScripts: false, + agentDblClickAction: "", }, getters: { loggedIn(state) { @@ -135,6 +136,9 @@ export default function () { }, setShowCommunityScripts(state, show) { state.showCommunityScripts = show + }, + SET_AGENT_DBLCLICK_ACTION(state, action) { + state.agentDblClickAction = action } }, actions: { diff --git a/web/src/views/Dashboard.vue b/web/src/views/Dashboard.vue index 6f08eab3..5a9f743d 100644 --- a/web/src/views/Dashboard.vue +++ b/web/src/views/Dashboard.vue @@ -73,6 +73,11 @@ + + + Preferences + + Logout @@ -354,6 +359,10 @@ + + + + @@ -369,6 +378,7 @@ import PolicyAdd from "@/components/automation/modals/PolicyAdd"; import ClientsForm from "@/components/modals/clients/ClientsForm"; import SitesForm from "@/components/modals/clients/SitesForm"; import InstallAgent from "@/components/modals/agents/InstallAgent"; +import UserPreferences from "@/components/modals/coresettings/UserPreferences"; export default { components: { @@ -380,6 +390,7 @@ export default { ClientsForm, SitesForm, InstallAgent, + UserPreferences, }, data() { return { @@ -413,6 +424,7 @@ export default { filterChecksFailing: false, filterRebootNeeded: false, currentTRMMVersion: null, + showUserPreferencesModal: false, columns: [ { name: "smsalert", @@ -673,7 +685,7 @@ export default { this.darkMode = r.data.dark_mode; this.$q.dark.set(this.darkMode); this.currentTRMMVersion = r.data.trmm_version; - + this.$store.commit("SET_AGENT_DBLCLICK_ACTION", r.data.dbl_click_action); this.$store.commit("setShowCommunityScripts", r.data.show_community_scripts); }); },