Skip to content

Commit fd86df1

Browse files
committed
Merge branch 'can/feature/new-ui' of https://github.com/Countly/countly-server into can/feature/new-ui
2 parents 3cb2009 + f9163a6 commit fd86df1

File tree

18 files changed

+147
-31
lines changed

18 files changed

+147
-31
lines changed

frontend/express/public/javascripts/countly/countly.auth.js

+17
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,23 @@
168168
return validateWrite('d', feature, member, app_id);
169169
};
170170

171+
/**
172+
* validate all types of requests for specific feature on specific app
173+
* @param {string} accessType - write process type [c, r, u, d]
174+
* @param {string} feature - feature name that required access right
175+
* @param {object} member - countly member object
176+
* @param {string} app_id - countly application id
177+
* @return {boolean} result of permission check
178+
*/
179+
countlyAuth.validate = function(accessType, feature, member, app_id) {
180+
if (accessType === "r") {
181+
return countlyAuth.validateRead(feature, member, app_id);
182+
}
183+
else {
184+
return validateWrite(accessType, feature, member, app_id);
185+
}
186+
};
187+
171188
/**
172189
* Validate is this user global admin or not
173190
* @returns {boolean} is this user global admin or not?

frontend/express/public/javascripts/countly/vue/components/helpers.js

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global Vue, CV, app, countlyEvent, countlyGlobal*/
1+
/* global Vue, CV, app, countlyEvent, countlyGlobal, countlyAuth*/
22

