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:40 UTC
[10/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/common/Header.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Header.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Header.js
deleted file mode 100644
index 3cdca56..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Header.js
+++ /dev/null
@@ -1,481 +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',
- 'handlebars',
- 'hbs!tmpl/common/Header_tmpl',
- 'utils/Utils',
- 'moment',
- 'utils/Globals',
-], function(require, Backbone, Handlebars, Header_tmpl, Utils, moment, Globals) {
- 'use strict';
-
- var Header = Backbone.Marionette.Layout.extend(
- /** @lends Header */
- {
- _viewName: 'Header',
-
- template: Header_tmpl,
-
-
- /** ui selector cache */
- ui: {
- 'takeATour': "[data-id='takeATour']",
- 'globalFilter': "li[data-id='exclusionList']",
- 'globalNotification': '.dropdown .excludeStatus',
- 'timeZoneChange': "li[data-id='timeZoneChange']",
- 'createFilters' : "[data-id='createFilters']",
- 'editParams' : "a[data-id='editParams']"
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- events['click ' + this.ui.takeATour] = 'takeATour';
- events['click ' + this.ui.globalFilter] = 'exclusionListClick';
- events['click ' + this.ui.timeZoneChange] = 'timeZoneChangeClick';
- events['click ' + this.ui.createFilters] = 'createFiltersClick';
- events['click ' + this.ui.editParams] = 'editParamsClick';
- return events;
- },
-
- /**
- * intialize a new Header Layout
- * @constructs
- */
- initialize: function(options) {
-
- _.extend(this, _.pick(options, 'collection', 'globalVent'));
- this.collection = new Backbone.Collection();
- this.bottomToTop();
- this.topToBottom();
- this.exclusionObj = {
- logMessageCollection: this.collection,
- components: []
- }
-
- this.bindEvents();
- },
-
- /** all events binding here */
- bindEvents: function() {
- this.listenTo(this.globalVent,"currentMap:load",function(obj){
- this.currentTimezone = obj;
- },this);
- },
- /** on render callback */
- onRender: function() {
- this.loadTimeZone();
- this.setNotificationCount(this.exclusionObj.components, this.collection.length);
- var storeTimezone = Utils.localStorage.checkLocalStorage('timezone');
- var zoneName = moment.tz(storeTimezone.value.split(',')[0]).zoneName();
-
- if (storeTimezone.value.split(',').length) {
- if (storeTimezone.value.split(',')[1]) {
- if (storeTimezone.value.split(',')[1] != zoneName) {
- Utils.localStorage.setLocalStorage('timezone', storeTimezone.value.split(',')[0] + "," + zoneName);
- }
- }
- this.ui.timeZoneChange.find('span').text(moment.tz(storeTimezone.value.split(',')[0]).zoneName());
- }
- this.currentTimezone = storeTimezone;
- this.checkParams();
- },
- onShow : function(){
- this.triggerAutoTourCheck();
- },
- loadTimeZone: function() {
-
-
- },
- checkParams : function(){
- if(window.location.search){
- var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
- if(url.length === 1){
- var bundleIdCheck = url[0].split('=');
- (bundleIdCheck[0] ==='bundle_id') ? this.ui.editParams.hide() : this.ui.editParams.show();
- }else{
- this.ui.editParams.show();
- }
- }
- },
- editParamsClick: function() {
- var that = this;
- var newUrl = '',
- hash,
- str = '<ul>';
- var oldUrl = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
- for (var i = 0; i < oldUrl.length; i++) {
-
- hash = oldUrl[i].split('=');
- if (hash[0] === "bundle_id") {
- if(_.isEmpty(hash[1])){
- hash[1] = '';
- }
- newUrl = hash[0] + "=" + hash[1];
- }else{
- str += '<li>' + hash[0] + " : " + hash[1] + '</li>';
- }
- }
- str += '</ul>';
-
- Utils.bootboxCustomDialogs({
- 'title': ' Are you sure you want to remove these params ?',
- 'msg': str,
- 'callback': function() {
- var editUrl = window.location.href.substring(0, window.location.href.indexOf('?'));
- var params = (newUrl.length > 0) ? window.location.search = '?' + newUrl : window.location.search = '';
- window.location.href = editUrl + params;
- that.ui.editParams.hide();
- }
- });
- },
- takeATour: function() {
- require(['utils/Tour'],function(Tour){
- Tour.Start();
- });
-
- /*localStorage.clear();
- if (typeof(Storage) !== "undefined") {
- if (!localStorage.getItem("startIntro")) {
- localStorage.setItem("startIntro", true);
- //Intro.Start();
- }
- } else {
- // Sorry! No Web Storage support..
- }*/
- },
- createFiltersClick: function(){
- var that = this;
- require(['views/filter/CreateLogfeederFilterView'],function(CreateLogfeederFilter){
- var view = new CreateLogfeederFilter({});
- var options = {
- title: "Log Feeder Log Levels Filter",
- content: view,
- viewType: 'Filter',
- resizable: false,
- width: 1000,
- height: 550,
- autoFocus1stElement : false,
- buttons: [{
- id: "okBtn",
- text: "Save",
- "class": "btn btn-primary defaultBtn",
- click: function() {
- that.onCreateFilterSubmit();
- }
- }, {
- id: "cancelBtn",
- text: "Close",
- "class": "btn btn-default defaultCancelBtn",
- click: function() {
- that.onDialogClosed();
- }
- }]
- };
- that.createFilterDialog(options);
- that.onDialogClosed();
- });
- },// Filter Dialogs
- createFilterDialog : function(options){
- var that = this,
- opts = _.extend({
- appendTo: this.$el,
- modal: true,
- resizable: false,
- width: 650,
- height: 350,
- beforeClose: function(event, ui) {
- //that.onDialogClosed();
- }
- },options);
-
- require(['views/common/JBDialog'], function(JBDialog) {
- var dialog = that.dialog = new JBDialog(opts).render();
- if(options.viewType == "Filter"){
- dialog.on("dialog:open", function(){
- options.content.trigger("toggle:okBtn",false);
- // dialog.trigger("toggle:okBtn",false);
- });
- }
- options.content.on("closeDialog",function(){
- that.onDialogClosed();
- });
- dialog.open();
- });
- },
- onCreateFilterSubmit : function(){
- var content = this.dialog.options.content;
- var that = this;
- content.setValues();
- content.trigger("toggle:okBtn",false);
-
- // this.componentArray = content.ui.componentSelect2.val().split(',');
- //this.hostArray = content.ui.hostSelect2.val().split(',');
- // this.levelArray = content.ui.levelSelect2.val().split(',');
-
- //this.filterList = { /*components : this.componentArray,*/hosts : this.hostArray/*, levels : this.levelArray */}
- content.model.set(content.setValues());
-
- content.model.save(content.model.attributes, {
- url: Globals.baseURL + 'history/filters',
- success : function(model,response){
- Utils.notifySuccess({
- content: "Filter has been saved."
- });
- },
- error : function(model,response){
- Utils.notifyError({
- content: "There is some issues on server, Please try again later."
- });
- },
- complete : function(){
- that.onDialogClosed();
- }
- });
- },
- setupDialog: function(options) {
- var that = this,
- opts = _.extend({
- appendTo: this.$el,
- modal: true,
- resizable: false,
- width: 650,
- height: 450,
- beforeClose: function(event, ui) {
- that.onDialogClosed();
- }
- }, options);
-
- require(['views/common/JBDialog'], function(JBDialog) {
- var dialog = that.dialog = new JBDialog(opts).render();
- if (options.viewType == "timezone") {
- dialog.on("dialog:open", function() {
- that.dialog.options.content.$('#timezone-picker').WorldMapGenerator({
- quickLink: [{
- "PST": "PST",
- "MST": "MST",
- "CST": "CST",
- "EST": "EST",
- "GMT": "GMT",
- "LONDON": "Europe/London",
- "IST": "IST"
- }]
- });
- });
- }
- dialog.open();
- });
- },
- exclusionListClick: function() {
- var that = this;
- require(['views/dialog/GlobalExclusionCompositeView'], function(GlobalExclusionView) {
- var view = new GlobalExclusionView({
- exclusionObj: that.exclusionObj
- });
- var opts = {
- title: "Global Exclusion",
- content: view,
- viewType: 'exclusion',
- resizable: false,
- width: 650,
- height: 450,
- buttons: [{
- id: "okBtn",
- text: "Apply",
- "class": "btn btn-primary",
- click: function() {
- that.onDialogSubmitted();
- }
- }, {
- id: "cancelBtn",
- text: "Close",
- "class": "btn btn-default",
- click: function() {
- that.onDialogClosed();
- }
- }]
- }
- that.setupDialog(opts);
- });
-
- },
- onDialogSubmitted: function() {
- var content = this.dialog.options.content;
- var componentList = [];
- if (content.ui.select2Input.select2("data") != null) {
- componentList = content.ui.select2Input.select2("data").map(function(d) {
- return d.type
- });
- }
-
- this.exclusionObj.components = componentList;
- var logMessagesList = [];
- content.$('div[data-id="L"] textarea').map(function(i, element) {
- if (element.value != "") logMessagesList.push({
- "message": element.value
- })
-
- })
- this.collection.reset(logMessagesList);
-
- var gMessage = logMessagesList.map(function(e) {
- return e.message
- });
- this.setNotificationCount(componentList.length, gMessage.length);
- },
- /** closing the movable/resizable popup */
- onDialogClosed: function() {
- if (this.dialog) {
- this.dialog.close && this.dialog.close();
- this.dialog.remove && this.dialog.remove();
- this.dialog = null;
- }
- },
- timeZoneChangeClick: function() {
- var that = this;
- require(['views/dialog/TimeZoneChangeView'], function(TimeZoneChangeView) {
- var view = new TimeZoneChangeView({currentTime : that.currentTimezone});
- var opts = {
- title: "Time Zone",
- content: view,
- viewType: 'timezone',
- resizable: false,
- width: 650,
- height: 530,
- buttons: [{
- id: "reloadBtn",
- text: "Reload",
- "class": "btn btn-primary defaultBtn",
- click: function() {
- that.onTimeZoneReload();
- }
- }, {
- id: "reloadNewBtn",
- text: "Reload in new tab",
- "class": "btn btn-primary defaultBtn",
- click: function() {
- that.onTimeZoneReloadinNewTab();
- }
- }, {
- id: "cancelBtn",
- text: "Close",
- "class": "btn btn-default defaultCancelBtn",
- click: function() {
- that.onDialogClosed();
- }
- }]
- }
- that.setupDialog(opts);
- });
- },
- onTimeZoneReloadinNewTab: function() {
- var content = this.dialog.options.content;
- this.onDialogClosed();
- if (content.changedTimeZone) {
- var obj = Utils.localStorage.checkLocalStorage('timezone');
- Utils.localStorage.setLocalStorage('timezone', content.selectedtimeZone);
- //this.ui.timeZoneChange.find('span').text(moment.tz(content.selectedtimeZone).zoneName());
- this.globalVent.trigger("currentMap:load",obj);
- window.open(window.location.href);
-
- }
- },
- onTimeZoneReload: function() {
- var content = this.dialog.options.content;
- if (content.changedTimeZone) {
- Utils.localStorage.setLocalStorage('timezone', content.selectedtimeZone);
- //this.ui.timeZoneChange.find('span').text(moment.tz(content.selectedtimeZone).zoneName());
- window.location.reload();
-
- } else {
- this.onDialogClosed();
- }
- },
- setNotificationCount: function(componentList, gMessage) {
- if (componentList > 0 || gMessage > 0) {
- this.ui.globalNotification.addClass('full')
- } else {
- this.ui.globalNotification.removeClass('full')
- }
-
- },
- /** on close */
- onClose: function() {},
- bottomToTop: function() {
- $(window).scroll(function() {
- var tabSelected = $('[role="tablist"]').find('.active').data()
- /*if (tabSelected.id == "hierarchy") {*/
- if ($(this).scrollTop() >= 53) {
- $('.topLevelFilter').addClass('fixed');
- if ($('.topLevelFilter').find('.fixedSearchBox .select2-container.select2-dropdown-open').length || $('.topLevelFilter').find('.VS-focus').length || $('.topLevelFilter').find('.advanceSearchActive').length) {
- $('.topLevelFilter').find('.fixedSearchBox').removeClass('hiddeBox')
- } else {
- $('.topLevelFilter').find('.fixedSearchBox').addClass('hiddeBox')
- }
- $('.setHeight').css('height', '120px');
- $('.setHeight_LogFile').css('height', '90px');
- } else {
- $('.topLevelFilter').removeClass('fixed');
- $('.setHeight').css('height', '0px');
- $('.setHeight_LogFile').css('height', '0px');
- }
- /* }*/
-
- if ($(this).scrollTop() > 600) {
- $('.arrowDiv').fadeIn();
- } else {
- $('.arrowDiv').fadeOut();
- }
- });
- $('.bottomToTop').click(function() {
- $('html, body').animate({
- scrollTop: 0
- }, 400);
- });
-
- },
- topToBottom: function() {
- $('.topToBottom').click(function() {
- $('html, body').animate({
- scrollTop: $(document).height()
- }, 400);
- });
- },
- triggerAutoTourCheck : function(){
- var that = this;
- var storageVal = Utils.localStorage.checkLocalStorage('autoTour');
- if(! storageVal.found){
- Utils.localStorage.setLocalStorage("autoTour",true);
- setTimeout(function(){
- Utils.confirmPopup({
- 'msg':'Do you want to take a Tour with LogSearch App ?',
- 'callback':that.takeATour
- });
- },3000);
- }
- }
-
-
- });
-
- return Header;
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/JBDialog.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/JBDialog.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/JBDialog.js
deleted file mode 100644
index b047f4a..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/JBDialog.js
+++ /dev/null
@@ -1,211 +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.
-*/
-/**
- * @file jQuery Dialog (movable and resizable popup) wrapper for use with Backbone.
- *
- * Takes care of instantiation, fires and listen to events,
- * adds several options and removes the element from the DOM when closed.
- *
- * @borrows jquery-ui.js
- * @extends Backbone.View
- *
- * @fires dialog:rendered - Fired when the dialog view is rendered
- * @fires dialog:open - Fired when the dialog is instantiated and opened
- * @fires dialog:closing - Fired when the dialog view is about to close (before closing)
- */
-define(['require','backbone'],function(require,Backbone){
- //var App = require('App');
-
- /**
- * Creates instance of JBDialog
- */
- var JBDialog = Backbone.View.extend({
- /** @lends JBDialog */
- className: 'ui-dialog-content ui-widget-content',
-
- tagName: 'div',
-
- initialize: function(customOpts){
- this.options = _.extend({
- // defaults
- appendTo: "body",
- autoOpen: false,
- buttons: [],
- closeOnEscape: false,
- closeText: "close",
- dialogClass: "",
- draggable: true,
- hide: null,
- height: "auto",
- maxHeight: 600,
- maxWidth: 1000,
- minHeight: 300,
- minWidth: 250,
- modal: false,
- position: {
- my: "center",
- at: "center",
- of: window,
- collision: "fit"
- },
- resizable: true,
- show: null,
- title: null,
- width: "auto",
- autoFocus1stElement : true,
- // callbacks
- // beforeClose: null,
- // close: null,
- // drag: null,
- // dragStart: null,
- // dragStop: null,
- // focus: null,
- // open: null,
- // resize: null,
- // resizeStart: null,
- // resizeStop: null
- }, customOpts);
-
- this.customOpts = customOpts;
-
- this.bindButtonEvents();
- },
-
- bindButtonEvents: function(){
- var options = this.options,
- content = options.content;
-
- /*Bind button events on main content, if it's a view*/
- if (content && content.$el) {
- this.listenTo(content, "toggle:okBtn", function(isEnable){
- this.toggleButtonState('okBtn',!!isEnable);
- }, this);
-
- this.listenTo(content, "toggle:cancelBtn", function(isEnable){
- this.toggleButtonState('cancelBtn',!!isEnable);
- }, this);
-
- this.listenTo(content, "toggle:btn", function(isEnable, buttonId){
- this.toggleButtonState(buttonId,!!isEnable);
- }, this);
- }
- },
-
- render: function() {
- var self = this;
- var $el = self.$el,
- options = self.options,
- content = options.content;
-
- /*Create the modal container*/
- if (content && content.$el) {
- /*Insert the main content if it's a view*/
- content.render();
- $el.html(options.content.$el);
- } else {
- $el.html(options.content);
- }
-
- self.isRendered = true;
-
- self.trigger("dialog:rendered");
-
- return self;
- },
-
- /**
- * [initializing and invoking open function on dialog]
- * @return {Object} context
- */
- open: function() {
- var self = this;
- var $el = self.$el;
-
- if (!self.isRendered){
- self.render();
- }
-
- //Create it
- $el.dialog(self.options);
- if (!self.options.autoOpen) {
- $el.dialog("open");
- }
- $('.ui-dialog-titlebar-close').click(function(e){
- self.close();
- });
- if (this.options.autoFocus1stElement)
- $el.find("[autofocus]:first").focus();
-
- self.trigger("dialog:open");
-
- return self;
- },
-
- /**
- * closing the dialog and destroying it from DOM if open
- */
- close: function() {
- var self = this;
- var $el = self.$el;
-
- self.trigger("dialog:closing");
-
- $el.hide();
-
- if (self.options.content) {
- /*Closing Backbone.View*/
- self.options.content.close();
- }
- if($el.dialog("isOpen")){
- $el.dialog("destroy");
- }
- },
-
- /**
- * toggle particular button state
- * @param {String} buttonId - id of the button element
- * @param {Boolean} isEnable - flag to enable/disable
- * @return {Object} context
- */
- toggleButtonState: function(buttonId, isEnable){
- var $selector, self = this;
- if (buttonId) {
- $selector = self.$el.next().find('#'+buttonId);
- self.enableDisableBtn($selector, isEnable);
- }
- return self;
- },
-
- /**
- * enable/disable button
- * @param {Object} selector - jquery dom element
- * @param {Boolean} isEnable - flag to enable/disable
- */
- enableDisableBtn: function(selector, isEnable) {
- if (selector && selector.length) {
- if (isEnable) {
- selector.removeAttr('disabled');
- } else {
- selector.attr('disabled', 'disabled');
- }
- }
- }
-
- });
- return JBDialog;
-});
\ 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/LogSnapShotLayout.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/LogSnapShotLayout.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/LogSnapShotLayout.js
deleted file mode 100644
index 4750592..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/LogSnapShotLayout.js
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-define(['require',
- 'backbone',
- 'utils/Utils',
- 'hbs!tmpl/common/LogSnapShotLayout_tmpl',
- 'moment'
-], function(require, backbone, Utils, LogSnapShotLayoutTmpl, moment) {
- 'use strict';
-
- return Backbone.Marionette.Layout.extend(
- /** @lends LogSnapShotLayout */
- {
- _viewName: 'LogSnapShotLayout',
-
- template: LogSnapShotLayoutTmpl,
-
-
- /** ui selector cache */
- ui: {
- startStop: '[data-id="startStop"]',
- start: '[data-id="start"]',
- stop: '[data-id="stop"]',
- counter: '[data-id="counter"]',
- showAutoTriggerMsg:'[data-id="showAutoTriggerMsg"]'
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- events["click " + this.ui.startStop] = 'onStartStopClick';
- /* events["click " + this.ui.start] = 'onStartClick';
- events["click " + this.ui.stop] = 'onStopClick';*/
- return events;
- },
-
- /**
- * intialize a new LogSnapShotLayout Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options, 'vent', 'globalVent', 'params'));
- this.dateUtil = Utils.dateUtil;
- },
- bindEvents: function() {},
- onRender: function() {
- this.ui.stop.hide();
- this.ui.counter.hide();
- this.ui.counter.text("00:00");
- },
- onStartStopClick: function() {
- if (this.ui.start.is(":hidden")) {
- this.onStopClick();
- } else {
- this.onStartClick();
- }
- },
- onStartClick: function() {
- var that = this;
- this.startDate = this.dateUtil.getMomentObject();
- clearTimeout(that.autoStartTime);
- clearTimeout(this.textAutoRefresh);
- clearTimeout(this.refreshInterval);
- that.ui.showAutoTriggerMsg.hide();
- this.ui.start.hide();
- this.ui.stop.show();
- this.ui.counter.show();
- this.$('.snapShotTitle').hide();
- this.counterValue = new Date(moment().format("MM/DD/YY"));
- this.counter = 1;
- that.ui.counter.text('00:01');
- this.interval = setInterval(function() {
- if (that.counterValue.getSeconds() == 0) {
- that.counter = 1;
- }
- if (that.counterValue.getMinutes() > 59 && that.counterValue.getHours() >= 0) {
- that.onStopClick();
- return;
- }
- that.counterValue.setSeconds(++that.counter);
- that.ui.counter.text(((that.counterValue.getMinutes().toString().length > 1) ?
- (that.counterValue.getMinutes()) : ("0" + that.counterValue.getMinutes())) + ':' +
- ((that.counterValue.getSeconds().toString().length > 1) ?
- (that.counterValue.getSeconds()) : ("0" + that.counterValue.getSeconds())));
- }, 1000);
- },
- onStopClick: function() {
- var that = this;
- Utils.alertPopup({
- msg:"For more accurate results, automatic refresh will be triggered in 30 secs."
- });
- this.refreshSecond = 30;
- this.ui.showAutoTriggerMsg.text("Triggering auto-refresh in" + " " + ('30')).show();
- this.timerStartRefresh();
- this.autoStartTime = setTimeout(function(){
- that.vent.trigger("tab:refresh",that.params);
- that.ui.showAutoTriggerMsg.hide();
- }, 30000);
- this.endDate = this.dateUtil.getMomentObject();
- this.vent.trigger("date:click", {
- 'from': that.startDate,
- 'to': that.endDate,
- dateRangeLabel: "Custom Range",
- });
- this.ui.stop.hide();
- this.ui.start.show();
- this.ui.counter.hide();
- this.$('.snapShotTitle').show();
- this.ui.counter.text("00:00");
- this.counterValue = new Date(moment().format("MM/DD/YY"));
- this.counter = 1;
- clearInterval(this.interval);
- },
- timerStartRefresh: function(){
- var that= this;
- var refreshCounter = new Date(moment().format("MM/DD/YY"));
- refreshCounter.setSeconds(30);
- this.refreshInterval = setInterval(function() {
- var getCounterValue = refreshCounter.getSeconds();
- refreshCounter.setSeconds(--getCounterValue);
- that.ui.showAutoTriggerMsg.text("Triggering auto-refresh in" + " " + refreshCounter.getSeconds());
- }, 1000);
- }
- });
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/ProfileBar.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/ProfileBar.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/ProfileBar.js
deleted file mode 100644
index 0cdef28..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/ProfileBar.js
+++ /dev/null
@@ -1,105 +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',
- 'App',
- 'communicator',
- 'hbs!tmpl/common/ProfileBar_tmpl'
-],function(require,Backbone,App,Communicator,ProfileBar_tmpl){
- 'use strict';
-
- var ProfileBar = Backbone.Marionette.ItemView.extend(
- /** @lends ProfileBar */
- {
- _viewName : ProfileBar,
-
- template: ProfileBar_tmpl,
- templateHelpers : function(){
- return {
- userProfile : this.userProfile
- };
- },
-
- /** ui selector cache */
- ui: {
- logout : 'a[data-id="logout"]'
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- //events['change ' + this.ui.input] = 'onInputChange';
- events['click ' + this.ui.logout] = 'onLogout';
- return events;
- },
- onLogout : function(){
- var url = 'security-admin-web/logout.html';
- $.ajax({
- url : url,
- type : 'GET',
- headers : {
- "cache-control" : "no-cache"
- },
- success : function() {
- window.location.replace('login.html');
- },
- error : function(jqXHR, textStatus, err ) {
- }
-
- });
- },
- /**
- * intialize a new ProfileBar ItemView
- * @constructs
- */
- initialize: function(options) {
- console.log("initialized a ProfileBar ItemView");
-
- _.extend(this, _.pick(options, ''));
-
- this.userProfile = SessionMgr.getUserProfile();
- this.bindEvents();
- },
-
- /** all events binding here */
- bindEvents : function(){
- //this.listenTo(this.userProfile, "change", this.render, this);
- this.listenTo(Communicator.vent,'ProfileBar:rerender', this.render, this);
- },
-
- /** on render callback */
- onRender: function() {
-
- this.initializePlugins();
- },
-
- /** all post render plugin initialization */
- initializePlugins: function(){
- },
-
- /** on close */
- onClose: function(){
- }
-
- });
-
- return ProfileBar;
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Spinner.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Spinner.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Spinner.js
deleted file mode 100644
index 9d3714e..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Spinner.js
+++ /dev/null
@@ -1,85 +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','handlebars','communicator'],function(require,Backbone,Handlebars,Communicator){
- 'use strict';
-
- var Spinner = Backbone.Marionette.Layout.extend(
- /** @lends Spinner */
- {
- _viewName : 'Spinner',
-
- template : Handlebars.compile("<span></span>"),
-
- tagName : 'span',
-
- /** ui selector cache */
- ui: {},
-
- /** ui events hash */
- events: function() {
- var events = {};
- //events['change ' + this.ui.input] = 'onInputChange';
- return events;
- },
-
- /**
- * intialize a new Spinner Layout
- * @constructs
- */
- initialize: function(options) {
- console.log("initialized a Spinner ItemView");
-
- _.extend(this, _.pick(options, 'collection'));
-
- this.bindEvents();
- },
-
- /** all events binding here */
- bindEvents : function(){
- this.listenTo(this.collection, 'request', this.displaySpinner);
- this.listenTo(this.collection, 'sync error', this.removeSpinner);
- },
-
- /** on render callback */
- onRender: function() {
- this.initializePlugins();
- },
-
- /** all post render plugin initialization */
- initializePlugins: function(){
- },
-
- displaySpinner: function () {
- this.$el.empty().append('<i class="icon-spinner icon-spin icon-3x white spin-position"></i>');
- },
-
- removeSpinner: function () {
- this.$el.empty();
- },
-
- /** on close */
- onClose: function(){
- }
-
- });
-
- return Spinner;
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/TableLayout.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/TableLayout.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/TableLayout.js
deleted file mode 100644
index b2f0871..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/TableLayout.js
+++ /dev/null
@@ -1,405 +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.
- */
-/**
- * @file This is the common View file for displaying Table/Grid to be used overall in the application.
- */
-define(['require',
- 'backbone',
- 'hbs!tmpl/common/TableLayout_tmpl',
- 'backgrid-filter',
- 'backgrid-paginator',
- 'backgrid-columnmanager',
- 'backgrid-sizeable',
- 'backgrid-orderable'
-],function(require,Backbone,FSTablelayoutTmpl){
- 'use strict';
-
- var FSTableLayout = Backbone.Marionette.Layout.extend(
- /** @lends FSTableLayout */
- {
- _viewName : 'FSTableLayout',
-
- template: FSTablelayoutTmpl,
-
- /** Layout sub regions */
- regions: {
- 'rTableList' : 'div[data-id="r_tableList"]',
- 'rTableSpinner' : 'div[data-id="r_tableSpinner"]',
- 'rPagination' : 'div[data-id="r_pagination"]',
- 'rFooterRecords': 'div[data-id="r_footerRecords"]'
- },
-
- // /** ui selector cache */
- ui: {
- selectPageSize :'select[data-id="pageSize"]'
- },
-
- gridOpts : {
- className: 'table table-bordered table-hover table-condensed backgrid',
- emptyText : 'No Records found!'
- },
-
- /**
- * Backgrid.Filter default options
- */
- filterOpts : {
- placeholder: 'plcHldr.searchByResourcePath',
- wait: 150
- },
-
- /**
- * Paginator default options
- */
- paginatorOpts : {
- // If you anticipate a large number of pages, you can adjust
- // the number of page handles to show. The sliding window
- // will automatically show the next set of page handles when
- // you click next at the end of a window.
- windowSize: 10, // Default is 10
-
- // Used to multiple windowSize to yield a number of pages to slide,
- // in the case the number is 5
- slideScale: 0.5, // Default is 0.5
-
- // Whether sorting should go back to the first page
- goBackFirstOnSort: false // Default is true
- },
-
- /**
- page handlers for pagination
- */
- controlOpts : {
- rewind: {
- label: "《",
- title: "First"
- },
- back: {
- label: "〈",
- title: "Previous"
- },
- forward: {
- label: "〉",
- title: "Next"
- },
- fastForward: {
- label: "》",
- title: "Last"
- }
- },
- columnOpts : {
- initialColumnsVisible: 4,
- // State settings
- saveState: false,
- loadStateOnInit: true
- },
-
- includePagination : true,
-
- includeFilter : false,
-
- includeHeaderSearch : false,
-
- includePageSize : false,
-
- includeFooterRecords : true,
-
- includeColumnManager : false,
-
- //includeSizeAbleColumns : false,
-
- /** ui events hash */
- events: function() {
- var events = {};
- events['change ' + this.ui.selectPageSize] = 'onPageSizeChange';
- return events;
- },
-
- /**
- * intialize a new HDFSTableLayout Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options, 'collection', 'columns', 'includePagination',
- 'includeHeaderSearch', 'includeFilter', 'includePageSize',
- 'includeFooterRecords','includeColumnManager','includeSizeAbleColumns'));
-
- _.extend(this.gridOpts, options.gridOpts, {collection : this.collection, columns : this.columns});
- _.extend(this.filterOpts, options.filterOpts);
- _.extend(this.paginatorOpts, options.paginatorOpts);
- _.extend(this.controlOpts, options.controlOpts);
- _.extend(this.columnOpts, options.columnOpts);
-
- this.bindEvents();
- },
-
- /** all events binding here */
- bindEvents : function(){
- this.listenTo(this.collection, 'request', function(){
- this.$('div[data-id="r_tableSpinner"]').addClass('loading');
- },this);
- this.listenTo(this.collection, 'sync error', function(){
- this.$('div[data-id="r_tableSpinner"]').removeClass('loading');
- },this);
-
- this.listenTo(this.collection, 'reset', function(collection, response){
- if(this.includePagination) {
- this.renderPagination();
- }
- if(this.includeFooterRecords){
- this.renderFooterRecords(this.collection.state);
- }
- },this);
-
- /*This "sort" trigger event is fired when clicked on
- 'sortable' header cell (backgrid).
- Collection.trigger event was fired because backgrid has
- removeCellDirection function (backgrid.js - line no: 2088)
- which is invoked when "sort" event is triggered
- on collection (backgrid.js - line no: 2081).
- removeCellDirection function - removes "ascending" and "descending"
- which in turn removes chevrons from every 'sortable' header-cells*/
- this.listenTo(this.collection, "backgrid:sort", function(){
- this.collection.trigger("sort");
- });
-
- /*this.listenTo(this.collection, 'remove', function(model, collection, response){
- if (model.isNew() || !this.includePagination) {
- return;
- }
- if (this.collection.state && this.collection.state.totalRecords>0) {
- this.collection.state.totalRecords-=1;
- }
- if (this.collection.length===0 && this.collection.state && this.collection.state.totalRecords>0) {
-
- if (this.collection.state.totalRecords>this.collection.state.currentPage*this.collection.state.pageSize) {
- this.collection.fetch({reset:true});
- } else {
- if (this.collection.state.currentPage>0) {
- this.collection.state.currentPage-=1;
- this.collection.fetch({reset:true});
- }
- }
-
- } else if (this.collection.length===0 && this.collection.state && this.collection.state.totalRecords===0) {
- this.collection.state.currentPage=0;
- this.collection.fetch({reset:true});
- }
- }, this);*/
-
- // It will show tool tip when td has ellipsis Property
- this.listenTo(this.collection, "backgrid:refresh", function(){
- /*this.$('.table td').bind('mouseenter', function() {
- var $this = $(this);
- if (this.offsetWidth < this.scrollWidth && !$this.attr('title')) {
- $this.attr('title', $this.text());
- }
- });*/
- },this);
-
- },
-
- /** on render callback */
- onRender: function() {
- this.renderTable();
- if(this.includePagination) {
- this.renderPagination();
- }
- if(this.includeFilter){
- this.renderFilter();
- }
- if(!this.includePageSize){
- this.ui.selectPageSize.remove();
- }
- if(this.includeFooterRecords){
- this.renderFooterRecords(this.collection.state);
- }
- if(this.includeColumnManager){
- this.renderColumnManager();
- }
-// if(this.includeSizeAbleColumns){
-// this.renderSizeAbleColumns();
-// }
- this.$('[data-id="pageSize"]').val(this.collection.state.pageSize);
-
-
- },
- renderOrder : function(){
- // Setup sortable column collection
-
- var columns = this.columns;
- //columns.setPositions().sort();
-
- // Add sizeable columns
- var sizeAbleCol = new Backgrid.Extension.SizeAbleColumns({
- grid: this.getGridObj(),
- collection: this.collection,
- columns: columns
- });
- this.$('thead').before(sizeAbleCol.render().el);
-
- // Make columns reorderable
- var orderHandler = new Backgrid.Extension.OrderableColumns({
- grid: this.getGridObj(),
- sizeAbleColumns: sizeAbleCol
- });
- this.$('thead').before(orderHandler.render().el);
-
- },
-
- /**
- * show table
- */
- renderTable : function(){
- var that = this;
- this.rTableList.show(new Backgrid.Grid(this.gridOpts));
- },
-
- /**
- * show pagination buttons(first, last, next, prev and numbers)
- */
- renderPagination : function(){
- var options = _.extend({
- collection: this.collection,
- controls: this.controlOpts
- }, this.paginatorOpts);
-
- // TODO - Debug this part
- if(this.rPagination){
- this.rPagination.show(new Backgrid.Extension.Paginator(options));
- }
- else if(this.regions.rPagination){
- this.$('div[data-id="r_pagination"]').show(new Backgrid.Extension.Paginator(options));
- }
- },
-
- /**
- * show/hide pagination buttons of the grid
- */
- showHidePager : function(){
-
- if(!this.includePagination) {
- return;
- }
-
- if(this.collection.state && this.collection.state.totalRecords > this.collection.state.pageSize) {
- this.$('div[data-id="r_pagination"]').show();
- } else {
- this.$('div[data-id="r_pagination"]').hide();
- }
- },
-
- /**
- * show/hide filter of the grid
- */
- renderFilter : function(){
- this.rFilter.show(new Backgrid.Extension.ServerSideFilter({
- collection: this.collection,
- name: ['name'],
- placeholder: 'plcHldr.searchByResourcePath',
- wait: 150
- }));
-
- setTimeout(function(){
- that.$('table').colResizable({liveDrag :true});
- },0);
- },
-
- /**
- * show/hide footer details of the list/collection shown in the grid
- */
- renderFooterRecords : function(collectionState){
- var collState = collectionState;
- var totalRecords = collState.totalRecords || 0;
- var pageStartIndex = totalRecords ? (collState.currentPage*collState.pageSize) : 0;
- var pageEndIndex = pageStartIndex+this.collection.length;
-
- this.$('[data-id="r_footerRecords"]').html('Showing '+(totalRecords ? pageStartIndex+1 : 0)+' to '+pageEndIndex+' of '+totalRecords+' entries');
- return this;
- },
- /**
- * ColumnManager for the table
- */
- renderColumnManager : function(){
- var $el = this.$("[data-id='control']");
- var colManager = new Backgrid.Extension.ColumnManager(this.columns, this.columnOpts);
- // Add control
- var colVisibilityControl = new Backgrid.Extension.ColumnManagerVisibilityControl({
- columnManager: colManager
- });
-
- $el.append(colVisibilityControl.render().el);
- },
-
- /*renderSizeAbleColumns : function(){
- // Add sizeable columns
- var sizeAbleCol = new Backgrid.Extension.SizeAbleColumns({
- collection: this.collection,
- columns: this.columns,
- grid :this.getGridObj()
- });
- this.$('thead').before(sizeAbleCol.render().el);
-
- // Add resize handlers
- var sizeHandler = new Backgrid.Extension.SizeAbleColumnsHandlers({
- sizeAbleColumns: sizeAbleCol,
- grid: this.getGridObj(),
- saveModelWidth: true
- });
- this.$('thead').before(sizeHandler.render().el);
-
- // Listen to resize events
- this.columns.on('resize', function(columnModel, newWidth, oldWidth) {
- console.log('Resize event on column; name, model, new and old width: ', columnModel.get("name"), columnModel, newWidth, oldWidth);
- });
- },/*
-
- /** on close */
- onClose: function(){
- },
-
- /**
- * get the Backgrid object
- * @return {null}
- */
- getGridObj : function(){
- if (this.rTableList.currentView){
- return this.rTableList.currentView;
- }
- return null;
- },
-
- /**
- * handle change event on page size select box
- * @param {Object} e event
- */
- onPageSizeChange : function(e){
- var pagesize = $(e.currentTarget).val();
- this.collection.state.pageSize = parseInt(pagesize,10);
-
- this.collection.state.currentPage = this.collection.state.firstPage;
- delete this.collection.queryParams.lastPage;
- this.collection.fetch({
- sort: false,
- reset: true,
- cache: false
- });
- }
- });
-
- return FSTableLayout;
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/TimerView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/TimerView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/TimerView.js
deleted file mode 100644
index 01dcf92..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/TimerView.js
+++ /dev/null
@@ -1,126 +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','hbs!tmpl/common/TimerView_tmpl'],function(require,Backbone,TimerViewTmpl){
- 'use strict';
-
- var TimerView = Backbone.Marionette.ItemView.extend(
- /** @lends TimerView */
- {
- _viewName : "TimerView",
-
- template: TimerViewTmpl,
- /** ui selector cache */
- ui: {
- container : "#container",
- timerBtn : "[data-id='timerBtn']"
- },
- //tagName : "span",
- className : "timer",
- /** ui events hash */
- events: function() {
- var events = {};
- //events['change ' + this.ui.input] = 'onInputChange';
- events['click ' + this.ui.timerBtn] = 'onTimerBtnClick';
- return events;
- },
-
- /**
- * intialize a new TimerView ItemView
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options, 'vent', 'globalVent'));
- this.bindEvents();
- },
-
- /** all events binding here */
- bindEvents : function(){
- /*this.listenTo(this.model, "change:foo", this.modelChanged, this);*/
- this.listenTo(this.vent,'start:timer', this.startTimer, this);
- },
-
- /** on render callback */
- onRender: function() {
- //this.startTimer();
- },
- onTimerBtnClick : function(e){
- var $el = $(e.currentTarget).find("i");
- if($el.hasClass("fa-play")){
- $el.removeClass().addClass("fa fa-stop").attr("title","Stop auto-refresh");
- this.startTimer();
- }else{
- $el.removeClass().addClass("fa fa-play").attr("title","Start auto-refresh");;
- this.clearTimerInterval();
- }
- },
- startTimer : function(){
-// var today = new Date(),that=this;
-// today.setHours(0, 0, 10, 0);
-// var startTime = function(){
-// var h = today.getHours();
-// var m = today.getMinutes();
-// today.setSeconds(today.getSeconds() - 1);
-// var s = today.getSeconds();
-// m = that.checkTime(m);
-// s = that.checkTime(s);
-// that.ui.container.text(m + ":" + s);
-// var t = setTimeout(startTime, 1000);
-// }
-// startTime();
- var time = 10,that=this;
- var initialOffset = '56';
- var i = 1;
- clearInterval(that.timerInterval);
- this.$('h6').show();
- this.timerInterval = setInterval(function() {
- that.$('.circle_animation').css('stroke-dashoffset', initialOffset-(i*(initialOffset/time)));
- that.$('h6').text(i);
- if (i == time) {
- clearInterval(that.timerInterval);
- setTimeout(function(){
- if(! that.isTimerManuallyStopped()){
- that.timerCallBack();
- }
- },1000);
- }
- i++;
- }, 1000);
- },
- timerCallBack : function(){
- this.vent.trigger("timer:end");
- //this.startTimer();
- },
- clearTimerInterval : function(){
- this.$('h6').text(0).hide();
- this.$('.circle_animation').css('stroke-dashoffset', "56.2px");
- clearInterval(this.timerInterval);
- },
- isTimerManuallyStopped : function(){
- return this.ui.timerBtn.find('i').hasClass("fa-play");
- },
- /** on close */
- onClose: function(){
- }
-
- });
-
- return TimerView;
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/TopNav.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/TopNav.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/TopNav.js
deleted file mode 100644
index d126185..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/TopNav.js
+++ /dev/null
@@ -1,93 +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','hbs!tmpl/common/TopNav_tmpl','jquery.cookie'],function(require,Backbone,TopNav_tmpl){
- 'use strict';
-
- var TopNav = Backbone.Marionette.ItemView.extend(
- /** @lends TopNav */
- {
- _viewName : TopNav,
-
- template: TopNav_tmpl,
- templateHelpers : function(){
-
- },
-
- /** ui selector cache */
- ui: {},
-
- /** ui events hash */
- events: function() {
- var events = {};
- //events['change ' + this.ui.input] = 'onInputChange';
- events['click li'] = 'onNavMenuClick';
- return events;
- },
-
- /**
- * intialize a new TopNav ItemView
- * @constructs
- */
- initialize: function(options) {
- console.log("initialized a TopNav ItemView");
- _.extend(this, _.pick(options, ''));
- this.bindEvents();
- this.appState = options.appState;
- this.appState.on('change:currentTab', this.highlightNav,this);
- },
-
- /** 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() {
- var that = this;
- this.initializePlugins();
- $('.page-logo').on('click',function(){
- that.$('ul li').removeClass('active');
- that.$('ul li:first').addClass('active');
- });
- $.cookie('clientTimeOffset', new Date().getTimezoneOffset());
- },
-
- /** all post render plugin initialization */
- initializePlugins: function(){
- },
- onNavMenuClick : function(e){
- var ele = $(e.currentTarget);
- this.$('ul li').removeClass('active');
- ele.addClass('active');
- },
- highlightNav : function(e){
- this.$('ul li').removeClass('active');
- this.$('#nav' + this.appState.get('currentTab')).parent().addClass('active');
- },
- /** on close */
- onClose: function(){
- }
-
- });
-
- return TopNav;
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/02360dd5/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/BubbleGraphTableLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/BubbleGraphTableLayoutView.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/BubbleGraphTableLayoutView.js
deleted file mode 100644
index e144ae9..0000000
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/dashboard/BubbleGraphTableLayoutView.js
+++ /dev/null
@@ -1,716 +0,0 @@
-/**
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-define(['require',
- 'backbone',
- 'moment',
- 'utils/Globals',
- 'utils/Utils',
- 'utils/ViewUtils',
- 'd3.tip',
- 'collections/VLogLevelList',
- 'collections/VLogList',
- 'models/VGraphInfo',
- 'hbs!tmpl/dashboard/BubbleGraphTableLayoutView_tmpl',
- 'views/common/JBDialog',
- 'select2'
-],function(require,Backbone,moment,Globals,Utils,ViewUtils,tip,VLogLevel,VLogList,VGraphInfo,BubbleGraphTableLayoutViewTmpl,JBDialog){
- 'use strict';
-
- return Backbone.Marionette.Layout.extend(
- /** @lends BubbleGraphTableLayoutView */
- {
- _viewName : 'BubbleGraphTableLayoutView',
-
- template: BubbleGraphTableLayoutViewTmpl,
-
- /** Layout sub regions */
- regions: {
- RLogTable : "#rLogTable",
- RComponentList : "#componentList",
- RHostList : "#hostList",
- RTimer : "[data-id='timer']"
- },
-
- /** ui selector cache */
- ui: {
- graph : "#graphAgg",
- viewType: "input[name='viewType']",
- hostList : "#hostList",
- componentList : "#componentList"
- },
-
- /** ui events hash */
- events: function() {
- var events = {};
- events['click [data-id="refresh-tab"]'] = 'onTabRefresh';
- events['change ' + this.ui.viewType] = 'onViewTypeChange';
- events['click .quickMenu li'] = 'onQuickMenuClick';
- return events;
- },
-
- /**
- * intialize a new LogLevelView Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options,'vent','globalVent','params','quickHelp','columns'));
- (_.isUndefined(this.quickHelp)) ? this.quickHelp = false : "";
- this.collection = new VLogList([], {
- state: {
- firstPage: 0,
- pageSize: 25
- }
- });
- this.collection.url = Globals.baseURL + "service/logs";
- this.graphModel = new VGraphInfo();
- this.bindEvents();
- this.graphParams = this.params;
-
- },
- bindEvents : function(){
- this.listenTo(this.collection,"reset",function(collection){
- //this.populateDetails();
- },this);
- this.listenTo(this.collection, "backgrid:refresh",function(){
- $(".contextMenuBody [data-id='F']").show();
- $(".contextMenuBody").hide();
- this.$(".loader").hide();
- },this);
- this.listenTo(this.collection, 'request', function(){
- this.$("#loader").show();
- },this);
- this.listenTo(this.collection, 'sync error', function(){
- this.$("#loader").hide();
- },this);
- this.listenTo(this.vent,"main:search tree:search level:filter type:mustNot type:mustBe logtime:filter search:include:exclude " +
- Globals.eventName.serviceLogsIncludeColumns+" "+Globals.eventName.serviceLogsExcludeColumns,function(value){
- this.fetchAllTogether(value);
- this.selectionText="";
- });
-// });
- this.listenTo(this.vent,"reinitialize:filter:bubbleTable",function(value){
- this.reinitializeBubbleTableFilter(value);
- });
- this.listenTo(this.globalVent, "globalExclusion:component:message", function(value) {
- this.fetchAllTogether(value);
- }, this);
- this.listenTo(this.vent, "timer:end", function(value) {
- ViewUtils.setLatestTimeParams(this.params);
- this.vent.trigger("tab:refresh",this.params);
- var that = this;
- this.fetchTableCollection(this.params,{
- complete : function(){
- that.vent.trigger("start:timer");
- }
- });
- }, this);
- this.listenTo(this.vent, "tab:refresh", function(value) {
- this.fetchTableCollection(value);
- },this);
- },
- fetchAllTogether : function(value){
- //this.$("#loaderGraph").show();
- this.fetchTableData(value);
- _.extend(this.graphParams,value);
- //this.fetchGraphData(this.graphParams);
- },
- onRender : function(){
- var that = this;
- this.fetchTableData((this.params) ? this.params : {q:"*:*"});
- this.renderComponentList();
- this.renderTable();
- this.renderHostList();
- this.renderTimer();
- if(this.quickHelp){
- this.initializeContextMenu();
- this.bindContextMenuClick();
- }
- },
- onShow : function(){
- //this.fetchGraphData((this.params) ? this.params : {q:"*:*"});
- },
- onTabRefresh : function(){
- ViewUtils.setLatestTimeParams(this.params);
- this.vent.trigger("tab:refresh",this.params);
- },
- onNewTabIconClick : function($el){
- var host,component,id,that=this;
- if($el.data("host") && $el.data("node")){
- host = $el.data("host");
- component = $el.data("node");
- id = $el.data("id");
- that.globalVent.trigger("render:tab",{
- params:_.extend({},{
- host_name : host,
- component_name : component,
- sourceLogId: id
- },that.graphParams,{hostList:null}),
- globalVent : that.globalVent
- });
- }
- },
- renderTable : function(){
- var that = this;
- var cols = new Backgrid.Columns(this.getColumns());
- require(['views/common/TableLayout','views/common/CustomBackgrid'],function(TableLayout,CustomBackgrid){
- var IdRow = Backgrid.Row.extend({
- render: function() {
- IdRow.__super__.render.apply(this, arguments);
- if (this.model.has("id")) {
- this.$el.attr("data-id", this.model.get('id'));
- }
- return this;
- }
- });
- that.RLogTable.show(new TableLayout({
- columns: cols,
- collection: that.collection,
- includeFilter : false,
- includePagination : true,
- includePageSize : true,
- includeFooterRecords : true,
- includeColumnManager : true,
- columnOpts : {
- initialColumnsVisible: 3,
- saveState : false
- },
- gridOpts : {
- header : CustomBackgrid,
- row: IdRow,
- emptyText : 'No records found!',
- className: 'table table-bordered table-hover table-condensed backgrid table-quickMenu'
- },
- filterOpts : {},
- paginatorOpts : {}
- }));
- });
- },
- renderComponentList : function(){
- var that = this;
- require(['views/dashboard/ComponentListView'],function(ComponentListView){
- that.RComponentList.show(new ComponentListView({
- vent : that.vent,
- globalVent : that.globalVent,
- params : that.params
- }));
- })
- },
- renderHostList : function(){
- var that = this;
- require(['views/dashboard/HostListView'],function(HostListView){
- that.RHostList.show(new HostListView({
- vent : that.vent,
- globalVent : that.globalVent,
- params : that.params
- }));
- })
- },
- renderTimer : function(){
- var that = this;
- require(['views/common/TimerView'],function(TimerView){
- that.RTimer.show(new TimerView({
- vent : that.vent,
- globalVent : that.globalVent
- }));
- });
- },
- getColumns : function(){
- var timeZone = moment().zoneAbbr(),
- cols = {},
- that = this;
- var columns = {
- logtime : {
- name: "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 += "<div style='position:relative'><p style='margin-left:20px'>"+moment(rawValue).format("YYYY-MM-DD HH:mm:ss,SSS")+"</p>";
- if(model.get("type"))
- str += "<p style='margin-left:20px'>"+(model.get("level") ? "<label class='label label-"+model.get("level")+"'>"+model.get("level")+"</label>" : "")+
- "<strong>"+model.get("type")+"</strong>" +
- "</p>";
- str += '<div class="dropdown quickMenu">' +
- '<a class="btn btn-success btn-xs btn-quickMenu" data-toggle="dropdown">' +
- '<i class="fa fa-ellipsis-v"></i></span></a>' +
- '<ul class="dropdown-menu dropupright">' +
- '<li data-id="A_B"><a href="javascript:void(0)">Preview</a></li>' +
- "<li data-id='N_T'><a title='Open logs in new tab' data-type='C' data-host='"+model.get("host")+"' data-node='"+model.get("type")+"' data-id='"+model.get("id")+"' href='javascript:void(0)' class=''>Go To Log</a></li>" +
- "<li data-id='C_M'><a title='Add to compare' data-type='C' data-host='"+model.get("host")+"' data-node='"+model.get("type")+"' data-id='"+model.get("id")+"' href='javascript:void(0)' class=''>Add to Compare</a></li>" +
- '</ul>' +
- '</div></div>';
- return str;
- }
- })
- },
- log_message : {
- name: "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>" : "";
- }
- })
- },
- host : {
- label: "Host",
- cell: "String",
- editable: false,
- sortType: 'toggle',
- sortable : false,
- orderable : true,
- displayOrder :5,
- width : 10
- },
- 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
- }
-
- };
- _.each(this.columns, function(value){
- var name = Globals.invertedServiceLogMappings[value];
- if (columns[name] === undefined) {
- var columnObj = {
- name: Globals.invertedServiceLogMappings[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);
- },
- fetchTableData : function(params){
- var that = this;
- $.extend(this.collection.queryParams,params);
- this.collection.getFirstPage({
- reset:true,
- beforeSend : function(){
- that.$("#loaderGraph").show();
- that.$(".loader").show();
- },
- complete : function(){
- that.$("#loaderGraph").hide();
- that.$(".loader").hide();
- }
- });
- },
- fetchTableCollection : function(queryParams, param){
- var that = this;
- $.extend(this.collection.queryParams,queryParams);
- this.collection.fetch(_.extend({
- reset:true,
- beforeSend : function(){
- that.$("#loaderGraph").show();
- that.$(".loader").show();
- },
- complete : function(){
- that.$("#loaderGraph").hide();
- that.$(".loader").hide();
- }
- },param));
- },
- fetchGraphData : function(params){
- var that = this;
- that.$(".loader").show();
- this.graphModel.fetch({
- dataType:"json",
- data : params,
- success : function(data,textStatus,jqXHR){
- that.renderGraph();
- },
- error : function(){
- },
- complete : function(){
- that.$(".loader").hide();
- }
- });
- },
- reinitializeBubbleTableFilter : function(values){
- this.fetchTableData(values);
- //this.fetchGraphData(values);
- },
- onViewTypeChange: function(e){
- var that = this;
- var val = that.$("[name='viewType']:checked").val();
- this.toggleViewType(val);
- },
- toggleViewType : function(val){
- this.$("[data-id='table']").hide();
- this.ui.graph.hide();
- this.ui.hostList.hide();
- this.ui.componentList.hide();
- this.$(".alert").hide();
- if(val === "G"){
- this.ui.graph.show();
- this.$(".alert").show();
- }else if(val === "T"){
- this.$(".alert").hide();
- this.$("[data-id='table']").show();
- }else if(val === "H"){
- this.ui.hostList.show();
- }else
- this.ui.componentList.show();
-
- },
- bindContextMenuClick : function(){
- var that = this;
- $("body").on("click",".contextMenuBody li a",function(e){
- that.onDropDownMenuClick(e);
- });
- },
- initializeContextMenu : function(){
- var that = this;
- $('body').on("mouseup.contextMenu",function(e){
- var selection;
- if (window.getSelection) {
- selection = window.getSelection();
- } else if (document.selection) {
- selection = document.selection.createRange();
- }
- if(_.isEmpty(selection.toString()) && ($(".contextMenuBody").is(":hidden")) ){
- that.selectionText ="";
- }
- });
- this.$el.on('mouseup contextmenu', ".logMessage", function(e){
- var selection;
- e.stopPropagation();
-
- var range = window.getSelection().getRangeAt(0);
- var selectionContents = range.cloneContents();
- selection = selectionContents.textContent;
-
- setTimeout(function(){
- that.selectionCallBack(selection,e)
- },1);
-
-
- });
- },
- selectionCallBack : function(selection,e){
- this.RLogTable.currentView.$el.removeHighlight(true);
- if(this.selectionText != selection.toString()){
- this.selectionText = selection.toString();
- }else{
- $(".contextMenuBody [data-id='F']").show();
- $(".contextMenuBody").hide();
- return;
- }
- if(selection.toString() && selection && (! _.isEmpty(selection.toString().trim())) ){
- this.RLogTable.currentView.$el.find(".logMessage").highlight(selection.toString().trim(),true,e.currentTarget);
- $(".contextMenuBody [data-id='F']").hide();
- $(".contextMenuBody").show();
- $(".contextMenuBody").css({
- 'top':e.pageY - 40,
- 'left':e.pageX
- });
- }else{
- this.RLogTable.currentView.$el.removeHighlight(true);
- $(".contextMenuBody [data-id='F']").show();
- $(".contextMenuBody").hide();
- }
- },
- onDropDownMenuClick : function(e){
- var $el = $(e.currentTarget),type=$el.data("id");
- if(! _.isEmpty(this.selectionText)){
- if(type === "I" || type === "E"){
- this.vent.trigger("toggle:facet",{viewName:((type === "I") ? "include" : "exclude") +"ServiceColumns",
- key:Globals.serviceLogsColumns["log_message"],value:this.selectionText});
- }else if(type === "IA" || type === "EA"){
- this.vent.trigger("toggle:facet",{viewName:((type === "IA") ? "include" : "exclude") +"ServiceColumns",
- key:Globals.serviceLogsColumns["log_message"],value:"*"+this.selectionText+"*"});
- }
- $(".contextMenuBody [data-id='F']").show();
- $(".contextMenuBody").hide();
- }else{
- $(".contextMenuBody").hide();
- }
- },
- onQuickMenuClick : function(e){
- var that = this,$el = $(e.currentTarget);
- if($el.data("id") === "A_B"){
- var model = this.collection.get($el.parents("tr").data("id"));
- require(["views/dialog/DetailLogFileView"],function(view){
- that.renderDetailLogFileView(new view({
- model : model,
- collection : that.collection
- }));
- });
- }else if ($el.data("id") === "N_T"){
- this.onNewTabIconClick($el.find('a'));
- }else if ($el.data("id") === "C_M"){
- this.globalVent.trigger("add:compare",$el.find('a'));
- }
-
- },
- renderDetailLogFileView : function(view){
- var that = this;
- var opts = {
- title: view.model.get("host")+" -> "+view.model.get("type"),
- className : "ui-dialog-content ui-widget-content logFile",
- content: view,
- viewType: 'logfile',
- resizable: false,
- appendTo: "body",
- modal: true,
- width: 950,
- height: 572,
- buttons: [{
- id: "cancelBtn",
- text: "Close",
- "class": "btn btn-default",
- click: function() {
- that.onDialogClosed();
- }
- }]
- };
- var dialog = that.dialog = new JBDialog(opts).render();
- dialog.open();
- dialog.on("dialog:closing",function(){
- $('body').css('overflow', 'auto');
- })
- $('body').css('overflow', 'hidden');
- },
- onDialogClosed: function() {
- if (this.dialog) {
- this.dialog.close && this.dialog.close();
- this.dialog.remove && this.dialog.remove();
- this.dialog = null;
- }
- },
- renderGraph : function() {
- var that =this,diameter;
- if(this.diameter)
- diameter = this.diameter;
- else
- diameter =this.diameter = this.ui.graph.width() === 0 ? 935 : this.ui.graph.width(); /*880;*///this.ui.graph.width();//960;
- if(! (_.isArray(this.graphModel.get("graphData")) && this.graphModel.get("graphData").length > 0)){
- this.ui.graph.text("no data");
- return
- }
-
- var root = {
- name : "",
- dataList : this.graphModel.get("graphData")
- };
-
- var margin = 20;
- this.ui.graph.empty();
- // var color = d3.scale.linear()
- // .domain([-1, 5])
- // .range(["hsl(152,90%,90%)", "hsl(228,30%,40%)"])
- // .interpolate(d3.interpolateHcl);
- var color = d3.scale.ordinal().domain([ 0, 1 ])
- //.range(["#ECFCBD","#ECFCBD","#ECE78F","#f4f4c8"]);
- .range([ "#dddddd", "#cccccc", "#F5F5F5" ]);
- var pack = d3.layout.pack().padding(2).size(
- [ diameter - margin, diameter - margin ]).value(
- function(d) {
- return d.count;
- }).children(function(d) {
- return d.dataList;
- })
-
- var svg = d3.select(this.ui.graph[0]).append("svg")
- .attr("width",diameter)
- .attr("height", diameter)
- .attr("class", "bubbleGraph")
- .append("g")
- .attr("transform","translate(" + diameter / 2 + "," + diameter / 2 + ")");
-
- //d3.json("flare.json", function(error, root) {
-
- var focus = root, nodes = pack.nodes(root), view;
- /*
- * Tip
- */
- var tipCirclePack = tip().attr('class', 'd3-tip')
- .offset([ -10, 0 ]).html(function(d) {
- var tempName = "<div>";
- if (d.parent) {
- if (d.depth > 1)
- tempName += (d.parent.name.split(".")[0]) + " => ";
- tempName += d.name;
- }
- return tempName + "</div>";
- })
- svg.call(tipCirclePack);
- var circle = svg.selectAll("circle").data(nodes).enter().append(
- "circle").attr(
- "class",
- function(d) {
- return d.parent ? d.children ? "node"
- : "node node--leaf " + d.name
- : "node node--root";
- }).style("fill", function(d) {
- return d.children ? color(d.depth) : null;
- }).on("click", function(d) {
- if (d3.event.shiftKey && d.depth == 2) {
- that.globalVent.trigger("render:tab",/*new LogFileView(*/{
- params : _.extend({
- host_name : d.parent.name,
- component_name : d.name,
-// level : that.collection.queryParams.level,
-// iMessage : that.collection.queryParams.iMessage,
-// eMessage : that.collection.queryParams.eMessage,
-// query : that.collection.queryParams.query
- },that.collection.queryParams,{hostList:null}),
- globalVent : that.globalVent
- }/*)*/);
- } else {
- if (focus !== d)
- zoom(d), d3.event.stopPropagation();
- }
-
- }).on('mouseover', function(d, i) {
- if (d.x) {
- tipCirclePack.show(d);
- }
- }).on('mouseout', function(d, i) {
- if (d.x) {
- tipCirclePack.hide(d);
- }
- });
-
- var text = svg.selectAll("text").data(nodes).enter().append("text")
- .attr("class", "label").style("fill-opacity", function(d) {
- return d.parent === root ? 1 : 0;
- }).style("display", function(d) {
- return d.parent === root ? null : "none";
- }).text(function(d) {
- if (d.count) {
- if (d.count > 0){
- if(d.depth === 1){
- return d.name.split(".")[0];
- }else
- return d.name;
- }
- else
- return "";
- } else
- return d.name;
-
- });
-
- var node = svg.selectAll("circle,text");
-
- d3.select(this.ui.graph[0]).style("background", color(-1)).on(
- "click", function() {
- zoom(root);
- });
-
- zoomTo([ root.x, root.y, root.r * 2 + margin ]);
- function zoom(d) {
- var focus0 = focus;
- focus = d;
-
- var transition = d3.transition().duration(
- d3.event.altKey ? 7500 : 750).tween(
- "zoom",
- function(d) {
- var i = d3.interpolateZoom(view, [ focus.x,
- focus.y, focus.r * 2 + margin ]);
- return function(t) {
- zoomTo(i(t));
- };
- });
-
- transition.selectAll("#"+that.ui.graph.attr("id")+" text").filter(
- function(d) {
- return d.parent === focus
- || this.style.display === "inline";
- }).style("fill-opacity", function(d) {
- return d.parent === focus ? 1 : 0;
- }).each("start", function(d) {
- if (d.parent === focus)
- this.style.display = "inline";
- }).each("end", function(d) {
- if (d.parent !== focus)
- this.style.display = "none";
- });
- }
-
- function zoomTo(v) {
- var k = diameter / v[2];
- view = v;
- node.attr("transform", function(d) {
- return "translate(" + (d.x - v[0]) * k + "," + (d.y - v[1])
- * k + ")";
- });
- circle.attr("r", function(d) {
- return d.r * k;
- });
- }
- },
- onClose : function(){
- $('body').unbind("mouseup.contextMenu");
- }
- });
-
-
-});