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:41 UTC
[11/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/audit/AuditTabLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/audit/AuditTabLayoutView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/audit/AuditTabLayoutView.js
deleted file mode 100644
index 7710156..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/audit/AuditTabLayoutView.js
+++ /dev/null
@@ -1,429 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-define(['require',
- 'backbone',
- 'utils/Globals',
- 'utils/Utils',
- 'utils/ViewUtils',
- 'collections/VGroupList',
- 'collections/VAuditLogList',
- 'models/VAuditLog',
- 'hbs!tmpl/audit/AuditTabLayoutView_tmpl',
- 'moment'
-], function (require, Backbone, Globals, Utils, ViewUtils, VGroupList, VAuditLogList, VAuditLog, AuditTabLayoutViewTmpl, moment) {
-
- 'use strict';
-
- return Backbone.Marionette.Layout.extend(
- {
- _viewName: 'AuditTabLayoutView',
-
- template: AuditTabLayoutViewTmpl,
-
- /** Layout sub regions */
- regions: {
- RAuditTable: "[data-id='auditTable']",
- RVisualSearch: "#r_vsSearch",
- RVisualSearchInc: "#r_vsSearchInc",
- RVisualSearchEx: "#r_vsSearchEx",
- RAuditLine: "#r_AuditLine",
- RAuditAggregated: "[data-id='auditAggregated']",
- },
-
- /** ui selector cache */
- ui: {
- viewType: "input[name='viewTypeAudit']",
- excludeComponents: "#excludeComponents",
- includeComponents: "#includeComponents",
- collapseArrowClick: "a.collapse-link.chkArrow"
- },
-
- /** ui events hash */
- events: function () {
- var events = {};
- events['click [data-id="refresh-tab-audit"]'] = 'onAuditTabRefresh';
- events['change ' + this.ui.viewType] = 'onViewTypeChange';
- events['click ' + this.ui.collapseArrowClick] = function (e) {
- if ($(e.currentTarget).find('i').hasClass('fa-chevron-down')) {
- if (this.RAuditAggregated.currentView) {
- this.RAuditAggregated.currentView.trigger("button:min:max");
- }
- }
- };
- return events;
- },
- initialize: function (options) {
- _.extend(this, _.pick(options, 'globalVent'));
- this.defaultParams = ViewUtils.getDefaultParamsForHierarchy();
- delete this.defaultParams.level;
- this.vent = new Backbone.Wreqr.EventAggregator();
- this.initializeCollections();
- this.columns = [];
- this.bindEvents();
- },
- initializeCollections: function () {
- this.auditModel = new VAuditLog();
- this.collection = new VAuditLogList([], {
- state: {
- firstPage: 0,
- pageSize: 25
- }
- });
-
- this.componentsList = new VGroupList([], {
- state: {
- firstPage: 0,
- pageSize: 99999
- }
- });
- this.componentsList.url = Globals.baseURL + "audit/logs/components";
- },
- bindEvents: function () {
- this.listenTo(this.componentsList, "reset", function (col, abc) {
- this.setupSelect2Fields(col, "type", 'type', 'excludeComponents', 'Exclude Components');
- this.setupSelect2Fields(col, "type", 'type', 'includeComponents', 'Include Components');
- }, this);
- this.listenTo(this.vent, "search:audit:query auditComponents:include auditComponents:exclude search:audit:include search:audit:exclude logtime:filter", function (value) {
- _.extend(this.defaultParams, value);
- this.fetchAuditLogs(value);
- }, this);
- this.listenTo(this.vent, "reinitialize:filter:mustBe", function (value) {
- this.reinitializeFilterMustBe(value);
- }, this);
- this.listenTo(this.vent, "reinitialize:filter:mustNot", function (value) {
- this.reinitializeFilterMustNot(value);
- }, this);
-
- this.listenTo(this.globalVent, "reinitialize:auditLogs", function (options) {
- this.vent.trigger("reinitialize:filter:mustNot reinitialize:filter:mustBe reinitialize:filter:logtime " +
- "reinitialize:TopTenGraph", options);
- this.fetchAuditLogs(options);
- }, this);
-
- },
- onRender: function () {
- this.renderHistogram();
- this.renderAuditAggregatedInfo();
- this.fetchAuditColumns();
- this.fetchAuditLogs((this.defaultParams) ? this.defaultParams : {q: "*:*"});
- this.componentsList.fetch({reset: true});
- },
- renderHistogram: function () {
- var that = this;
- require(['views/graphs/GraphLayoutView'], function (GraphLayoutView) {
- that.RAuditLine.show(new GraphLayoutView({
- vent: that.vent,
- globalVent: that.globalVent,
- params: that.defaultParams,
- viewType: Globals.graphType.MULTILINE.value,
- showDatePicker: true,
- futureDate: false
- }));
- })
- },
- renderAuditAggregatedInfo: function () {
- var that = this;
- require(['views/audit/AuditAggregatedView'], function (AuditAggregatedView) {
- that.RAuditAggregated.show(new AuditAggregatedView({
- vent: that.vent,
- globalVent: that.globalVent,
- params: that.defaultParams
- }));
- })
-
- },
- fetchAuditColumns: function () {
- var that = this;
- this.collection.getAuditSchemaFieldsName({}, {
- beforeSend: function () {
- that.$("#loaderAudit").show();
- },
- success: function (data) {
- that.columns = ViewUtils.getLogSchemaFields(data, Globals.defaultAuditLogMappings, Globals.defaultAuditLogExcludes);
- },
- error: function (error, data, status) {
- var obj = JSON.parse(error.responseText);
- if (obj)
- Utils.notifyError({content: obj.msgDesc});
- },
- complete: function () {
- that.renderAuditTable();
- that.renderVSSearch();
- that.$("#loaderAudit").hide();
- }
- });
- },
- fetchAuditLogs: function (params) {
- $.extend(this.collection.queryParams, params);
- this.collection.getFirstPage({reset: true});
- },
- renderVSSearch: function () {
- var that = this;
- require(['views/tabs/VisualSearchView'], function (VisualSearchView) {
-
- _.each(that.columns, function (v, i) {
- if (v.toLowerCase().indexOf("time") > 0) {
- delete that.columns[v]
- }
- });
- that.RVisualSearchInc.show(new VisualSearchView({
- viewName: "includeColumns",
- placeholder: "Include Search",
- vent: that.vent,
- globalVent: that.globalVent,
- customOptions: _.values(that.columns),
- eventName: "search:audit:include",
- myFormatData: function (query, searchCollection) {
- var obj = ViewUtils.replaceColumnNamesWithKeys(searchCollection, Globals.invertedAuditLogMappings, true);
- return {
- includeQuery: JSON.stringify(obj),
- query: query
- }
- }
- }));
- that.RVisualSearchEx.show(new VisualSearchView({
- placeholder: "Exclude Search",
- vent: that.vent,
- globalVent: that.globalVent,
- customOptions: _.values(that.columns),
- eventName: "search:audit:exclude",
- myFormatData: function (query, searchCollection) {
- var obj = ViewUtils.replaceColumnNamesWithKeys(searchCollection, Globals.invertedAuditLogMappings, true);
- return {
- excludeQuery: JSON.stringify(obj),
- query: query
- }
- }
- }));
- });
- },
- renderAuditTable: function () {
- var that = this;
- require(['views/common/TableLayout'], function (TableLayout) {
- var cols = new Backgrid.Columns(that.getColumns());
- that.RAuditTable.show(new TableLayout({
- columns: cols,
- collection: that.collection,
- includeFilter: false,
- includePagination: true,
- includePageSize: true,
- includeFooterRecords: true,
- includeColumnManager: true,
- columnOpts: {
- initialColumnsVisible: 9,
- saveState: false
- },
- gridOpts: {
- className: "table table-bordered table-hover table-condensed backgrid",
- emptyText: 'No records found!'
- },
- filterOpts: {},
- paginatorOpts: {}
- }));
- });
- },
- getColumns: function () {
- var cols = {};
- var that = this;
- var columns = {
- evtTime: {
- label: "Event Time",
- cell: "String",
- sortType: 'toggle',
- editable: false,
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function (rawValue, model) {
- return moment(rawValue).format("YYYY-MM-DD HH:mm:ss,SSS");
- }
- })
- },
- reqUser: {
- label: "User",
- cell: "String",
- sortType: 'toggle',
- editable: false
- },
- repo: {
- label: 'Repo',
- cell: "String",
- sortType: 'toggle',
- editable: false
- },
- resource: {
- label: 'Resource',
- cell: "String",
- sortType: 'toggle',
- editable: false
- },
- access: {
- label: 'Access Type',
- cell: "String",
- sortType: 'toggle',
- editable: false
- },
- result: {
- label: 'Result',
- cell: "String",
- sortType: 'toggle',
- editable: false,
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function (rawValue, model) {
- return (rawValue === 1) ? "Allowed" : "Denied";
- }
- })
- },
- enforcer: {
- label: 'Access Enforcer',
- cell: "String",
- sortType: 'toggle',
- editable: false
- },
- cliIP: {
- label: 'Client IP',
- cell: "String",
- sortType: 'toggle',
- editable: false
- },
- event_count: {
- label: 'Event Count',
- cell: "String",
- sortType: 'toggle',
- editable: false
- }
- };
- _.each(this.columns, function(value){
- var name = Globals.invertedAuditLogMappings[value];
- if (columns[name] === undefined && value != "_version_") {
- var columnObj = {
- name: Globals.invertedAuditLogMappings[value],
- label: value,
- cell: "String",
- sortType: 'toggle',
- editable: false
- };
- columns[name] = columnObj;
- } else {
- if (columns[name] && columns[name].label) {
- columns[name].label = value;
- }
- }
- });
- return this.collection.constructor.getTableCols(columns, this.collection);
- },
- onAuditTabRefresh: function (e) {
- ViewUtils.setLatestTimeParams(this.defaultParams);
- $.extend(this.collection.queryParams, this.defaultParams);
- this.collection.fetch({reset: true});
- this.vent.trigger("tab:refresh", this.defaultParams);
- },
- onViewTypeChange: function (e) {
- var that = this;
- var val = that.$("[name='viewTypeAudit']:checked").val();
- this.toggleViewType(val);
- },
- toggleViewType: function (val) {
- if (val === "A") {
- this.$("[data-id='auditTable']").show();
- this.$('[data-id="auditAggregated"]').hide();
- } else {
- this.$('[data-id="auditAggregated"]').show();
- this.$("[data-id='auditTable']").hide();
- if (this.RAuditAggregated.currentView)
- this.RAuditAggregated.currentView.$el.resize();
- }
- },
- 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[selectTagId].select2({
- placeholder: (placeHolder) ? placeHolder : 'Select',
- tags: true,
- allowClear: true,
- width: '100%',
- data: {results: data, text: textKey},
- formatSelection: function (item) {
- return item[textKey];
- },
- formatResult: function (item) {
- return item[textKey];
- }
- }).on("change", function (e) {
- var data = that.ui[selectTagId].select2("data").map(function (d) {
- return d.type
- });
- if (selectTagId === "excludeComponents") {
- that.vent.trigger("auditComponents:exclude", {mustNot: data.toString()});
- }
- if (selectTagId === "includeComponents")
- that.vent.trigger("auditComponents:include", {mustBe: data.toString()});
- });
- },
- startPoll: function () {
- var that = this;
- setInterval(function () {
- that.pollLiveFeed();
- }, 5000);
- },
- pollLiveFeed: function () {
- var that = this;
- if (this.pollXhr) {
- if (this.pollXhr.readyState > 0 && this.pollXhr.readyState < 4)
- return
- }
- this.pollXhr = this.auditModel.auditLiveFeed({}, {
- beforeSend: function () {
- that.$("#loaderFeed").show();
- },
- success: function (data) {
- var dd = [];
- that.$("#spark").parent().show();
- _.each(data.vnameValues, function (d) {
- dd.push(d.value);
- });
- that.$("#spark").sparkline(dd, {lineColor: '#5A8DB6', width: "100px"});
- },
- error: function () {
- that.$("#spark").parent().hide();
- },
- complete: function () {
- setTimeout(function () {
- that.$("#loaderFeed").hide();
- }, 1000);
- }
- });
- },
- reinitializeFilterMustBe: function (values) {
- if (values.mustBe) {
- this.ui.includeComponents.select2('val', values.mustBe.split(","));
- } else {
- this.ui.includeComponents.select2('val', []);
- }
- },
- reinitializeFilterMustNot: function (values) {
- if (values.mustNot) {
- this.ui.excludeComponents.select2('val', values.mustNot.split(","));
- } else {
- this.ui.excludeComponents.select2('val', []);
- }
- }
- });
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/AdvanceSearchLayout.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/AdvanceSearchLayout.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/AdvanceSearchLayout.js
deleted file mode 100644
index c05caa7..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/AdvanceSearchLayout.js
+++ /dev/null
@@ -1,146 +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/common/AdvanceSearchLayout_tmpl'
-], function(require, backbone, Utils, Globals, AdvanceSearchLayoutTmpl) {
- 'use strict';
-
- return Backbone.Marionette.Layout.extend(
- /** @lends AdvanceSearchLayout */
- {
- _viewName: 'AdvanceSearchLayout',
-
- template: AdvanceSearchLayoutTmpl,
-
-
- /** ui selector cache */
- ui: {
- searchArea : '[data-id="searchArea"]',
- searchInput: '[data-id="searchInput"]',
- suggesterBox: '[data-id="suggesterBox"]',
- suggesterList: '[data-id="suggesterList"]'
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- events["click " + this.ui.startStop] = 'onStartStopClick';
- events["change " + this.ui.searchArea] = 'advancedSearch';
- /* events["click " + this.ui.start] = 'onStartClick';
- events["click " + this.ui.stop] = 'onStopClick';*/
- return events;
- },
-
- /**
- * intialize a new AdvanceSearchLayout Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options, 'vent', 'globalVent', 'params'));
- this.dateUtil = Utils.dateUtil;
- },
- bindEvents: function() {},
- onRender: function() {
- var that = this;
-
- var li = this.elementGenerator(Globals.serviceLogsColumns)
- that.ui.suggesterList.html(li);
- this.ui.searchInput.on('focusin', function() {
- that.ui.suggesterBox.show();
- that.ui.suggesterBox.addClass('advanceSearchActive');
- });
-
- this.$('.advanceSearchList').on('click', 'li', function(e) {
- var value = that.ui.searchInput.val();
- that.ui.searchInput.val(value + $(this).data().value);
- });
- this.ui.searchInput.on('focusout', function() {
- that.ui.suggesterBox.hide();
- that.ui.suggesterBox.removeClass('advanceSearchActive')
- });
- },
- elementGenerator: function(serviceLogsColumns) {
- var li = "";
- _.keys(serviceLogsColumns).map(function(object) {
- li += '<li data-value="' + object + '">' + serviceLogsColumns[object] + '(' + object + ')</li>'
- });
- return li;
- },
- advancedSearch : function(){
- var that = this,textareaValue = '';
-
- if(that.ui.searchArea.val() != ""){
- textareaValue = that.ui.searchArea.val();
- }
- textareaValue = textareaValue.replace(/\&/g,'}{');
- // that.vent.trigger('main:search',{advanceSearch : textareaValue});
- }
- /* suggester*/
- /*elementGenerator: function(text) {
- this.$('.advanceSearchList').on('click keydown', 'li', function(e) {
- var value = that.ui.searchInput.val();
- if (that.lastSpchar) {
- var splitArray = value.split(that.lastSpchar[0])
- splitArray[splitArray.length - 1] = $(this).data().value;
- that.ui.searchInput.val(splitArray.join(that.lastSpchar));
- } else {
- that.ui.searchInput.val($(this).data().value);
- }
-
- })
- var checkLastLatter = text.slice(-1).match(/^[ :~?\}\{\[\]!@#\$%\^\&*\)\(+=._-]+$/g);
- if (checkLastLatter) {
- this.lastSpchar = checkLastLatter;
- var splitArray = text.split(this.lastSpchar[0])
- text = splitArray[splitArray.length - 1];
- } else {
- if (this.lastSpchar) {
- var splitArray = text.split(this.lastSpchar[0])
- text = splitArray[splitArray.length - 1];
- }
- }
- var li = "";
- if (text != '') {
- _.each(this.availableTags, function(object) {
- var regex = new RegExp(text.replace(/(\S+)/g, function(s) {
- return "\\b(" + s + ")(.*)"
- }).replace(/\s+/g, ''), "gi");
- var matches = regex.exec(object);
- var result = '';
- if (matches && matches.length) {
- for (var i = 1; i < matches.length; i++) {
- if (i % 2 == 1)
- result += '<b>' + matches[i] + '</b>';
- else
- result += matches[i];
- }
- li += '<li data-value="' + object + '">' + result + '</li>'
- }
- });
- return li
- }
-
- },*/
-
-
- });
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/BreadCrumbs.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/BreadCrumbs.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/BreadCrumbs.js
deleted file mode 100644
index bf05758..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/BreadCrumbs.js
+++ /dev/null
@@ -1,83 +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.
- */
-
- /**
- *
- * BreadCrumbs Veiw
- * BreadCrumbs is directly accessible through App object .But can also create a instance of it.
- * @array
- */
-
-define(['require',
- 'backbone.marionette',
- 'hbs!tmpl/common/breadcrumbs',
- 'App'
-],function(require,Marionette,tmpl,App) {
-
-
- var BreadCrumbs = Marionette.ItemView.extend({
- template : tmpl,
- templateHelpers : function(){
- return {
- breadcrumb : this.setLast(this.breadcrumb)
- };
- },
- initialize : function(options){
- this.breadcrumb = [];
- if(typeof options !== 'undefined'){
- this.breadcrumb = options.breadcrumb;
- }
- //In docs the breadcrubs region stays constant only inner content changes
- /* this.listenTo(Vent,'draw:docs:breadcrumbs',function(breads){
- this.breadcrumb = breads;
- this.reRenderBookmarks();
- },this);*/
- },
- onRender : function(){
-
- },
- reRenderBookmarks : function(){
- this.breadcrumb = this.setLast(this.breadcrumb);
- this.render();
- },
- setLast : function(breadcrumb){
- if(breadcrumb.length > 0){
- //breadcrumb[breadcrumb.length -1].isLast = true;
- breadcrumb[breadcrumb.length -1] = _.extend({},breadcrumb[breadcrumb.length -1],{isLast : true});
- }
- return breadcrumb;
- },
- // showBreadCrumbs : function(view,breadcrumb){
- // var brRgn = view.$el.find('#brdCrumbs');
- // if(brRgn){
- // $(brRgn).html(Marionette.Renderer.render(tmpl,{breadcrumb : this.setLast(breadcrumb)}));
- // }/*else{*/
- // ////throw new Error('This view does not have a #brdCrumbs id');
- // /*}*/
- // },
- onClose : function(){
- console.log('OnItemClosed called of BreadCrumbs');
- // this.stopListening(Vent);
- }
- });
-
- App.BreadCrumbs = new BreadCrumbs();
-
- return BreadCrumbs;
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/CustomBackgrid.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/CustomBackgrid.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/CustomBackgrid.js
deleted file mode 100644
index 83b756b..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/CustomBackgrid.js
+++ /dev/null
@@ -1,284 +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',
- 'backgrid-filter',
- 'backgrid-paginator',
- 'select2'
-],function(require,Backbone,Util){
- 'use strict';
-
- var HeaderSearchCell = Backbone.View.extend({
-
- tagName: "td",
-
- className: "backgrid-filter",
-
- template: _.template('<input type="search" <% if (placeholder) { %> placeholder="<%- placeholder %>" <% } %> name="<%- name %>" <% if (style) { %> style="<%- style %>" <% } %> />'),
- //<a class="clear" href="#">×</a>'),
-
- placeholder: "",
-
- events: {
- "keyup input": "evKeyUp",
- "submit": "search"
- },
-
- initialize: function (options) {
- _.extend(this, _.pick(options, 'column'));
- this.name = this.column.get('name');
- if(this.column.get('reName') != undefined)
- this.name = this.column.get('reName');
-
-
- var collection = this.collection, self = this;
- if (Backbone.PageableCollection && collection instanceof Backbone.PageableCollection ) {
- collection.queryParams[this.name] = function () {
- return self.searchBox().val() || null;
- };
- }
- },
-
- render: function () {
- this.$el.empty().append(this.template({
- name: this.column.get('name'),
- placeholder: this.column.get('placeholder') || "Search",
- style : this.column.get('headerSearchStyle')
- }));
- this.$el.addClass('renderable');
- this.delegateEvents();
- return this;
-
- },
-
- evKeyUp: function (e) {
- var $clearButton = this.clearButton();
- var searchTerms = this.searchBox().val();
-
- if(!e.shiftKey) {
- this.search();
- }
-
- if (searchTerms) {
- $clearButton.show();
- } else {
- $clearButton.hide();
- }
- },
-
- searchBox: function () {
- return this.$el.find("input[type=search]");
- },
-
- clearButton: function () {
- return this.$el.find(".clear");
- },
-
- search: function () {
-
- var data = {};
-
- // go back to the first page on search
- var collection = this.collection;
- if (Backbone.PageableCollection &&
- collection instanceof Backbone.PageableCollection &&
- collection.mode == "server") {
- collection.state.currentPage = collection.state.firstPage;
- }
- var query = this.searchBox().val();
- if (query) data[this.name] = query;
- if(collection.extraSearchParams){
- _.extend(data, collection.extraSearchParams);
- }
- collection.fetch({
- data: data,
- reset: true,
- success : function(){},
- error : function(msResponse){
- Util.notifyError('Error', 'Invalid input data!');
- }
- });
- },
-
- clear: function (e) {
- if (e) e.preventDefault();
- this.searchBox().val(null);
- this.collection.fetch({reset: true});
- }
-
- });
-
- var HeaderFilterCell = Backbone.View.extend({
-
- tagName: "td",
-
- className: "backgrid-filter",
-
- template: _.template('<select > <option>ALL</option>' +
- '<% _.each(list, function(data) {' +
- 'if(_.isObject(data)){ %>' +
- '<option value="<%= data.value %>"><%= data.label %></option>' +
- '<% }else{ %>' +
- '<option value="<%= data %>"><%= data %></option>' +
- '<% } %>' +
- '<% }); %></select>'),
-
- placeholder: "",
-
- events: {
- "click": function(){
- },
- },
-
- initialize: function (options) {
- _.extend(this, _.pick(options, 'column'));
- this.name = this.column.get('name');
- this.headerFilterOptions = this.column.get('headerFilterOptions');
- },
-
- render: function () {
- var that =this;
- this.$el.empty().append(this.template({
- name: this.column.get('name'),
- list : this.headerFilterOptions.filterList,
- }));
-
- this.$el.find('select').select2({
- allowClear: true,
- closeOnSelect : false,
- width : this.headerFilterOptions.filterWidth || '100%' ,
- height : this.headerFilterOptions.filterHeight || '20px',
- });
-
- this.$el.addClass('renderable');
-
- this.$el.find('select').on('click',function(e){
- that.search(e.currentTarget.value);
- });
- //this.delegateEvents();
- return this;
-
- },
-
-
-
- search: function (selectedOptionValue) {
-
- var data = {}, query;
-
- // go back to the first page on search
- var collection = this.collection;
- if (Backbone.PageableCollection &&
- collection instanceof Backbone.PageableCollection &&
- collection.mode == "server") {
- collection.state.currentPage = collection.state.firstPage;
- }
- if(selectedOptionValue != "ALL") {
- query = selectedOptionValue;
- }
- if (query) {
- data[this.name] = query;
- }
- if(collection.extraSearchParams){
- _.extend(data, collection.extraSearchParams);
- }
- collection.fetch({data: data, reset: true});
- },
-
- /*clear: function (e) {
- if (e) e.preventDefault();
- this.searchBox().val(null);
- this.collection.fetch({reset: true});
- }*/
-
- });
-
-
-
- var HeaderRow = Backgrid.Row.extend({
-
- requiredOptions: ["columns", "collection"],
-
- initialize: function () {
- Backgrid.Row.prototype.initialize.apply(this, arguments);
- },
-
- makeCell: function (column, options) {
- var headerCell;
- switch(true){
- case (column.has('canHeaderSearch') && column.get('canHeaderSearch') === true) :
- headerCell = new HeaderSearchCell({
- column : column,
- collection : this.collection,
- });
- break;
-
- case (column.has('canHeaderFilter') && column.get('canHeaderFilter') === true) :
- headerCell = new HeaderFilterCell({
- column : column,
- collection : this.collection,
- });
- break;
- default :
- headerCell = new Backbone.View({
- tagName : 'td'
- });
- }
- return headerCell;
- }
-
- });
-
-
-
- var FSHeader = Backgrid.Header.extend({
-
- initialize: function (options) {
- var args = Array.prototype.slice.apply(arguments);
- Backgrid.Header.prototype.initialize.apply(this, args);
- this.searchRow = new HeaderRow({
- columns: this.columns,
- collection: this.collection
- });
- },
-
- /**
- Renders this table head with a single row of header cells.
- */
- render: function () {
- var args = Array.prototype.slice.apply(arguments);
- Backgrid.Header.prototype.render.apply(this, args);
-
- this.$el.append(this.searchRow.render().$el);
- return this;
- },
-
- remove: function () {
- var args = Array.prototype.slice.apply(arguments);
- Backgrid.Header.prototype.remove.apply(this, args);
-
- this.searchRow.remove.apply(this.searchRow, arguments);
- return Backbone.View.prototype.remove.apply(this, arguments);
- }
-
- });
-
-
- return FSHeader;
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/DatePickerLayout.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/DatePickerLayout.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/DatePickerLayout.js
deleted file mode 100644
index 22a9b30..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/DatePickerLayout.js
+++ /dev/null
@@ -1,228 +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/common/DatePickerLayout_tmpl',
- 'bootstrap-daterangepicker'
-], function(require, backbone, Utils, DatePickerLayoutTmpl, daterangepicker) {
- 'use strict';
-
- return Backbone.Marionette.Layout.extend(
- /** @lends DatePickerLayout */
- {
- _viewName: 'DatePickerLayout',
-
- template: DatePickerLayoutTmpl,
-
-
- /** ui selector cache */
- ui: {
- dateRange: "#dateRange",
- selectDateRange: ".selectDateRange",
- dateRangeTitle: "span[data-id='dateRangeTitle']",
-
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- events['change ' + this.ui.viewType] = 'onViewTypeChange';
- return events;
- },
-
- /**
- * intialize a new DatePickerLayout Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options, 'vent', 'globalVent', 'params', 'viewType', 'datePickerPosition','parentEl', 'fetch', 'rangeLabel', 'width', 'hideFireButton','buttonLabel'));
- this.dateUtil = Utils.dateUtil;
- this.dateRangeLabel = new String();
-
- this.bindEvents();
- this.graphParams = {};
- this.unit = this.params.unit ? this.params.unit : "+1HOUR";
- this.isEventTriggerdFromVent = false;
- },
- bindEvents: function() {
- this.listenTo(this.vent, "tab:refresh", function(params) {
- this.reRenderView(params);
- }, this);
- this.listenTo(this.vent, "date:setDate", function(options) {
- this.setValues(options);
- }, this);
- this.listenTo(this.vent, "date:click", function(options) {
- this.isEventTriggerdFromVent = true;
- this.setValues(options);
- this.ui.dateRange.data('daterangepicker').clickApply();
- }, this);
- this.listenTo(this.vent, "date:getValues", function(obj) {
- var dates = this.getValues();
- obj.dates = [dates[0], dates[1]];
- obj.dateRangeLabel = this.dateRangeLabel;
- obj.unit = this.unit;
- }, this);
-
- },
- onRender: function() {
- var that = this;
- if(this.hideFireButton){
- this.$(".goBtn").hide();
- }
- if(this.buttonLabel){
- this.$(".goBtn").text(this.buttonLabel);
- }
- if (!this.params.dateRangeLabel) {
- this.params['dateRangeLabel'] = "Today";
- }
- this.initializeDateRangePicker();
- this.setValues(this.params);
- this.unit = that.checkDateRange(that.ui.dateRange.data("daterangepicker"));
- if (this.fetch) {
- that.vent.trigger("logtime:filter", _.extend({
- q: "*:*"
- }, this.params, {
- unit: this.unit
- }));
- }
- if (this.rangeLabel) {
- this.ui.dateRangeTitle.show();
- }else{
- this.ui.dateRangeTitle.hide();
- }
- if (this.width) {
- this.ui.selectDateRange.css('width',this.width);
- }
-
- },
- setValues: function(val) {
- var startDate, endDate;
- if (val.from) {
- startDate = this.dateUtil.getMomentObject(val.from)
- this.ui.dateRange.data('daterangepicker').setStartDate(startDate);
- }
- if (val.to) {
- endDate = this.dateUtil.getMomentObject(val.to)
- this.ui.dateRange.data('daterangepicker').setEndDate(endDate);
- }
- if (startDate && endDate)
- this.setDateText(startDate, endDate);
- if (val.dateRangeLabel) this.ui.dateRangeTitle.html(val.dateRangeLabel);
- this.dateRangeLabel = val.dateRangeLabel;
- },
- getValues : function(){
- var obj = this.ui.dateRange.data("daterangepicker");
- if(obj){
- return [obj.startDate, obj.endDate];
- }
- },
- initializeDateRangePicker: function() {
- var that = this,
- ranges = {};
- //Apply moments for all ranges separately if you pass single instance then it will run into problem.
- _.each(Utils.relativeDates, function(k) {
- ranges[k.text] = [];
- })
- this.ui.dateRange.daterangepicker(_.extend({
- 'ranges': Object.keys(ranges)
- }, {
- "timePicker": true,
- "timePickerIncrement": 1,
- "timePicker24Hour": true,
- "opens": (that.datePickerPosition) ? (that.datePickerPosition) : (undefined),
- timePickerSeconds: true,
- showWeekNumbers: true,
- timeZone: 0,
- locale: {
- format: 'MM/DD/YYYY H:mm:ss,SSS'
- },
- parentEl: (that.parentEl) ? (that.parentEl) : (that.$el),
- }));
- this.bindDateRangePicker();
- },
- bindDateRangePicker: function() {
- var that = this;
- if (this.parentEl) {
- var elem = this.parentEl.find('.daterangepicker');
- } else {
- var elem = this.$('.daterangepicker');
- }
-
-
- this.ui.dateRange.on('apply.daterangepicker ', function(ev, picker) {
- if(! that.isEventTriggerdFromVent && !(_.isUndefined(picker.chosenLabel)) ){
- that.dateRangeLabel = picker.chosenLabel;
- }else{
- that.isEventTriggerdFromVent = false;
- }
- if (that.dateRangeLabel !== "Custom Range") {
- var range = that.dateUtil.getRelativeDateFromString(that.dateRangeLabel);
- that.setDateText(range[0], range[1]);
- }
- that.ui.dateRangeTitle.html(that.dateRangeLabel);
- that.unit = that.checkDateRange(picker);
- var options = {
- 'from': (picker.startDate).toJSON(),
- 'to': (picker.endDate).toJSON(),
- 'unit': that.unit,
- 'dateRangeLabel': that.dateRangeLabel
- }
- that.vent.trigger("logtime:filter", options);
- that.pickerOpend = false
- });
- this.ui.dateRange.on('show.daterangepicker', function(ev, picker) {
- elem.find('li').removeClass('active');
- elem.find('li:contains(' + that.dateRangeLabel + ')').addClass('active');
- picker.chosenLabel = that.dateRangeLabel;
- });
- this.ui.dateRange.on('hide.daterangepicker', function(ev, picker) {
- that.pickerOpend = true
- });
-
- this.ui.selectDateRange.on("click", 'button.goBtn', function() {
- if (that.pickerOpend) {
- var textRange = elem.find('li.active').text();
- if (textRange == "Custom Range") that.dateRangeLabel = elem.find('li.active').text();
- }
- if (that.dateRangeLabel == "Last 1 Hour") {
- var last1Hour = that.dateUtil.getRelativeDateFromString(that.dateRangeLabel);
- that.setDateText(last1Hour[0], last1Hour[1]);
- }
- that.ui.dateRange.data('daterangepicker').clickApply();
-
- });
- },
- checkDateRange: function(picker) {
- return this.dateUtil.calculateUnit(picker)
- },
- setDateText: function(start, end) {
-
- this.ui.dateRange.val(this.dateUtil.getTimeZone(start, "MM/DD/YYYY H:mm:ss,SSS") + ' - ' + this.dateUtil.getTimeZone(end, "MM/DD/YYYY H:mm:ss,SSS"));
- this.ui.dateRange.data('daterangepicker').setStartDate(start);
- this.ui.dateRange.data('daterangepicker').setEndDate(end);
-
- },
- reRenderView: function(params) {
- this.setValues(_.extend(this.params, params));
- }
- });
-
-
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/ErrorView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/ErrorView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/ErrorView.js
deleted file mode 100644
index a26088e..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/ErrorView.js
+++ /dev/null
@@ -1,100 +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',
- 'hbs!tmpl/common/ErrorView_tmpl'
-],function(require,Backbone,Communicator,ErrorView_tmpl){
- 'use strict';
-
- var ErrorView = Backbone.Marionette.ItemView.extend(
- /** @lends ErrorView */
- {
- _viewName : ErrorView,
-
- template: ErrorView_tmpl,
- templateHelpers :function(){
- var msg = '', moreInfo = '';
- if(this.status == 401){
- msg = 'Access Denied (401)'
- moreInfo = "Sorry, you don't have enough privileges to view this page.";
- }else{
- msg = 'Page not found (404).'
- moreInfo = "Sorry, this page isn't here or has moved.";
- }
- return {
- 'msg' : msg,
- 'moreInfo' : moreInfo
- };
- },
- /** ui selector cache */
- ui: {
- 'goBackBtn' : 'a[data-id="goBack"]',
- 'home' : 'a[data-id="home"]'
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- //events['change ' + this.ui.input] = 'onInputChange';
- events['click ' + this.ui.goBackBtn] = 'goBackClick';
- return events;
- },
-
- /**
- * intialize a new ErrorView ItemView
- * @constructs
- */
- initialize: function(options) {
- console.log("initialized a ErrorView ItemView");
-
- _.extend(this, _.pick(options, 'status'));
-
- 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();
- $('#r_breadcrumbs').hide();
- },
- goBackClick : function(){
- history.back();
- },
-
- /** all post render plugin initialization */
- initializePlugins: function(){
- },
- /** on close */
- onClose: function(){
- $('#r_breadcrumbs').show();
- }
-
- });
-
- return ErrorView;
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/EventHistoryLayout.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/EventHistoryLayout.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/EventHistoryLayout.js
deleted file mode 100644
index 01e18b1..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/EventHistoryLayout.js
+++ /dev/null
@@ -1,486 +0,0 @@
-/**
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-define(['require',
- 'backbone',
- 'utils/Globals',
- 'utils/Utils',
- 'collections/VEventHistoryList',
- 'models/VCommonModel',
- 'hbs!tmpl/common/EventHistoryLayout_tmpl',
- 'hbs!tmpl/common/EventHistoryItemView_tmpl',
- 'moment'
-],function(require,Backbone,Globals,Utils,VEventHistoryList,VCommonModel,EventHistoryLayout_tmpl, EventHistoryItemView_tmpl,moment){
- 'use strict';
-
- var EventView = Backbone.Marionette.ItemView.extend({
- tagName:"li",
- template : EventHistoryItemView_tmpl,
- ui : {
- content : "[data-id='content']",
- flagWrap : ".flagWrap"
- },
- /** ui events hash */
- events: function() {
- var events = {};
- events["click "+this.ui.flagWrap] = 'onFlagClick';
- events["click .infoBtn"] = 'onInfoClick';
- events["click .removeFlag"] = 'onRemoveFlagClick';
- events["click .saveBtn"] = 'onSaveClick';
- return events;
- },
- initialize: function(options) {
- _.extend(this, _.pick(options,'eventVent','vent'));
- this.bindEvents();
- },
- bindEvents : function(){
- this.listenTo(this.model, "event:highlight", function($el) {
- this.highlightli($el);
- }, this);
- this.listenTo(this.model, "event:fireReinitialize", function() {
- this.fireReinitialize();
- }, this);
- },
- onRender : function(){
- this.ui.content.text(this.getLabel());
- },
- getLabel : function(){
- var text = "",param = this.model.get("newParam"),key = _.keys(this.model.get("newParam"))[0];
- if(param){
- var preText = "Value:";
- if(param.dateRangeLabel){
- return param.dateRangeLabel;
- }
- if(key === "includeQuery"){
- preText = "IColumn :";
- }
- if(key === "excludeQuery"){
- preText = "EColumn :";
- }
- if(key === "level"){
- preText = "Level :";
- }
- if(key === "mustBe"){
- preText = "IC :";
- }
- if(key === "mustNot"){
- preText = "EC :";
- }
- if(key === "mustNot"){
- preText = "EC :";
- }
- if(key === "from" || key === "to"){
- preText = param.dateRangeLabel;
- }
- if(key === "filtername"){
- preText = "Filter :";
- }
- return preText + " "+this.model.get("newParam")[_.keys(this.model.get("newParam"))[0]];
- }
- return text;
- },
- onFlagClick : function(e){
- var that = this;
- this.fireReinitialize();
- setTimeout(function(){
- that.highlightli(that.$el.children("[data-id]"))
- },10);
- },
- highlightli : function($el){
- //$el is the flag container
- $el.parents("li").siblings("li").find(".showFlag").removeClass("flagActive");
- $el.addClass("flagActive");
- this.eventVent.trigger("event:position:center",$el.parents("li"));
- },
- onInfoClick : function(e){
- var html = "<table class='table eventTable table-hover'><thead><th>Name</th><th>Value</th></thead>",that=this;
- var customParam = {"mustNot":[],"mustBe":[],"includeQuery":[],"excludeQuery":[]};
- var paramNames = _.extend({},this.model.get("params"),customParam);
- _.each(paramNames, function(value, key) {
- if ( (! _.isEmpty(value) || _.isArray(value)) && ( key != "bundleId" && key != "start_time" &&
- key != "end_time" && key != "q" && key != "unit" && key != "query" && key != "type" &&
- key != "time" && key != "dateRangeLabl" && key != "advanceSearch" && !_.isUndefined(Globals.paramsNameMapping[key]) )){
- html += '<tr class="' + key + '"><td>' + Globals.paramsNameMapping[key].label + '</td><td>' + that.getHtmlForParam(key) + '</td><tr>'
- }
- });
- html += "</table>";
- Utils.alertPopup({msg : html,className:"bootBoxSmall"});
- },
- getHtmlForParam : function(key){
- var paramValue = this.model.get("params"),value=paramValue[key];
-
- if(key === "from" || key === "to"){
- value = moment(paramValue[key]).format('MM/DD/YYYY,HH:mm:ss,SSS');
- }else{
- if(_.isUndefined(paramValue[key])){
- value = "[]";
- }
- }
- return value;
- },
- onRemoveFlagClick : function(e){
- e.stopImmediatePropagation();e.stopPropagation();
- var siblings = this.$el.siblings(),that=this;
- if(siblings.length > 0){
- var focusLi = $(siblings[siblings.length -1]).children("[data-id]");
- this.collection.remove(this.model);
- this.close();
- focusLi.find(".flagWrap").click();
- }
-
- },
- fireReinitialize: function() {
- this.vent.trigger("reinitialize:filter:tree " +
- "reinitialize:filter:include:exclude " +
- "reinitialize:filter:bubbleTable " +
- "reinitialize:filter:mustNot " +
- "reinitialize:filter:mustBe " +
- "reinitialize:filter:level " +
- "reinitialize:filter:logtime", _.extend({
- mustNot: null,
- mustBe: null,
- query: null,
- includeQuery: null,
- excludeQuery: null
- }, this.model.get('params')));
- },
- onSaveClick : function(e){
- var that = this;
- require(['views/dialog/SaveSearchFilterView'], function(SaveSearchFilterView) {
- var view = new SaveSearchFilterView({
- selectedCollectionObject: that.model
- });
- that.setupDialog({
- title: "Save Search Filter",
- content: view,
- viewType: 'Save',
- width: 850,
- height: 500,
- buttons: [{
- id: "okBtn",
- text: "Save",
- "class": "btn btn-primary",
- click: function() {
- that.onDialogSubmitted();
- }
- }, {
- id: "cancelBtn",
- text: "Close",
- "class": "btn btn-default",
- click: function() {
- that.onDialogClosed();
- }
- }]
- });
- });
- },
- setupDialog: function(options) {
- var that = this;
- require(['views/common/JBDialog'], function(JBDialog) {
- var opts = _.extend({
- appendTo: 'body',
- modal: true,
- resizable: false
- }, options);
- var dialog = that.dialog = new JBDialog(opts).render().open();
- })
- },
- onDialogSubmitted: function() {
- var content = this.dialog.options.content;
- if (content.$('form')[0].checkValidity && !content.$('form')[0].checkValidity()) {
- content.$('form').addClass('has-error');
- if (content.$('form')[0].reportValidity) {
- if (!content.$('form')[0].reportValidity()) {
- return;
- }
- }
- return;
- } else {
- if(_.isEmpty(content.ui.filterName.val().trim())){
- if(content.$('form')[0].reportValidity){
- content.ui.filterName.val('')
- content.$('form')[0].reportValidity();
- return;
- }
- return;
- }else{
- content.$('form').removeClass('has-error');
- }
- }
- var timeType = content.$("input[name='radio']:checked").parents("[data-id]").data('id'),
- params = content.selectedCollectionObject.get("params");
- if(timeType === "absolute"){
- params["dateRangeLabel"] = "Custom Range";
- }
- params["time"] = timeType;
- var postObject = {
- filtername: content.ui.filterName.val().trim(),
- rowType: "history",
- values: JSON.stringify(params)
- }
- content.trigger("toggle:okBtn");
- this.saveEventHistory(postObject);
- },
- saveEventHistory: function(postObject) {
- var that = this
- this.collection.saveEventHistory(postObject, {
- success: function(data, textStatus, jqXHR) {
- Utils.notifySuccess({
- content: "Event History saved successfully."
- });
- that.onDialogClosed();
- },
- error: function(jqXHR, textStatus, errorThrown) {
- Utils.notifyError({
- content: JSON.parse(jqXHR.responseText).msgDesc || "There is some problem in Event History, Please try again later."
- });
- that.dialog.options.content.trigger("toggle:okBtn",true);
- },
- complete: function() {
- }
- });
- },
- onDialogClosed: function() {
- if (this.dialog) {
- this.dialog.close && this.dialog.close();
- this.dialog.remove && this.dialog.remove();
- this.dialog = null;
- }
- }
- });
-
-
-
- return Backbone.Marionette.CompositeView.extend(
- /** @lends EventHistoryLayout */
- {
- _viewName : 'EventHistoryLayout_tmpl',
-
- template: EventHistoryLayout_tmpl,
-
- itemViewContainer : "#events",
-
- itemView : EventView,
-
- itemViewOptions : function(){
- return {
- collection : this.collection,
- eventVent : this.eventVent,
- vent : this.vent
- }
- },
-
- /** Layout sub regions */
- regions: {
- },
-
- /** ui selector cache */
- ui: {
- loaderEvent : "#loaderEvent",
- eventsCont : "#eventsCont",
- events : "#events"
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- events["change "+this.ui.mainCheck] = 'onMainCheckboxClick';
- events["click .slideArrow a"] = 'slideArrowClick';
- events['click .apply-link'] = 'onEventHistoryLoadClick';
- events["click .collapse-link"] = 'onCollapseBoxClick';
- return events;
- },
-
- /**
- * intialize a new EventHistoryLayout Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options,'vent','globalVent','params'));
- this.eventVent = new Backbone.Wreqr.EventAggregator();
- this.searchParmas = (this.params) ? this.params : {};
- this.collection = new VEventHistoryList();
- this.bindEvents();
- },
- bindEvents: function() {
- this.listenTo(this.vent, "level:filter type:mustNot type:mustBe search:include:exclude " +
- "logtime:filter " + Globals.eventName.serviceLogsIncludeColumns + " " + Globals.eventName.serviceLogsExcludeColumns,
- function(value) {
- if(this.collection.last()){
- var params = _.extend({},this.searchParmas, value);//,id=this.getNewIndex();
- this.addFlag(params,value);
- var leftOffset = this.ui.events.offset();
- (leftOffset.left < 0) ? this.$('.slideArrow').show() : this.$('.slideArrow').hide();
- }
-
- }, this);
-
- this.listenTo(this.collection, "add remove reset", function() {
- this.$("[data-id='count']").text(this.collection.length);
- this.$("[data-id='totalCount']").text(this.collection.totalCount);
- this.limitTheFlags();
- }, this);
-
- this.listenTo(this.eventVent, "event:position:center", function($li) {
- this.scrollToElement($li);
- }, this);
- },
- onRender : function(){
- if(this.params){
- this.collection.add(this.collection.model({id:this.getNewIndex(),
- params:_.extend({},this.params),
- newParam:{level:this.params.level
- }}));
- this.$(".removeFlag").remove();
- }
- },
- onShow : function(){
- this.flagDraggable();
- },
- addFlag : function(params, showParam){
- var id=this.getNewIndex();
- var model = new this.collection.model({
- id : id,
- params : params,
- newParam : showParam
- });
- this.collection.add(model);
- model.trigger("event:highlight",this.ui.events.find("[data-id='"+id+"']"));
- return model;
- },
- limitTheFlags : function(){
- if(this.collection.length == 26){
- this.collection.remove(this.collection.at(1));
- }
- },
- flagDraggable: function() {
- var that = this;
- this.ui.events.draggable({
- axis: "x",
- stop : function(){
- that.toggleSlideArrow();
- }
- });
-
- },
- toggleSlideArrow : function(){
- var that = this;
- that.leftDistance = that.ui.events.offset();
- if(that.timeLineWidth <= that.leftDistance.left){
- //this.$('.slideArrow').hide();
- }else{
- that.$('.slideArrow').show();
- }
- },
- getNewIndex : function(){
- if(this.lastIndex){
- this.lastIndex++;
- }else{
- this.lastIndex = 1;
- }
- return this.lastIndex;
- },
- scrollToElement : function($li){
- var flagIndex = $li.index();
- var options = { duration: 200 };
- this.timeLineWidth = this.ui.eventsCont.width() / 2;
-
- this.ui.events.animate({ 'left': this.timeLineWidth - (flagIndex * $li.outerWidth()) + 'px' }, options);
-
- },
- slideArrowClick : function(e){
- e.preventDefault();
- var leftDistance = this.ui.events.offset();
- if($(e.currentTarget).hasClass('arrowLeft')){
- this.ui.events.animate({ 'left': leftDistance.left - 140 + 'px' }, 200) ;
- }else{
- this.ui.events.animate({ 'left': leftDistance.left + 140 + 'px' }, 200);
- }
- },
- onEventHistoryLoadClick: function() {
- var that = this;
- require(['views/dialog/ApplySearchFilterView'], function(ApplySearchFilterView) {
- var view = new ApplySearchFilterView({
- collection: new VEventHistoryList([], {
- state: {
- firstPage: 0,
- pageSize: 10 // have to pass max pageSize value or
- // else it will take default pageSize
- }
- })
- })
- that.setupDialog({
- title: "Apply Filter",
- content: view,
- viewType: 'Save',
- width: 850,
- height: 500,
- buttons: [{
- id: "cancelBtn",
- text: "Close",
- "class": "btn btn-default",
- click: function() {
- that.onDialogClosed();
- }
- }]
- });
- view.on("apply:filter",function(model){
- var params = JSON.parse(model.get("values"));
- if (params.time === "relative") {
- var rangeNew = Utils.dateUtil.getRelativeDateFromString(params.dateRangeLabel);
- if (_.isArray(rangeNew)) {
- params.from = rangeNew[0].toJSON();
- params.to = rangeNew[1].toJSON();
- }
- }
- var newModel = that.addFlag(params,{filtername:model.get("filtername")});
- newModel.trigger("event:fireReinitialize");
- that.onDialogClosed();
- })
- });
- },
- setupDialog: function(options) {
- var that = this;
- require(['views/common/JBDialog'], function(JBDialog) {
- var opts = _.extend({
- appendTo: 'body',
- modal: true,
- resizable: false
- }, options);
- var dialog = that.dialog = new JBDialog(opts).render().open();
- })
- },
- onDialogClosed: function() {
- if (this.dialog) {
- this.dialog.close && this.dialog.close();
- this.dialog.remove && this.dialog.remove();
- this.dialog = null;
- }
- },
- onCollapseBoxClick : function(e){
- if($(e.currentTarget).find("i").hasClass("fa-chevron-down")){
- var $el = this.ui.events.find(".flagActive");
- if($el.length){
- var model = this.collection.get($el.data("id"));
- setTimeout(function(){
- model.trigger("event:highlight",$el);
- },1000);
- }
- }
- }
- });
-});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Footer.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Footer.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Footer.js
deleted file mode 100644
index dcbd633..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Footer.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',
- 'hbs!tmpl/common/Footer_tmpl'
-],function(require,Backbone,Communicator,Footer_tmpl){
- 'use strict';
-
- var Footer = Backbone.Marionette.ItemView.extend(
- /** @lends Footer */
- {
- _viewName : Footer,
-
- template: Footer_tmpl,
-
- /** ui selector cache */
- ui: {},
-
- /** ui events hash */
- events: function() {
- var events = {};
- //events['change ' + this.ui.input] = 'onInputChange';
- return events;
- },
-
- /**
- * intialize a new Footer ItemView
- * @constructs
- */
- initialize: function(options) {
- console.log("initialized a Footer ItemView");
-
- _.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 Footer;
-});