Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dashboards apps in vuex #2875

Merged
merged 6 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,17 @@ 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.zoom],
props: {
data: {
type: Object,
default: function() {
return {};
}
},
isAllowed: {
type: Boolean,
default: true
}
},
mounted: function() {
Expand Down Expand Up @@ -477,7 +481,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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
(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.zoom],
props: {
data: {
type: Object,
default: function() {
return {};
}
},
isAllowed: {
type: Boolean,
default: true
}
},
data: function() {
Expand Down Expand Up @@ -100,7 +104,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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -180,13 +180,17 @@ 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,
default: function() {
return {};
}
},
isAllowed: {
type: Boolean,
default: true
}
},
mounted: function() {
Expand Down Expand Up @@ -238,7 +242,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]});
}
Expand Down Expand Up @@ -369,7 +373,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) {
Expand Down
47 changes: 37 additions & 10 deletions frontend/express/public/javascripts/countly/vue/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {};
Expand Down Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
/*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,
default: function() {
return {};
}
},
isAllowed: {
type: Boolean,
default: true
}
},
data: function() {
Expand Down Expand Up @@ -47,10 +51,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 {
Expand Down Expand Up @@ -164,7 +168,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) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/dashboards/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, type: apps[appId].type});
}
}

Expand Down
38 changes: 9 additions & 29 deletions plugins/dashboards/frontend/public/javascripts/countly.helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) + '")'
};
}
}
Expand All @@ -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,
Expand All @@ -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] || []
});
}
Expand Down
Loading