From 522cabafe10516122379118dd76da154633e63a5 Mon Sep 17 00:00:00 2001 From: Waiter Zen Date: Mon, 14 Mar 2022 17:26:10 +0800 Subject: [PATCH 1/3] [alerts] update permission control --- plugins/alerts/frontend/public/javascripts/countly.models.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/alerts/frontend/public/javascripts/countly.models.js b/plugins/alerts/frontend/public/javascripts/countly.models.js index f1e8f6c8391..da8a4a4fc07 100644 --- a/plugins/alerts/frontend/public/javascripts/countly.models.js +++ b/plugins/alerts/frontend/public/javascripts/countly.models.js @@ -158,6 +158,8 @@ context.dispatch("countlyAlerts/table/fetchAll", null, {root: true}); }, saveAlert: function(context, alertConfig) { + delete alertConfig._canUpdate; + delete alertConfig._canDelete; return CV.$.ajax({ type: "GET", url: countlyCommon.API_PARTS.data.w + "/alert/save", @@ -205,6 +207,9 @@ }); }, saveOnlineUsersAlert: function(context, alertConfig) { + delete alertConfig._canUpdate; + delete alertConfig._canDelete; + return CV.$.ajax({ type: "GET", url: countlyCommon.API_PARTS.data.w + "/concurrent_alert/save", From 4185bfba91e430b0c17aba3e68ea414562ffad40 Mon Sep 17 00:00:00 2001 From: Waiter Zen Date: Mon, 14 Mar 2022 17:26:40 +0800 Subject: [PATCH 2/3] [hooks] update permission control --- .../frontend/public/javascripts/countly.models.js | 13 +++++++++++-- .../frontend/public/javascripts/countly.views.js | 4 +++- .../frontend/public/templates/vue-hooks-detail.html | 6 +++--- .../hooks/frontend/public/templates/vue-table.html | 11 ++++++----- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/plugins/hooks/frontend/public/javascripts/countly.models.js b/plugins/hooks/frontend/public/javascripts/countly.models.js index dc8558d1c37..32210bd68f4 100644 --- a/plugins/hooks/frontend/public/javascripts/countly.models.js +++ b/plugins/hooks/frontend/public/javascripts/countly.models.js @@ -3,11 +3,13 @@ CV, countlyVue, countlyGlobal, + countlyAuth, _, moment, */ (function(hooksPlugin, jQuery) { + var FEATURE_NAME = "hooks"; var countlyCommon = window.countlyCommon; @@ -197,8 +199,11 @@ dataType: "json", success: function(data) { if (data.hooksList && data.hooksList.length === 1) { - data.hooksList[0].triggerEffectDom = hooksPlugin.generateTriggerActionsTreeDom(data.hooksList[0]); - context.commit("setDetail", data.hooksList[0]); + var record = data.hooksList[0]; + record.triggerEffectDom = hooksPlugin.generateTriggerActionsTreeDom(record); + record._canUpdate = countlyAuth.validateUpdate(FEATURE_NAME, countlyGlobal.member, record.apps[0]), + record._canDelete = countlyAuth.validateDelete(FEATURE_NAME, countlyGlobal.member, record.apps[0]), + context.commit("setDetail", record); context.commit("setDetailLogsInitialized", true); } }, @@ -208,6 +213,8 @@ context.dispatch("countlyHooks/table/fetchAll", null, {root: true}); }, saveHook: function(context, record) { + delete record._canUpdate; + delete record._canDelete; return CV.$.ajax({ type: "POST", url: countlyCommon.API_PARTS.data.w + "/hook/save?" + "app_id=" + record.apps[0], @@ -335,6 +342,8 @@ created_at: hookList[i].created_at || 0, created_at_string: moment(hookList[i].created_at).fromNow(), triggerEffectColumn: triggerEffectDom || "", + _canUpdate: countlyAuth.validateUpdate(FEATURE_NAME, countlyGlobal.member, hookList[i].apps[0]), + _canDelete: countlyAuth.validateDelete(FEATURE_NAME, countlyGlobal.member, hookList[i].apps[0]), }); } context.commit("setInitialized", true); diff --git a/plugins/hooks/frontend/public/javascripts/countly.views.js b/plugins/hooks/frontend/public/javascripts/countly.views.js index 9abeb4702e3..4d24e0383f2 100644 --- a/plugins/hooks/frontend/public/javascripts/countly.views.js +++ b/plugins/hooks/frontend/public/javascripts/countly.views.js @@ -62,7 +62,9 @@ value: "lastTriggerTimestampString", label: CV.i18n('hooks.trigger-last-time'), default: true - }] + }], + tablePersistKey: "hooks_table_" + countlyCommon.ACTIVE_APP_ID, + }; }, methods: { diff --git a/plugins/hooks/frontend/public/templates/vue-hooks-detail.html b/plugins/hooks/frontend/public/templates/vue-hooks-detail.html index 674a00649c5..e65a563a144 100644 --- a/plugins/hooks/frontend/public/templates/vue-hooks-detail.html +++ b/plugins/hooks/frontend/public/templates/vue-hooks-detail.html @@ -13,12 +13,12 @@

{{hookDetail.name}}

@@ -79,13 +80,13 @@ - +