Skip to content

Commit 85eae47

Browse files
authored
Merge pull request #6979 from Countly/alert-validation-24
Alert interval validation
2 parents 118caa0 + d17616c commit 85eae47

File tree

4 files changed

+195
-141
lines changed

4 files changed

+195
-141
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
## Version 24.05.46
2+
Fixes:
3+
- [alerts] Add alert interval validation in the frontend
4+
25
Enterprise Fixes:
36
- [concurrent_users] Fix email check for alert
47

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,29 @@
77
countlyCommon,
88
app,
99
countlyAuth,
10+
countlyPlugins,
1011
CV,
1112
groupsModel,
1213
_,
14+
VeeValidate,
1315
*/
1416
(function() {
1517
var ALERTS_FEATURE_NAME = "alerts";
1618

19+
VeeValidate.extend('alert_interval', function(inpValue, args) {
20+
var min = parseInt(args[0] || 0, 10);
21+
var max = parseInt(args[1] || 60, 10);
22+
var valid = parseInt(inpValue, 10) >= min && inpValue <= max;
23+
24+
if (valid) {
25+
return {
26+
valid: valid,
27+
};
28+
}
29+
30+
return 'Alert interval has to be between ' + min + ' and ' + max;
31+
});
32+
1733
var AlertDrawer = countlyVue.views.BaseView.extend({
1834
template: "#alert-drawer",
1935
mixins: [
@@ -411,6 +427,27 @@
411427
return;
412428
}
413429
},
430+
filteredEmailOptions: function() {
431+
if (!countlyGlobal.plugins.includes("groups")) {
432+
return this.emailOptions.filter(
433+
(option) => option.value !== "toGroup"
434+
);
435+
}
436+
return this.emailOptions;
437+
},
438+
alertIntervalValidationRules: function() {
439+
var rule = 'required';
440+
441+
if (this.$refs.drawerData.editedObject.alertDataType === 'onlineUsers') {
442+
var concurrentUserConfig = countlyPlugins.getConfigsData().concurrent_users || {};
443+
var concurrentAlertIntervalMin = concurrentUserConfig.alert_interval || 3;
444+
var concurrentAlertIntervalMax = Math.min(concurrentAlertIntervalMin + 60, 90);
445+
446+
rule += '|alert_interval:' + concurrentAlertIntervalMin + ',' + concurrentAlertIntervalMax;
447+
}
448+
449+
return rule;
450+
},
414451
},
415452
props: {
416453
placeholder: { type: String, default: "Select" },

plugins/alerts/frontend/public/stylesheets/vue-main.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@
143143
.alert-drawer-trigger-input {
144144
width: 48px;
145145
}
146+
147+
.is-error {
148+
.alert-drawer-trigger-input {
149+
background-color: #FBECE5 !important;
150+
}
151+
}
146152

147153
.no-spinner::-webkit-inner-spin-button,
148154
.no-spinner::-webkit-outer-spin-button {
@@ -335,4 +341,4 @@
335341
border-radius: 4px;
336342
background-position: center;
337343
display: inline-block;
338-
}
344+
}

0 commit comments

Comments
 (0)