http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java index ff185f8..0bd326e 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java @@ -45,7 +45,6 @@ import org.apache.ambari.logsearch.query.model.AuditBarGraphSearchCriteria; import org.apache.ambari.logsearch.query.model.CommonSearchCriteria; import org.apache.ambari.logsearch.query.model.FieldAuditLogSearchCriteria; import org.apache.ambari.logsearch.query.model.FieldAuditBarGraphSearchCriteria; -import org.apache.ambari.logsearch.query.model.SearchCriteria; import org.apache.ambari.logsearch.model.request.impl.AuditLogRequest; import org.apache.ambari.logsearch.manager.AuditLogsManager; import org.apache.ambari.logsearch.query.model.UserExportSearchCriteria;
http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileResource.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileResource.java deleted file mode 100644 index c23f457..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileResource.java +++ /dev/null @@ -1,69 +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. - */ -package org.apache.ambari.logsearch.rest; - -import javax.inject.Inject; -import javax.ws.rs.BeanParam; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.ambari.logsearch.model.request.impl.LogFileRequest; -import org.apache.ambari.logsearch.model.request.impl.LogFileTailRequest; -import org.apache.ambari.logsearch.model.response.LogFileDataListResponse; -import org.apache.ambari.logsearch.model.response.LogListResponse; -import org.apache.ambari.logsearch.query.model.LogFileSearchCriteria; -import org.apache.ambari.logsearch.query.model.LogFileTailSearchCriteria; -import org.apache.ambari.logsearch.manager.LogFileManager; -import org.springframework.context.annotation.Scope; -import org.springframework.core.convert.ConversionService; -import org.springframework.stereotype.Component; - -import static org.apache.ambari.logsearch.doc.DocConstants.LogFileOperationDescriptions.*; - -@Api(value = "logfile", description = "Logfile operations") -@Path("logfile") -@Component -@Scope("request") -public class LogFileResource { - - @Inject - private LogFileManager logFileManager; - - @Inject - private ConversionService conversionService; - - @GET - @Produces({"application/json"}) - @ApiOperation(SEARCH_LOG_FILES_OD) - public LogFileDataListResponse searchLogFiles(@BeanParam LogFileRequest request) { - return logFileManager.searchLogFiles(conversionService.convert(request, LogFileSearchCriteria.class)); - } - - @GET - @Path("/tail") - @Produces({"application/json"}) - @ApiOperation(GET_LOG_FILE_TAIL_OD) - public LogListResponse getLogFileTail(@BeanParam LogFileTailRequest request) { - return logFileManager.getLogFileTail(conversionService.convert(request, LogFileTailSearchCriteria.class)); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java index 6cc69d4..5a17147 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java @@ -34,7 +34,6 @@ import org.apache.ambari.logsearch.model.request.impl.ServiceAnyGraphRequest; import org.apache.ambari.logsearch.model.request.impl.ServiceExtremeDatesRequest; import org.apache.ambari.logsearch.model.request.impl.ServiceGraphRequest; import org.apache.ambari.logsearch.model.request.impl.ServiceLogExportRequest; -import org.apache.ambari.logsearch.model.request.impl.ServiceLogFileRequest; import org.apache.ambari.logsearch.model.request.impl.ServiceLogRequest; import org.apache.ambari.logsearch.model.request.impl.ServiceLogTruncatedRequest; import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse; @@ -44,15 +43,12 @@ import org.apache.ambari.logsearch.model.response.GroupListResponse; import org.apache.ambari.logsearch.model.response.NameValueDataListResponse; import org.apache.ambari.logsearch.model.response.NodeListResponse; import org.apache.ambari.logsearch.model.response.ServiceLogResponse; -import org.apache.ambari.logsearch.query.model.CommonSearchCriteria; import org.apache.ambari.logsearch.query.model.CommonServiceLogSearchCriteria; -import org.apache.ambari.logsearch.query.model.SearchCriteria; import org.apache.ambari.logsearch.manager.ServiceLogsManager; import org.apache.ambari.logsearch.query.model.ServiceAnyGraphSearchCriteria; import org.apache.ambari.logsearch.query.model.ServiceExtremeDatesCriteria; import org.apache.ambari.logsearch.query.model.ServiceGraphSearchCriteria; import org.apache.ambari.logsearch.query.model.ServiceLogExportSearchCriteria; -import org.apache.ambari.logsearch.query.model.ServiceLogFileSearchCriteria; import org.apache.ambari.logsearch.query.model.ServiceLogSearchCriteria; import org.apache.ambari.logsearch.query.model.ServiceLogTruncatedSearchCriteria; import org.springframework.context.annotation.Scope; @@ -132,8 +128,8 @@ public class ServiceLogsResource { @Path("/tree") @Produces({"application/json"}) @ApiOperation(GET_TREE_EXTENSION_OD) - public NodeListResponse getTreeExtension(@QueryParam("hostName") @ApiParam String hostName, @BeanParam ServiceLogFileRequest request) { - ServiceLogFileSearchCriteria searchCriteria = conversionService.convert(request, ServiceLogFileSearchCriteria.class); + public NodeListResponse getTreeExtension(@QueryParam("hostName") @ApiParam String hostName, @BeanParam ServiceLogRequest request) { + ServiceLogSearchCriteria searchCriteria = conversionService.convert(request, ServiceLogSearchCriteria.class); searchCriteria.addParam("hostName", hostName); // TODO: use host_name instead - needs UI change return serviceLogsManager.getTreeExtension(searchCriteria); } @@ -142,8 +138,8 @@ public class ServiceLogsResource { @Path("/levels/counts/namevalues") @Produces({"application/json"}) @ApiOperation(GET_LOG_LEVELS_COUNT_OD) - public NameValueDataListResponse getLogsLevelCount(@BeanParam ServiceLogFileRequest request) { - return serviceLogsManager.getLogsLevelCount(conversionService.convert(request, ServiceLogFileSearchCriteria.class)); + public NameValueDataListResponse getLogsLevelCount(@BeanParam ServiceLogRequest request) { + return serviceLogsManager.getLogsLevelCount(conversionService.convert(request, ServiceLogSearchCriteria.class)); } @GET @@ -175,8 +171,8 @@ public class ServiceLogsResource { @Path("/hosts/components") @Produces({"application/json"}) @ApiOperation(GET_HOST_LIST_BY_COMPONENT_OD) - public NodeListResponse getHostListByComponent(@BeanParam ServiceLogFileRequest request, @QueryParam("componentName") @ApiParam String componentName) { - ServiceLogFileSearchCriteria searchCriteria = conversionService.convert(request, ServiceLogFileSearchCriteria.class); + public NodeListResponse getHostListByComponent(@BeanParam ServiceLogRequest request, @QueryParam("componentName") @ApiParam String componentName) { + ServiceLogSearchCriteria searchCriteria = conversionService.convert(request, ServiceLogSearchCriteria.class); searchCriteria.addParam("componentName", componentName); // TODO: use component_name instead - needs UI change return serviceLogsManager.getHostListByComponent(searchCriteria); } @@ -185,8 +181,8 @@ public class ServiceLogsResource { @Path("/components/levels/counts") @Produces({"application/json"}) @ApiOperation(GET_COMPONENT_LIST_WITH_LEVEL_COUNT_OD) - public NodeListResponse getComponentListWithLevelCounts(@BeanParam ServiceLogFileRequest request) { - return serviceLogsManager.getComponentListWithLevelCounts(conversionService.convert(request, ServiceLogFileSearchCriteria.class)); + public NodeListResponse getComponentListWithLevelCounts(@BeanParam ServiceLogRequest request) { + return serviceLogsManager.getComponentListWithLevelCounts(conversionService.convert(request, ServiceLogSearchCriteria.class)); } @GET @@ -198,14 +194,6 @@ public class ServiceLogsResource { } @GET - @Path("/fields") - @Produces({"application/json"}) - @ApiOperation(GET_SERVICE_LOGS_FIELD_NAME_OD) - public String getServiceLogsFieldsName() { - return serviceLogsManager.getServiceLogsFieldsName(); - } - - @GET @Path("/schema/fields") @Produces({"application/json"}) @ApiOperation(GET_SERVICE_LOGS_SCHEMA_FIELD_NAME_OD) http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java index d398bdc..a89b5dd 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java @@ -25,7 +25,7 @@ import javax.inject.Inject; import org.apache.ambari.logsearch.common.ExternalServerClient; import org.apache.ambari.logsearch.common.PropertiesHelper; -import org.apache.ambari.logsearch.conf.AuthConfig; +import org.apache.ambari.logsearch.conf.AuthPropsConfig; import org.apache.ambari.logsearch.util.JSONUtil; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; @@ -99,7 +99,7 @@ public class LogsearchExternalServerAuthenticationProvider extends private ExternalServerClient externalServerClient; @Inject - private AuthConfig authConfig; + private AuthPropsConfig authPropsConfig; /** * Authenticating user from external-server using REST call @@ -113,7 +113,7 @@ public class LogsearchExternalServerAuthenticationProvider extends @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { - if (!authConfig.isAuthExternalEnabled()) { + if (!authPropsConfig.isAuthExternalEnabled()) { LOG.debug("external server auth is disabled."); return authentication; } @@ -129,7 +129,7 @@ public class LogsearchExternalServerAuthenticationProvider extends password = StringEscapeUtils.unescapeHtml(password); username = StringEscapeUtils.unescapeHtml(username); try { - String finalLoginUrl = authConfig.getExternalAuthLoginUrl().replace("$USERNAME", username); + String finalLoginUrl = authPropsConfig.getExternalAuthLoginUrl().replace("$USERNAME", username); String responseObj = (String) externalServerClient.sendGETRequest( finalLoginUrl, String.class, null, username, password); if (!isAllowedRole(responseObj)) { http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java index 9662266..dc70b82 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java @@ -20,7 +20,7 @@ package org.apache.ambari.logsearch.web.security; import java.util.Collection; -import org.apache.ambari.logsearch.conf.AuthConfig; +import org.apache.ambari.logsearch.conf.AuthPropsConfig; import org.apache.ambari.logsearch.util.CommonUtil; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; @@ -42,14 +42,14 @@ public class LogsearchFileAuthenticationProvider extends LogsearchAbstractAuthen private static Logger logger = Logger.getLogger(LogsearchFileAuthenticationProvider.class); @Inject - private AuthConfig authConfig; + private AuthPropsConfig authPropsConfig; @Inject private UserDetailsService userDetailsService; @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { - if (!authConfig.isAuthFileEnabled()) { + if (!authPropsConfig.isAuthFileEnabled()) { logger.debug("File auth is disabled."); return authentication; } http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchLdapAuthenticationProvider.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchLdapAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchLdapAuthenticationProvider.java index f6c7df0..52dd66e 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchLdapAuthenticationProvider.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchLdapAuthenticationProvider.java @@ -20,7 +20,7 @@ package org.apache.ambari.logsearch.web.security; import java.util.List; -import org.apache.ambari.logsearch.conf.AuthConfig; +import org.apache.ambari.logsearch.conf.AuthPropsConfig; import org.apache.log4j.Logger; import org.springframework.ldap.CommunicationException; import org.springframework.ldap.core.support.LdapContextSource; @@ -47,7 +47,7 @@ public class LogsearchLdapAuthenticationProvider extends private String logStatement = ""; @Inject - private AuthConfig authConfig; + private AuthPropsConfig authPropsConfig; public LogsearchLdapAuthenticationProvider() { } @@ -55,7 +55,7 @@ public class LogsearchLdapAuthenticationProvider extends @PostConstruct public void postConstruct() { logger.debug("Creating object of ldap auth provider "); - if (authConfig.isAuthLdapEnabled()) { + if (authPropsConfig.isAuthLdapEnabled()) { ldapAuthProvider = loadLdapAuthenticationProvider(); } else { logger.info("Ldap auth is disabled"); @@ -65,7 +65,7 @@ public class LogsearchLdapAuthenticationProvider extends @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { - if (!authConfig.isAuthLdapEnabled()) { + if (!authPropsConfig.isAuthLdapEnabled()) { logger.debug("Ldap auth is disabled"); return authentication; } http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java index 5dc1c1f..17d099b 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java @@ -18,7 +18,7 @@ */ package org.apache.ambari.logsearch.web.security; -import org.apache.ambari.logsearch.conf.AuthConfig; +import org.apache.ambari.logsearch.conf.AuthPropsConfig; import org.apache.ambari.logsearch.web.model.User; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; @@ -37,11 +37,11 @@ public class LogsearchSimpleAuthenticationProvider extends LogsearchAbstractAuth private static Logger logger = Logger.getLogger(LogsearchSimpleAuthenticationProvider.class); @Inject - private AuthConfig authConfig; + private AuthPropsConfig authPropsConfig; @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { - if (!authConfig.isAuthSimpleEnabled()) { + if (!authPropsConfig.isAuthSimpleEnabled()) { logger.debug("Simple auth is disabled"); return authentication; } http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/resources/default.properties ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/default.properties b/ambari-logsearch/ambari-logsearch-portal/src/main/resources/default.properties index d89a6c9..9a44761 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/default.properties +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/resources/default.properties @@ -13,28 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -#Service Logs Field Names -logsearch.service.logs.fields=logtime,level,event_count,ip,type,path,file,line_number,host,log_message,method,id -#Exclude Column List for Service Logs -logsearch.solr.service.logs.exclude.columnlist=tags,text,message,seq_num - -#Exclude Column List for Ranger Audits -logsearch.solr.audit.logs.exclude.columnlist=tags,tags_str,seq_num - -#Value Mapping for Audit Fields -#Example FieldName=ValueOfUI:ValueOfSolr -result=Allowed:1,Denied:0 - -#Column Mapping -#Example CoulumnInSolr:ColumnInUI -#For Service Logs -logsearch.solr.service.logs.column.mapping=bundle_id:Bundle Id,thread_name:Thread,log_message:Message,case_id:Case Id,cluster:Cluster,event_count:Event Count,file:File,host:Host,id:Id,ip:Ip,level:Level,line_number:Line Number,logfile_line_number:Logfile Line Number,logger_name:Logger Name,logtype:Log Type,method:Method,path:Path,rowtype:Row Type,type:Type - -#For Audit Logs -logsearch.solr.audit.logs.column.mapping=access:Access Type,reqUser:User,enforcer:Access Enforcer,ip:IP,action:Action,agent:Agent,agentHost:Agent Host,authType:Auth Type,bundle_id:Bundle Id,case_id:Case Id,cliIP:Client Ip,cliType:Client Type,cluster:Cluster,dst:DST,event_count:Event Count,file:File,host:Host,id:Id,level:Level,log_message:Log Message,logfile_line_number:Logfile Line Number,logger_name:Logger Name,logType:Log Type,path:Path,perm:Perm,policy:Policy,proxyAuthType:Proxy Auth Type,proxyUsers:Proxy Users,reason:Reason,repo:Repo,repoType:Repo Type,req_caller_id:Req Caller Id,req_self_id:Req Self Id,reqContext:Req Context,reqData:Req Data,resource:Resource,resType:Res Type,result:Result,seq_num:Seq Num,sess:Sess,text:Text,type:Type,ugi:UGI - -#login method #Note: Simple will be supported only if both file and ldap is disabled. logsearch.auth.file.enable=true logsearch.auth.ldap.enable=false http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/App.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/App.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/App.js index 24cbd5a..664f55f 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/App.js +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/App.js @@ -18,15 +18,13 @@ define(['backbone','utils/LangSupport', 'backbone.marionette'],function(Backbone,localization) { 'use strict'; - - //var SessionMgr = require('mgrs/SessionMgr'); + /* * Localization initialization */ localization.setDefaultCulture(); // will take default that is en var App = new Backbone.Marionette.Application(); - //App.userProfile = SessionMgr.getUserProfile(); /* Add application regions here */ App.addRegions({ http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VAuditLogListBase.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VAuditLogListBase.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VAuditLogListBase.js index 0f72697..53ec922 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VAuditLogListBase.js +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VAuditLogListBase.js @@ -58,7 +58,7 @@ define(['require', }, options); return this.constructor.nonCrudOperation.call(this, url, 'GET', options); - }, + } },{ /** * Table Cols to be passed to Backgrid http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VLogListBase.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VLogListBase.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VLogListBase.js index 72ab530..08a8271 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VLogListBase.js +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VLogListBase.js @@ -76,19 +76,18 @@ define(['require', contentType : 'application/json', dataType : 'json' }, options); - return this.constructor.nonCrudOperation.call(this, url, 'GET', options); }, - getServiceLogSchemaFields : function(token, options){ - var url = Globals.baseURL + 'service/logs/schema/fields'; - - options = _.extend({ - data : $.param(token), - contentType : 'application/json', - dataType : 'json' - }, options); + getServiceLogSchemaFields : function(token, options){ + var url = Globals.baseURL + 'service/logs/schema/fields'; - return this.constructor.nonCrudOperation.call(this, url, 'GET', options); + options = _.extend({ + data: $.param(token), + contentType: 'application/json', + dataType: 'json' + }, options); + + return this.constructor.nonCrudOperation.call(this, url, 'GET', options); }, getTruncatedLogs : function(token, options){ var url = Globals.baseURL + 'service/logs/truncated'; http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/BaseCollection.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/BaseCollection.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/BaseCollection.js index ac82708..c175397 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/BaseCollection.js +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/BaseCollection.js @@ -152,7 +152,6 @@ define(['require', var retCols = _.map(cols, function(v, k, l){ var defaults = collection.constructor.tableCols[k]; if(! defaults){ - //console.log("Error!! " + k + " not found in collection: " , collection); defaults = {}; } return _.extend({ 'name' : k }, defaults, v ); http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/SchemaFieldList.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/SchemaFieldList.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/SchemaFieldList.js new file mode 100644 index 0000000..a1c2799 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/SchemaFieldList.js @@ -0,0 +1,29 @@ +/** + * 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'], function(require, Backbone) { + 'use strict'; + + var SchemaField = Backbone.Model.extend({ + }); + + return Backbone.Collection.extend({ + model: SchemaField, + url: '../static/schema_fields.json' + }); +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/mgrs/SessionMgr.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/mgrs/SessionMgr.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/mgrs/SessionMgr.js deleted file mode 100644 index 0809ce0..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/mgrs/SessionMgr.js +++ /dev/null @@ -1,137 +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. - */ - - -// Manages the user session -define(function(require){ - 'use strict'; - - // var VXPortalUser = require('models/VXPortalUser'); - - // // Private properties - // var vXPortalUser = null; - // var vSessionSettings = null; - - // // Public methods - // var SessionMgr = {}; - - // /** - // * Gets the user profile for the given session - // * - // * @returns VXPortalUser - // */ - - // SessionMgr.getUserProfile = function() { - // if ( vXPortalUser){ - // return vXPortalUser; - // } - - // vXPortalUser = new VXPortalUser(); - // vXPortalUser.getUserProfile({async : false,cache:false}).done(function(data){ - // vXPortalUser.set(data); - // }); - // return vXPortalUser; - // }; - - - // SessionMgr.getLoginId = function() { - // if (vXPortalUser) { - // return vXPortalUser.get('loginId'); - // } - // }; - - // SessionMgr.userInRole = function(role) { - // var vXPortalUser = SessionMgr.getUserProfile(); - // var userRoles = vXPortalUser.get('userRoleList'); - // if (!userRoles || !role) { - // return false; - // } - // if (userRoles.constructor != Array) { - // userRoles = [ userRoles ]; - // } - - // return (userRoles.indexOf(role) > -1); - // }; - - // SessionMgr.getUserRoles = function() { - // var vXPortalUser = SessionMgr.getUserProfile(); - // var userRoles = vXPortalUser.get('userRoleList'); - // if (!userRoles) { - // return []; - // } - // if (userRoles.constructor != Array) { - // userRoles = [ userRoles ]; - // } - - // return userRoles; - // }; - - // SessionMgr.getSetting = function(key) { - // if (!vSessionSettings) { - // var msResponse = GeneralMgr.getSessionSettings(); - // if (msResponse.isSuccess()) { - // vSessionSettings = msResponse.response; - // } - // } - // var value = null; - // if (vSessionSettings && key) { - // vSessionSettings.each(function(vNameValue) { - // if (vNameValue.get('name') == key) { - // value = vNameValue.get('value'); - // } - // }); - // } - // return value; - // }; - - // SessionMgr.resetSession = function() { - // vXPortalUser = null; - // vSessionSettings = null; - // MSCacheMgr.resetAll(); - // }; - - // /** - // * Logs out the user and resets all session variables - // */ - // SessionMgr.logout = function(reDirectUser) { - // SessionMgr.resetSession(); - // MSCacheMgr.resetAll(); - // if (reDirectUser) { - // // This will ask the browser to redirect - // window.location.replace("logout.html"); - // } else { - // // We will do an implicit logout - // $.ajax({ - // url : 'logout.html', - // type : 'GET', - // async : false - // }); - // } - // }; - - // SessionMgr.isSystemAdmin = function(){ - // return this.userInRole('ROLE_SYS_ADMIN') ? true : false; - // }; - - // SessionMgr.isUser = function(){ - // var roles = this.getRoleInUserSchool(); - // return $.inArray('ROLE_USER',roles) != -1 ? true : false ; - // }; - // return SessionMgr; -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Globals.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Globals.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Globals.js index b6e8d7d..8356b9c 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Globals.js +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Globals.js @@ -1,85 +1,91 @@ /** -* 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. -*/ + * 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','App'], function(require, App){ - 'use strict'; - - var Globals = {}; - - Globals.settings = {}; - Globals.settings.PAGE_SIZE = 25; - Globals.settings.uploadDefaultOpts = { - disableImageResize: false, - maxFileSize: 5000000, - autoUpload : false - //maxNumberOfFiles : 2 - }; - Globals.settings.MAX_VALUE = 2147483647; +define(['require', 'collections/SchemaFieldList'], function (require, SchemaFieldList) { + 'use strict'; - Globals.keys = {}; - Globals.keys.ENTER_KEY = 13; - Globals.keys.ESC_KEY = 27; - - Globals.EventHistory = { - totalCount : 50 - }; + var Globals = {}; - Globals.baseURL = '../api/v1/'; - //Globals.baseURL = App.baseUrl; + Globals.settings = {}; + Globals.settings.PAGE_SIZE = 25; + Globals.settings.uploadDefaultOpts = { + disableImageResize: false, + maxFileSize: 5000000, + autoUpload: false + }; + Globals.settings.MAX_VALUE = 2147483647; - Globals.AppTabs = { - DASHBOARD : { value:1, valStr: 'Dashboard'}, - MAINVIEW : { value:2, valStr: 'Main View'} - }; + Globals.keys = {}; + Globals.keys.ENTER_KEY = 13; + Globals.keys.ESC_KEY = 27; - Globals.BooleanValue = { - BOOL_TRUE:{value:"true", label:'True'}, - BOOL_FALSE:{value:"false", label:'False'} - }; - Globals.paramsNameMapping = { - q:{label:'Query'}, - from:{label:'From'}, - to:{label:'To'}, - unit:{label:'Unit'}, - level:{label:'Level'}, - mustNot:{label:'Exclude Component'}, - mustBe:{label:'Include Component'}, - iMessage:{label:'Include Message'}, - eMessage:{label:'Exclude Message'}, - time:{label:''}, - includeQuery : {label:"Include Column"}, - excludeQuery : {label:"Exclude Column"}, - dateRangeLabel : {label : "Date Range"} - }; + Globals.EventHistory = { + totalCount: 50 + }; - Globals.graphType = { - MULTILINE:{value:1}, - HISTOGRAM:{value:2}, - PIE:{value:3}, - TABLE:{value:4} - }; + Globals.baseURL = '../api/v1/'; - Globals.dateFormat = "YYYY-MM-DD HH:mm:ss.SSS"; - Globals.splitToken = "|i::e|"; - Globals.eventName = { - serviceLogsIncludeColumns : "search:serviceLogs:include", - serviceLogsExcludeColumns : "search:serviceLogs:exclude" - }; - Globals.serviceLogsColumns = []; - return Globals; + Globals.AppTabs = { + DASHBOARD: {value: 1, valStr: 'Dashboard'}, + MAINVIEW: {value: 2, valStr: 'Main View'} + }; + + Globals.BooleanValue = { + BOOL_TRUE: {value: "true", label: 'True'}, + BOOL_FALSE: {value: "false", label: 'False'} + }; + Globals.paramsNameMapping = { + q: {label: 'Query'}, + from: {label: 'From'}, + to: {label: 'To'}, + unit: {label: 'Unit'}, + level: {label: 'Level'}, + mustNot: {label: 'Exclude Component'}, + mustBe: {label: 'Include Component'}, + iMessage: {label: 'Include Message'}, + eMessage: {label: 'Exclude Message'}, + time: {label: ''}, + includeQuery: {label: "Include Column"}, + excludeQuery: {label: "Exclude Column"}, + dateRangeLabel: {label: "Date Range"} + }; + + Globals.graphType = { + MULTILINE: {value: 1}, + HISTOGRAM: {value: 2}, + PIE: {value: 3}, + TABLE: {value: 4} + }; + + Globals.dateFormat = "YYYY-MM-DD HH:mm:ss.SSS"; + Globals.splitToken = "|i::e|"; + Globals.eventName = { + serviceLogsIncludeColumns: "search:serviceLogs:include", + serviceLogsExcludeColumns: "search:serviceLogs:exclude" + }; + Globals.serviceLogsColumns = []; + Globals.schemaFields = new SchemaFieldList().fetch({async: false}).responseJSON; + Globals.defaultServiceLogMappings = Globals.schemaFields.serviceLogMappings; + Globals.defaultServiceLogExcludes = Globals.schemaFields.serviceLogExcludes; + Globals.defaultAuditLogMappings = Globals.schemaFields.auditLogMappings; + Globals.defaultAuditLogExcludes = Globals.schemaFields.auditLogExcludes; + Globals.invertedServiceLogMappings = _.invert(Globals.defaultServiceLogMappings); + Globals.invertedAuditLogMappings = _.invert(Globals.defaultAuditLogMappings); + + return Globals; }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/ViewUtils.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/ViewUtils.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/ViewUtils.js index 62d785b..4c23290 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/ViewUtils.js +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/ViewUtils.js @@ -18,214 +18,249 @@ */ - define(['require', - 'utils/Utils', - 'moment', - 'collections/VNameValueList', - 'utils/Globals' -], function(require, Utils, moment, VNameValueList, Globals) { - 'use strict'; - - var ViewUtil = {}; - - ViewUtil.setdefaultParams = function() { - var fromSolr, toSolr,that=this; - var params = Utils.getQueryParams(window.location.search); - this.defaultParams = { - q: "*:*", - from: moment().hours("00").minutes("00").seconds("01").milliseconds("000").toJSON(), - to: moment().hours("23").minutes("59").seconds("59").milliseconds("999").toJSON(), - unit: "+1HOUR", - level: "FATAL,ERROR,WARN" - }; - var 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(); - } - } + 'utils/Utils', + 'moment', + 'collections/VNameValueList', + 'utils/Globals' +], function (require, Utils, moment, VNameValueList, Globals) { + 'use strict'; + + var ViewUtil = {}; + + ViewUtil.setdefaultParams = function () { + var fromSolr, toSolr, that = this; + var params = Utils.getQueryParams(window.location.search); + this.defaultParams = { + q: "*:*", + from: moment().hours("00").minutes("00").seconds("01").milliseconds("000").toJSON(), + to: moment().hours("23").minutes("59").seconds("59").milliseconds("999").toJSON(), + unit: "+1HOUR", + level: "FATAL,ERROR,WARN" + }; + var 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(); + } } - if (params.bundle_id && !params.start_time && !params.end_time) { - var collection = new VNameValueList(); - - collection.url = Globals.baseURL + "service/logs/solr/boundarydates"; - collection.modelAttrName = "vNameValues"; - _.extend(collection.queryParams, { - "bundle_id": params.bundle_id - }); - collection.fetch({ - reset: true, - async: false, - success: function(data) { - collection.each(function(model) { - if (model.get('name') == "From") { - fromSolr = moment(parseInt(model.get('value'))).toJSON(); - } - if (model.get('name') == "To") { - toSolr = moment(parseInt(model.get('value'))).toJSON(); - } - if(fromSolr && toSolr){ - that.defaultParams['dateRangeLabel'] = "Custom Range"; - } - }) - - } - }); - } - if (params.bundle_id) { - this.defaultParams['bundle_id'] = params.bundle_id; - } - if (params.start_time) { - var startDateString = applyParamsDate(params.start_time); - } - if (params.end_time) { - var endDateString = applyParamsDate(params.end_time); - } - if (params.host_name) { - this.defaultParams['host_name'] = params.host_name; - } - if (params.component_name) { - this.defaultParams['component_name'] = params.component_name; - } - if (params.file_name) { - this.defaultParams['file_name'] = params.file_name; - } - if (startDateString && endDateString) { - if (params.timezone) { - var timeZoneObject = worldMapTime.getTimeZoneObject(params.timezone) - if (timeZoneObject.length) { - var timeZoneName = timeZoneObject[0].timezone - } - if (timeZoneName) { - var startEncodeDate = params.start_time.replace(",", ".") - var endEncodeDate = params.end_time.replace(",", ".") - startDateString = moment.tz(startEncodeDate, timeZoneName).toJSON(); - endDateString = moment.tz(endEncodeDate, timeZoneName).toJSON(); - var timeZoneString = timeZoneName + "," + timeZoneObject[0].zoneName + "," + timeZoneObject.length; - Utils.localStorage.setLocalStorage('timezone', timeZoneString); - moment.tz.setDefault(timeZoneName); - } + } + } + if (params.bundle_id && !params.start_time && !params.end_time) { + var collection = new VNameValueList(); + + collection.url = Globals.baseURL + "service/logs/solr/boundarydates"; + collection.modelAttrName = "vNameValues"; + _.extend(collection.queryParams, { + "bundle_id": params.bundle_id + }); + collection.fetch({ + reset: true, + async: false, + success: function (data) { + collection.each(function (model) { + if (model.get('name') == "From") { + fromSolr = moment(parseInt(model.get('value'))).toJSON(); } - this.defaultParams['end_time'] = endDateString - this.defaultParams['start_time'] = startDateString; - this.defaultParams['from'] = startDateString; - this.defaultParams['to'] = endDateString; - this.defaultParams['dateRangeLabel'] = "Custom Range"; - } - if (fromSolr && toSolr) { - this.defaultParams['from'] = fromSolr; - this.defaultParams['to'] = toSolr; - this.defaultParams['dateRangeLabel'] = "Custom Range"; + if (model.get('name') == "To") { + toSolr = moment(parseInt(model.get('value'))).toJSON(); + } + if (fromSolr && toSolr) { + that.defaultParams['dateRangeLabel'] = "Custom Range"; + } + }) + } + }); } - ViewUtil.getDefaultParams = function() { - return $.extend(true, {}, this.defaultParams); + if (params.bundle_id) { + this.defaultParams['bundle_id'] = params.bundle_id; } - ViewUtil.getCountDistributionHTML = function(node) { - if (!node.logLevelCount) - return ""; - return '<div data-node = "' + node.name + '" class="nodebar">' + ViewUtil.getLevelDistributionHTML(node) + '</div>'; - }; - ViewUtil.getLevelDistributionHTML = function(node) { - var html = ""; - if (!_.isUndefined(node.logLevelCount) && !_.isArray(node.logLevelCount)) - node.logLevelCount = [node.logLevelCount]; - var toPct = ViewUtil.calculatePercentge(node.logLevelCount); - _.each(node.logLevelCount, function(data) { - //html += '<div class="node '+data.name+'" style="width:'+toPct(data)+'%;" data-toggle="tooltip" title="'+data.value+'" data-original-title="'+data.value+'"></div>'; - html += '<div class="node ' + data.name + '" style="width:' + toPct(data) + '%;"></div>'; - }); - return html; - }; - ViewUtil.calculatePercentge = function(values) { - var sum = 0; - for (var i = 0; i != values.length; ++i) { - sum = sum + parseInt(values[i].value, 10); + if (params.start_time) { + var startDateString = applyParamsDate(params.start_time); + } + if (params.end_time) { + var endDateString = applyParamsDate(params.end_time); + } + if (params.host_name) { + this.defaultParams['host_name'] = params.host_name; + } + if (params.component_name) { + this.defaultParams['component_name'] = params.component_name; + } + if (params.file_name) { + this.defaultParams['file_name'] = params.file_name; + } + if (startDateString && endDateString) { + if (params.timezone) { + var timeZoneObject = worldMapTime.getTimeZoneObject(params.timezone) + if (timeZoneObject.length) { + var timeZoneName = timeZoneObject[0].timezone } - var scale = 100 / sum; - return function(x) { - return (parseInt(x.value, 10) * scale) /*.toFixed(5)*/ ; - }; + if (timeZoneName) { + var startEncodeDate = params.start_time.replace(",", ".") + var endEncodeDate = params.end_time.replace(",", ".") + startDateString = moment.tz(startEncodeDate, timeZoneName).toJSON(); + endDateString = moment.tz(endEncodeDate, timeZoneName).toJSON(); + var timeZoneString = timeZoneName + "," + timeZoneObject[0].zoneName + "," + timeZoneObject.length; + Utils.localStorage.setLocalStorage('timezone', timeZoneString); + moment.tz.setDefault(timeZoneName); + } + } + this.defaultParams['end_time'] = endDateString + this.defaultParams['start_time'] = startDateString; + this.defaultParams['from'] = startDateString; + this.defaultParams['to'] = endDateString; + this.defaultParams['dateRangeLabel'] = "Custom Range"; + } + if (fromSolr && toSolr) { + this.defaultParams['from'] = fromSolr; + this.defaultParams['to'] = toSolr; + this.defaultParams['dateRangeLabel'] = "Custom Range"; + } + } + ViewUtil.getDefaultParams = function () { + return $.extend(true, {}, this.defaultParams); + } + ViewUtil.getCountDistributionHTML = function (node) { + if (!node.logLevelCount) + return ""; + return '<div data-node = "' + node.name + '" class="nodebar">' + ViewUtil.getLevelDistributionHTML(node) + '</div>'; + }; + ViewUtil.getLevelDistributionHTML = function (node) { + var html = ""; + if (!_.isUndefined(node.logLevelCount) && !_.isArray(node.logLevelCount)) + node.logLevelCount = [node.logLevelCount]; + var toPct = ViewUtil.calculatePercentge(node.logLevelCount); + _.each(node.logLevelCount, function (data) { + //html += '<div class="node '+data.name+'" style="width:'+toPct(data)+'%;" data-toggle="tooltip" title="'+data.value+'" data-original-title="'+data.value+'"></div>'; + html += '<div class="node ' + data.name + '" style="width:' + toPct(data) + '%;"></div>'; + }); + return html; + }; + ViewUtil.calculatePercentge = function (values) { + var sum = 0; + for (var i = 0; i != values.length; ++i) { + sum = sum + parseInt(values[i].value, 10); + } + var scale = 100 / sum; + return function (x) { + return (parseInt(x.value, 10) * scale) /*.toFixed(5)*/; }; + }; - ViewUtil.getDefaultParamsForHierarchy = function() { - return ViewUtil.getDefaultParams(); - }; + ViewUtil.getDefaultParamsForHierarchy = function () { + return ViewUtil.getDefaultParams(); + }; - ViewUtil.setLatestTimeParams = function(params) { - if (params && params.dateRangeLabel) { - var arr = Utils.dateUtil.getRelativeDateFromString(params.dateRangeLabel); - if (_.isArray(arr)) { - params.from = arr[0].toJSON(); - params.to = arr[1].toJSON(); - }; - } + ViewUtil.setLatestTimeParams = function (params) { + if (params && params.dateRangeLabel) { + var arr = Utils.dateUtil.getRelativeDateFromString(params.dateRangeLabel); + if (_.isArray(arr)) { + params.from = arr[0].toJSON(); + params.to = arr[1].toJSON(); + } + ; + } - }; - - ViewUtil.foramtLogMessageAsLogFile = function(model, logMessageHtmlClass){ - var attrs = model.attributes; - var str=""; - if(attrs.logtime) - str += moment(attrs.logtime).format("YYYY-MM-DD HH:mm:ss,SSS")+" "; - if(attrs.level) - str += "<span class='"+(""+attrs.level).toUpperCase()+"'>"+(""+attrs.level).toUpperCase()+"</span> "; - if(attrs.thread_name) - str += $.trim(attrs.thread_name)+" "; - if(attrs.logger_name) - str += $.trim(attrs.logger_name)+" "; - if(attrs.file && attrs.line_number) - str += attrs.file+":"+attrs.line_number+" "; -// if(attrs.cluster) -// str += attrs.cluster+" "; - if(attrs.log_message) - str += "<span class='"+(logMessageHtmlClass ? logMessageHtmlClass : "logMessage")+"'>- "+Utils.escapeHtmlChar(attrs.log_message)+" </span>"; - return str; + }; + + ViewUtil.foramtLogMessageAsLogFile = function (model, logMessageHtmlClass) { + var attrs = model.attributes; + var str = ""; + if (attrs.logtime) + str += moment(attrs.logtime).format("YYYY-MM-DD HH:mm:ss,SSS") + " "; + if (attrs.level) + str += "<span class='" + ("" + attrs.level).toUpperCase() + "'>" + ("" + attrs.level).toUpperCase() + "</span> "; + if (attrs.thread_name) + str += $.trim(attrs.thread_name) + " "; + if (attrs.logger_name) + str += $.trim(attrs.logger_name) + " "; + if (attrs.file && attrs.line_number) + str += attrs.file + ":" + attrs.line_number + " "; + if (attrs.log_message) + str += "<span class='" + (logMessageHtmlClass ? logMessageHtmlClass : "logMessage") + "'>- " + Utils.escapeHtmlChar(attrs.log_message) + " </span>"; + return str; + } + + ViewUtil.scrollToElement = function (top, speed) { + if (!top) + return; + $("html, body").animate({scrollTop: (top - 200)}, (speed) ? speed : 300); + }; + + ViewUtil.formatAuditGraphData = function (collection) { + var mainObj = [], len = 0, that = this; + collection.each(function (m, index) { + var userName = m.get("name"); + if (len < userName.length) + len = userName.length; + var compo = m.get("dataCount"); + for (var i = 0; i < compo.length; i++) { + var b = {label: userName, value: parseInt(compo[i].value, 10)} + var ret = _.findWhere(mainObj, {key: compo[i].name}); + if (ret) { + ret.values.push(b); + } else { + mainObj.push({ + key: compo[i].name, + values: [b], + color: Utils.getRandomColor(compo[i].name) + }); + } + } + }); + return { + max: len, + arr: mainObj } - - ViewUtil.scrollToElement = function(top, speed){ - if(!top) - return; - $("html, body").animate({ scrollTop : (top -200) }, (speed) ? speed : 300); - }; - - ViewUtil.formatAuditGraphData = function(collection){ - var mainObj = [],len=0,that=this; - collection.each(function(m,index){ - var userName = m.get("name"); - if(len < userName.length ) - len = userName.length; - var compo = m.get("dataCount"); - for(var i=0;i < compo.length; i++){ - var b = {label:userName,value:parseInt(compo[i].value,10)} - var ret = _.findWhere(mainObj,{key:compo[i].name}); - if(ret){ - ret.values.push(b); - }else{ - mainObj.push({ - key : compo[i].name, - values : [b], - color : Utils.getRandomColor(compo[i].name) - }); - } - } - }); - return { - max : len, - arr : mainObj - } + }; + + /** + * Generate sorted named schema field list for service/audit logs + * @param data Response data + * @param fieldMappings Solr field - UI field mapping + * @param excludes Array of fields that needs to be filtered out on UI + * @returns sorted schema field list (human readable format) + */ + ViewUtil.getLogSchemaFields = function(data, fieldMappings, excludes) { + var jsonData = {}; + for (var key in data) { + if ($.inArray(key.toString(), excludes) == -1) { + if (fieldMappings.hasOwnProperty(key)) { + jsonData[key] = fieldMappings[key]; + } else { + jsonData[key] = key; + } + } } + return _.sortBy(jsonData, function(k, v){return k}); + }; + + + ViewUtil.replaceColumnNamesWithKeys = function (collection, nameKeyMap, addingAstrik) { + var result = []; + collection.each(function (m) { + var data = {}; + var value = addingAstrik == true ? Utils.manipulateValueForAddingAstrik(m.get("value")) : m.get("value"); + if (nameKeyMap[m.get("category")] === undefined) { + data[m.get("category")] = m.get("value"); + } else { + data[nameKeyMap[m.get("category")]] = m.get("value"); + } + result.push(data); + }); + return result; + }; - return ViewUtil; + return ViewUtil; }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditTabLayoutView.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditTabLayoutView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditTabLayoutView.js index a399cbf..4e09e88 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditTabLayoutView.js +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditTabLayoutView.js @@ -1,459 +1,429 @@ /** -* 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. -*/ + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ define(['require', - 'backbone', - 'utils/Globals', - 'utils/Utils', - 'utils/ViewUtils', - 'collections/VGroupList', - 'collections/VAuditLogList', - 'models/VAuditLog', - 'hbs!tmpl/audit/AuditTabLayoutView_tmpl', - 'moment' -],function(require,Backbone,Globals,Utils,ViewUtils,VGroupList,VAuditLogList,VAuditLog,AuditTabLayoutViewTmpl,moment){ + 'backbone', + 'utils/Globals', + 'utils/Utils', + 'utils/ViewUtils', + 'collections/VGroupList', + 'collections/VAuditLogList', + 'models/VAuditLog', + 'hbs!tmpl/audit/AuditTabLayoutView_tmpl', + 'moment' +], function (require, Backbone, Globals, Utils, ViewUtils, VGroupList, VAuditLogList, VAuditLog, AuditTabLayoutViewTmpl, moment) { - 'use strict'; + 'use strict'; - return Backbone.Marionette.Layout.extend( - /** @lends LogLevelView */ - { - _viewName : 'AuditTabLayoutView', + return Backbone.Marionette.Layout.extend( + { + _viewName: 'AuditTabLayoutView', - template: AuditTabLayoutViewTmpl, + template: AuditTabLayoutViewTmpl, - /** Layout sub regions */ - regions: { - RAuditTable : "[data-id='auditTable']", - RVisualSearch : "#r_vsSearch", - RVisualSearchInc : "#r_vsSearchInc", - RVisualSearchEx : "#r_vsSearchEx", - RAuditLine : "#r_AuditLine", - RAuditAggregated : "[data-id='auditAggregated']", - }, + /** Layout sub regions */ + regions: { + RAuditTable: "[data-id='auditTable']", + RVisualSearch: "#r_vsSearch", + RVisualSearchInc: "#r_vsSearchInc", + RVisualSearchEx: "#r_vsSearchEx", + RAuditLine: "#r_AuditLine", + RAuditAggregated: "[data-id='auditAggregated']", + }, - /** ui selector cache */ - ui: { - viewType: "input[name='viewTypeAudit']", - excludeComponents : "#excludeComponents", - includeComponents : "#includeComponents", - collapseArrowClick : "a.collapse-link.chkArrow" - }, + /** ui selector cache */ + ui: { + viewType: "input[name='viewTypeAudit']", + excludeComponents: "#excludeComponents", + includeComponents: "#includeComponents", + collapseArrowClick: "a.collapse-link.chkArrow" + }, - /** ui events hash */ - events: function() { - var events = {}; - events['click [data-id="refresh-tab-audit"]'] = 'onAuditTabRefresh'; - events['change ' + this.ui.viewType] = 'onViewTypeChange'; - events['click ' +this.ui.collapseArrowClick] = function(e){ - if($(e.currentTarget).find('i').hasClass('fa-chevron-down')){ - if(this.RAuditAggregated.currentView){ - this.RAuditAggregated.currentView.trigger("button:min:max"); - } - } - } - return events; - }, + /** ui events hash */ + events: function () { + var events = {}; + events['click [data-id="refresh-tab-audit"]'] = 'onAuditTabRefresh'; + events['change ' + this.ui.viewType] = 'onViewTypeChange'; + events['click ' + this.ui.collapseArrowClick] = function (e) { + if ($(e.currentTarget).find('i').hasClass('fa-chevron-down')) { + if (this.RAuditAggregated.currentView) { + this.RAuditAggregated.currentView.trigger("button:min:max"); + } + } + }; + return events; + }, + initialize: function (options) { + _.extend(this, _.pick(options, 'globalVent')); + this.defaultParams = ViewUtils.getDefaultParamsForHierarchy(); + delete this.defaultParams.level; + this.vent = new Backbone.Wreqr.EventAggregator(); + this.initializeCollections(); + this.columns = []; + this.bindEvents(); + }, + initializeCollections: function () { + this.auditModel = new VAuditLog(); + this.collection = new VAuditLogList([], { + state: { + firstPage: 0, + pageSize: 25 + } + }); - /** - * intialize a new LogLevelView Layout - * @constructs - */ - initialize: function(options) { - _.extend(this, _.pick(options,'globalVent')); - this.defaultParams = ViewUtils.getDefaultParamsForHierarchy(); - delete this.defaultParams.level; - this.vent = new Backbone.Wreqr.EventAggregator(); - this.initializeCollections(); - this.columns = []; - this.bindEvents(); - }, - initializeCollections : function(){ - this.auditModel = new VAuditLog(); - this.collection = new VAuditLogList([],{ - state: { - firstPage: 0, - pageSize: 25 - } - }); + this.componentsList = new VGroupList([], { + state: { + firstPage: 0, + pageSize: 99999 + } + }); + this.componentsList.url = Globals.baseURL + "audit/logs/components"; + }, + bindEvents: function () { + this.listenTo(this.componentsList, "reset", function (col, abc) { + this.setupSelect2Fields(col, "type", 'type', 'excludeComponents', 'Exclude Components'); + this.setupSelect2Fields(col, "type", 'type', 'includeComponents', 'Include Components'); + }, this); + this.listenTo(this.vent, "search:audit:query auditComponents:include auditComponents:exclude search:audit:include search:audit:exclude logtime:filter", function (value) { + _.extend(this.defaultParams, value); + this.fetchAuditLogs(value); + }, this); + this.listenTo(this.vent, "reinitialize:filter:mustBe", function (value) { + this.reinitializeFilterMustBe(value); + }, this); + this.listenTo(this.vent, "reinitialize:filter:mustNot", function (value) { + this.reinitializeFilterMustNot(value); + }, this); - this.componentsList = new VGroupList([],{ - state: { - firstPage: 0, - pageSize: 99999 - } - }); - this.componentsList.url = Globals.baseURL + "audit/logs/components"; - }, - bindEvents : function(){ - this.listenTo(this.componentsList, "reset", function(col, abc){ - this.setupSelect2Fields(col,"type", 'type', 'excludeComponents', 'Exclude Components'); - this.setupSelect2Fields(col,"type", 'type', 'includeComponents', 'Include Components'); - }, this); - this.listenTo(this.vent,"search:audit:query auditComponents:include auditComponents:exclude search:audit:include search:audit:exclude logtime:filter",function(value){ - _.extend(this.defaultParams,value); - this.fetchAuditLogs(value); - }, this); - this.listenTo(this.vent,"reinitialize:filter:mustBe",function(value){ - this.reinitializeFilterMustBe(value); - },this); - this.listenTo(this.vent,"reinitialize:filter:mustNot",function(value){ - this.reinitializeFilterMustNot(value); - },this); + this.listenTo(this.globalVent, "reinitialize:auditLogs", function (options) { + this.vent.trigger("reinitialize:filter:mustNot reinitialize:filter:mustBe reinitialize:filter:logtime " + + "reinitialize:TopTenGraph", options); + this.fetchAuditLogs(options); + }, this); - this.listenTo(this.globalVent,"reinitialize:auditLogs",function(options){ - this.vent.trigger("reinitialize:filter:mustNot reinitialize:filter:mustBe reinitialize:filter:logtime "+ - "reinitialize:TopTenGraph",options); - this.fetchAuditLogs(options); - },this); + }, + onRender: function () { + this.renderHistogram(); + this.renderAuditAggregatedInfo(); + this.fetchAuditColumns(); + this.fetchAuditLogs((this.defaultParams) ? this.defaultParams : {q: "*:*"}); + this.componentsList.fetch({reset: true}); + }, + renderHistogram: function () { + var that = this; + require(['views/graphs/GraphLayoutView'], function (GraphLayoutView) { + that.RAuditLine.show(new GraphLayoutView({ + vent: that.vent, + globalVent: that.globalVent, + params: that.defaultParams, + viewType: Globals.graphType.MULTILINE.value, + showDatePicker: true, + futureDate: false + })); + }) + }, + renderAuditAggregatedInfo: function () { + var that = this; + require(['views/audit/AuditAggregatedView'], function (AuditAggregatedView) { + that.RAuditAggregated.show(new AuditAggregatedView({ + vent: that.vent, + globalVent: that.globalVent, + params: that.defaultParams + })); + }) - }, - onRender : function(){ - this.renderHistogram(); - this.renderAuditAggregatedInfo(); - this.fetchAuditColumns(); - this.fetchAuditLogs((this.defaultParams) ? this.defaultParams : {q:"*:*"}); - this.componentsList.fetch({reset:true}); - //this.startPoll(); - }, - renderHistogram : function(){ - var that = this; - require(['views/graphs/GraphLayoutView'],function(GraphLayoutView){ - that.RAuditLine.show(new GraphLayoutView({ - vent : that.vent, - globalVent:that.globalVent, - params : that.defaultParams, - //parentView : this, - viewType : Globals.graphType.MULTILINE.value, - showDatePicker:true, - futureDate : false - })); - }) - }, - renderAuditAggregatedInfo : function(){ - var that = this; - require(['views/audit/AuditAggregatedView'],function(AuditAggregatedView){ - that.RAuditAggregated.show(new AuditAggregatedView({ - vent : that.vent, - globalVent:that.globalVent, - params : that.defaultParams - })); - }) + }, + fetchAuditColumns: function () { + var that = this; + this.collection.getAuditSchemaFieldsName({}, { + beforeSend: function () { + that.$("#loaderAudit").show(); + }, + success: function (data) { + that.columns = ViewUtils.getLogSchemaFields(data, Globals.defaultAuditLogMappings, Globals.defaultAuditLogExcludes); + }, + error: function (error, data, status) { + var obj = JSON.parse(error.responseText); + if (obj) + Utils.notifyError({content: obj.msgDesc}); + }, + complete: function () { + that.renderAuditTable(); + that.renderVSSearch(); + that.$("#loaderAudit").hide(); + } + }); + }, + fetchAuditLogs: function (params) { + $.extend(this.collection.queryParams, params); + this.collection.getFirstPage({reset: true}); + }, + renderVSSearch: function () { + var that = this; + require(['views/tabs/VisualSearchView'], function (VisualSearchView) { - }, - fetchAuditColumns : function(){ - var that =this; - this.collection.getAuditSchemaFieldsName({},{ - beforeSend : function(){ - that.$("#loaderAudit").show(); - }, - success : function(data){ - that.columns = data; - }, - error : function(error,data,status){ - var obj = JSON.parse(error.responseText); - if(obj) - Utils.notifyError({content:obj.msgDesc}); - }, - complete : function(){ - that.renderAuditTable(); - that.renderVSSearch(); - that.$("#loaderAudit").hide(); - } - }); - }, - fetchAuditLogs : function(params){ - $.extend(this.collection.queryParams,params); - this.collection.getFirstPage({reset:true}); - }, - renderVSSearch : function(){ - var that = this; - require(['views/tabs/VisualSearchView'], function(VisualSearchView){ - - _.each(that.columns,function(v,i){ - if(v.toLowerCase().indexOf("time") > 0 ){ - //that.columns.splice(i, 1); - delete that.columns[v] - } - }); - that.RVisualSearchInc.show(new VisualSearchView({ - viewName : "includeColumns", - placeholder : "Include Search", - vent : that.vent, - globalVent:that.globalVent, - customOptions : _.values(that.columns), - eventName : "search:audit:include", - myFormatData : function(query,searchCollection){ - var obj=[]; - searchCollection.each(function(m){ - var data = {}; - data[m.get("category")] = Utils.manipulateValueForAddingAstrik(m.get("value")); - obj.push(data); - }); - return { - includeQuery : JSON.stringify(obj), - query : query - } - } - })); - that.RVisualSearchEx.show(new VisualSearchView({ - placeholder : "Exclude Search", - vent : that.vent, - globalVent:that.globalVent, - customOptions : _.values(that.columns), - eventName : "search:audit:exclude", - myFormatData : function(query,searchCollection){ - var obj=[]; - searchCollection.each(function(m){ - var data = {}; - data[m.get("category")] = Utils.manipulateValueForAddingAstrik(m.get("value")); - obj.push(data); - }); - return { - excludeQuery : JSON.stringify(obj), - query : query - } - } - })); - }); - }, - renderAuditTable : function(){ - var that = this; - require(['views/common/TableLayout'], function(TableLayout){ - var cols = new Backgrid.Columns(that.getColumns()); - that.RAuditTable.show(new TableLayout({ - columns: cols, - collection: that.collection, - includeFilter : false, - includePagination : true, - includePageSize : true, - includeFooterRecords : true, - includeColumnManager : true, - columnOpts : { - initialColumnsVisible: 9, - saveState : false - }, - gridOpts : { - className : "table table-bordered table-hover table-condensed backgrid", - emptyText : 'No records found!' - }, - filterOpts : {}, - paginatorOpts : {} - })); - }); - }, - getColumns : function(){ - var cols = {}; - var that = this; - _.each(this.columns,function(value,col){ - cols[col] = { - label:value, - cell: "String", - sortType: 'toggle', - editable: false, - } - }); - var columns = { - evtTime : { - label : "Event Time", - cell: "String", - sortType: 'toggle', - editable: false, - formatter: _.extend({}, Backgrid.CellFormatter.prototype, { - fromRaw: function(rawValue, model){ - return moment(rawValue).format("YYYY-MM-DD HH:mm:ss,SSS"); - } - }) - }, - reqUser : { - label : "User", - cell: "String", - sortType: 'toggle', - editable: false - }, - repo : { - label : 'Repo', - cell: "String", - sortType: 'toggle', - editable:false - }, - resource : { - label : 'Resource', - cell: "String", - sortType: 'toggle', - editable:false - }, - access : { - label : 'Access Type', - cell: "String", - sortType: 'toggle', - editable:false - }, - result : { - label : 'Result', - cell: "String", - sortType: 'toggle', - editable:false, - formatter: _.extend({}, Backgrid.CellFormatter.prototype, { - fromRaw: function(rawValue, model){ - return (rawValue === 1) ? "Allowed" : "Denied"; - } - }) - }, - enforcer : { - label : 'Access Enforcer', - cell: "String", - sortType: 'toggle', - editable:false - }, - cliIP : { - label : 'Client IP', - cell: "String", - sortType: 'toggle', - editable:false - }, - event_count : { - label : 'Event Count', - cell: "String", - sortType: 'toggle', - editable:false - } - }; - _.each(cols,function(c,k){ - if(columns[k] == undefined && k != "_version_"){ - columns[k] = c; - }else{ - if(columns[k] && columns[k].label){ - columns[k].label = c.label; - } - } - }) - /*_.each(columns,function(c,k){ - if(columns[k] == undefined && k != "_version_"){ - columns[k] = c; - } - })*/ - return this.collection.constructor.getTableCols(columns, this.collection); - }, - onAuditTabRefresh : function(e){ - ViewUtils.setLatestTimeParams(this.defaultParams); - //this.fetchAuditColumns(); - $.extend(this.collection.queryParams,this.defaultParams); - this.collection.fetch({reset:true}); - this.vent.trigger("tab:refresh",this.defaultParams); - }, - onViewTypeChange: function(e){ - var that = this; - var val = that.$("[name='viewTypeAudit']:checked").val(); - this.toggleViewType(val); - }, - toggleViewType : function(val){ - if(val === "A"){ - this.$("[data-id='auditTable']").show(); - this.$('[data-id="auditAggregated"]').hide(); - }else{ - this.$('[data-id="auditAggregated"]').show(); - this.$("[data-id='auditTable']").hide(); - if(this.RAuditAggregated.currentView) - this.RAuditAggregated.currentView.$el.resize(); - } - }, - setupSelect2Fields : function(col, idKey, textKey, selectTagId, placeHolder){ - var that = this, data = []; - data = _.pluck(col.models, 'attributes'); -// data = data.map(function(obj){ -// return {id : obj[idKey], text : obj[textKey]} -// }) - //data.unshift({'id': null, 'text': null}); - for(var i=0;i < data.length;i++){ - data[i].id = data[i].type; - } - this.ui[selectTagId].select2({ - placeholder: (placeHolder) ? placeHolder :'Select', - tags:true, - allowClear : true, - width: '100%', - data: { results: data, text: textKey}, - formatSelection: function(item){ - return item[textKey]; - }, - formatResult: function(item){ - return item[textKey]; - } - }).on("change",function(e){ - var data = that.ui[selectTagId].select2("data").map(function(d){return d.type}); - if(selectTagId === "excludeComponents"){ - that.vent.trigger("auditComponents:exclude",{mustNot:data.toString()}); - } - if(selectTagId === "includeComponents") - that.vent.trigger("auditComponents:include",{mustBe:data.toString()}); - }); - }, - startPoll : function(){ - var that = this; - setInterval(function(){ - that.pollLiveFeed(); - },5000); - }, - pollLiveFeed : function(){ - var that = this; - if(this.pollXhr){ - if(this.pollXhr.readyState > 0 && this.pollXhr.readyState < 4) - return - } - this.pollXhr = this.auditModel.auditLiveFeed({},{ - beforeSend : function(){ - that.$("#loaderFeed").show(); - }, - success : function(data){ - var dd=[]; - that.$("#spark").parent().show(); - _.each(data.vnameValues,function(d){ - dd.push(d.value); - }); - that.$("#spark").sparkline(dd, {lineColor: '#5A8DB6',width:"100px", - /*tooltipFormatter : function(){ - console.log(arguments) - }*/}); - }, - error : function(){ - that.$("#spark").parent().hide(); - }, - complete : function(){ - setTimeout(function(){ - that.$("#loaderFeed").hide(); - },1000); - } - }); - }, - reinitializeFilterMustBe : function(values){ - if(values.mustBe){ - this.ui.includeComponents.select2('val',values.mustBe.split(",")); - }else{ - this.ui.includeComponents.select2('val',[]); - } - }, - reinitializeFilterMustNot : function(values){ - if(values.mustNot){ - this.ui.excludeComponents.select2('val',values.mustNot.split(",")); - }else{ - this.ui.excludeComponents.select2('val',[]); - } - } - }); + _.each(that.columns, function (v, i) { + if (v.toLowerCase().indexOf("time") > 0) { + delete that.columns[v] + } + }); + that.RVisualSearchInc.show(new VisualSearchView({ + viewName: "includeColumns", + placeholder: "Include Search", + vent: that.vent, + globalVent: that.globalVent, + customOptions: _.values(that.columns), + eventName: "search:audit:include", + myFormatData: function (query, searchCollection) { + var obj = ViewUtils.replaceColumnNamesWithKeys(searchCollection, Globals.invertedAuditLogMappings, true); + return { + includeQuery: JSON.stringify(obj), + query: query + } + } + })); + that.RVisualSearchEx.show(new VisualSearchView({ + placeholder: "Exclude Search", + vent: that.vent, + globalVent: that.globalVent, + customOptions: _.values(that.columns), + eventName: "search:audit:exclude", + myFormatData: function (query, searchCollection) { + var obj = ViewUtils.replaceColumnNamesWithKeys(searchCollection, Globals.invertedAuditLogMappings, true); + return { + excludeQuery: JSON.stringify(obj), + query: query + } + } + })); + }); + }, + renderAuditTable: function () { + var that = this; + require(['views/common/TableLayout'], function (TableLayout) { + var cols = new Backgrid.Columns(that.getColumns()); + that.RAuditTable.show(new TableLayout({ + columns: cols, + collection: that.collection, + includeFilter: false, + includePagination: true, + includePageSize: true, + includeFooterRecords: true, + includeColumnManager: true, + columnOpts: { + initialColumnsVisible: 9, + saveState: false + }, + gridOpts: { + className: "table table-bordered table-hover table-condensed backgrid", + emptyText: 'No records found!' + }, + filterOpts: {}, + paginatorOpts: {} + })); + }); + }, + getColumns: function () { + var cols = {}; + var that = this; + var columns = { + evtTime: { + label: "Event Time", + cell: "String", + sortType: 'toggle', + editable: false, + formatter: _.extend({}, Backgrid.CellFormatter.prototype, { + fromRaw: function (rawValue, model) { + return moment(rawValue).format("YYYY-MM-DD HH:mm:ss,SSS"); + } + }) + }, + reqUser: { + label: "User", + cell: "String", + sortType: 'toggle', + editable: false + }, + repo: { + label: 'Repo', + cell: "String", + sortType: 'toggle', + editable: false + }, + resource: { + label: 'Resource', + cell: "String", + sortType: 'toggle', + editable: false + }, + access: { + label: 'Access Type', + cell: "String", + sortType: 'toggle', + editable: false + }, + result: { + label: 'Result', + cell: "String", + sortType: 'toggle', + editable: false, + formatter: _.extend({}, Backgrid.CellFormatter.prototype, { + fromRaw: function (rawValue, model) { + return (rawValue === 1) ? "Allowed" : "Denied"; + } + }) + }, + enforcer: { + label: 'Access Enforcer', + cell: "String", + sortType: 'toggle', + editable: false + }, + cliIP: { + label: 'Client IP', + cell: "String", + sortType: 'toggle', + editable: false + }, + event_count: { + label: 'Event Count', + cell: "String", + sortType: 'toggle', + editable: false + } + }; + _.each(this.columns, function(value){ + var name = Globals.invertedAuditLogMappings[value]; + if (columns[name] === undefined && value != "_version_") { + var columnObj = { + name: Globals.invertedAuditLogMappings[value], + label:value, + cell: "String", + sortType: 'toggle', + editable: false + }; + columns[name] = columnObj; + } else { + if (columns[name] && columns[name].label) { + columns[name].label = value; + } + } + }); + return this.collection.constructor.getTableCols(columns, this.collection); + }, + onAuditTabRefresh: function (e) { + ViewUtils.setLatestTimeParams(this.defaultParams); + $.extend(this.collection.queryParams, this.defaultParams); + this.collection.fetch({reset: true}); + this.vent.trigger("tab:refresh", this.defaultParams); + }, + onViewTypeChange: function (e) { + var that = this; + var val = that.$("[name='viewTypeAudit']:checked").val(); + this.toggleViewType(val); + }, + toggleViewType: function (val) { + if (val === "A") { + this.$("[data-id='auditTable']").show(); + this.$('[data-id="auditAggregated"]').hide(); + } else { + this.$('[data-id="auditAggregated"]').show(); + this.$("[data-id='auditTable']").hide(); + if (this.RAuditAggregated.currentView) + this.RAuditAggregated.currentView.$el.resize(); + } + }, + setupSelect2Fields: function (col, idKey, textKey, selectTagId, placeHolder) { + var that = this, data = []; + data = _.pluck(col.models, 'attributes'); + for (var i = 0; i < data.length; i++) { + data[i].id = data[i].type; + } + this.ui[selectTagId].select2({ + placeholder: (placeHolder) ? placeHolder : 'Select', + tags: true, + allowClear: true, + width: '100%', + data: {results: data, text: textKey}, + formatSelection: function (item) { + return item[textKey]; + }, + formatResult: function (item) { + return item[textKey]; + } + }).on("change", function (e) { + var data = that.ui[selectTagId].select2("data").map(function (d) { + return d.type + }); + if (selectTagId === "excludeComponents") { + that.vent.trigger("auditComponents:exclude", {mustNot: data.toString()}); + } + if (selectTagId === "includeComponents") + that.vent.trigger("auditComponents:include", {mustBe: data.toString()}); + }); + }, + startPoll: function () { + var that = this; + setInterval(function () { + that.pollLiveFeed(); + }, 5000); + }, + pollLiveFeed: function () { + var that = this; + if (this.pollXhr) { + if (this.pollXhr.readyState > 0 && this.pollXhr.readyState < 4) + return + } + this.pollXhr = this.auditModel.auditLiveFeed({}, { + beforeSend: function () { + that.$("#loaderFeed").show(); + }, + success: function (data) { + var dd = []; + that.$("#spark").parent().show(); + _.each(data.vnameValues, function (d) { + dd.push(d.value); + }); + that.$("#spark").sparkline(dd, {lineColor: '#5A8DB6', width: "100px"}); + }, + error: function () { + that.$("#spark").parent().hide(); + }, + complete: function () { + setTimeout(function () { + that.$("#loaderFeed").hide(); + }, 1000); + } + }); + }, + reinitializeFilterMustBe: function (values) { + if (values.mustBe) { + this.ui.includeComponents.select2('val', values.mustBe.split(",")); + } else { + this.ui.includeComponents.select2('val', []); + } + }, + reinitializeFilterMustNot: function (values) { + if (values.mustNot) { + this.ui.excludeComponents.select2('val', values.mustNot.split(",")); + } else { + this.ui.excludeComponents.select2('val', []); + } + } + }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/CustomBackgrid.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/CustomBackgrid.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/CustomBackgrid.js index e43f239..83b756b 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/CustomBackgrid.js +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/CustomBackgrid.js @@ -252,7 +252,6 @@ define(['require', initialize: function (options) { var args = Array.prototype.slice.apply(arguments); Backgrid.Header.prototype.initialize.apply(this, args); - this.searchRow = new HeaderRow({ columns: this.columns, collection: this.collection http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/Header.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/Header.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/Header.js index e88afea..1e469d5 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/Header.js +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/Header.js @@ -339,12 +339,8 @@ define(['require', var gMessage = logMessagesList.map(function(e) { return e.message - }) - this.setNotificationCount(componentList.length, gMessage.length); - this.globalVent.trigger("globalExclusion:component:message", { - gMustNot: (componentList.length != 0) ? (componentList.join()) : (""), - gEMessage: (gMessage.length != 0) ? (gMessage.join(Globals.splitToken)) : ("") }); + this.setNotificationCount(componentList.length, gMessage.length); }, /** closing the movable/resizable popup */ onDialogClosed: function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/c15ed8b7/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/ProfileBar.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/ProfileBar.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/ProfileBar.js index f46d94b..0cdef28 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/ProfileBar.js +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/ProfileBar.js @@ -22,9 +22,8 @@ define(['require', 'backbone', 'App', 'communicator', - 'mgrs/SessionMgr', 'hbs!tmpl/common/ProfileBar_tmpl' -],function(require,Backbone,App,Communicator,SessionMgr,ProfileBar_tmpl){ +],function(require,Backbone,App,Communicator,ProfileBar_tmpl){ 'use strict'; var ProfileBar = Backbone.Marionette.ItemView.extend(