http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/ComponentListView.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/ComponentListView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/ComponentListView.js deleted file mode 100644 index f3bf985..0000000 --- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/ComponentListView.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* 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. -*/ - -define(['require', - 'backbone', - 'utils/Globals', - 'utils/ViewUtils', - 'collections/VNodeList', - 'hbs!tmpl/dashboard/ComponentListView_tmpl' -],function(require,Backbone,Globals,ViewUtils,VNodeList,ComponentListViewTmpl){ - 'use strict'; - - return Backbone.Marionette.ItemView.extend( - /** @lends ComponentListView */ - { - _viewName : 'ComponentListView', - - template: ComponentListViewTmpl, - - /** ui selector cache */ - ui: { - componentsList : "[data-id='componentContainer']", - content : "[data-id='content']" - }, - - /** ui events hash */ - events: function() { - var events={}; - events["click li"] = 'onComponentClick'; - events["click .host-info a[data-host]"] = 'onNewTabIconClick'; - events["mouseenter .host-info"] = function(e){ - $(e.currentTarget).children("a[data-host]").removeClass("hidden"); - }; - events["mouseleave .host-info"] = function(e){ - $(e.currentTarget).children("a[data-host]").addClass("hidden"); - }; - return events; - }, - /** - * intialize a new ComponentListView ItemView - * @constructs - */ - initialize: function(options) { - _.extend(this, _.pick(options,'vent','globalVent','params')); - this.searchParams = (this.params)? this.params :{}; - this.initializeCollection(); - this.bindEvents(); - }, - initializeCollection : function(){ - this.componentsList = new VNodeList([],{ - state: { - firstPage: 0, - pageSize: 99999 - } - }); - this.componentsList.url = Globals.baseURL + "service/logs/components/levels/counts"; - this.hostList = new VNodeList([],{ - state: { - firstPage: 0, - pageSize: 99999 - } - }); - this.hostList.url = Globals.baseURL + "service/logs/hosts/components"; - }, - /** all events binding here */ - bindEvents : function(){ - this.listenTo(this.componentsList,"reset",function(collection){ - this.renderComponents(); - this.$("#dashboard_tabs").height(this.ui.componentsList.height()); - //this.renderGraph(); - },this); - this.listenTo(this.hostList,"reset",function(collection){ - this.renderHostDetails(); - },this); - this.listenTo(this.vent,"main:search level:filter type:mustNot type:mustBe search:include:exclude " + - "logtime:filter reinitialize:filter:tree tab:refresh " + - Globals.eventName.serviceLogsIncludeColumns+" "+Globals.eventName.serviceLogsExcludeColumns,function(value){ - _.extend(this.searchParams,value); - this.fetchComponents(this.searchParams); - this.fetchComponentsHost(this.searchParams); - },this); - this.listenTo(this.globalVent, "globalExclusion:component:message", function(value) { - _.extend(this.searchParams,value); - this.fetchComponents(this.searchParams); - this.fetchComponentsHost(this.searchParams); - },this); - }, - /** on render callback */ - onRender: function() { - this.fetchComponents((this.params) ? this.params : {q:"*:*"}); - }, - fetchComponents : function(params){ - var that = this; - $.extend(this.componentsList.queryParams,params); - this.componentsList.fetch({ - beforeSend : function(){ - that.ui.componentsList.siblings(".loader").show(); - }, - reset:true, - complete : function(){ - that.ui.componentsList.siblings(".loader").hide(); - } - }); - }, - fetchComponentsHost : function(params){ - var that = this; - $.extend(this.hostList.queryParams,params); - this.hostList.fetch({ - beforeSend : function(){ - that.ui.content.siblings(".loader").show() - }, - reset:true, - complete : function(){ - that.ui.content.siblings(".loader").hide() - } - }); - }, - renderComponents : function(){ - var that = this; - that.ui.componentsList.find('.nodebar').popover('destroy'); - that.ui.componentsList.empty(); - if(this.componentsList.length == 0){ - this.$("#dashboard_tabs").hide(); - }else{ - this.$("#dashboard_tabs").show(); - this.componentsList.each(function(model){ - var total=0,logLevelCount = model.get("logLevelCount"); - for(var i=0;i < logLevelCount.length;i++){ - if(logLevelCount[i].value) - total = total +parseInt(logLevelCount[i].value,10); - } - that.ui.componentsList.append('<li data-name="'+model.get("name")+'"><a href="javascript:void(0);" class="tab-link" id="clients">'+model.get("name")+' ('+total+')</a>'+ViewUtils.getCountDistributionHTML(model.attributes)+'</li>'); - that.appendPopover(that.ui.componentsList.find("li").last(),model.attributes); - }); - } - - if(that.lastComponentLI && that.ui.componentsList.find("li[data-name='"+that.lastComponentLI+"']").length){ - that.ui.componentsList.find("li").removeClass("active"); - that.ui.componentsList.find("li[data-name='"+that.lastComponentLI+"']").addClass("active"); - }else{ - if(that.ui.componentsList.find("li").first().length > 0){ - that.ui.componentsList.find("li").first().click(); - } - } - }, - renderHostDetails : function(){ - var that=this; - that.ui.content.find('.nodebar').popover('destroy'); - that.ui.content.empty(); - that.ui.content.append('<div id="dashboard-overview" class="row" style="visibility: visible; position: relative;"></div>'); - if(this.hostList.length > 0){ - var model = this.hostList.first(); - _.each(model.get("childs"),function(m){ - var html = '<div class="col-md-3"><div class="host-info">'; - html += '<a data-host="'+m.name+'" title="'+m.name+' -> '+model.get("name")+'" data-type = "'+model.get("name")+'" href="javascript:void(0)" class="pull-right hidden"><i class="fa fa-share"></i></a>'; - html += '<h5>'+m.name.split(".")[0] + ' ('+m.value+')</h5>'; - html += ViewUtils.getCountDistributionHTML(m); - html += '</div></div>'; - that.ui.content.append(html); - that.appendPopover(that.ui.content.find('.col-md-3').last(),m); - }); - } - }, - onComponentClick : function(e){ - var $el = $(e.currentTarget); - this.lastComponentLI = $el.data("name"); - this.ui.componentsList.find("li").removeClass("active"); - $el.addClass("active"); - this.fetchComponentsHost(_.extend({component_name:$el.data("name")},this.searchParams)); - }, - onNewTabIconClick : function(e){ - var $el = $(e.currentTarget),host,component,that=this; - host = $el.data("host"); - component = $el.data("type"); - that.globalVent.trigger("render:tab",{ - params:_.extend({},{ - host_name : host, - component_name : component - }, that.searchParams, {hostList: null}), - globalVent : that.globalVent - }); - }, - appendPopover : function(node,data){ - node.find('.nodebar').popover({ - trigger: 'hover', - placement: "top", - html: true, - container: 'body', - template : '<div class="popover log-count" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>', - content: this.getPopoverHTML(data) - }); - }, - getPopoverHTML : function(node){ - if(! node.logLevelCount) - return ""; - var html=""; - //if count for all elements is zero then popover should not appear - if(_.find(node.logLevelCount,function(d){ return parseInt(d.value,10) > 0})){ - _.each(node.logLevelCount,function(data){ - html += "<span class='"+data.name+"'><i class='fa fa-circle'></i> "+data.name+": <strong>"+data.value+"</strong></span>"; - }); - } - return html; - }, - renderGraph : function(){ - var fatalData=[],errorData=[],warnData=[],infoData=[],debugData=[],traceData=[], - fatalIndex={},errorIndex={},warnIndex={},infoIndex={},debugIndex={},traceIndex={},tooltipIndex={}; - this.componentsList.each(function(m,i){ - var attr = m.get("logLevelCount"); - tooltipIndex[i] =m.get("name"); - //fatal - var fatal = _.findWhere(attr,{name:"FATAL"}); - if(fatal){ - fatalData.push(fatal.value); - fatalIndex[fatalData.length -1] =m.get("name"); - } - //error - var error = _.findWhere(attr,{name:"ERROR"}); - if(error){ - errorData.push(error.value); - errorIndex[errorData.length -1]=m.get("name"); - } - //warn - var warn = _.findWhere(attr,{name:"WARN"}); - if(warn){ - warnData.push(warn.value); - warnIndex[warnData.length -1] =m.get("name"); - } - //info - var info = _.findWhere(attr,{name:"INFO"}); - if(info){ - infoData.push(info.value); - infoIndex[infoData.length -1] =m.get("name"); - } - //debug - var debug = _.findWhere(attr,{name:"DEBUG"}); - if(debug){ - debugData.push(debug.value); - debugIndex[debugData.length -1] =m.get("name"); - } - //trace - var trace = _.findWhere(attr,{name:"TRACE"}); - if(trace){ - traceData.push(trace.value); - traceIndex[traceData.length -1] =m.get("name"); - } - }); - var barOptions = { - type : "bar", - barWidth : 8, - highlightColor : '#353535', - barSpacing : 2, - height : 30, - tooltipFormat : '{{offset:offset}} {{value}}' - }; - this.$(".g-fatal").sparkline(fatalData, - _.extend({}, barOptions, { - barColor : '#830A0A', - tooltipValueLookups : { - 'offset' : fatalIndex - }, - })); - this.$(".g-error").sparkline(errorData, - _.extend({}, barOptions, { - barColor : '#E81D1D', - tooltipValueLookups : { - 'offset' : errorIndex - }, - })); - this.$(".g-warn").sparkline(warnData, - _.extend({}, barOptions, { - barColor : '#FF8916', - tooltipValueLookups : { - 'offset' : warnIndex - }, - })); - - this.$(".g-info").sparkline(infoData, - _.extend({}, barOptions, { - barColor : '#2577B5', - tooltipValueLookups : { - 'offset' : infoIndex - }, - })); - - this.$(".g-debug").sparkline(debugData, - _.extend({}, barOptions, { - barColor : '#65E8FF', - tooltipValueLookups : { - 'offset' : debugIndex - }, - })); - - this.$(".g-trace").sparkline(debugData, - _.extend({}, barOptions, { - barColor : '#65E8FF', - tooltipValueLookups : { - 'offset' : traceIndex - }, - })); - - } - }); -}); \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/ComponentsView.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/ComponentsView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/ComponentsView.js deleted file mode 100644 index 424236d..0000000 --- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/ComponentsView.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* 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. -*/ - -define(['require', - 'backbone', - 'utils/Globals', - 'collections/VLogLevelList', - 'hbs!tmpl/dashboard/ComponentsView_tmpl', - 'select2' -],function(require,Backbone,Globals,VLogLevel,ComponentsTmpl){ - 'use strict'; - - return Backbone.Marionette.Layout.extend( - /** @lends LogLevelView */ - { - _viewName : 'ComponentsView', - - template: ComponentsTmpl, - - /** Layout sub regions */ - regions: { - }, - - /** ui selector cache */ - ui: { - }, - - /** ui events hash */ - events: function() { - var events = {}; - return events; - }, - - /** - * intialize a new LogLevelView Layout - * @constructs - */ - initialize: function(options) { - _.extend(this, _.pick(options,'vent')); - this.collection = new VLogLevel(); - this.collection.url = Globals.baseURL+"service/logs/components/count"; - this.bindEvents(); - }, - onRender : function(){ - this.fetchCollection(); - }, - bindEvents : function(){ - this.listenTo(this.collection,"reset",function(collection){ - this.populateDetails(); - },this); - this.listenTo(this.collection, 'request', function(){ - this.$("#loader").show(); - },this); - this.listenTo(this.collection, 'sync error', function(){ - this.$("#loader").hide(); - },this); - this.listenTo(this.vent,"main:search",function(value){ - this.fetchCollection({q:value}); - }); - }, - fetchCollection : function(params){ - $.extend(this.collection.queryParams, params); - this.collection.fetch({reset:true}); - }, - populateDetails : function(){ - var that = this; - that.$("tbody").empty(); - var actions = '<td>'+ - '<a href="javascript:void(0);"><i class="fa fa-search"></i></a>'+ - //'<a href="javascript:void(0);"><i class="fa fa-ban"></i></a>'+ - '</td>'; - this.collection.each(function(m,i){ - var html = "<tr>"; - html += "<td>"+m.get("name")+"</td>"; - html += "<td>"+m.get("count")+"</td>"; - html += actions; - that.$("tbody").append(html); - }); - } - }); - - -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/DashboardView.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/DashboardView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/DashboardView.js deleted file mode 100644 index 461e132..0000000 --- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/DashboardView.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* 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. -*/ - -define(['require', - 'backbone', - 'utils/Globals', - 'hbs!tmpl/dashboard/DashboardView_tmpl', - 'collections/VGroupList', - 'select2', - 'd3' -],function(require,Backbone,Globals,DashboardviewTmpl,VGroupList){ - 'use strict'; - - - var DashboardView = Backbone.Marionette.Layout.extend( - /** @lends DashboardView */ - { - _viewName : 'DashboardView', - - template: DashboardviewTmpl, - - /** Layout sub regions */ - regions: { - RLogDetail : "#r_LogDetail" - }, - - /** ui selector cache */ - ui: { - hosts : "#hosts", - components : "#components", - time : "#time" - }, - - /** ui events hash */ - events: function() { - var events = {}; - events['click #searchLog'] = 'onSearchLogClick'; - //events['click #searchLog'] = 'onSearchLogClick'; - return events; - }, - - /** - * intialize a new DashboardView Layout - * @constructs - */ - initialize: function(options) { - _.extend(this, _.pick(options, 'collection')); - this.setupCollections(); - this.bindEvents(); - this.hostCollection.fetch({reset:true}); - this.cComponents.fetch({reset:true}); - }, - setupCollections : function(){ - this.logRegions = new Backbone.Collection(); - this.hostCollection = new VGroupList([],{}); - this.cComponents = new VGroupList([],{}); - this.cComponents.url = Globals.baseURL + "service/logs/components"; - this.cTime = new VGroupList(Globals.timeQueryLOV,{}); - }, - /** all events binding here */ - bindEvents : function(){ - this.listenTo(this.hostCollection, "reset", function(col, abc){ - this.setupSelect2Fields(col,"host", 'host', 'hosts'); - }, this); - this.listenTo(this.cComponents, "reset", function(col, abc){ - this.setupSelect2Fields(col,"type", 'type', 'components'); - }, this); - }, - - /** on render callback */ - onRender: function() { - this.setupSelect2Fields(this.cTime,"value","text","time"); - }, - showLogDetail : function(){ - var that = this; - require(['views/dashboard/LogDetailView'],function(LogDetailView){ - that.RLogDetail.show(new LogDetailView({})); - }) - }, - setupSelect2Fields: function(col, idKey, textKey, selectTagId){ - var that = this, data = []; - data = _.pluck(col.models, 'attributes'); - - this.ui[selectTagId].select2({ - placeholder: 'Select', - allowClear : true, - width: '100%', - data: { results: data, text: textKey }, - formatSelection: function(item){ - return item[textKey]; - }, - formatResult: function(item){ - return item[textKey]; - } - }); - }, - onSearchLogClick : function(e){ - var searchParams = this.getSearchparams(); - - if(this.logRegions.length == 0){ - var model = new Backbone.Model({ - id : 1, - params : searchParams - }); - this.generateView(model); - }else{ - - var existsMod = this.logRegions.find(function(m){ - return JSON.stringify(searchParams) === JSON.stringify(m.get('params')) - }); - if(existsMod){ - $('html, body').animate({ - 'scrollTop' : this.$("#"+existsMod.get("tabName")).position().top - }); - return; - } - var lastModel = this.logRegions.last(); - var model = new Backbone.Model({ - id : parseInt(lastModel.get("id"),10) + 1, - params : searchParams - }); - this.generateView(model); - } - }, - generateView : function(model){ - var tabName = "r_LogDetail"+model.get("id"); - model.set("tabName",tabName); - $('<div/>', { - 'id': tabName, - 'class': 'r-tab-content col-md-12', - }).appendTo(this.$('#r_LogDetail')); - var region = {}; - region[tabName] = '#' + tabName; - this.addRegions(region); - this.logRegions.add(model); - this.renderRegion(model); - }, - renderRegion : function(model){ - var region = this.getRegion(model.get("tabName")); - require(['views/dashboard/LogDetailView'],function(LogDetailView){ - region.show(new LogDetailView({model: model})); - }) - - }, - getSearchparams : function(){ - var obj={hosts : null, components : null, time:null}; - if(this.ui.hosts.select2("data") != undefined || this.ui.hosts.select2("data") != null){ - if(this.ui.hosts.select2("data").host) - obj.hosts = this.ui.hosts.select2("data").host; - } - if(this.ui.components.select2("data") != undefined || this.ui.components.select2("data") != null){ - if(this.ui.components.select2("data").host) - obj.components = this.ui.components.select2("data").type; - } - if(this.ui.time.select2("data") != undefined || this.ui.time.select2("data") != null){ - if(this.ui.time.select2("data").id) - obj.time = this.ui.time.select2("val"); - } - return obj; - - }, - /** on close */ - onClose: function(){ - } - - }); - - return DashboardView; -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/GridTableLayoutView.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/GridTableLayoutView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/GridTableLayoutView.js deleted file mode 100644 index da930ea..0000000 --- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/GridTableLayoutView.js +++ /dev/null @@ -1,219 +0,0 @@ -/** - * 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. - */ - -define(['require', - 'backbone', - 'moment', - 'd3.tip', - 'utils/Globals', - 'utils/Utils', - 'collections/VLogList', - 'hbs!tmpl/dashboard/GridTableLayoutView_tmpl', - 'bootstrap-daterangepicker', - 'nv' -], function(require, Backbone, moment, tip, Globals, Utils, VLogList, GridTableLayoutViewTmpl, daterangepicker) { - 'use strict'; - - return Backbone.Marionette.Layout.extend( - /** @lends GridGraphLayoutView */ - { - _viewName: 'GridGraphLayoutView', - - template: GridTableLayoutViewTmpl, - - - /** ui selector cache */ - ui: { - dateRange: "#dateRange", - selectDateRange: ".selectDateRange", - dateRangeTitle: "span[data-id='dateRangeTitle']", - gridSettingPopup: "[data-id='gridSettingPopup']", - gridHeader: ".gridHeader" - - }, - - /** ui events hash */ - events: function() { - var events = {}; - events['change ' + this.ui.viewType] = 'onViewTypeChange'; - events['click [data-id="refresh-tab-graph"]'] = 'onTabRefresh'; - events['click ' + this.ui.gridSettingPopup] = 'onGridSettingPopupClick'; - return events; - }, - - /** - * intialize a new GridGraphLayoutView Layout - * @constructs - */ - initialize: function(options) { - _.extend(this, _.pick(options, 'globalVent', 'params', 'viewType', 'dashboard', 'model', 'gridHelp')); - this.vent = new Backbone.Wreqr.EventAggregator(); - this.collection = new VLogList([], { - state: { - firstPage: 0, - pageSize: 999999999, - - } - }); - - this.dateUtil = Utils.dateUtil; - this.dateRangeLabel = new String(); - - this.bindEvents(); - this.graphParams = {}; - this.unit = (this.model.params && this.model.params.unit) ? this.model.params.unit : "+1HOUR"; - this.firstRender = true; - this.collection.url = Globals.baseURL + "audit/logs/anygraph"; - this.collection.modelAttrName = "graphData"; - - }, - bindEvents: function() { - this.listenTo(this.collection, "reset", function(collection) { - this.$(".loader").hide(); - this.$("#loaderGraph").hide(); - }, this); - this.listenTo(this.collection, 'request', function() { - this.$(".loader").show(); - this.$("#loaderGraph").show(); - }, this); - this.listenTo(this.collection, 'sync error', function() { - this.$(".loader").hide(); - this.$("#loaderGraph").hide(); - }, this); - this.listenTo(this.vent, "graph:update", function(options) { - - options['params'] = this.params - if (this.model) { - this.model.clear().set(options) - } - this.configureChart(options); - }, this); - this.listenTo(this.vent, "graph:data:update", function(params, options) { - this.params = params - options['params'] = this.params - if (this.model) { - this.model.clear().set(options) - } - this.fetchGraphData(params, options); - }, this); - this.listenTo(this.vent, "table:grid:update", function(options) { - options['params'] = this.params - if (this.model) { - this.model.clear().set(options) - } - this.updateGrid(options) - }, this); - - }, - onRender: function() { - var that = this; - if (this.model) { - var mObject = this.model.toJSON(); - if (mObject.params) { - this.params = mObject.params; - this.fetchGraphData(mObject.params, mObject); - } - this.updateGrid(mObject); - } - if (this.gridHelp) { - setTimeout(function() { - this.$('.gridSettinghand').hide(); - }, 3000); - } else { - this.$('.gridSettinghand').hide(); - } - - }, - - fetchGraphData: function(params, options) { - var that = this; - that.$("#loaderGraph").show(); - that.$(".loader").show(); - _.extend(this.collection.queryParams, params); - this.collection.fetch({ - reset: true, - success: function() { - that.createDataForGraph(options) - } - }); - }, - updateGrid: function(options) { - if (options.title) { - this.ui.gridHeader.find('.gridTitle').text(options.title); - } - }, - setupDialog: function(options) { - var that = this; - require(['views/common/JBDialog'], function(JBDialog) { - var opts = _.extend({ - appendTo: that.$el, - modal: true, - resizable: false, - beforeClose: function(event, ui) { - that.onDialogClosed(); - } - }, options); - var dialog = that.dialog = new JBDialog(opts).render().open(); - }) - - }, - onGridSettingPopupClick: function() { - this.$('.gridSettinghand').hide(); - this.dashboard.disable(); - var that = this; - var overlay = document.createElement('div'); - overlay.setAttribute('class', 'overlayDashboard'); - this.$el.append(overlay); - require(['views/dialog/GridGraphSettingView'], function(GridGraphSettingView) { - var view = new GridGraphSettingView({ - vent: that.vent, - params: (that.model) ? (that.params) : ({}), - model: that.model, - viewType: that.viewType - }); - - that.setupDialog({ - title: "Setting", - content: view, - viewType: 'Save', - width: 560, - height: 500, - buttons: [{ - id: "cancelBtn", - text: "Close", - "class": "btn btn-default", - click: function() { - that.onDialogClosed(); - } - }] - }); - }); - }, - onDialogClosed: function() { - this.$el.find('.overlayDashboard').remove(); - this.dashboard.enable(); - if (this.dialog) { - this.dialog.close && this.dialog.close(); - this.dialog.remove && this.dialog.remove(); - this.dialog = null; - } - } - }); - - -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/HostListView.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/HostListView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/HostListView.js deleted file mode 100644 index 4283f02..0000000 --- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/HostListView.js +++ /dev/null @@ -1,356 +0,0 @@ -/** -* 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. -*/ - -define(['require', - 'backbone', - 'utils/Globals', - 'hbs!tmpl/dashboard/HostListView_tmpl', - 'collections/VNodeList' -],function(require,Backbone,Globals,HostListViewTmpl,VNodeList){ - 'use strict'; - - var HostListView = Backbone.Marionette.ItemView.extend( - /** @lends HostListView */ - { - _viewName : 'HostListView', - - template: HostListViewTmpl, - - /** ui selector cache */ - ui: { - hostNameTxt : "[data-id='hostName']", - searcHostBtn : "[data-id='searchHost']", - mainCheck : "#mainCheck" - }, - - /** ui events hash */ - events: function() { - var events = {}; - events["change "+this.ui.mainCheck] = 'onMainCheckboxClick'; - events["click "+this.ui.searcHostBtn] = 'onSearchHostClick'; - events["change .tree input[type='checkbox']"] = 'onChangeNodeCheckbox'; - events["keypress "+this.ui.hostNameTxt] = 'onSearchHostKeypress'; - events["click .tree a[data-type='C']"] = 'onNewTabIconClick'; - events["mouseenter .tree li[data-type='C']"] = function(e){ - $(e.currentTarget).children("a").removeClass("hidden"); - }; - events["mouseleave .tree li[data-type='C']"] = function(e){ - $(e.currentTarget).children("a").addClass("hidden"); - }; - events["click [data-id='collapseAll']"] = function(e){ - //_.each(this.$("[data-state='expand']")); - this.$("[data-state='expand']").click(); - }; - events["click [data-id='expandAll']"] = function(e){ - //_.each(this.$("[data-state='expand']")); - this.$("[data-state='collapse']").click(); - }; - return events; - }, - - /** - * intialize a new HostListView ItemView - * @constructs - */ - initialize: function(options) { - _.extend(this, _.pick(options,'vent','globalVent','params')); - this.searchParams = (this.params)? this.params :{}; - this.collection = new VNodeList([], { - state: { - firstPage: 0, - pageSize: 50 - } - }); - this.bindEvents(); - this.hostState = {}; - }, - /** all events binding here */ - bindEvents : function(){ - this.listenTo(this.vent,"main:search level:filter type:mustNot type:mustBe search:include:exclude " + - "logtime:filter reinitialize:filter:tree tab:refresh " + - Globals.eventName.serviceLogsIncludeColumns+" "+Globals.eventName.serviceLogsExcludeColumns,function(value){ - _.extend(this.searchParams,value); - this.fetchHosts(this.searchParams); - },this); - - this.listenTo(this.globalVent, "globalExclusion:component:message", function(value) { - _.extend(this.searchParams,value); - this.fetchHosts(this.searchParams); - },this); - -// this.listenTo(this.vent, "tab:refresh", function(params) { -// _.extend(this.searchParams,params); -// this.fetchHosts(this.searchParams); -// },this); - - this.listenTo(this.collection,"reset",function(){ - this.removeSpinner(); - this.renderHosts(); - }); - }, - /** on render callback */ - onRender: function() { - this.fetchHosts((this.params) ? this.params : {q:"*:*"}); - }, - fetchHosts : function(params){ - var that = this; - $.extend(this.collection.queryParams, params, {hostList: null}); - this.collection.fetch({ - reset:true, - complete : function(){ - that.removeSpinner(); - } - }); - }, - renderHosts : function(){ - var $el = this.$(".hostNodes"),that=this; - this.$('.nodebar').popover('destroy'); - $el.empty(); - var $ul; - this.collection.each(function(data,i){ - //appending box for every host - //if(i==0 || (i % 5 == 0)){ - //($ul) ? that.formatTree($ul.parent(".tree")) : ""; - $el.append("<div class='col-md-3'><div class='box box-dashed'><div class='box-contentHost'><div class='tree smart-form'><ul></ul></div></div></div></div>"); - $ul = $el.find(".tree.smart-form").last().find("ul"); - //} - if(data.get("isParent") === "true" || data.get("isParent") == true){ - $ul.append(that.getParentNode(data.attributes)); - var rootNode = $ul.find("li[data-node='"+data.get("name")+"']"); - that.appendChilNodes(data.attributes,rootNode); - that.appendPopover(rootNode,data.attributes); - } - }); - this.formatTree(); - this.restoreCheckbox(); - }, - formatTree : function(){ - var that = this; - this.$('.tree > ul').attr('role', 'tree').find('ul').attr('role', 'group'); - this.$('.tree').find('li:has(ul)').addClass('parent_li').attr('role', 'treeitem').find(' > span').attr('title', 'Expand this branch').attr("data-state","collapse").on('click', function(e) { - var children = $(this).parent('li.parent_li').find(' > ul > li'); - if (children.is(':visible')) { - that.hostState[$(this).parent().data("node")] = false; - children.hide('fast'); - $(this).attr('title', 'Expand this branch').attr("data-state","collapse").find(' > i').removeClass().addClass('fa fa-plus-circle'); - } else { - that.hostState[$(this).parent().data("node")] = true; - children.show('fast'); - $(this).attr('title', 'Collapse this branch').attr("data-state","expand").find(' > i').removeClass().addClass('fa fa-minus-circle'); - } - e.stopPropagation(); - }); - //this.$('[data-toggle="tooltip"]').tooltip(); - }, - getParentNode : function(node){ - return '<li data-type="'+node.type+'" data-parent="'+node.isParent+'" data-node = "'+node.name+'"> '+this.getCountDistribution(node)+this.getCheckbox(node)+' <span><i class="fa fa-plus-circle"></i> <strong>'+node.name.split(".")[0]+'</strong> ('+node.value+')</span></li>'; - }, - getChildNode : function(node){ - return '<li style="display:none;" data-type="'+node.type+'" data-node = "'+node.name+'" >'+ - '<a data-type="'+node.type+'" data-node = "'+node.name+'" href="javascript:void(0)" class="pull-right hidden"><i class="fa fa-share"></i></a>'+ - this.getCountDistribution(node)+ - //this.getCheckbox(node)+ - ' <span><strong>'+node.name+'</strong> ('+node.value+')</span></li>'; - }, - getCheckbox : function(node){ - return '<label class="checkbox no-margin"> <input data-parent="'+node.isParent+'" data-type="'+node.type+'" data-node="'+node.name+'" checked="checked" type="checkbox"> <i class="fa fa-square-o small"></i></label>'; - }, - appendChilNodes : function(data, $parentNode){ - $parentNode.append('<ul>'); - data.childs = _.isArray(data.childs) ? data.childs : new Array(data.childs); - var $el = $parentNode.find('ul'),that=this; - _.each(data.childs,function(node){ - if(! _.isUndefined(node.childs)){ - $el.append(this.getParentNode(node)); - var rootNode = $el.find("li[data-node='"+data.name+"']"); - that.appendChilNodes(node,rootNode); - } - - if(node.isParent === "true" || node.isParent == true) - $el.append(that.getParentNode(node)); - else{ - $el.append(that.getChildNode(node)); - } - that.appendPopover($el.find('li').last(),node); - }); - }, - appendPopover : function(node,data){ - node.children('.nodebar').popover({ - trigger: 'hover', - placement: "top", - html: true, - container: 'body', - template : '<div class="popover log-count" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>', - content: this.getPopoverHTML(data) - }); - }, - getPopoverHTML : function(node){ - //<span style='color:#E2D014'><i class='fa fa-circle'></i> 12876</span> - if(! node.logLevelCount) - return ""; - var html=""; - //if count for all elements is zero then popover should not appear - if(_.find(node.logLevelCount,function(d){ return parseInt(d.value,10) > 0})){ - _.each(node.logLevelCount,function(data){ - html += "<span class='"+data.name+"'><i class='fa fa-circle'></i> "+data.name+": <strong>"+data.value+"</strong></span>"; - }); - } - return html; - }, - getCountDistribution : function(node){ - if(! node.logLevelCount) - return ""; - return '<div data-node = "'+node.name+'" class="nodebar">'+this.getLevelDistribution(node)+'</div>'; - }, - getLevelDistribution : function(node){ - var html=""; - if(! _.isUndefined(node.logLevelCount) && ! _.isArray(node.logLevelCount)) - node.logLevelCount = [node.logLevelCount]; - var toPct = this.calculatePercentge(node.logLevelCount); - _.each(node.logLevelCount,function(data){ - //html += '<div class="node '+data.name+'" style="width:'+toPct(data)+'%;" data-toggle="tooltip" title="'+data.value+'" data-original-title="'+data.value+'"></div>'; - html += '<div class="node '+data.name+'" style="width:'+toPct(data)+'%;"></div>'; - }); - return html; - }, - calculatePercentge : function(values) { - var sum = 0; - for( var i = 0; i != values.length; ++i ) { - sum = sum + parseInt(values[i].value,10); - } - var scale = 100/sum; - return function( x ){ - return (parseInt(x.value,10)*scale)/*.toFixed(5)*/; - }; - }, - onNewTabIconClick : function(e){ - var $el = $(e.currentTarget),host,component,that=this; - if($el.children().is('img')){ - this.onCompareLink($el); - }else{ - if($el.parents("[data-parent=true]")){ - host = $el.parents("[data-parent=true]").data("node"); - component = $el.data("node"); - that.globalVent.trigger("render:tab",{ - params:_.extend({},{ - host_name : host, - component_name : component - },that.searchParams,{hostList:null}), - globalVent : that.globalVent - }); - } - } - - }, - onChangeNodeCheckbox : function(e){ - var $el = $(e.currentTarget); - if($el.data("parent") == "true" || $el.data("parent") == true){ - if($el[0].checked) - $el.parent().siblings("ul").find("input").prop("checked",true); - else - $el.parent().siblings("ul").find("input").prop("checked",false); - }else{ - var mainParent = $el.parents("[data-type='H']"); - var checkedLen = mainParent.find("ul :checkbox:checked").length; - var totalCheckboxLen = mainParent.find("ul :checkbox").length; - if(checkedLen > 0) - mainParent.find("input[data-type='H']").prop("checked",true); - else - mainParent.find("input[data-type='H']").prop("checked",false); - if(checkedLen < totalCheckboxLen) - mainParent.find("input[data-type='H']").prop("indeterminate",true); - else - mainParent.find("input[data-type='H']").prop("indeterminate",false); - - } - var data = this.getCheckedHierarchyData(); - this.vent.trigger("tree:search", {hostList: (_.pluck(data, "h")).toString()}); - }, - getCheckedHierarchyData : function(){ - var data=[]; - var parents = this.$('.tree :checkbox:checked').filter('[data-parent="true"]'); - _.each(parents,function(p){ - var obj = { - h : $(p).data("node"), - c : [] - }; - _.each($(p).parent().siblings("ul").find(":checkbox:checked"),function(c){ - obj.c.push($(c).data("node")); - }); - data.push(obj); - }); - return data; - }, - onMainCheckboxClick : function(e){ - if(e.target.checked){ - this.$('.tree input[type="checkbox"]').prop({"checked":true,"indeterminate":false}); - - }else - this.$('.tree input[type="checkbox"]').prop({"checked":false,"indeterminate":false}); - var data = this.getCheckedHierarchyData(); - this.params.hostList = _.extend({},data); - this.vent.trigger("tree:search",{hostList : (_.pluck(data,"h")).toString()}); - - }, - onSearchHostClick : function(e){ - var hostName = this.ui.hostNameTxt.val(); - this.searchHostNameCallBck(hostName); - }, - searchHostNameCallBck : function(name){ - this.$('.nodebar').popover('destroy'); - this.addSpinner(); - this.$(".hostNodes").empty().html("Loading....."); - this.fetchHosts({hostName:$.trim(name)}); - }, - onSearchHostKeypress : function(e){ - if(e.which == 13){ - this.searchHostNameCallBck(e.currentTarget.value); - } - }, - addSpinner : function(){ - this.ui.searcHostBtn.find("i").removeClass().addClass("fa fa-spinner fa-spin"); - }, - removeSpinner : function(){ - this.ui.searcHostBtn.find("i").removeClass().addClass("fa fa-search"); - }, - restoreCheckbox : function(){ - var params = (this.params.hostList) ? this.params.hostList.toString() : undefined, that = this; - if(params){ - that.$("input[data-node]").prop("checked",false); - _.each(params,function(node){ - if(node){ - that.$("input[data-type='H'][data-node='"+node+"']").prop("checked",true); - } - - - }); - } - if(this.hostState){ - _.each(this.hostState,function(value,key){ - if(value){ - that.$("li[data-type='H'][data-node='"+key+"']").find("span").click(); - } - }); - } - }, - /** on close */ - onClose: function(){ - }, - }); - return HostListView; -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/HostsView.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/HostsView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/HostsView.js deleted file mode 100644 index 2440fd0..0000000 --- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/HostsView.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* 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. -*/ - -define(['require', - 'backbone', - 'utils/Globals', - 'collections/VLogLevelList', - 'hbs!tmpl/dashboard/HostsView_tmpl', - 'select2' -],function(require,Backbone,Globals,VLogLevel,HostsTmpl){ - 'use strict'; - - return Backbone.Marionette.Layout.extend( - /** @lends HostsView */ - { - _viewName : 'HostsView', - - template: HostsTmpl, - - /** Layout sub regions */ - regions: { - }, - - /** ui selector cache */ - ui: { - }, - - /** ui events hash */ - events: function() { - var events = {}; - return events; - }, - - /** - * intialize a new LogLevelView Layout - * @constructs - */ - initialize: function(options) { - _.extend(this, _.pick(options,'vent')); - this.collection = new VLogLevel(); - this.collection.url = Globals.baseURL+"service/logs/hosts/count"; - this.bindEvents(); - }, - onRender : function(){ - this.fetchCollection(); - }, - bindEvents : function(){ - this.listenTo(this.collection,"reset",function(collection){ - this.populateDetails(); - },this); - this.listenTo(this.collection, 'request', function(){ - this.$("#loader").show(); - },this); - this.listenTo(this.collection, 'sync error', function(){ - this.$("#loader").hide(); - },this); - this.listenTo(this.vent,"main:search",function(value){ - this.fetchCollection({q:value}); - }); - }, - fetchCollection : function(params){ - $.extend(this.collection.queryParams, params); - this.collection.fetch({reset:true}); - }, - populateDetails : function(){ - var that = this; - that.$("tbody").empty(); - var actions = '<td>'+ - '<a href="javascript:void(0);"><i class="fa fa-search"></i></a>'+ - //'<a href="javascript:void(0);"><i class="fa fa-ban"></i></a>'+ - '</td>'; - this.collection.each(function(m,i){ - var html = "<tr>"; - html += "<td>"+m.get("name")+"</td>"; - html += "<td>"+m.get("count")+"</td>"; - html += actions; - that.$("tbody").append(html); - }); - } - }); - - -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/LogDetailView.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/LogDetailView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/LogDetailView.js deleted file mode 100644 index 1de9b96..0000000 --- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/LogDetailView.js +++ /dev/null @@ -1,249 +0,0 @@ -/** -* 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. -*/ - -define(['require', - 'backbone', - 'collections/VLogList', - 'hbs!tmpl/dashboard/LogDetailView_tmpl' -],function(require,Backbone,VUserList,LogDetailViewTmpl){ - 'use strict'; - - var LogDetailView = Backbone.Marionette.ItemView.extend( - /** @lends LogDetailView */ - { - _viewName : 'LogDetailView', - - template: LogDetailViewTmpl, - - templateHelpers : function(){ -// return { -// logData : this.logData -// }; - }, - - /** ui selector cache */ - ui: { - btnPin : ".btn-pin", - searchTags : "#tags" - }, - - /** ui events hash */ - events: function() { - var events = {}; - events['click ' + this.ui.btnPin] = 'onBtnPinClick'; - events['click .btn-minimize'] = 'onBtnMinimizeClick'; - return events; - }, - - /** - * intialize a new LogDetailView ItemView - * @constructs - */ - initialize: function(options) { - _.extend(this, _.pick(options)); - - this.logData = {}; - this.collection = new VUserList([], { - state: { - firstPage: 0, - pageSize: 50 - } - }); - var query = {q:""}; - if(this.model.get("params")){ - if(this.model.get("params").hosts){ - query.hosts = this.model.get("params").hosts; - } - if(this.model.get("params").components){ - query.components = this.model.get("params").components - } - if(this.model.get("params").time){ - query.time = this.model.get("params").time - } - } - this.mergeParams(query); - this.isLoading = false; - this.bindEvents(); - }, - /** all events binding here */ - bindEvents : function(){ - this.listenTo(this.collection, "reset", function(){ - this.renderLogLines(this.collection); - }, this); - this.listenTo(this.collection, 'request', function(){ - this.isLoading = true; - this.$("#logLines").append('<div class="loading-lines" align="center"><img src="images/loading.gif"/></div>'); - },this); - this.listenTo(this.collection, 'sync error', function(){ - this.isLoading = false; - this.$(".loading-lines").remove(); - },this); - }, - - /** on render callback */ - onRender: function() { - this.fetchCollection(); - this.initializePlugins(); - - }, - initializePlugins : function(){ - var that = this; - this.infiniteScrolling(); - this.ui.searchTags.select2({ - placeholder: "Manual search", - closeOnSelect : true, - tags:true, - multiple: true, - minimumInputLength: 1, - tokenSeparators: [",", " "] - }).on("change",function(){ - that.$("#logLines").empty(); - var q = ""; - if( _.isObject(that.ui.searchTags) && (! _.isEmpty(that.ui.searchTags.select2('val'))) ){ - var arr = that.ui.searchTags.select2('val'),qArr=[]; - - _.each(arr,function(d){ - qArr.push("*"+d+"*"); - }); - q = qArr.toString(); - } - that.mergeParams({q : q}); - that.collection.getFirstPage({reset:true}); - }); - }, - initializeResize : function(){ - if(! this.$('.record').hasClass("ui-resizable")){ - var org = this.$('.record').height(),that=this; - this.$('.record').resizable({ghost:false,minHeight: 386,handles: 's'}).on("resize",function(e,ui){ - var current = $(e.currentTarget).height(); - var height = (current - org) + that.$('.record-panel').height(); - that.$('.record').find('.record-panel').height(height); - org += (current - org); - }); - } - }, - mergeParams : function(obj){ - $.extend(this.collection.queryParams, obj); - }, - fetchCollection : function(){ - this.collection.fetch({reset:true}); - }, - infiniteScrolling : function(){ - var that = this; - this.$('.record-panel').bind('scroll', function() { - if($(this).scrollTop() + $(this).innerHeight() >= this.scrollHeight) { - if(! that.isLoading){ - that.infiniteScrollCallBack(); - } - - } - }) - }, - infiniteScrollCallBack : function(){ - if(this.collection.hasNext()) - this.collection.getNextPage({reset:true}); - }, - onBtnPinClick : function(e){ - this.ui.btnPin.toggleClass("unpin"); - }, - onBtnMinimizeClick : function(e){ - e.preventDefault(); - var box = $(e.currentTarget).closest('div.record'); - var button = $(e.currentTarget).find('i'); - var content = box.find('div.record-content'); - content.slideToggle('fast'); - button.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down'); - content.parent().css('height','auto'); - if(! button.hasClass('fa-chevron-up')){ - this.$('.record').resizable('disable'); - }else - this.$('.record').resizable('enable'); - }, - /*getData : function(params){ - var that = this; - that.$("#logLines").append('<div class="loading-lines" align="center"><img src="images/loading.gif"/></div>'); - this.isLoading = true; - $.ajax({ - url:"service/test/solr", - data : params, - success : function(data,textStatus,jqXHR ){ - that.logData = data; - that.$(".loading-lines").remove(); - that.renderLogLines(data); - that.renderRecordsInfo(); - that.isLoading = false; - }, - error : function(jqXHR,textStatus,errorThrown){ - console.log("ERROR:"+errorThrown); - } - }); - }, - renderRecordsInfo : function(){ - if(this.logData){ - this.$("#recFetched").text(this.logData.startIndex + this.logData.pageSize); - this.$("#recTotal").text(this.logData.totalCount); - } - }, - getQueryParams : function(){ - var startIndex = this.logData.startIndex, - pageSize = this.logData.pageSize ? this.logData.pageSize : 10,obj={}; - if(_.isUndefined(startIndex)){ - obj.startIndex = 0; - }else - obj.startIndex = startIndex + pageSize; - obj.pageSize = pageSize; - return obj; - },*/ - renderLogLines : function(collection){ - var $el = this.$("#logLines"),state=this.collection.state,recordsFetched =0; - if(collection.length > 0){ - _.each(collection.models,function(d){ - $el.append("<p class='log-line'>["+d.get("message")+"]</p>"); - }); - }else{ - $el.append("<span class='no-record'>no records found !</span>"); - } - - - if(this.collection.hasNext()) - recordsFetched = (state.currentPage + 1) * state.pageSize; - else - recordsFetched = state.totalRecords; - this.$("#recFetched").text(recordsFetched); - this.$("#recTotal").text(state.totalRecords); - this.highlightSearch(); - this.initializeResize(); - }, - highlightSearch : function(){ - var str = this.ui.searchTags.select2('val').toString(),that=this; - if(! _.isEmpty(str)){ - var arr = str.split(","); - _.each(arr,function(v){ - var searchStr = v.replace(/\*/g,''); - that.$("#logLines").highlight(searchStr); - }); - } - }, - /** on close */ - onClose: function(){ - } - - }); - - return LogDetailView; -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/LogLevelBoxView.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/LogLevelBoxView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/LogLevelBoxView.js deleted file mode 100644 index eb73fb8..0000000 --- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/LogLevelBoxView.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* 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. -*/ - -define(['require', - 'backbone', - 'utils/Globals', - 'collections/VLogLevelList', - 'hbs!tmpl/dashboard/LogLevelBoxView_tmpl', - 'select2' -],function(require,Backbone,Globals,VLogLevelList,LogLevelBoxTmpl){ - 'use strict'; - - return Backbone.Marionette.Layout.extend( - /** @lends LogLevelBoxView */ - { - _viewName : 'LogLevelBoxView', - - template: LogLevelBoxTmpl, - - /** Layout sub regions */ - regions: { - }, - - /** ui selector cache */ - ui: { - INFO : "[data-id='INFO']", - WARN : "[data-id='WARN']", - ERROR : "[data-id='ERROR']", - DEBUG : "[data-id='DEBUG']", - FATAL : "[data-id='FATAL']", - TRACE : "[data-id='TRACE']", - UNKNOWN : "[data-id='UNKNOWN']", - loader:".server-info .fa-spin" - }, - - /** ui events hash */ - events: function() { - var events = {}; - events["click .server-info a"] = 'onLogLevelClick'; - return events; - }, - - /** - * intialize a new LogLevelBoxView Layout - * @constructs - */ - initialize: function(options) { - _.extend(this, _.pick(options,'vent','globalVent','params')); - this.logLevelList = new VLogLevelList(); - this.logLevelList.url = Globals.baseURL + "service/logs/levels/counts"; - this.logLevelList.modelAttrName = "vNameValues"; - this.bindEvents(); - }, - onRender : function(){ -// this.fetchLogLevelCounts({level:(this.params) ? this.params.level : null}); - this.fetchLogLevelCounts((this.params) ? this.params : {}); - if(this.params && this.params.level){ - var levels = this.params.level.split(","); - this.highlightLevels(levels); - } - }, - highlightLevels : function(levels){ - this.$(".node").removeClass("active") - for(var i=0;i<levels.length;i++){ - this.$(".node."+levels[i]).addClass("active"); - } - }, - fetchLogLevelCounts : function(params){ - $.extend(this.logLevelList.queryParams,params,{level: "FATAL,ERROR,WARN,INFO,DEBUG,TRACE,UNKNOWN"}); - this.ui.loader.show(); - this.logLevelList.fetch({reset:true}); - }, - bindEvents : function(){ - this.listenTo(this.logLevelList,"reset",function(){ - this.ui.loader.hide(); - this.renderLogLevelCounts(); - },this); - this.listenTo(this.vent,"main:search tree:search type:mustNot type:mustBe logtime:filter" + - " search:include:exclude "+Globals.eventName.serviceLogsIncludeColumns+" "+Globals.eventName.serviceLogsExcludeColumns,function(value){ - this.fetchLogLevelCounts(value); - },this); -// this.listenTo(this.vent,"tree:search",function(value){ -// this.fetchLogLevelCounts(value); -// },this); -// this.listenTo(this.vent,"type:mustNot",function(value){ -// this.fetchLogLevelCounts(value); -// },this); -// this.listenTo(this.vent,"type:mustBe",function(value){ -// this.fetchLogLevelCounts(value); -// },this); -// this.listenTo(this.vent,"logtime:filter",function(value){ -// this.fetchLogLevelCounts(value); -// },this); -// this.listenTo(this.vent,"search:include:exclude",function(value){ -// this.fetchLogLevelCounts(value); -// },this); - this.listenTo(this.vent,"reinitialize:filter:level",function(value){ - this.reinitializeFilter(value); - },this); - this.listenTo(this.globalVent, "globalExclusion:component:message", function(value) { - this.fetchLogLevelCounts(value); - },this); - this.listenTo(this.vent,"tab:refresh",function(params){ - this.reRenderView(params); - },this); - }, - renderLogLevelCounts : function(){ - var that = this; - this.logLevelList.each(function(model){ - that.$("[data-total='"+model.get("name")+"']").parent().prop('title',model.get("value")) - that.$("[data-total='"+model.get("name")+"']").text(model.get("value")); - }); - }, - onLogLevelClick : function(e){ - var $el = $(e.currentTarget); - if($el.hasClass("active")){ - $el.removeClass("active"); - }else{ - $el.addClass("active"); - } - var params = []; - _.each(this.$(".server-info a.active"),function(e){ - params.push($(e).find("strong").data("total")); - }); - this.fetchLogLevelCounts({level:params.toString()}); - this.vent.trigger("level:filter",{level:params.toString()}); - }, - reinitializeFilter : function(value){ - this.fetchLogLevelCounts(value); - if(value.level) - this.highlightLevels(value.level.split(",")); - - }, - reRenderView : function(params){ - this.fetchLogLevelCounts(params); - } - }); - - -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/LogLevelView.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/LogLevelView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/LogLevelView.js deleted file mode 100644 index 79c8bcf..0000000 --- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/LogLevelView.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* 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. -*/ - -define(['require', - 'backbone', - 'utils/Globals', - 'collections/VLogLevelList', - 'hbs!tmpl/dashboard/LogLevelView_tmpl', - 'select2' -],function(require,Backbone,Globals,VLogLevel,LogLevelTmpl){ - 'use strict'; - - return Backbone.Marionette.Layout.extend( - /** @lends LogLevelView */ - { - _viewName : 'LogLevelView', - - template: LogLevelTmpl, - - /** Layout sub regions */ - regions: { - RLogLevelPieChart : "#r_logLevelPieChart", - }, - - /** ui selector cache */ - ui: { - INFO : "[data-id='INFO']", - WARN : "[data-id='WARN']", - ERROR : "[data-id='ERROR']", - DEBUG : "[data-id='DEBUG']", - FATAL : "[data-id='FATAL']", - TRACE : "[data-id='TRACE']", - UNKNOWN : "[data-id='UNKNOWN']", - togglePieViewButton:'#logToggle', - pieRegionId:'#r_logLevelPieChart', - logTable:'#logTable' - }, - - /** ui events hash */ - events: function() { - var events = {}; - events['click #searchLog'] = 'onSearchLogClick'; - events['click ' + this.ui.togglePieViewButton] = 'onToggaleView'; - return events; - }, - - /** - * intialize a new LogLevelView Layout - * @constructs - */ - initialize: function(options) { - _.extend(this, _.pick(options,'vent')); - this.collection = new VLogLevel(); - this.bindEvents(); - }, - onRender : function(){ - this.fetchCollection(); - this.ui.pieRegionId.hide(); - }, - fetchCollection : function(params){ - $.extend(this.collection.queryParams, params); - this.collection.fetch({reset:true}); - }, - bindEvents : function(){ - this.listenTo(this.collection,"reset",function(collection){ - this.populateDetails(); - this.renderLogLevelPieChart(); - },this); - this.listenTo(this.collection, 'request', function(){ - this.$("#loader").show(); - },this); - this.listenTo(this.collection, 'sync error', function(){ - this.$("#loader").hide(); - },this); - this.listenTo(this.vent,"main:search",function(value){ - this.fetchCollection({q:value}); - }); - }, - populateDetails : function(){ - var that = this; - this.collection.each(function(m,i){ - that.ui[m.get("name")].text(m.get("count")); - }); - }, - renderLogLevelPieChart:function(){ - var that = this; - require(['views/graphs/PieChartGraphLayoutView'],function(PieChartGraphLayoutView){ - that.RLogLevelPieChart.show(new PieChartGraphLayoutView({ - vent : that.vent, - collection:that.collection - /*parentView:this*/ - })); - }) - }, - onToggaleView:function(){ - this.ui.togglePieViewButton.children().toggleClass('fa-pie-chart fa-th'); - this.ui.pieRegionId.toggle(); - this.ui.logTable.toggle() - } - }); - - -}); \ No newline at end of file