diff --git a/webroot/common/api/infra.common.api.js b/webroot/common/api/infra.common.api.js
index 6051ba7e5..6d3494638 100644
--- a/webroot/common/api/infra.common.api.js
+++ b/webroot/common/api/infra.common.api.js
@@ -1061,13 +1061,27 @@ function sendServerRetrieveError (res)
commonUtils.handleJSONResponse(error, res, null);
}
function getUVEKeys (req, res, appData) {
- var url = '/analytics/uves';
+ var url = '/analytics/uve-types';
+ var isProject = req.query['isProject'],
+ globalUVEKeys = [],
+ projectUVEKeys = [],
+ uveKeys = [];
opApiServer.apiGet(url, appData,
function(err, data) {
if (err || (null == data)) {
commonUtils.handleJSONResponse(err, res, null);
} else {
- commonUtils.handleJSONResponse(null, res, data);
+ for(var key in data) {
+ if (data[key] != null) {
+ var uveObj = data[key];
+ globalUVEKeys.push(key);
+ if (uveObj['global_system_object'] == false) {
+ projectUVEKeys.push(key);
+ }
+ }
+ }
+ uveKeys = (isProject === 'true') ? projectUVEKeys : globalUVEKeys;
+ commonUtils.handleJSONResponse(null, res, uveKeys);
}
});
}
diff --git a/webroot/common/ui/js/controller.labels.js b/webroot/common/ui/js/controller.labels.js
index c5a61b5f4..b1dfeff93 100644
--- a/webroot/common/ui/js/controller.labels.js
+++ b/webroot/common/ui/js/controller.labels.js
@@ -1001,9 +1001,9 @@ define([
this.TITLE_CREATE_ALARM_RULE = 'Create Alarm Rule';
this.TXT_CONFIG_ALARM_RULE = 'rule';
this.CONFIG_ALARM_TEXT_MAP = {
- 2: 'Critical',
- 3: 'Major',
- 4: 'Minor'
+ 0: 'Critical',
+ 1: 'Major',
+ 2: 'Minor'
};
//Config DB Labels - Start
diff --git a/webroot/config/alarm/common/ui/js/ConfigAlarmFormatters.js b/webroot/config/alarm/common/ui/js/ConfigAlarmFormatters.js
index 98f47adfd..059da64af 100644
--- a/webroot/config/alarm/common/ui/js/ConfigAlarmFormatters.js
+++ b/webroot/config/alarm/common/ui/js/ConfigAlarmFormatters.js
@@ -21,7 +21,7 @@
var template = contrail.getTemplate4Id(ctwc.CONFIG_ALARM_SEVERITY_TEMPLATE);
if (ctwl.CONFIG_ALARM_TEXT_MAP[getValueByJsonPath(dc, 'alarm_severity', null)] != null) {
var color = 'red';
- if (dc['alarm_severity'] == '4') {
+ if (dc['alarm_severity'] == '2') {
color = 'orange';
}
return template({
@@ -71,8 +71,8 @@
var returnString = "";
returnString += alarmObj['operand1'] + " ";
returnString += ''+ alarmObj['operation'] +'';
- returnString += " "+alarmObj['operand2'];
- if (ifNull(alarmObj['vars'], []).length) {
+ returnString += " "+getValueByJsonPath(alarmObj,'operand2;uve_attribute',getValueByJsonPath(alarmObj,'operand2;json_value'));
+ if (ifNull(alarmObj['variables'], []).length) {
returnString += ", variables " +alarmObj['variables'];
}
return returnString;
diff --git a/webroot/config/alarm/common/ui/js/models/AlarmModel.js b/webroot/config/alarm/common/ui/js/models/AlarmModel.js
index f22e19632..14f088d4b 100644
--- a/webroot/config/alarm/common/ui/js/models/AlarmModel.js
+++ b/webroot/config/alarm/common/ui/js/models/AlarmModel.js
@@ -14,7 +14,7 @@ define([
defaultConfig: {
name: null,
display_name: null,
- alarm_severity: 4, //Default minor severity
+ alarm_severity: 2, //Default minor severity
uve_keys: {
uve_key: []
},
@@ -81,10 +81,23 @@ define([
} else if (vars == "") {
vars = [];
}
+ var operation = andRuleObj.operation()();
+ operationArr = operation.split(cowc.DROPDOWN_VALUE_SEPARATOR),
+ operand2 = andRuleObj.operand2()(),
+ operand2Obj = {};
+ if (operationArr[1] == 'uve_attribute') {
+ operand2Obj = {
+ uve_attribute: operand2
+ }
+ } else if (operationArr[1] == 'json_value') {
+ operand2Obj = {
+ json_value: operand2
+ }
+ }
andRulePostObjArr.push({
operand1: andRuleObj.operand1()(),
- operand2: andRuleObj.operand2()(),
- operation: andRuleObj.operation()(),
+ operand2: operand2Obj,
+ operation: operationArr[0],
variables: vars
});
}
diff --git a/webroot/config/alarm/common/ui/js/models/AlarmRuleModel.js b/webroot/config/alarm/common/ui/js/models/AlarmRuleModel.js
index 899175272..d34a8f8f6 100644
--- a/webroot/config/alarm/common/ui/js/models/AlarmRuleModel.js
+++ b/webroot/config/alarm/common/ui/js/models/AlarmRuleModel.js
@@ -11,7 +11,7 @@ define([
var AlarmRuleModel = ContrailModel.extend({
defaultConfig: {
- operation: '==',
+ operation: '==' + cowc.DROPDOWN_VALUE_SEPARATOR + 'uve_attribute',
variables: [],
operand1: null,
operand2: null,
diff --git a/webroot/config/alarm/common/ui/js/models/AlarmRuleOrModel.js b/webroot/config/alarm/common/ui/js/models/AlarmRuleOrModel.js
index 0dfa39104..5de6f2d99 100644
--- a/webroot/config/alarm/common/ui/js/models/AlarmRuleOrModel.js
+++ b/webroot/config/alarm/common/ui/js/models/AlarmRuleOrModel.js
@@ -45,10 +45,16 @@ define([
if (andRuleListLen > 0) {
for (var i = 0 ; i < andRuleListLen; i ++) {
var ruleObj = andRuleList[i];
+ var operand2Key = 'uve_attribute';
+ if (getValueByJsonPath(ruleObj, 'operand2;json_value') != null) {
+ operand2Key = 'json_value';
+ }
+ var operand2 = getValueByJsonPath(ruleObj, 'operand2;'+operand2Key);
+ var operation = ruleObj['operation'] + cowc.DROPDOWN_VALUE_SEPARATOR + operand2Key,
andRuleObj = {
operand1: ruleObj['operand1'],
- operand2: ruleObj['operand2'],
- operation: ruleObj['operation'],
+ operand2: operand2,
+ operation: operation,
variables: ruleObj['variables'],
};
andRuleModel = new AlarmRuleModel(self, andRuleObj);
@@ -98,18 +104,25 @@ define([
operand2 = andRuleObj.operand2(),
operation = andRuleObj.operation(),
vars = andRuleObj.variables(),
- andRuleStr = '';
+ andRuleStr = '', operationStr = '';
operand1 = contrail.checkIfFunction(operand1) ? operand1() : operand1;
operand2 = contrail.checkIfFunction(operand2) ? operand2() : operand2;
operation = contrail.checkIfFunction(operation) ? operation() : operation;
vars = contrail.checkIfFunction(vars) ? vars() : vars;
+ operationArr = operation.split(cowc.DROPDOWN_VALUE_SEPARATOR);
+ if (operationArr[1] == 'uve_attribute') {
+ operationStr += 'UVE Key';
+ } else if (operationArr[1] == 'json_value') {
+ operationStr += 'Value';
+ }
+ operationStr += " "+operationArr[0];
if (operand1 != null && operand2 != null && operation != null ) {
- andRuleStr += operand1 + ' ' + operation + ' ' + operand2;
+ andRuleStr += operand1 + ' ' + operationStr + ' ' + operand2;
if (vars != null){
if (typeof vars == 'string') {
- andRuleStr += ', vars ' + vars;
+ andRuleStr += ', variables ' + vars;
} else if (typeof vars == 'object' && vars.length > 0){
- andRuleStr += ', vars ' + vars.join(',');
+ andRuleStr += ', variables ' + vars.join(',');
}
}
andRuleArray.push(andRuleStr);
diff --git a/webroot/config/alarm/common/ui/js/views/ConfigAlarmEditView.js b/webroot/config/alarm/common/ui/js/views/ConfigAlarmEditView.js
index 2d715abc6..a804624a2 100644
--- a/webroot/config/alarm/common/ui/js/views/ConfigAlarmEditView.js
+++ b/webroot/config/alarm/common/ui/js/views/ConfigAlarmEditView.js
@@ -63,13 +63,10 @@ define([
'body': editLayout,
'footer': footer
});
- var disableElement = false
- if (options['mode'] == "edit") {
- disableElement = true;
- }
+
self.renderView4Config(
$("#" + modalId).find("#" + modalId + "-form"), self.model,
- getConfigureViewConfig(disableElement), 'configAlarmValidations', null, null, function () {
+ getConfigureViewConfig(options), 'configAlarmValidations', null, null, function () {
self.model.showErrorAttr(prefixId + cowc.FORM_SUFFIX_ID, false);
Knockback.applyBindings(self.model, document.getElementById(modalId));
var orRuleCollection = self.model.model().attributes.orRules,
@@ -137,7 +134,9 @@ define([
}
});
- var getConfigureViewConfig = function (isDisable) {
+ var getConfigureViewConfig = function(options) {
+ var isDisable = options['mode'] == ctwl.EDIT_ACTION ? true : false;
+ var isProject = options.isProject;
return {
elementId: cowu.formatElementId(
[prefixId, ctwl.TITLE_EDIT_ALARM_RULE]),
@@ -176,26 +175,21 @@ define([
data: function () {
var template = contrail.getTemplate4Id(ctwc.CONFIG_ALARM_SEVERITY_TEMPLATE);
return [
- {value: '2', text: template({
+ {value: '0', text: template({
showText : true,
color : 'red',
- text : ctwl.CONFIG_ALARM_TEXT_MAP[2],
+ text : ctwl.CONFIG_ALARM_TEXT_MAP[0],
})},
- {value: '3', text: template({
+ {value: '1', text: template({
showText : true,
color : 'red',
- text : ctwl.CONFIG_ALARM_TEXT_MAP[3],
+ text : ctwl.CONFIG_ALARM_TEXT_MAP[1],
})},
- {value: '4', text: template({
+ {value: '2', text: template({
showText : true,
color : 'orange',
- text : ctwl.CONFIG_ALARM_TEXT_MAP[4],
+ text : ctwl.CONFIG_ALARM_TEXT_MAP[2],
})},
- {value: '0', text: '0'},
- {value: '1', text: '1'},
- {value: '5', text: '5'},
- {value: '6', text: '6'},
- {value: '7', text: '7'},
];
}()
}
@@ -218,15 +212,14 @@ define([
tags: true,
dataSource : {
type: 'remote',
- url: '/api/admin/monitor/get-uve-keys',
+ url: '/api/admin/monitor/get-uve-keys?isProject='+isProject,
parse: function(uveList) {
var uveList = ifNull(uveList, []),
uveListLen = uveList.length,
multiSelectData = [];
for (var i = 0; i < uveListLen; i++) {
- var uveObj = uveList[i];
- if (uveObj != null && uveObj['name']!= null) {
- var uveKey = uveObj['name'].slice(0, -1);
+ var uveKey = uveList[i];
+ if (uveKey != null) {
multiSelectData.push({
text: uveKey,
value: uveKey
@@ -334,21 +327,92 @@ define([
templateId: cowc.TMPL_EDITABLE_GRID_DROPDOWN_VIEW,
path: "operation",
dataBindValue: "operation()",
- width: 80,
+ width: 160,
elementConfig: {
dataTextField: 'text',
- dataValueField: 'value',
+ dataValueField: 'id',
+ showParentInSelection: true,
dataSource: {
type: 'local',
data: [
- {value: '==', text: '=='},
- {value: '!=', text: '!='},
- {value: '>=', text: '>='},
- {value: '<=', text: '<='},
- {value: 'in', text: 'in'},
- {value: 'not in', text: 'not in'},
- {value: 'size ==', text: 'size=='},
- {value: 'size!=', text: 'size!='},
+ {
+ id:"uve_attribute",
+ text:"UVE Key",
+ children: [
+ {
+ id: '==' + cowc.DROPDOWN_VALUE_SEPARATOR + 'uve_attribute',
+ text: '==',
+ parent: 'uve_attribute',
+ },{
+ id: '!=' + cowc.DROPDOWN_VALUE_SEPARATOR + 'uve_attribute',
+ text: '!=',
+ parent: 'uve_attribute',
+ },{
+ id: '>=' + cowc.DROPDOWN_VALUE_SEPARATOR + 'uve_attribute',
+ text: '>=',
+ parent: 'uve_attribute',
+ },{
+ id: '<=' + cowc.DROPDOWN_VALUE_SEPARATOR + 'uve_attribute',
+ text: '<=',
+ parent: 'uve_attribute',
+ },{
+ id: 'in' + cowc.DROPDOWN_VALUE_SEPARATOR + 'uve_attribute',
+ text: 'in',
+ parent: 'uve_attribute',
+ },{
+ id: 'not in' + cowc.DROPDOWN_VALUE_SEPARATOR + 'uve_attribute',
+ text: 'not in',
+ parent: 'uve_attribute',
+ },{
+ id: 'size ==' + cowc.DROPDOWN_VALUE_SEPARATOR + 'uve_attribute',
+ text: 'size==',
+ parent: 'uve_attribute',
+ },{
+ id: 'size!=' + cowc.DROPDOWN_VALUE_SEPARATOR + 'uve_attribute',
+ text: 'size!=',
+ parent: 'uve_attribute',
+ }
+ ]
+ },
+ {
+ id:"json_value",
+ text:"Value",
+ children: [
+ {
+ id: '==' + cowc.DROPDOWN_VALUE_SEPARATOR + 'json_value',
+ text: '==',
+ parent: 'json_value',
+ },{
+ id: '!=' + cowc.DROPDOWN_VALUE_SEPARATOR + 'json_value',
+ text: '!=',
+ parent: 'json_value',
+ },{
+ id: '>=' + cowc.DROPDOWN_VALUE_SEPARATOR + 'json_value',
+ text: '>=',
+ parent: 'json_value',
+ },{
+ id: '<=' + cowc.DROPDOWN_VALUE_SEPARATOR + 'json_value',
+ text: '<=',
+ parent: 'json_value',
+ },{
+ id: 'in' + cowc.DROPDOWN_VALUE_SEPARATOR + 'json_value',
+ text: 'in',
+ parent: 'json_value',
+ },{
+ id: 'not in' + cowc.DROPDOWN_VALUE_SEPARATOR + 'json_value',
+ text: 'not in',
+ parent: 'json_value',
+ },{
+ id: 'size ==' + cowc.DROPDOWN_VALUE_SEPARATOR + 'json_value',
+ text: 'size==',
+ parent: 'json_value',
+ },{
+ id: 'size!=' + cowc.DROPDOWN_VALUE_SEPARATOR + 'json_value',
+ text: 'size!=',
+ parent: 'json_value',
+ }
+ ]
+ }
]
}
}