|
@@ -26,12 +26,6 @@ App.alertDefinitionsMapper = App.QuickDataMapper.create({
|
|
metricsSourceModel: App.AlertMetricsSourceDefinition,
|
|
metricsSourceModel: App.AlertMetricsSourceDefinition,
|
|
metricsUriModel: App.AlertMetricsUriDefinition,
|
|
metricsUriModel: App.AlertMetricsUriDefinition,
|
|
|
|
|
|
- portModel: App.PortAlertDefinition,
|
|
|
|
- metricsModel: App.MetricsAlertDefinition,
|
|
|
|
- webModel: App.WebAlertDefinition,
|
|
|
|
- aggregateModel: App.AggregateAlertDefinition,
|
|
|
|
- scriptModel: App.ScriptAlertDefinition,
|
|
|
|
-
|
|
|
|
config: {
|
|
config: {
|
|
id: 'AlertDefinition.id',
|
|
id: 'AlertDefinition.id',
|
|
name: 'AlertDefinition.name',
|
|
name: 'AlertDefinition.name',
|
|
@@ -53,7 +47,7 @@ App.alertDefinitionsMapper = App.QuickDataMapper.create({
|
|
|
|
|
|
portConfig: {
|
|
portConfig: {
|
|
default_port: 'AlertDefinition.source.default_port',
|
|
default_port: 'AlertDefinition.source.default_port',
|
|
- uri: 'AlertDefinition.source.uri'
|
|
|
|
|
|
+ port_uri: 'AlertDefinition.source.uri'
|
|
},
|
|
},
|
|
|
|
|
|
aggregateConfig: {
|
|
aggregateConfig: {
|
|
@@ -76,17 +70,13 @@ App.alertDefinitionsMapper = App.QuickDataMapper.create({
|
|
if (json && json.items) {
|
|
if (json && json.items) {
|
|
|
|
|
|
var self = this,
|
|
var self = this,
|
|
- portAlertDefinitions = [],
|
|
|
|
- metricsAlertDefinitions = [],
|
|
|
|
- webAlertDefinitions = [],
|
|
|
|
- aggregateAlertDefinitions = [],
|
|
|
|
- scriptAlertDefinitions = [],
|
|
|
|
|
|
+ alertDefinitions = [],
|
|
alertReportDefinitions = [],
|
|
alertReportDefinitions = [],
|
|
alertMetricsSourceDefinitions = [],
|
|
alertMetricsSourceDefinitions = [],
|
|
alertMetricsUriDefinitions = [],
|
|
alertMetricsUriDefinitions = [],
|
|
alertGroupsMap = App.cache['previousAlertGroupsMap'],
|
|
alertGroupsMap = App.cache['previousAlertGroupsMap'],
|
|
- alertDefinitions = App.AlertDefinition.getAllDefinitions(),
|
|
|
|
- alertDefinitionsToDelete = alertDefinitions.mapProperty('id'),
|
|
|
|
|
|
+ existingAlertDefinitions = App.AlertDefinition.find(),
|
|
|
|
+ alertDefinitionsToDelete = existingAlertDefinitions.mapProperty('id'),
|
|
rawSourceData = {};
|
|
rawSourceData = {};
|
|
|
|
|
|
json.items.forEach(function (item) {
|
|
json.items.forEach(function (item) {
|
|
@@ -123,7 +113,7 @@ App.alertDefinitionsMapper = App.QuickDataMapper.create({
|
|
alertDefinition.groups = alertGroupsMap[alertDefinition.id];
|
|
alertDefinition.groups = alertGroupsMap[alertDefinition.id];
|
|
}
|
|
}
|
|
|
|
|
|
- var oldAlertDefinition = alertDefinitions.findProperty('id', alertDefinition.id);
|
|
|
|
|
|
+ var oldAlertDefinition = existingAlertDefinitions.findProperty('id', alertDefinition.id);
|
|
if (oldAlertDefinition) {
|
|
if (oldAlertDefinition) {
|
|
// new values will be parsed in the another mapper, so for now just use old values
|
|
// new values will be parsed in the another mapper, so for now just use old values
|
|
alertDefinition.summary = oldAlertDefinition.get('summary');
|
|
alertDefinition.summary = oldAlertDefinition.get('summary');
|
|
@@ -135,7 +125,7 @@ App.alertDefinitionsMapper = App.QuickDataMapper.create({
|
|
// map properties dependent on Alert Definition type
|
|
// map properties dependent on Alert Definition type
|
|
switch (item.AlertDefinition.source.type) {
|
|
switch (item.AlertDefinition.source.type) {
|
|
case 'PORT':
|
|
case 'PORT':
|
|
- portAlertDefinitions.push($.extend(alertDefinition, this.parseIt(item, this.get('portConfig'))));
|
|
|
|
|
|
+ alertDefinitions.push($.extend(alertDefinition, this.parseIt(item, this.get('portConfig'))));
|
|
break;
|
|
break;
|
|
case 'METRIC':
|
|
case 'METRIC':
|
|
// map App.AlertMetricsSourceDefinition's
|
|
// map App.AlertMetricsSourceDefinition's
|
|
@@ -162,20 +152,20 @@ App.alertDefinitionsMapper = App.QuickDataMapper.create({
|
|
alertDefinition.uri_id = item.AlertDefinition.id + 'uri';
|
|
alertDefinition.uri_id = item.AlertDefinition.id + 'uri';
|
|
item.AlertDefinition.source.uri.id = alertDefinition.uri_id;
|
|
item.AlertDefinition.source.uri.id = alertDefinition.uri_id;
|
|
alertMetricsUriDefinitions.push(this.parseIt(item, this.get('uriConfig')));
|
|
alertMetricsUriDefinitions.push(this.parseIt(item, this.get('uriConfig')));
|
|
- metricsAlertDefinitions.push(alertDefinition);
|
|
|
|
|
|
+ alertDefinitions.push(alertDefinition);
|
|
break;
|
|
break;
|
|
case 'WEB':
|
|
case 'WEB':
|
|
// map App.AlertMetricsUriDefinition
|
|
// map App.AlertMetricsUriDefinition
|
|
alertDefinition.uri_id = item.AlertDefinition.id + 'uri';
|
|
alertDefinition.uri_id = item.AlertDefinition.id + 'uri';
|
|
item.AlertDefinition.source.uri.id = alertDefinition.uri_id;
|
|
item.AlertDefinition.source.uri.id = alertDefinition.uri_id;
|
|
alertMetricsUriDefinitions.push(this.parseIt(item, this.get('uriConfig')));
|
|
alertMetricsUriDefinitions.push(this.parseIt(item, this.get('uriConfig')));
|
|
- webAlertDefinitions.push(alertDefinition);
|
|
|
|
|
|
+ alertDefinitions.push(alertDefinition);
|
|
break;
|
|
break;
|
|
case 'AGGREGATE':
|
|
case 'AGGREGATE':
|
|
- aggregateAlertDefinitions.push($.extend(alertDefinition, this.parseIt(item, this.get('aggregateConfig'))));
|
|
|
|
|
|
+ alertDefinitions.push($.extend(alertDefinition, this.parseIt(item, this.get('aggregateConfig'))));
|
|
break;
|
|
break;
|
|
case 'SCRIPT':
|
|
case 'SCRIPT':
|
|
- scriptAlertDefinitions.push($.extend(alertDefinition, this.parseIt(item, this.get('scriptConfig'))));
|
|
|
|
|
|
+ alertDefinitions.push($.extend(alertDefinition, this.parseIt(item, this.get('scriptConfig'))));
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
console.error('Incorrect Alert Definition type:', item.AlertDefinition);
|
|
console.error('Incorrect Alert Definition type:', item.AlertDefinition);
|
|
@@ -183,7 +173,7 @@ App.alertDefinitionsMapper = App.QuickDataMapper.create({
|
|
}, this);
|
|
}, this);
|
|
|
|
|
|
alertDefinitionsToDelete.forEach(function(definitionId) {
|
|
alertDefinitionsToDelete.forEach(function(definitionId) {
|
|
- self.deleteRecord(alertDefinitions.findProperty('id', definitionId));
|
|
|
|
|
|
+ self.deleteRecord(existingAlertDefinitions.findProperty('id', definitionId));
|
|
});
|
|
});
|
|
|
|
|
|
// load all mapped data to model
|
|
// load all mapped data to model
|
|
@@ -191,11 +181,7 @@ App.alertDefinitionsMapper = App.QuickDataMapper.create({
|
|
App.store.loadMany(this.get('metricsSourceModel'), alertMetricsSourceDefinitions);
|
|
App.store.loadMany(this.get('metricsSourceModel'), alertMetricsSourceDefinitions);
|
|
this.setMetricsSourcePropertyLists(this.get('metricsSourceModel'), alertMetricsSourceDefinitions);
|
|
this.setMetricsSourcePropertyLists(this.get('metricsSourceModel'), alertMetricsSourceDefinitions);
|
|
App.store.loadMany(this.get('metricsUriModel'), alertMetricsUriDefinitions);
|
|
App.store.loadMany(this.get('metricsUriModel'), alertMetricsUriDefinitions);
|
|
- App.store.loadMany(this.get('portModel'), portAlertDefinitions);
|
|
|
|
- App.store.loadMany(this.get('metricsModel'), metricsAlertDefinitions);
|
|
|
|
- App.store.loadMany(this.get('webModel'), webAlertDefinitions);
|
|
|
|
- App.store.loadMany(this.get('aggregateModel'), aggregateAlertDefinitions);
|
|
|
|
- App.store.loadMany(this.get('scriptModel'), scriptAlertDefinitions);
|
|
|
|
|
|
+ App.store.loadMany(this.get('model'), alertDefinitions);
|
|
this.setAlertDefinitionsRawSourceData(rawSourceData);
|
|
this.setAlertDefinitionsRawSourceData(rawSourceData);
|
|
if (App.router.get('mainAlertDefinitionsController')) {
|
|
if (App.router.get('mainAlertDefinitionsController')) {
|
|
App.router.set('mainAlertDefinitionsController.mapperTimestamp', (new Date()).getTime());
|
|
App.router.set('mainAlertDefinitionsController.mapperTimestamp', (new Date()).getTime());
|
|
@@ -220,7 +206,7 @@ App.alertDefinitionsMapper = App.QuickDataMapper.create({
|
|
* @param rawSourceData
|
|
* @param rawSourceData
|
|
*/
|
|
*/
|
|
setAlertDefinitionsRawSourceData: function (rawSourceData) {
|
|
setAlertDefinitionsRawSourceData: function (rawSourceData) {
|
|
- var allDefinitions = App.AlertDefinition.getAllDefinitions();
|
|
|
|
|
|
+ var allDefinitions = App.AlertDefinition.find();
|
|
for (var alertDefinitionId in rawSourceData) {
|
|
for (var alertDefinitionId in rawSourceData) {
|
|
if (rawSourceData.hasOwnProperty(alertDefinitionId)) {
|
|
if (rawSourceData.hasOwnProperty(alertDefinitionId)) {
|
|
allDefinitions.findProperty('id', +alertDefinitionId).set('rawSourceData', rawSourceData[alertDefinitionId]);
|
|
allDefinitions.findProperty('id', +alertDefinitionId).set('rawSourceData', rawSourceData[alertDefinitionId]);
|