<commit_before>/*
 * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
 */

define([
    'underscore',
    'contrail-view',
    'config/alarm/common/ui/js/models/AlarmModel',
    'config/alarm/common/ui/js/views/ConfigAlarmEditView',
    'config/alarm/common/ui/js/ConfigAlarmFormatters'
], function(_, ContrailView, AlarmModel,
    AlarmEditView, AlarmFormatters) {
    var self, gridElId = '#' + ctwc.ALARM_GRID_ID, gridObj,
        alarmEditView = new AlarmEditView(),
        alarmFormatters = new AlarmFormatters();
    var configAlarmGridView = ContrailView.extend({
        el: $(contentContainer),

        render: function () {
            self = this;
            var viewConfig = self.attributes.viewConfig;
            self.renderView4Config(self.$el, self.model,
                getAlarmGridViewConfig(viewConfig));
        }
    });

    function getAlarmGridViewConfig (viewConfig) {
        return {
            elementId:
                cowu.formatElementId(
                [ctwc.CONFIG_ALARM_LIST_VIEW_ID]),
            view: "SectionView",
            viewConfig: {
                rows: [
                    {
                        columns: [
                            {
                                elementId: ctwc.ALARM_GRID_ID,
                                view: "GridView",
                                viewConfig: {
                                    elementConfig:
                                        getConfiguration(viewConfig)
                                }
                            }
                        ]
                    }
                ]
            }
        }
    };

    function getConfiguration (viewConfig) {
        var gridElementConfig = {
            header: {
                title: {
                    text: ctwl.TITLE_ALARM_RULE
                },
                advanceControls: getHeaderActionConfig(viewConfig)
            },
            body: {
                options: {
                    checkboxSelectable: {
                        onNothingChecked: function(e){
                            $('#btnDeleteAlarm').addClass('disabled-link');
                        },
                        onSomethingChecked: function(e){
                            $('#btnDeleteAlarm').
                                removeClass('disabled-link');
                        }
                    },
                    actionCell: getRowActionConfig(viewConfig),
                    detail: {
                        template:
                            cowu.generateDetailTemplateHTML(getAlarmDetailsTemplateConfig(),
                            cowc.APP_CONTRAIL_CONTROLLER)
                    }
                },
                dataSource: {
                },
                statusMessages: {
                    loading: {
                        text: 'Loading Alarms ...'
                    },
                    empty: {
                        text: 'No Alarms found'
                    }
                }
            },
            columnHeader: {
                columns: [
                   {
                        field: "name",
                        name: "Name",
                        sortable: true,
                        maxWidth: 230,
                    },{
                        field: "alarm_severity",
                        name: "Severity",
                        sortable: true,
                        maxWidth: 100,
                        formatter: alarmFormatters.severityFormatter
                    },{
                        field: "uve_keys",
                        name: "UVE Keys",
                        sortable: true,
                        maxWidth: 130,
                        formatter: alarmFormatters.uveKeysFormatter
                    },{
                        field: "alarm_rules",
                        name: "Rule",
                        sortable: true,
                        formatter: alarmFormatters.rulesFormatter
                    }
                ]<commit_msg>Closes-Bug:#1602364 Increased the grid column width of UVE Keys in config alarms page, so that each key will display in single line without wrapped to next line.<commit_after>/*
 * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
 */

define([
    'underscore',
    'contrail-view',
    'config/alarm/common/ui/js/models/AlarmModel',
    'config/alarm/common/ui/js/views/ConfigAlarmEditView',
    'config/alarm/common/ui/js/ConfigAlarmFormatters'
], function(_, ContrailView, AlarmModel,
    AlarmEditView, AlarmFormatters) {
    var self, gridElId = '#' + ctwc.ALARM_GRID_ID, gridObj,
        alarmEditView = new AlarmEditView(),
        alarmFormatters = new AlarmFormatters();
    var configAlarmGridView = ContrailView.extend({
        el: $(contentContainer),

        render: function () {
            self = this;
            var viewConfig = self.attributes.viewConfig;
            self.renderView4Config(self.$el, self.model,
                getAlarmGridViewConfig(viewConfig));
        }
    });

    function getAlarmGridViewConfig (viewConfig) {
        return {
            elementId:
                cowu.formatElementId(
                [ctwc.CONFIG_ALARM_LIST_VIEW_ID]),
            view: "SectionView",
            viewConfig: {
                rows: [
                    {
                        columns: [
                            {
                                elementId: ctwc.ALARM_GRID_ID,
                                view: "GridView",
                                viewConfig: {
                                    elementConfig:
                                        getConfiguration(viewConfig)
                                }
                            }
                        ]
                    }
                ]
            }
        }
    };

    function getConfiguration (viewConfig) {
        var gridElementConfig = {
            header: {
                title: {
                    text: ctwl.TITLE_ALARM_RULE
                },
                advanceControls: getHeaderActionConfig(viewConfig)
            },
            body: {
                options: {
                    checkboxSelectable: {
                        onNothingChecked: function(e){
                            $('#btnDeleteAlarm').addClass('disabled-link');
                        },
                        onSomethingChecked: function(e){
                            $('#btnDeleteAlarm').
                                removeClass('disabled-link');
                        }
                    },
                    actionCell: getRowActionConfig(viewConfig),
                    detail: {
                        template:
                            cowu.generateDetailTemplateHTML(getAlarmDetailsTemplateConfig(),
                            cowc.APP_CONTRAIL_CONTROLLER)
                    }
                },
                dataSource: {
                },
                statusMessages: {
                    loading: {
                        text: 'Loading Alarms ...'
                    },
                    empty: {
                        text: 'No Alarms found'
                    }
                }
            },
            columnHeader: {
                columns: [
                   {
                        field: "name",
                        name: "Name",
                        sortable: true,
                        maxWidth: 230,
                    },{
                        field: "alarm_severity",
                        name: "Severity",
                        sortable: true,
                        maxWidth: 100,
                        formatter: alarmFormatters.severityFormatter
                    },{
                        field: "uve_keys",
                        name: "UVE Keys",
                        sortable: true,
                        maxWidth: 170,
                        formatter: alarmFormatters.uveKeysFormatter
                    },{
                        field: "alarm_rules",
                        name: "Rule",
                        sortable: true,
                        formatter: alarmFormatters.rulesFormatter
                    }
                ]
{'fraction_non_alphanumeric': 0.0794517224648229, 'fraction_numerical': 0.004245511887433284, 'mean_word_length': 0.8940960257293821, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1371566', 'n_tokens_mistral': 1967, 'n_tokens_neox': 1768, 'n_words': 312}