You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ol...@apache.org on 2017/09/05 19:37:22 UTC
[06/51] [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/tabs/ComparisonView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/ComparisonView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/ComparisonView.js
deleted file mode 100644
index 7c50cbb..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/ComparisonView.js
+++ /dev/null
@@ -1,242 +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',
- 'moment',
- 'utils/Globals',
- 'collections/VLogList',
- 'hbs!tmpl/tabs/ComparisonView_tmpl',
-], function(require, Backbone, Utils, moment, Globals, VLogList, ComparisonViewTmpl) {
- 'use strict';
-
- return Backbone.Marionette.Layout.extend(
- {
- _viewName: 'ComparisonView',
-
- template: ComparisonViewTmpl,
-
- regions: {
- RVSSearch: "#r_VSSearch",
- RLogTable: "#rLogTable",
- RDatePicker: "#r_DatePicker"
- },
- /** ui selector cache */
- ui: {
- dateRange: "#dateRange",
- selectDateRange: ".selectDateRange",
- tabTitle: "[data-id='tabTitle']"
-
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- return events;
- },
- /**
- * intialize a new ComparisonView Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'params', 'datePickerPosition'));
- this.vent = new Backbone.Wreqr.EventAggregator();
- this.collection = new VLogList([], {
- state: {
- firstPage: 0,
- pageSize: 25
- }
- });
- this.dateUtil = Utils.dateUtil;
- this.collection.url = Globals.baseURL + "service/logs";
- this.bindEvents();
- this.dateRangeLabel = "Last 1 Hour"
- },
- bindEvents: function() {
- this.listenTo(this.vent, "search:include:exclude", function(value) {
- this.fetchCollection(value);
- }, this);
- this.listenTo(this.vent, "logtime:filter", function(value) {
- this.fetchCollection(value);
- }, this);
- },
- onRender: function() {
- if (this.params) {
- this.fetchCollection(this.params);
- if (this.params.component_name && this.params.host_name) {
- this.ui.tabTitle.html(this.params.host_name + ' <i class="fa fa-angle-double-right"></i> ' + this.params.component_name)
- }
- } else {
- this.fetchCollection({
- "q": "*:*"
- });
- }
- this.renderVisualSearch();
- this.renderDatePicker();
- this.renderTable();
-
- },
- renderVisualSearch: function() {
- var that = this;
- require(['views/tabs/VisualSearchView'], function(VisualSearchView) {
- that.RVSSearch.show(new VisualSearchView({
- vent: that.vent,
- globalVent: that.globalVent,
- params: that.params,
- eventName: "search:include:exclude"
- }));
- })
-
- },
- renderDatePicker: function() {
- var that = this;
- require(['views/common/DatePickerLayout'], function(DatePickerLayout) {
- that.RDatePicker.show(new DatePickerLayout({
- vent: that.vent,
- globalVent: that.globalVent,
- params: that.params,
- datePickerPosition: that.datePickerPosition,
- parentEl: that.$el,
- rangeLabel: true
- }));
- });
- },
- fetchCollection: function(params) {
- var that = this;
- this.$('#loaderToolbar').show();
- _.extend(this.params, params);
- $.extend(this.collection.queryParams, params);
- this.collection.getFirstPage({
- reset: true,
- complete: function() {
- that.$('#loaderToolbar').hide();
- }
- });
- },
- renderTable: function() {
- var that = this;
- require(['views/common/TableLayout', 'views/common/CustomBackgrid'], function(TableLayout, CustomBackgrid) {
- var cols = new Backgrid.Columns(that.getColumns());
- that.RLogTable.show(new TableLayout({
- columns: cols,
- collection: that.collection,
- includeFilter: false,
- includePagination: true,
- includePageSize: true,
- includeFooterRecords: true,
- includeColumnManager: true,
- columnOpts: {
- initialColumnsVisible: 2,
- saveState: false
- },
- gridOpts: {
- header: CustomBackgrid,
- emptyText: 'No records found!'
- },
- filterOpts: {},
- paginatorOpts: {}
- }));
- });
- },
- getColumns: function() {
- var timeZone = moment().zoneAbbr();
- this.cols = {
- logtime: {
- label: "Log Time " + (!_.isEmpty(timeZone) ? "(" + timeZone + ")" : ""),
- cell: "html",
- editable: false,
- sortType: 'toggle',
- direction: "descending",
- orderable: true,
- displayOrder: 1,
- width: 17,
- className: "logTime",
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function(rawValue, model) {
- var str = "";
- if (rawValue)
- str += "<p>" + moment(rawValue).format("YYYY-MM-DD HH:mm:ss,SSS") + "</p>";
- if (model.get("type"))
- str += "<p style='float:left;width:90%'>" + (model.get("level") ? "<label class='label label-" + (""+model.get("level")).toUpperCase() + "'>" + (""+model.get("level")).toUpperCase() + "</label>" : "") +
- "</p><a style='width:9%' title='Open logs in new tab' data-type='C' data-host='" + model.get("host") + "' data-node='" + model.get("type") + "' href='javascript:void(0)' class='pull-right hidden'><i class='fa fa-share'></i></a>";
- return str;
- }
- })
- },
- log_message: {
- label: "Message",
- cell: "html",
- editable: false,
- sortType: 'toggle',
- sortable: false,
- orderable: true,
- displayOrder: 4,
- className: "logMessage",
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function(rawValue, model) {
- return (rawValue) ? "<pre>" + Utils.escapeHtmlChar(rawValue) + "</pre>" : "";
- }
- })
- },
- thread_name: {
- label: "Thread",
- cell: "String",
- editable: false,
- sortType: 'toggle',
- sortable: false,
- orderable: true,
- displayOrder: 5,
- width: 10
- },
- logger_name: {
- label: "Logger",
- cell: "String",
- editable: false,
- sortType: 'toggle',
- sortable: false,
- orderable: true,
- displayOrder: 6,
- width: 13
- },
- bundle_id: {
- label: "Bundle Id",
- cell: "String",
- editable: false,
- sortType: 'toggle',
- sortable: false,
- orderable: true,
- displayOrder: 6,
- width: 6
- }
-
- };
- return this.collection.constructor.getTableCols(this.cols, this.collection);
- },
- 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);
-
- }
-
- });
-
-
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/EventHistoryLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/EventHistoryLayoutView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/EventHistoryLayoutView.js
deleted file mode 100644
index 1eda79b..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/EventHistoryLayoutView.js
+++ /dev/null
@@ -1,506 +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',
- 'moment',
- 'timeline',
- 'collections/VEventHistoryList',
- 'hbs!tmpl/tabs/EventHistoryLayoutView_tmpl'
-], function(require, Backbone, Globals, Utils, moment, Timeline, VEventHistory, EventHistoryLayoutViewTmpl) {
- 'use strict';
-
- return Backbone.Marionette.Layout.extend(
- /** @lends EventHistoryLayoutViewTmpl */
- {
- _viewName: 'EventHistoryLayoutView',
-
- template: EventHistoryLayoutViewTmpl,
-
-
- /** ui selector cache */
- ui: {
- eventHistory: "#timeline",
- saveLink: ".save-link",
- applyLink: ".apply-link"
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- events['change ' + this.ui.viewType] = 'onViewTypeChange';
- events['click ' + this.ui.saveLink] = 'onSaveClick';
- events['click ' + this.ui.applyLink] = 'onEventHistoryLoadClick';
-
- return events;
- },
-
- /**
- * intialize a new LogLevelView Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options, 'vent', 'globalVent', 'params'));
- this.searchParams = (this.params) ? this.params : {};
- this.collection = new VEventHistory();
- this.collection.totalCount = Globals.EventHistory.totalCount;
- this.dateUtil = Utils.dateUtil;
- this.data = {
- "timeline": {
- "headline": "Events",
- "type": "default",
- "text": "People say stuff"
-
- }
- }
- },
- bindEvents: function() {
- var that = this
- 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.length >= this.collection.totalCount)
- return;
- _.extend(this.searchParams, value);
- that.eventClicked = true;
- if(that.time){
- that.addEventInTimeline(this.searchParams, Object.keys(value)[0]);
- }else{
- that.timeundefined =[this.searchParams, Object.keys(value)[0]]
- }
-
-
- });
- this.ui.eventHistory.delegate(".vco-timeline", "LOADED", function() {
- if (that.timeLineLoadedOnce) {
- /*if (typeof(Storage) !== "undefined") {
- if (!localStorage.getItem("startIntro")) {
- localStorage.setItem("startIntro", true);
- //Intro.Start();
- }
- } else {
- // Sorry! No Web Storage support..
- }*/
- that.time = new VMM.Timeline()
- that.timeLineLoadedOnce = false;
- }
- if(that.timeundefined){
-
- }
-
- if (that.eventClicked) {
- that.ui.eventHistory.find('.marker#' + (that.markerId) + " h3").click();
- that.eventClicked = false;
- }
- that.$("#loaderEvent").hide();
- that.$(".loader").hide();
-
- });
- this.ui.eventHistory.delegate(".marker", "click", function(event) {
- if (event.target.nodeName === "I") return;
- var typeToTrigger = $(this).find('h3').text().split(":")
-
- if (event.isTrigger === undefined) {
- that.fireReinitialize($(this).attr('id'))
- }
- });
- this.ui.eventHistory.delegate(".close", "click", function(event) {
- var elementId = $(event.currentTarget).attr('id');
- var p = $(event.currentTarget).parents(".marker")
- var prevClick = p.prev();
- //prevClick.find("h3").click();
- VMM.fireEvent(prevClick.find(".flag"), 'click', {
- number: 1
- });
- that.collection.remove(elementId);
- var lastStartDate, count = 1;
- for (var i = 0; i < that.data.timeline.date.length; i++) {
- if (that.data.timeline.date[i].customOption.id == elementId) {
- that.data.timeline.date.splice(i, 1);
- i = i - 1;
- that.markerId = that.data.timeline.date[that.data.timeline.date.length - 1].customOption.id;
- } else {
- if (i == 1) lastStartDate = that.data.timeline.date[i].startDate;
- if (i > 1) {
- that.data.timeline.date[i].startDate = moment(lastStartDate.split(',').join("-")).add((count++), 'd').format('YYYY,MM,DD');
- }
- }
-
- }
- /* that.markerId = that.data.timeline.date.length+1;*/
- that.fireReinitialize(prevClick.attr('id'));
- that.addEventInTimeline();
- return false;
- })
-
- 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);
- /*that.ui.saveLink.on('click', function() {
- that.saveEventHistory();
- });*/
- },
- fireReinitialize: function(id) {
- 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,
- iMessage: null,
- eMessage: null,
- query: null,
- includeQuery: null,
- excludeQuery: null
- }, this.collection.get(id).get('params')));
- },
- initializeData: function() {
- var that = this;
- this.markerId = 1;
- that.eventClicked = true;
- this.data.timeline.date = [{
- "startDate": moment('2015-01-02').format('YYYY,MM,DD'),
- "headline": this.getHeadline("level", this.searchParams),
- "params": _.extend({
- type: "level"
- }, this.searchParams),
- "customOption": {
- id: this.markerId,
- close: false
- }
- }, {
- "startDate": moment('2015-01-02').add((this.markerId++), 'd').format('YYYY,MM,DD'),
- "headline": this.getHeadline("from", this.searchParams),
- /*"headline": "Logtime: " + moment(this.searchParams.from).format(Globals.dateFormat) + " TO " + moment(this.searchParams.to).format(Globals.dateFormat),*/
- "params": _.extend({
- type: "from"
- }, this.searchParams),
- "customOption": {
- id: this.markerId,
- close: false
- }
- }];
- _.each(this.data.timeline.date, function(values) {
- that.collection.add(new Backbone.Model({
- id: values.customOption.id,
- /* headline: values.headline,*/
- params: values.params
- }))
- })
-
-
- this.generateTimeline(this.data);
- },
-
- generateTimeline: function(data) {
- var that = this;
- createStoryJS({
- type: 'timeline',
- width: '100%',
- height: '180',
- source: data,
- embed_id: that.ui.eventHistory,
- debug: true
- });
- this.timeLineLoadedOnce = true
- },
- onRender: function() {
- this.bindEvents()
- this.initializeData();
- //this.fetchEventHistory();
- this.$("#loaderEvent").show();
- this.$(".loader").show();
- },
- addEventInTimeline: function(params, type) {
- if (params) {
-
- try {
- var lastDate = this.data.timeline.date[this.data.timeline.date.length - 1].startDate;
- } catch (e) {
- throw "StartDate undefined";
- }
-
- this.data.timeline.date.push({
- "startDate": moment(lastDate.split(',').join("-")).add(1, 'd').format('YYYY,MM,DD'),
- "headline": this.getHeadline(type, params),
- "customOption": {
- id: ++this.markerId,
- close: true
- }
- })
-
- params.type = type;
- this.collection.add({
- id: this.markerId,
- /* headline: getHeadline(),*/
- params: _.extend({}, params)
- })
-
- }
- if (this.time) {
- this.time.reload(this.data)
- }
-
- return;
-
-
- },
- getHeadline: function(type, params) {
- var excludeInclude = function() {
- var str = "";
- if (params.iMessage) {
- str += "IS:" + Utils.encodeIncludeExcludeStr(params.iMessage);
- } else
- str += "IS:";
- if (params.eMessage) {
- str += " ES:" + Utils.encodeIncludeExcludeStr(params.eMessage);
- } else
- str += " ES:";
- return str;
-
- };
- var includeExcludeColumnSearch = function() {
- var str = "";
- if (params.includeQuery || params.excludeQuery) {
- var obj;
- if (type === "includeQuery") {
- str += "IColumn:";
- obj = JSON.parse(params.includeQuery)
- } else {
- str += "EColumn:";
- obj = JSON.parse(params.excludeQuery)
- }
-
- if (_.isArray(obj)) {
- for (var i = 0; i < obj.length; i++) {
- var key = _.keys(obj[i])[0];
- str += "" + key + "=" + obj[i][key];
- if (!(i == obj.length - 1))
- str += ",";
- }
-
- }
- }
- return str;
- };
- return (type === "level") ?
- ("Level: " + params.level) : (type === "from") ?
- ("Logtime: " + this.dateUtil.getTimeZone(params.from) + " TO " + this.dateUtil.getTimeZone(params.to)) : (type === "mustBe") ?
- ("IC:" + params.mustBe) : (type === "mustNot") ?
- ("EC:" + params.mustNot) : ((type === "includeQuery" || type === "excludeQuery") ? (includeExcludeColumnSearch()) : (excludeInclude()))
-
-
- },
- onEventHistoryLoadClick: function() {
- var that = this;
- require(['views/dialog/ApplySearchFilterView'], function(ApplySearchFilterView) {
- if (that.collection.length >= 50) {
- Utils.alertPopup({
- msg: "Event History limit has reached, Please clear your history"
- });
- return;
- }
- var view = new ApplySearchFilterView({
- collection: new VEventHistory([], {
- 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.onApplyDialogClosed();
- }
- }]
- });
- });
- },
- onSaveClick: function() {
- var that = this;
- require(['views/dialog/SaveSearchFilterView'], function(SaveSearchFilterView) {
- var activeFlag = that.$('.timenav').find('.marker:gt(0).active');
- if (activeFlag.length == 0) {
- Utils.notifyInfo({
- content: "Item not selected in event history."
- });
- return;
- } else {
- var selectedCollectionObject = that.collection.findWhere({
- "id": parseInt(activeFlag.attr('id'))
- });
- }
-
- var view = new SaveSearchFilterView({
- selectedCollectionObject: selectedCollectionObject
- });
-
- 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: that.$el,
- modal: true,
- resizable: false,
- beforeClose: function(event, ui) {
- that.onDialogClosed();
- }
- }, options);
- var dialog = that.dialog = new JBDialog(opts).render().open();
- })
-
-
- },
- onDialogSubmitted: function() {
- var content = this.dialog.options.content;
- /* if (!content.$('form')[0].reportValidity()) {
- return;
- }*/
-
-
-
- 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');
-
- if(timeType === "absolute"){
- content.selectedCollectionObject.get("params")["dateRangeLabel"] = "Custom Range";
- }
-
- content.selectedCollectionObject.get("params")["time"] = timeType;
- var postObject = {
- filtername: content.ui.filterName.val(),
- rowType: "history",
- values: JSON.stringify(content.selectedCollectionObject.get('params'))
- }
- this.onDialogClosed();
- this.saveEventHistory(postObject);
- },
- /** closing the movable/resizable popup */
- onApplyDialogClosed: function() {
- var content = this.dialog.options.content;
- if (content.apllyedModel) {
- var params = JSON.parse(content.apllyedModel.toJSON().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();
- }
- }
- this.eventClicked = true;
- this.addEventInTimeline(params, params.type);
- if (this.collection.last()) {
- this.fireReinitialize(this.collection.last().get('id'));
- } else {
- console.log('Not going to last marker as collection is empty');
- }
-
- }
-
- this.onDialogClosed();
-
-
- },
- onDialogClosed: function() {
- if (this.dialog) {
- this.dialog.close && this.dialog.close();
- this.dialog.remove && this.dialog.remove();
- this.dialog = null;
- }
- },
- saveEventHistory: function(postObject) {
- var that = this
- this.$("#loaderEvent").show();
- that.$(".loader").show();
- this.collection.saveEventHistory(postObject, {
- success: function(data, textStatus, jqXHR) {
- Utils.notifySuccess({
- content: "Event History saved successfully."
- });
- },
- error: function(jqXHR, textStatus, errorThrown) {
- Utils.notifyError({
- content: JSON.parse(jqXHR.responseText).msgDesc || "There is some problem in Event History, Please try again later."
- });
- },
- complete: function() {
- that.$("#loaderEvent").hide();
- that.$(".loader").hide();
- }
- });
- }
-
- });
-
-
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/ExportLogFileView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/ExportLogFileView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/ExportLogFileView.js
deleted file mode 100644
index c4eaeda..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/ExportLogFileView.js
+++ /dev/null
@@ -1,50 +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/tabs/ExportLogFileView_tmpl'
-], function(require, Backbone, Utils, ExportLogFileViewTmpl) {
- 'use strict';
-
- return Backbone.Marionette.Layout.extend(
- /** @lends ComparisonLayoutView */
- {
- _viewName: 'ExportLogFileView',
- template: ExportLogFileViewTmpl,
- /**
- * intialize a new LogFileView Layout
- * @constructs
- */
- ui: {
- rowView: "[data-id='rowsData']"
- },
- initialize: function(options) {
- _.extend(this, options);
- },
- onRender: function() {
- if (this.viewType === "aggregatView") {
- this.ui.rowView.hide();
- }
- },
-
- });
-
-
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/HierarchyTabLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/HierarchyTabLayoutView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/HierarchyTabLayoutView.js
deleted file mode 100644
index 43ee5db..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/HierarchyTabLayoutView.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',
- 'moment',
- 'utils/ViewUtils',
- 'collections/VLogList',
- 'collections/VGroupList',
- 'hbs!tmpl/tabs/HierarchyTabLayoutView_tmpl'
-], function (require, Backbone, Globals, Utils, moment, ViewUtils, VLogList, VGroupList, HierarchyTabLayoutViewTmpl) {
- 'use strict';
-
- return Backbone.Marionette.Layout.extend(
- /** @lends LogLevelView */
- {
- _viewName: 'HierarchyTabLayoutView',
-
- template: HierarchyTabLayoutViewTmpl,
-
- /** Layout sub regions */
- regions: {
- RTreeView: "#r_TreeView",
- RBubbleTable: "#r_BubbleTable",
- RLogLevel: "#r_LogLevel",
- RHistogram: "#r_Histogram",
- RVisualSearch: "#r_vsSearch",
- REventHistory: "#r_EventHistory",
- RVisualSearchIncCol: "#r_vsSearchIncCol",
- RVisualSearchExCol: "#r_vsSearchExCol",
- RDatePicker: "#r_DatePicker",
- RLogSnapShot: "#r_LogSnapShot",
- RAdvanceSearch: "#r_AdvanceSearch"
- },
-
- /** ui selector cache */
- ui: {
- applySearch: '#applySearch',
- searchBoxBtn: '[data-id="hierarchySearchBtn"]',
- searchBox: '[data-id="hierarchySearch"]',
- excludeComponents: "#excludeComponents",
- includeComponents: "#includeComponents",
- basicSearch: '[data-id="basicSearch"]',
- advanceSearch: '[data-id="advanceSearch"]',
- toggleTableAccessLog: '[data-id="toggleTableAccessLog"]'
- },
-
- /** ui events hash */
- events: function () {
- var events = {};
- events["click " + this.ui.applySearch] = 'applySearchBtn';
- events["click " + this.ui.searchBoxBtn] = 'onSearchLogClick';
- events["click .server-info a"] = 'onLogLevelClick';
- events["change " + this.ui.toggleTableAccessLog] = 'onSearchSwitch';
-
- return events;
- },
-
- /**
- * intialize a new LogLevelView Layout
- * @constructs
- */
- initialize: function (options) {
- _.extend(this, _.pick(options, 'globalVent'));
- this.columnCollection = new VLogList([], {
- state: {
- firstPage: 0,
- pageSize: 99999
- }
- });
- this.componentsList = new VGroupList([], {
- state: {
- firstPage: 0,
- pageSize: 99999
- }
- });
- this.componentsList.url = Globals.baseURL + "service/logs/components";
- this.vent = new Backbone.Wreqr.EventAggregator();
-
- this.defaultParams = ViewUtils.getDefaultParamsForHierarchy();
- this.bindEvents();
- },
- applyParamsDate: function (date) {
- if (date) {
- var dateString = date.split(',');
- if (dateString.length) {
- var checkDate = Utils.dateUtil.getMomentUTC(dateString[0]);
- if (checkDate.isValid()) {
- if (dateString[1]) {
- checkDate.millisecond(dateString[1])
- } else {
- checkDate.millisecond('000')
- }
- return checkDate.toJSON();
- }
- }
- }
- },
- 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, "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.vent, "add:include:exclude", function (value) {
- //this.$(".vs-box").find(".fa-chevron-down").click();
- }, this);
- this.listenTo(this.vent, "tab:refresh", function (params) {
- this.reRenderComponents(params);
- }, this);
-
- this.listenTo(this.globalVent, "reinitialize:serviceLogs", function (options) {
- 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", options);
- }, this);
- },
- onRender: function () {
- this.fetchServiceLogsColumns();
- this.renderLogLevel();
- this.renderEventHistory();
- this.renderHistogram();
- this.renderDatePicker();
- this.renderLogSnapShot();
- this.componentsList.fetch({reset: true});
- },
- onShow: function () {
-
- },
- fetchServiceLogsColumns: function () {
- var that = this;
- this.columnCollection.getServiceLogSchemaFields({}, {
- success: function (data) {
- Globals.serviceLogsColumns = ViewUtils.getLogSchemaFields(data, Globals.defaultServiceLogMappings, Globals.defaultServiceLogExcludes);
- },
- error: function (error, data, status) {
- var obj = JSON.parse(error.responseText);
- if (obj)
- Utils.notifyError({content: obj.msgDesc});
- },
- complete: function () {
- that.renderServiceColumnsVSSearch();
- that.renderBubbleTableView();
- }
- });
- },
- renderTreeView: function () {
- var that = this;
- require(['views/tabs/TreeView'], function (TreeView) {
- that.RTreeView.show(new TreeView({
- vent: that.vent,
- globalVent: that.globalVent,
- params: that.defaultParams
- }));
- });
- },
- renderBubbleTableView: function () {
- var that = this;
- require(['views/dashboard/BubbleGraphTableLayoutView'], function (BubbleTableLayoutView) {
- that.RBubbleTable.show(new BubbleTableLayoutView({
- vent: that.vent,
- globalVent: that.globalVent,
- params: that.defaultParams,
- columns: Globals.serviceLogsColumns,
- quickHelp: true
- }));
- });
- },
- renderLogLevel: function () {
- var that = this;
- require(['views/dashboard/LogLevelBoxView'], function (LogLevelBoxView) {
- that.RLogLevel.show(new LogLevelBoxView({
- vent: that.vent,
- globalVent: that.globalVent,
- params: that.defaultParams
- }));
- });
- },
- renderHistogram: function () {
- var that = this;
- require(['views/graphs/GraphLayoutView'], function (GraphLayoutView) {
- that.RHistogram.show(new GraphLayoutView({
- vent: that.vent,
- globalVent: that.globalVent,
- params: that.defaultParams,
- showUnit: true,
- futureDate: true
- }));
- });
- },
- renderDatePicker: function () {
- var that = this;
- require(['views/common/DatePickerLayout'], function (DatePickerLayout) {
- that.RDatePicker.show(new DatePickerLayout({
- vent: that.vent,
- globalVent: that.globalVent,
- params: that.defaultParams,
- datePickerPosition: 'left',
- rangeLabel: true,
- parentEl: that.$el.find('.topLevelFilter')
- }));
- });
- },
- renderLogSnapShot: function () {
- var that = this;
- require(['views/common/LogSnapShotLayout'], function (LogSnalShopLayout) {
- that.RLogSnapShot.show(new LogSnalShopLayout({
- vent: that.vent,
- globalVent: that.globalVent,
- params: that.defaultParams
- }));
- });
- },
- renderAdvanceSearch: function () {
- var that = this;
- require(['views/common/AdvanceSearchLayout'], function (AdvanceSearchLayout) {
- that.RAdvanceSearch.show(new AdvanceSearchLayout({
- vent: that.vent,
- globalVent: that.globalVent,
- params: that.defaultParams
- }));
- });
-
-
- },
- renderVSSearch: function () {
- var that = this;
- require(['views/tabs/VisualSearchView'], function (VisualSearchView) {
- that.RVisualSearch.show(new VisualSearchView({
- viewName: "includeExclude",
- vent: that.vent,
- globalVent: that.globalVent,
- eventName: "search:include:exclude",
- myFormatData: function (query, searchCollection) {
- var include = [], exclude = [];
- searchCollection.each(function (m) {
- if (m.get("category") === "Exclude") {
- (!_.isEmpty(m.get("value"))) ? exclude.push(m.get("value")) : '';
- }
- else {
- (!_.isEmpty(m.get("value"))) ? include.push(m.get("value")) : '';
- }
- });
- return {
- iMessage: Utils.encodeIncludeExcludeStr(include, true),
- eMessage: Utils.encodeIncludeExcludeStr(exclude, true),
- query: query
- };
- }
-
- }));
- });
- },
- renderServiceColumnsVSSearch: function () {
- var that = this;
- require(['views/tabs/VisualSearchView'], function (VisualSearchView) {
- var data = _.values(Globals.serviceLogsColumns);
- var columns = _.without(data, _.findWhere(data, "logtime"));
- that.RVisualSearchIncCol.show(new VisualSearchView({
- viewName: "includeServiceColumns",
- placeholder: "Include Search",
- vent: that.vent,
- globalVent: that.globalVent,
- customOptions: columns,
- eventName: Globals.eventName.serviceLogsIncludeColumns,
- myFormatData: function (query, searchCollection) {
- var obj = ViewUtils.replaceColumnNamesWithKeys(searchCollection, Globals.invertedServiceLogMappings, false);
- return {
- includeQuery: JSON.stringify(obj),
- query: query
- }
- }
- }));
- that.RVisualSearchExCol.show(new VisualSearchView({
- viewName: "excludeServiceColumns",
- placeholder: "Exclude Search",
- vent: that.vent,
- globalVent: that.globalVent,
- customOptions: columns,
- eventName: Globals.eventName.serviceLogsExcludeColumns,
- myFormatData: function (query, searchCollection) {
- var obj = ViewUtils.replaceColumnNamesWithKeys(searchCollection, Globals.invertedServiceLogMappings, false);
- return {
- excludeQuery: JSON.stringify(obj),
- query: query
- }
- }
- }));
- });
- },
- renderEventHistory: function () {
- var that = this;
- require(['views/common/EventHistoryLayout'], function (EventHistoryLayoutView) {
- that.REventHistory.show(new EventHistoryLayoutView({
- vent: that.vent,
- globalVent: that.globalVent,
- params: that.defaultParams
- }));
- });
- },
- fetchCollection: function (params) {
- $.extend(this.collection.queryParams, params);
- this.collection.fetch({reset: true});
- },
- onSearchLogClick: function () {
- var value = this.ui.searchBox.val();
- if (_.isEmpty(value)) {
- this.ui.searchBox.val("*:*");
- value = "*:*";
- }
- this.vent.trigger("main:search", {q: value});
- },
- 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({
- dropdownParent: that.$el,
- 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];
- }
- }).off("change").on("change", function (e) {
- var data = that.ui[selectTagId].select2("data").map(function (d) {
- return d.type
- });
- if (selectTagId === "excludeComponents") {
- that.vent.trigger("tree:strike:component", data);
- that.vent.trigger("type:mustNot", {mustNot: data.toString()});
- }
- if (selectTagId === "includeComponents")
- that.vent.trigger("type:mustBe", {mustBe: data.toString()});
- });
- },
- 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', []);
-
- },
- reRenderComponents: function (params) {
- var iComponents = this.ui.includeComponents.val(), eComponents = this.ui.excludeComponents.val(), that = this;
- this.componentsList.fetch({
- reset: true,
- complete: function () {
- that.ui.includeComponents.select2('val', iComponents.split(","));
- that.ui.excludeComponents.select2('val', eComponents.split(","));
- }
- });
- },
- onSearchSwitch: function (e) {
- var obj = {};
- if (e.target.checked) {
- this.ui.advanceSearch.show();
- this.ui.applySearch.show();
- this.ui.basicSearch.hide();
- obj.advanceSearch = this.RAdvanceSearch.currentView.ui.searchArea.val();
- obj.includeQuery = null;
- obj.excludeQuery = null;
- } else {
- this.ui.advanceSearch.hide();
- this.ui.applySearch.hide();
- this.ui.basicSearch.show();
- obj = this.getIncludeExcludeColValues();
- obj.advanceSearch = null;
- }
-
- this.vent.trigger('main:search', obj);
-
- },
- applySearchBtn: function () {
- var obj = {};
- obj.advanceSearch = this.RAdvanceSearch.currentView.ui.searchArea.val();
-
- this.vent.trigger('main:search', obj);
-
- },
- getIncludeExcludeColValues: function () {
- return _.extend(this.RVisualSearchIncCol.currentView.formatData(this.RVisualSearchIncCol.currentView.visualSearch.searchBox.value(), this.RVisualSearchIncCol.currentView.visualSearch.searchQuery),
- this.RVisualSearchExCol.currentView.formatData(this.RVisualSearchExCol.currentView.visualSearch.searchBox.value(), this.RVisualSearchExCol.currentView.visualSearch.searchQuery));
- },
- toggleSearchBackToBasicSearch: function (options) {
- if (!this.ui.advanceSearch.is(":hidden")) {
- this.ui.advanceSearch.hide();
- this.ui.basicSearch.show();
- this.ui.toggleTableAccessLog[0].checked = false;
- _.extend(options, this.getIncludeExcludeColValues(), {advanceSearch: null});
- }
- }
- });
-
-
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/HostInfoTabLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/HostInfoTabLayoutView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/HostInfoTabLayoutView.js
deleted file mode 100644
index 7be5f14..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/tabs/HostInfoTabLayoutView.js
+++ /dev/null
@@ -1,178 +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',
- 'moment',
- 'models/VGraphInfo',
- 'hbs!tmpl/tabs/HostInfoTabLayoutView_tmpl'
-],function(require,Backbone,Globals,Utils,moment,VGraphInfo,HostInfoTabLayoutViewTmpl){
- 'use strict';
-
- return Backbone.Marionette.Layout.extend(
- /** @lends HostInfoTabLayoutView */
- {
- _viewName : 'HostInfoTabLayoutView',
-
- template: HostInfoTabLayoutViewTmpl,
-
- /** Layout sub regions */
- regions: {
-
- },
-
- /** ui selector cache */
- ui: {
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- return events;
- },
-
- /**
- * intialize a new HostInfoTabLayoutView Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options,'globalVent'));
- this.graphModel = new VGraphInfo();
- this.bindEvents();
- },
- bindEvents : function(){
- },
- onRender : function(){
- this.fetchGraphData();
- },
- fetchGraphData : function(){
- var that = this;
- this.graphModel.getCriticalLogsInfo({},{
- dataType:"json",
- success : function(data,textStatus,jqXHR){
- that.graphModel.set(data);
- that.renderGraph();
- },
- error : function(){
- },
- complete : function(){
- that.$("#loaderGraph").hide();
- that.$(".loader").hide();
- }
- });
- },
- renderGraph : function(){
- var that = this;
- var data = [];
- var error = {
- "key": "ERROR",
- "color": "#E81D1D",
- "values" : []
- };
- var fatal = {
- "key": "FATAL",
- "color": "#830A0A",
- "values" : []
- }
- if(this.graphModel.get("errorCount")){
- _.each(this.graphModel.get("errorCount").compName,function(v,i){
- error.values.push({
- label : v,
- value : that.graphModel.get("errorCount").countMsg[i],
- message : that.graphModel.get("errorCount").cricticalMsg[i]
- });
- });
- }
- if(this.graphModel.get("fatalCount")){
- _.each(this.graphModel.get("fatalCount").compName,function(v,i){
- fatal.values.push({
- label : v,
- value : that.graphModel.get("fatalCount").countMsg[i],
- message : that.graphModel.get("fatalCount").cricticalMsg[i]
-
- });
- });
- }
- data.push(error);
- data.push(fatal);
- var parentWidth = (that.$('svg').parent().width()),
- parentHeight = (that.$('svg').parent().height()),
- width = ((parentWidth === 0) ? (293) : (parentWidth)), // -15 because parent has 15 padding
- height = ((parentHeight === 0) ? (150) : (parentHeight)) // -15 because parent has 15 padding
- nv.addGraph(function() {
- var chart = nv.models.multiBarHorizontalChart()
- .width(width)
- .height(height)
- .x(function(d) { return d.label })
- .y(function(d) { return d.value })
- .margin({top: 15, right: 10, bottom: 25, left: 80})
- .showValues(false)
- //.tooltips(false)
- .showControls(false)
- .showLegend(false);
-
- chart.yAxis
- .tickFormat(d3.format(',.2f'));
- chart.tooltip.contentGenerator(
- function(data) {
- var tootTipTemplate = '<div>' +
- '<table>' +
- '<thead>' +
- '<tr>' +
- '<td colspan="3"><strong class="x-value">' + data.value + '</strong></td>' +
- '</tr>' +
- '<tr>' +
- //'<td colspan="3"><small class="x-value" style="font-size:5px">' + data.data.message + '</small></td>' +
- '</tr>' +
- '</thead>' +
- '<tbody>' +
- '<tr>' +
- '<td class="legend-color-guide">' +
- '<div style="background-color: ' + data.color + '"></div>' +
- '</td>' +
- '<td class="key">' + data.data.key + '</td>' +
- '<td class="value">' + data.data.value + '</td>' +
- '</tr>' +
- '</tbody>' +
- '</table>' +
- '</div>'
-
- return tootTipTemplate
- })
- chart.tooltip.enabled();
- chart.dispatch.on('renderEnd', function() {
- d3.selectAll("#hostCriticalGraph g .nv-bar").on("click",function(d){
- Utils.alertPopup({msg : "<pre>"+d.message+"</pre>"});
- })
- });
- d3.select('#hostCriticalGraph svg')
- .datum(data)
- .transition().duration(500)
- .call(chart);
-
- return chart;
- });
- }
-
-
-
- });
-
-});
-
\ No newline at end of file