33
(function(countlyVue) {
44

@@ -447,6 +447,13 @@
447447
type: Number,
448448
default: 0,
449449
required: false
450+
},
451+
auth: {
452+
type: Object,
453+
default: function() {
454+
return {};
455+
},
456+
required: false
450457
}
451458
},
452459
computed: {
@@ -461,6 +468,24 @@
461468
},
462469
apps: function() {
463470
var apps = countlyGlobal.apps || {};
471+
472+
if (this.auth && this.auth.feature && this.auth.permission) {
473+
var expectedPermission = this.auth.permission,
474+
targetFeature = this.auth.feature;
475+
476+
return Object.keys(apps).reduce(function(acc, key) {
477+
var currentApp = apps[key];
478+
479+
if (countlyAuth.validate(expectedPermission, targetFeature, null, currentApp._id)) {
480+
acc.push({
481+
label: currentApp.name,
482+
value: currentApp._id
483+
});
484+
}
485+
return acc;
486+
}, []);
487+
}
488+
464489
return Object.keys(apps).map(function(key) {
465490
return {
466491
label: apps[key].name,

frontend/express/public/javascripts/utils/vue/element-ui.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/express/public/stylesheets/vue/element-ui.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/alerts/frontend/public/javascripts/countly.models.js

+5
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@
158158
context.dispatch("countlyAlerts/table/fetchAll", null, {root: true});
159159
},
160160
saveAlert: function(context, alertConfig) {
161+
delete alertConfig._canUpdate;
162+
delete alertConfig._canDelete;
161163
return CV.$.ajax({
162164
type: "GET",
163165
url: countlyCommon.API_PARTS.data.w + "/alert/save",
@@ -205,6 +207,9 @@
205207
});
206208
},
207209
saveOnlineUsersAlert: function(context, alertConfig) {
210+
delete alertConfig._canUpdate;
211+
delete alertConfig._canDelete;
212+
208213
return CV.$.ajax({
209214
type: "GET",
210215
url: countlyCommon.API_PARTS.data.w + "/concurrent_alert/save",

plugins/hooks/frontend/public/javascripts/countly.models.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
CV,
44
countlyVue,
55
countlyGlobal,
6+
countlyAuth,
67
_,
78
moment,
89
*/
910

1011
(function(hooksPlugin, jQuery) {
12+
var FEATURE_NAME = "hooks";
1113
var countlyCommon = window.countlyCommon;
1214

1315

@@ -197,8 +199,11 @@
197199
dataType: "json",
198200
success: function(data) {
199201
if (data.hooksList && data.hooksList.length === 1) {
200-
data.hooksList[0].triggerEffectDom = hooksPlugin.generateTriggerActionsTreeDom(data.hooksList[0]);
201-
context.commit("setDetail", data.hooksList[0]);
202+
var record = data.hooksList[0];
203+
record.triggerEffectDom = hooksPlugin.generateTriggerActionsTreeDom(record);
204+
record._canUpdate = countlyAuth.validateUpdate(FEATURE_NAME, countlyGlobal.member, record.apps[0]),
205+
record._canDelete = countlyAuth.validateDelete(FEATURE_NAME, countlyGlobal.member, record.apps[0]),
206+
context.commit("setDetail", record);
202207
context.commit("setDetailLogsInitialized", true);
203208
}
204209
},
@@ -208,6 +213,8 @@
208213
context.dispatch("countlyHooks/table/fetchAll", null, {root: true});
209214
},
210215
saveHook: function(context, record) {
216+
delete record._canUpdate;
217+
delete record._canDelete;
211218
return CV.$.ajax({
212219
type: "POST",
213220
url: countlyCommon.API_PARTS.data.w + "/hook/save?" + "app_id=" + record.apps[0],
@@ -335,6 +342,8 @@
335342
created_at: hookList[i].created_at || 0,
336343
created_at_string: moment(hookList[i].created_at).fromNow(),
337344
triggerEffectColumn: triggerEffectDom || "",
345+
_canUpdate: countlyAuth.validateUpdate(FEATURE_NAME, countlyGlobal.member, hookList[i].apps[0]),
346+
_canDelete: countlyAuth.validateDelete(FEATURE_NAME, countlyGlobal.member, hookList[i].apps[0]),
338347
});
339348
}
340349
context.commit("setInitialized", true);

plugins/hooks/frontend/public/javascripts/countly.views.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@
6262
value: "lastTriggerTimestampString",
6363
label: CV.i18n('hooks.trigger-last-time'),
6464
default: true
65-
}]
65+
}],
66+
tablePersistKey: "hooks_table_" + countlyCommon.ACTIVE_APP_ID,
67+
6668
};
6769
},
6870
methods: {

plugins/hooks/frontend/public/templates/vue-hooks-detail.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ <h3>{{hookDetail.name}}</h3>
1313
</template>
1414
<template v-slot:header-right>
1515
<div>
16-
<div class="is-option-button" v-if="canUserUpdate || canUserDelete">
16+
<div class="is-option-button" v-if="hookDetail._canUpdate || hookDetail._canDelete">
1717
<cly-more-options size="small" @command="handleHookEditCommand($event, hookDetail)">
18-
<el-dropdown-item icon="el-icon-document-copy" v-if="canUserUpdate" command="edit-comment">
18+
<el-dropdown-item icon="el-icon-document-copy" v-if="hookDetail._canUpdate" command="edit-comment">
1919
Edit
2020
</el-dropdown-item>
21-
<el-dropdown-item icon="el-icon-delete" v-if="canUserDelete" command="delete-comment">
21+
<el-dropdown-item icon="el-icon-delete" v-if="hookDetail._canDelete" command="delete-comment">
2222
Delete
2323
</el-dropdown-item>
2424
</cly-more-options>

plugins/hooks/frontend/public/templates/vue-table.html

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<cly-section>
22
<cly-datatable-n
33
:force-loading="!initialized"
4+
:persist-key="tablePersistKey"
45
class="cly-vue-hook-table is-clickable"
56
:tracked-fields="localTableTrackedFields"
67
:rows="tableRows" :resizable="false"
@@ -28,7 +29,7 @@
2829
<template v-slot="rowScope">
2930
<el-switch :value="rowScope.row.enabled"
3031
class="bu-ml-4 bu-mr-2"
31-
:disabled="!canUserUpdate"
32+
:disabled="!rowScope.row._canUpdate"
3233
@input="scope.patch(rowScope.row, {enabled: !rowScope.row.enabled})">
3334
</el-switch>
3435
</template>
@@ -79,13 +80,13 @@
7980
</div>
8081
</template>
8182
</el-table-column>
82-
<el-table-column type="options" v-if="canUserUpdate || canUserDelete" >
83+
<el-table-column type="options">
8384
<template v-slot="rowScope">
84-
<cly-more-options v-if="rowScope.row.hover" size="small" @command="handleHookEditCommand($event,rowScope)">
85-
<el-dropdown-item v-if="canUserUpdate" icon="el-icon-document-copy" command="edit-comment">
85+
<cly-more-options v-if="rowScope.row.hover &&(rowScope.row._canUpdate || rowScope.row._canDelete)" size="small" @command="handleHookEditCommand($event,rowScope)">
86+
<el-dropdown-item v-if="rowScope.row._canUpdate" icon="el-icon-document-copy" command="edit-comment">
8687
{{i18n('hooks.edit')}}
8788
</el-dropdown-item>
88-
<el-dropdown-item v-if="canUserDelete" icon="el-icon-delete" command="delete-comment">
89+
<el-dropdown-item v-if="rowScope.row._canDelete" icon="el-icon-delete" command="delete-comment">
8990
{{i18n('hooks.delete')}}
9091
</el-dropdown-item>
9192
</cly-more-options>

plugins/push/frontend/public/javascripts/countly.models.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@
815815
newElement.setAttribute("data-user-property-label", userProperty.l);
816816
newElement.setAttribute("data-user-property-value", userProperty.k);
817817
newElement.setAttribute("data-user-property-fallback", userProperty.f);
818-
newElement.innerText = userProperty.k + "|" + userProperty.f;
818+
newElement.innerText = userProperty.l + "|" + userProperty.f;
819819
return newElement.outerHTML;
820820
},
821821
decodeMessage: function(message) {
@@ -1308,10 +1308,7 @@
13081308
return {
13091309
_id: dto._id || null,
13101310
status: this.mapStatus(dto),
1311-
createdDateTime: {
1312-
date: moment(dto.created).valueOf(),
1313-
time: moment(dto.created).format("H:mm")
1314-
},
1311+
createdAt: dto.info && dto.info.created || null,
13151312
name: dto.info && dto.info.title,
13161313
createdBy: dto.info && dto.info.createdByName || '',
13171314
platforms: this.mapPlatforms(dto.platforms),

plugins/push/frontend/public/templates/push-notification-details.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h2> {{pushNotification.name || '-' }} </h2>
2929
</div>
3030
<div class="bu-level-item cly-vue-push-notification-details-sub-header">
3131
<div class="text-medium color-cool-gray-50"><i class="far fa-clock bu-pr-1"></i></div>
32-
<span class="cly-vue-push-notification-details-sub-header-title"> {{i18n('push-notification-details.created-by',pushNotification.createdDateTime && formatTimeAgoText(pushNotification.createdDateTime.date),pushNotification.createdBy)}}</span>
32+
<span class="cly-vue-push-notification-details-sub-header-title"> {{i18n('push-notification-details.created-by',pushNotification.createdAt && formatTimeAgoText(pushNotification.createdAt),pushNotification.createdBy)}}</span>
3333
</div>
3434
<div class="bu-level-item cly-vue-push-notification-details-sub-header">
3535
<div class="text-medium color-cool-gray-50" style="padding-right: 5.33px;"><i class="ion ion-pricetags"></i></div>

plugins/reports/frontend/public/javascripts/countly.models.js

+17
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/*global
22
countlyCommon,
33
countlyGlobal,
4+
countlyAuth,
45
jQuery,
56
CV,
67
CountlyHelpers,
78
countlyVue,
89
app,
910
*/
1011
(function(countlyReporting, $) {
12+
var FEATURE_NAME = "reports";
1113
//Private Properties
1214
var _data = {};
1315
var _metrics = [
@@ -179,6 +181,8 @@
179181
});
180182
},
181183
saveReport: function(context, args) {
184+
delete args._canUpdate;
185+
delete args._canDelete;
182186
return CV.$.ajax({
183187
type: "GET",
184188
url: countlyCommon.API_PARTS.data.w + "/reports/" + (args._id ? "update" : "create"),
@@ -290,6 +294,17 @@
290294
ret = ret.substring(0, ret.length - 2);
291295

292296
ret += " for " + data[i].appNames.join(", ");
297+
298+
data[i]._canUpdate = true;
299+
data[i]._canDelete = true;
300+
for (var aIdx = 0; aIdx < data[i].apps.length; aIdx++) {
301+
if (!countlyAuth.validateUpdate(FEATURE_NAME, countlyGlobal.member, data[i].apps[aIdx])) {
302+
data[i]._canUpdate = false;
303+
}
304+
if (!countlyAuth.validateDelete(FEATURE_NAME, countlyGlobal.member, data[i].apps[aIdx])) {
305+
data[i]._canDelete = false;
306+
}
307+
}
293308
}
294309
else if (!data[i].pluginEnabled) {
295310
ret = jQuery.i18n.prop("reports.enable-plugin", data[i].report_type);
@@ -308,6 +323,8 @@
308323
}
309324
}
310325
ret = "Dashboard " + (dashboard.name || "");
326+
data[i]._canUpdate = countlyAuth.validateUpdate(FEATURE_NAME, countlyGlobal.member, countlyCommon.ACTIVE_APP_ID);
327+
data[i]._canDelete = countlyAuth.validateDelete(FEATURE_NAME, countlyGlobal.member, countlyCommon.ACTIVE_APP_ID);
311328
}
312329
data[i].dataColumn = ret;
313330

plugins/reports/frontend/public/templates/vue-main.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ <h2> {{i18n('reports.title')}}
3737
<template v-slot="scope">
3838
<el-table-column type="switch" fixed="left" width="88" prop="enabled">
3939
<template v-slot="rowScope">
40-
<el-switch :value="rowScope.row.enabled" class="bu-ml-4 bu-mr-2" :disabled="!canUserUpdate"
40+
<el-switch :value="rowScope.row.enabled" class="bu-ml-4 bu-mr-2" :disabled="!rowScope.row._canUpdate"
4141
@input="scope.patch(rowScope.row, {enabled: !rowScope.row.enabled})">
4242
</el-switch>
4343
</template>
@@ -84,7 +84,7 @@ <h2> {{i18n('reports.title')}}
8484
<el-table-column type="options">
8585
<template v-slot="rowScope">
8686
<cly-more-options v-if="rowScope.row.hover" size="small" @command="handleReportEditCommand($event,rowScope)">
87-
<el-dropdown-item v-if="canUserUpdate" icon="el-icon-document-copy" command="edit-comment">
87+
<el-dropdown-item v-if="rowScope.row._canUpdate" icon="el-icon-document-copy" command="edit-comment">
8888
Edit
8989
</el-dropdown-item>
9090
<el-dropdown-item icon="el-icon-position" command="send-comment">
@@ -93,7 +93,7 @@ <h2> {{i18n('reports.title')}}
9393
<el-dropdown-item icon="el-icon-chat-dot-square" command="preview-comment">
9494
Preview
9595
</el-dropdown-item>
96-
<el-dropdown-item v-if="canUserDelete" icon="el-icon-delete" command="delete-comment">
96+
<el-dropdown-item v-if="rowScope.row._canDelete" icon="el-icon-delete" command="delete-comment">
9797
Delete
9898
</el-dropdown-item>
9999
</cly-more-options>
Loading

plugins/star-rating/frontend/public/javascripts/countly.views.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,11 @@
442442
],
443443
data: function() {
444444
return {
445+
empty: {
446+
title: CV.i18n("ratings.empty.title"),
447+
body: CV.i18n("ratings.empty.body"),
448+
image: "/star-rating/images/star-rating/ratings-empty.svg"
449+
},
445450
widgets: [],
446451
drawerSettings: {
447452
createTitle: CV.i18n('feedback.add-widget'),
@@ -657,19 +662,24 @@
657662
// reset cumulative data
658663
self.cumulativeData = [{
659664
count: 0,
660-
percent: 0
665+
percent: 0,
666+
rating: 0
661667
}, {
662668
count: 0,
663-
percent: 0
669+
percent: 0,
670+
rating: 1
664671
}, {
665672
count: 0,
666-
percent: 0
673+
percent: 0,
674+
rating: 2
667675
}, {
668676
count: 0,
669-
percent: 0
677+
percent: 0,
678+
rating: 3
670679
}, {
671680
count: 0,
672-
percent: 0
681+
percent: 0,
682+
rating: 4
673683
}];
674684

675685
var ratingArray = [];

plugins/star-rating/frontend/public/localization/star-rating.properties

+2
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,5 @@ ratings.tooltip.drawer-visibility = When checked, the Ratings sticker will be hi
170170
ratings.tooltip.widget-detail-ratings = Number of Ratings surveys received.
171171
ratings.tooltip.widget-detail-rate = Rate of ratings calculated by Ratings Count / Times Shown
172172
ratings.tooltip.drawer-logo = Add your own company or app logo to customize your Ratings widget. Please limit logo file with XXX and PNG, JPEG file types.
173+
ratings.empty.title = Create your first Ratings Widget
174+
ratings.empty.body = Create a Ratings Widget to collect, store, search, and track user feedback from web and mobile applications.

0 commit comments

Comments
 (0)