123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- /**
- * 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 filters = require('views/common/filter_view');
- var sort = require('views/common/sort_view');
- App.MainAlertDefinitionDetailsView = App.TableView.extend({
- templateName: require('templates/main/alerts/definition_details'),
- /**
- * Determines if <code>controller.content</code> is loaded
- * @type {bool}
- */
- isLoaded: false,
- /**
- * @type {string}
- */
- enabledDisplay: Em.I18n.t('alerts.table.state.enabled'),
- /**
- * @type {string}
- */
- disabledDisplay: Em.I18n.t('alerts.table.state.disabled'),
- colPropAssoc: ['serviceName', 'hostName', 'state'],
- /**
- * return filtered number of all content number information displayed on the page footer bar
- * @returns {String}
- */
- filteredContentInfo: Em.computed.i18nFormat('tableView.filters.filteredAlertInstancesInfo', 'filteredCount', 'totalCount'),
- content: function () {
- return this.get('controller.alerts');
- }.property('controller.alerts.@each'),
- willInsertElement: function () {
- this._super();
- this.get('controller').clearStep();
- if (this.get('controller.content.isLoaded')) {
- this.set('isLoaded', true);
- this.get('controller').loadAlertInstances();
- } else {
- this.loadDefinitionDetails();
- }
- },
- loadDefinitionDetails: function() {
- var self = this,
- updater = App.router.get('updateController');
- updater.updateAlertGroups(function () {
- updater.updateAlertDefinitions(function () {
- updater.updateAlertDefinitionSummary(function () {
- self.set('isLoaded', true);
- // App.AlertDefinition doesn't represents real models
- // Real model (see AlertDefinition types) should be used
- self.set('controller.content', App.AlertDefinition.find(parseInt(self.get('controller.content.id'))));
- self.get('controller').loadAlertInstances();
- });
- });
- });
- },
- didInsertElement: function () {
- this.filter();
- this.tooltipsUpdater();
- },
- /**
- * Update tooltips when <code>pageContent</code> is changed
- * @method tooltipsUpdater
- */
- tooltipsUpdater: function () {
- Em.run.next(function () {
- App.tooltip($(".enable-disable-button"));
- });
- }.observes('controller.content.enabled'),
- sortView: sort.wrapperView.extend({}),
- /**
- * Sorting header for <label>alertDefinition.label</label>
- * @type {Em.View}
- */
- serviceSort: sort.fieldView.extend({
- column: 0,
- name: 'serviceName',
- displayName: Em.I18n.t('common.service')
- }),
- /**
- * Sorting header for <label>alertDefinition.status</label>
- * @type {Em.View}
- */
- hostNameSort: sort.fieldView.extend({
- column: 1,
- name: 'hostName',
- displayName: Em.I18n.t('common.host')
- }),
- /**
- * Sorting header for <label>alertDefinition.service.serviceName</label>
- * @type {Em.View}
- */
- stateSort: sort.fieldView.extend({
- column: 2,
- name: 'state',
- displayName: Em.I18n.t('common.status')
- }),
- /**
- * Filtering header for <label>alertInstance.hostName</label>
- * @type {Em.View}
- */
- hostNameFilterView: filters.createTextView({
- column: 1,
- fieldType: 'input-medium',
- onChangeValue: function(){
- this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
- }
- }),
- /**
- * Filtering header for <label>alertInstance.serviceName</label>
- * @type {Em.View}
- */
- serviceFilterView: filters.createSelectView({
- column: 0,
- fieldType: 'input-small',
- content: filters.getComputedServicesList(),
- onChangeValue: function () {
- this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'select');
- }
- }),
- /**
- * Filtering header for <label>alertInstance.state</label>
- * @type {Em.View}
- */
- stateFilterView: filters.createSelectView({
- column: 2,
- fieldType: 'filter-input-width',
- content: [
- {
- value: '',
- label: Em.I18n.t('common.all')
- },
- {
- value: 'OK',
- label: 'OK'
- },
- {
- value: 'WARNING',
- label: 'WARNING'
- },
- {
- value: 'CRITICAL',
- label: 'CRITICAL'
- },
- {
- value: 'UNKNOWN',
- label: 'UNKNOWN'
- },
- {
- value: 'PENDING',
- label: 'NONE'
- }
- ],
- onChangeValue: function () {
- this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'select');
- }
- }),
- /**
- * View calculates and represents count of alerts on appropriate host during last day
- */
- lastDayCount: Em.View.extend({
- hostName: '', // binding from template
- template: Ember.Handlebars.compile('<span>{{view.count}}</span>'),
- count: function () {
- var lastDayAlertsCount = this.get('parentView.controller.lastDayAlertsCount');
- return lastDayAlertsCount ? lastDayAlertsCount[this.get('hostName')] || 0 : Em.I18n.t('app.loadingPlaceholder');
- }.property('parentView.controller.lastDayAlertsCount', 'hostName')
- }),
- /**
- * View represents each row of instances table
- */
- instanceTableRow: Em.View.extend({
- tagName: 'tr',
- didInsertElement: function () {
- App.tooltip(this.$("[rel=tooltip]"));
- App.tooltip(this.$(".alert-text"), {
- placement: 'left',
- template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner alert-def-detail-tooltip"></div></div>'
- });
- },
- willDestroyElement: function() {
- this.$("[rel=tooltip]").tooltip('destroy');
- this.$(".alert-text").tooltip('destroy');
- },
- /**
- * Router transition to service page
- * @param event
- */
- goToService: function (event) {
- if (event && event.context) {
- App.router.transitionTo('main.services.service.summary', event.context);
- }
- },
- /**
- * Router transition to host level alerts page
- * @param {object} event
- * @method goToHostAlerts
- */
- goToHostAlerts: function (event) {
- if (event && event.context) {
- App.router.get('mainHostDetailsController').set('referer', App.router.location.lastSetURL);
- App.router.transitionTo('main.hosts.hostDetails.alerts', event.context);
- }
- },
- /**
- * open popup that contain full response of Alert Instance
- * @param {Object} event
- */
- openFullResponse: function(event) {
- App.showLogsPopup(Em.I18n.t('alerts.instance.fullLogPopup.header'), event.context.get('text'));
- }
- }),
- paginationLeftClass: function () {
- if (this.get("startIndex") > 1) {
- return "paginate_previous";
- }
- return "paginate_disabled_previous";
- }.property("startIndex", 'filteredCount'),
- /**
- * Determines how display "next"-link - as link or text
- * @type {string}
- */
- paginationRightClass: function () {
- if (this.get("endIndex") < this.get("filteredCount")) {
- return "paginate_next";
- }
- return "paginate_disabled_next";
- }.property("endIndex", 'filteredCount'),
- /**
- * Show previous-page if user not in the first page
- * @method previousPage
- */
- previousPage: function () {
- if (this.get('paginationLeftClass') === 'paginate_previous') {
- this._super();
- }
- },
- /**
- * Show next-page if user not in the last page
- * @method nextPage
- */
- nextPage: function () {
- if (this.get('paginationRightClass') === 'paginate_next') {
- this._super();
- }
- }
- });
- App.AlertInstanceServiceHostView = Em.View.extend({
- templateName: require('templates/main/alerts/instance_service_host'),
- /**
- * Define whether show link for transition to service page
- */
- serviceIsLink: function () {
- return App.get('services.all').contains(this.get('instance.service.serviceName'));
- }.property('instance.service.serviceName'),
- /**
- * Define whether show separator between service and hosts labels
- */
- showSeparator: Em.computed.and('instance.serviceDisplayName', 'instance.hostName')
- });
|