You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by mr...@apache.org on 2017/09/11 04:38:38 UTC
[08/94] [abbrv] [partial] ambari git commit: AMBARI-21870. Integrate
LogSearch new UI with the server and get rid of the old one (oleewere)
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/MainLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/MainLayoutView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/MainLayoutView.js
deleted file mode 100644
index 929ca98..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/MainLayoutView.js
+++ /dev/null
@@ -1,670 +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/Utils',
- 'utils/ViewUtils',
- 'utils/Globals',
- 'hbs!tmpl/dashboard/MainLayoutView_tmpl',
- 'select2',
- 'sparkline',
- 'd3.tip'
-],function(require,Backbone,Utils,ViewUtils,Globals,MainLayoutViewTmpl){
- 'use strict';
-
- var MainLayoutView = Backbone.Marionette.Layout.extend(
- /** @lends MainLayoutView */
- {
- _viewName : 'MainLayoutView',
-
- template: MainLayoutViewTmpl,
-
- /** Layout sub regions */
- regions: {
- RLogLevel : "#r_logLevel",
- RComponents : "#r_components",
- RHosts : "#r_hosts",
- RHierarchyTab : "#r_Hierarchy",
- RHostInfoTab : "#r_HostInfo",
- RBubbleTable : "#r_BubbleTable",
- RAuditTab : "#r_AuditInfo",
- RAuditDashboard:"#r_AuditDashboard",
- RTroubleShoot:"#r_TroubleShoot"
- },
-
- /** ui selector cache */
- ui: {
-// graph : "#graphAgg",
- searchBox : '[data-id="mainSearch"]',
- searchBoxBtn : '[data-id="mainSearchBtn"]',
- compare:".compare .panel-heading",
- CompareButton:"[data-id='CompareButton']",
- CompareClearAll:"[data-id='CompareClearAll']",
- CloseCompareComponent:".hostCompList .closeComponent"
- //viewType: "input[name='viewType']",
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- //events['click #searchLog'] = 'onSearchLogClick';
- events["click "+this.ui.searchBoxBtn] = 'onSearchLogClick';
- events['change ' + this.ui.viewType] = 'onViewTypeChange';
- events['click button[data-tab-id]'] = 'onDeleteTabClick';
- events["click "+this.ui.compare] = function(e){
- this.togglePanelPosition(false,false);
- }
- events["click "+this.ui.CompareButton] = 'onCompareButtonClick';
- events["click "+this.ui.CompareClearAll] = 'onCompareClearAllClick';
- events["click "+this.ui.CloseCompareComponent] = function(e){
- this.onCloseCompareComponentClick($(e.currentTarget).parents('span').data().id,true);
- }
- events["click .nav.nav-tabs li"] = function(e){
- this.hideContextMenu();
- }
- return events;
- },
-
- /**
- * intialize a new MainLayoutView Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options,'globalVent'));
- this.vent = new Backbone.Wreqr.EventAggregator();
- this.dateUtil = Utils.dateUtil;
- this.bindEvents();
- this.componetList =[];
- },
- bindEvents : function(){
- this.listenTo(this.globalVent,"render:tab",function(options){
- var that = this;
- this.hideContextMenu();
- this.renderLogFileTab(options);
- setTimeout(function(){
- that.reAdjustTab()
- },1000);
-
- },this);
- this.listenTo(this.globalVent,"render:comparison:tab",function(options){
- this.hideContextMenu();
- this.renderComparisonTab(options);
- },this);
- this.listenTo(this.globalVent,"show:tab",function(tabName){
- this.showTab(tabName);
- },this);
- this.listenTo(this.globalVent,"add:compare",function($el){
- this.quickMenuCompare = true;
- this.onCompareLink($el);
- },this);
- },
- onRender : function(){
- this.renderTroubleShootTab();
- this.renderHierarchyTab();
- this.renderAuditTab();
- this.togglePanelPosition(true);
- this.bindTabCheckboxClick();
- this.bindTabClickListener();
- this.tabScrollBind();
- },
- onShow : function(){
- //navigating to specific component tab
- var params = ViewUtils.getDefaultParams();
- if(params.host_name && params.component_name){
- this.globalVent.trigger("render:tab",{
- params:_.extend({},{
- host_name : params.host_name,
- component_name : params.component_name
- },params),
- globalVent : this.globalVent
- });
- }
- },
- renderLogFileTab : function(view){
- var that = this;
- require(['views/tabs/LogFileView'], function(LogFileView){
- var tabName = (view.params.host_name + view.params.component_name).replace(/\./g,"_");
- if(_.isUndefined(that[tabName])){
- var region = {};
- region[tabName] = '#' + tabName;
- $('<div/>', {
- 'id': tabName,
- 'class': 'tab-pane',
- 'role':"tabpanel"
- }).appendTo(that.$('.tab-content'));
- that.addRegions(region);
- var region = that.getRegion(tabName);
- region.show(new LogFileView(view));
- that.$(".nav.nav-tabs").append('<li data-id="'+tabName+'" role="presentation">'+
- '<a data-id="'+tabName+'" data-host="'+view.params.host_name+'" data-component="'+view.params.component_name+'" href="#'+tabName+'" aria-controls="profile" role="tab" data-toggle="tab" title="'+view.params.host_name.split(".")[0]+' >> '+view.params.component_name+' ">'+view.params.host_name.split(".")[0]+'<b> >> </b>'+view.params.component_name+'</a>'+
- // '<span class="air air-top-right">'+
- '<button data-tab-id="'+tabName+'" class="btn-closeTab"><i class="fa fa-times-circle"></i></button>'+
- '<div class="compareClick" title="Compare"><i class="fa fa-square-o"></i></div>');
- // '<i class="fa fa-times"></i>'+
- // '</button></span></li>');
- }else{
- if(that[tabName].currentView){
- _.extend(that[tabName].currentView.params,view.params);
- that[tabName].currentView.render();
- }
- }
- //$("html, body").animate({ scrollTop: 0 }, 500);
- that.showTab(tabName);
- });
- },
- renderComparisonTab:function(view){
- var that = this;
- require(['views/tabs/ComparisonLayoutView'], function(ComparisonLayoutView){
- var tabName = "";
- _.each(view.componetList,function(object){
- if(object.host_name && object.component_name){
- tabName += (object.host_name + object.component_name).replace(/\./g,"_");
- }
- });
- if(_.isUndefined(that[tabName])){
- var region = {};
- region[tabName] = '#' + tabName;
- $('<div/>', {
- 'id': tabName,
- 'class': 'tab-pane',
- 'role':"tabpanel"
- }).appendTo(that.$('.tab-content'));
- that.addRegions(region);
- var region = that.getRegion(tabName);
- region.show(new ComparisonLayoutView(view));
- that.$(".nav.nav-tabs").append('<li data-id="'+tabName+'" role="presentation">'+
- '<a data-id="'+tabName+'" href="#'+tabName+'" aria-controls="profile" role="tab" data-toggle="tab">Compare</a>'+
- // '<span class="air air-top-right">'+
- '<button data-tab-id="'+tabName+'" class="btn-closeTab"><i class="fa fa-times-circle"></i></button>');
- // '<i class="fa fa-times"></i>'+
- // '</button></span></li>');
- }else{
- if(that[tabName].currentView){
- _.extend(that[tabName].currentView.params,view.params);
- that[tabName].currentView.render();
- }
- }
- $("html, body").animate({ scrollTop: 0 }, 500);
- that.showTab(tabName);
- });
-
- },
- showTab : function(tabId){
- this.$(".nav.nav-tabs li").removeClass("active");
- this.$("li[data-id='"+tabId+"']").addClass("active");
- this.$(".tab-pane").removeClass("active");
- this.$("#"+tabId).addClass("active");
- this.tabOpen = true;
- this.reAdjustTab();
- },
- onDeleteTabClick : function(e){
- var tabId = $(e.currentTarget).data("tab-id");
- if(this[tabId]){
- this[tabId].close && this[tabId].close();
- this.removeRegion(tabId);
- this.$("li[data-id="+tabId+"]").remove();
- this.$("#"+tabId).remove();
- this.showTab(this.$(".nav.nav-tabs li").last().data("id"));
- }
- },
- bindDraggableEvent : function(){
- Utils.bindDraggableEvent(this.$( "div.box").not('.no-drop'));
- },
- renderLogLevel : function(){
- var that = this;
- require(['views/dashboard/LogLevelView'], function(LogLevelView){
- that.RLogLevel.show(new LogLevelView({
- vent : that.vent,
- globalVent:that.globalVent
- }));
- })
-
- },
- renderComponents : function(){
- var that = this;
- require(['views/dashboard/ComponentsView'], function(ComponentsView){
- that.RComponents.show(new ComponentsView({
- vent : that.vent,
- globalVent:that.globalVent
- }));
- })
- },
- renderHosts : function(){
- var that = this;
- require(['views/dashboard/HostsView'], function(HostsView){
- that.RHosts.show(new HostsView({
- vent : that.vent,
- globalVent:that.globalVent
- }));
- });
- },
- renderBubbleTableView : function(){
- var that = this;
- require(['views/dashboard/BubbleGraphTableLayoutView'], function(BubbleTableLayoutView){
- that.RBubbleTable.show(new BubbleTableLayoutView({
- vent : that.vent,
- globalVent:that.globalVent
- }));
- });
- },
- renderTroubleShootTab:function(){
- var that = this;
- require(['views/troubleshoot/TroubleShootLayoutView'], function(TroubleShootLayoutView){
-
- that.RTroubleShoot.show(new TroubleShootLayoutView({
- globalVent:that.globalVent
- }));
- });
- },
- renderHierarchyTab : function(){
- var that = this;
- require(['views/tabs/HierarchyTabLayoutView'], function(HierarchyTabLayoutView){
- that.RHierarchyTab.show(new HierarchyTabLayoutView({
- globalVent:that.globalVent
- }));
- });
- },
- renderHostInfoTab : function(){
- var that = this;
- require(['views/tabs/HostInfoTabLayoutView'], function(HostInfoTabLayoutView){
- that.RHostInfoTab.show(new HostInfoTabLayoutView({
- globalVent:that.globalVent
- }));
- });
- },
- renderAuditTab : function(){
- var that = this;
- require(['views/audit/AuditTabLayoutView'], function(AuditTabLayoutView){
- that.RAuditTab.show(new AuditTabLayoutView({
- globalVent:that.globalVent
- }));
- });
- },
- hideContextMenu : function(){
- $(".contextMenu").hide();
- },
- onSearchLogClick : function(){
- var value = this.ui.searchBox.val();
- if(_.isEmpty(value)){
- this.ui.searchBox.val("*:*");
- value = "*:*";
- }
-// this.fetchGraphData({q : value});
-// this.fetchTableData(value);
- this.vent.trigger("main:search",{q:value});
- },
- //Style 2
- renderGraph : function(){
- var root = {
- name : "",
- dataList : this.graphModel.get("graphData")
- };
- var margin = 20,
- diameter = 880;//this.ui.graph.width();//960;
- this.ui.graph.empty();
-// var color = d3.scale.linear()
-// .domain([-1, 5])
-// .range(["hsl(152,90%,90%)", "hsl(228,30%,40%)"])
-// .interpolate(d3.interpolateHcl);
- var color = d3.scale.ordinal()
- .domain([0,1])
- //.range(["#ECFCBD","#ECFCBD","#ECE78F","#f4f4c8"]);
- .range(["#dddddd","#cccccc","#F5F5F5"]);
- var pack = d3.layout.pack()
- .padding(2)
- .size([diameter - margin, diameter - margin])
- .value(function(d) {
- return d.count; })
- .children(function(d){
- return d.dataList;
- })
-
- var svg = d3.select(this.ui.graph[0]).append("svg")
- .attr("width", diameter)
- .attr("height", diameter)
- .append("g")
- .attr("transform", "translate(" + diameter / 2 + "," + diameter / 2 + ")");
-
- //d3.json("flare.json", function(error, root) {
-
- var focus = root,
- nodes = pack.nodes(root),
- view;
- /*
- * Tip
- */
- var tipCirclePack = tip()
- .attr('class', 'd3-tip')
- .offset([-10, 0])
- .html(function(d) {
- var tempName = "<div>";
- if(d.parent){
- if(d.depth > 1)
- tempName += d.parent.name+" => ";
- tempName += d.name;
- }
- return tempName + "</div>";
- })
- svg.call(tipCirclePack);
- var circle = svg.selectAll("circle")
- .data(nodes)
- .enter().append("circle")
- .attr("class", function(d) {
- return d.parent ? d.children ? "node" : "node node--leaf "+d.name : "node node--root"; })
- .style("fill", function(d) {
- return d.children ? color(d.depth) : null; })
- .on("click", function(d) {
- if(d3.event.shiftKey){
- alert("open in new tab")
- }else{
- if (focus !== d) zoom(d), d3.event.stopPropagation();
- }
-
- })
- .on('mouseover', function (d,i) {
- if (d.x) {
- tipCirclePack.show(d);
- }
- })
- .on('mouseout', function (d,i) {
- if (d.x) {
- tipCirclePack.hide(d);
- }
- });
-
- var text = svg.selectAll("text")
- .data(nodes)
- .enter().append("text")
- .attr("class", "label")
- .style("fill-opacity", function(d) { return d.parent === root ? 1 : 0; })
- .style("display", function(d) { return d.parent === root ? null : "none"; })
- .text(function(d) {
- if(d.count){
- if(d.count > 0)
- return d.name;
- else
- return "";
- }else
- return d.name;
-
- });
-
- var node = svg.selectAll("circle,text");
-
- d3.select(this.ui.graph[0])
- .style("background", color(-1))
- .on("click", function() { zoom(root); });
-
- zoomTo([root.x, root.y, root.r * 2 + margin]);
- function zoom(d) {
- var focus0 = focus; focus = d;
-
- var transition = d3.transition()
- .duration(d3.event.altKey ? 7500 : 750)
- .tween("zoom", function(d) {
- var i = d3.interpolateZoom(view, [focus.x, focus.y, focus.r * 2 + margin]);
- return function(t) { zoomTo(i(t)); };
- });
-
- transition.selectAll("text")
- .filter(function(d) { return d.parent === focus || this.style.display === "inline"; })
- .style("fill-opacity", function(d) { return d.parent === focus ? 1 : 0; })
- .each("start", function(d) { if (d.parent === focus) this.style.display = "inline"; })
- .each("end", function(d) { if (d.parent !== focus) this.style.display = "none"; });
- }
-
- function zoomTo(v) {
- var k = diameter / v[2]; view = v;
- node.attr("transform", function(d) { return "translate(" + (d.x - v[0]) * k + "," + (d.y - v[1]) * k + ")"; });
- circle.attr("r", function(d) { return d.r * k; });
- }
- },
- bindTabCheckboxClick:function(){
- var that = this;
- this.$('div[role="tabpanel"] ul').on('click','li div.compareClick',function(){
- that.tabcheckBoxSelectDeselect($(this))
- })
- },
- tabcheckBoxSelectDeselect:function(el,fromEvent){
- var that = this,
- clickedId = this.$('div[role="tabpanel"] ul').find(el).parents('li').data('id');
- if (el.find('i').hasClass('fa-square-o')) {
- var idList = _.pluck(this.componetList, 'id');
- if (! _.contains(idList, clickedId)) {
- if(this.componetList.length >= 4){
- Utils.alertPopup({
- msg: "Currently only four components comparison supported."
- });
- return;
- }else{
- el.find('i').removeClass('fa-square-o').addClass('fa-check-square-o');
- this.quickMenuCompare = false;
- this.onCompareLink(el);
- }
- }else{
- el.find('i').removeClass('fa-square-o').addClass('fa-check-square-o');
- }
- } else {
- el.find('i').removeClass('fa-check-square-o').addClass('fa-square-o');
- if (!fromEvent) {
- this.onCloseCompareComponentClick(el.parents('li').find('a').data().id)
- }
- }
- },
- onCompareLink:function($el){
- this.togglePanelPosition(false, true);
- var clickedId = "",
- newValue = true,
- dataValue;
- if (this.quickMenuCompare) {
- dataValue = $el.data();
- if(dataValue.host){
- dataValue.id = dataValue.host.replace(/\./g, '_') + dataValue.node;
- }
- } else {
- dataValue = $el.parents('li').find('a').data();
- }
- if (dataValue.id) {
- var clickedId = dataValue.id;
- }
- _.each(this.componetList, function(object) {
- if (object.id.match(clickedId)) {
- newValue = false;
- }
- });
- if (this.componetList.length >= 4) {
- if (newValue) {
- Utils.alertPopup({
- msg: "Currently only four components comparison supported."
- });
- return;
- }
- }
- if (this.componetList.length <= 3 && newValue) {
- if (dataValue.host && (dataValue.component || dataValue.node)) {
- var host = dataValue.host;
- var component = dataValue.component || dataValue.node;
- var spanLength = this.$('.compare .panel-body span.hasNode');
- if (spanLength.length != 0 && spanLength.length >= 1) {
- this.componetList.push({ 'host_name': host, 'component_name': component, id: clickedId });
- this.$('.compare .panel-body .hostCompList').append('<span class="hasNode" data-id="' + clickedId + '"><i class=" closeComponent fa fa-times-circle"></i>' + host.split(".")[0] + ' <i class="fa fa-angle-double-right"></i><br> ' + component + '</span>');
- } else {
- this.componetList.push({ 'host_name': host, 'component_name': component, id: clickedId });
- this.$('.compare .panel-body .hostCompList').html('<span class="hasNode" data-id="' + clickedId + '"><i class=" closeComponent fa fa-times-circle"></i>' + host.split(".")[0] + ' <i class="fa fa-angle-double-right"></i><br> ' + component + '</span>');
- }
- }
- }
- this.quickMenuCompare = false;
- },
- onCompareButtonClick:function(){
- if(this.componetList.length == 1){
- Utils.alertPopup({
- msg: "Minimum two components are required for comparison. Please select one more component and try again."
- });
- }else{
- var dateRangeLabel ='Last 1 Hour';
- var dateObj = this.dateUtil.getRelativeDateFromString(dateRangeLabel);
-
- if (this.RHierarchyTab.currentView && this.RHierarchyTab.currentView.defaultParams) {
- var dateParams = this.RHierarchyTab.currentView.defaultParams;
- if (!_.isUndefined(dateParams) && _.isObject(dateParams)) {
- dateObj = {
- from: dateParams.from,
- to: dateParams.to,
- dateRangeLabel: dateParams.dateRangeLabel
- };
- }
- }
-
- this.globalVent.trigger("render:comparison:tab",{
- params: dateObj,
- componetList:this.componetList,
- globalVent : this.globalVent
- });
- }
- this.togglePanelPosition(false,false)
- },
- togglePanelPosition:function(hideFully,clickFromLi){
- if(hideFully){
- this.$('.compare').css('bottom', "-136px");
- this.$('.compare .panel-heading').addClass("down");
- return;
- }
- if (this.$('.compare .panel-heading').hasClass('down')) {
- this.$('.compare').css('bottom', "0px");
- this.$('.compare .panel-heading').removeClass("down")
- /* setTimeout(function() {
- this.$('.compare').css('bottom', (-(this.$('.compare .panel-body').height() + 39)) + "px");
- this.$('.compare .panel-heading').addClass("down");;
- }, 2000);*/
- } else if (!clickFromLi) {
- this.$('.compare').css('bottom', (-(this.$('.compare .panel-body').height() + 32)) + "px");
- this.$('.compare .panel-heading').addClass("down");
- }
- },
- onCompareClearAllClick:function(e){
- e.stopPropagation();
- this.componetList =[];
- this.$('.compare .panel-body .hostCompList').html('');
- this.$('div[role="tabpanel"] ul').find('li div.compareClick i').removeClass('fa-check-square-o').addClass('fa-square-o');
- this.togglePanelPosition(true)
- },
- onCloseCompareComponentClick:function(id,fromEvent){
- var clickedId = id,that = this;
- if (clickedId) {
- var clickedIndex = undefined;
- _.each(this.componetList, function(object, i) {
- if (object.id.match(clickedId)) {
- that.$('.compare .panel-body .hostCompList').find('span[data-id="'+id+'"]').remove();
- clickedIndex = i + 1;
- }
- });
- if (clickedIndex) {
- this.componetList.splice(clickedIndex - 1, 1);
- if(this.componetList.length == 0){
- this.togglePanelPosition(true);
- }else{
- this.togglePanelPosition(false,true);
- }
- }
- if(fromEvent){
- this.tabcheckBoxSelectDeselect(this.$('div[role="tabpanel"] ul').find('li[data-id="'+clickedId+'"] div.compareClick'),true)
- }
- }
- },
- bindTabClickListener:function(){
- var that = this;
- this.$("ul[role='tablist']").on('click','li',function(){
- that.globalVent.trigger("tab:click",this);
- });
- },
- tabScrollBind:function(){
- var hidWidth;
- var scrollBarWidths = 40;
- var that = this;
-
- var widthOfList = function(){
- var itemsWidth = 0;
- that.$('.list li').each(function(){
- var itemWidth = $(this).outerWidth();
- itemsWidth+=itemWidth;
- });
- return itemsWidth;
- };
-
- var widthOfHidden = function(){
- return (($('.wrapper').outerWidth())-widthOfList()-getLeftPosi())-scrollBarWidths;
- };
-
- var getLeftPosi = function(){
- return that.$('.list').position().left;
- };
-
- this.reAdjustTab = function(){
- if ((that.$('.wrapper').outerWidth()) < widthOfList()) {
- if(that.tabOpen){
- that.$('.list').animate({left:"+="+widthOfHidden()+"px"},'slow');
- that.tabOpen = false;
- }
- that.$('.scroller-right').show();
- }
- else {
- that.$('.scroller-right').hide();
- }
-
- if (getLeftPosi()<0) {
- that.$('.scroller-left').show();
- }
- else {
- that.$('.item').animate({left:"-="+(-200)+"px"},'slow');
- that.$('.scroller-left').hide();
- }
- }
-
-
- this.$('.scroller-right').click(function(e) {
-
- /* that.$('.scroller-left').fadeIn('slow');
- that.$('.scroller-right').fadeOut('slow');*/
- //console.log(widthOfHidden())
- if(widthOfHidden()+55 < 0){
- that.$('.list').animate({left:"+="+(-43)+"px"},0,function(){
- that.reAdjustTab();
- });
- }
-
- });
-
- this.$('.scroller-left').click(function() {
-
- /*that.$('.scroller-right').fadeIn('slow');
- that.$('.scroller-left').fadeOut('slow');*/
- //console.log(getLeftPosi())
- if(getLeftPosi() < 0){
- that.$('.list').animate({left:"-="+(-40)+"px"},0,function(){
- that.reAdjustTab();
- });
- }
-
- });
- },
- });
- return MainLayoutView;
-
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/ApplySearchFilterView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/ApplySearchFilterView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/ApplySearchFilterView.js
deleted file mode 100644
index 62b74c8..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/ApplySearchFilterView.js
+++ /dev/null
@@ -1,214 +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/Utils',
- 'hbs!tmpl/dialog/ApplySearchFilterView_tmpl'
-], function(require, Backbone, Utils, ApplySearchFilterViewTmpl) {
- 'use strict';
-
- return Backbone.Marionette.Layout.extend(
- /** @lends SaveSearchFilterView */
- {
- _viewName: 'SaveSearchFilterView',
-
- template: ApplySearchFilterViewTmpl,
-
-
- /** ui selector cache */
- ui: {
- applyFilter: "[data-id = 'applyFilter']",
- deleteFilter: "[data-id = 'deleteFilter']"
- },
-
- regions: {
- 'rTable': 'div[data-id="r_table"]'
- },
-
-
- /** ui events hash */
- events: function() {
- var events = {};
- events['click ' + this.ui.applyFilter] = 'onApplyClick';
- events['click ' + this.ui.deleteFilter] = 'onDeleteClick';
- events["click [data-id='searchFilter']"] = 'onSearchFilterClick';
- events["keypress [data-id='filterName']"] = 'onSearchFilterKeypress';
- return events;
- },
-
- /**
- * intialize a new SaveSearchFilterView Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options, 'collection'));
- this.dateUtil = Utils.dateUtil;
- this.bindEvents();
- this.fetchFilters();
-
- },
- bindEvents: function() {
- this.listenTo(this.collection, 'reset', function() {
-
- }, this);
- },
- onRender: function() {
- this.renderTable();
- },
- fetchFilters: function() {
-
- var that = this;
- $.extend(this.collection.queryParams, {
- rowType:"history"
- });
- this.collection.getFirstPage({
- error: function(jqXHR, textStatus, errorThrown) {
- Utils.notifyError({
- content: "There is some problem in Event History, Please try again later."
- });
- that.initializeData();
- },
- reset: true
- });
- },
- renderTable: function() {
- var that = this;
- var cols = new Backgrid.Columns(this.getColumns());
- require(['views/common/TableLayout'],function(TableLayout){
- that.rTable.show(new TableLayout({
- columns: cols,
- collection: that.collection,
- includeFilter: false,
- includePagination: true,
- includePageSize: true,
- includeFooterRecords: true,
- gridOpts: {
- emptyText: 'No records found!'
- },
- filterOpts: {},
- paginatorOpts: {}
- }));
- });
- },
- getColumns: function() {
- var that = this,
- cols = {
- filtername: {
- label: "Name",
- cell: "String",
- editable: false,
- sortType: 'toggle',
- sortable: true,
- direction: 'ascending',
- className: "filterName",
- width: 20
- },
- values: {
- label: "Message",
- cell: "html",
- editable: false,
- sortType: 'toggle',
- sortable: false,
- className: "logMessage",
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function(rawValue, model) {
- return that.showParams(JSON.parse(rawValue), model.get('id'))
-
- }
- })
-
- }
- }
-
-
- return this.collection.constructor.getTableCols(cols, this.collection);
- },
- showParams: function(params, id) {
-
- return '<pre class="applyFilter">' +
- '<button class="btn btn-primary btn-app-sm pull-right" data-nameId="' + id + '" data-id="applyFilter"><i class="fa fa-check"></i></button>' +
- '<button class="btn btn-primary btn-app-sm pull-right" data-nameId="' + id + '" data-id="deleteFilter"><i class="fa fa-times"></i></button>' +
- '<strong>Range:</strong>' + (this.createInnerSpan(params, "from")) + '<strong> :To: :</strong>' + (this.createInnerSpan(params, "to")) + '<br>' +
- '<strong>Level:</strong>' + (this.createInnerSpan(params, "level")) + '<br>' +
- '<strong>Include Components:</strong>' + (this.createInnerSpan(params, "mustBe")) + '<br>' +
- '<strong>Exclude Components:</strong>' + (this.createInnerSpan(params, "mustNot")) + '<br>' +
- '<strong>Include Columns:</strong>' + (this.createInnerSpan(params, "includeQuery")) + '<br>' +
- '<strong>Exclude Columns:</strong>' + (this.createInnerSpan(params, "excludeQuery")) +
- '</pre>';
-
- },
- createInnerSpan: function(params, type) {
- var typeString = "",
- that = this;
- if (params[type]) {
- if(type == "includeQuery" || type == "excludeQuery"){
- typeString += "<span>"+params[type].replace("},{",",").replace("[{","").replace("}]","")+"</span>";
- }else{
- Utils.encodeIncludeExcludeStr(params[type], false, ((type == "iMessage" || type == "eMessage") ? ("|i::e|") : (","))).map(function(typeName) {
- typeString += '<span class="' + ((type != "level") ? (type) : (typeName)) + '">' +
- ((type == "from" || type == "to") ? (that.dateUtil.getTimeZone(params[type])) : (Utils.escapeHtmlChar(typeName))) + '</span>' +
- ((type == "level") ? (",") : (""));
- });
- }
-
- }
- return ((typeString.length == 0) ? ("-") : ((type == "level") ? ((typeString).slice(0, -1)) : (typeString)))
- },
- onApplyClick: function(e) {
- this.selectedModel = this.collection.findWhere({
- id: ""+parseInt($(arguments[0].currentTarget).attr('data-nameId'))
- });
- this.trigger("apply:filter",this.selectedModel);
- },
- onDeleteClick: function(e) {
- var that = this;
- var postObject = {
- id: parseInt($(arguments[0].currentTarget).attr('data-nameId'))
- }
- this.collection.deleteEventHistory(postObject, {
- success: function(data, textStatus, jqXHR) {
- Utils.notifySuccess({
- content: "Event History Deleted successfully."
- });
- that.fetchFilters();
- },
- error: function(jqXHR, textStatus, errorThrown) {
- Utils.notifyError({
- content: "There is some problem in Event History, Please try again later."
- });
- }
- });
-
- },
- onSearchFilterClick: function() {
- var filterName = this.$("[data-id='filterName']").val();
- $.extend(this.collection.queryParams, {
- filterName: filterName
- });
- this.fetchFilters();
- },
- onSearchFilterKeypress: function(e) {
- if (e.which == 13) {
- this.onSearchFilterClick();
- }
- }
- });
-
-
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/DetailLogFileView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/DetailLogFileView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/DetailLogFileView.js
deleted file mode 100644
index 689bacd..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/DetailLogFileView.js
+++ /dev/null
@@ -1,167 +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/Utils',
- 'utils/ViewUtils',
- 'hbs!tmpl/dialog/DetailLogFileView_tmpl',
- 'collections/VLogList'
-],function(require,Backbone,Utils,ViewUtils,DetailLogFileView_tmpl, VLogList) {
- 'use strict';
-
- return Backbone.Marionette.ItemView.extend(
- /** @lends DetailLogFileView */
- {
- _viewName: 'DetailLogFileView',
-
- template: DetailLogFileView_tmpl,
-
-
- /** ui selector cache */
- ui: {
- logsContainer: ".logsContainer",
- prevBtn : "[data-id='prev']",
- nextBtn : "[data-id='next']"
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- events["click .logsDetail button"] = 'onButtonClick';
- return events;
- },
-
- /**
- * intialize a new TimeZoneChangeView Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options, 'model'));
- this.collection = new VLogList([],{
- state: {
- firstPage: 0,
- pageSize: 9999
- }
- });
- this.defaultRecords = 10;
- this.params = {};
- },
- bindEvents: function() {
- var that = this;
- },
- onRender: function() {
- var that = this;
- this.fetchLogs({
- host_name : this.model.get("host"),
- component_name : this.model.get("type"),
- numberRows : this.defaultRecords,
- id : this.model.get("id")
- },{
- beforeSend : function(){
- that.ui.logsContainer.append("<b>Loading...</b>");
- },
- success : function(data){
- that.collection.reset(data.logList);
- that.renderLogs();
- }
- });
- },
- fetchLogs : function(params,options){
- $.extend(this.params,params);
- this.collection.getTruncatedLogs(this.params,_.extend({
- error :function(error,data,status){
- var obj = JSON.parse(error.responseText);
- Utils.notifyError({content:obj.msgDesc});
- that.ui.logsContainer.html("");
- }
- },options));
- },
- renderLogs: function() {
- var that = this;
- that.ui.logsContainer.html("<hr>")
- this.collection.each(function(model){
- var highlightClass = "highlightLog";
- that.ui.logsContainer.append("<div data-id='"+model.get("id")+"' class='"+(that.model.get("id") === model.get("id") ? highlightClass : "")+"'><pre>"+ViewUtils.foramtLogMessageAsLogFile(model, "mess")+"</pre></div>");
- });
- that.ui.logsContainer.append("<hr>")
- var top = this.$("[data-id="+this.model.get("id")+"]").position().top;
- this.scrollToLogEntry(top -200,300);
- this.$("button[data-id]").removeClass("hidden");
- },
- appendLogs : function(data,type){
- var isNext = (type === "next") ? true : false,that=this;
- if(data.length == 0 && (!isNext)){
- that.ui.logsContainer.prepend("<span>no records found!</span>");
- that.ui.prevBtn.hide();
- }
- _.each(data,function(log,i){
- var html = "<div data-id='"+log.id+"'><pre>"+ViewUtils.foramtLogMessageAsLogFile(new Backbone.Model(log),"mess")+"</pre></div>";
- if(isNext)
- that.ui.logsContainer.append(html);
- else
- that.ui.logsContainer.prepend(html);
- });
- if(isNext)
- that.ui.logsContainer.append("<hr>");
- else
- that.ui.logsContainer.prepend("<hr>");
- },
- onButtonClick : function(e){
- var $el = $(e.currentTarget),that=this,type = $el.data("id"),isNext = (type === "next") ? true : false;
- $el.addClass("disabled");
- $el.find("span").text("loading more "+this.defaultRecords);
- this.toggleLoadMoreBtn($el);
- var $row = isNext ? this.ui.logsContainer.find("[data-id]").last() : this.ui.logsContainer.find("[data-id]").first();
- if($row){
- this.fetchLogs({
- id : $row.data("id"),
- scrollType : isNext ? "after" : "before"
- },{
- success : function(data){
- that.appendLogs(data.logList,type);
- },
- complete : function(){
- $el.removeClass("disabled");
- $el.find("span").text("Load more");
- that.toggleLoadMoreBtn($el);
- if(! isNext){
- var top = that.$("[data-id="+$row.data("id")+"]").position().top;
- that.scrollToLogEntry(top - 50,0);
- }
- }
- });
- }
- },
- toggleLoadMoreBtn : function($btn){
- var $i = $btn.find('i'),className = ($btn.data("id") === "next") ? "fa-arrow-down" : "fa-arrow-up";
- if($i.hasClass(className)){
- $i.removeClass(className).addClass("fa-spinner fa-spin");
- }else
- $i.removeClass("fa-spinner fa-spin").addClass(className);
- },
- scrollToLogEntry : function(top,speed){
- this.$(".logsDetail").animate({ scrollTop : (top) }, speed);
- },
- onClose : function(){
- }
-
- });
-
-
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/GlobalExclusionCompositeView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/GlobalExclusionCompositeView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/GlobalExclusionCompositeView.js
deleted file mode 100644
index ffef322..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/GlobalExclusionCompositeView.js
+++ /dev/null
@@ -1,141 +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/VGroupList',
- 'hbs!tmpl/dialog/GlobalExclusionCompositeView_tmpl',
- 'views/dialog/GlobalExclusionItemView'
-],function(require,Backbone,Globals,VGroupList,GlobalExclusionCompositeView,GlobalExclusionItemView) {
- 'use strict';
-
- return Backbone.Marionette.CompositeView.extend(
- /** @lends GlobalExclusionListView */
- {
- _viewName: 'GlobalExclusionListView',
-
- template: GlobalExclusionCompositeView,
-
- itemView: GlobalExclusionItemView,
-
- itemViewContainer: "div[data-id='addRowDiv']",
-
- itemViewOptions: function() {
- return {
- col: this.componentsList
- }
- },
-
- initialize: function(options) {
-
- _.extend(this, _.pick(options, 'exclusionObj'));
- this.componentsList = new VGroupList([], {
- state: {
- pageSize: 1000
- }
- });
- this.componentsList.url = Globals.baseURL + "service/logs/components";
-
- this.collection = this.exclusionObj.logMessageCollection;
- if (this.collection.length == 0) {
- this.collection.add(new this.collection.model());
- }
-
- this.bindEvents();
- },
- /** Layout sub regions */
- regions: {},
-
- /** ui selector cache */
- ui: {
- addRow: "button[data-id='addRowButton']",
- addRowDiv: "div[data-id='addRowDiv']",
- getRow: "div[data-id='getRow']",
- select2Input: ".select2IComponents",
- select2Load:".select2Load"
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- events['click ' + this.ui.addRow] = 'onAddRow';
- return events;
- },
-
- /**
- * intialize a new GlobalExclusionLView Layout
- * @constructs
- */
-
- onRender: function() {
- this.componentsList.fetch({
- reset: true
- });
- this.ui.select2Input.select2({
- placeholder: 'Exclude Components',
- data: [],
- width: '75%',
- });
- this.ui.select2Input.select2("disable");
- },
- onAddRow: function() {
- this.collection.add(new this.collection.model());
- },
- bindEvents: function() {
- this.listenTo(this.componentsList, "reset", function(col, abc) {
- this.setupSelect2Fields(col, "type", 'type', 'excludeComponents', 'Exclude Components');
- this.setComponentsList(this.exclusionObj.components)
- // this.setupSelect2Fields(col, "type", 'type', 'includeComponents', 'Include Components');
- }, this);
- },
- setupSelect2Fields: function(col, idKey, textKey, selectTagId, placeHolder) {
- var that = this,
- data = [];
- data = _.pluck(col.models, 'attributes');
- for (var i = 0; i < data.length; i++) {
- data[i].id = data[i].type;
- }
- this.ui.select2Input.select2({
- placeholder: (placeHolder) ? placeHolder : 'Select',
- tags: true,
- allowClear: true,
- width: '75%',
- data: {
- results: data,
- text: textKey
- },
- formatSelection: function(item) {
- return item[textKey];
- },
- formatResult: function(item) {
- return item[textKey];
- }
- })
- this.ui.select2Input.select2("enable");
- this.ui.select2Load.hide();
- },
- setComponentsList: function(values) {
- if (values)
- this.ui.select2Input.select2('val', values);
- else
- this.ui.select2Input.select2('val', []);
- }
-
- });
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/GlobalExclusionItemView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/GlobalExclusionItemView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/GlobalExclusionItemView.js
deleted file mode 100644
index 855a1c9..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/GlobalExclusionItemView.js
+++ /dev/null
@@ -1,84 +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/VGroupList',
- 'hbs!tmpl/dialog/GlobalExclusionItemView_tmpl'
-],function(require,Backbone,Globals,VGroupList,GlobalExclusionItemViewTmpl) {
- 'use strict';
-
- return Backbone.Marionette.ItemView.extend(
- /** @lends GlobalExclusionListView */
- {
-
- template: GlobalExclusionItemViewTmpl,
-
- /** Layout sub regions */
- regions: {},
-
- /** ui selector cache */
- ui: {
- selectionTypeLOV: "select[data-id='selectionTypeLOV']",
- /* select2Input: ".select2IComponents",*/
- textArea: "div[data-id='L']",
- closeButton: "div[data-id='closeButton']"
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- events['change ' + this.ui.selectionTypeLOV] = 'onSelectionTypeLOVClicked';
- events['click ' + this.ui.closeButton] = 'onCloseButton';
- return events;
- },
-
- /**
- * intialize a new GlobalExclusionComponentView Layout
- * @constructs
- */
- initialize: function(options) {
- this.componentsList = options.col
- this.bindEvents();
- },
- onRender: function() {
- var that = this;
- this.$('textarea').text(that.model.get('message'));
- },
- bindEvents: function() {},
- /*changeDisplayType: function() {
- if (this.ui.selectionTypeLOV.val() == "C") {
- this.ui.textArea.hide();
- this.$('.select2IComponents').show();
- } else if (this.ui.selectionTypeLOV.val() == "L") {
- this.$('.select2IComponents').hide();
- this.ui.textArea.show();
-
- }
- },*/
- onSelectionTypeLOVClicked: function() {
- this.changeDisplayType();
- },
-
- onCloseButton: function() {
- this.model.destroy();
- }
-
- });
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/GridGraphSettingView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/GridGraphSettingView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/GridGraphSettingView.js
deleted file mode 100644
index c1d1d22..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/GridGraphSettingView.js
+++ /dev/null
@@ -1,476 +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/Utils',
- 'utils/Globals',
- 'collections/VAuditLogList',
- 'hbs!tmpl/dialog/GridGraphSettingView_tmpl',
- 'bootstrap-daterangepicker'
-], function(require, Backbone, Utils, Globals, VAuditLogList, GridGraphSettingViewTmpl, daterangepicker) {
- 'use strict';
-
- return Backbone.Marionette.Layout.extend(
- /** @lends GridGraphSettingView */
- {
- _viewName: 'GridGraphSettingView',
-
- template: GridGraphSettingViewTmpl,
- templateHelpers: function() {
- return {
- title: this.options.title,
- showLegend: this.options.showLegend,
- showY: this.options.showY,
- showX: this.options.showX,
- unit: this.options.unit,
- xTimeFormat: this.options.xTimeFormat,
- xNormalFormat: this.options.xNormalFormat,
- yAxisFormat: this.options.yAxisFormat,
- stackOrGroup: this.options.stackOrGroup,
- pieOrDonut: this.options.pieOrDonut,
- viewTypePie: this.pieView,
- firstTime: this.firstTime
- };
- },
-
-
- /** ui selector cache */
- ui: {
- select2XColumns: ".select2XColumns",
- select2XType: ".select2XType",
- select2Y: ".select2Y",
- select2StackColumns: ".select2StackColumns",
- startDate: "#startDate",
- endDate: "#endDate",
- dateRangeTitle: ".dateRangeTitle:not('.custome')",
- input: "input:not('.unbind')",
- select: "select[data-fetch='true']",
- selectXAxis: "[data-id='selectx']",
- column: "[data-id='column']",
- time: "[data-id='time']",
- showXBox: "[data-id='showX']",
- alert: "[data-id='alert']",
- stackOrGroupLov: "[data-id='stackOrGroupLov']"
- },
-
-
- /** ui events hash */
- events: function() {
- var events = {};
- events['click ' + this.ui.applyFilter] = 'onApplyClick';
- events['click ' + this.ui.deleteFilter] = 'onDeleteClick';
- events['click ' + this.ui.dateRangeTitle] = 'onRelativeDateClick';
- events['change ' + this.ui.selectXAxis] = 'onSelectXAxis';
- events['change ' + this.ui.input] = 'onInputChanges';
- events['change ' + this.ui.select] = 'onInputChanges';
- return events;
- },
-
- /**
- * intialize a new GridGraphSettingView Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options, 'vent', 'model', 'viewType'));
- if (this.model) {
- this.options = this.model.toJSON();
- if (!this.options.params) {
- this.firstTime = true;
- }
- }
- this.dateUtil = Utils.dateUtil;
-
- this.params = {};
- if (!this.viewType || this.viewType == Globals.graphType.HISTOGRAM.value) {
- this.histogramView = true;
- } else if (this.viewType == Globals.graphType.MULTILINE.value) {
- this.lineView = true;
- } else if (this.viewType == Globals.graphType.PIE.value) {
- this.pieView = true;
- }
- this.initializeCollection();
- this.bindEvents();
- },
- bindEvents: function() {
-
-
- },
- onRender: function() {
- this.initializePlugins(this.listOfselect2);
- //this.ui.column.hide();
- this.initializeDateRangePicker();
- this.initializePopover();
- if (this.options) {
- if (!this.options.stackOrGroup && (this.options.stackOrGroup == "" || this.options)) {
- this.$('.normalRadio').prop("checked", true);
- }
- if (this.options.xAxis == "evtTime") {
- this.$('.xTimeFormat').show();
- this.$('.xNormalFormat').hide();
-
- } else {
- this.$('.xNormalFormat').show();
- this.$('.xTimeFormat').hide();
- }
-
- }
- this.stackPrvValue = "Normal";
- },
- getDefaultDate: function() {
- var todayDate = this.dateUtil.getRelativeDateFromString('Today');
- return todayDate;
- },
- initializeDateRangePicker: function() {
- var that = this;
- this.ui.startDate.daterangepicker({
- singleDatePicker: true,
- showDropdowns: false,
- timePicker: true,
- autoApply: true,
- autoUpdateInput: true,
- timePicker: true,
- timePickerIncrement: 1,
- timePicker24Hour: true,
- timePickerSeconds: true,
- timeZone: 0,
- locale: {
- format: 'MM/DD/YYYY H:mm:ss,SSS'
- }
- }, function(start, end, labe) {
- if (that.relativeDateSet) {
- that.relativeDateSet = false;
- }
- that.$el.find('.dateRangeTitle.custome').addClass('active').siblings().removeClass('active');
- that.startDate = start;
- that.onDateChanged();
- });
- this.ui.endDate.daterangepicker({
- singleDatePicker: true,
- showDropdowns: true,
- timePicker: true,
- autoApply: true,
- autoUpdateInput: true,
- timePicker: true,
- timePickerIncrement: 1,
- timePicker24Hour: true,
- timePickerSeconds: true,
- timeZone: 0,
- locale: {
- format: 'MM/DD/YYYY H:mm:ss,SSS'
- }
- }, function(start, end, labe) {
- if (that.relativeDateSet) {
- that.relativeDateSet = false;
- }
- that.$el.find('.dateRangeTitle.custome').addClass('active').siblings().removeClass('active');
- that.endDate = start;
- that.onDateChanged();
- });
- if (this.options && this.options.params) {
- this.setDateText(this.dateUtil.getMomentObject(this.options.params.from), this.dateUtil.getMomentObject(this.options.params.to));
- this.params = this.options.params;
- if (this.params.dateRangeTitle) {
- that.$el.find('.dateRangeTitle:contains(' + this.params.dateRangeTitle + ')').addClass('active').siblings().removeClass('active');
- }
- } else {
- var getdateObject = this.getDefaultDate();
- this.setDateText(getdateObject[0], getdateObject[1]);
- this.params = this.setDateParams();
- }
-
-
-
- },
- onInputChanges: function(e) {
- var data = $(e.currentTarget).data(),
- key = e.currentTarget.name,
- dataObject = this.getData(),
- value = dataObject[key];
- if (key == "stackOrGroup") {
- this.ui.stackOrGroupLov.find('label').text(value);
- if (value == "Normal") {
- this.stackPrvValue = value;
- this.vent.trigger('graph:data:update', {
- "stackBy": null
- }, dataObject);
-
- this.ui.select2StackColumns.select2("disable");
- return;
- } else {
- this.ui.select2StackColumns.select2("enable");
- if (this.stackPrvValue == "Normal" && this.ui.select2StackColumns.val() != "") {
- this.stackPrvValue = value;
- this.vent.trigger('graph:data:update', {
- "stackBy": this.ui.select2StackColumns.val()
- }, dataObject);
-
- return;
- } else {
- this.stackPrvValue = value;
- }
-
- }
-
- }
- if (key == "xAxis") {
- if (value == "evtTime") {
- this.$('.xTimeFormat').show();
- this.$('.xNormalFormat').hide();
- } else {
- this.$('.xTimeFormat').hide();
- this.$('.xNormalFormat').show();
- }
- }
- var obj = {};
- // For Temp we set y axis explicitly
- if (dataObject.yAxis && dataObject.yAxis != "") {
- obj['yAxis'] = dataObject['yAxis'];
- }
- if (data.fetch) {
- obj[key] = value;
-
- /* if (key == "xAxis" && key == "yAxis" && dataObject.xAxis && dataObject.xAxis != "") {
- if (this.ui.time.is(':hidden')) {
- this.ui.alert.removeClass('text-danger').addClass(' text-success');
- } else {
- this.ui.alert.removeClass('text-success').addClass('text-danger');
- }
- } else {
- this.ui.alert.removeClass('text-success').addClass('text-danger');
- }*/
- this.triggerFetch(obj, dataObject);
- } else if (data.grid) {
- this.vent.trigger('graph:grid:update', dataObject);
- } else {
- this.vent.trigger('graph:update', dataObject);
-
- }
- },
- onDateChanged: function(value) {
- var dataObject = this.getData();
- var params = this.setDateParams();
- if (dataObject.xAxis && dataObject.xAxis != "" && dataObject.yAxis && dataObject.yAxis != "") {
- this.triggerFetch(params, dataObject);
- }
-
- },
- setDateParams: function() {
- if (this.startDate && this.endDate) {
-
- var dateUnit = this.dateUtil.calculateUnit({
- startDate: this.startDate,
- endDate: this.endDate
- });
- $('input[name="unit"]').val(dateUnit.substr(1));
-
- var params = {
- from: this.startDate.toJSON(),
- to: this.endDate.toJSON(),
- unit: dateUnit
- }
- return params;
- }
- },
- triggerFetch: function(params, object) {
- this.vent.trigger('graph:data:update', $.extend(this.params, params), object);
- },
- getData: function() {
- return Utils.getFormData(this.$("#CreateLogicForm").serializeArray());
- },
- onRelativeDateClick: function(e) {
- this.relativeDateSet = true;
- this.params['dateRangeTitle'] = $(e.currentTarget).text()
- $(e.currentTarget).addClass('active').siblings().removeClass('active');
- var relativeDate = $(e.currentTarget).text()
- var date = this.dateUtil.getRelativeDateFromString(relativeDate);
- this.setDateText(date[0], date[1], true);
- },
- setDateText: function(start, end, fetch) {
- this.ui.startDate.data('daterangepicker').setStartDate(start);
- this.startDate = start;
- this.ui.startDate.val(this.dateUtil.getTimeZone(start, "MM/DD/YYYY H:mm:ss,SSS"));
- this.ui.endDate.data('daterangepicker').setStartDate(end);
- this.endDate = end;
- if (fetch) {
- this.ui.endDate.val(this.dateUtil.getTimeZone(end, "MM/DD/YYYY H:mm:ss,SSS"));
- this.onDateChanged();
- } else {
- this.ui.endDate.val(this.dateUtil.getTimeZone(end, "MM/DD/YYYY H:mm:ss,SSS"));
- }
-
-
- },
- initializePopover: function() {
- var that = this;
- this.$('.timeInfo').popover({
- html: true,
- animation: true,
- container: 'body',
- placement: "auto",
- trigger: 'click',
- content: function() {
- return ('<ul class="d3TimeDetails">' +
- '<li>' +
- '<code>%a</code> - abbreviated weekday name.</li>' +
- '<li>' +
- '<code>%A</code> - full weekday name.</li>' +
- '<li>' +
- '<code>%b</code> - abbreviated month name.</li>' +
- '<li>' +
- '<code>%B</code> - full month name.</li>' +
- '<li>' +
- '<code>%c</code> - date and time, as "%a %b %e %H:%M:%S %Y".</li>' +
- '<li>' +
- '<code>%d</code> - zero-padded day of the month as a decimal number [01,31].</li>' +
- '<li>' +
- '<code>%e</code> - space-padded day of the month as a decimal number [ 1,31]; equivalent to <code>%_d</code>.</li>' +
- '<li>' +
- '<code>%H</code> - hour (24-hour clock) as a decimal number [00,23].</li>' +
- '<li>' +
- '<code>%I</code> - hour (12-hour clock) as a decimal number [01,12].</li>' +
- '<li>' +
- '<code>%j</code> - day of the year as a decimal number [001,366].</li>' +
- '<li>' +
- '<code>%m</code> - month as a decimal number [01,12].</li>' +
- '<li>' +
- '<code>%M</code> - minute as a decimal number [00,59].</li>' +
- '<li>' +
- '<code>%L</code> - milliseconds as a decimal number [000, 999].</li>' +
- '<li>' +
- '<code>%p</code> - either AM or PM.</li>' +
- '<li>' +
- '<code>%S</code> - second as a decimal number [00,61].</li>' +
- '<li>' +
- '<code>%U</code> - week number of the year (Sunday as the first day of the week) as a decimal number [00,53].</li>' +
- '<li>' +
- '<code>%w</code> - weekday as a decimal number [0(Sunday),6].</li>' +
- '<li>' +
- '<code>%W</code> - week number of the year (Monday as the first day of the week) as a decimal number [00,53].</li>' +
- '<li>' +
- '<code>%x</code> - date, as "%m/%d/%Y".</li>' +
- '<li>' +
- '<code>%X</code> - time, as "%H:%M:%S".</li>' +
- '<li>' +
- '<code>%y</code> - year without century as a decimal number [00,99].</li>' +
- '<li>' +
- '<code>%Y</code> - year with century as a decimal number.</li>' +
- '<li>' +
- '<code>%Z</code> - time zone offset, such as "-0700".</li>' +
- '<li>' +
- '<code>%</code> - a literal "%" character.</li>' +
- '</ul>');
- }
- });
- this.$el.find('.Header span[data-id="gridSettingPopup"]').on('shown.bs.popover', function(e) {
- //$(this).addClass("gridPopover")
- });
-
- },
- initializeCollection: function() {
- var that = this;
- this.auditLogList = new VAuditLogList([], {
- state: {
- firstPage: 0,
- pageSize: 50
- }
- });
-
- var getAuditSchemaFieldsName = function(el) {
- that.auditLogList.getAuditSchemaFieldsName({}, {
- beforeSend: function() {
- that.$("#loaderAudit").show();
- },
- success: function(data) {
- var myData = [];
- _.each(data, function(a, b) {
- myData.push({
- id: b,
- text: a
- })
- })
- el.select2({
- data: myData
- });
- if (el[0].name == "xAxis") {
- el.select2("enable");
- }
- if (el[0].name == "stackBy" && (that.options.stackOrGroup == "Group" || that.options.stackOrGroup == "Stack")) {
- el.select2("enable");
- }
- if (that.model) {
- if (that.model.get('xAxis') && el[0].name == "xAxis") {
- that.ui.select2XColumns.select2('val', that.model.get('xAxis'))
- }
- if (that.model.get('stackBy') && el[0].name == "stackBy") {
- that.ui.select2StackColumns.select2('val', that.model.get('stackBy'))
- }
-
- }
- //that.collection.reset(new Backbone.Model(myData));
- },
- error: function(error, data, status) {
- var obj = JSON.parse(error.responseText);
- if (obj)
- Utils.notifyError({
- content: obj.msgDesc
- });
- },
- complete: function() {
- that.$("#loaderAudit").hide();
- }
- });
-
- }
-
- this.listOfselect2 = [{
- id: "select2XType",
- placeholder: "Select X axis",
- mandatory: false,
- attachSelect: true
- }, {
- id: "select2Y",
- placeholder: "select Y",
- mandatory: false,
- attachSelect: true
- }, {
- id: "select2XColumns",
- placeholder: "select Columns",
- collection: this.auditLogList, //pass string or object reference
- mandatory: false,
- nonCrud: getAuditSchemaFieldsName, // pass function
- fetch: true
- }]
- if (!this.pieView) {
- this.listOfselect2.push({
- id: "select2StackColumns",
- placeholder: "select Columns",
- collection: this.auditLogList, //pass string or object reference
- mandatory: false,
- nonCrud: getAuditSchemaFieldsName, // pass function
- fetch: true
- })
- }
- },
- initializePlugins: function(listOfselect2) {
- Utils.genrateSelect2(listOfselect2, this);
- }
-
-
- })
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/SaveSearchFilterView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/SaveSearchFilterView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/SaveSearchFilterView.js
deleted file mode 100644
index fc44f61..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dialog/SaveSearchFilterView.js
+++ /dev/null
@@ -1,120 +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/Utils',
- 'utils/Globals',
- 'hbs!tmpl/dialog/SaveSearchFilterView_tmpl'
-], function(require, Backbone, Utils, Globals, SaveSearchFilterViewTmpl) {
- 'use strict';
-
- return Backbone.Marionette.Layout.extend(
- /** @lends SaveSearchFilterView */
- {
- _viewName: 'SaveSearchFilterView',
-
- template: SaveSearchFilterViewTmpl,
-
-
- /** ui selector cache */
- ui: {
- radioAbsolute: "[data-id = 'absolute']",
- radioRelative: "[data-id='relative']",
- paramsPanelBody: "[data-id='panelBody']",
- panelHeading: "[data-id='panelHeading']",
- filterName: "[data-id='name']"
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- events['change ' + this.ui.viewType] = 'onViewTypeChange';
- return events;
- },
-
- /**
- * intialize a new SaveSearchFilterView Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options, 'selectedCollectionObject'));
- this.dateUtil = Utils.dateUtil;
-
-
- },
- bindEvents: function() {
- this.listenTo(this, "dialog:rendered", function(value) {
- this.popoverForTd();
- }, this);
- },
- onRender: function() {
- this.params = this.selectedCollectionObject.get('params');
- //this.ui.panelHeading.html("Filter Parameter From : <strong>"+ this.dateUtil.getTimeZone(this.params.from) +"</strong> To <strong>" +this.dateUtil.getTimeZone(this.params.from)+"</strong>" )
- this.ui.radioAbsolute.find('label').html(' <input type="radio" name="radio" checked>' + this.dateUtil.getTimeZone(this.params.from) + '   TO                         ' + this.dateUtil.getTimeZone(this.params.to) + '<i class="fa fa-circle-o small"></i>');
- if (this.params.dateRangeLabel == "Custom Range") {
- this.ui.radioRelative.find('label').html(' <input type="radio" name="radio" disabled="disabled">' + this.params.dateRangeLabel + '<i class="fa fa-circle-o small"></i>');
- this.ui.radioRelative.css('color', '#8C8C8C');
- } else {
- this.ui.radioRelative.find('label').html(' <input type="radio" name="radio">' + this.params.dateRangeLabel + '<i class="fa fa-circle-o small"></i>');
- }
- this.showParams();
- },
- showParams: function() {
- var tableSting = "",
- that = this;
- var customParam = {"mustNot":[],"mustBe":[],"includeQuery":[],"excludeQuery":[]};
- var paramNames = _.extend({},this.params,customParam);
- _.each(paramNames, function(value, key) {
- if ((key != "from" && (! _.isEmpty(value) || _.isArray(value)) && key != "to" && key != "bundleId" && key != "start_time" &&
- key != "end_time" && key != "q" && key != "unit" && key != "query" && key != "type" &&
- key != "time" && key != "dateRangeLabel" && key != "advanceSearch" && !_.isUndefined(Globals.paramsNameMapping[key]) )) {
- tableSting += '<tr class="' + key + '"><td>' + Globals.paramsNameMapping[key].label + '</td><td>' + (that.createInnerSpan(key)) + '</td><tr>'
- }
- });
- this.ui.paramsPanelBody.html(tableSting);
- },
- createInnerSpan: function(type) {
- var typeString = "",
- that = this;
- if (this.params[type]) {
- Utils.encodeIncludeExcludeStr(this.params[type], false, ((type == "iMessage" || type == "eMessage") ? ("|i::e|") : (","))).map(function(typeName) {
- typeString += '<span class="' + ((type != "level") ? (type) : (typeName)) + '">' +
- ((type == "from" || type == "to") ? (that.dateUtil.getTimeZone(that.params[type])) : (Utils.escapeHtmlChar(typeName))) + '</span>' +
- ((type == "level") ? (",") : (""));
- });
- }
- return ((typeString.length == 0) ? ("[ ]") : ((type == "level") ? ((typeString).slice(0, -1)) : (typeString)))
- },
- popoverForTd: function() {
- this.ui.paramsPanelBody.find('td:nth-child(2) span').map(function() {
- if (this.offsetWidth < this.scrollWidth) {
- $(this).popover({
- html: true,
- content: function() {
- return this.textContent
- },
- placement: 'left',
- container: 'body',
- trigger: 'hover'
- });
- }
- });
- }
- });
-});