| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717 |
1
1
1
1
1
1
1
3
3
6
6
6
1
1
4
3
3
20
10
7
3
3
3
3
3
3
3
3
3
3
3
4
4
4
3
3
3
4
3
3
3
3
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
2
1
| 'use strict';
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
;require.register("controllers/main/alerts/manage_alert_groups_controller", function (exports, require, module) {
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var App = require('app');
var validator = require('utils/validator');
function stringify(obj, property) {
return JSON.stringify(obj.get(property).slice().sort());
}
function groupsAreNotEqual(group1, group2) {
return stringify(group1, 'definitions') !== stringify(group2, 'definitions') || stringify(group1, 'notifications') !== stringify(group2, 'notifications');
}
function mapToEmObjects(collection, fields, renamedFields) {
var _renamedFields = arguments.length === 3 ? renamedFields : [];
return collection.map(function (item) {
var ret = Em.Object.create(Em.getProperties(item, fields));
_renamedFields.forEach(function (renamedField) {
var _renamedField$split = renamedField.split(':'),
_renamedField$split2 = _slicedToArray(_renamedField$split, 2),
realName = _renamedField$split2[0],
newName = _renamedField$split2[1];
Em.set(ret, newName, Em.get(item, realName));
});
return ret;
});
}
var AlertGroupClone = Em.Object.extend({
displayName: function () {
var name = App.config.truncateGroupName(this.get('name'));
return this.get('default') ? name + ' Default' : name;
}.property('name', 'default'),
label: Em.computed.format('{0} ({1})', 'displayName', 'definitions.length')
});
App.ManageAlertGroupsController = Em.Controller.extend({
name: 'manageAlertGroupsController',
/**
* @type {boolean}
*/
isLoaded: false,
/**
* Property used to trigger Alert Groups Filter content updating
* @type {Boolean}
*/
changeTrigger: false,
/**
* @type {App.AlertGroup[]}
*/
alertGroups: [],
/**
* @type {App.AlertGroup[]}
*/
originalAlertGroups: [],
/**
* @type {App.AlertGroup}
*/
selectedAlertGroup: null,
/**
* @type {App.AlertDefinition[]}
*/
selectedDefinitions: [],
/**
* List of all Alert Notifications
* @type {App.AlertNotification[]}
*/
alertNotifications: function () {
return this.get('isLoaded') ? mapToEmObjects(App.AlertNotification.find(), ['id', 'name', 'description', 'type', 'global']) : [];
}.property('isLoaded'),
/**
* List of all global Alert Notifications
* @type {App.AlertNotification[]}
*/
alertGlobalNotifications: Em.computed.filterBy('alertNotifications', 'global', true),
/**
* @type {boolean}
*/
isRemoveButtonDisabled: true,
/**
* @type {boolean}
*/
isRenameButtonDisabled: true,
/**
* @type {boolean}
*/
isDuplicateButtonDisabled: true,
/**
* @type {boolean}
*/
isDeleteDefinitionsDisabled: function () {
var selectedGroup = this.get('selectedAlertGroup');
return selectedGroup ? selectedGroup.default || this.get('selectedDefinitions').length === 0 : true;
}.property('selectedAlertGroup.definitions.length', 'selectedDefinitions.length'),
/**
* observes if any group changed including: group name, newly created group, deleted group, group with definitions/notifications changed
* @type {{toDelete: App.AlertGroup[], toSet: App.AlertGroup[], toCreate: App.AlertGroup[]}}
*/
defsModifiedAlertGroups: {},
/**
* Determines if some group was edited/created/deleted
* @type {boolean}
*/
isDefsModified: Em.computed.and('isLoaded', 'isDefsModifiedAlertGroups'),
isDefsModifiedAlertGroups: Em.computed.or('defsModifiedAlertGroups.toSet.length', 'defsModifiedAlertGroups.toCreate.length', 'defsModifiedAlertGroups.toDelete.length'),
/**
* Check when some config group was changed and updates <code>defsModifiedAlertGroups</code> once
* @method defsModifiedAlertGroupsObs
*/
defsModifiedAlertGroupsObs: function () {
Em.run.once(this, this.defsModifiedAlertGroupsObsOnce);
}.observes('selectedAlertGroup.definitions.[]', 'selectedAlertGroup.notifications.[]', 'alertGroups', 'isLoaded'),
/**
* Update <code>defsModifiedAlertGroups</code>-value
* Called once in the <code>defsModifiedAlertGroupsObs</code>
* @method defsModifiedAlertGroupsObsOnce
* @returns {boolean}
*/
defsModifiedAlertGroupsObsOnce: function defsModifiedAlertGroupsObsOnce() {
if (!this.get('isLoaded')) {
return;
}
var groupsToDelete = [];
var groupsToSet = [];
var groupsToCreate = [];
var groups = this.get('alertGroups'); //current alert groups
var originalGroups = this.get('originalAlertGroups'); // original alert groups
var mappedOriginalGroups = {}; // map is faster than `originalGroups.findProperty('id', ...)`
originalGroups.forEach(function (group) {
mappedOriginalGroups[group.get('id')] = group;
});
var originalGroupsIds = originalGroups.mapProperty('id');
groups.forEach(function (group) {
var originalGroup = mappedOriginalGroups[group.get('id')];
if (originalGroup) {
// should update definitions or notifications
if (groupsAreNotEqual(group, originalGroup) || group.get('name') !== originalGroup.get('name')) {
// should update name
groupsToSet.push(group.set('id', originalGroup.get('id')));
}
originalGroupsIds = originalGroupsIds.without(group.get('id'));
} else {
// should add new group
groupsToCreate.push(group);
}
});
// should delete groups
originalGroupsIds.forEach(function (id) {
groupsToDelete.push(originalGroups.findProperty('id', id));
});
this.set('defsModifiedAlertGroups', {
toDelete: groupsToDelete,
toSet: groupsToSet,
toCreate: groupsToCreate
});
},
/**
* Load all Alert Notifications from server
* @returns {$.ajax}
* @method loadAlertNotifications
*/
loadAlertNotifications: function loadAlertNotifications() {
this.setProperties({
isLoaded: false,
alertGroups: [],
originalAlertGroups: [],
selectedAlertGroup: null,
isRemoveButtonDisabled: true,
isRenameButtonDisabled: true,
isDuplicateButtonDisabled: true
});
return App.ajax.send({
name: 'alerts.notifications',
sender: this,
success: 'getAlertNotificationsSuccessCallback',
error: 'getAlertNotificationsErrorCallback'
});
},
/**
* Success-callback for load alert notifications request
* @param {object} json
* @method getAlertNotificationsSuccessCallback
*/
getAlertNotificationsSuccessCallback: function getAlertNotificationsSuccessCallback(json) {
App.alertNotificationMapper.map(json);
this.loadAlertGroups();
},
/**
* Error-callback for load alert notifications request
* @method getAlertNotificationsErrorCallback
*/
getAlertNotificationsErrorCallback: function getAlertNotificationsErrorCallback() {
this.set('isLoaded', true);
},
/**
* Load all alert groups from alert group model
* @method loadAlertGroups
*/
loadAlertGroups: function loadAlertGroups() {
var alertGroups = App.AlertGroup.find().map(function (group) {
var definitions = mapToEmObjects(group.get('definitions'), ['name', 'serviceName', 'componentName', 'label', 'id'], ['service.displayName:serviceNameDisplay', 'componentNameFormatted:componentNameDisplay']);
var targets = mapToEmObjects(group.get('targets'), ['name', 'id', 'description', 'type', 'global']);
var hash = Em.getProperties(group, ['id', 'name', 'default', 'isAddDefinitionsDisabled']);
hash.definitions = definitions;
hash.notifications = targets;
return AlertGroupClone.create(hash);
});
this.setProperties({
alertGroups: alertGroups,
isLoaded: true,
originalAlertGroups: this.copyAlertGroups(alertGroups),
selectedAlertGroup: alertGroups[0]
});
},
/**
* Enable/disable "Remove"/"Rename"/"Duplicate" buttons basing on <code>controller.selectedAlertGroup</code>
* @method buttonObserver
*/
buttonObserver: function () {
var selectedAlertGroup = this.get('selectedAlertGroup');
var flag = selectedAlertGroup && selectedAlertGroup.get('default');
this.setProperties({
isRemoveButtonDisabled: flag,
isRenameButtonDisabled: flag,
isDuplicateButtonDisabled: false
});
}.observes('selectedAlertGroup'),
/**
* @method resortAlertGroup
*/
resortAlertGroup: function () {
var alertGroups = Em.copy(this.get('alertGroups'));
if (alertGroups.length < 2) {
return;
}
var defaultGroups = alertGroups.filterProperty('default');
defaultGroups.forEach(function (defaultGroup) {
alertGroups.removeObject(defaultGroup);
});
var sorted = defaultGroups.sortProperty('name').concat(alertGroups.sortProperty('name'));
this.removeObserver('alertGroups.@each.name', this, 'resortAlertGroup');
this.set('alertGroups', sorted);
this.addObserver('alertGroups.@each.name', this, 'resortAlertGroup');
}.observes('alertGroups.@each.name'),
/**
* remove definitions from group
* @method deleteDefinitions
*/
deleteDefinitions: function deleteDefinitions() {
Iif (this.get('isDeleteDefinitionsDisabled')) {
return;
}
var groupDefinitions = this.get('selectedAlertGroup.definitions');
this.get('selectedDefinitions').slice().forEach(function (defObj) {
groupDefinitions.removeObject(defObj);
}, this);
this.set('selectedDefinitions', []);
},
/**
* Provides alert definitions which are available for inclusion in
* non-default alert groups.
* @param {App.AlertGroup} selectedAlertGroup
* @method getAvailableDefinitions
* @return {{name: string, serviceName: string, componentName: string, serviceNameDisplay: string, componentNameDisplay: string, label: string, id: number}[]}
*/
getAvailableDefinitions: function getAvailableDefinitions(selectedAlertGroup) {
if (selectedAlertGroup.get('default')) return [];
var usedDefinitionsMap = {};
var availableDefinitions = [];
var sharedDefinitions = App.AlertDefinition.find();
usedDefinitionsMap = selectedAlertGroup.get('definitions').toWickMapByProperty('name');
selectedAlertGroup.get('definitions').forEach(function (def) {
usedDefinitionsMap[def.name] = true;
});
sharedDefinitions.forEach(function (sharedDef) {
if (!usedDefinitionsMap[sharedDef.get('name')]) {
availableDefinitions.pushObject(sharedDef);
}
});
return mapToEmObjects(availableDefinitions, ['name', 'serviceName', 'componentName', 'label', 'id'], ['service.displayName:serviceNameDisplay', 'componentNameFormatted:componentNameDisplay']);
},
/**
* add alert definitions to a group
* @method addDefinitions
*/
addDefinitions: function addDefinitions() {
if (this.get('selectedAlertGroup.isAddDefinitionsDisabled')) {
return false;
}
var availableDefinitions = this.getAvailableDefinitions(this.get('selectedAlertGroup'));
var validComponents = App.StackServiceComponent.find().map(function (component) {
return Em.Object.create({
componentName: component.get('componentName'),
displayName: App.format.role(component.get('componentName'), false),
selected: false
});
});
var validServices = App.Service.find().map(function (service) {
return Em.Object.create({
serviceName: service.get('serviceName'),
displayName: App.format.role(service.get('serviceName'), true),
selected: false
});
});
return this.launchDefsSelectionDialog(availableDefinitions, [], validServices, validComponents);
},
/**
* Launch a table view of all available definitions to choose
* @method launchDefsSelectionDialog
* @return {App.ModalPopup}
*/
launchDefsSelectionDialog: function launchDefsSelectionDialog(initialDefs, selectedDefs, validServices, validComponents) {
var self = this;
return App.ModalPopup.show({
classNames: ['common-modal-wrapper', 'full-height-modal'],
modalDialogClasses: ['modal-lg'],
header: Em.I18n.t('alerts.actions.manage_alert_groups_popup.selectDefsDialog.title'),
/**
* @type {string}
*/
dialogMessage: Em.I18n.t('alerts.actions.manage_alert_groups_popup.selectDefsDialog.message').format(this.get('selectedAlertGroup.displayName')),
/**
* @type {string|null}
*/
warningMessage: null,
/**
* @type {App.AlertDefinition[]}
*/
availableDefs: [],
onPrimary: function onPrimary() {
this.set('warningMessage', null);
var arrayOfSelectedDefs = this.get('availableDefs').filterProperty('selected', true);
if (arrayOfSelectedDefs.length < 1) {
this.set('warningMessage', Em.I18n.t('alerts.actions.manage_alert_groups_popup.selectDefsDialog.message.warning'));
return;
}
self.addDefinitionsCallback(arrayOfSelectedDefs);
this.hide();
},
/**
* Primary button should be disabled while alert definitions are not loaded
* @type {boolean}
*/
disablePrimary: Em.computed.not('isLoaded'),
onSecondary: function onSecondary() {
self.addDefinitionsCallback(null);
this.hide();
},
bodyClass: App.SelectDefinitionsPopupBodyView.extend({
filterComponents: validComponents,
filterServices: validServices,
initialDefs: initialDefs
})
});
},
/**
* add alert definitions callback
* @method addDefinitionsCallback
*/
addDefinitionsCallback: function addDefinitionsCallback(selectedDefs) {
var group = this.get('selectedAlertGroup');
Eif (selectedDefs) {
group.get('definitions').pushObjects(selectedDefs);
}
},
/**
* copy alert groups for backup, to compare with current alert groups, so will know if some groups changed/added/deleted
* @param {App.AlertGroup[]} originGroups
* @return {App.AlertGroup[]}
* @method copyAlertGroups
*/
copyAlertGroups: function copyAlertGroups(originGroups) {
var alertGroups = [];
originGroups.forEach(function (alertGroup) {
var copiedGroup = Em.Object.create($.extend(true, {}, alertGroup));
alertGroups.pushObject(copiedGroup);
});
return alertGroups;
},
/**
* Create a new alert group
* @param {Em.Object} newAlertGroupData
* @param {callback} callback Callback function for Success or Error handling
* @return {App.AlertGroup} Returns the created alert group
* @method postNewAlertGroup
*/
postNewAlertGroup: function postNewAlertGroup(newAlertGroupData, callback) {
// create a new group with name , definition and notifications
var data = {
name: newAlertGroupData.get('name')
};
if (newAlertGroupData.get('definitions').length > 0) {
data.definitions = newAlertGroupData.get('definitions').mapProperty('id');
}
if (newAlertGroupData.get('notifications').length > 0) {
data.targets = newAlertGroupData.get('notifications').mapProperty('id');
}
var sendData = {
name: 'alert_groups.create',
data: data,
success: 'successFunction',
error: 'errorFunction',
successFunction: function successFunction() {
if (callback) {
callback();
}
},
errorFunction: function errorFunction(xhr, text, errorThrown) {
if (callback) {
callback(xhr, text, errorThrown);
}
}
};
sendData.sender = sendData;
App.ajax.send(sendData);
return newAlertGroupData;
},
/**
* PUTs the new alert group information on the server.
* Changes possible here are the name, definitions, notifications
*
* @param {App.AlertGroup} alertGroup
* @param {Function} successCallback
* @param {Function} errorCallback
* @method updateAlertGroup
*/
updateAlertGroup: function updateAlertGroup(alertGroup, successCallback, errorCallback) {
var sendData = {
name: 'alert_groups.update',
data: {
group_id: alertGroup.id,
name: alertGroup.get('name'),
definitions: alertGroup.get('definitions').mapProperty('id'),
targets: alertGroup.get('notifications').mapProperty('id')
},
success: 'successFunction',
error: 'errorFunction',
successFunction: function successFunction() {
if (successCallback) {
successCallback();
}
},
errorFunction: function errorFunction(xhr, text, errorThrown) {
if (errorCallback) {
errorCallback(xhr, text, errorThrown);
}
}
};
sendData.sender = sendData;
App.ajax.send(sendData);
},
/**
* Request for deleting alert group
* @param {App.AlertGroup} alertGroup
* @param {callback} successCallback
* @param {callback} errorCallback
* @method removeAlertGroup
*/
removeAlertGroup: function removeAlertGroup(alertGroup, successCallback, errorCallback) {
var sendData = {
name: 'alert_groups.delete',
data: {
group_id: alertGroup.id
},
success: 'successFunction',
error: 'errorFunction',
successFunction: function successFunction() {
if (successCallback) {
successCallback();
}
},
errorFunction: function errorFunction(xhr, text, errorThrown) {
if (errorCallback) {
errorCallback(xhr, text, errorThrown);
}
}
};
sendData.sender = sendData;
App.ajax.send(sendData);
},
/**
* confirm delete alert group
* @method confirmDelete
*/
confirmDelete: function confirmDelete() {
if (this.get('isRemoveButtonDisabled')) return;
var self = this;
App.showConfirmationPopup(function () {
self.deleteAlertGroup();
});
},
/**
* delete selected alert group
* @method deleteAlertGroup
*/
deleteAlertGroup: function deleteAlertGroup() {
var selectedAlertGroup = this.get('selectedAlertGroup');
if (this.get('isDeleteAlertDisabled')) {
return;
}
this.get('alertGroups').removeObject(selectedAlertGroup);
this.set('selectedAlertGroup', this.get('alertGroups')[0]);
},
/**
* Rename non-default alert group
* @method renameAlertGroup
*/
renameAlertGroup: function renameAlertGroup() {
Iif (this.get('selectedAlertGroup.default')) {
return;
}
var self = this;
var popup = App.ModalPopup.show({
header: Em.I18n.t('alerts.actions.manage_alert_groups_popup.renameButton'),
bodyClass: Ember.View.extend({
templateName: require('templates/main/alerts/create_new_alert_group')
}),
/**
* @type {string}
*/
alertGroupName: self.get('selectedAlertGroup.name'),
alertGroupNameIsEmpty: function () {
return !this.get('alertGroupName').trim().length;
}.property('alertGroupName'),
/**
* @type {string|null}
*/
warningMessage: function () {
var originalGroup = self.get('selectedAlertGroup');
var groupName = this.get('alertGroupName').trim();
Eif (originalGroup.get('name').trim() === groupName) {
return Em.I18n.t("alerts.actions.manage_alert_groups_popup.addGroup.exist");
}
if (self.get('alertGroups').mapProperty('displayName').contains(groupName)) {
return Em.I18n.t("alerts.actions.manage_alert_groups_popup.addGroup.exist");
}
if (groupName && !validator.isValidAlertGroupName(groupName)) {
return Em.I18n.t("form.validator.alertGroupName");
}
return '';
}.property('alertGroupName'),
/**
* Primary button is disabled while user doesn't input valid group name
* @type {boolean}
*/
disablePrimary: Em.computed.or('alertGroupNameIsEmpty', 'warningMessage'),
onPrimary: function onPrimary() {
self.set('selectedAlertGroup.name', this.get('alertGroupName'));
this._super();
}
});
this.set('renameGroupPopup', popup);
},
/**
* Create new alert group
* @param {boolean} duplicated is new group a copy of the existing group
* @method addAlertGroup
*/
addAlertGroup: function addAlertGroup(duplicated) {
duplicated = duplicated === true;
var self = this;
var popup = App.ModalPopup.show({
header: Em.I18n.t('alerts.actions.manage_alert_groups_popup.addButton'),
bodyClass: Em.View.extend({
templateName: require('templates/main/alerts/create_new_alert_group')
}),
/**
* Name for new alert group
* @type {string}
*/
alertGroupName: duplicated ? self.get('selectedAlertGroup.name') + ' Copy' : "",
alertGroupNameIsEmpty: function () {
return !this.get('alertGroupName').trim().length;
}.property('alertGroupName'),
/**
* @type {string}
*/
warningMessage: function () {
var groupName = this.get('alertGroupName').trim();
Iif (self.get('alertGroups').mapProperty('displayName').contains(groupName)) {
return Em.I18n.t("alerts.actions.manage_alert_groups_popup.addGroup.exist");
}
Iif (groupName && !validator.isValidAlertGroupName(groupName)) {
return Em.I18n.t("form.validator.alertGroupName");
}
return '';
}.property('alertGroupName'),
/**
* Primary button is disabled while user doesn't input valid group name
* @type {boolean}
*/
disablePrimary: Em.computed.or('alertGroupNameIsEmpty', 'warningMessage'),
onPrimary: function onPrimary() {
var newAlertGroup = AlertGroupClone.create({
name: this.get('alertGroupName').trim(),
default: false,
definitions: duplicated ? self.get('selectedAlertGroup.definitions').slice(0) : [],
notifications: self.get('alertGlobalNotifications'),
isAddDefinitionsDisabled: false
});
self.get('alertGroups').pushObject(newAlertGroup);
self.set('selectedAlertGroup', newAlertGroup);
this.hide();
}
});
this.set('addGroupPopup', popup);
},
/**
* @method duplicateAlertGroup
*/
duplicateAlertGroup: function duplicateAlertGroup() {
this.addAlertGroup(true);
}
});
}); |