123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- /**
- * 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');
- App.ManageAlertNotificationsView = Em.View.extend({
- templateName: require('templates/main/alerts/manage_alert_notifications_popup'),
- /**
- * @type {App.AlertNotification}
- */
- selectedAlertNotification: null,
- selectedAlertNotificationGroups: function () {
- return this.get('controller.selectedAlertNotification.groups').toArray().mapProperty('name').join(', ');
- }.property('controller.selectedAlertNotification'),
- isEditButtonDisabled: true,
- isRemoveButtonDisabled: true,
- isDuplicateButtonDisabled: true,
- /**
- * Show EMAIL information if selected alert notification has type EMAIL
- * @type {boolean}
- */
- showEmailDetails: function () {
- return this.get('controller.selectedAlertNotification.type') === 'EMAIL';
- }.property('controller.selectedAlertNotification.type'),
- /**
- * Show SNMP information if selected alert notification has type SNMP
- * @type {boolean}
- */
- showSNMPDetails: function () {
- return this.get('controller.selectedAlertNotification.type') === 'SNMP';
- }.property('controller.selectedAlertNotification.type'),
- /**
- * Enable/disable "edit"/"remove"/"duplicate" buttons basing on <code>controller.selectedAlertNotification</code>
- * @method buttonObserver
- */
- buttonObserver: function () {
- var selectedAlertNotification = this.get('controller.selectedAlertNotification');
- this.set('isEditButtonDisabled', !selectedAlertNotification);
- this.set('isRemoveButtonDisabled', !selectedAlertNotification);
- this.set('isDuplicateButtonDisabled', !selectedAlertNotification);
- }.observes('controller.selectedAlertNotification'),
- /**
- * Prevent user select more than 1 alert notification
- * @method onAlertNotificationSelect
- */
- onAlertNotificationSelect: function () {
- var selectedAlertNotification = this.get('selectedAlertNotification');
- if (selectedAlertNotification && selectedAlertNotification.length) {
- this.set('controller.selectedAlertNotification', selectedAlertNotification[selectedAlertNotification.length - 1]);
- }
- if (selectedAlertNotification && selectedAlertNotification.length > 1) {
- this.set('selectedAlertNotification', selectedAlertNotification[selectedAlertNotification.length - 1]);
- }
- }.observes('selectedAlertNotification'),
- /**
- * Set first alert notification as selected (if they are already loaded)
- * Add some tooltips on manage buttons
- * @method onLoad
- */
- onLoad: function () {
- if (this.get('controller.isLoaded')) {
- var notifications = this.get('controller.alertNotifications');
- if (notifications && notifications.length) {
- this.set('selectedAlertNotification', notifications[0]);
- this.buttonObserver();
- } else {
- this.set('selectedAlertNotification', null);
- }
- Em.run.later(this, function () {
- App.tooltip(this.$("[rel='button-info']"));
- App.tooltip(this.$("[rel='button-info-dropdown']"), {placement: 'left'});
- }, 50) ;
- }
- }.observes('controller.isLoaded'),
- willInsertElement: function () {
- this.get('controller').loadAlertNotifications();
- },
- didInsertElement: function () {
- this.onLoad();
- }
- });
|