From 31cae7f403cc174005cc71dc9de74a0c0f536dec Mon Sep 17 00:00:00 2001 From: itsiprikshit Date: Sun, 6 Mar 2022 10:20:25 +0000 Subject: [PATCH 1/6] removed permission from widget registrations --- .../public/core/device-and-type/javascripts/countly.views.js | 1 - .../public/core/geo-countries/javascripts/countly.widgets.geo.js | 1 - .../core/user-analytics-overview/javascripts/countly.views.js | 1 - .../crashes/frontend/public/javascripts/countly.widgets.crash.js | 1 - .../frontend/public/javascripts/countly.widgets.analytics.js | 1 - .../frontend/public/javascripts/countly.widgets.events.js | 1 - .../frontend/public/javascripts/countly.widgets.note.js | 1 - plugins/push/frontend/public/javascripts/countly.views.js | 1 - plugins/sources/frontend/public/javascripts/countly.views.js | 1 - plugins/views/frontend/public/javascripts/countly.views.js | 1 - 10 files changed, 10 deletions(-) diff --git a/frontend/express/public/core/device-and-type/javascripts/countly.views.js b/frontend/express/public/core/device-and-type/javascripts/countly.views.js index 1524a7c4f1c..105d70f953d 100644 --- a/frontend/express/public/core/device-and-type/javascripts/countly.views.js +++ b/frontend/express/public/core/device-and-type/javascripts/countly.views.js @@ -477,7 +477,6 @@ var DrawerComponent = countlyVue.views.create({ countlyVue.container.registerData("/custom/dashboards/widget", { type: "analytics", label: CV.i18n("sidebar.analytics.technology"), - permission: "core", priority: 1, primary: false, getter: function(widget) { diff --git a/frontend/express/public/core/geo-countries/javascripts/countly.widgets.geo.js b/frontend/express/public/core/geo-countries/javascripts/countly.widgets.geo.js index e70f6392c3c..55dc783e1da 100644 --- a/frontend/express/public/core/geo-countries/javascripts/countly.widgets.geo.js +++ b/frontend/express/public/core/geo-countries/javascripts/countly.widgets.geo.js @@ -100,7 +100,6 @@ countlyVue.container.registerData("/custom/dashboards/widget", { type: "analytics", label: CV.i18nM("dashboards.widget-type.analytics"), - permission: "core", priority: 1, primary: false, getter: function(widget) { diff --git a/frontend/express/public/core/user-analytics-overview/javascripts/countly.views.js b/frontend/express/public/core/user-analytics-overview/javascripts/countly.views.js index f29b49e0d8e..f4b551cdc1d 100644 --- a/frontend/express/public/core/user-analytics-overview/javascripts/countly.views.js +++ b/frontend/express/public/core/user-analytics-overview/javascripts/countly.views.js @@ -369,7 +369,6 @@ var DrawerComponent = countlyVue.views.create({ countlyVue.container.registerData("/custom/dashboards/widget", { type: "analytics", label: CV.i18n("user-analytics.overview-title"), - permission: "core", priority: 1, primary: false, getter: function(widget) { diff --git a/plugins/crashes/frontend/public/javascripts/countly.widgets.crash.js b/plugins/crashes/frontend/public/javascripts/countly.widgets.crash.js index 4cb5ec9d6de..cfd852486e2 100644 --- a/plugins/crashes/frontend/public/javascripts/countly.widgets.crash.js +++ b/plugins/crashes/frontend/public/javascripts/countly.widgets.crash.js @@ -164,7 +164,6 @@ countlyVue.container.registerData("/custom/dashboards/widget", { type: "crashes", label: CV.i18nM("dashboards.widget-type.crash"), - permission: "crashes", priority: 11, primary: true, getter: function(widget) { diff --git a/plugins/dashboards/frontend/public/javascripts/countly.widgets.analytics.js b/plugins/dashboards/frontend/public/javascripts/countly.widgets.analytics.js index 33a4ae50012..fbea4b02934 100644 --- a/plugins/dashboards/frontend/public/javascripts/countly.widgets.analytics.js +++ b/plugins/dashboards/frontend/public/javascripts/countly.widgets.analytics.js @@ -201,7 +201,6 @@ countlyVue.container.registerData("/custom/dashboards/widget", { type: "analytics", label: CV.i18nM("dashboards.widget-type.analytics"), - permission: "core", priority: 1, primary: true, getter: function(widget) { diff --git a/plugins/dashboards/frontend/public/javascripts/countly.widgets.events.js b/plugins/dashboards/frontend/public/javascripts/countly.widgets.events.js index 4f3db707a4c..303f807cd2c 100644 --- a/plugins/dashboards/frontend/public/javascripts/countly.widgets.events.js +++ b/plugins/dashboards/frontend/public/javascripts/countly.widgets.events.js @@ -253,7 +253,6 @@ countlyVue.container.registerData("/custom/dashboards/widget", { type: "events", label: CV.i18nM("dashboards.widget-type.events"), - permission: "events", priority: 2, primary: true, getter: function(widget) { diff --git a/plugins/dashboards/frontend/public/javascripts/countly.widgets.note.js b/plugins/dashboards/frontend/public/javascripts/countly.widgets.note.js index 4b0be5b08d6..25e8400356e 100644 --- a/plugins/dashboards/frontend/public/javascripts/countly.widgets.note.js +++ b/plugins/dashboards/frontend/public/javascripts/countly.widgets.note.js @@ -135,7 +135,6 @@ countlyVue.container.registerData("/custom/dashboards/widget", { type: "note", label: CV.i18nM("dashboards.widget-type.note"), - permission: "core", priority: 5, primary: true, getter: function(widget) { diff --git a/plugins/push/frontend/public/javascripts/countly.views.js b/plugins/push/frontend/public/javascripts/countly.views.js index 1875f88d5b6..4cc35939675 100644 --- a/plugins/push/frontend/public/javascripts/countly.views.js +++ b/plugins/push/frontend/public/javascripts/countly.views.js @@ -2546,7 +2546,6 @@ countlyVue.container.registerData('/custom/dashboards/widget', { type: 'push', label: CV.i18n('push-notification.title'), - permission: featureName, priority: 6, primary: true, getter: function(widget) { diff --git a/plugins/sources/frontend/public/javascripts/countly.views.js b/plugins/sources/frontend/public/javascripts/countly.views.js index 5fdcae65cb6..37908687dd1 100755 --- a/plugins/sources/frontend/public/javascripts/countly.views.js +++ b/plugins/sources/frontend/public/javascripts/countly.views.js @@ -389,7 +389,6 @@ countlyVue.container.registerData("/custom/dashboards/widget", { type: "analytics", label: CV.i18nM("sources.title"), - permission: FEATURE_NAME, priority: 1, primary: false, getter: function(widget) { diff --git a/plugins/views/frontend/public/javascripts/countly.views.js b/plugins/views/frontend/public/javascripts/countly.views.js index 47ee3571756..9d96cc6142c 100644 --- a/plugins/views/frontend/public/javascripts/countly.views.js +++ b/plugins/views/frontend/public/javascripts/countly.views.js @@ -924,7 +924,6 @@ countlyVue.container.registerData("/custom/dashboards/widget", { type: "analytics", label: CV.i18n("views.widget-type"), - permission: FEATURE_NAME, priority: 1, primary: false, getter: function(widget) { From 1b558afb9bfb32b484232728e8a61fd62f879807 Mon Sep 17 00:00:00 2001 From: itsiprikshit Date: Sun, 6 Mar 2022 10:51:00 +0000 Subject: [PATCH 2/6] set dashboard apps --- .../public/javascripts/countly.models.js | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/plugins/dashboards/frontend/public/javascripts/countly.models.js b/plugins/dashboards/frontend/public/javascripts/countly.models.js index 1158971fa26..3bbf5310890 100644 --- a/plugins/dashboards/frontend/public/javascripts/countly.models.js +++ b/plugins/dashboards/frontend/public/javascripts/countly.models.js @@ -372,7 +372,8 @@ id: null, data: null }, - events: {} + events: {}, + apps: {} }; }; @@ -383,6 +384,9 @@ selected: function(state) { return state.selected; }, + allApps: function(state) { + return state.apps; + }, reportDateRangeDict: function() { return { daily: [ @@ -498,6 +502,12 @@ var eventsObj = state.events; eventsObj[events._id] = events; state.events = JSON.parse(JSON.stringify(eventsObj)); + }, + setApps: function(state, apps) { + state.apps = apps.reduce(function(acc, app) { + acc[app._id] = app; + return acc; + }, {}); } }; @@ -528,6 +538,7 @@ var isSane = context.getters["requests/isSane"]; var dashbaord = null; var widgets = []; + var apps = []; var dId = null; if (res && res._id) { @@ -536,6 +547,7 @@ if (dId === dashboardId) { dashbaord = res; widgets = dashbaord.widgets || []; + apps = dashbaord.apps || []; } else { dId = null; @@ -563,6 +575,9 @@ } context.dispatch("widgets/setAll", widgets); + context.commit("setApps", apps); + + return false; } return dashbaord; @@ -595,21 +610,16 @@ }); var widgets = dash && dash.widgets || []; + var apps = dash && dash.apps || []; context.commit("setSelectedDashboard", {id: dashboardId, data: dash}); - - /* - Set all widgets of this dashboard here in the vuex store - Start - */ context.dispatch("widgets/setAll", widgets); - /* - Set all widgets of this dashboard here in the vuex store - End - */ + context.commit("setApps", apps); /* We have already set the current dashboard and its widget data in the vuex store But we will update it again after we have the updated data from the server - Until the request is processing, we will show the loading states for the widgets if no data is available + Until the request is processing, we will show the loading states for the widgets if no data is available. */ if (dashboardId) { From 47704761beeb101207c215c230bebc19635a6768 Mon Sep 17 00:00:00 2001 From: itsiprikshit Date: Sun, 6 Mar 2022 11:07:45 +0000 Subject: [PATCH 3/6] lets also add global apps in local apps object --- .../public/javascripts/countly.models.js | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/plugins/dashboards/frontend/public/javascripts/countly.models.js b/plugins/dashboards/frontend/public/javascripts/countly.models.js index 3bbf5310890..a7dfda77f9a 100644 --- a/plugins/dashboards/frontend/public/javascripts/countly.models.js +++ b/plugins/dashboards/frontend/public/javascripts/countly.models.js @@ -408,6 +408,7 @@ }, allEvents: function(state) { var eventsObj = state.events; + var appsObj = state.apps; return function(appIds) { var allEvents = []; @@ -423,7 +424,7 @@ var isGroupEvent = false; var eventName = events.list[k]; - var eventNamePostfix = (appIds.length > 1) ? " (" + ((countlyGlobal.apps[events._id] && countlyGlobal.apps[events._id].name) || "Unknown") + ")" : ""; + var eventNamePostfix = (appIds.length > 1) ? " (" + ((appsObj[events._id] && appsObj[events._id].name) || "Unknown") + ")" : ""; if (events.map && events.map[eventName] && events.map[eventName].is_group_event) { isGroupEvent = true; @@ -504,10 +505,24 @@ state.events = JSON.parse(JSON.stringify(eventsObj)); }, setApps: function(state, apps) { - state.apps = apps.reduce(function(acc, app) { - acc[app._id] = app; + var appsObj = apps.reduce(function(acc, app) { + acc[app._id] = { + _id: app._id, + name: app.name + }; return acc; }, {}); + + var globalApps = {}; + + for (var key in countlyGlobal.apps) { + globalApps[key] = { + _id: key, + name: countlyGlobal.apps[key].name + }; + } + + state.apps = Object.assign({}, appsObj, globalApps); } }; From bbed9a68b1601c1e7d57e57bf80f3f3f40e197df Mon Sep 17 00:00:00 2001 From: itsiprikshit Date: Sun, 6 Mar 2022 11:46:15 +0000 Subject: [PATCH 4/6] dashboard apps mixin in core --- .../javascripts/countly.views.js | 2 +- .../javascripts/countly.widgets.geo.js | 2 +- .../javascripts/countly.views.js | 2 +- .../public/javascripts/countly/vue/core.js | 47 +++++++++++++++---- .../javascripts/countly.widgets.crash.js | 2 +- plugins/dashboards/api/api.js | 2 +- .../public/javascripts/countly.helpers.js | 38 ++++----------- .../public/javascripts/countly.models.js | 6 ++- .../javascripts/countly.widgets.analytics.js | 8 ++-- .../javascripts/countly.widgets.events.js | 2 +- .../public/javascripts/countly.views.js | 2 +- .../public/javascripts/countly.views.js | 2 +- 12 files changed, 62 insertions(+), 53 deletions(-) diff --git a/frontend/express/public/core/device-and-type/javascripts/countly.views.js b/frontend/express/public/core/device-and-type/javascripts/countly.views.js index 105d70f953d..bb08950d973 100644 --- a/frontend/express/public/core/device-and-type/javascripts/countly.views.js +++ b/frontend/express/public/core/device-and-type/javascripts/countly.views.js @@ -358,7 +358,7 @@ var TechnologyHomeWidget = countlyVue.views.create({ var GridComponent = countlyVue.views.create({ template: CV.T('/dashboards/templates/widgets/analytics/widget.html'), //using core dashboard widget template - mixins: [countlyVue.mixins.DashboardsHelpersMixin, countlyVue.mixins.zoom], + mixins: [countlyVue.mixins.customDashboards.widget, countlyVue.mixins.customDashboards.apps, countlyVue.mixins.zoom], props: { data: { type: Object, diff --git a/frontend/express/public/core/geo-countries/javascripts/countly.widgets.geo.js b/frontend/express/public/core/geo-countries/javascripts/countly.widgets.geo.js index 55dc783e1da..cfa5a7b33b2 100644 --- a/frontend/express/public/core/geo-countries/javascripts/countly.widgets.geo.js +++ b/frontend/express/public/core/geo-countries/javascripts/countly.widgets.geo.js @@ -3,7 +3,7 @@ (function() { var WidgetComponent = countlyVue.views.create({ template: CV.T('/dashboards/templates/widgets/analytics/widget.html'), //using core dashboard widget template - mixins: [countlyVue.mixins.DashboardsHelpersMixin, countlyVue.mixins.zoom], + mixins: [countlyVue.mixins.customDashboards.widget, countlyVue.mixins.customDashboards.apps, countlyVue.mixins.zoom], props: { data: { type: Object, diff --git a/frontend/express/public/core/user-analytics-overview/javascripts/countly.views.js b/frontend/express/public/core/user-analytics-overview/javascripts/countly.views.js index f4b551cdc1d..7945b003581 100644 --- a/frontend/express/public/core/user-analytics-overview/javascripts/countly.views.js +++ b/frontend/express/public/core/user-analytics-overview/javascripts/countly.views.js @@ -180,7 +180,7 @@ app.route("/analytics/users/*tab", "user-analytics-tab", function(tab) { //Analytics->User analytics - overview widget var GridComponent = countlyVue.views.create({ template: CV.T('/dashboards/templates/widgets/analytics/widget.html'), //using core dashboard widget template - mixins: [countlyVue.mixins.DashboardsHelpersMixin, countlyVue.mixins.zoom], + mixins: [countlyVue.mixins.customDashboards.widget, countlyVue.mixins.customDashboards.apps, countlyVue.mixins.zoom], props: { data: { type: Object, diff --git a/frontend/express/public/javascripts/countly/vue/core.js b/frontend/express/public/javascripts/countly/vue/core.js index e4a55209ec8..d836dcd6fb1 100644 --- a/frontend/express/public/javascripts/countly/vue/core.js +++ b/frontend/express/public/javascripts/countly/vue/core.js @@ -150,17 +150,33 @@ } }; - - var _mixins = { - 'autoRefresh': autoRefreshMixin, - 'refreshOnParentActive': refreshOnParentActiveMixin, - 'i18n': i18nMixin, - 'commonFormatters': commonFormattersMixin, - 'auth': authMixin, - 'basicComponentUtils': basicComponentUtilsMixin + var DashboardsAppsMixin = { + computed: { + __allApps: function() { + return this.$store.getters["countlyDashboards/allApps"]; + } + }, + methods: { + __getAppName: function(appId) { + if (this.__allApps && this.__allApps[appId] && this.__allApps[appId].name) { + return this.__allApps[appId].name; + } + else { + return appId; + } + }, + __getAppLogo: function(appId) { + if (this.__allApps && this.__allApps[appId] && this.__allApps[appId].image) { + return this.__allApps[appId].image; + } + else { + return 'appimages/' + appId + '.png'; + } + } + } }; - var DashboardsHelpersMixin = { + var DashboardsWidgetMixin = { methods: { calculateTableDataFromWidget: function(widgetData) { widgetData = widgetData || {}; @@ -288,7 +304,18 @@ } }; - _mixins.DashboardsHelpersMixin = DashboardsHelpersMixin; + var _mixins = { + 'autoRefresh': autoRefreshMixin, + 'refreshOnParentActive': refreshOnParentActiveMixin, + 'i18n': i18nMixin, + 'commonFormatters': commonFormattersMixin, + 'auth': authMixin, + 'basicComponentUtils': basicComponentUtilsMixin, + 'customDashboards': { + apps: DashboardsAppsMixin, + widget: DashboardsWidgetMixin + }, + }; var _globalVuexStore = new Vuex.Store({ modules: { diff --git a/plugins/crashes/frontend/public/javascripts/countly.widgets.crash.js b/plugins/crashes/frontend/public/javascripts/countly.widgets.crash.js index cfd852486e2..45dbb592745 100644 --- a/plugins/crashes/frontend/public/javascripts/countly.widgets.crash.js +++ b/plugins/crashes/frontend/public/javascripts/countly.widgets.crash.js @@ -3,7 +3,7 @@ (function() { var WidgetComponent = countlyVue.views.create({ template: CV.T('/dashboards/templates/widgets/analytics/widget.html'), - mixins: [countlyVue.mixins.DashboardsHelpersMixin, countlyVue.mixins.zoom], + mixins: [countlyVue.mixins.customDashboards.widget, countlyVue.mixins.customDashboards.apps, countlyVue.mixins.zoom], props: { data: { type: Object, diff --git a/plugins/dashboards/api/api.js b/plugins/dashboards/api/api.js index 08b38462f06..db01a7c7093 100644 --- a/plugins/dashboards/api/api.js +++ b/plugins/dashboards/api/api.js @@ -1232,7 +1232,7 @@ plugins.setConfigs("dashboards", { allApps.push(apps[appId]); } else { - allApps.push({_id: apps[appId]._id, name: apps[appId].name}); + allApps.push({_id: apps[appId]._id, name: apps[appId].name, image: apps[appId].image}); } } diff --git a/plugins/dashboards/frontend/public/javascripts/countly.helpers.js b/plugins/dashboards/frontend/public/javascripts/countly.helpers.js index 1b21e99f6ab..ffc1ac31d1c 100644 --- a/plugins/dashboards/frontend/public/javascripts/countly.helpers.js +++ b/plugins/dashboards/frontend/public/javascripts/countly.helpers.js @@ -5,27 +5,6 @@ * DRAWER HELPERS */ - var AppsMixin = { - methods: { - getAppName: function(appId) { - if (countlyGlobal.apps && countlyGlobal.apps[appId] && countlyGlobal.apps[appId].name) { - return countlyGlobal.apps[appId].name; - } - else { - return appId; - } - }, - getAppLogo: function(appId) { - if (countlyGlobal.apps && countlyGlobal.apps[appId] && countlyGlobal.apps[appId].image) { - return countlyGlobal.apps[appId].image; - } - else { - return 'appimages/' + appId + '.png'; - } - } - } - }; - var MetricComponent = countlyVue.views.create({ template: CV.T('/dashboards/templates/helpers/drawer/metric.html'), props: { @@ -129,6 +108,7 @@ var BreakdownComponent = countlyVue.views.create({ template: CV.T('/dashboards/templates/helpers/drawer/breakdown.html'), + mixins: [countlyVue.mixins.customDashboards.apps], props: { appId: { type: String, @@ -166,7 +146,7 @@ switch (this.type) { case "session": - var app = countlyGlobal.apps[appId]; + var app = this.__allApps[appId]; if (app && app.type) { breakdowns.push( @@ -285,7 +265,7 @@ breakdowns.push({ label: this.i18n("density.title"), value: "density"}); } - var app1 = countlyGlobal.apps[appId]; + var app1 = this.__allApps[appId]; if (app1 && app1.type) { if (app1.type === "web") { if (countlyGlobal.plugins && countlyGlobal.plugins.indexOf("browser") > -1) { @@ -975,7 +955,7 @@ */ var PrimaryWidgetLegend = countlyVue.views.create({ template: CV.T('/dashboards/templates/helpers/widget/primary-legend.html'), - mixins: [AppsMixin], + mixins: [countlyVue.mixins.customDashboards.apps], props: { apps: { type: Array, @@ -1005,8 +985,8 @@ return { id: appId, - name: this.getAppName(appId), - image: 'background-image: url("' + this.getAppLogo(appId) + '")' + name: this.__getAppName(appId), + image: 'background-image: url("' + this.__getAppLogo(appId) + '")' }; } } @@ -1018,7 +998,7 @@ */ var SecondaryWidgetLegend = countlyVue.views.create({ template: CV.T('/dashboards/templates/helpers/widget/secondary-legend.html'), - mixins: [AppsMixin], + mixins: [countlyVue.mixins.customDashboards.apps], props: { apps: { type: Array, @@ -1043,8 +1023,8 @@ var appId = this.apps[i]; appData.push({ id: appId, - name: this.getAppName(appId), - image: 'background-image: url("' + this.getAppLogo(appId) + '")', + name: this.__getAppName(appId), + image: 'background-image: url("' + this.__getAppLogo(appId) + '")', labels: labels[appId] || [] }); } diff --git a/plugins/dashboards/frontend/public/javascripts/countly.models.js b/plugins/dashboards/frontend/public/javascripts/countly.models.js index a7dfda77f9a..e58302be541 100644 --- a/plugins/dashboards/frontend/public/javascripts/countly.models.js +++ b/plugins/dashboards/frontend/public/javascripts/countly.models.js @@ -508,7 +508,8 @@ var appsObj = apps.reduce(function(acc, app) { acc[app._id] = { _id: app._id, - name: app.name + name: app.name, + image: app.image }; return acc; }, {}); @@ -518,7 +519,8 @@ for (var key in countlyGlobal.apps) { globalApps[key] = { _id: key, - name: countlyGlobal.apps[key].name + name: countlyGlobal.apps[key].name, + image: countlyGlobal.apps[key].image }; } diff --git a/plugins/dashboards/frontend/public/javascripts/countly.widgets.analytics.js b/plugins/dashboards/frontend/public/javascripts/countly.widgets.analytics.js index fbea4b02934..376b6251130 100644 --- a/plugins/dashboards/frontend/public/javascripts/countly.widgets.analytics.js +++ b/plugins/dashboards/frontend/public/javascripts/countly.widgets.analytics.js @@ -1,9 +1,9 @@ -/*global countlyVue, CV, countlyGlobal, countlyCommon */ +/*global countlyVue, CV, countlyCommon */ (function() { var WidgetComponent = countlyVue.views.create({ template: CV.T('/dashboards/templates/widgets/analytics/widget.html'), - mixins: [countlyVue.mixins.DashboardsHelpersMixin, countlyVue.mixins.zoom], + mixins: [countlyVue.mixins.customDashboards.widget, countlyVue.mixins.customDashboards.apps, countlyVue.mixins.zoom], props: { data: { type: Object, @@ -52,10 +52,10 @@ for (var k = 0; k < this.data.metrics.length; k++) { if (multiApps) { if (this.data.metrics.length > 1) { - name = (this.map[this.data.metrics[k]] || this.data.metrics[k]) + " " + (countlyGlobal.apps[app].name || ""); + name = (this.map[this.data.metrics[k]] || this.data.metrics[k]) + " " + (this.__allApps[app] && this.__allApps[app].name || "Unknown"); } else { - name = (countlyGlobal.apps[app].name || ""); + name = (this.__allApps[app] && this.__allApps[app].name || "Unknown"); } } else { diff --git a/plugins/dashboards/frontend/public/javascripts/countly.widgets.events.js b/plugins/dashboards/frontend/public/javascripts/countly.widgets.events.js index 303f807cd2c..0c93dff3e35 100644 --- a/plugins/dashboards/frontend/public/javascripts/countly.widgets.events.js +++ b/plugins/dashboards/frontend/public/javascripts/countly.widgets.events.js @@ -3,7 +3,7 @@ (function() { var WidgetComponent = countlyVue.views.create({ template: CV.T('/dashboards/templates/widgets/analytics/widget.html'), - mixins: [countlyVue.mixins.DashboardsHelpersMixin, countlyVue.mixins.zoom], + mixins: [countlyVue.mixins.customDashboards.widget, countlyVue.mixins.customDashboards.apps, countlyVue.mixins.zoom], props: { data: { type: Object, diff --git a/plugins/push/frontend/public/javascripts/countly.views.js b/plugins/push/frontend/public/javascripts/countly.views.js index 4cc35939675..62109266739 100644 --- a/plugins/push/frontend/public/javascripts/countly.views.js +++ b/plugins/push/frontend/public/javascripts/countly.views.js @@ -2380,7 +2380,7 @@ var PushNotificationWidgetComponent = countlyVue.views.create({ template: CV.T('/dashboards/templates/widgets/analytics/widget.html'), - mixins: [countlyVue.mixins.DashboardsHelpersMixin, countlyVue.mixins.zoom], + mixins: [countlyVue.mixins.customDashboards.widget, countlyVue.mixins.customDashboards.apps, countlyVue.mixins.zoom], props: { data: { type: Object, diff --git a/plugins/sources/frontend/public/javascripts/countly.views.js b/plugins/sources/frontend/public/javascripts/countly.views.js index 37908687dd1..2499f70c1b2 100755 --- a/plugins/sources/frontend/public/javascripts/countly.views.js +++ b/plugins/sources/frontend/public/javascripts/countly.views.js @@ -294,7 +294,7 @@ var WidgetComponent = countlyVue.views.create({ template: CV.T('/dashboards/templates/widgets/analytics/widget.html'), //using core dashboard widget template - mixins: [countlyVue.mixins.DashboardsHelpersMixin, countlyVue.mixins.zoom], + mixins: [countlyVue.mixins.customDashboards.widget, countlyVue.mixins.customDashboards.apps, countlyVue.mixins.zoom], props: { data: { type: Object, From c5cdb6059bb9dc4dc74a8bb0db2ebc1ff71f429a Mon Sep 17 00:00:00 2001 From: itsiprikshit Date: Sun, 6 Mar 2022 12:03:07 +0000 Subject: [PATCH 5/6] using app data from vuex --- .../core/device-and-type/javascripts/countly.views.js | 2 +- .../core/geo-countries/javascripts/countly.widgets.geo.js | 2 +- .../user-analytics-overview/javascripts/countly.views.js | 2 +- .../frontend/public/javascripts/countly.widgets.crash.js | 4 ++-- plugins/dashboards/api/api.js | 2 +- .../frontend/public/javascripts/countly.models.js | 6 ++++-- .../frontend/public/javascripts/countly.widgets.events.js | 4 ++-- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/frontend/express/public/core/device-and-type/javascripts/countly.views.js b/frontend/express/public/core/device-and-type/javascripts/countly.views.js index bb08950d973..7d1c5a37d6f 100644 --- a/frontend/express/public/core/device-and-type/javascripts/countly.views.js +++ b/frontend/express/public/core/device-and-type/javascripts/countly.views.js @@ -358,7 +358,7 @@ var TechnologyHomeWidget = countlyVue.views.create({ var GridComponent = countlyVue.views.create({ template: CV.T('/dashboards/templates/widgets/analytics/widget.html'), //using core dashboard widget template - mixins: [countlyVue.mixins.customDashboards.widget, countlyVue.mixins.customDashboards.apps, countlyVue.mixins.zoom], + mixins: [countlyVue.mixins.customDashboards.widget, countlyVue.mixins.zoom], props: { data: { type: Object, diff --git a/frontend/express/public/core/geo-countries/javascripts/countly.widgets.geo.js b/frontend/express/public/core/geo-countries/javascripts/countly.widgets.geo.js index cfa5a7b33b2..4c838d924cb 100644 --- a/frontend/express/public/core/geo-countries/javascripts/countly.widgets.geo.js +++ b/frontend/express/public/core/geo-countries/javascripts/countly.widgets.geo.js @@ -3,7 +3,7 @@ (function() { var WidgetComponent = countlyVue.views.create({ template: CV.T('/dashboards/templates/widgets/analytics/widget.html'), //using core dashboard widget template - mixins: [countlyVue.mixins.customDashboards.widget, countlyVue.mixins.customDashboards.apps, countlyVue.mixins.zoom], + mixins: [countlyVue.mixins.customDashboards.widget, countlyVue.mixins.zoom], props: { data: { type: Object, diff --git a/frontend/express/public/core/user-analytics-overview/javascripts/countly.views.js b/frontend/express/public/core/user-analytics-overview/javascripts/countly.views.js index 7945b003581..37ba88d8f8a 100644 --- a/frontend/express/public/core/user-analytics-overview/javascripts/countly.views.js +++ b/frontend/express/public/core/user-analytics-overview/javascripts/countly.views.js @@ -238,7 +238,7 @@ var GridComponent = countlyVue.views.create({ var name = this.map[this.data.metrics[k]] || this.data.metrics[k]; if (multiApps) { - name = (countlyGlobal.apps[app].name || app) + " (" + name + ")"; + name = (this.__allApps[app] && this.__allApps[app].name || app) + " (" + name + ")"; } series.push({ "data": [], "name": name, "app": app, "metric": this.data.metrics[k], color: countlyCommon.GRAPH_COLORS[series.length]}); } diff --git a/plugins/crashes/frontend/public/javascripts/countly.widgets.crash.js b/plugins/crashes/frontend/public/javascripts/countly.widgets.crash.js index 45dbb592745..2fe95a7275d 100644 --- a/plugins/crashes/frontend/public/javascripts/countly.widgets.crash.js +++ b/plugins/crashes/frontend/public/javascripts/countly.widgets.crash.js @@ -47,10 +47,10 @@ for (var k = 0; k < this.data.metrics.length; k++) { if (multiApps) { if (this.data.metrics.length > 1) { - name = (this.map[this.data.metrics[k]] || this.data.metrics[k]) + " " + (countlyGlobal.apps[app].name || ""); + name = (this.map[this.data.metrics[k]] || this.data.metrics[k]) + " " + (this.__allApps[app] && this.__allApps[app].name || "Unknown"); } else { - name = (countlyGlobal.apps[app].name || ""); + name = (this.__allApps[app] && this.__allApps[app].name || "Unknown"); } } else { diff --git a/plugins/dashboards/api/api.js b/plugins/dashboards/api/api.js index db01a7c7093..d91c0dbf4b4 100644 --- a/plugins/dashboards/api/api.js +++ b/plugins/dashboards/api/api.js @@ -1232,7 +1232,7 @@ plugins.setConfigs("dashboards", { allApps.push(apps[appId]); } else { - allApps.push({_id: apps[appId]._id, name: apps[appId].name, image: apps[appId].image}); + allApps.push({_id: apps[appId]._id, name: apps[appId].name, image: apps[appId].image, type: apps[appId].type}); } } diff --git a/plugins/dashboards/frontend/public/javascripts/countly.models.js b/plugins/dashboards/frontend/public/javascripts/countly.models.js index e58302be541..369b0fc76d9 100644 --- a/plugins/dashboards/frontend/public/javascripts/countly.models.js +++ b/plugins/dashboards/frontend/public/javascripts/countly.models.js @@ -509,7 +509,8 @@ acc[app._id] = { _id: app._id, name: app.name, - image: app.image + image: app.image, + type: app.type }; return acc; }, {}); @@ -520,7 +521,8 @@ globalApps[key] = { _id: key, name: countlyGlobal.apps[key].name, - image: countlyGlobal.apps[key].image + image: countlyGlobal.apps[key].image, + type: countlyGlobal.apps[key].type }; } diff --git a/plugins/dashboards/frontend/public/javascripts/countly.widgets.events.js b/plugins/dashboards/frontend/public/javascripts/countly.widgets.events.js index 0c93dff3e35..c51fe38744e 100644 --- a/plugins/dashboards/frontend/public/javascripts/countly.widgets.events.js +++ b/plugins/dashboards/frontend/public/javascripts/countly.widgets.events.js @@ -96,10 +96,10 @@ for (var k = 0; k < this.data.metrics.length; k++) { if (multiApps) { if (this.data.metrics.length > 1) { - name = eventName + " " + (this.map[this.data.metrics[k]] || this.data.metrics[k]) + " " + (countlyGlobal.apps[app].name || ""); + name = eventName + " " + (this.map[this.data.metrics[k]] || this.data.metrics[k]) + " " + (this.__allApps[app] && this.__allApps[app].name || ""); } else { - name = (eventName + " " + countlyGlobal.apps[app].name || ""); + name = (eventName + " " + this.__allApps[app] && this.__allApps[app].name || ""); } } else { From d3217d7223f74a0cc5fa17168a799408869cdc29 Mon Sep 17 00:00:00 2001 From: itsiprikshit Date: Sun, 6 Mar 2022 12:21:59 +0000 Subject: [PATCH 6/6] isallowed fix and linting fixes --- .../core/device-and-type/javascripts/countly.views.js | 4 ++++ .../core/geo-countries/javascripts/countly.widgets.geo.js | 4 ++++ .../user-analytics-overview/javascripts/countly.views.js | 6 +++++- .../frontend/public/javascripts/countly.widgets.crash.js | 6 +++++- .../public/javascripts/countly.widgets.analytics.js | 4 ++++ .../frontend/public/javascripts/countly.widgets.events.js | 6 +++++- .../public/templates/widgets/analytics/widget.html | 4 ++-- plugins/push/frontend/public/javascripts/countly.views.js | 8 ++++++-- .../sources/frontend/public/javascripts/countly.views.js | 4 ++++ .../views/frontend/public/javascripts/countly.views.js | 4 ++++ 10 files changed, 43 insertions(+), 7 deletions(-) diff --git a/frontend/express/public/core/device-and-type/javascripts/countly.views.js b/frontend/express/public/core/device-and-type/javascripts/countly.views.js index 7d1c5a37d6f..a32711232ec 100644 --- a/frontend/express/public/core/device-and-type/javascripts/countly.views.js +++ b/frontend/express/public/core/device-and-type/javascripts/countly.views.js @@ -365,6 +365,10 @@ var GridComponent = countlyVue.views.create({ default: function() { return {}; } + }, + isAllowed: { + type: Boolean, + default: true } }, mounted: function() { diff --git a/frontend/express/public/core/geo-countries/javascripts/countly.widgets.geo.js b/frontend/express/public/core/geo-countries/javascripts/countly.widgets.geo.js index 4c838d924cb..49c2761a5eb 100644 --- a/frontend/express/public/core/geo-countries/javascripts/countly.widgets.geo.js +++ b/frontend/express/public/core/geo-countries/javascripts/countly.widgets.geo.js @@ -10,6 +10,10 @@ default: function() { return {}; } + }, + isAllowed: { + type: Boolean, + default: true } }, data: function() { diff --git a/frontend/express/public/core/user-analytics-overview/javascripts/countly.views.js b/frontend/express/public/core/user-analytics-overview/javascripts/countly.views.js index 37ba88d8f8a..31075b3f7d5 100644 --- a/frontend/express/public/core/user-analytics-overview/javascripts/countly.views.js +++ b/frontend/express/public/core/user-analytics-overview/javascripts/countly.views.js @@ -1,4 +1,4 @@ -/* global countlyVue,CV,countlyCommon, $, countlySession,countlyTotalUsers,app, jQuery, countlyGlobal*/ +/* global countlyVue,CV,countlyCommon, $, countlySession,countlyTotalUsers,app, jQuery*/ var UserAnalyticsOverview = countlyVue.views.create({ template: CV.T("/core/user-analytics-overview/templates/overview.html"), data: function() { @@ -187,6 +187,10 @@ var GridComponent = countlyVue.views.create({ default: function() { return {}; } + }, + isAllowed: { + type: Boolean, + default: true } }, mounted: function() { diff --git a/plugins/crashes/frontend/public/javascripts/countly.widgets.crash.js b/plugins/crashes/frontend/public/javascripts/countly.widgets.crash.js index 2fe95a7275d..cdff8ed73ab 100644 --- a/plugins/crashes/frontend/public/javascripts/countly.widgets.crash.js +++ b/plugins/crashes/frontend/public/javascripts/countly.widgets.crash.js @@ -1,4 +1,4 @@ -/*global countlyVue, CV, countlyGlobal, countlyCommon */ +/*global countlyVue, CV, countlyCommon */ (function() { var WidgetComponent = countlyVue.views.create({ @@ -10,6 +10,10 @@ default: function() { return {}; } + }, + isAllowed: { + type: Boolean, + default: true } }, data: function() { diff --git a/plugins/dashboards/frontend/public/javascripts/countly.widgets.analytics.js b/plugins/dashboards/frontend/public/javascripts/countly.widgets.analytics.js index 376b6251130..9f9de684f88 100644 --- a/plugins/dashboards/frontend/public/javascripts/countly.widgets.analytics.js +++ b/plugins/dashboards/frontend/public/javascripts/countly.widgets.analytics.js @@ -10,6 +10,10 @@ default: function() { return {}; } + }, + isAllowed: { + type: Boolean, + default: true } }, data: function() { diff --git a/plugins/dashboards/frontend/public/javascripts/countly.widgets.events.js b/plugins/dashboards/frontend/public/javascripts/countly.widgets.events.js index c51fe38744e..585fc76295d 100644 --- a/plugins/dashboards/frontend/public/javascripts/countly.widgets.events.js +++ b/plugins/dashboards/frontend/public/javascripts/countly.widgets.events.js @@ -1,4 +1,4 @@ -/*global countlyVue,countlyGlobal, CV, countlyCommon */ +/*global countlyVue, CV, countlyCommon */ (function() { var WidgetComponent = countlyVue.views.create({ @@ -10,6 +10,10 @@ default: function() { return {}; } + }, + isAllowed: { + type: Boolean, + default: true } }, data: function() { diff --git a/plugins/dashboards/frontend/public/templates/widgets/analytics/widget.html b/plugins/dashboards/frontend/public/templates/widgets/analytics/widget.html index 9a77a1693bc..542eb5a6428 100644 --- a/plugins/dashboards/frontend/public/templates/widgets/analytics/widget.html +++ b/plugins/dashboards/frontend/public/templates/widgets/analytics/widget.html @@ -7,7 +7,7 @@

{{title}}

-
+
@@ -15,7 +15,7 @@

{{title}}

{{i18n('common.edit')}} {{i18n('common.delete')}} - Zoom + {{i18n('common.zoom-in')}}
diff --git a/plugins/push/frontend/public/javascripts/countly.views.js b/plugins/push/frontend/public/javascripts/countly.views.js index 62109266739..4f7444498b1 100644 --- a/plugins/push/frontend/public/javascripts/countly.views.js +++ b/plugins/push/frontend/public/javascripts/countly.views.js @@ -2387,6 +2387,10 @@ default: function() { return {}; } + }, + isAllowed: { + type: Boolean, + default: true } }, data: function() { @@ -2422,10 +2426,10 @@ for (var k = 0; k < this.data.metrics.length; k++) { if (multiApps) { if (this.data.metrics.length > 1) { - name = (this.map[this.data.metrics[k]] || this.data.metrics[k]) + " " + (countlyGlobal.apps[app].name || ""); + name = (this.map[this.data.metrics[k]] || this.data.metrics[k]) + " " + (this.__allApps[app] && this.__allApps[app].name || "Unknown"); } else { - name = (countlyGlobal.apps[app].name || ""); + name = (this.__allApps[app] && this.__allApps[app].name || "Unknown"); } } else { diff --git a/plugins/sources/frontend/public/javascripts/countly.views.js b/plugins/sources/frontend/public/javascripts/countly.views.js index 2499f70c1b2..aee743c9936 100755 --- a/plugins/sources/frontend/public/javascripts/countly.views.js +++ b/plugins/sources/frontend/public/javascripts/countly.views.js @@ -301,6 +301,10 @@ default: function() { return {}; } + }, + isAllowed: { + type: Boolean, + default: true } }, data: function() { diff --git a/plugins/views/frontend/public/javascripts/countly.views.js b/plugins/views/frontend/public/javascripts/countly.views.js index 9d96cc6142c..e979ebe5481 100644 --- a/plugins/views/frontend/public/javascripts/countly.views.js +++ b/plugins/views/frontend/public/javascripts/countly.views.js @@ -795,6 +795,10 @@ default: function() { return {}; } + }, + isAllowed: { + type: Boolean, + default: true } }, mounted: function() {