diff --git a/webroot/css/contrail.custom.css b/webroot/css/contrail.custom.css index 5002171f1..8a7391752 100644 --- a/webroot/css/contrail.custom.css +++ b/webroot/css/contrail.custom.css @@ -898,6 +898,13 @@ a.selectAllLink:hover { .slick-viewport { border-top: 1px solid #dadada; } +.grid-state-fetching-rows .slick-row, +.grid-state-fetching .widget-toolbar .widget-toolbar-icon[data-action="export"], +.grid-state-fetching .widget-toolbar .widget-toolbar-icon[data-action="refresh"] { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=60)"; + filter: alpha(opacity=60); + opacity: 0.6; +} .slick-row { border:none; } @@ -2754,7 +2761,7 @@ p.error, p.error-text { font-size: 11px; } -.ui-multiselect-menu { display:none; position:absolute; z-index: 12; text-align: left } +.ui-multiselect-menu { display:none; position:absolute; z-index: 1051; text-align: left } .ui-multiselect-checkboxes { position:relative /* fixes bug in IE6/7 */; overflow-y:scroll } .ui-multiselect-checkboxes input.ace-input[type=checkbox] { width: 0; } .ui-multiselect-checkboxes label { cursor:default; display:block; border:1px solid transparent; padding:3px 3px 3px 10px } diff --git a/webroot/css/contrail.layout.css b/webroot/css/contrail.layout.css index 2c3963e17..8fc053152 100644 --- a/webroot/css/contrail.layout.css +++ b/webroot/css/contrail.layout.css @@ -541,23 +541,23 @@ li [class*=" icon-"], .nav-list > li.open { border-bottom-color: #e5e5e5; } -.nav-list > li.active.open > .submenu > li.active > a:after { - display: inline-block; - content: ""; - position: absolute !important; - right: -8px; - top: 9px; - width: 15px; - height: 15px; - border: 1px solid #ccc; - border-width: 1px 0 0 1px; - background-color: #FFF; - -webkit-transform: rotate(-45deg); - -moz-transform: rotate(-45deg); - -ms-transform: rotate(-45deg); - -o-transform: rotate(-45deg); - transform: rotate(-45deg); -} +/*.nav-list > li.active.open > .submenu > li.active > a:after {*/ + /*display: inline-block;*/ + /*content: "";*/ + /*position: absolute !important;*/ + /*right: -8px;*/ + /*top: 9px;*/ + /*width: 15px;*/ + /*height: 15px;*/ + /*border: 1px solid #ccc;*/ + /*border-width: 1px 0 0 1px;*/ + /*background-color: #FFF;*/ + /*!*-webkit-transform: rotate(-45deg);*!*/ + /*-moz-transform: rotate(-45deg);*/ + /*-ms-transform: rotate(-45deg);*/ + /*-o-transform: rotate(-45deg);*/ + /*transform: rotate(-45deg);*/ +/*}*/ .nav-list > li.active .submenu { display: block; @@ -572,17 +572,12 @@ li [class*=" icon-"], border-top: 1px solid #e5e5e5; } .nav-list > li .submenu > li { - margin-left: 0; - position: relative; - /* tree like menu */ - - /* the horizontal dashed line */ - - /* the vertical dashed line */ - - /* optional icon before each item */ - + margin-left: 0; + position: relative; } +/*.nav-list > li .submenu > li.active {*/ + /*border-right: 3px solid #555555;*/ +/*}*/ .nav-list > li .submenu > li > a { display: block; position: relative; diff --git a/webroot/js/common/core.constants.js b/webroot/js/common/core.constants.js index 7f1e8a9ec..0c45500b2 100644 --- a/webroot/js/common/core.constants.js +++ b/webroot/js/common/core.constants.js @@ -266,7 +266,7 @@ define([ {id: "50", text: "50 Messages" }, {id: "100", text: "100 Messages" }, {id: "200", text: "200 Messages" }, - {id: "500", text: "500 Messages" }, + {id: "500", text: "500 Messages" } ]; this.DIRECTION_DROPDOWN_VALUES = [ @@ -290,6 +290,8 @@ define([ 8: 'RegEx=' }; + this.BYTE_PREFIX = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + this.URL_TABLES = "/api/qe/tables"; this.URL_PREFIX_TABLE_SCHEMA = "/api/qe/table/schema/"; @@ -303,129 +305,168 @@ define([ this.UMID_QUERY_RESULT_LINE_CHART_MODEL = "qe:query-result-line-chart-model"; this.UMID_QUERY_RESULT_LIST_MODEL = "qe:query-result-list-model"; - this.MAP_Y_FORMATTER = { + this.QUERY_COLUMN_FORMATTER = { + "T": "micro-date", + "T=": "micro-date", + "MessageTS": "micro-date", + "protocol": "protocol", + "direction_ing": "query-direction", + + "bytes": "byte", "sum(bytes)": "byte", + "packets": "number", + "sum(packets)": "number", + "flow_count": "number", + + "agg-bytes": "byte", + "agg-packets": "number", // cpu_info + "cpu_info.mem_virt": "byte", "SUM(cpu_info.mem_virt)": "byte", "MAX(cpu_info.mem_virt)": "byte", "MIN(cpu_info.mem_virt)": "byte", + "cpu_info.mem_res": "byte", "SUM(cpu_info.mem_res)": "byte", "MAX(cpu_info.mem_res)": "byte", "MIN(cpu_info.mem_res)": "byte", + "cpu_info.used_sys_mem": "byte", "SUM(cpu_info.used_sys_mem)": "byte", "MAX(cpu_info.used_sys_mem)": "byte", "MIN(cpu_info.used_sys_mem)": "byte", - "SUM(cpu_info.cpu_share)": "percentage", - "MAX(cpu_info.cpu_share)": "percentage", - "MIN(cpu_info.cpu_share)": "percentage", + "cpu_info.cpu_share": [{format: 'number', options: {formatSpecifier: '.3n'}}, {format: 'percentage'}], + "SUM(cpu_info.cpu_share)": [{format: 'number', options: {formatSpecifier: '.3n'}}, {format: 'percentage'}], + "MAX(cpu_info.cpu_share)": [{format: 'number', options: {formatSpecifier: '.3n'}}, {format: 'percentage'}], + "MIN(cpu_info.cpu_share)": [{format: 'number', options: {formatSpecifier: '.3n'}}, {format: 'percentage'}], - "SUM(cpu_info.one_min_cpuload)": "percentage", - "MAX(cpu_info.one_min_cpuload)": "percentage", - "MIN(cpu_info.one_min_cpuload)": "percentage", + "cpu_info.one_min_cpuload": [{format: 'number', options: {formatSpecifier: '.3n'}}, {format: 'percentage'}], + "SUM(cpu_info.one_min_cpuload)": [{format: 'number', options: {formatSpecifier: '.3n'}}, {format: 'percentage'}], + "MAX(cpu_info.one_min_cpuload)": [{format: 'number', options: {formatSpecifier: '.3n'}}, {format: 'percentage'}], + "MIN(cpu_info.one_min_cpuload)": [{format: 'number', options: {formatSpecifier: '.3n'}}, {format: 'percentage'}], // cpu_stats - "SUM(cpu_stats.cpu_one_min_avg)": "percentage", - "MAX(cpu_stats.cpu_one_min_avg)": "percentage", - "MIN(cpu_stats.cpu_one_min_avg)": "percentage", + "cpu_stats.cpu_one_min_avg": [{format: 'number', options: {formatSpecifier: '.3n'}}, {format: 'percentage'}], + "SUM(cpu_stats.cpu_one_min_avg)": [{format: 'number', options: {formatSpecifier: '.3n'}}, {format: 'percentage'}], + "MAX(cpu_stats.cpu_one_min_avg)": [{format: 'number', options: {formatSpecifier: '.3n'}}, {format: 'percentage'}], + "MIN(cpu_stats.cpu_one_min_avg)": [{format: 'number', options: {formatSpecifier: '.3n'}}, {format: 'percentage'}], + "cpu_stats.vm_memory_quota": "byte", "SUM(cpu_stats.vm_memory_quota)": "byte", "MAX(cpu_stats.vm_memory_quota)": "byte", "MIN(cpu_stats.vm_memory_quota)": "byte", + "cpu_stats.virt_memory": "byte", "SUM(cpu_stats.virt_memory)": "byte", "MAX(cpu_stats.virt_memory)": "byte", "MIN(cpu_stats.virt_memory)": "byte", + "cpu_stats.peak_virt_memory": "byte", "SUM(cpu_stats.peak_virt_memory)": "byte", "MAX(cpu_stats.peak_virt_memory)": "byte", "MIN(cpu_stats.peak_virt_memory)": "byte", - // msg_info + "msg_info.bytes": "byte", "SUM(msg_info.bytes)": "byte", "MAX(msg_info.bytes)": "byte", "MIN(msg_info.bytes)": "byte", // vn_stats + "vn_stats.in_bytes": "byte", "SUM(vn_stats.in_bytes)": "byte", "MAX(vn_stats.in_bytes)": "byte", "MIN(vn_stats.in_bytes)": "byte", + "vn_stats.out_bytes": "byte", "SUM(vn_stats.out_bytes)": "byte", "MAX(vn_stats.out_bytes)": "byte", "MIN(vn_stats.out_bytes)": "byte", // tx_socket_stats + "tx_socket_stats.bytes": "byte", "SUM(tx_socket_stats.bytes)": "byte", "MAX(tx_socket_stats.bytes)": "byte", "MIN(tx_socket_stats.bytes)": "byte", + "tx_socket_stats.average_bytes": "byte", "SUM(tx_socket_stats.average_bytes)": "byte", "MAX(tx_socket_stats.average_bytes)": "byte", "MIN(tx_socket_stats.average_bytes)": "byte", // rx_socket_stats + "rx_socket_stats.bytes": "byte", "SUM(rx_socket_stats.bytes)": "byte", "MAX(rx_socket_stats.bytes)": "byte", "MIN(rx_socket_stats.bytes)": "byte", + "rx_socket_stats.average_bytes": "byte", "SUM(rx_socket_stats.average_bytes)": "byte", "MAX(rx_socket_stats.average_bytes)": "byte", "MIN(rx_socket_stats.average_bytes)": "byte", // rx_message_stats + "rx_message_stats.bytes": "byte", "SUM(rx_message_stats.bytes)": "byte", "MAX(rx_message_stats.bytes)": "byte", "MIN(rx_message_stats.bytes)": "byte", // virtual_ip_stats + "virtual_ip_stats.bytes_in": "byte", "SUM(virtual_ip_stats.bytes_in)": "byte", "MAX(virtual_ip_stats.bytes_in)": "byte", "MIN(virtual_ip_stats.bytes_in)": "byte", + "virtual_ip_stats.bytes_out": "byte", "SUM(virtual_ip_stats.bytes_out)": "byte", "MAX(virtual_ip_stats.bytes_out)": "byte", "MIN(virtual_ip_stats.bytes_out)": "byte", // pool_stats + "pool_stats.bytes_in": "byte", "SUM(pool_stats.bytes_in)": "byte", "MAX(pool_stats.bytes_in)": "byte", "MIN(pool_stats.bytes_in)": "byte", + "pool_stats.bytes_out": "byte", "SUM(pool_stats.bytes_out)": "byte", "MAX(pool_stats.bytes_out)": "byte", "MIN(pool_stats.bytes_out)": "byte", // member_stats + "member_stats.bytes_in": "byte", "SUM(member_stats.bytes_in)": "byte", "MAX(member_stats.bytes_in)": "byte", "MIN(member_stats.bytes_in)": "byte", + "member_stats.bytes_out": "byte", "SUM(member_stats.bytes_out)": "byte", "MAX(member_stats.bytes_out)": "byte", "MIN(member_stats.bytes_out)": "byte", // fip_diff_stats + "fip_diff_stats.in_bytes": "byte", "SUM(fip_diff_stats.in_bytes)": "byte", "MAX(fip_diff_stats.in_bytes)": "byte", "MIN(fip_diff_stats.in_bytes)": "byte", + "fip_diff_stats.out_bytes": "byte", "SUM(fip_diff_stats.out_bytes)": "byte", "MAX(fip_diff_stats.out_bytes)": "byte", "MIN(fip_diff_stats.out_bytes)": "byte", // if_stats + "if_stats.in_bytes": "byte", "SUM(if_stats.in_bytes)": "byte", "MAX(if_stats.in_bytes)": "byte", "MIN(if_stats.in_bytes)": "byte", + "if_stats.out_bytes": "byte", "SUM(if_stats.out_bytes)": "byte", "MAX(if_stats.out_bytes)": "byte", "MIN(if_stats.out_bytes)": "byte", diff --git a/webroot/js/common/core.formatters.js b/webroot/js/common/core.formatters.js index 0bedf3d65..92bc18085 100644 --- a/webroot/js/common/core.formatters.js +++ b/webroot/js/common/core.formatters.js @@ -7,74 +7,117 @@ define([ ], function (_) { var CoreFormatters = function () { var self = this; - this.getTextGenerator = function (templateGeneratorConfig, key, obj) { - var formatterKey = templateGeneratorConfig.formatter, - value = cowu.getJSONValueByPath(key, obj); - return self.getFormattedValue(formatterKey, value, templateGeneratorConfig.iconClass, obj, key); + this.format = { + 'number': function (value, options) { + var defaultOptions = {formatSpecifier: ',d'}, + options = _.extend(defaultOptions, options); + + return d3.format(options.formatSpecifier)(value) + }, + 'date': function (value, options) { + var defaultOptions = {formatSpecifier: 'llll'}, + options = _.extend(defaultOptions, options); + + return moment(parseInt(value)).format(options.formatSpecifier) + }, + 'micro-date': function (value, options) { + var defaultOptions = {formatSpecifier: 'YYYY-MM-DD HH:mm:ss:SSS'}, + options = _.extend(defaultOptions, options); + + if(value == null || value == 0 || value == '') { + return '' + } else { + return self.format.date(value / 1000, options) + + ':' + ((value % 1000 === 0) ? '0' : value % 1000); + } + }, + 'percentage': function (value, options) { + return value + " %"; + }, + 'length': function (value, options) { + return value.length; + }, + 'byte': function (value, options) { + var defaultOptions = {valueFormat: 'B'}, + options = _.extend(defaultOptions, options), + byteIndex = cowc.BYTE_PREFIX.indexOf(options.valueFormat); + + value = (byteIndex > 0) ? value * (Math.pow(1024,byteIndex)) : value + + return cowu.addUnits2Bytes(value); + }, + 'kilo-byte': function (value, options) { + return cowu.addUnits2Bytes(value * 1024); + }, + 'mega-byte': function (value, options) { + return cowu.addUnits2Bytes(value * 1024 * 1024); + }, + 'time-period': function (value, options) { + var timeValue = parseInt(value), + timeStr = ''; + + if (timeValue === -1) { + timeStr = '-'; + } else { + if (value >= 3600) { + var days = parseInt(timeValue / 3600); + timeStr += days.toString(); + timeStr += (days === 1) ? ' day ' : ' days '; + timeValue = timeValue % 3600; + } + + if (timeValue >= 60) { + var mins = parseInt(timeValue / 60); + timeStr += mins.toString(); + timeStr += (mins === 1) ? ' min ' : ' mins '; + timeValue = timeValue % 60; + } + + if (value > 0) { + var secs = timeValue; + timeStr += secs.toString(); + timeStr += (secs === 1) ? ' sec' : ' secs'; + } + } + + return timeStr; + }, + 'query-time-range': function (value, options) { + return qewu.formatTimeRange(value); + }, + 'query-direction': function (value, options) { + return (value == 0) ? 'EGRESS' : 'INGRESS'; + }, + 'protocol': function (value, options) { + return getProtocolName(value) + } }; - this.getFormattedValue = function (formatterKey, value, iconClass, obj, key) { - if (contrail.checkIfFunction(formatterKey)) { - return formatterKey(value, obj, iconClass, key); + this.getFormattedValue = function (formatterKey, value, options) { + if (!contrail.checkIfExist(value)) { + return ''; + } else if (contrail.checkIfFunction(formatterKey)) { + return formatterKey(value, options); + } else if (_.isArray(formatterKey)) { + var formattedValue = value; + $.each(formatterKey, function(formatIndex, formatObj){ + formattedValue = self.getFormattedValue(formatObj.format, formattedValue, formatObj.options); + }); + return formattedValue; + } else if (contrail.checkIfExist(this.format[formatterKey])) { + return this.format[formatterKey](value, options); } else { - switch (formatterKey) { - case 'byte' : - return cowu.addUnits2Bytes(value); - break; + var obj = contrail.checkIfExist(options) ? options.obj : null, + iconClass = contrail.checkIfExist(options) ? options.iconClass : null, + key = contrail.checkIfExist(options) ? options.key : null; - case 'kilo-byte' : - return cowu.addUnits2Bytes(value * 1024); - break; - - case 'mega-byte' : - return cowu.addUnits2Bytes(value * 1024 * 1024); - break; - - case 'length' : - return value.length; - break; + switch (formatterKey) { case 'throughput' : return formatThroughput(value); break; - case 'percentage' : - return value + " %"; - break; - - case 'date-time' : - return moment(parseInt(value)).format('YYYY-MM-DD HH:mm:ss'); - break; - - case 'time-period' : - var timeValue = parseInt(value), - timeStr = ''; - - if (value >= 3600) { - var days = parseInt(timeValue / 3600); - timeStr += days.toString(); - timeStr += (days === 1) ? ' day ' : ' days '; - timeValue = timeValue % 3600; - } - - if (timeValue >= 60) { - var mins = parseInt(timeValue / 60); - timeStr += mins.toString(); - timeStr += (mins === 1) ? ' min ' : ' mins '; - timeValue = timeValue % 60; - } - - if (value > 0) { - var secs = timeValue; - timeStr += secs.toString(); - timeStr += (secs === 1) ? ' sec' : ' secs'; - } - - return timeStr; - - break; - case 'fault-state' : if (value === true || value === 'true') { return '' + value + ''; @@ -93,7 +136,8 @@ define([ break; case 'health-status-state' : - var iconHTML = (contrail.checkIfExist(iconClass) ? + var iconClass = options.iconClass, + iconHTML = (contrail.checkIfExist(iconClass) ? '' : ''); if (value === 'critical') { @@ -107,6 +151,7 @@ define([ } break; + case 'alert-percentage' : try { if (value != null && value > 90) { @@ -123,13 +168,7 @@ define([ return cowu.addUnits2Packets(value); break; - case 'query-time-range' : - return qewu.formatTimeRange(value); - break; - case 'query-direction' : - return (value == 0) ? 'EGRESS' : 'INGRESS'; - break; //run the user defined formatter function default : @@ -137,7 +176,7 @@ define([ return eval(formatterKey)(value, obj, iconClass, key); } else { //Reg Ex to display comma separated numbers - return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); + return value; } }; } diff --git a/webroot/js/common/core.utils.js b/webroot/js/common/core.utils.js index 573d9c63e..3577fea74 100644 --- a/webroot/js/common/core.utils.js +++ b/webroot/js/common/core.utils.js @@ -636,7 +636,7 @@ define(['underscore'], function (_) { }; this.addUnits2Bytes = function (traffic, noDecimal, maxPrecision, precision, timeInterval) { - var trafficPrefixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'], + var trafficPrefixes = cowc.BYTE_PREFIX, formatStr = '', decimalDigits = 2, size = 1024; if (!$.isNumeric(traffic)) { diff --git a/webroot/js/common/core.views.default.config.js b/webroot/js/common/core.views.default.config.js index f30cb6d6a..6e6c43470 100644 --- a/webroot/js/common/core.views.default.config.js +++ b/webroot/js/common/core.views.default.config.js @@ -50,7 +50,8 @@ define([ lazyLoading: true, defaultDataStatusMessage: true, actionCellPosition: 'end', //actionCellPosition indicates position of the settings icon whether it should be on row start and end - multiRowSelection: true //This property will enable/disable selecting multiple rows of the grid, but the checkbox in the header should be removed by the client because as of now, we don't have way in api to remove the checkbox in header + multiRowSelection: true, //This property will enable/disable selecting multiple rows of the grid, but the checkbox in the header should be removed by the client because as of now, we don't have way in api to remove the checkbox in header + disableRowsOnLoading: false }, dataSource: { remote: null, diff --git a/webroot/js/common/qe.grid.config.js b/webroot/js/common/qe.grid.config.js index 2cbec5ede..084ba7260 100644 --- a/webroot/js/common/qe.grid.config.js +++ b/webroot/js/common/qe.grid.config.js @@ -10,9 +10,14 @@ define([ var newColumnDisplay = [], columnDisplaySelect, columnDisplay = getColumnDisplay4Query(tableName, tableType); - $.each(columnDisplay, function(key, val){ - if (selectArray.indexOf(val.select) != -1) { - newColumnDisplay.push(val.display); + $.each(columnDisplay, function(columnKey, columnValue){ + if (selectArray.indexOf(columnValue.select) != -1) { + if (_.isUndefined(columnValue.display.formatter)) { + columnValue.display.formatter = { + format: cowc.QUERY_COLUMN_FORMATTER[columnValue.select] + }; + } + newColumnDisplay.push(columnValue.display); } }); @@ -27,7 +32,9 @@ define([ id: selectValue, field: selectValue, name: columnName, width: columnName.length * 8, groupable:false, - formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc[selectValue]);} + formatter: { + format: cowc.QUERY_COLUMN_FORMATTER[selectValue] + } }) } @@ -40,9 +47,14 @@ define([ var newColumnDisplay = [], columnDisplaySelect, columnDisplay = getColumnDisplay4Query(tableName, tableType); - $.each(columnDisplay, function(key, val){ - if (selectArray.indexOf(val.select) != -1 && !qewu.isAggregateField(val.select) && val.select !== 'T' && val.select !== 'T=' && val.select !== 'UUID') { - newColumnDisplay.push(val.display); + $.each(columnDisplay, function(columnKey, columnValue){ + if (selectArray.indexOf(columnValue.select) != -1 && !qewu.isAggregateField(columnValue.select) && columnValue.select !== 'T' && columnValue.select !== 'T=' && columnValue.select !== 'UUID') { + if (_.isUndefined(columnValue.display.formatter)) { + columnValue.display.formatter = { + format: cowc.QUERY_COLUMN_FORMATTER[columnValue.select] + }; + } + newColumnDisplay.push(columnValue.display); } }); @@ -58,7 +70,9 @@ define([ id: selectValue, field: selectValue, name: columnName, width: columnName.length * 8, groupable:false, - formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc[selectValue]);} + formatter: { + format: cowc.QUERY_COLUMN_FORMATTER[selectValue] + } }) } @@ -92,7 +106,13 @@ define([ } } }, - { id:"startTime", field:"startTime", name:"Time Issued", width: 140, formatter: function(r, c, v, cd, dc) { return moment(dc.startTime).format('YYYY-MM-DD HH:mm:ss'); } }, + { + id:"startTime", field:"startTime", name:"Time Issued", width: 140, + formatter: { + format: 'date', + options: {formatSpecifier: 'llll'} + } + }, { id:"table_name", field:"", name:"Table Name", width: 200, sortable:false, formatter: function(r, c, v, cd, dc) { @@ -100,20 +120,43 @@ define([ } }, { - id:"", field:"", name:"Time Range", width: 100, sortable:false, - formatter: function(r, c, v, cd, dc) { - return qewu.formatTimeRange(dc.queryReqObj.formModelAttrs.time_range); + id:"time_range", field:"time_range", name:"Time Range", width: 100, sortable:false, + formatter: { + format: 'query-time-range', + path: 'queryReqObj.formModelAttrs.time_range' + } + }, + { + id:"fromTime", field:"fromTime", name:"From Time", width: 140, + formatter: { + format: 'date', + path: 'queryReqObj.formModelAttrs.from_time_utc', + options: { + formatSpecifier: 'lll' + } + } + }, + { + id:"toTime", field:"toTime", name:"To Time", width: 140, + formatter: { + format: 'date', + path: 'queryReqObj.formModelAttrs.to_time_utc', + options: { + formatSpecifier: 'lll' + } } }, - { id:"fromTime", field:"fromTime", name:"From Time", width: 140, formatter: function(r, c, v, cd, dc) { return moment(dc.queryReqObj.formModelAttrs.from_time_utc).format('YYYY-MM-DD HH:mm:ss'); } }, - { id:"toTime", field:"toTime", name:"To Time", width: 140, formatter: function(r, c, v, cd, dc) { return moment(dc.queryReqObj.formModelAttrs.to_time_utc).format('YYYY-MM-DD HH:mm:ss'); } }, { id:"progress", field:"progress", name:"Progress", width:75, formatter: function(r, c, v, cd, dc) { return (dc.status != 'error' && dc.progress != '' && parseInt(dc.progress) > 0) ? (dc.progress + '%') : '-'; } }, - { id:"count", field:"count", name:"Records", width:75 }, + { id:"count", field:"count", name:"Records", width:75, + formatter: { + format: 'number' + } + }, { id:"status", field:"status", name:"Status", width:90 }, { id:"timeTaken", field:"timeTaken", name:"Time Taken", width:100, sortable:true, - formatter: function(r, c, v, cd, dc) { - return (dc.timeTaken == -1) ? '-' : cowf.getFormattedValue('time-period', dc.timeTaken); + formatter: { + format:'time-period' } } ]; @@ -151,17 +194,17 @@ define([ var columnDisplayMap = { "FlowSeriesTable": [ - {select:"T", display:{id:"T", field:"T", width:210, name:"Time", formatter: function(r, c, v, cd, dc){ return cowu.formatMicroDate(dc.T);}, filterable:false, groupable:false}}, - {select:"T=", display:{id:"T", field:"T", width:210, name:"Time", formatter: function(r, c, v, cd, dc){ return cowu.formatMicroDate(dc.T);}, filterable:false, groupable:false}}, - {select:"vrouter", display:{id:"vrouter",field:"vrouter", width:100, name:"Virtual Router", groupable:false, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.vrouter);}}}, - {select:"sourcevn", display:{id:"sourcevn",field:"sourcevn", width:240, name:"Source VN", groupable:false, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.sourcevn);}}}, - {select:"destvn", display:{id:"destvn", field:"destvn", width:240, name:"Destination VN", groupable:false, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.destvn);}}}, - {select:"sourceip", display:{id:"sourceip", field:"sourceip", width:100, name:"Source IP", groupable:false, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.sourceip);}}}, - {select:"destip", display:{id:"destip", field:"destip", width:120, name:"Destination IP", groupable:false, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.destip);}}}, - {select:"sport", display:{id:"sport", field:"sport", width:100, name:"Source Port", groupable:false, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.sport);}}}, - {select:"dport", display:{id:"dport", field:"dport", width:130, name:"Destination Port", groupable:false, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.dport);}}}, - {select:"direction_ing", display:{id:"direction_ing", field:"direction_ing", width:100, name:"Direction", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(getDirName(dc.direction_ing));}}}, - {select:"protocol", display:{id:"protocol", field:"protocol", width:100, name:"Protocol", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(getProtocolName(dc.protocol));}}}, + {select:"T", display:{id:"T", field:"T", width:210, name:"Time", filterable:false, groupable:false}}, + {select:"T=", display:{id:"T", field:"T", width:210, name:"Time", filterable:false, groupable:false}}, + {select:"vrouter", display:{id:"vrouter",field:"vrouter", width:100, name:"Virtual Router", groupable:false}}, + {select:"sourcevn", display:{id:"sourcevn",field:"sourcevn", width:240, name:"Source VN", groupable:false}}, + {select:"destvn", display:{id:"destvn", field:"destvn", width:240, name:"Destination VN", groupable:false}}, + {select:"sourceip", display:{id:"sourceip", field:"sourceip", width:100, name:"Source IP", groupable:false}}, + {select:"destip", display:{id:"destip", field:"destip", width:120, name:"Destination IP", groupable:false}}, + {select:"sport", display:{id:"sport", field:"sport", width:100, name:"Source Port", groupable:false}}, + {select:"dport", display:{id:"dport", field:"dport", width:130, name:"Destination Port", groupable:false}}, + {select:"direction_ing", display:{id:"direction_ing", field:"direction_ing", width:100, name:"Direction", groupable:true}}, + {select:"protocol", display:{id:"protocol", field:"protocol", width:100, name:"Protocol", groupable:true}}, {select:"bytes", display:{id:"bytes", field:"bytes", width:120, name:"Bytes", groupable:false}}, {select:"sum(bytes)", display:{id:"sum(bytes)", field:"sum(bytes)", width:100, name:"SUM (Bytes)", groupable:false}}, {select:"avg(bytes)", display:{id:"avg(bytes)", field:"avg(bytes)", width:100, name:"AVG (Bytes)", groupable:false}}, @@ -172,24 +215,24 @@ define([ ], "FlowRecordTable": [ {select:"action", display:{id:"action", field:"action", width:60, name:"Action", groupable:true}}, - {select:"setup_time", display:{id:"setup_time", field:"setup_time", width:210, name:"Setup Time", formatter: function(r, c, v, cd, dc){ return cowu.formatMicroDate(dc.setup_time); }, filterable:false, groupable:false}}, - {select:"teardown_time", display:{id:"teardown_time", field:"teardown_time", width:210, name:"Teardown Time", formatter: function(r, c, v, cd, dc){ return cowu.formatMicroDate(dc.teardown_time); }, filterable:false, groupable:false}}, - {select:"vrouter", display:{id:"vrouter", field:"vrouter", width:100, name:"Virtual Router", groupable:false, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.vrouter);}}}, - {select:"vrouter_ip", display:{id:"vrouter_ip", field:"vrouter_ip", width:120, name:"Virtual Router IP", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.vrouter_ip);}}}, - {select:"other_vrouter_ip", display:{id:"other_vrouter_ip", field:"other_vrouter_ip", width:170, name:"Other Virtual Router IP", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.other_vrouter_ip);}}}, - {select:"sourcevn", display:{id:"sourcevn", field:"sourcevn", width:240, name:"Source VN", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.sourcevn);}}}, - {select:"destvn", display:{id:"destvn", field:"destvn", width:240, name:"Destination VN", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.destvn);}}}, - {select:"sourceip", display:{id:"sourceip", field:"sourceip", width:100, name:"Source IP", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.sourceip);}}}, - {select:"destip", display:{id:"destip", field:"destip", width:120, name:"Destination IP", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.destip);}}}, - {select:"sport", display:{id:"sport", field:"sport", width:100, name:"Source Port", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.sport);}}}, - {select:"dport", display:{id:"dport", field:"dport", width:130, name:"Destination Port", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.dport);}}}, - {select:"direction_ing", display:{id:"direction_ing", field:"direction_ing", width:100, name:"Direction", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(getDirName(dc.direction_ing));}}}, - {select:"protocol", display:{id:"protocol", field:"protocol", width:100, name:"Protocol", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(getProtocolName(dc.protocol));}}}, - {select:"underlay_proto", display:{id:"underlay_proto", field:"underlay_proto", width:150, name:"Underlay Protocol", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.underlay_proto);}}}, - {select:"underlay_source_port", display:{id:"underlay_source_port", field:"underlay_source_port", width:150, name:"Underlay Source Port", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.underlay_source_port);}}}, - {select:"UuidKey", display:{id:"UuidKey", field:"UuidKey", width:280, name:"UUID", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.UuidKey);}}}, - {select:"sg_rule_uuid", display:{id:"sg_rule_uuid", field:"sg_rule_uuid", width:280, name:"Rule UUID", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.sg_rule_uuid);}}}, - {select:"nw_ace_uuid", display:{id:"nw_ace_uuid", field:"nw_ace_uuid", width:280, name:"Network UUID", groupable:true, formatter: function(r, c, v, cd, dc){ return cowu.handleNull4Grid(dc.nw_ace_uuid);}}}, + {select:"setup_time", display:{id:"setup_time", field:"setup_time", width:210, name:"Setup Time", filterable:false, groupable:false}}, + {select:"teardown_time", display:{id:"teardown_time", field:"teardown_time", width:210, name:"Teardown Time", filterable:false, groupable:false}}, + {select:"vrouter", display:{id:"vrouter", field:"vrouter", width:100, name:"Virtual Router", groupable:false}}, + {select:"vrouter_ip", display:{id:"vrouter_ip", field:"vrouter_ip", width:120, name:"Virtual Router IP", groupable:true}}, + {select:"other_vrouter_ip", display:{id:"other_vrouter_ip", field:"other_vrouter_ip", width:170, name:"Other Virtual Router IP", groupable:true}}, + {select:"sourcevn", display:{id:"sourcevn", field:"sourcevn", width:240, name:"Source VN", groupable:true}}, + {select:"destvn", display:{id:"destvn", field:"destvn", width:240, name:"Destination VN", groupable:true}}, + {select:"sourceip", display:{id:"sourceip", field:"sourceip", width:100, name:"Source IP", groupable:true}}, + {select:"destip", display:{id:"destip", field:"destip", width:120, name:"Destination IP", groupable:true}}, + {select:"sport", display:{id:"sport", field:"sport", width:100, name:"Source Port", groupable:true}}, + {select:"dport", display:{id:"dport", field:"dport", width:130, name:"Destination Port", groupable:true}}, + {select:"direction_ing", display:{id:"direction_ing", field:"direction_ing", width:100, name:"Direction", groupable:true}}, + {select:"protocol", display:{id:"protocol", field:"protocol", width:100, name:"Protocol", groupable:true}}, + {select:"underlay_proto", display:{id:"underlay_proto", field:"underlay_proto", width:150, name:"Underlay Protocol", groupable:true}}, + {select:"underlay_source_port", display:{id:"underlay_source_port", field:"underlay_source_port", width:150, name:"Underlay Source Port", groupable:true}}, + {select:"UuidKey", display:{id:"UuidKey", field:"UuidKey", width:280, name:"UUID", groupable:true}}, + {select:"sg_rule_uuid", display:{id:"sg_rule_uuid", field:"sg_rule_uuid", width:280, name:"Rule UUID", groupable:true}}, + {select:"nw_ace_uuid", display:{id:"nw_ace_uuid", field:"nw_ace_uuid", width:280, name:"Network UUID", groupable:true}}, {select:"agg-bytes", display:{id:"agg-bytes", field:"agg-bytes", width:120, name:"Aggregate Bytes", groupable:false}}, {select:"agg-packets", display:{id:"agg-packets", field:"agg-packets", width:140, name:"Aggregate Packets", groupable:false}}, {select:"vmi_uuid", display:{id:"vmi_uuid", field:"vmi_uuid", width:140, name:"VMI UUID", groupable:false}}, @@ -1799,18 +1842,18 @@ define([ {select:"MAX(egressRqeQueue.rqeBufferCount)", display:{id:'MAX(egressRqeQueue.rqeBufferCount)', field:'MAX(egressRqeQueue.rqeBufferCount)', width:200, name:"MAX (Rqe Buffer Count)", groupable:false}}, ], "defaultStatColumns": [ - {select:"T", display:{id:"T", field:"T", width:210, name:"Time", formatter: function(r, c, v, cd, dc) { return cowu.formatMicroDate(dc.T); }, filterable:false, groupable:false}}, - {select:"T=", display:{id: 'T=', field:'["T="]', width:210, name:"Time", formatter: function(r, c, v, cd, dc) { return cowu.formatMicroDate(dc['T=']); }, filterable:false, groupable:false}}, + {select:"T", display:{id:"T", field:"T", width:210, name:"Time", filterable:false, groupable:false}}, + {select:"T=", display:{id: 'T=', field:'T=', width:210, name:"Time", filterable:false, groupable:false}}, {select:"UUID", display:{id:"UUID", field:"UUID", name:"UUID", width:150, groupable:true}}, {select:"name", display:{id:'name', field:'name', width:150, name:"Name", groupable:false}}, {select:"Source", display:{id:'Source', field:'Source', width:70, name:"Source", groupable:false}} ], "defaultObjectColumns": [ - {select: "MessageTS", display:{id: "MessageTS", field: "MessageTS", name: "Time", width:210, filterable:false, groupable:false, formatter: function(r, c, v, cd, dc) { return (dc.MessageTS && dc.MessageTS != '') ? (cowu.formatMicroDate(dc.MessageTS)) : ''; }}}, - {select: "ObjectId", display:{id:"ObjectId", field:"ObjectId", name:"Object Id", width:150, searchable: true, formatter: function(r, c, v, cd, dc) { return cowu.handleNull4Grid(dc.ObjectId);}, hide: true}}, - {select: "Source", display:{id:"Source", field:"Source", name:"Source", width:150, searchable: true, formatter: function(r, c, v, cd, dc) { return cowu.handleNull4Grid(dc.Source);}}}, - {select: "ModuleId", display:{id: "ModuleId", field: "ModuleId", name: "Module Id", width: 150, searchable:true, formatter: function(r, c, v, cd, dc) { return cowu.handleNull4Grid(dc.ModuleId);}}}, - {select: "Messagetype", display:{id:"Messagetype", field:"Messagetype", name:"Message Type", width:300, searchable:true, formatter: function(r, c, v, cd, dc) { return cowu.handleNull4Grid(dc.Messagetype); }}}, + {select: "MessageTS", display:{id: "MessageTS", field: "MessageTS", name: "Time", width:210, filterable:false, groupable:false}}, + {select: "ObjectId", display:{id:"ObjectId", field:"ObjectId", name:"Object Id", width:150, searchable: true, hide: true}}, + {select: "Source", display:{id:"Source", field:"Source", name:"Source", width:150, searchable: true}}, + {select: "ModuleId", display:{id: "ModuleId", field: "ModuleId", name: "Module Id", width: 150, searchable:true}}, + {select: "Messagetype", display:{id:"Messagetype", field:"Messagetype", name:"Message Type", width:300, searchable:true}}, { select: "ObjectLog", display:{ @@ -1851,15 +1894,15 @@ define([ } ], "MessageTable": [ - {select: "MessageTS", display:{id: "MessageTS", field: "MessageTS", name: "Time", width:210, filterable:false, groupable:false, formatter: function(r, c, v, cd, dc) { return (dc.MessageTS && dc.MessageTS != '') ? (cowu.formatMicroDate(dc.MessageTS)) : ''; }}}, - {select: "Source", display:{id:"Source", field:"Source", name:"Source", width:150, searchable: true, formatter: function(r, c, v, cd, dc) { return cowu.handleNull4Grid(dc.Source);}}}, - {select: "NodeType", display:{id:"NodeType", field:"NodeType", name:"Node Type", width:100, searchable: true, formatter: function(r, c, v, cd, dc) { return cowu.handleNull4Grid(dc.NodeType);}}}, - {select: "ModuleId", display:{id: "ModuleId", field: "ModuleId", name: "Module Id", width: 150, searchable:true, formatter: function(r, c, v, cd, dc) { return cowu.handleNull4Grid(dc.ModuleId);}}}, - {select: "Messagetype", display:{id:"Messagetype", field:"Messagetype", name:"Message Type", width:200, searchable:true, formatter: function(r, c, v, cd, dc) { return cowu.handleNull4Grid(dc.Messagetype); }}}, - {select: "Keyword", display:{id:"Keyword", field:"Keyword", name:"Keyword", width:150, searchable:true, formatter: function(r, c, v, cd, dc) { return cowu.handleNull4Grid(dc.Keyword); }}}, + {select: "MessageTS", display:{id: "MessageTS", field: "MessageTS", name: "Time", width:210, filterable:false, groupable:false}}, + {select: "Source", display:{id:"Source", field:"Source", name:"Source", width:150, searchable: true}}, + {select: "NodeType", display:{id:"NodeType", field:"NodeType", name:"Node Type", width:100, searchable: true}}, + {select: "ModuleId", display:{id: "ModuleId", field: "ModuleId", name: "Module Id", width: 150, searchable:true}}, + {select: "Messagetype", display:{id:"Messagetype", field:"Messagetype", name:"Message Type", width:200, searchable:true}}, + {select: "Keyword", display:{id:"Keyword", field:"Keyword", name:"Keyword", width:150, searchable:true}}, {select: "Level", display:{id:"Level", field:"Level", name:"Level", width:100, searchable:true, formatter: function(r, c, v, cd, dc) { return qewu.getLevelName4Value(dc.Level); }}}, - {select: "Category", display:{id: "Category", field: "Category", name: "Category", width: 150, searchable:true, formatter: function(r, c, v, cd, dc) { return cowu.handleNull4Grid(dc.Category);}}}, - {select: "Context", display:{id:"Context", field:"Context", name:"Context", width:150, searchable:true, formatter: function(r, c, v, cd, dc) { return cowu.handleNull4Grid(dc.Context); }}}, + {select: "Category", display:{id: "Category", field: "Category", name: "Category", width: 150, searchable:true}}, + {select: "Context", display:{id:"Context", field:"Context", name:"Context", width:150, searchable:true}}, { select: "Xmlmessage", display:{ @@ -1887,7 +1930,7 @@ define([ } } }, - {select: "InstanceId", display:{id: "InstanceId", field: "InstanceId", name: "Instance Id", width: 150, searchable:true, formatter: function(r, c, v, cd, dc) { return cowu.handleNull4Grid(dc.InstanceId);}}} + {select: "InstanceId", display:{id: "InstanceId", field: "InstanceId", name: "Instance Id", width: 150, searchable:true}} ] }; diff --git a/webroot/js/common/qe.utils.js b/webroot/js/common/qe.utils.js index fd31f69eb..c278d30ec 100644 --- a/webroot/js/common/qe.utils.js +++ b/webroot/js/common/qe.utils.js @@ -226,17 +226,17 @@ define([ var chartDataValues = chartDataRow.values, newChartDataValues = {}, emptyChartDataValue = {}, - toTime = queryFormAttributes.to_time_utc, - fromTime = queryFormAttributes.from_time_utc, timeGranularity = queryFormAttributes.time_granularity, timeGranularityUnit = queryFormAttributes.time_granularity_unit, - timeInterval = timeGranularity * cowc.TIME_GRANULARITY_INTERVAL_VALUES[timeGranularityUnit]; + timeInterval = timeGranularity * cowc.TIME_GRANULARITY_INTERVAL_VALUES[timeGranularityUnit], + toTime = queryFormAttributes.to_time_utc, + fromTime = queryFormAttributes.from_time_utc; $.each(plotFields, function(plotFieldKey, plotFieldValue) { emptyChartDataValue[plotFieldValue] = 0; }); - for (var i = fromTime; i <= toTime; i += timeInterval) { + for (var i = fromTime; i < toTime; i += timeInterval) { if (!contrail.checkIfExist(chartDataValues[i])) { newChartDataValues[i] = emptyChartDataValue } else { diff --git a/webroot/js/contrail-common.js b/webroot/js/contrail-common.js index c384a09b3..6a004ebc2 100644 --- a/webroot/js/contrail-common.js +++ b/webroot/js/contrail-common.js @@ -102,6 +102,21 @@ function Contrail() { } } }; + this.getObjectValueByPath = function(valueObject, pathString) { + var pathArray = pathString.split('.'), + returnValue = valueObject; + + $.each(pathArray, function (pathKey, pathValue) { + if (contrail.checkIfExist(returnValue[pathValue])) { + returnValue = returnValue[pathValue]; + } else { + returnValue = null; + return; + } + }); + + return returnValue + }; this.parseErrorMsgFromXHR = function(xhr) { var errorMsg = ''; if(contrail.checkIfExist(xhr.errorThrown)) { diff --git a/webroot/js/contrail-elements.js b/webroot/js/contrail-elements.js index 362354923..f153f3152 100644 --- a/webroot/js/contrail-elements.js +++ b/webroot/js/contrail-elements.js @@ -836,7 +836,11 @@ control: false, selectedList: 3, tristate: false, - emptyOptionText: 'No option found.' + emptyOptionText: 'No option found.', + position: { + my: 'left top', + at: 'left bottom' + } }, defaultFilterConfig = { label: false @@ -905,6 +909,19 @@ multiSelectMenu.append(msControls); } + var closeFn = function(event) { + var positionTop = multiSelectMenu.position().top, + scrollTop = $(this).scrollTop(); + + if (multiSelectMenu.is(':visible') && (positionTop - scrollTop) < 40) { + self.find('select').multiselect('close'); + } + }; + + $(window) + .off('scroll', closeFn) + .on('scroll', closeFn); + self.data('contrailCheckedMultiselect', $.extend(true, getDefaultMultiselectMethods(), { getPreChecked: function () { return preChecked; diff --git a/webroot/js/handlebars-utils.js b/webroot/js/handlebars-utils.js index 02708054b..2883398b1 100644 --- a/webroot/js/handlebars-utils.js +++ b/webroot/js/handlebars-utils.js @@ -221,7 +221,14 @@ Handlebars.registerHelper('getValueByConfig', function (obj, options) { switch (templateGenerator) { case 'TextGenerator': if (contrail.checkIfExist(templateGeneratorConfig)) { - return cowf.getTextGenerator(templateGeneratorConfig, key, obj); + var formatterKey = templateGeneratorConfig.formatter, + options = { + iconClass: templateGeneratorConfig.iconClass, + obj: obj, + key: key + }; + + return cowf.getFormattedValue(formatterKey, value, options); } else { returnValue = $.isArray(value) ? value.join(', ') : value; } diff --git a/webroot/js/views/GridView.js b/webroot/js/views/GridView.js index f980b5e39..2082625b6 100644 --- a/webroot/js/views/GridView.js +++ b/webroot/js/views/GridView.js @@ -66,6 +66,13 @@ define([ dataView.setData(dataViewData); } + if (contrailListModel.isRequestInProgress()) { + gridContainer.addClass('grid-state-fetching'); + if (gridOptions.disableRowsOnLoading) { + gridContainer.addClass('grid-state-fetching-rows'); + } + } + if (contrailListModel.loadedFromCache || !(contrailListModel.isRequestInProgress())) { if (contrail.checkIfExist(gridContainer.data('contrailGrid'))) { gridContainer.data('contrailGrid').removeGridLoading(); @@ -217,28 +224,32 @@ define([ e.stopPropagation(); break; case 'refresh': - gridContainer.find('.link-refreshable i').removeClass('icon-repeat').addClass('icon-spin icon-spinner'); - gridContainer.data('contrailGrid').refreshData(); + if (!contrailListModel.isRequestInProgress()) { + gridContainer.find('.link-refreshable i').removeClass('icon-repeat').addClass('icon-spin icon-spinner'); + gridContainer.data('contrailGrid').refreshData(); + } break; case 'export': - var gridDSConfig = gridDataSource, - gridData = [], dv; - - gridContainer.find('a[data-action="export"] i').removeClass('icon-download-alt').addClass('icon-spin icon-spinner'); - gridContainer.find('a[data-action="export"]').prop('title', 'Exporting...').data('action', 'exporting').addClass('blue'); - if (contrail.checkIfExist(gridDSConfig.remote) && gridDSConfig.remote.serverSidePagination) { - var exportCB = gridDSConfig.remote.exportFunction; - if (exportCB != null) { - exportCB(gridConfig, gridContainer); + if (!contrailListModel.isRequestInProgress()) { + var gridDSConfig = gridDataSource, + gridData = [], dv; + + gridContainer.find('a[data-action="export"] i').removeClass('icon-download-alt').addClass('icon-spin icon-spinner'); + gridContainer.find('a[data-action="export"]').prop('title', 'Exporting...').data('action', 'exporting').addClass('blue'); + if (contrail.checkIfExist(gridDSConfig.remote) && gridDSConfig.remote.serverSidePagination) { + var exportCB = gridDSConfig.remote.exportFunction; + if (exportCB != null) { + exportCB(gridConfig, gridContainer); + } + } else { + dv = gridContainer.data('contrailGrid')._dataView; + gridData = dv.getItems(); + exportGridData2CSV(gridConfig, gridData); + setTimeout(function () { + gridContainer.find('a[data-action="export"] i').addClass('icon-download-alt').removeClass('icon-spin icon-spinner'); + gridContainer.find('a[data-action="export"]').prop('title', 'Export as CSV').data('action', 'export').removeClass('blue'); + }, 500); } - } else { - dv = gridContainer.data('contrailGrid')._dataView; - gridData = dv.getItems(); - exportGridData2CSV(gridConfig, gridData); - setTimeout(function () { - gridContainer.find('a[data-action="export"] i').addClass('icon-download-alt').removeClass('icon-spin icon-spinner'); - gridContainer.find('a[data-action="export"]').prop('title', 'Export as CSV').data('action', 'export').removeClass('blue'); - }, 500); } break; case 'collapse': @@ -271,22 +282,36 @@ define([ }); } - $.each(gridColumns, function (key, val) { + $.each(gridColumns, function (columnKey, columnValue) { // Setting sortable:true for columns wherever necessary if (gridOptions.sortable != false) { - if (!contrail.checkIfExist(val.sortable)) { - gridColumns[key].sortable = true; + if (!contrail.checkIfExist(columnValue.sortable)) { + gridColumns[columnKey].sortable = true; } - if (contrail.checkIfExist(gridOptions.sortable.defaultSortCols) && contrail.checkIfExist(gridOptions.sortable.defaultSortCols[val.field])) { - gridOptions.sortable.defaultSortCols[val.field].sortCol = val; + if (contrail.checkIfExist(gridOptions.sortable.defaultSortCols) && contrail.checkIfExist(gridOptions.sortable.defaultSortCols[columnValue.field])) { + gridOptions.sortable.defaultSortCols[columnValue.field].sortCol = columnValue; } } else { - gridColumns[key].sortable = false; + gridColumns[columnKey].sortable = false; } - if (!contrail.checkIfExist(gridColumns[key].id)) { - gridColumns[key].id = val.field + '_' + key; + if ($.isPlainObject(columnValue.formatter)) { + columnValue.formatterObj = _.clone(columnValue.formatter) + columnValue.formatter = function (r, c, v, cd, dc) { + var formatterObj = columnValue.formatterObj, + fieldValue = dc[columnValue.field]; + + if (contrail.checkIfExist(formatterObj.path)) { + fieldValue = contrail.getObjectValueByPath(dc, formatterObj.path); + } + + return cowf.getFormattedValue(formatterObj.format, fieldValue, formatterObj.options); + }; + } + + if (!contrail.checkIfExist(gridColumns[columnKey].id)) { + gridColumns[columnKey].id = columnValue.field + '_' + columnKey; } }); }; @@ -343,22 +368,24 @@ define([ var target = e.target; if ($(target).hasClass('icon-caret-right')) { - if (!$(target).parents('.slick-row-master').next().hasClass('slick-row-detail')) { + if (!$(target).parents('.slick-row-master').next().hasClass('slick-row-detail') || $(target).parents('.slick-row-master').next().hasClass('slick-row-detail-state-fetching')) { + $(target).parents('.slick-row-master').next('.slick-row-detail').remove(); var cellSpaceColumn = 0, - cellSpaceRow = gridColumns.length - 1; + cellSpaceRow = gridColumns.length - 1, + fetchingCSSClass = (contrailListModel.isRequestInProgress() ? ' slick-row slick-row-detail-state-fetching' : ''); //if (gridOptions.checkboxSelectable != false) { // cellSpaceColumn++; //} $(target).parents('.slick-row-master').after(' \ -
\ -
\ -
\ -
\ -
\ -
\ -
'); +
\ +
\ +
\ +
\ +
\ +
\ +
'); $(target).parents('.slick-row-master').next('.slick-row-detail').find('.slick-row-detail-container').show(); @@ -368,6 +395,7 @@ define([ gridOptions.detail.onInit(e, dc); } refreshDetailTemplateById($(target).parents('.slick-row-master').data('cgrid')); + } else { $(target).parents('.slick-row-master').next('.slick-row-detail').show(); @@ -589,77 +617,79 @@ define([ grid['onHeaderClick'].subscribe(eventHandlerMap.grid['onHeaderClick']); eventHandlerMap.grid['onClick'] = function (e, args) { - var column = grid.getColumns()[args.cell], - rowData = grid.getDataItem(args.row); - gridContainer.data('contrailGrid').selectedRow = args.row; - gridContainer.data('contrailGrid').selectedCell = args.cell; - - if (contrail.checkIfExist(gridConfig.body.events) && contrail.checkIfFunction(gridConfig.body.events.onClick)) { - gridConfig.body.events.onClick(e, rowData); - } - - if (contrail.checkIfExist(column.events) && contrail.checkIfFunction(column.events.onClick)) { - column.events.onClick(e, rowData); - } - - if (gridOptions.rowSelectable) { - if (!gridContainer.find('.slick_row_' + rowData.cgrid).hasClass('selected_row')) { - gridContainer.find('.selected_row').removeClass('selected_row'); - gridContainer.find('.slick_row_' + rowData.cgrid).addClass('selected_row'); + if (!gridOptions.disableRowsOnLoading || (gridOptions.disableRowsOnLoading && !contrailListModel.isRequestInProgress())) { + var column = grid.getColumns()[args.cell], + rowData = grid.getDataItem(args.row); + gridContainer.data('contrailGrid').selectedRow = args.row; + gridContainer.data('contrailGrid').selectedCell = args.cell; + + if (contrail.checkIfExist(gridConfig.body.events) && contrail.checkIfFunction(gridConfig.body.events.onClick)) { + gridConfig.body.events.onClick(e, rowData); } - } - setTimeout(function () { - if (gridContainer.data('contrailGrid') != null) - gridContainer.data('contrailGrid').adjustRowHeight(rowData.cgrid); - }, 50); + if (contrail.checkIfExist(column.events) && contrail.checkIfFunction(column.events.onClick)) { + column.events.onClick(e, rowData); + } - if ($(e.target).hasClass("grid-action-dropdown")) { - if ($('#' + gridContainer.prop('id') + '-action-menu-' + args.row).is(':visible')) { - $('#' + gridContainer.prop('id') + '-action-menu-' + args.row).remove(); - } else { - $('.grid-action-menu').remove(); - var actionCellArray = []; - if (contrail.checkIfFunction(gridOptions.actionCell.optionList)) { - actionCellArray = gridOptions.actionCell.optionList(rowData); - } else { - actionCellArray = gridOptions.actionCell.optionList; + if (gridOptions.rowSelectable) { + if (!gridContainer.find('.slick_row_' + rowData.cgrid).hasClass('selected_row')) { + gridContainer.find('.selected_row').removeClass('selected_row'); + gridContainer.find('.slick_row_' + rowData.cgrid).addClass('selected_row'); } + } + + setTimeout(function () { + if (gridContainer.data('contrailGrid') != null) + gridContainer.data('contrailGrid').adjustRowHeight(rowData.cgrid); + }, 50); - //$('#' + gridContainer.prop('id') + '-action-menu').remove(); - addGridRowActionDroplist(actionCellArray, gridContainer, args.row, $(e.target)); - var offset = $(e.target).offset(), actionCellStyle = ''; - if (gridOptions.actionCellPosition == 'start') { - actionCellStyle = 'top:' + (offset.top + 20) + 'px' + ';right:auto !important;left:' + offset.left + 'px !important;'; + if ($(e.target).hasClass("grid-action-dropdown")) { + if ($('#' + gridContainer.prop('id') + '-action-menu-' + args.row).is(':visible')) { + $('#' + gridContainer.prop('id') + '-action-menu-' + args.row).remove(); } else { - actionCellStyle = 'top:' + (offset.top + 20) + 'px' + ';left:' + (offset.left - 155) + 'px;'; - } - $('#' + gridContainer.prop('id') + '-action-menu-' + args.row).attr('style', function (idx, obj) { - if (obj != null) { - return obj + actionCellStyle; + $('.grid-action-menu').remove(); + var actionCellArray = []; + if (contrail.checkIfFunction(gridOptions.actionCell.optionList)) { + actionCellArray = gridOptions.actionCell.optionList(rowData); } else { - return actionCellStyle; + actionCellArray = gridOptions.actionCell.optionList; } - }).show(function () { - var dropdownHeight = $('#' + gridContainer.prop('id') + '-action-menu-' + args.row).height(), - windowHeight = $(window).height(), - currentScrollPosition = $(window).scrollTop(), - actionScrollPosition = offset.top + 20 - currentScrollPosition; - - if ((actionScrollPosition + dropdownHeight) > windowHeight) { - window.scrollTo(0, (actionScrollPosition + dropdownHeight) - windowHeight + currentScrollPosition); + + //$('#' + gridContainer.prop('id') + '-action-menu').remove(); + addGridRowActionDroplist(actionCellArray, gridContainer, args.row, $(e.target)); + var offset = $(e.target).offset(), actionCellStyle = ''; + if (gridOptions.actionCellPosition == 'start') { + actionCellStyle = 'top:' + (offset.top + 20) + 'px' + ';right:auto !important;left:' + offset.left + 'px !important;'; + } else { + actionCellStyle = 'top:' + (offset.top + 20) + 'px' + ';left:' + (offset.left - 155) + 'px;'; } - }); - e.stopPropagation(); - initOnClickDocument('#' + gridContainer.prop('id') + '-action-menu-' + args.row, function () { - $('#' + gridContainer.prop('id') + '-action-menu-' + args.row).hide(); - }); + $('#' + gridContainer.prop('id') + '-action-menu-' + args.row).attr('style', function (idx, obj) { + if (obj != null) { + return obj + actionCellStyle; + } else { + return actionCellStyle; + } + }).show(function () { + var dropdownHeight = $('#' + gridContainer.prop('id') + '-action-menu-' + args.row).height(), + windowHeight = $(window).height(), + currentScrollPosition = $(window).scrollTop(), + actionScrollPosition = offset.top + 20 - currentScrollPosition; + + if ((actionScrollPosition + dropdownHeight) > windowHeight) { + window.scrollTo(0, (actionScrollPosition + dropdownHeight) - windowHeight + currentScrollPosition); + } + }); + e.stopPropagation(); + initOnClickDocument('#' + gridContainer.prop('id') + '-action-menu-' + args.row, function () { + $('#' + gridContainer.prop('id') + '-action-menu-' + args.row).hide(); + }); + } } - } - if ($(e.target).hasClass("grid-action-link")) { - if (gridOptions.actionCell.type == 'link') { - gridOptions.actionCell.onclick(e, args); + if ($(e.target).hasClass("grid-action-link")) { + if (gridOptions.actionCell.type == 'link') { + gridOptions.actionCell.onclick(e, args); + } } } }; @@ -951,6 +981,8 @@ define([ }, removeGridLoading: function () { gridContainer.find('.grid-header-icon-loading').hide(); + gridContainer.removeClass('grid-state-fetching'); + gridContainer.removeClass('grid-state-fetching-rows'); }, adjustAllRowHeight: function () { diff --git a/webroot/js/views/QueryResultLineChartView.js b/webroot/js/views/QueryResultLineChartView.js index 17786e328..691eaa044 100644 --- a/webroot/js/views/QueryResultLineChartView.js +++ b/webroot/js/views/QueryResultLineChartView.js @@ -32,7 +32,7 @@ define([ chartAxesOptions = {}; $.each(aggregateSelectFields, function(selectFieldKey, selectFieldValue) { - var yFormatterKey = cowc.MAP_Y_FORMATTER[selectFieldValue]; + var yFormatterKey = cowc.QUERY_COLUMN_FORMATTER[selectFieldValue]; chartAxesOptions[selectFieldValue] = { axisLabelDistance: 5,