You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by mg...@apache.org on 2017/02/07 09:01:23 UTC
[1/2] ambari git commit: AMBARI-19863 Fix Log Search User Config bugs
(mgergely)
Repository: ambari
Updated Branches:
refs/heads/trunk 536192bb6 -> e55a595ac
http://git-wip-us.apache.org/repos/asf/ambari/blob/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/MainLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/MainLayoutView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/MainLayoutView.js
index 2333c53..929ca98 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/MainLayoutView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/MainLayoutView.js
@@ -17,376 +17,367 @@
*/
define(['require',
- 'backbone',
- 'utils/Utils',
- 'utils/ViewUtils',
- 'utils/Globals',
- 'hbs!tmpl/dashboard/MainLayoutView_tmpl',
- 'select2',
- 'sparkline',
- 'd3.tip'
+ '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);
+ 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.hideContextMenu();
+ this.renderComparisonTab(options);
},this);
this.listenTo(this.globalVent,"show:tab",function(tabName){
- this.showTab(tabName);
+ this.showTab(tabName);
},this);
this.listenTo(this.globalVent,"add:compare",function($el){
- this.quickMenuCompare = true;
- this.onCompareLink($el);
+ this.quickMenuCompare = true;
+ this.onCompareLink($el);
},this);
- },
- onRender : function(){
- this.renderTroubleShootTab();
- this.renderHierarchyTab();
- this.renderAuditTab();
- //this.renderDashBoardTab();
- 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
- }));
- });
- },
- renderDashBoardTab:function(){
- var that = this;
- require(['views/dashboard/DashboardLayoutView'], function(DashboardLayoutView){
- that.RAuditDashboard.show(new DashboardLayoutView({
- 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>";
- })
+ },
+ 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) {
+ 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);
}
@@ -397,283 +388,283 @@ define(['require',
}
});
- 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({
+ 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;
+ }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/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dialog/ApplySearchFilterView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dialog/ApplySearchFilterView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dialog/ApplySearchFilterView.js
index 16a37ad..62b74c8 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dialog/ApplySearchFilterView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dialog/ApplySearchFilterView.js
@@ -75,7 +75,6 @@ define(['require',
var that = this;
$.extend(this.collection.queryParams, {
- userId: "admin",
rowType:"history"
});
this.collection.getFirstPage({
@@ -142,31 +141,32 @@ define(['require',
},
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 style="display:none"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>';
-
+ 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) {
+ 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)))
},
@@ -178,11 +178,8 @@ define(['require',
},
onDeleteClick: function(e) {
var that = this;
- var deleteModel = this.collection.findWhere({
- id: parseInt($(arguments[0].currentTarget).attr('data-nameId'))
- });
var postObject = {
- id: deleteModel.get('id')
+ id: parseInt($(arguments[0].currentTarget).attr('data-nameId'))
}
this.collection.deleteEventHistory(postObject, {
success: function(data, textStatus, jqXHR) {
@@ -202,7 +199,7 @@ define(['require',
onSearchFilterClick: function() {
var filterName = this.$("[data-id='filterName']").val();
$.extend(this.collection.queryParams, {
- filterName: filterName
+ filterName: filterName
});
this.fetchFilters();
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/EventHistoryLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/EventHistoryLayoutView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/EventHistoryLayoutView.js
index b30dd50..1eda79b 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/EventHistoryLayoutView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/EventHistoryLayoutView.js
@@ -438,7 +438,6 @@ define(['require',
content.selectedCollectionObject.get("params")["time"] = timeType;
var postObject = {
- userName: "admin",
filtername: content.ui.filterName.val(),
rowType: "history",
values: JSON.stringify(content.selectedCollectionObject.get('params'))
http://git-wip-us.apache.org/repos/asf/ambari/blob/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/dashboard/DashboardLayoutView_tmpl.html
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/dashboard/DashboardLayoutView_tmpl.html b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/dashboard/DashboardLayoutView_tmpl.html
deleted file mode 100644
index e00896f..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/dashboard/DashboardLayoutView_tmpl.html
+++ /dev/null
@@ -1,28 +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.
--->
-<div class="row dashboard">
- <div class="pull-right">
- <label class="btn"><input class="" data-id="enableHelp" value="true" checked type="checkbox">Enable Help</label>
- <button class="btn" data-id="save">Save</button>
- <!-- <button class="btn" data-id="load">Load</button> -->
- </div>
- <div class="col-md-12">
- <div class="loader" style="display:none"></div>
- <div class="gridster">
- </div>
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverterTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverterTest.java
index 66c172a..a126df8 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverterTest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverterTest.java
@@ -18,7 +18,9 @@
*/
package org.apache.ambari.logsearch.converter;
+import org.apache.ambari.logsearch.common.LogSearchContext;
import org.apache.ambari.logsearch.model.request.impl.UserConfigRequest;
+import org.apache.ambari.logsearch.web.model.User;
import org.apache.solr.client.solrj.SolrQuery;
import org.junit.Before;
import org.junit.Test;
@@ -39,8 +41,13 @@ public class UserConfigRequestQueryConverterTest extends AbstractRequestConverte
// GIVEN
UserConfigRequest request = new UserConfigRequest();
request.setRowType("myRowType"); // TODO: validate these 3 fields @Valid on UserConfigRequest object -> not null
- request.setUserId("myUserId");
request.setFilterName("myFilterName");
+
+ LogSearchContext context = new LogSearchContext();
+ User user = new User();
+ user.setUsername("myUserId");
+ context.setUser(user);
+ LogSearchContext.setContext(context);
// WHEN
SolrQuery queryResult = underTest.convert(request);
// THEN
[2/2] ambari git commit: AMBARI-19863 Fix Log Search User Config bugs
(mgergely)
Posted by mg...@apache.org.
AMBARI-19863 Fix Log Search User Config bugs (mgergely)
Change-Id: I0e84dc7f79d67ef492a78a88a6eef613bee052c1
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e55a595a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e55a595a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e55a595a
Branch: refs/heads/trunk
Commit: e55a595ac10d9e822e1c8e27dc098f829ec2e2e7
Parents: 536192b
Author: Miklos Gergely <mg...@hortonworks.com>
Authored: Tue Feb 7 10:01:12 2017 +0100
Committer: Miklos Gergely <mg...@hortonworks.com>
Committed: Tue Feb 7 10:01:12 2017 +0100
----------------------------------------------------------------------
.../logsearch/common/LogSearchConstants.java | 1 -
.../UserConfigRequestQueryConverter.java | 17 +-
.../ambari/logsearch/doc/DocConstants.java | 3 -
.../logsearch/manager/UserConfigManager.java | 53 +-
.../request/UserConfigParamDefinition.java | 6 -
.../model/request/impl/UserConfigRequest.java | 15 +-
.../model/response/UserConfigData.java | 11 -
.../logsearch/rest/UserConfigResource.java | 17 +-
.../ambari/logsearch/solr/SolrConstants.java | 1 -
.../scripts/views/common/DashboardLayout.js | 80 --
.../scripts/views/common/EventHistoryLayout.js | 1 -
.../views/dashboard/DashboardLayoutView.js | 354 -----
.../scripts/views/dashboard/MainLayoutView.js | 1259 +++++++++---------
.../views/dialog/ApplySearchFilterView.js | 41 +-
.../views/tabs/EventHistoryLayoutView.js | 1 -
.../dashboard/DashboardLayoutView_tmpl.html | 28 -
.../UserConfigRequestQueryConverterTest.java | 9 +-
17 files changed, 672 insertions(+), 1225 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java
index 1e46ae9..a260ed0 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java
@@ -101,7 +101,6 @@ public class LogSearchConstants {
public static final String REQUEST_PARAM_SOURCE_LOG_ID = "sourceLogId";
public static final String REQUEST_PARAM_KEYWORD_TYPE = "keywordType";
public static final String REQUEST_PARAM_TOKEN = "token";
- public static final String REQUEST_PARAM_USER_ID = "userId";
public static final String REQUEST_PARAM_FILTER_NAME = "filterName";
public static final String REQUEST_PARAM_ROW_TYPE = "rowType";
public static final String REQUEST_PARAM_UTC_OFFSET = "utcOffset";
http://git-wip-us.apache.org/repos/asf/ambari/blob/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverter.java
index 082f45c..fc75a17 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverter.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverter.java
@@ -30,8 +30,6 @@ import java.util.List;
import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.FILTER_NAME;
import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.ROW_TYPE;
-import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.SHARE_NAME_LIST;
-import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.USER_NAME;
@Named
public class UserConfigRequestQueryConverter extends AbstractConverterAware<UserConfigRequest, SolrQuery> {
@@ -43,21 +41,16 @@ public class UserConfigRequestQueryConverter extends AbstractConverterAware<User
int startIndex = StringUtils.isNotEmpty(userConfigRequest.getStartIndex()) && StringUtils.isNumeric(userConfigRequest.getStartIndex())
? Integer.parseInt(userConfigRequest.getStartIndex()) : 0;
- int maxRows = StringUtils.isNotEmpty(userConfigRequest.getPageSize()) && StringUtils.isNumeric(userConfigRequest.getStartIndex())
- ? Integer.parseInt(userConfigRequest.getStartIndex()) : 10;
+ int maxRows = StringUtils.isNotEmpty(userConfigRequest.getPageSize()) && StringUtils.isNumeric(userConfigRequest.getPageSize())
+ ? Integer.parseInt(userConfigRequest.getPageSize()) : 10;
SolrQuery.ORDER order = userConfigRequest.getSortType() != null && SolrQuery.ORDER.desc.equals(SolrQuery.ORDER.valueOf(userConfigRequest.getSortType()))
? SolrQuery.ORDER.desc : SolrQuery.ORDER.asc;
- String sortBy = StringUtils.isNotEmpty(userConfigRequest.getSortBy()) ? userConfigRequest.getSortBy(): FILTER_NAME;
+ String sortBy = StringUtils.isNotEmpty(userConfigRequest.getSortBy()) ? userConfigRequest.getSortBy() : FILTER_NAME;
String filterName = StringUtils.isBlank(userConfigRequest.getFilterName()) ? "*" : "*" + userConfigRequest.getFilterName() + "*";
- userConfigQuery.addFilterQuery(String.format("%s:%s",
- ROW_TYPE, userConfigRequest.getRowType()));
- userConfigQuery.addFilterQuery(String.format("%s:%s OR %s:%s",
- USER_NAME, userConfigRequest.getUserId(),
- SHARE_NAME_LIST, userConfigRequest.getUserId()));
- userConfigQuery.addFilterQuery(String.format("%s:%s",
- FILTER_NAME, SolrUtil.makeSearcableString(filterName)));
+ userConfigQuery.addFilterQuery(String.format("%s:%s", ROW_TYPE, userConfigRequest.getRowType()));
+ userConfigQuery.addFilterQuery(String.format("%s:%s", FILTER_NAME, SolrUtil.makeSearcableString(filterName)));
userConfigQuery.setStart(startIndex);
userConfigQuery.setRows(maxRows);
http://git-wip-us.apache.org/repos/asf/ambari/blob/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
index caf0636..713c9f6 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
@@ -100,19 +100,16 @@ public class DocConstants {
}
public class UserConfigDescriptions {
- public static final String USER_ID_D = "Get config for a particular user id";
public static final String FILTER_NAME_D = "The saved query as filter in Solr, search is sopprted by this param";
public static final String ROW_TYPE_D = "Row type is solr to identify as filter query";
}
public class UserConfigOperationDescriptions {
public static final String SAVE_USER_CONFIG_OD = "Save user config";
- public static final String UPDATE_USER_CONFIG_OD = "Update user config";
public static final String DELETE_USER_CONFIG_OD = "Delete user config";
public static final String GET_USER_CONFIG_OD = "Get user config";
public static final String GET_USER_FILTER_OD = "Get user filter";
public static final String UPDATE_USER_FILTER_OD = "Update user filter";
- public static final String GET_USER_FILTER_BY_ID_OD = "Get user filter by id";
public static final String GET_ALL_USER_NAMES_OD = "Get all user names";
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
index 03535b1..a60fc5c 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import org.apache.ambari.logsearch.common.LogSearchContext;
import org.apache.ambari.logsearch.common.MessageEnums;
import org.apache.ambari.logsearch.dao.UserConfigSolrDao;
import org.apache.ambari.logsearch.model.common.LogFeederDataMap;
@@ -32,6 +33,7 @@ import org.apache.ambari.logsearch.model.response.UserConfigData;
import org.apache.ambari.logsearch.model.response.UserConfigDataListResponse;
import org.apache.ambari.logsearch.util.RESTErrorUtil;
import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.solr.client.solrj.SolrQuery;
@@ -53,7 +55,6 @@ import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants
import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.FILTER_NAME;
import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.ROW_TYPE;
import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.SHARE_NAME_LIST;
-import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.COMPOSITE_KEY;
@Named
public class UserConfigManager extends JsonManagerBase {
@@ -66,45 +67,25 @@ public class UserConfigManager extends JsonManagerBase {
private ConversionService conversionService;
public String saveUserConfig(UserConfigData userConfig) {
+ String filterName = userConfig.getFiltername();
SolrInputDocument solrInputDoc = new SolrInputDocument();
if (!isValid(userConfig)) {
throw RESTErrorUtil.createRESTException("No FilterName Specified", MessageEnums.INVALID_INPUT_DATA);
}
- if (isNotUnique(userConfig) && !userConfig.isOverwrite()) {
+ if (isNotUnique(filterName)) {
throw RESTErrorUtil.createRESTException( "Name '" + userConfig.getFiltername() + "' already exists", MessageEnums.INVALID_INPUT_DATA);
}
- String loggedInUserName = userConfig.getUserName();
- String filterName = userConfig.getFiltername();
-
solrInputDoc.addField(ID, userConfig.getId());
- solrInputDoc.addField(USER_NAME, loggedInUserName);
+ solrInputDoc.addField(USER_NAME, LogSearchContext.getCurrentUsername());
solrInputDoc.addField(VALUES, userConfig.getValues());
solrInputDoc.addField(FILTER_NAME, filterName);
solrInputDoc.addField(ROW_TYPE, userConfig.getRowType());
List<String> shareNameList = userConfig.getShareNameList();
- if (shareNameList != null && !shareNameList.isEmpty()) {
+ if (CollectionUtils.isNotEmpty(shareNameList)) {
solrInputDoc.addField(SHARE_NAME_LIST, shareNameList);
}
- // Check whether the Filter Name exists in solr
- SolrQuery solrQuery = new SolrQuery();
- solrQuery.setQuery("*:*");
- solrQuery.addFilterQuery(String.format("%s:%s", FILTER_NAME, SolrUtil.makeSearcableString(filterName)));
- solrQuery.addFilterQuery(String.format("%s:%s", USER_NAME, loggedInUserName));
- try {
- QueryResponse queryResponse = userConfigSolrDao.process(solrQuery);
- if (queryResponse != null) {
- SolrDocumentList documentList = queryResponse.getResults();
- if (documentList != null && !documentList.isEmpty() && !userConfig.isOverwrite()) {
- logger.error("Filtername is already present");
- throw RESTErrorUtil.createRESTException("Filtername is already present", MessageEnums.INVALID_INPUT_DATA);
- }
- }
- } catch (SolrException e) {
- logger.error("Error in checking same filtername config", e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
try {
userConfigSolrDao.addDocs(solrInputDoc);
@@ -115,14 +96,14 @@ public class UserConfigManager extends JsonManagerBase {
}
}
- private boolean isNotUnique(UserConfigData userConfig) {
- String filterName = userConfig.getFiltername();
- String rowType = userConfig.getRowType();
+ private boolean isNotUnique(String filterName) {
- if (filterName != null && rowType != null) {
+ if (filterName != null) {
SolrQuery solrQuery = new SolrQuery();
filterName = SolrUtil.makeSearcableString(filterName);
- solrQuery.setQuery(COMPOSITE_KEY + ":" + filterName + "-" + rowType);
+ solrQuery.setQuery("*:*");
+ solrQuery.addFilterQuery(FILTER_NAME + ":" + filterName);
+ solrQuery.addFilterQuery(USER_NAME + ":" + LogSearchContext.getCurrentUsername());
SolrUtil.setRowCount(solrQuery, 0);
try {
Long numFound = userConfigSolrDao.process(solrQuery).getResults().getNumFound();
@@ -139,7 +120,6 @@ public class UserConfigManager extends JsonManagerBase {
private boolean isValid(UserConfigData vHistory) {
return StringUtils.isNotBlank(vHistory.getFiltername())
&& StringUtils.isNotBlank(vHistory.getRowType())
- && StringUtils.isNotBlank(vHistory.getUserName())
&& StringUtils.isNotBlank(vHistory.getValues());
}
@@ -159,12 +139,9 @@ public class UserConfigManager extends JsonManagerBase {
throw RESTErrorUtil.createRESTException("row type was not specified", MessageEnums.INVALID_INPUT_DATA);
}
- String userName = request.getUserId();
- if (StringUtils.isBlank(userName)) {
- throw RESTErrorUtil.createRESTException("user name was not specified", MessageEnums.INVALID_INPUT_DATA);
- }
-
SolrQuery userConfigQuery = conversionService.convert(request, SolrQuery.class);
+ userConfigQuery.addFilterQuery(String.format("%s:%s OR %s:%s", USER_NAME, LogSearchContext.getCurrentUsername(),
+ SHARE_NAME_LIST, LogSearchContext.getCurrentUsername()));
SolrDocumentList solrList = userConfigSolrDao.process(userConfigQuery).getResults();
Collection<UserConfigData> configList = new ArrayList<>();
@@ -199,10 +176,6 @@ public class UserConfigManager extends JsonManagerBase {
}
- public String updateUserConfig(UserConfigData userConfig) {
- return saveUserConfig(userConfig);
- }
-
// ////////////////////////////LEVEL FILTER/////////////////////////////////////
public LogFeederDataMap getUserFilter() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.java
index 23b350a..dd74b6f 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.java
@@ -21,17 +21,11 @@ package org.apache.ambari.logsearch.model.request;
import io.swagger.annotations.ApiParam;
import org.apache.ambari.logsearch.common.LogSearchConstants;
-import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigDescriptions.USER_ID_D;
import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigDescriptions.FILTER_NAME_D;
import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigDescriptions.ROW_TYPE_D;
public interface UserConfigParamDefinition {
- String getUserId();
-
- @ApiParam(value = USER_ID_D, name = LogSearchConstants.REQUEST_PARAM_USER_ID)
- void setUserId(String userId);
-
String getFilterName();
@ApiParam(value = FILTER_NAME_D, name = LogSearchConstants.REQUEST_PARAM_FILTER_NAME)
http://git-wip-us.apache.org/repos/asf/ambari/blob/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserConfigRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserConfigRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserConfigRequest.java
index c99ea75..cbbc6e6 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserConfigRequest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserConfigRequest.java
@@ -25,26 +25,13 @@ import javax.ws.rs.QueryParam;
public class UserConfigRequest extends CommonSearchRequest implements UserConfigParamDefinition {
- @QueryParam(LogSearchConstants.REQUEST_PARAM_USER_ID)
- private String userId;
-
- @QueryParam(LogSearchConstants.REQUEST_PARAM_FILE_NAME)
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_FILTER_NAME)
private String filterName;
@QueryParam(LogSearchConstants.REQUEST_PARAM_ROW_TYPE)
private String rowType;
@Override
- public String getUserId() {
- return userId;
- }
-
- @Override
- public void setUserId(String userId) {
- this.userId = userId;
- }
-
- @Override
public String getFilterName() {
return filterName;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigData.java
index 1fca3ba..ef4e0be 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigData.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigData.java
@@ -43,9 +43,6 @@ public class UserConfigData {
@ApiModelProperty
private String rowType;
- @ApiModelProperty
- private boolean isOverwrite = false;
-
public UserConfigData() {
id = String.valueOf(new Date().getTime());
}
@@ -97,12 +94,4 @@ public class UserConfigData {
public void setRowType(String rowType) {
this.rowType = rowType;
}
-
- public boolean isOverwrite() {
- return isOverwrite;
- }
-
- public void setOverwrite(boolean overwrite) {
- isOverwrite = overwrite;
- }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java
index 31f584d..19cfbed 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java
@@ -59,13 +59,6 @@ public class UserConfigResource {
return userConfigManager.saveUserConfig(userConfig);
}
- @PUT
- @Produces({"application/json"})
- @ApiOperation(UPDATE_USER_CONFIG_OD)
- public String updateUserConfig(UserConfigData userConfig) {
- return userConfigManager.updateUserConfig(userConfig);
- }
-
@DELETE
@Path("/{id}")
@ApiOperation(DELETE_USER_CONFIG_OD)
@@ -88,18 +81,10 @@ public class UserConfigResource {
return userConfigManager.getUserFilter();
}
- @POST
- @Path("/filters")
- @Produces({"application/json"})
- @ApiOperation(UPDATE_USER_FILTER_OD)
- public LogFeederDataMap createUserFilter(LogFeederDataMap request) {
- return userConfigManager.saveUserFiter(request);
- }
-
@PUT
@Path("/filters/{id}")
@Produces({"application/json"})
- @ApiOperation(GET_USER_FILTER_BY_ID_OD)
+ @ApiOperation(UPDATE_USER_FILTER_OD)
public LogFeederDataMap updateUserFilter(LogFeederDataMap request) {
return userConfigManager.saveUserFiter(request);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java
index 85554bc..39e134a 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java
@@ -107,7 +107,6 @@ public class SolrConstants {
public static final String VALUES = "jsons";
public static final String FILTER_NAME = "filtername";
public static final String ROW_TYPE = "rowtype";
- public static final String COMPOSITE_KEY = "composite_filtername-username";
public static final String SHARE_NAME_LIST = "share_username_list";
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/DashboardLayout.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/DashboardLayout.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/DashboardLayout.js
deleted file mode 100644
index 7adfeb8..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/DashboardLayout.js
+++ /dev/null
@@ -1,80 +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',
- 'communicator',
- 'modules/XALinks',
- 'hbs!tmpl/dashboard/DashboardLayout_tmpl'
-],function(require,Backbone,Communicator,XALinks,DashboardlayoutTmpl){
- 'use strict';
-
- var DashboardLayout = Backbone.Marionette.Layout.extend(
- /** @lends DashboardLayout */
- {
- _viewName : name,
-
- template: DashboardlayoutTmpl,
- breadCrumbs : [XALinks.get('Dashboard')],
-
- /** Layout sub regions */
- regions: {},
-
- /** ui selector cache */
- ui: {},
-
- /** ui events hash */
- events: {},
-
- /**
- * intialize a new DashboardLayout Layout
- * @constructs
- */
- initialize: function(options) {
- console.log("initialized a DashboardLayout Layout");
-
- _.extend(this, _.pick(options, ''));
-
- this.bindEvents();
- },
-
- /** all events binding here */
- bindEvents : function(){
- /*this.listenTo(this.model, "change:foo", this.modelChanged, this);*/
- /*this.listenTo(communicator.vent,'someView:someEvent', this.someEventHandler, this)'*/
- },
-
- /** on render callback */
- onRender: function() {
- this.initializePlugins();
- },
-
- /** all post render plugin initialization */
- initializePlugins: function(){
- },
-
- /** on close */
- onClose: function(){
- }
-
- });
-
- return DashboardLayout;
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/EventHistoryLayout.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/EventHistoryLayout.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/EventHistoryLayout.js
index 89914ea..01e18b1 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/EventHistoryLayout.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/EventHistoryLayout.js
@@ -228,7 +228,6 @@ define(['require',
}
params["time"] = timeType;
var postObject = {
- userName: "admin",
filtername: content.ui.filterName.val().trim(),
rowType: "history",
values: JSON.stringify(params)
http://git-wip-us.apache.org/repos/asf/ambari/blob/e55a595a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/DashboardLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/DashboardLayoutView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/DashboardLayoutView.js
deleted file mode 100644
index 6358eb2..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/DashboardLayoutView.js
+++ /dev/null
@@ -1,354 +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',
- 'dashboard',
- 'utils/Globals',
- 'collections/VEventHistoryList',
- 'hbs!tmpl/dashboard/DashboardLayoutView_tmpl'
-], function(require, Backbone, Utils, dashboard, Globals, VEventHistory, DashboardLayoutView_Tmpl) {
- 'use strict';
-
- return Backbone.Marionette.Layout.extend(
- /** @lends DashboardLayoutView */
- {
- _viewName: 'DashboardLayoutView',
-
- template: DashboardLayoutView_Tmpl,
-
-
- /** ui selector cache */
- ui: {
- gridClose: "[data-id='gridClose']",
- saveData: "[data-id='save']",
- loadData: "[data-id='load']",
- enableHelp: "[data-id='enableHelp']"
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- events['click ' + this.ui.gridClose] = 'onGridCloseClick';
- events['click ' + this.ui.saveData] = 'onSaveDataClick';
- events['click ' + this.ui.loadData] = 'onLoadDataClick';
- events['change ' + this.ui.enableHelp] = 'onEnableHelpClick';
- return events;
- },
- regions: {},
-
- /**
- * intialize a new DashboardLayoutView Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'params', 'componetList'));
- this.bindEvents();
- this.tabOpend = false;
- this.graphIdCounter = 0;
- this.dateUtil = Utils.dateUtil;
- this.vent = new Backbone.Wreqr.EventAggregator();
- this.storedValueCollection = new Backbone.Collection();
- this.saveDahboardCollection = new VEventHistory();
- this.gridHelp = true;
- },
- bindEvents: function() {
- this.listenTo(this.globalVent, "tab:click", function($this) {
- if (!this.tabOpend) {
- this.tabOpend = true
- this.initializePlugin();
- //this.dashboard.bindEvent();
- }
- }, this);
- },
- onRender: function() {
- this.setSettingCheckbox();
- },
- addElement: function(el, data) {
- var that = this;
- //this.dashboard.addWidget($('<li class="new" data-type="' + type + '"></li>'), 3, 2);
- var regionid = that.createRegion();
- if (data) {
- el.attr('data-type', data.myData.type)
- }
-
- el.append('<div class="regionBox" data-regionid= "' + regionid + '" id = "' + regionid + '"> </div>')
- el.attr('data-dataId', regionid)
- var dataType = el.data();
- if (dataType && dataType.type) {
- that.addRegion(regionid, dataType.type, data);
- }
-
- },
- initializePlugin: function() {
- var that = this;
- this.dashboard = $(".gridster").dashboard({
- widget_margins: [10, 10],
- widget_base_dimensions: [140, 140],
- resize: {
- enabled: true,
- stop: function(e, ui, $widget) {
- $widget.resize();
- },
- axes: ['both']
- },
- max_cols: 7,
- avoid_overlapped_widgets: true,
- dock: {
- dockIcon: [{
- iClass: "fa fa-bar-chart",
- parentAttr: {
- "data-type": Globals.graphType.HISTOGRAM.value,
- "class": "icon"
- }
- }, {
- iClass: "fa fa-line-chart",
- parentAttr: {
- "data-type": Globals.graphType.MULTILINE.value,
- "class": "iconG"
- }
- }, {
- iClass: "fa fa-pie-chart",
- parentAttr: {
- "data-type": Globals.graphType.PIE.value,
- "class": "iconG"
- }
- },
- /* {
- iClass: "fa fa-table",
- parentAttr: {
- "data-type": Globals.graphType.TABLE.value,
- "class": "iconG"
- }
- }*/
- ],
- position: 'right',
- dockClick: true,
- droppable: {
- /* el: that.$(".dashboard .grid-container"),*/
- hoverClass: "over",
- accept: ".slideMenu li.iconG"
- },
- draggable: {
- /*el: that.$('.dashboard .slideMenu li.iconG'),*/
- cursor: "move",
- start: function(event, ui) {},
- appendTo: '.grid-container',
- scroll: false,
- helper: "clone"
-
- }
- },
- serialize_params: function($w, wgd) {
- return {
- myData: {
- type: $w.data('type'),
- dataId: $w.data('dataid')
- },
- col: wgd.col,
- row: wgd.row,
- size_x: wgd.size_x,
- size_y: wgd.size_y
- };
- },
- onLoaded: function() {
- //console.log('loaded')
- that.onLoadDataClick();
- },
- onAdded: function(el, data) {
- that.addElement(el, data);
- },
- onDeleted: function() {
- console.log("delete");
- },
- onAllDeleted: function() {
- console.log("onAllDeleted");
- }
- }).data('dashboard');
-
- /* this.gridster = this.$(".gridster ul").gridster({
- widget_margins: [10, 10],
- widget_base_dimensions: [140, 140],
- resize: {
- enabled: true
- },
- draggable: {
- handle: '.Header'
- },
- resize: {
- enabled: true,
- stop: function(e, ui, $widget) {
- $widget.resize();
- }
- },
- avoid_overlapped_widgets: true,
- serialize_params: function($w, wgd) {
- return {
- myData: $w.data('type'),
- col: wgd.col,
- row: wgd.row,
- size_x: wgd.size_x,
- size_y: wgd.size_y
- };
- },
-
- }).data('gridster');*/
-
- this.$('.dashboard').on('mouseenter', 'li.iconG', function() {
- that.$('.dashboard').find('.grid-container').addClass('droupAreaHoverEffect');
- });
- this.$('.dashboard').on('mouseleave', 'li.iconG', function() {
- that.$('.dashboard').find('.grid-container').removeClass('droupAreaHoverEffect');
- });
- },
- addRegion: function(region_id, type, data) {
- var that = this;
- require(['views/graphs/GridGraphLayoutView', 'views/dashboard/GridTableLayoutView'], function(GridGraphLayoutView, GridTableLayoutView) {
- var region = that.getRegion(region_id);
- var ViewtypeObj = type;
- var modalObj = that.storedValueCollection.add(new Backbone.Model({
- id: region_id
- }))
- if (data) {
- modalObj.set(data);
- }
- var options = {
- globalVent: that.globalVent,
- vent: that.vent,
- viewType: ViewtypeObj,
- model: modalObj,
- dashboard: that.dashboard,
- gridHelp: that.gridHelp
-
- }
- if (type == Globals.graphType.TABLE.value) {
- that.showRegion(region, new GridTableLayoutView(options));
- } else {
- that.showRegion(region, new GridGraphLayoutView(options));
- }
-
- })
-
- },
- createRegion: function(rId) {
- var id = (rId) ? (rId) : ("grid_histo" + (this.graphIdCounter++));
- var region = {};
- region[id] = '#' + id;
- this.addRegions(region);
- return id;
-
- },
- showRegion: function(region, layout) {
- region.show(layout);
- },
- onSaveDataClick: function() {
- var that = this;
- var exportData = this.dashboard.exportData();
-
- _.each(exportData, function(ref, i) {
- var obj = JSON.parse(JSON.stringify(ref));
- if (that.storedValueCollection.get(ref.myData.dataId)) {
- var id = ref.myData.dataId;
- exportData[i] = _.extend(that.storedValueCollection.get(id).attributes, obj)
- }
- });
-
- var postObject = {
- userId: 0,
- name: "Temp",
- rowType: "dashboard",
- isOverwrite: true,
- values: JSON.stringify(exportData)
- }
-
- this.saveDahboardCollection.saveDashboard(postObject, {
- success: function(data, textStatus, jqXHR) {
- Utils.notifySuccess({
- content: "Dashboard saved successfully."
- });
- },
- error: function(jqXHR, textStatus, errorThrown) {
- Utils.notifyError({
- content: JSON.parse(jqXHR.responseText).msgDesc || "There is some problem in Dashboard, Please try again later."
- });
- },
- complete: function() {
- that.$("#loaderEvent").hide();
- that.$(".loader").hide();
- }
- });
-
- },
- onLoadDataClick: function() {
- var that = this;
- $.extend(this.saveDahboardCollection.queryParams, {
- userId: 0,
- rowType: "dashboard"
- });
- that.$(".loader").show();
- this.saveDahboardCollection.fetch({
- error: function(jqXHR, textStatus, errorThrown) {
- Utils.notifyError({
- content: "There is some problem in Event History, Please try again later."
- });
-
- },
- success: function(data, textStatus, jqXHR) {
- if(that.saveDahboardCollection.length){
- var dataObject = JSON.parse(that.saveDahboardCollection.models[0].get('values'));
- //that.saveDahboardCollection.reset(dataObject);
- //that.storedValueCollection.reset(dataObject);
- //var importData = that.storedValueCollection.toJSON();
- that.dashboard.importData(dataObject);
- }
- },
- complete: function() {
- //that.$("#loaderEvent").hide();
- that.$(".loader").hide();
- }
- });
- },
- onGridCloseClick: function(e) {
- this.dashboard.deleteWidget($(e.currentTarget).parents('li'))
- },
- setSettingCheckbox: function() {
- var gridHelp = Utils.localStorage.checkLocalStorage('gridHelp');
- if (gridHelp && gridHelp.found && gridHelp.value) {
- if (gridHelp.value == "false") {
- this.gridHelp = false;
- this.ui.enableHelp.prop("checked", false);
- } else {
- this.gridHelp = true;
- this.ui.enableHelp.prop("checked", true);
- }
- }
- },
- onEnableHelpClick: function(e) {
- if (e.currentTarget.checked) {
- this.gridHelp = true;
- Utils.localStorage.setLocalStorage('gridHelp', true);
- } else {
- this.gridHelp = false;
- Utils.localStorage.setLocalStorage('gridHelp', false);
- }
- },
- });
-
-
-});