diff --git a/README.md b/README.md index 3963fdfe..110887ad 100644 --- a/README.md +++ b/README.md @@ -52,21 +52,23 @@ pig-ui -- https://github.com/pigxcloud/pig-ui pig ├── pig-auth -- oauth-server[3000] -├── pig-codegen -- graphical code generation[5002] └── pig-common ├── pig-common-core -- tool core package ├── pig-common-datasource -- dynamic data source package ├── pig-common-log -- Log service package ├── pig-common-mybatis -- mybatis expand ├── pig-common-security -- security tools - └── pig-common-swagger -- api documentation + ├── pig-common-swagger -- api documentation + └── pig-common-sentinel -- sentinel auto fallbak ├── pig-register -- nacos server[8848] ├── pig-gateway -- spring cloud gateway[9999] -├── pig-monitor -- spring boot admin[5001] └── pig-upms └── pig-upms-api -- user management system api └── pig-upms-biz -- user management system biz[4000] - +└── pig-visual + └── pig-monitor -- spring boot admin[5001] + ├── pig-codegen -- graphical code generation[5002] + └── pig-sentinel-dashboard -- sentinel dashboard [5003] ``` #### Open source co-construction diff --git a/README.zh.md b/README.zh.md index 32b5f7a0..09b21627 100644 --- a/README.zh.md +++ b/README.zh.md @@ -50,21 +50,23 @@ pig-ui -- https://gitee.com/log4j/pig-ui pig ├── pig-auth -- 授权服务提供[3000] -├── pig-codegen -- 图形化代码生成[5002] └── pig-common -- 系统公共模块 ├── pig-common-core -- 公共工具类核心包 ├── pig-common-datasource -- 动态数据源包 ├── pig-common-log -- 日志服务 ├── pig-common-mybatis -- mybatis 扩展封装 ├── pig-common-security -- 安全工具类 - └── pig-common-swagger -- 接口文档 + ├── pig-common-swagger -- 接口文档 + └── pig-common-sentinel -- sentinel 扩展封装 ├── pig-register -- Nacos Server[8848] ├── pig-gateway -- Spring Cloud Gateway网关[9999] -├── pig-monitor -- Spring Boot Admin监控 [5001] └── pig-upms -- 通用用户权限管理模块 └── pig-upms-api -- 通用用户权限管理系统公共api模块 └── pig-upms-biz -- 通用用户权限管理系统业务处理模块[4000] - +└── pig-visual + └── pig-monitor -- 服务监控 [5001] + ├── pig-codegen -- 图形化代码生成 [5002] + └── pig-sentinel-dashboard -- 流量高可用 [5003] ``` #### 开源共建 diff --git a/db/pig_config.sql b/db/pig_config.sql index 9f0fcc69..59183d0a 100644 --- a/db/pig_config.sql +++ b/db/pig_config.sql @@ -36,7 +36,7 @@ CREATE TABLE `config_info` ( -- Records of config_info -- ---------------------------- BEGIN; -INSERT INTO `config_info` VALUES (1, 'application-dev.yml', 'DEFAULT_GROUP', '# 加解密根密码\njasypt:\n encryptor:\n password: pig #根密码\n\n# Spring 相关\nspring:\n redis:\n password:\n host: pig-redis\n\n# 暴露监控端点\nmanagement:\n endpoints:\n web:\n exposure:\n include: \'*\'\n\n# feign 配置\nfeign:\n hystrix:\n enabled: true\n okhttp:\n enabled: true\n httpclient:\n enabled: false\n client:\n config:\n default:\n connectTimeout: 10000\n readTimeout: 10000\n compression:\n request:\n enabled: true\n response:\n enabled: true\n\n# hystrix 配置\nhystrix:\n command:\n default:\n execution:\n isolation:\n strategy: SEMAPHORE\n thread:\n timeoutInMilliseconds: 60000\n shareSecurityContext: true\n\n#请求处理的超时时间\nribbon:\n ReadTimeout: 10000\n ConnectTimeout: 10000\n\n# mybaits-plus配置\nmybatis-plus:\n mapper-locations: classpath:/mapper/*Mapper.xml\n global-config:\n banner: false\n db-config:\n id-type: auto\n table-underline: true\n logic-delete-value: 1\n logic-not-delete-value: 0\n configuration:\n map-underscore-to-camel-case: true\n\n# spring security 配置\nsecurity:\n oauth2:\n resource:\n loadBalanced: true\n token-info-uri: http://pig-auth/oauth/check_token\n # 通用放行URL,服务个性化,请在对应配置文件覆盖\n ignore:\n urls:\n - /v2/api-docs\n - /actuator/**\n# swagger 配置\nswagger:\n title: Pig Swagger API\n license: Powered By pig4cloud\n licenseUrl: https://pig4cloud.com\n terms-of-service-url: https://pig4cloud.com\n contact:\n email: wangiegie@gmail.com\n url: https://pig4cloud.com\n authorization:\n name: pig4cloud OAuth\n auth-regex: ^.*$\n authorization-scope-list:\n - scope: server\n description: server all\n token-url-list:\n - http://${GATEWAY_HOST:pig-gateway}:${GATEWAY-PORT:9999}/auth/oauth/token', '08678a260d44e4ca86b23829076cec98', '2019-11-29 16:31:20', '2020-03-14 16:27:14', NULL, '172.17.0.125', '', '', '通用配置', 'null', 'null', 'yaml', 'null'); +INSERT INTO `config_info` VALUES (1, 'application-dev.yml', 'DEFAULT_GROUP', '# 加解密根密码\njasypt:\n encryptor:\n password: pig #根密码\n\n# Spring 相关\nspring:\n redis:\n password:\n host: pig-redis\n cloud:\n sentinel:\n eager: true\n transport:\n dashboard: pig-sentinel:5003\n\n# 暴露监控端点\nmanagement:\n endpoints:\n web:\n exposure:\n include: \'*\'\n\n# feign 配置\nfeign:\n sentinel:\n enabled: true\n okhttp:\n enabled: true\n httpclient:\n enabled: false\n client:\n config:\n default:\n connectTimeout: 10000\n readTimeout: 10000\n compression:\n request:\n enabled: true\n response:\n enabled: true\n\n#请求处理的超时时间\nribbon:\n ReadTimeout: 10000\n ConnectTimeout: 10000\n\n# mybaits-plus配置\nmybatis-plus:\n mapper-locations: classpath:/mapper/*Mapper.xml\n global-config:\n banner: false\n db-config:\n id-type: auto\n table-underline: true\n logic-delete-value: 1\n logic-not-delete-value: 0\n configuration:\n map-underscore-to-camel-case: true\n\n# spring security 配置\nsecurity:\n oauth2:\n resource:\n loadBalanced: true\n token-info-uri: http://pig-auth/oauth/check_token\n # 通用放行URL,服务个性化,请在对应配置文件覆盖\n ignore:\n urls:\n - /v2/api-docs\n - /actuator/**\n# swagger 配置\nswagger:\n title: Pig Swagger API\n license: Powered By pig4cloud\n licenseUrl: https://pig4cloud.com\n terms-of-service-url: https://pig4cloud.com\n contact:\n email: wangiegie@gmail.com\n url: https://pig4cloud.com\n authorization:\n name: pig4cloud OAuth\n auth-regex: ^.*$\n authorization-scope-list:\n - scope: server\n description: server all\n token-url-list:\n - http://${GATEWAY_HOST:pig-gateway}:${GATEWAY-PORT:9999}/auth/oauth/token', '841de89cde20a1a045f46001f9a89266', '2019-11-29 16:31:20', '2020-06-11 16:28:09', NULL, '127.0.0.1', '', '', '通用配置', 'null', 'null', 'yaml', 'null'); INSERT INTO `config_info` VALUES (2, 'pig-auth-dev.yml', 'DEFAULT_GROUP', '# 数据源\nspring:\n datasource:\n type: com.zaxxer.hikari.HikariDataSource\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: root\n password: root\n url: jdbc:mysql://pig-mysql:3306/pig?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai\n freemarker:\n allow-request-override: false\n allow-session-override: false\n cache: true\n charset: UTF-8\n check-template-location: true\n content-type: text/html\n enabled: true\n expose-request-attributes: false\n expose-session-attributes: false\n expose-spring-macro-helpers: true\n prefer-file-system-access: true\n suffix: .ftl\n template-loader-path: classpath:/templates/', '58b1b48a2888f49e667864be32edf9c1', '2019-11-29 16:31:48', '2020-01-01 18:30:58', NULL, '127.0.0.1', '', '', '认证中心配置', 'null', 'null', 'yaml', 'null'); INSERT INTO `config_info` VALUES (3, 'pig-codegen-dev.yml', 'DEFAULT_GROUP', '## spring security 配置\nsecurity:\n oauth2:\n client:\n client-id: ENC(27v1agvAug87ANOVnbKdsw==)\n client-secret: ENC(VbnkopxrwgbFVKp+UxJ2pg==)\n scope: server\n\n# 数据源配置\nspring:\n datasource:\n type: com.zaxxer.hikari.HikariDataSource\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: root\n password: root\n url: jdbc:mysql://pig-mysql:3306/pig_codegen?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai\n resources:\n static-locations: classpath:/static/,classpath:/views/\n\n# 直接放行URL\nignore:\n urls:\n - /v2/api-docs\n - /actuator/**\n', 'abc702838b34d11b46e96143ccd9f367', '2019-11-29 16:32:12', '2019-11-29 16:32:12', NULL, '127.0.0.1', '', '', '代码生成配置', NULL, NULL, 'yaml', NULL); INSERT INTO `config_info` VALUES (4, 'pig-gateway-dev.yml', 'DEFAULT_GROUP', 'spring:\n cloud:\n gateway:\n locator:\n enabled: true\n routes:\n # 认证中心\n - id: pig-auth\n uri: lb://pig-auth\n predicates:\n - Path=/auth/**\n filters:\n # 验证码处理\n - ValidateCodeGatewayFilter\n # 前端密码解密\n - PasswordDecoderFilter\n #UPMS 模块\n - id: pig-upms-biz\n uri: lb://pig-upms-biz\n predicates:\n - Path=/admin/**\n filters:\n # 限流配置\n - name: RequestRateLimiter\n args:\n key-resolver: \'#{@remoteAddrKeyResolver}\'\n redis-rate-limiter.replenishRate: 10\n redis-rate-limiter.burstCapacity: 20\n # 降级配置\n - name: Hystrix\n args:\n name: default\n fallbackUri: \'forward:/fallback\'\n # 代码生成模块\n - id: pig-codegen\n uri: lb://pig-codegen\n predicates:\n - Path=/gen/**\n\n\nsecurity:\n encode:\n # 前端密码密钥,必须16位\n key: \'thanks,pig4cloud\'\n\n# 不校验验证码终端\nignore:\n clients:\n - test\n', '32ce953f48c958bb869a7e3e442a4a11', '2019-11-29 16:32:42', '2019-11-29 16:32:42', NULL, '127.0.0.1', '', '', '网关配置', NULL, NULL, 'yaml', NULL); diff --git a/docker-compose.yml b/docker-compose.yml index c7e1ec37..428486ea 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -57,7 +57,7 @@ services: pig-monitor: build: - context: ./pig-monitor + context: ./pig-visual/pig-monitor restart: always ports: - 5001:5001 @@ -65,9 +65,18 @@ services: hostname: pig-monitor image: pig-monitor + pig-sentinel: + build: + context: ./pig-visual/pig-sentinel-dashboard + restart: always + image: pig-sentinel + container_name: pig-sentinel + ports: + - 5003:5003 + pig-codegen: build: - context: ./pig-codegen + context: ./pig-visual/pig-codegen restart: always container_name: pig-codegen hostname: pig-codegen diff --git a/pig-auth/pom.xml b/pig-auth/pom.xml index 087c984b..d2b08bc8 100755 --- a/pig-auth/pom.xml +++ b/pig-auth/pom.xml @@ -42,6 +42,12 @@ com.alibaba.cloud spring-cloud-starter-alibaba-nacos-config + + + com.pig4cloud + pig-common-sentinel + 2.7.8.snapshot + com.pig4cloud diff --git a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/util/WebUtils.java b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/util/WebUtils.java index a49059e2..7d1ea615 100755 --- a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/util/WebUtils.java +++ b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/util/WebUtils.java @@ -24,7 +24,6 @@ import com.pig4cloud.pig.common.core.exception.CheckedException; import lombok.SneakyThrows; import lombok.experimental.UtilityClass; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.server.reactive.ServerHttpRequest; diff --git a/pig-common/pig-common-sentinel/pom.xml b/pig-common/pig-common-sentinel/pom.xml new file mode 100755 index 00000000..8728bdcf --- /dev/null +++ b/pig-common/pig-common-sentinel/pom.xml @@ -0,0 +1,31 @@ + + + + com.pig4cloud + pig-common + 2.7.8.snapshot + + + 4.0.0 + jar + pig-common-sentinel + sentinel服务降级熔断、限流组件 + + + com.pig4cloud + pig-common-core + 2.7.8.snapshot + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + diff --git a/pig-common/pig-common-sentinel/src/main/java/com/pig4cloud/pig/common/sentinel/SentinelAutoConfiguration.java b/pig-common/pig-common-sentinel/src/main/java/com/pig4cloud/pig/common/sentinel/SentinelAutoConfiguration.java new file mode 100755 index 00000000..3eb8b2e9 --- /dev/null +++ b/pig-common/pig-common-sentinel/src/main/java/com/pig4cloud/pig/common/sentinel/SentinelAutoConfiguration.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.common.sentinel; + +import com.alibaba.cloud.sentinel.feign.SentinelFeignAutoConfiguration; +import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler; +import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser; +import com.pig4cloud.pig.common.sentinel.feign.PigSentinelFeign; +import com.pig4cloud.pig.common.sentinel.handle.PigUrlBlockHandler; +import com.pig4cloud.pig.common.sentinel.parser.PigHeaderRequestOriginParser; +import feign.Feign; +import org.springframework.boot.autoconfigure.AutoConfigureBefore; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Scope; + +/** + * sentinel 配置 + * + * @author lengleng + * @date 2020-02-12 + */ +@Configuration(proxyBeanMethods = false) +@AutoConfigureBefore(SentinelFeignAutoConfiguration.class) +public class SentinelAutoConfiguration { + + @Bean + @Scope("prototype") + @ConditionalOnMissingBean + @ConditionalOnProperty(name = "feign.sentinel.enabled") + public Feign.Builder feignSentinelBuilder() { + return PigSentinelFeign.builder(); + } + + @Bean + @ConditionalOnMissingBean + public BlockExceptionHandler blockExceptionHandler() { + return new PigUrlBlockHandler(); + } + + @Bean + @ConditionalOnMissingBean + public RequestOriginParser requestOriginParser() { + return new PigHeaderRequestOriginParser(); + } +} diff --git a/pig-common/pig-common-sentinel/src/main/java/com/pig4cloud/pig/common/sentinel/feign/PigSentinelFeign.java b/pig-common/pig-common-sentinel/src/main/java/com/pig4cloud/pig/common/sentinel/feign/PigSentinelFeign.java new file mode 100644 index 00000000..e3435ec8 --- /dev/null +++ b/pig-common/pig-common-sentinel/src/main/java/com/pig4cloud/pig/common/sentinel/feign/PigSentinelFeign.java @@ -0,0 +1,142 @@ +package com.pig4cloud.pig.common.sentinel.feign; + +import com.alibaba.cloud.sentinel.feign.SentinelContractHolder; +import feign.Contract; +import feign.Feign; +import feign.InvocationHandlerFactory; +import feign.Target; +import feign.hystrix.FallbackFactory; +import org.springframework.beans.BeansException; +import org.springframework.cloud.openfeign.FeignContext; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.util.ReflectionUtils; +import org.springframework.util.StringUtils; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.util.Map; + +/** + * 支持自动降级注入 + * 重写 {@link com.alibaba.cloud.sentinel.feign.SentinelFeign} + * + * @author lengleng + * @date 2020/6/9 + */ +public final class PigSentinelFeign { + private PigSentinelFeign() { + + } + + public static PigSentinelFeign.Builder builder() { + return new PigSentinelFeign.Builder(); + } + + public static final class Builder extends Feign.Builder + implements ApplicationContextAware { + + private Contract contract = new Contract.Default(); + + private ApplicationContext applicationContext; + + private FeignContext feignContext; + + @Override + public Feign.Builder invocationHandlerFactory( + InvocationHandlerFactory invocationHandlerFactory) { + throw new UnsupportedOperationException(); + } + + @Override + public PigSentinelFeign.Builder contract(Contract contract) { + this.contract = contract; + return this; + } + + @Override + public Feign build() { + super.invocationHandlerFactory(new InvocationHandlerFactory() { + @Override + public InvocationHandler create(Target target, + Map dispatch) { + // using reflect get fallback and fallbackFactory properties from + // FeignClientFactoryBean because FeignClientFactoryBean is a package + // level class, we can not use it in our package + Object feignClientFactoryBean = PigSentinelFeign.Builder.this.applicationContext + .getBean("&" + target.type().getName()); + + Class fallback = (Class) getFieldValue(feignClientFactoryBean, + "fallback"); + Class fallbackFactory = (Class) getFieldValue(feignClientFactoryBean, + "fallbackFactory"); + String beanName = (String) getFieldValue(feignClientFactoryBean, + "contextId"); + if (!StringUtils.hasText(beanName)) { + beanName = (String) getFieldValue(feignClientFactoryBean, "name"); + } + + Object fallbackInstance; + FallbackFactory fallbackFactoryInstance; + // check fallback and fallbackFactory properties + if (void.class != fallback) { + fallbackInstance = getFromContext(beanName, "fallback", fallback, + target.type()); + return new PigSentinelInvocationHandler(target, dispatch, + new FallbackFactory.Default(fallbackInstance)); + } + if (void.class != fallbackFactory) { + fallbackFactoryInstance = (FallbackFactory) getFromContext( + beanName, "fallbackFactory", fallbackFactory, + FallbackFactory.class); + return new PigSentinelInvocationHandler(target, dispatch, + fallbackFactoryInstance); + } + return new PigSentinelInvocationHandler(target, dispatch); + } + + private Object getFromContext(String name, String type, + Class fallbackType, Class targetType) { + Object fallbackInstance = feignContext.getInstance(name, + fallbackType); + if (fallbackInstance == null) { + throw new IllegalStateException(String.format( + "No %s instance of type %s found for feign client %s", + type, fallbackType, name)); + } + + if (!targetType.isAssignableFrom(fallbackType)) { + throw new IllegalStateException(String.format( + "Incompatible %s instance. Fallback/fallbackFactory of type %s is not assignable to %s for feign client %s", + type, fallbackType, targetType, name)); + } + return fallbackInstance; + } + }); + + super.contract(new SentinelContractHolder(contract)); + return super.build(); + } + + private Object getFieldValue(Object instance, String fieldName) { + Field field = ReflectionUtils.findField(instance.getClass(), fieldName); + field.setAccessible(true); + try { + return field.get(instance); + } catch (IllegalAccessException e) { + // ignore + } + return null; + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) + throws BeansException { + this.applicationContext = applicationContext; + feignContext = this.applicationContext.getBean(FeignContext.class); + } + + } + +} diff --git a/pig-common/pig-common-sentinel/src/main/java/com/pig4cloud/pig/common/sentinel/feign/PigSentinelInvocationHandler.java b/pig-common/pig-common-sentinel/src/main/java/com/pig4cloud/pig/common/sentinel/feign/PigSentinelInvocationHandler.java new file mode 100644 index 00000000..a397a8e7 --- /dev/null +++ b/pig-common/pig-common-sentinel/src/main/java/com/pig4cloud/pig/common/sentinel/feign/PigSentinelInvocationHandler.java @@ -0,0 +1,165 @@ +package com.pig4cloud.pig.common.sentinel.feign; + +import com.alibaba.cloud.sentinel.feign.SentinelContractHolder; +import com.alibaba.cloud.sentinel.feign.SentinelInvocationHandler; +import com.alibaba.csp.sentinel.Entry; +import com.alibaba.csp.sentinel.EntryType; +import com.alibaba.csp.sentinel.SphU; +import com.alibaba.csp.sentinel.Tracer; +import com.alibaba.csp.sentinel.context.ContextUtil; +import com.alibaba.csp.sentinel.slots.block.BlockException; +import com.pig4cloud.pig.common.core.util.R; +import feign.Feign; +import feign.InvocationHandlerFactory; +import feign.MethodMetadata; +import feign.Target; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.LinkedHashMap; +import java.util.Map; + +import static feign.Util.checkNotNull; + +/** + * 支持自动降级注入 + * 重写 {@link com.alibaba.cloud.sentinel.feign.SentinelInvocationHandler} + * + * @author lengleng + * @date 2020/6/9 + */ +@Slf4j +public class PigSentinelInvocationHandler implements InvocationHandler { + public static final String EQUALS = "equals"; + public static final String HASH_CODE = "hashCode"; + public static final String TO_STRING = "toString"; + private final Target target; + + private final Map dispatch; + + private FallbackFactory fallbackFactory; + + private Map fallbackMethodMap; + + PigSentinelInvocationHandler(Target target, Map dispatch, + FallbackFactory fallbackFactory) { + this.target = checkNotNull(target, "target"); + this.dispatch = checkNotNull(dispatch, "dispatch"); + this.fallbackFactory = fallbackFactory; + this.fallbackMethodMap = toFallbackMethod(dispatch); + } + + PigSentinelInvocationHandler(Target target, Map dispatch) { + this.target = checkNotNull(target, "target"); + this.dispatch = checkNotNull(dispatch, "dispatch"); + } + + @Override + public Object invoke(final Object proxy, final Method method, final Object[] args) + throws Throwable { + if (EQUALS.equals(method.getName())) { + try { + Object otherHandler = args.length > 0 && args[0] != null + ? Proxy.getInvocationHandler(args[0]) : null; + return equals(otherHandler); + } catch (IllegalArgumentException e) { + return false; + } + } else if (HASH_CODE.equals(method.getName())) { + return hashCode(); + } else if (TO_STRING.equals(method.getName())) { + return toString(); + } + + Object result; + InvocationHandlerFactory.MethodHandler methodHandler = this.dispatch.get(method); + // only handle by HardCodedTarget + if (target instanceof Target.HardCodedTarget) { + Target.HardCodedTarget hardCodedTarget = (Target.HardCodedTarget) target; + MethodMetadata methodMetadata = SentinelContractHolder.METADATA_MAP + .get(hardCodedTarget.type().getName() + + Feign.configKey(hardCodedTarget.type(), method)); + // resource default is HttpMethod:protocol://url + if (methodMetadata == null) { + result = methodHandler.invoke(args); + } else { + String resourceName = methodMetadata.template().method().toUpperCase() + + ":" + hardCodedTarget.url() + methodMetadata.template().path(); + Entry entry = null; + try { + ContextUtil.enter(resourceName); + entry = SphU.entry(resourceName, EntryType.OUT, 1, args); + result = methodHandler.invoke(args); + } catch (Throwable ex) { + // fallback handle + if (!BlockException.isBlockException(ex)) { + Tracer.trace(ex); + } + if (fallbackFactory != null) { + try { + Object fallbackResult = fallbackMethodMap.get(method) + .invoke(fallbackFactory.create(ex), args); + return fallbackResult; + } catch (IllegalAccessException e) { + // shouldn't happen as method is public due to being an + // interface + throw new AssertionError(e); + } catch (InvocationTargetException e) { + throw new AssertionError(e.getCause()); + } + } else { + // 若是R类型 执行自动降级返回R + if (R.class == method.getReturnType()) { + log.error("feign 服务间调用异常", ex); + return R.failed(ex.getLocalizedMessage()); + } else { + throw ex; + } + } + } finally { + if (entry != null) { + entry.exit(1, args); + } + ContextUtil.exit(); + } + } + } else { + // other target type using default strategy + result = methodHandler.invoke(args); + } + + return result; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof SentinelInvocationHandler) { + PigSentinelInvocationHandler other = (PigSentinelInvocationHandler) obj; + return target.equals(other.target); + } + return false; + } + + @Override + public int hashCode() { + return target.hashCode(); + } + + @Override + public String toString() { + return target.toString(); + } + + static Map toFallbackMethod(Map dispatch) { + Map result = new LinkedHashMap<>(); + for (Method method : dispatch.keySet()) { + method.setAccessible(true); + result.put(method, method); + } + return result; + } +} diff --git a/pig-common/pig-common-sentinel/src/main/java/com/pig4cloud/pig/common/sentinel/handle/PigUrlBlockHandler.java b/pig-common/pig-common-sentinel/src/main/java/com/pig4cloud/pig/common/sentinel/handle/PigUrlBlockHandler.java new file mode 100644 index 00000000..5e37b0fc --- /dev/null +++ b/pig-common/pig-common-sentinel/src/main/java/com/pig4cloud/pig/common/sentinel/handle/PigUrlBlockHandler.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.common.sentinel.handle; + +import cn.hutool.http.ContentType; +import cn.hutool.json.JSONUtil; +import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler; +import com.alibaba.csp.sentinel.slots.block.BlockException; +import com.pig4cloud.pig.common.core.util.R; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * sentinel统一降级限流策略 + *

+ * {@link com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.DefaultBlockExceptionHandler} + * + * @author lengleng + * @date 2020-06-11 + */ +@Slf4j +public class PigUrlBlockHandler implements BlockExceptionHandler { + + @Override + public void handle(HttpServletRequest request, HttpServletResponse response, BlockException e) throws Exception { + log.error("sentinel 降级 资源名称{}", e.getRule().getResource(), e); + + response.setContentType(ContentType.JSON.toString()); + response.setStatus(HttpStatus.TOO_MANY_REQUESTS.value()); + response.getWriter().print( + JSONUtil.toJsonStr(R.failed(e.getMessage()))); + } +} diff --git a/pig-common/pig-common-sentinel/src/main/java/com/pig4cloud/pig/common/sentinel/parser/PigHeaderRequestOriginParser.java b/pig-common/pig-common-sentinel/src/main/java/com/pig4cloud/pig/common/sentinel/parser/PigHeaderRequestOriginParser.java new file mode 100644 index 00000000..9266d359 --- /dev/null +++ b/pig-common/pig-common-sentinel/src/main/java/com/pig4cloud/pig/common/sentinel/parser/PigHeaderRequestOriginParser.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pig.common.sentinel.parser; + +import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser; + +import javax.servlet.http.HttpServletRequest; + +/** + * sentinel 请求头解析判断 + * + * @author lengleng + * @date 2020-06-11 + */ +public class PigHeaderRequestOriginParser implements RequestOriginParser { + /** + * 请求头获取allow + */ + private static final String ALLOW = "Allow"; + + /** + * Parse the origin from given HTTP request. + * + * @param request HTTP request + * @return parsed origin + */ + @Override + public String parseOrigin(HttpServletRequest request) { + return request.getHeader(ALLOW); + } +} diff --git a/pig-common/pig-common-sentinel/src/main/resources/META-INF/spring.factories b/pig-common/pig-common-sentinel/src/main/resources/META-INF/spring.factories new file mode 100755 index 00000000..2a074b95 --- /dev/null +++ b/pig-common/pig-common-sentinel/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + com.pig4cloud.pig.common.sentinel.SentinelAutoConfiguration diff --git a/pig-common/pom.xml b/pig-common/pom.xml index 5d4200d2..ba6d2edd 100755 --- a/pig-common/pom.xml +++ b/pig-common/pom.xml @@ -37,6 +37,7 @@ pig-common-log pig-common-mybatis pig-common-security + pig-common-sentinel pig-common-swagger diff --git a/pig-gateway/pom.xml b/pig-gateway/pom.xml index 69e2883d..89e125e0 100755 --- a/pig-gateway/pom.xml +++ b/pig-gateway/pom.xml @@ -51,18 +51,18 @@ com.alibaba.cloud spring-cloud-starter-alibaba-nacos-config + + + com.pig4cloud + pig-common-sentinel + 2.7.8.snapshot + com.github.axet kaptcha ${kaptcha.version} - - - com.pig4cloud - pig-common-core - 2.7.8.snapshot - io.springfox diff --git a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/PigGatewayApplication.java b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/PigGatewayApplication.java index 9d405600..03b02aa3 100755 --- a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/PigGatewayApplication.java +++ b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/PigGatewayApplication.java @@ -20,7 +20,6 @@ package com.pig4cloud.pig.gateway; import org.springframework.boot.SpringApplication; -import org.springframework.boot.context.properties.ConfigurationPropertiesScan; import org.springframework.cloud.client.SpringCloudApplication; /** @@ -30,7 +29,6 @@ import org.springframework.cloud.client.SpringCloudApplication; * 网关应用 */ @SpringCloudApplication -@ConfigurationPropertiesScan public class PigGatewayApplication { public static void main(String[] args) { diff --git a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/IgnoreClientConfiguration.java b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/IgnoreClientConfiguration.java index 605fe976..e30fb824 100755 --- a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/IgnoreClientConfiguration.java +++ b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/IgnoreClientConfiguration.java @@ -19,10 +19,9 @@ package com.pig4cloud.pig.gateway.config; import lombok.Data; -import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.cloud.context.config.annotation.RefreshScope; -import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; @@ -33,6 +32,7 @@ import java.util.List; * 放行参数配置 */ @Data +@Component @RefreshScope @ConfigurationProperties(prefix = "ignore") public class IgnoreClientConfiguration { diff --git a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/RouterFunctionConfiguration.java b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/RouterFunctionConfiguration.java index 14733df2..af02b329 100755 --- a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/RouterFunctionConfiguration.java +++ b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/RouterFunctionConfiguration.java @@ -18,7 +18,10 @@ package com.pig4cloud.pig.gateway.config; -import com.pig4cloud.pig.gateway.handler.*; +import com.pig4cloud.pig.gateway.handler.ImageCodeHandler; +import com.pig4cloud.pig.gateway.handler.SwaggerResourceHandler; +import com.pig4cloud.pig.gateway.handler.SwaggerSecurityHandler; +import com.pig4cloud.pig.gateway.handler.SwaggerUiHandler; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Bean; @@ -29,15 +32,15 @@ import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.RouterFunctions; /** - * @author lengleng - * @date 2019/2/1 * 路由配置信息 + * + * @author lengleng + * @date 2020-06-11 */ @Slf4j @Configuration @RequiredArgsConstructor public class RouterFunctionConfiguration { - private final HystrixFallbackHandler hystrixFallbackHandler; private final ImageCodeHandler imageCodeHandler; private final SwaggerResourceHandler swaggerResourceHandler; private final SwaggerSecurityHandler swaggerSecurityHandler; @@ -47,9 +50,7 @@ public class RouterFunctionConfiguration { @Bean public RouterFunction routerFunction() { return RouterFunctions.route( - RequestPredicates.path("/fallback") - .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)), hystrixFallbackHandler) - .andRoute(RequestPredicates.GET("/code") + RequestPredicates.path("/code") .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)), imageCodeHandler) .andRoute(RequestPredicates.GET("/swagger-resources") .and(RequestPredicates.accept(MediaType.ALL)), swaggerResourceHandler) diff --git a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/handler/HystrixFallbackHandler.java b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/handler/HystrixFallbackHandler.java deleted file mode 100755 index 03938247..00000000 --- a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/handler/HystrixFallbackHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * * Copyright (c) 2019-2020, 冷冷 (wangiegie@gmail.com). - * *

- * * Licensed under the GNU Lesser General Public License 3.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * *

- * * https://www.gnu.org/licenses/lgpl.html - * *

- * * 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 com.pig4cloud.pig.gateway.handler; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.server.HandlerFunction; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; -import reactor.core.publisher.Mono; - -import java.util.Optional; - -import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR; - -/** - * @author lengleng - * @date 2019/2/1 - * Hystrix 降级处理 - */ -@Slf4j -@Component -public class HystrixFallbackHandler implements HandlerFunction { - @Override - public Mono handle(ServerRequest serverRequest) { - Optional originalUris = serverRequest.attribute(GATEWAY_ORIGINAL_REQUEST_URL_ATTR); - - originalUris.ifPresent(originalUri -> log.error("网关执行请求:{}失败,hystrix服务降级处理", originalUri)); - - return ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR.value()) - .contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromValue("服务异常")); - } -} diff --git a/pig-upms/pig-upms-biz/pom.xml b/pig-upms/pig-upms-biz/pom.xml index b26ae423..492b8c04 100644 --- a/pig-upms/pig-upms-biz/pom.xml +++ b/pig-upms/pig-upms-biz/pom.xml @@ -72,6 +72,12 @@ com.alibaba.cloud spring-cloud-starter-alibaba-nacos-config + + + com.pig4cloud + pig-common-sentinel + 2.7.8.snapshot + org.springframework.boot diff --git a/pig-codegen/Dockerfile b/pig-visual/pig-codegen/Dockerfile similarity index 100% rename from pig-codegen/Dockerfile rename to pig-visual/pig-codegen/Dockerfile diff --git a/pig-codegen/pom.xml b/pig-visual/pig-codegen/pom.xml similarity index 93% rename from pig-codegen/pom.xml rename to pig-visual/pig-codegen/pom.xml index 724e7217..87725830 100755 --- a/pig-codegen/pom.xml +++ b/pig-visual/pig-codegen/pom.xml @@ -23,7 +23,7 @@ com.pig4cloud - pig + pig-visual 2.7.8.snapshot @@ -49,6 +49,12 @@ com.alibaba.cloud spring-cloud-starter-alibaba-nacos-config + + + com.pig4cloud + pig-common-sentinel + 2.7.8.snapshot + com.pig4cloud diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/PigCodeGenApplication.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/PigCodeGenApplication.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/PigCodeGenApplication.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/PigCodeGenApplication.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenDsConfController.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenDsConfController.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenDsConfController.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenDsConfController.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenFormConfController.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenFormConfController.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenFormConfController.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenFormConfController.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GeneratorController.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GeneratorController.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GeneratorController.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GeneratorController.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/ColumnEntity.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/ColumnEntity.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/ColumnEntity.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/ColumnEntity.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenConfig.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenConfig.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenConfig.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenConfig.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenDatasourceConf.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenDatasourceConf.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenDatasourceConf.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenDatasourceConf.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFormConf.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFormConf.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFormConf.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFormConf.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/TableEntity.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/TableEntity.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/TableEntity.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/TableEntity.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenDatasourceConfMapper.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenDatasourceConfMapper.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenDatasourceConfMapper.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenDatasourceConfMapper.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenFormConfMapper.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenFormConfMapper.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenFormConfMapper.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GenFormConfMapper.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GeneratorMapper.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GeneratorMapper.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GeneratorMapper.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/mapper/GeneratorMapper.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenDatasourceConfService.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenDatasourceConfService.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenDatasourceConfService.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenDatasourceConfService.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenFormConfService.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenFormConfService.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenFormConfService.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GenFormConfService.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GeneratorService.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GeneratorService.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GeneratorService.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/GeneratorService.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenDatasourceConfServiceImpl.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenDatasourceConfServiceImpl.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenDatasourceConfServiceImpl.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenDatasourceConfServiceImpl.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenFormConfServiceImpl.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenFormConfServiceImpl.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenFormConfServiceImpl.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenFormConfServiceImpl.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java diff --git a/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/CodeGenUtils.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/CodeGenUtils.java similarity index 100% rename from pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/CodeGenUtils.java rename to pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/CodeGenUtils.java diff --git a/pig-codegen/src/main/resources/bootstrap.yml b/pig-visual/pig-codegen/src/main/resources/bootstrap.yml similarity index 100% rename from pig-codegen/src/main/resources/bootstrap.yml rename to pig-visual/pig-codegen/src/main/resources/bootstrap.yml diff --git a/pig-codegen/src/main/resources/generator.properties b/pig-visual/pig-codegen/src/main/resources/generator.properties similarity index 100% rename from pig-codegen/src/main/resources/generator.properties rename to pig-visual/pig-codegen/src/main/resources/generator.properties diff --git a/pig-codegen/src/main/resources/mapper/GenFormConfMapper.xml b/pig-visual/pig-codegen/src/main/resources/mapper/GenFormConfMapper.xml similarity index 100% rename from pig-codegen/src/main/resources/mapper/GenFormConfMapper.xml rename to pig-visual/pig-codegen/src/main/resources/mapper/GenFormConfMapper.xml diff --git a/pig-codegen/src/main/resources/mapper/GeneratorMapper.xml b/pig-visual/pig-codegen/src/main/resources/mapper/GeneratorMapper.xml similarity index 100% rename from pig-codegen/src/main/resources/mapper/GeneratorMapper.xml rename to pig-visual/pig-codegen/src/main/resources/mapper/GeneratorMapper.xml diff --git a/pig-codegen/src/main/resources/template/Controller.java.vm b/pig-visual/pig-codegen/src/main/resources/template/Controller.java.vm similarity index 100% rename from pig-codegen/src/main/resources/template/Controller.java.vm rename to pig-visual/pig-codegen/src/main/resources/template/Controller.java.vm diff --git a/pig-codegen/src/main/resources/template/Entity.java.vm b/pig-visual/pig-codegen/src/main/resources/template/Entity.java.vm similarity index 100% rename from pig-codegen/src/main/resources/template/Entity.java.vm rename to pig-visual/pig-codegen/src/main/resources/template/Entity.java.vm diff --git a/pig-codegen/src/main/resources/template/Mapper.java.vm b/pig-visual/pig-codegen/src/main/resources/template/Mapper.java.vm similarity index 100% rename from pig-codegen/src/main/resources/template/Mapper.java.vm rename to pig-visual/pig-codegen/src/main/resources/template/Mapper.java.vm diff --git a/pig-codegen/src/main/resources/template/Mapper.xml.vm b/pig-visual/pig-codegen/src/main/resources/template/Mapper.xml.vm similarity index 100% rename from pig-codegen/src/main/resources/template/Mapper.xml.vm rename to pig-visual/pig-codegen/src/main/resources/template/Mapper.xml.vm diff --git a/pig-codegen/src/main/resources/template/Service.java.vm b/pig-visual/pig-codegen/src/main/resources/template/Service.java.vm similarity index 100% rename from pig-codegen/src/main/resources/template/Service.java.vm rename to pig-visual/pig-codegen/src/main/resources/template/Service.java.vm diff --git a/pig-codegen/src/main/resources/template/ServiceImpl.java.vm b/pig-visual/pig-codegen/src/main/resources/template/ServiceImpl.java.vm similarity index 100% rename from pig-codegen/src/main/resources/template/ServiceImpl.java.vm rename to pig-visual/pig-codegen/src/main/resources/template/ServiceImpl.java.vm diff --git a/pig-codegen/src/main/resources/template/avue/api.js.vm b/pig-visual/pig-codegen/src/main/resources/template/avue/api.js.vm similarity index 100% rename from pig-codegen/src/main/resources/template/avue/api.js.vm rename to pig-visual/pig-codegen/src/main/resources/template/avue/api.js.vm diff --git a/pig-codegen/src/main/resources/template/avue/crud.js.vm b/pig-visual/pig-codegen/src/main/resources/template/avue/crud.js.vm similarity index 100% rename from pig-codegen/src/main/resources/template/avue/crud.js.vm rename to pig-visual/pig-codegen/src/main/resources/template/avue/crud.js.vm diff --git a/pig-codegen/src/main/resources/template/avue/index.vue.vm b/pig-visual/pig-codegen/src/main/resources/template/avue/index.vue.vm similarity index 100% rename from pig-codegen/src/main/resources/template/avue/index.vue.vm rename to pig-visual/pig-codegen/src/main/resources/template/avue/index.vue.vm diff --git a/pig-codegen/src/main/resources/template/menu.sql.vm b/pig-visual/pig-codegen/src/main/resources/template/menu.sql.vm similarity index 100% rename from pig-codegen/src/main/resources/template/menu.sql.vm rename to pig-visual/pig-codegen/src/main/resources/template/menu.sql.vm diff --git a/pig-monitor/Dockerfile b/pig-visual/pig-monitor/Dockerfile similarity index 100% rename from pig-monitor/Dockerfile rename to pig-visual/pig-monitor/Dockerfile diff --git a/pig-monitor/pom.xml b/pig-visual/pig-monitor/pom.xml similarity index 93% rename from pig-monitor/pom.xml rename to pig-visual/pig-monitor/pom.xml index 9a4e6ecd..a04b505e 100755 --- a/pig-monitor/pom.xml +++ b/pig-visual/pig-monitor/pom.xml @@ -48,6 +48,12 @@ com.alibaba.cloud spring-cloud-starter-alibaba-nacos-config + + + com.pig4cloud + pig-common-sentinel + 2.7.8.snapshot + org.springframework.boot diff --git a/pig-monitor/src/main/java/com/pig4cloud/pig/monitor/PigMonitorApplication.java b/pig-visual/pig-monitor/src/main/java/com/pig4cloud/pig/monitor/PigMonitorApplication.java similarity index 100% rename from pig-monitor/src/main/java/com/pig4cloud/pig/monitor/PigMonitorApplication.java rename to pig-visual/pig-monitor/src/main/java/com/pig4cloud/pig/monitor/PigMonitorApplication.java diff --git a/pig-monitor/src/main/java/com/pig4cloud/pig/monitor/config/WebSecurityConfigurer.java b/pig-visual/pig-monitor/src/main/java/com/pig4cloud/pig/monitor/config/WebSecurityConfigurer.java similarity index 100% rename from pig-monitor/src/main/java/com/pig4cloud/pig/monitor/config/WebSecurityConfigurer.java rename to pig-visual/pig-monitor/src/main/java/com/pig4cloud/pig/monitor/config/WebSecurityConfigurer.java diff --git a/pig-monitor/src/main/resources/bootstrap.yml b/pig-visual/pig-monitor/src/main/resources/bootstrap.yml similarity index 100% rename from pig-monitor/src/main/resources/bootstrap.yml rename to pig-visual/pig-monitor/src/main/resources/bootstrap.yml diff --git a/pig-visual/pig-sentinel-dashboard/Dockerfile b/pig-visual/pig-sentinel-dashboard/Dockerfile new file mode 100644 index 00000000..89fa4d28 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/Dockerfile @@ -0,0 +1,27 @@ +# pig4cloud/java:8-jre镜像增加了中文字体与wait-for-it.sh的支持 +# 镜像链接:https://hub.docker.com/r/pig4cloud/java/ +# wait-for-it.sh采用https://github.com/vishnubob/wait-for-it作为解决方案 +FROM pig4cloud/java:8-jre + +MAINTAINER wangiegie@gmail.com + +ARG JAR_FILE=./target/pig-sentinel-biz.jar + +# JVM调优参数等额外参数 +ENV PARAMS "" + +ENV NACOS_HOST pig-register + +ENV NACOS_PORT 8848 + +ENV TZ=PRC + +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +WORKDIR /tmp + +EXPOSE 5003 + +ADD ${JAR_FILE} ./app.jar + +ENTRYPOINT ["wait-for-it.sh","$NACOS_HOST:$NACOS_PORT","--","java","-jar","app.jar","-Djava.security.egd=file:/dev/./urandom","$PARAMS"] diff --git a/pig-visual/pig-sentinel-dashboard/pom.xml b/pig-visual/pig-sentinel-dashboard/pom.xml new file mode 100755 index 00000000..56f9c246 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/pom.xml @@ -0,0 +1,112 @@ + + + 4.0.0 + + + com.pig4cloud + pig-visual + 2.7.8.snapshot + + + pig-sentinel-dashboard + jar + + + + com.alibaba.csp + sentinel-core + + + com.alibaba.csp + sentinel-web-servlet + + + com.alibaba.csp + sentinel-transport-simple-http + + + com.alibaba.csp + sentinel-parameter-flow-control + + + com.alibaba.csp + sentinel-api-gateway-adapter-common + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-undertow + + + org.springframework.boot + spring-boot-starter-logging + + + + log4j + log4j + 1.2.14 + + + + commons-lang + commons-lang + 2.6 + + + + org.apache.httpcomponents + httpclient + 4.5.3 + + + org.apache.httpcomponents + httpcore + 4.4.5 + + + org.apache.httpcomponents + httpasyncclient + 4.1.3 + + + org.apache.httpcomponents + httpcore-nio + 4.4.6 + + + + + pigx-sentinel-dashboard + + + src/main/resources + + + + src/main/webapp/ + + resources/node_modules/** + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + io.fabric8 + docker-maven-plugin + + false + + + + + diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/PigSentinelApplication.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/PigSentinelApplication.java new file mode 100755 index 00000000..dc2c2eff --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/PigSentinelApplication.java @@ -0,0 +1,40 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard; + +import com.alibaba.csp.sentinel.init.InitExecutor; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author nacos + *

+ * sentinel console 源码运行,方便开发 + * 生产建议从官网下载最新版配置运行 + */ +@SpringBootApplication +public class PigSentinelApplication { + + public static void main(String[] args) { + triggerSentinelInit(); + SpringApplication.run(PigSentinelApplication.class, args); + } + + private static void triggerSentinelInit() { + new Thread(InitExecutor::doInit).start(); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthAction.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthAction.java new file mode 100755 index 00000000..f521c04d --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthAction.java @@ -0,0 +1,47 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.auth; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author lkxiaolou + * @since 1.7.1 + */ +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Target({ElementType.METHOD}) +public @interface AuthAction { + + /** + * @return the privilege type + */ + AuthService.PrivilegeType value(); + + /** + * @return the target name to control + */ + String targetName() default "app"; + + /** + * @return the message when permission is denied + */ + String message() default "Permission denied"; +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthService.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthService.java new file mode 100755 index 00000000..cdda6a3b --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthService.java @@ -0,0 +1,113 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.auth; + +/** + * Interface for authentication and authorization. + * + * @author Carpenter Lee + * @since 1.5.0 + */ +public interface AuthService { + + /** + * Get the authentication user. + * + * @param request the request contains the user information + * @return the auth user represent the current user, when the user is illegal, a null value will return. + */ + AuthUser getAuthUser(R request); + + /** + * Privilege type. + */ + enum PrivilegeType { + /** + * Read rule + */ + READ_RULE, + /** + * Create or modify rule + */ + WRITE_RULE, + /** + * Delete rule + */ + DELETE_RULE, + /** + * Read metrics + */ + READ_METRIC, + /** + * Add machine + */ + ADD_MACHINE, + /** + * All privileges above are granted. + */ + ALL + } + + /** + * Represents the current user. + */ + interface AuthUser { + + /** + * Query whether current user has the specific privilege to the target, the target + * may be an app name or an ip address, or other destination. + *

+ * This method will use return value to represent whether user has the specific + * privileges to the target, but to throw a RuntimeException to represent no auth + * is also a good way. + *

+ * + * @param target the target to check + * @param privilegeType the privilege type to check + * @return if current user has the specific privileges to the target, return true, + * otherwise return false. + */ + boolean authTarget(String target, PrivilegeType privilegeType); + + /** + * Check whether current user is a super-user. + * + * @return if current user is super user return true, else return false. + */ + boolean isSuperUser(); + + /** + * Get current user's nick name. + * + * @return current user's nick name. + */ + String getNickName(); + + /** + * Get current user's login name. + * + * @return current user's login name. + */ + String getLoginName(); + + /** + * Get current user's ID. + * + * @return ID of current user + */ + String getId(); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthorizationInterceptor.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthorizationInterceptor.java new file mode 100755 index 00000000..19472521 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthorizationInterceptor.java @@ -0,0 +1,72 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.auth; + +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.fastjson.JSON; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.HandlerInterceptor; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.lang.reflect.Method; + +/** + * The web interceptor for privilege-based authorization. + * + * @author lkxiaolou + * @since 1.7.1 + */ +@Component +public class AuthorizationInterceptor implements HandlerInterceptor { + + @Autowired + private AuthService authService; + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) + throws Exception { + if (handler.getClass().isAssignableFrom(HandlerMethod.class)) { + Method method = ((HandlerMethod) handler).getMethod(); + + AuthAction authAction = method.getAnnotation(AuthAction.class); + if (authAction != null) { + AuthService.AuthUser authUser = authService.getAuthUser(request); + if (authUser == null) { + responseNoPrivilegeMsg(response, authAction.message()); + return false; + } + String target = request.getParameter(authAction.targetName()); + + if (!authUser.authTarget(target, authAction.value())) { + responseNoPrivilegeMsg(response, authAction.message()); + return false; + } + } + } + + return true; + } + + private void responseNoPrivilegeMsg(HttpServletResponse response, String message) throws IOException { + Result result = Result.ofFail(-1, message); + response.addHeader("Content-Type", "application/json;charset=UTF-8"); + response.getOutputStream().write(JSON.toJSONBytes(result)); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/FakeAuthServiceImpl.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/FakeAuthServiceImpl.java new file mode 100755 index 00000000..b40ea564 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/FakeAuthServiceImpl.java @@ -0,0 +1,65 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.auth; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.stereotype.Component; + +/** + * A fake AuthService implementation, which will pass all user auth checking. + * + * @author Carpenter Lee + * @since 1.5.0 + */ +@Component +public class FakeAuthServiceImpl implements AuthService { + + @Override + public AuthUser getAuthUser(HttpServletRequest request) { + return new AuthUserImpl(); + } + + static final class AuthUserImpl implements AuthUser { + + @Override + public boolean authTarget(String target, PrivilegeType privilegeType) { + // fake implementation, always return true + return true; + } + + @Override + public boolean isSuperUser() { + // fake implementation, always return true + return true; + } + + @Override + public String getNickName() { + return "FAKE_NICK_NAME"; + } + + @Override + public String getLoginName() { + return "FAKE_LOGIN_NAME"; + } + + @Override + public String getId() { + return "FAKE_EMP_ID"; + } + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/LoginAuthenticationFilter.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/LoginAuthenticationFilter.java new file mode 100755 index 00000000..f489b48e --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/LoginAuthenticationFilter.java @@ -0,0 +1,125 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.auth; + +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import java.io.IOException; +import java.util.List; + +/** + *

The Servlet filter for authentication.

+ * + *

Note: some urls are excluded as they needn't auth, such as:

+ *
    + *
  • index url: {@code /}
  • + *
  • authentication request url: {@code /login}, {@code /logout}
  • + *
  • machine registry: {@code /registry/machine}
  • + *
  • static resources
  • + *
+ * + * The excluded urls and urlSuffixes could be configured in {@code application.properties} file. + * + * @author cdfive + * @since 1.6.0 + */ +@Component +public class LoginAuthenticationFilter implements Filter { + + private static final String URL_SUFFIX_DOT = "."; + + /** + * Some urls which needn't auth, such as /auth/login, /registry/machine and so on. + */ + @Value("#{'${auth.filter.exclude-urls}'.split(',')}") + private List authFilterExcludeUrls; + + /** + * Some urls with suffixes which needn't auth, such as htm, html, js and so on. + */ + @Value("#{'${auth.filter.exclude-url-suffixes}'.split(',')}") + private List authFilterExcludeUrlSuffixes; + + /** + * Authentication using AuthService interface. + */ + @Autowired + private AuthService authService; + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + HttpServletRequest httpRequest = (HttpServletRequest) request; + + String servletPath = httpRequest.getServletPath(); + + // Exclude the urls which needn't auth + if (authFilterExcludeUrls.contains(servletPath)) { + chain.doFilter(request, response); + return; + } + + // Exclude the urls with suffixes which needn't auth + for (String authFilterExcludeUrlSuffix : authFilterExcludeUrlSuffixes) { + if (StringUtils.isBlank(authFilterExcludeUrlSuffix)) { + continue; + } + + // Add . for url suffix so that we needn't add . in property file + if (!authFilterExcludeUrlSuffix.startsWith(URL_SUFFIX_DOT)) { + authFilterExcludeUrlSuffix = URL_SUFFIX_DOT + authFilterExcludeUrlSuffix; + } + + if (servletPath.endsWith(authFilterExcludeUrlSuffix)) { + chain.doFilter(request, response); + return; + } + } + + AuthService.AuthUser authUser = authService.getAuthUser(httpRequest); + + HttpServletResponse httpResponse = (HttpServletResponse) response; + if (authUser == null) { + // If auth fail, set response status code to 401 + httpResponse.setStatus(HttpStatus.UNAUTHORIZED.value()); + } else { + chain.doFilter(request, response); + } + } + + @Override + public void destroy() { + + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/SimpleWebAuthServiceImpl.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/SimpleWebAuthServiceImpl.java new file mode 100755 index 00000000..5d9599ee --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/SimpleWebAuthServiceImpl.java @@ -0,0 +1,80 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.auth; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +/** + * @author cdfive + * @since 1.6.0 + */ +@Component +@Primary +@ConditionalOnProperty(name = "auth.enabled", matchIfMissing = true) +public class SimpleWebAuthServiceImpl implements AuthService { + + public static final String WEB_SESSION_KEY = "session_sentinel_admin"; + + @Override + public AuthUser getAuthUser(HttpServletRequest request) { + HttpSession session = request.getSession(); + Object sentinelUserObj = session.getAttribute(SimpleWebAuthServiceImpl.WEB_SESSION_KEY); + if (sentinelUserObj != null && sentinelUserObj instanceof AuthUser) { + return (AuthUser) sentinelUserObj; + } + + return null; + } + + public static final class SimpleWebAuthUserImpl implements AuthUser { + + private String username; + + public SimpleWebAuthUserImpl(String username) { + this.username = username; + } + + @Override + public boolean authTarget(String target, PrivilegeType privilegeType) { + return true; + } + + @Override + public boolean isSuperUser() { + return true; + } + + @Override + public String getNickName() { + return username; + } + + @Override + public String getLoginName() { + return username; + } + + @Override + public String getId() { + return username; + } + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/client/CommandFailedException.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/client/CommandFailedException.java new file mode 100755 index 00000000..76b6aeb1 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/client/CommandFailedException.java @@ -0,0 +1,33 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.client; + +/** + * @author Eric Zhao + */ +public class CommandFailedException extends RuntimeException { + + public CommandFailedException() {} + + public CommandFailedException(String message) { + super(message); + } + + @Override + public synchronized Throwable fillInStackTrace() { + return this; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/client/CommandNotFoundException.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/client/CommandNotFoundException.java new file mode 100755 index 00000000..0db95680 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/client/CommandNotFoundException.java @@ -0,0 +1,34 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.client; + +/** + * @author Eric Zhao + * @since 0.2.1 + */ +public class CommandNotFoundException extends Exception { + + public CommandNotFoundException() { } + + public CommandNotFoundException(String message) { + super(message); + } + + @Override + public synchronized Throwable fillInStackTrace() { + return this; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/client/SentinelApiClient.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/client/SentinelApiClient.java new file mode 100755 index 00000000..008e67c1 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/client/SentinelApiClient.java @@ -0,0 +1,818 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.client; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; + +import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule; +import com.alibaba.csp.sentinel.command.CommandConstants; +import com.alibaba.csp.sentinel.config.SentinelConfig; +import com.alibaba.csp.sentinel.command.vo.NodeVo; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayFlowRuleEntity; +import com.alibaba.csp.sentinel.dashboard.util.AsyncUtils; +import com.alibaba.csp.sentinel.slots.block.Rule; +import com.alibaba.csp.sentinel.slots.block.authority.AuthorityRule; +import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule; +import com.alibaba.csp.sentinel.slots.block.flow.FlowRule; +import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowRule; +import com.alibaba.csp.sentinel.slots.system.SystemRule; +import com.alibaba.csp.sentinel.util.AssertUtil; +import com.alibaba.csp.sentinel.util.StringUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.SentinelVersion; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AuthorityRuleEntity; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.DegradeRuleEntity; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.ParamFlowRuleEntity; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.RuleEntity; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.SystemRuleEntity; +import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterClientInfoVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterServerStateVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterStateSimpleEntity; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ClusterClientConfig; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerFlowConfig; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerTransportConfig; +import com.alibaba.csp.sentinel.dashboard.util.VersionUtils; + +import org.apache.http.Consts; +import org.apache.http.HttpResponse; +import org.apache.http.NameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.concurrent.FutureCallback; +import org.apache.http.entity.ContentType; +import org.apache.http.impl.client.DefaultRedirectStrategy; +import org.apache.http.impl.nio.client.CloseableHttpAsyncClient; +import org.apache.http.impl.nio.client.HttpAsyncClients; +import org.apache.http.impl.nio.reactor.IOReactorConfig; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.lang.Nullable; +import org.springframework.stereotype.Component; + +/** + * Communicate with Sentinel client. + * + * @author leyou + */ +@Component +public class SentinelApiClient { + private static Logger logger = LoggerFactory.getLogger(SentinelApiClient.class); + + private static final Charset DEFAULT_CHARSET = Charset.forName(SentinelConfig.charset()); + + private static final String RESOURCE_URL_PATH = "jsonTree"; + private static final String CLUSTER_NODE_PATH = "clusterNode"; + private static final String GET_RULES_PATH = "getRules"; + private static final String SET_RULES_PATH = "setRules"; + private static final String GET_PARAM_RULE_PATH = "getParamFlowRules"; + private static final String SET_PARAM_RULE_PATH = "setParamFlowRules"; + + private static final String FETCH_CLUSTER_MODE_PATH = "getClusterMode"; + private static final String MODIFY_CLUSTER_MODE_PATH = "setClusterMode"; + private static final String FETCH_CLUSTER_CLIENT_CONFIG_PATH = "cluster/client/fetchConfig"; + private static final String MODIFY_CLUSTER_CLIENT_CONFIG_PATH = "cluster/client/modifyConfig"; + + private static final String FETCH_CLUSTER_SERVER_ALL_CONFIG_PATH = "cluster/server/fetchConfig"; + private static final String FETCH_CLUSTER_SERVER_BASIC_INFO_PATH = "cluster/server/info"; + + private static final String MODIFY_CLUSTER_SERVER_TRANSPORT_CONFIG_PATH = "cluster/server/modifyTransportConfig"; + private static final String MODIFY_CLUSTER_SERVER_FLOW_CONFIG_PATH = "cluster/server/modifyFlowConfig"; + private static final String MODIFY_CLUSTER_SERVER_NAMESPACE_SET_PATH = "cluster/server/modifyNamespaceSet"; + + private static final String FETCH_GATEWAY_API_PATH = "gateway/getApiDefinitions"; + private static final String MODIFY_GATEWAY_API_PATH = "gateway/updateApiDefinitions"; + + private static final String FETCH_GATEWAY_FLOW_RULE_PATH = "gateway/getRules"; + private static final String MODIFY_GATEWAY_FLOW_RULE_PATH = "gateway/updateRules"; + + private static final String FLOW_RULE_TYPE = "flow"; + private static final String DEGRADE_RULE_TYPE = "degrade"; + private static final String SYSTEM_RULE_TYPE = "system"; + private static final String AUTHORITY_TYPE = "authority"; + + private CloseableHttpAsyncClient httpClient; + + private static final SentinelVersion version160 = new SentinelVersion(1, 6, 0); + + @Autowired + private AppManagement appManagement; + + public SentinelApiClient() { + IOReactorConfig ioConfig = IOReactorConfig.custom().setConnectTimeout(3000).setSoTimeout(10000) + .setIoThreadCount(Runtime.getRuntime().availableProcessors() * 2).build(); + httpClient = HttpAsyncClients.custom().setRedirectStrategy(new DefaultRedirectStrategy() { + @Override + protected boolean isRedirectable(final String method) { + return false; + } + }).setMaxConnTotal(4000).setMaxConnPerRoute(1000).setDefaultIOReactorConfig(ioConfig).build(); + httpClient.start(); + } + + private boolean isSuccess(int statusCode) { + return statusCode >= 200 && statusCode < 300; + } + + private boolean isCommandNotFound(int statusCode, String body) { + return statusCode == 400 && StringUtil.isNotEmpty(body) && body.contains(CommandConstants.MSG_UNKNOWN_COMMAND_PREFIX); + } + + private StringBuilder queryString(Map params) { + StringBuilder queryStringBuilder = new StringBuilder(); + for (Entry entry : params.entrySet()) { + if (StringUtil.isEmpty(entry.getValue())) { + continue; + } + String name = urlEncode(entry.getKey()); + String value = urlEncode(entry.getValue()); + if (name != null && value != null) { + if (queryStringBuilder.length() > 0) { + queryStringBuilder.append('&'); + } + queryStringBuilder.append(name).append('=').append(value); + } + } + return queryStringBuilder; + } + + private HttpUriRequest postRequest(String url, Map params) { + HttpPost httpPost = new HttpPost(url); + if (params != null && params.size() > 0) { + List list = new ArrayList<>(params.size()); + for (Entry entry : params.entrySet()) { + list.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); + } + httpPost.setEntity(new UrlEncodedFormEntity(list, Consts.UTF_8)); + } + return httpPost; + } + + private String urlEncode(String str) { + try { + return URLEncoder.encode(str, DEFAULT_CHARSET.name()); + } catch (UnsupportedEncodingException e) { + logger.info("encode string error: {}", str, e); + return null; + } + } + + private String getBody(HttpResponse response) throws Exception { + Charset charset = null; + try { + String contentTypeStr = response.getFirstHeader("Content-type").getValue(); + if (StringUtil.isNotEmpty(contentTypeStr)) { + ContentType contentType = ContentType.parse(contentTypeStr); + charset = contentType.getCharset(); + } + } catch (Exception ignore) { + } + return EntityUtils.toString(response.getEntity(), charset != null ? charset : DEFAULT_CHARSET); + } + + /** + * With no param + * + * @param ip + * @param port + * @param api + * @return + */ + private CompletableFuture executeCommand(String ip, int port, String api, boolean useHttpPost) { + return executeCommand(ip, port, api, null, useHttpPost); + } + + /** + * No app specified, force to GET + * + * @param ip + * @param port + * @param api + * @param params + * @return + */ + private CompletableFuture executeCommand(String ip, int port, String api, Map params, boolean useHttpPost) { + return executeCommand(null, ip, port, api, params, useHttpPost); + } + + /** + * Prefer to execute request using POST + * + * @param app + * @param ip + * @param port + * @param api + * @param params + * @return + */ + private CompletableFuture executeCommand(String app, String ip, int port, String api, Map params, boolean useHttpPost) { + CompletableFuture future = new CompletableFuture<>(); + if (StringUtil.isBlank(ip) || StringUtil.isBlank(api)) { + future.completeExceptionally(new IllegalArgumentException("Bad URL or command name")); + return future; + } + StringBuilder urlBuilder = new StringBuilder(); + urlBuilder.append("http://"); + urlBuilder.append(ip).append(':').append(port).append('/').append(api); + if (params == null) { + params = Collections.emptyMap(); + } + boolean supportPost = StringUtil.isNotEmpty(app) && Optional.ofNullable(appManagement.getDetailApp(app)) + .flatMap(e -> e.getMachine(ip, port)) + .flatMap(m -> VersionUtils.parseVersion(m.getVersion()) + .map(v -> v.greaterOrEqual(version160))) + .orElse(false); + if (!useHttpPost || !supportPost) { + // Using GET in older versions, append parameters after url + if (!params.isEmpty()) { + if (urlBuilder.indexOf("?") == -1) { + urlBuilder.append('?'); + } else { + urlBuilder.append('&'); + } + urlBuilder.append(queryString(params)); + } + return executeCommand(new HttpGet(urlBuilder.toString())); + } else { + // Using POST + return executeCommand(postRequest(urlBuilder.toString(), params)); + } + } + + private CompletableFuture executeCommand(HttpUriRequest request) { + CompletableFuture future = new CompletableFuture<>(); + httpClient.execute(request, new FutureCallback() { + @Override + public void completed(final HttpResponse response) { + int statusCode = response.getStatusLine().getStatusCode(); + try { + String value = getBody(response); + if (isSuccess(statusCode)) { + future.complete(value); + } else { + if (isCommandNotFound(statusCode, value)) { + future.completeExceptionally(new CommandNotFoundException(request.getURI().getPath())); + } else { + future.completeExceptionally(new CommandFailedException(value)); + } + } + + } catch (Exception ex) { + future.completeExceptionally(ex); + logger.error("HTTP request failed: {}", request.getURI().toString(), ex); + } + } + + @Override + public void failed(final Exception ex) { + future.completeExceptionally(ex); + logger.error("HTTP request failed: {}", request.getURI().toString(), ex); + } + + @Override + public void cancelled() { + future.complete(null); + } + }); + return future; + } + + public void close() throws Exception { + httpClient.close(); + } + + @Nullable + private CompletableFuture> fetchItemsAsync(String ip, int port, String api, String type, Class ruleType) { + AssertUtil.notEmpty(ip, "Bad machine IP"); + AssertUtil.isTrue(port > 0, "Bad machine port"); + Map params = null; + if (StringUtil.isNotEmpty(type)) { + params = new HashMap<>(1); + params.put("type", type); + } + return executeCommand(ip, port, api, params, false) + .thenApply(json -> JSON.parseArray(json, ruleType)); + } + + @Nullable + private List fetchItems(String ip, int port, String api, String type, Class ruleType) { + try { + AssertUtil.notEmpty(ip, "Bad machine IP"); + AssertUtil.isTrue(port > 0, "Bad machine port"); + Map params = null; + if (StringUtil.isNotEmpty(type)) { + params = new HashMap<>(1); + params.put("type", type); + } + return fetchItemsAsync(ip, port, api, type, ruleType).get(); + } catch (InterruptedException | ExecutionException e) { + logger.error("Error when fetching items from api: {} -> {}", api, type, e); + return null; + } catch (Exception e) { + logger.error("Error when fetching items: {} -> {}", api, type, e); + return null; + } + } + + private List fetchRules(String ip, int port, String type, Class ruleType) { + return fetchItems(ip, port, GET_RULES_PATH, type, ruleType); + } + + private boolean setRules(String app, String ip, int port, String type, List entities) { + if (entities == null) { + return true; + } + try { + AssertUtil.notEmpty(app, "Bad app name"); + AssertUtil.notEmpty(ip, "Bad machine IP"); + AssertUtil.isTrue(port > 0, "Bad machine port"); + String data = JSON.toJSONString( + entities.stream().map(r -> r.toRule()).collect(Collectors.toList())); + Map params = new HashMap<>(2); + params.put("type", type); + params.put("data", data); + String result = executeCommand(app, ip, port, SET_RULES_PATH, params, true).get(); + logger.info("setRules result: {}, type={}", result, type); + return true; + } catch (InterruptedException e) { + logger.warn("setRules API failed: {}", type, e); + return false; + } catch (ExecutionException e) { + logger.warn("setRules API failed: {}", type, e.getCause()); + return false; + } catch (Exception e) { + logger.error("setRules API failed, type={}", type, e); + return false; + } + } + + private CompletableFuture setRulesAsync(String app, String ip, int port, String type, List entities) { + try { + AssertUtil.notNull(entities, "rules cannot be null"); + AssertUtil.notEmpty(app, "Bad app name"); + AssertUtil.notEmpty(ip, "Bad machine IP"); + AssertUtil.isTrue(port > 0, "Bad machine port"); + String data = JSON.toJSONString( + entities.stream().map(r -> r.toRule()).collect(Collectors.toList())); + Map params = new HashMap<>(2); + params.put("type", type); + params.put("data", data); + return executeCommand(app, ip, port, SET_RULES_PATH, params, true) + .thenCompose(r -> { + if ("success".equalsIgnoreCase(r.trim())) { + return CompletableFuture.completedFuture(null); + } + return AsyncUtils.newFailedFuture(new CommandFailedException(r)); + }); + } catch (Exception e) { + logger.error("setRulesAsync API failed, type={}", type, e); + return AsyncUtils.newFailedFuture(e); + } + } + + public List fetchResourceOfMachine(String ip, int port, String type) { + return fetchItems(ip, port, RESOURCE_URL_PATH, type, NodeVo.class); + } + + /** + * Fetch cluster node. + * + * @param ip ip to fetch + * @param port port of the ip + * @param includeZero whether zero value should in the result list. + * @return + */ + public List fetchClusterNodeOfMachine(String ip, int port, boolean includeZero) { + String type = "notZero"; + if (includeZero) { + type = "zero"; + } + return fetchItems(ip, port, CLUSTER_NODE_PATH, type, NodeVo.class); + } + + public List fetchFlowRuleOfMachine(String app, String ip, int port) { + List rules = fetchRules(ip, port, FLOW_RULE_TYPE, FlowRule.class); + if (rules != null) { + return rules.stream().map(rule -> FlowRuleEntity.fromFlowRule(app, ip, port, rule)) + .collect(Collectors.toList()); + } else { + return null; + } + } + + public List fetchDegradeRuleOfMachine(String app, String ip, int port) { + List rules = fetchRules(ip, port, DEGRADE_RULE_TYPE, DegradeRule.class); + if (rules != null) { + return rules.stream().map(rule -> DegradeRuleEntity.fromDegradeRule(app, ip, port, rule)) + .collect(Collectors.toList()); + } else { + return null; + } + } + + public List fetchSystemRuleOfMachine(String app, String ip, int port) { + List rules = fetchRules(ip, port, SYSTEM_RULE_TYPE, SystemRule.class); + if (rules != null) { + return rules.stream().map(rule -> SystemRuleEntity.fromSystemRule(app, ip, port, rule)) + .collect(Collectors.toList()); + } else { + return null; + } + } + + /** + * Fetch all parameter flow rules from provided machine. + * + * @param app application name + * @param ip machine client IP + * @param port machine client port + * @return all retrieved parameter flow rules + * @since 0.2.1 + */ + public CompletableFuture> fetchParamFlowRulesOfMachine(String app, String ip, int port) { + try { + AssertUtil.notEmpty(app, "Bad app name"); + AssertUtil.notEmpty(ip, "Bad machine IP"); + AssertUtil.isTrue(port > 0, "Bad machine port"); + return fetchItemsAsync(ip, port, GET_PARAM_RULE_PATH, null, ParamFlowRule.class) + .thenApply(rules -> rules.stream() + .map(e -> ParamFlowRuleEntity.fromAuthorityRule(app, ip, port, e)) + .collect(Collectors.toList()) + ); + } catch (Exception e) { + logger.error("Error when fetching parameter flow rules", e); + return AsyncUtils.newFailedFuture(e); + } + } + + /** + * Fetch all authority rules from provided machine. + * + * @param app application name + * @param ip machine client IP + * @param port machine client port + * @return all retrieved authority rules + * @since 0.2.1 + */ + public List fetchAuthorityRulesOfMachine(String app, String ip, int port) { + AssertUtil.notEmpty(app, "Bad app name"); + AssertUtil.notEmpty(ip, "Bad machine IP"); + AssertUtil.isTrue(port > 0, "Bad machine port"); + Map params = new HashMap<>(1); + params.put("type", AUTHORITY_TYPE); + List rules = fetchRules(ip, port, AUTHORITY_TYPE, AuthorityRule.class); + return Optional.ofNullable(rules).map(r -> r.stream() + .map(e -> AuthorityRuleEntity.fromAuthorityRule(app, ip, port, e)) + .collect(Collectors.toList()) + ).orElse(null); + } + + /** + * set rules of the machine. rules == null will return immediately; + * rules.isEmpty() means setting the rules to empty. + * + * @param app + * @param ip + * @param port + * @param rules + * @return whether successfully set the rules. + */ + public boolean setFlowRuleOfMachine(String app, String ip, int port, List rules) { + return setRules(app, ip, port, FLOW_RULE_TYPE, rules); + } + + public CompletableFuture setFlowRuleOfMachineAsync(String app, String ip, int port, List rules) { + return setRulesAsync(app, ip, port, FLOW_RULE_TYPE, rules); + } + + /** + * set rules of the machine. rules == null will return immediately; + * rules.isEmpty() means setting the rules to empty. + * + * @param app + * @param ip + * @param port + * @param rules + * @return whether successfully set the rules. + */ + public boolean setDegradeRuleOfMachine(String app, String ip, int port, List rules) { + return setRules(app, ip, port, DEGRADE_RULE_TYPE, rules); + } + + /** + * set rules of the machine. rules == null will return immediately; + * rules.isEmpty() means setting the rules to empty. + * + * @param app + * @param ip + * @param port + * @param rules + * @return whether successfully set the rules. + */ + public boolean setSystemRuleOfMachine(String app, String ip, int port, List rules) { + return setRules(app, ip, port, SYSTEM_RULE_TYPE, rules); + } + + public boolean setAuthorityRuleOfMachine(String app, String ip, int port, List rules) { + return setRules(app, ip, port, AUTHORITY_TYPE, rules); + } + + public CompletableFuture setParamFlowRuleOfMachine(String app, String ip, int port, List rules) { + if (rules == null) { + return CompletableFuture.completedFuture(null); + } + if (StringUtil.isBlank(ip) || port <= 0) { + return AsyncUtils.newFailedFuture(new IllegalArgumentException("Invalid parameter")); + } + try { + String data = JSON.toJSONString( + rules.stream().map(ParamFlowRuleEntity::getRule).collect(Collectors.toList()) + ); + Map params = new HashMap<>(1); + params.put("data", data); + return executeCommand(app, ip, port, SET_PARAM_RULE_PATH, params, true) + .thenCompose(e -> { + if (CommandConstants.MSG_SUCCESS.equals(e)) { + return CompletableFuture.completedFuture(null); + } else { + logger.warn("Push parameter flow rules to client failed: " + e); + return AsyncUtils.newFailedFuture(new RuntimeException(e)); + } + }); + } catch (Exception ex) { + logger.warn("Error when setting parameter flow rule", ex); + return AsyncUtils.newFailedFuture(ex); + } + } + + // Cluster related + + public CompletableFuture fetchClusterMode(String ip, int port) { + if (StringUtil.isBlank(ip) || port <= 0) { + return AsyncUtils.newFailedFuture(new IllegalArgumentException("Invalid parameter")); + } + try { + return executeCommand(ip, port, FETCH_CLUSTER_MODE_PATH, false) + .thenApply(r -> JSON.parseObject(r, ClusterStateSimpleEntity.class)); + } catch (Exception ex) { + logger.warn("Error when fetching cluster mode", ex); + return AsyncUtils.newFailedFuture(ex); + } + } + + public CompletableFuture modifyClusterMode(String ip, int port, int mode) { + if (StringUtil.isBlank(ip) || port <= 0) { + return AsyncUtils.newFailedFuture(new IllegalArgumentException("Invalid parameter")); + } + try { + Map params = new HashMap<>(1); + params.put("mode", String.valueOf(mode)); + return executeCommand(ip, port, MODIFY_CLUSTER_MODE_PATH, params, false) + .thenCompose(e -> { + if (CommandConstants.MSG_SUCCESS.equals(e)) { + return CompletableFuture.completedFuture(null); + } else { + logger.warn("Error when modifying cluster mode: " + e); + return AsyncUtils.newFailedFuture(new RuntimeException(e)); + } + }); + } catch (Exception ex) { + logger.warn("Error when modifying cluster mode", ex); + return AsyncUtils.newFailedFuture(ex); + } + } + + public CompletableFuture fetchClusterClientInfoAndConfig(String ip, int port) { + if (StringUtil.isBlank(ip) || port <= 0) { + return AsyncUtils.newFailedFuture(new IllegalArgumentException("Invalid parameter")); + } + try { + return executeCommand(ip, port, FETCH_CLUSTER_CLIENT_CONFIG_PATH, false) + .thenApply(r -> JSON.parseObject(r, ClusterClientInfoVO.class)); + } catch (Exception ex) { + logger.warn("Error when fetching cluster client config", ex); + return AsyncUtils.newFailedFuture(ex); + } + } + + public CompletableFuture modifyClusterClientConfig(String app, String ip, int port, ClusterClientConfig config) { + if (StringUtil.isBlank(ip) || port <= 0) { + return AsyncUtils.newFailedFuture(new IllegalArgumentException("Invalid parameter")); + } + try { + Map params = new HashMap<>(1); + params.put("data", JSON.toJSONString(config)); + return executeCommand(app, ip, port, MODIFY_CLUSTER_CLIENT_CONFIG_PATH, params, true) + .thenCompose(e -> { + if (CommandConstants.MSG_SUCCESS.equals(e)) { + return CompletableFuture.completedFuture(null); + } else { + logger.warn("Error when modifying cluster client config: " + e); + return AsyncUtils.newFailedFuture(new RuntimeException(e)); + } + }); + } catch (Exception ex) { + logger.warn("Error when modifying cluster client config", ex); + return AsyncUtils.newFailedFuture(ex); + } + } + + public CompletableFuture modifyClusterServerFlowConfig(String app, String ip, int port, ServerFlowConfig config) { + if (StringUtil.isBlank(ip) || port <= 0) { + return AsyncUtils.newFailedFuture(new IllegalArgumentException("Invalid parameter")); + } + try { + Map params = new HashMap<>(1); + params.put("data", JSON.toJSONString(config)); + return executeCommand(app, ip, port, MODIFY_CLUSTER_SERVER_FLOW_CONFIG_PATH, params, true) + .thenCompose(e -> { + if (CommandConstants.MSG_SUCCESS.equals(e)) { + return CompletableFuture.completedFuture(null); + } else { + logger.warn("Error when modifying cluster server flow config: " + e); + return AsyncUtils.newFailedFuture(new RuntimeException(e)); + } + }); + } catch (Exception ex) { + logger.warn("Error when modifying cluster server flow config", ex); + return AsyncUtils.newFailedFuture(ex); + } + } + + public CompletableFuture modifyClusterServerTransportConfig(String app, String ip, int port, ServerTransportConfig config) { + if (StringUtil.isBlank(ip) || port <= 0) { + return AsyncUtils.newFailedFuture(new IllegalArgumentException("Invalid parameter")); + } + try { + Map params = new HashMap<>(2); + params.put("port", config.getPort().toString()); + params.put("idleSeconds", config.getIdleSeconds().toString()); + return executeCommand(app, ip, port, MODIFY_CLUSTER_SERVER_TRANSPORT_CONFIG_PATH, params, false) + .thenCompose(e -> { + if (CommandConstants.MSG_SUCCESS.equals(e)) { + return CompletableFuture.completedFuture(null); + } else { + logger.warn("Error when modifying cluster server transport config: " + e); + return AsyncUtils.newFailedFuture(new RuntimeException(e)); + } + }); + } catch (Exception ex) { + logger.warn("Error when modifying cluster server transport config", ex); + return AsyncUtils.newFailedFuture(ex); + } + } + + public CompletableFuture modifyClusterServerNamespaceSet(String app, String ip, int port, Set set) { + if (StringUtil.isBlank(ip) || port <= 0) { + return AsyncUtils.newFailedFuture(new IllegalArgumentException("Invalid parameter")); + } + try { + Map params = new HashMap<>(1); + params.put("data", JSON.toJSONString(set)); + return executeCommand(app, ip, port, MODIFY_CLUSTER_SERVER_NAMESPACE_SET_PATH, params, true) + .thenCompose(e -> { + if (CommandConstants.MSG_SUCCESS.equals(e)) { + return CompletableFuture.completedFuture(null); + } else { + logger.warn("Error when modifying cluster server NamespaceSet", e); + return AsyncUtils.newFailedFuture(new RuntimeException(e)); + } + }); + } catch (Exception ex) { + logger.warn("Error when modifying cluster server NamespaceSet", ex); + return AsyncUtils.newFailedFuture(ex); + } + } + + public CompletableFuture fetchClusterServerBasicInfo(String ip, int port) { + if (StringUtil.isBlank(ip) || port <= 0) { + return AsyncUtils.newFailedFuture(new IllegalArgumentException("Invalid parameter")); + } + try { + return executeCommand(ip, port, FETCH_CLUSTER_SERVER_BASIC_INFO_PATH, false) + .thenApply(r -> JSON.parseObject(r, ClusterServerStateVO.class)); + } catch (Exception ex) { + logger.warn("Error when fetching cluster sever all config and basic info", ex); + return AsyncUtils.newFailedFuture(ex); + } + } + + public CompletableFuture> fetchApis(String app, String ip, int port) { + if (StringUtil.isBlank(ip) || port <= 0) { + return AsyncUtils.newFailedFuture(new IllegalArgumentException("Invalid parameter")); + } + + try { + return executeCommand(ip, port, FETCH_GATEWAY_API_PATH, false) + .thenApply(r -> { + List entities = JSON.parseArray(r, ApiDefinitionEntity.class); + if (entities != null) { + for (ApiDefinitionEntity entity : entities) { + entity.setApp(app); + entity.setIp(ip); + entity.setPort(port); + } + } + return entities; + }); + } catch (Exception ex) { + logger.warn("Error when fetching gateway apis", ex); + return AsyncUtils.newFailedFuture(ex); + } + } + + public boolean modifyApis(String app, String ip, int port, List apis) { + if (apis == null) { + return true; + } + + try { + AssertUtil.notEmpty(app, "Bad app name"); + AssertUtil.notEmpty(ip, "Bad machine IP"); + AssertUtil.isTrue(port > 0, "Bad machine port"); + String data = JSON.toJSONString( + apis.stream().map(r -> r.toApiDefinition()).collect(Collectors.toList())); + Map params = new HashMap<>(2); + params.put("data", data); + String result = executeCommand(app, ip, port, MODIFY_GATEWAY_API_PATH, params, true).get(); + logger.info("Modify gateway apis: {}", result); + return true; + } catch (Exception e) { + logger.warn("Error when modifying gateway apis", e); + return false; + } + } + + public CompletableFuture> fetchGatewayFlowRules(String app, String ip, int port) { + if (StringUtil.isBlank(ip) || port <= 0) { + return AsyncUtils.newFailedFuture(new IllegalArgumentException("Invalid parameter")); + } + + try { + return executeCommand(ip, port, FETCH_GATEWAY_FLOW_RULE_PATH, false) + .thenApply(r -> { + List gatewayFlowRules = JSON.parseArray(r, GatewayFlowRule.class); + List entities = gatewayFlowRules.stream().map(rule -> GatewayFlowRuleEntity.fromGatewayFlowRule(app, ip, port, rule)).collect(Collectors.toList()); + return entities; + }); + } catch (Exception ex) { + logger.warn("Error when fetching gateway flow rules", ex); + return AsyncUtils.newFailedFuture(ex); + } + } + + public boolean modifyGatewayFlowRules(String app, String ip, int port, List rules) { + if (rules == null) { + return true; + } + + try { + AssertUtil.notEmpty(app, "Bad app name"); + AssertUtil.notEmpty(ip, "Bad machine IP"); + AssertUtil.isTrue(port > 0, "Bad machine port"); + String data = JSON.toJSONString( + rules.stream().map(r -> r.toGatewayFlowRule()).collect(Collectors.toList())); + Map params = new HashMap<>(2); + params.put("data", data); + String result = executeCommand(app, ip, port, MODIFY_GATEWAY_FLOW_RULE_PATH, params, true).get(); + logger.info("Modify gateway flow rules: {}", result); + return true; + } catch (Exception e) { + logger.warn("Error when modifying gateway apis", e); + return false; + } + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/DashboardConfig.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/DashboardConfig.java new file mode 100755 index 00000000..92e0608e --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/DashboardConfig.java @@ -0,0 +1,140 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.config; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.springframework.lang.NonNull; + +/** + *

Dashboard local config support.

+ *

+ * Dashboard supports configuration loading by several ways by order:
+ * 1. System.properties
+ * 2. Env + *

+ * + * @author jason + * @since 1.5.0 + */ +public class DashboardConfig { + + public static final int DEFAULT_MACHINE_HEALTHY_TIMEOUT_MS = 60_000; + + /** + * Login username + */ + public static final String CONFIG_AUTH_USERNAME = "sentinel.dashboard.auth.username"; + + /** + * Login password + */ + public static final String CONFIG_AUTH_PASSWORD = "sentinel.dashboard.auth.password"; + + /** + * Hide application name in sidebar when it has no healthy machines after specific period in millisecond. + */ + public static final String CONFIG_HIDE_APP_NO_MACHINE_MILLIS = "sentinel.dashboard.app.hideAppNoMachineMillis"; + /** + * Remove application when it has no healthy machines after specific period in millisecond. + */ + public static final String CONFIG_REMOVE_APP_NO_MACHINE_MILLIS = "sentinel.dashboard.removeAppNoMachineMillis"; + /** + * Timeout + */ + public static final String CONFIG_UNHEALTHY_MACHINE_MILLIS = "sentinel.dashboard.unhealthyMachineMillis"; + /** + * Auto remove unhealthy machine after specific period in millisecond. + */ + public static final String CONFIG_AUTO_REMOVE_MACHINE_MILLIS = "sentinel.dashboard.autoRemoveMachineMillis"; + + private static final ConcurrentMap cacheMap = new ConcurrentHashMap<>(); + + @NonNull + private static String getConfig(String name) { + // env + String val = System.getenv(name); + if (StringUtils.isNotEmpty(val)) { + return val; + } + // properties + val = System.getProperty(name); + if (StringUtils.isNotEmpty(val)) { + return val; + } + return ""; + } + + protected static String getConfigStr(String name) { + if (cacheMap.containsKey(name)) { + return (String) cacheMap.get(name); + } + + String val = getConfig(name); + + if (StringUtils.isBlank(val)) { + return null; + } + + cacheMap.put(name, val); + return val; + } + + protected static int getConfigInt(String name, int defaultVal, int minVal) { + if (cacheMap.containsKey(name)) { + return (int)cacheMap.get(name); + } + int val = NumberUtils.toInt(getConfig(name)); + if (val == 0) { + val = defaultVal; + } else if (val < minVal) { + val = minVal; + } + cacheMap.put(name, val); + return val; + } + + public static String getAuthUsername() { + return getConfigStr(CONFIG_AUTH_USERNAME); + } + + public static String getAuthPassword() { + return getConfigStr(CONFIG_AUTH_PASSWORD); + } + + public static int getHideAppNoMachineMillis() { + return getConfigInt(CONFIG_HIDE_APP_NO_MACHINE_MILLIS, 0, 60000); + } + + public static int getRemoveAppNoMachineMillis() { + return getConfigInt(CONFIG_REMOVE_APP_NO_MACHINE_MILLIS, 0, 120000); + } + + public static int getAutoRemoveMachineMillis() { + return getConfigInt(CONFIG_AUTO_REMOVE_MACHINE_MILLIS, 0, 300000); + } + + public static int getUnhealthyMachineMillis() { + return getConfigInt(CONFIG_UNHEALTHY_MACHINE_MILLIS, DEFAULT_MACHINE_HEALTHY_TIMEOUT_MS, 30000); + } + + public static void clearCache() { + cacheMap.clear(); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/WebConfig.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/WebConfig.java new file mode 100755 index 00000000..92e51e54 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/WebConfig.java @@ -0,0 +1,116 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.config; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter; +import com.alibaba.csp.sentinel.adapter.servlet.callback.WebCallbackManager; +import com.alibaba.csp.sentinel.dashboard.auth.AuthorizationInterceptor; +import com.alibaba.csp.sentinel.dashboard.auth.LoginAuthenticationFilter; +import com.alibaba.csp.sentinel.util.StringUtil; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import javax.annotation.PostConstruct; +import javax.servlet.Filter; + +/** + * @author leyou + */ +@Configuration +public class WebConfig implements WebMvcConfigurer { + + private final Logger logger = LoggerFactory.getLogger(WebConfig.class); + + @Autowired + private LoginAuthenticationFilter loginAuthenticationFilter; + + @Autowired + private AuthorizationInterceptor authorizationInterceptor; + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(authorizationInterceptor).addPathPatterns("/**"); + } + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/**").addResourceLocations("classpath:/resources/"); + } + + @Override + public void addViewControllers(ViewControllerRegistry registry) { + registry.addViewController("/").setViewName("forward:/index.htm"); + } + + /** + * Add {@link CommonFilter} to the server, this is the simplest way to use Sentinel + * for Web application. + */ + @Bean + public FilterRegistrationBean sentinelFilterRegistration() { + FilterRegistrationBean registration = new FilterRegistrationBean<>(); + registration.setFilter(new CommonFilter()); + registration.addUrlPatterns("/*"); + registration.setName("sentinelFilter"); + registration.setOrder(1); + // If this is enabled, the entrance of all Web URL resources will be unified as a single context name. + // In most scenarios that's enough, and it could reduce the memory footprint. + registration.addInitParameter(CommonFilter.WEB_CONTEXT_UNIFY, "true"); + + logger.info("Sentinel servlet CommonFilter registered"); + + return registration; + } + + @PostConstruct + public void doInit() { + Set suffixSet = new HashSet<>(Arrays.asList(".js", ".css", ".html", ".ico", ".txt", + ".woff", ".woff2")); + // Example: register a UrlCleaner to exclude URLs of common static resources. + WebCallbackManager.setUrlCleaner(url -> { + if (StringUtil.isEmpty(url)) { + return url; + } + if (suffixSet.stream().anyMatch(url::endsWith)) { + return null; + } + return url; + }); + } + + @Bean + public FilterRegistrationBean authenticationFilterRegistration() { + FilterRegistrationBean registration = new FilterRegistrationBean<>(); + registration.setFilter(loginAuthenticationFilter); + registration.addUrlPatterns("/*"); + registration.setName("authenticationFilter"); + registration.setOrder(0); + return registration; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java new file mode 100755 index 00000000..63548966 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java @@ -0,0 +1,85 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import com.alibaba.csp.sentinel.dashboard.discovery.AppInfo; +import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.dashboard.domain.vo.MachineInfoVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author Carpenter Lee + */ +@RestController +@RequestMapping(value = "/app") +public class AppController { + + @Autowired + private AppManagement appManagement; + + @GetMapping("/names.json") + public Result> queryApps(HttpServletRequest request) { + return Result.ofSuccess(appManagement.getAppNames()); + } + + @GetMapping("/briefinfos.json") + public Result> queryAppInfos(HttpServletRequest request) { + List list = new ArrayList<>(appManagement.getBriefApps()); + Collections.sort(list, Comparator.comparing(AppInfo::getApp)); + return Result.ofSuccess(list); + } + + @GetMapping(value = "/{app}/machines.json") + public Result> getMachinesByApp(@PathVariable("app") String app) { + AppInfo appInfo = appManagement.getDetailApp(app); + if (appInfo == null) { + return Result.ofSuccess(null); + } + List list = new ArrayList<>(appInfo.getMachines()); + Collections.sort(list, Comparator.comparing(MachineInfo::getApp).thenComparing(MachineInfo::getIp).thenComparingInt(MachineInfo::getPort)); + return Result.ofSuccess(MachineInfoVo.fromMachineInfoList(list)); + } + + @RequestMapping(value = "/{app}/machine/remove.json") + public Result removeMachineById( + @PathVariable("app") String app, + @RequestParam(name = "ip") String ip, + @RequestParam(name = "port") int port) { + AppInfo appInfo = appManagement.getDetailApp(app); + if (appInfo == null) { + return Result.ofSuccess(null); + } + if (appManagement.removeMachine(app, ip, port)) { + return Result.ofSuccessMsg("success"); + } else { + return Result.ofFail(1, "remove failed"); + } + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AuthController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AuthController.java new file mode 100755 index 00000000..8b01aed2 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AuthController.java @@ -0,0 +1,92 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller; + +import com.alibaba.csp.sentinel.dashboard.auth.AuthService; +import com.alibaba.csp.sentinel.dashboard.auth.SimpleWebAuthServiceImpl; +import com.alibaba.csp.sentinel.dashboard.config.DashboardConfig; +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + +/** + * @author cdfive + * @since 1.6.0 + */ +@RestController +@RequestMapping("/auth") +public class AuthController { + + private static final Logger LOGGER = LoggerFactory.getLogger(AuthController.class); + + @Value("${auth.username:sentinel}") + private String authUsername; + + @Value("${auth.password:sentinel}") + private String authPassword; + + @Autowired + private AuthService authService; + + @PostMapping("/login") + public Result login(HttpServletRequest request, String username, String password) { + if (StringUtils.isNotBlank(DashboardConfig.getAuthUsername())) { + authUsername = DashboardConfig.getAuthUsername(); + } + + if (StringUtils.isNotBlank(DashboardConfig.getAuthPassword())) { + authPassword = DashboardConfig.getAuthPassword(); + } + + /* + * If auth.username or auth.password is blank(set in application.properties or VM arguments), + * auth will pass, as the front side validate the input which can't be blank, + * so user can input any username or password(both are not blank) to login in that case. + */ + if (StringUtils.isNotBlank(authUsername) && !authUsername.equals(username) + || StringUtils.isNotBlank(authPassword) && !authPassword.equals(password)) { + LOGGER.error("Login failed: Invalid username or password, username=" + username); + return Result.ofFail(-1, "Invalid username or password"); + } + + AuthService.AuthUser authUser = new SimpleWebAuthServiceImpl.SimpleWebAuthUserImpl(username); + request.getSession().setAttribute(SimpleWebAuthServiceImpl.WEB_SESSION_KEY, authUser); + return Result.ofSuccess(authUser); + } + + @PostMapping(value = "/logout") + public Result logout(HttpServletRequest request) { + request.getSession().invalidate(); + return Result.ofSuccess(null); + } + + @PostMapping(value = "/check") + public Result check(HttpServletRequest request) { + AuthService.AuthUser authUser = authService.getAuthUser(request); + if (authUser == null) { + return Result.ofFail(-1, "Not logged in"); + } + return Result.ofSuccess(authUser); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AuthorityRuleController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AuthorityRuleController.java new file mode 100755 index 00000000..294455f0 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AuthorityRuleController.java @@ -0,0 +1,191 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller; + +import java.util.Date; +import java.util.List; + +import com.alibaba.csp.sentinel.dashboard.auth.AuthAction; +import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; +import com.alibaba.csp.sentinel.slots.block.RuleConstant; +import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AuthorityRuleEntity; +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.dashboard.repository.rule.RuleRepository; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author Eric Zhao + * @since 0.2.1 + */ +@RestController +@RequestMapping(value = "/authority") +public class AuthorityRuleController { + + private final Logger logger = LoggerFactory.getLogger(AuthorityRuleController.class); + + @Autowired + private SentinelApiClient sentinelApiClient; + @Autowired + private RuleRepository repository; + + @GetMapping("/rules") + @AuthAction(PrivilegeType.READ_RULE) + public Result> apiQueryAllRulesForMachine(@RequestParam String app, + @RequestParam String ip, + @RequestParam Integer port) { + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app cannot be null or empty"); + } + if (StringUtil.isEmpty(ip)) { + return Result.ofFail(-1, "ip cannot be null or empty"); + } + if (port == null || port <= 0) { + return Result.ofFail(-1, "Invalid parameter: port"); + } + try { + List rules = sentinelApiClient.fetchAuthorityRulesOfMachine(app, ip, port); + rules = repository.saveAll(rules); + return Result.ofSuccess(rules); + } catch (Throwable throwable) { + logger.error("Error when querying authority rules", throwable); + return Result.ofFail(-1, throwable.getMessage()); + } + } + + private Result checkEntityInternal(AuthorityRuleEntity entity) { + if (entity == null) { + return Result.ofFail(-1, "bad rule body"); + } + if (StringUtil.isBlank(entity.getApp())) { + return Result.ofFail(-1, "app can't be null or empty"); + } + if (StringUtil.isBlank(entity.getIp())) { + return Result.ofFail(-1, "ip can't be null or empty"); + } + if (entity.getPort() == null || entity.getPort() <= 0) { + return Result.ofFail(-1, "port can't be null"); + } + if (entity.getRule() == null) { + return Result.ofFail(-1, "rule can't be null"); + } + if (StringUtil.isBlank(entity.getResource())) { + return Result.ofFail(-1, "resource name cannot be null or empty"); + } + if (StringUtil.isBlank(entity.getLimitApp())) { + return Result.ofFail(-1, "limitApp should be valid"); + } + if (entity.getStrategy() != RuleConstant.AUTHORITY_WHITE + && entity.getStrategy() != RuleConstant.AUTHORITY_BLACK) { + return Result.ofFail(-1, "Unknown strategy (must be blacklist or whitelist)"); + } + return null; + } + + @PostMapping("/rule") + @AuthAction(PrivilegeType.WRITE_RULE) + public Result apiAddAuthorityRule(@RequestBody AuthorityRuleEntity entity) { + Result checkResult = checkEntityInternal(entity); + if (checkResult != null) { + return checkResult; + } + entity.setId(null); + Date date = new Date(); + entity.setGmtCreate(date); + entity.setGmtModified(date); + try { + entity = repository.save(entity); + } catch (Throwable throwable) { + logger.error("Failed to add authority rule", throwable); + return Result.ofThrowable(-1, throwable); + } + if (!publishRules(entity.getApp(), entity.getIp(), entity.getPort())) { + logger.info("Publish authority rules failed after rule add"); + } + return Result.ofSuccess(entity); + } + + @PutMapping("/rule/{id}") + @AuthAction(PrivilegeType.WRITE_RULE) + public Result apiUpdateParamFlowRule(@PathVariable("id") Long id, + @RequestBody AuthorityRuleEntity entity) { + if (id == null || id <= 0) { + return Result.ofFail(-1, "Invalid id"); + } + Result checkResult = checkEntityInternal(entity); + if (checkResult != null) { + return checkResult; + } + entity.setId(id); + Date date = new Date(); + entity.setGmtCreate(null); + entity.setGmtModified(date); + try { + entity = repository.save(entity); + if (entity == null) { + return Result.ofFail(-1, "Failed to save authority rule"); + } + } catch (Throwable throwable) { + logger.error("Failed to save authority rule", throwable); + return Result.ofThrowable(-1, throwable); + } + if (!publishRules(entity.getApp(), entity.getIp(), entity.getPort())) { + logger.info("Publish authority rules failed after rule update"); + } + return Result.ofSuccess(entity); + } + + @DeleteMapping("/rule/{id}") + @AuthAction(PrivilegeType.DELETE_RULE) + public Result apiDeleteRule(@PathVariable("id") Long id) { + if (id == null) { + return Result.ofFail(-1, "id cannot be null"); + } + AuthorityRuleEntity oldEntity = repository.findById(id); + if (oldEntity == null) { + return Result.ofSuccess(null); + } + try { + repository.delete(id); + } catch (Exception e) { + return Result.ofFail(-1, e.getMessage()); + } + if (!publishRules(oldEntity.getApp(), oldEntity.getIp(), oldEntity.getPort())) { + logger.error("Publish authority rules failed after rule delete"); + } + return Result.ofSuccess(id); + } + + private boolean publishRules(String app, String ip, Integer port) { + List rules = repository.findAllByMachine(MachineInfo.of(app, ip, port)); + return sentinelApiClient.setAuthorityRuleOfMachine(app, ip, port, rules); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DegradeController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DegradeController.java new file mode 100755 index 00000000..61aaee68 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DegradeController.java @@ -0,0 +1,214 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller; + +import java.util.Date; +import java.util.List; + +import com.alibaba.csp.sentinel.dashboard.auth.AuthAction; +import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; +import com.alibaba.csp.sentinel.slots.block.RuleConstant; +import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.DegradeRuleEntity; +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.dashboard.repository.rule.InMemDegradeRuleStore; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * @author leyou + */ +@Controller +@RequestMapping(value = "/degrade", produces = MediaType.APPLICATION_JSON_VALUE) +public class DegradeController { + + private final Logger logger = LoggerFactory.getLogger(DegradeController.class); + + @Autowired + private InMemDegradeRuleStore repository; + @Autowired + private SentinelApiClient sentinelApiClient; + + @ResponseBody + @RequestMapping("/rules.json") + @AuthAction(PrivilegeType.READ_RULE) + public Result> queryMachineRules(String app, String ip, Integer port) { + + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app can't be null or empty"); + } + if (StringUtil.isEmpty(ip)) { + return Result.ofFail(-1, "ip can't be null or empty"); + } + if (port == null) { + return Result.ofFail(-1, "port can't be null"); + } + try { + List rules = sentinelApiClient.fetchDegradeRuleOfMachine(app, ip, port); + rules = repository.saveAll(rules); + return Result.ofSuccess(rules); + } catch (Throwable throwable) { + logger.error("queryApps error:", throwable); + return Result.ofThrowable(-1, throwable); + } + } + + @ResponseBody + @RequestMapping("/new.json") + @AuthAction(PrivilegeType.WRITE_RULE) + public Result add(String app, String ip, Integer port, String limitApp, String resource, + Double count, Integer timeWindow, Integer grade) { + if (StringUtil.isBlank(app)) { + return Result.ofFail(-1, "app can't be null or empty"); + } + if (StringUtil.isBlank(ip)) { + return Result.ofFail(-1, "ip can't be null or empty"); + } + if (port == null) { + return Result.ofFail(-1, "port can't be null"); + } + if (StringUtil.isBlank(limitApp)) { + return Result.ofFail(-1, "limitApp can't be null or empty"); + } + if (StringUtil.isBlank(resource)) { + return Result.ofFail(-1, "resource can't be null or empty"); + } + if (count == null) { + return Result.ofFail(-1, "count can't be null"); + } + if (timeWindow == null) { + return Result.ofFail(-1, "timeWindow can't be null"); + } + if (grade == null) { + return Result.ofFail(-1, "grade can't be null"); + } + if (grade < RuleConstant.DEGRADE_GRADE_RT || grade > RuleConstant.DEGRADE_GRADE_EXCEPTION_COUNT) { + return Result.ofFail(-1, "Invalid grade: " + grade); + } + DegradeRuleEntity entity = new DegradeRuleEntity(); + entity.setApp(app.trim()); + entity.setIp(ip.trim()); + entity.setPort(port); + entity.setLimitApp(limitApp.trim()); + entity.setResource(resource.trim()); + entity.setCount(count); + entity.setTimeWindow(timeWindow); + entity.setGrade(grade); + Date date = new Date(); + entity.setGmtCreate(date); + entity.setGmtModified(date); + try { + entity = repository.save(entity); + } catch (Throwable throwable) { + logger.error("add error:", throwable); + return Result.ofThrowable(-1, throwable); + } + if (!publishRules(app, ip, port)) { + logger.info("publish degrade rules fail after rule add"); + } + return Result.ofSuccess(entity); + } + + @ResponseBody + @RequestMapping("/save.json") + @AuthAction(PrivilegeType.WRITE_RULE) + public Result updateIfNotNull(Long id, String app, String limitApp, String resource, + Double count, Integer timeWindow, Integer grade) { + if (id == null) { + return Result.ofFail(-1, "id can't be null"); + } + if (grade != null) { + if (grade < RuleConstant.DEGRADE_GRADE_RT || grade > RuleConstant.DEGRADE_GRADE_EXCEPTION_COUNT) { + return Result.ofFail(-1, "Invalid grade: " + grade); + } + } + DegradeRuleEntity entity = repository.findById(id); + if (entity == null) { + return Result.ofFail(-1, "id " + id + " dose not exist"); + } + + if (StringUtil.isNotBlank(app)) { + entity.setApp(app.trim()); + } + + if (StringUtil.isNotBlank(limitApp)) { + entity.setLimitApp(limitApp.trim()); + } + if (StringUtil.isNotBlank(resource)) { + entity.setResource(resource.trim()); + } + if (count != null) { + entity.setCount(count); + } + if (timeWindow != null) { + entity.setTimeWindow(timeWindow); + } + if (grade != null) { + entity.setGrade(grade); + } + Date date = new Date(); + entity.setGmtModified(date); + try { + entity = repository.save(entity); + } catch (Throwable throwable) { + logger.error("save error:", throwable); + return Result.ofThrowable(-1, throwable); + } + if (!publishRules(entity.getApp(), entity.getIp(), entity.getPort())) { + logger.info("publish degrade rules fail after rule update"); + } + return Result.ofSuccess(entity); + } + + @ResponseBody + @RequestMapping("/delete.json") + @AuthAction(PrivilegeType.DELETE_RULE) + public Result delete(Long id) { + if (id == null) { + return Result.ofFail(-1, "id can't be null"); + } + + DegradeRuleEntity oldEntity = repository.findById(id); + if (oldEntity == null) { + return Result.ofSuccess(null); + } + + try { + repository.delete(id); + } catch (Throwable throwable) { + logger.error("delete error:", throwable); + return Result.ofThrowable(-1, throwable); + } + if (!publishRules(oldEntity.getApp(), oldEntity.getIp(), oldEntity.getPort())) { + logger.info("publish degrade rules fail after rule delete"); + } + return Result.ofSuccess(id); + } + + private boolean publishRules(String app, String ip, Integer port) { + List rules = repository.findAllByMachine(MachineInfo.of(app, ip, port)); + return sentinelApiClient.setDegradeRuleOfMachine(app, ip, port, rules); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DemoController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DemoController.java new file mode 100755 index 00000000..91ae6712 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DemoController.java @@ -0,0 +1,135 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller; + +import java.util.Random; +import java.util.concurrent.TimeUnit; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.alibaba.csp.sentinel.Entry; +import com.alibaba.csp.sentinel.EntryType; +import com.alibaba.csp.sentinel.SphU; +import com.alibaba.csp.sentinel.context.ContextUtil; +import com.alibaba.csp.sentinel.slots.block.BlockException; + +@Controller +@RequestMapping(value = "/demo", produces = MediaType.APPLICATION_JSON_VALUE) +public class DemoController { + + Logger logger = LoggerFactory.getLogger(MachineRegistryController.class); + + @RequestMapping("/greeting") + public String greeting() { + return "index"; + } + + @RequestMapping("/link") + @ResponseBody + public String link() throws BlockException { + + Entry entry = SphU.entry("head1", EntryType.IN); + + Entry entry1 = SphU.entry("head2", EntryType.IN); + Entry entry2 = SphU.entry("head3", EntryType.IN); + Entry entry3 = SphU.entry("head4", EntryType.IN); + + entry3.exit(); + entry2.exit(); + entry1.exit(); + entry.exit(); + return "successfully create a call link"; + } + + @RequestMapping("/loop") + @ResponseBody + public String loop(String name, int time) throws BlockException { + for (int i = 0; i < 10; i++) { + Thread timer = new Thread(new RunTask(name, time, false)); + timer.setName("false"); + timer.start(); + } + return "successfully create a loop thread"; + } + + @RequestMapping("/slow") + @ResponseBody + public String slow(String name, int time) throws BlockException { + for (int i = 0; i < 10; i++) { + Thread timer = new Thread(new RunTask(name, time, true)); + timer.setName("false"); + timer.start(); + } + return "successfully create a loop thread"; + } + + static class RunTask implements Runnable { + int time; + boolean stop = false; + String name; + boolean slow = false; + + public RunTask(String name, int time, boolean slow) { + super(); + this.time = time; + this.name = name; + this.slow = slow; + } + + @Override + public void run() { + long startTime = System.currentTimeMillis(); + ContextUtil.enter(String.valueOf(startTime)); + while (!stop) { + + long now = System.currentTimeMillis(); + if (now - startTime > time * 1000) { + stop = true; + } + Entry e1 = null; + try { + e1 = SphU.entry(name); + + if (slow == true) { + TimeUnit.MILLISECONDS.sleep(3000); + } + + } catch (Exception e) { + } finally { + if (e1 != null) { + e1.exit(); + } + } + Random random2 = new Random(); + try { + TimeUnit.MILLISECONDS.sleep(random2.nextInt(200)); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + ContextUtil.exit(); + } + + } + +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/FlowControllerV1.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/FlowControllerV1.java new file mode 100755 index 00000000..50c4e32f --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/FlowControllerV1.java @@ -0,0 +1,273 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller; + +import java.util.Date; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + +import com.alibaba.csp.sentinel.dashboard.auth.AuthAction; +import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; +import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.dashboard.repository.rule.InMemoryRuleRepositoryAdapter; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * Flow rule controller. + * + * @author leyou + * @author Eric Zhao + */ +@RestController +@RequestMapping(value = "/v1/flow") +public class FlowControllerV1 { + + private final Logger logger = LoggerFactory.getLogger(FlowControllerV1.class); + + @Autowired + private InMemoryRuleRepositoryAdapter repository; + + @Autowired + private SentinelApiClient sentinelApiClient; + + @GetMapping("/rules") + @AuthAction(PrivilegeType.READ_RULE) + public Result> apiQueryMachineRules(@RequestParam String app, + @RequestParam String ip, + @RequestParam Integer port) { + + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app can't be null or empty"); + } + if (StringUtil.isEmpty(ip)) { + return Result.ofFail(-1, "ip can't be null or empty"); + } + if (port == null) { + return Result.ofFail(-1, "port can't be null"); + } + try { + List rules = sentinelApiClient.fetchFlowRuleOfMachine(app, ip, port); + rules = repository.saveAll(rules); + return Result.ofSuccess(rules); + } catch (Throwable throwable) { + logger.error("Error when querying flow rules", throwable); + return Result.ofThrowable(-1, throwable); + } + } + + private Result checkEntityInternal(FlowRuleEntity entity) { + if (StringUtil.isBlank(entity.getApp())) { + return Result.ofFail(-1, "app can't be null or empty"); + } + if (StringUtil.isBlank(entity.getIp())) { + return Result.ofFail(-1, "ip can't be null or empty"); + } + if (entity.getPort() == null) { + return Result.ofFail(-1, "port can't be null"); + } + if (StringUtil.isBlank(entity.getLimitApp())) { + return Result.ofFail(-1, "limitApp can't be null or empty"); + } + if (StringUtil.isBlank(entity.getResource())) { + return Result.ofFail(-1, "resource can't be null or empty"); + } + if (entity.getGrade() == null) { + return Result.ofFail(-1, "grade can't be null"); + } + if (entity.getGrade() != 0 && entity.getGrade() != 1) { + return Result.ofFail(-1, "grade must be 0 or 1, but " + entity.getGrade() + " got"); + } + if (entity.getCount() == null || entity.getCount() < 0) { + return Result.ofFail(-1, "count should be at lease zero"); + } + if (entity.getStrategy() == null) { + return Result.ofFail(-1, "strategy can't be null"); + } + if (entity.getStrategy() != 0 && StringUtil.isBlank(entity.getRefResource())) { + return Result.ofFail(-1, "refResource can't be null or empty when strategy!=0"); + } + if (entity.getControlBehavior() == null) { + return Result.ofFail(-1, "controlBehavior can't be null"); + } + int controlBehavior = entity.getControlBehavior(); + if (controlBehavior == 1 && entity.getWarmUpPeriodSec() == null) { + return Result.ofFail(-1, "warmUpPeriodSec can't be null when controlBehavior==1"); + } + if (controlBehavior == 2 && entity.getMaxQueueingTimeMs() == null) { + return Result.ofFail(-1, "maxQueueingTimeMs can't be null when controlBehavior==2"); + } + if (entity.isClusterMode() && entity.getClusterConfig() == null) { + return Result.ofFail(-1, "cluster config should be valid"); + } + return null; + } + + @PostMapping("/rule") + @AuthAction(PrivilegeType.WRITE_RULE) + public Result apiAddFlowRule(@RequestBody FlowRuleEntity entity) { + Result checkResult = checkEntityInternal(entity); + if (checkResult != null) { + return checkResult; + } + entity.setId(null); + Date date = new Date(); + entity.setGmtCreate(date); + entity.setGmtModified(date); + entity.setLimitApp(entity.getLimitApp().trim()); + entity.setResource(entity.getResource().trim()); + try { + entity = repository.save(entity); + + publishRules(entity.getApp(), entity.getIp(), entity.getPort()).get(5000, TimeUnit.MILLISECONDS); + return Result.ofSuccess(entity); + } catch (Throwable t) { + Throwable e = t instanceof ExecutionException ? t.getCause() : t; + logger.error("Failed to add new flow rule, app={}, ip={}", entity.getApp(), entity.getIp(), e); + return Result.ofFail(-1, e.getMessage()); + } + } + + @PutMapping("/save.json") + @AuthAction(PrivilegeType.WRITE_RULE) + public Result apiUpdateFlowRule(Long id, String app, + String limitApp, String resource, Integer grade, + Double count, Integer strategy, String refResource, + Integer controlBehavior, Integer warmUpPeriodSec, + Integer maxQueueingTimeMs) { + if (id == null) { + return Result.ofFail(-1, "id can't be null"); + } + FlowRuleEntity entity = repository.findById(id); + if (entity == null) { + return Result.ofFail(-1, "id " + id + " dose not exist"); + } + if (StringUtil.isNotBlank(app)) { + entity.setApp(app.trim()); + } + if (StringUtil.isNotBlank(limitApp)) { + entity.setLimitApp(limitApp.trim()); + } + if (StringUtil.isNotBlank(resource)) { + entity.setResource(resource.trim()); + } + if (grade != null) { + if (grade != 0 && grade != 1) { + return Result.ofFail(-1, "grade must be 0 or 1, but " + grade + " got"); + } + entity.setGrade(grade); + } + if (count != null) { + entity.setCount(count); + } + if (strategy != null) { + if (strategy != 0 && strategy != 1 && strategy != 2) { + return Result.ofFail(-1, "strategy must be in [0, 1, 2], but " + strategy + " got"); + } + entity.setStrategy(strategy); + if (strategy != 0) { + if (StringUtil.isBlank(refResource)) { + return Result.ofFail(-1, "refResource can't be null or empty when strategy!=0"); + } + entity.setRefResource(refResource.trim()); + } + } + if (controlBehavior != null) { + if (controlBehavior != 0 && controlBehavior != 1 && controlBehavior != 2) { + return Result.ofFail(-1, "controlBehavior must be in [0, 1, 2], but " + controlBehavior + " got"); + } + if (controlBehavior == 1 && warmUpPeriodSec == null) { + return Result.ofFail(-1, "warmUpPeriodSec can't be null when controlBehavior==1"); + } + if (controlBehavior == 2 && maxQueueingTimeMs == null) { + return Result.ofFail(-1, "maxQueueingTimeMs can't be null when controlBehavior==2"); + } + entity.setControlBehavior(controlBehavior); + if (warmUpPeriodSec != null) { + entity.setWarmUpPeriodSec(warmUpPeriodSec); + } + if (maxQueueingTimeMs != null) { + entity.setMaxQueueingTimeMs(maxQueueingTimeMs); + } + } + Date date = new Date(); + entity.setGmtModified(date); + try { + entity = repository.save(entity); + if (entity == null) { + return Result.ofFail(-1, "save entity fail: null"); + } + + publishRules(entity.getApp(), entity.getIp(), entity.getPort()).get(5000, TimeUnit.MILLISECONDS); + return Result.ofSuccess(entity); + } catch (Throwable t) { + Throwable e = t instanceof ExecutionException ? t.getCause() : t; + logger.error("Error when updating flow rules, app={}, ip={}, ruleId={}", entity.getApp(), + entity.getIp(), id, e); + return Result.ofFail(-1, e.getMessage()); + } + } + + @DeleteMapping("/delete.json") + @AuthAction(PrivilegeType.WRITE_RULE) + public Result apiDeleteFlowRule(Long id) { + + if (id == null) { + return Result.ofFail(-1, "id can't be null"); + } + FlowRuleEntity oldEntity = repository.findById(id); + if (oldEntity == null) { + return Result.ofSuccess(null); + } + + try { + repository.delete(id); + } catch (Exception e) { + return Result.ofFail(-1, e.getMessage()); + } + try { + publishRules(oldEntity.getApp(), oldEntity.getIp(), oldEntity.getPort()).get(5000, TimeUnit.MILLISECONDS); + return Result.ofSuccess(id); + } catch (Throwable t) { + Throwable e = t instanceof ExecutionException ? t.getCause() : t; + logger.error("Error when deleting flow rules, app={}, ip={}, id={}", oldEntity.getApp(), + oldEntity.getIp(), id, e); + return Result.ofFail(-1, e.getMessage()); + } + } + + private CompletableFuture publishRules(String app, String ip, Integer port) { + List rules = repository.findAllByMachine(MachineInfo.of(app, ip, port)); + return sentinelApiClient.setFlowRuleOfMachineAsync(app, ip, port, rules); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MachineRegistryController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MachineRegistryController.java new file mode 100755 index 00000000..9a9a7f76 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MachineRegistryController.java @@ -0,0 +1,77 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller; + +import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; +import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.discovery.MachineDiscovery; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping(value = "/registry", produces = MediaType.APPLICATION_JSON_VALUE) +public class MachineRegistryController { + + private final Logger logger = LoggerFactory.getLogger(MachineRegistryController.class); + + @Autowired + private AppManagement appManagement; + + @ResponseBody + @RequestMapping("/machine") + public Result receiveHeartBeat(String app, @RequestParam(value = "app_type", required = false, defaultValue = "0") Integer appType, Long version, String v, String hostname, String ip, Integer port) { + if (app == null) { + app = MachineDiscovery.UNKNOWN_APP_NAME; + } + if (ip == null) { + return Result.ofFail(-1, "ip can't be null"); + } + if (port == null) { + return Result.ofFail(-1, "port can't be null"); + } + if (port == -1) { + logger.info("Receive heartbeat from " + ip + " but port not set yet"); + return Result.ofFail(-1, "your port not set yet"); + } + String sentinelVersion = StringUtil.isEmpty(v) ? "unknown" : v; + version = version == null ? System.currentTimeMillis() : version; + try { + MachineInfo machineInfo = new MachineInfo(); + machineInfo.setApp(app); + machineInfo.setAppType(appType); + machineInfo.setHostname(hostname); + machineInfo.setIp(ip); + machineInfo.setPort(port); + machineInfo.setHeartbeatVersion(version); + machineInfo.setLastHeartbeat(System.currentTimeMillis()); + machineInfo.setVersion(sentinelVersion); + appManagement.addMachine(machineInfo); + return Result.ofSuccessMsg("success"); + } catch (Exception e) { + logger.error("Receive heartbeat error", e); + return Result.ofFail(-1, e.getMessage()); + } + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MetricController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MetricController.java new file mode 100755 index 00000000..ab90c0fc --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MetricController.java @@ -0,0 +1,175 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import java.util.concurrent.ConcurrentHashMap; + +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.dashboard.repository.metric.MetricsRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.MetricEntity; +import com.alibaba.csp.sentinel.dashboard.domain.vo.MetricVo; + +/** + * @author leyou + */ +@Controller +@RequestMapping(value = "/metric", produces = MediaType.APPLICATION_JSON_VALUE) +public class MetricController { + + private static Logger logger = LoggerFactory.getLogger(MetricController.class); + + private static final long maxQueryIntervalMs = 1000 * 60 * 60; + + @Autowired + private MetricsRepository metricStore; + + @ResponseBody + @RequestMapping("/queryTopResourceMetric.json") + public Result queryTopResourceMetric(final String app, + Integer pageIndex, + Integer pageSize, + Boolean desc, + Long startTime, Long endTime, String searchKey) { + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app can't be null or empty"); + } + if (pageIndex == null || pageIndex <= 0) { + pageIndex = 1; + } + if (pageSize == null) { + pageSize = 6; + } + if (pageSize >= 20) { + pageSize = 20; + } + if (desc == null) { + desc = true; + } + if (endTime == null) { + endTime = System.currentTimeMillis(); + } + if (startTime == null) { + startTime = endTime - 1000 * 60 * 5; + } + if (endTime - startTime > maxQueryIntervalMs) { + return Result.ofFail(-1, "time intervalMs is too big, must <= 1h"); + } + List resources = metricStore.listResourcesOfApp(app); + logger.debug("queryTopResourceMetric(), resources.size()={}", resources.size()); + + if (resources == null || resources.isEmpty()) { + return Result.ofSuccess(null); + } + if (!desc) { + Collections.reverse(resources); + } + if (StringUtil.isNotEmpty(searchKey)) { + List searched = new ArrayList<>(); + for (String resource : resources) { + if (resource.contains(searchKey)) { + searched.add(resource); + } + } + resources = searched; + } + int totalPage = (resources.size() + pageSize - 1) / pageSize; + List topResource = new ArrayList<>(); + if (pageIndex <= totalPage) { + topResource = resources.subList((pageIndex - 1) * pageSize, + Math.min(pageIndex * pageSize, resources.size())); + } + final Map> map = new ConcurrentHashMap<>(); + logger.debug("topResource={}", topResource); + long time = System.currentTimeMillis(); + for (final String resource : topResource) { + List entities = metricStore.queryByAppAndResourceBetween( + app, resource, startTime, endTime); + logger.debug("resource={}, entities.size()={}", resource, entities == null ? "null" : entities.size()); + List vos = MetricVo.fromMetricEntities(entities, resource); + Iterable vosSorted = sortMetricVoAndDistinct(vos); + map.put(resource, vosSorted); + } + logger.debug("queryTopResourceMetric() total query time={} ms", System.currentTimeMillis() - time); + Map resultMap = new HashMap<>(16); + resultMap.put("totalCount", resources.size()); + resultMap.put("totalPage", totalPage); + resultMap.put("pageIndex", pageIndex); + resultMap.put("pageSize", pageSize); + + Map> map2 = new LinkedHashMap<>(); + // order matters. + for (String identity : topResource) { + map2.put(identity, map.get(identity)); + } + resultMap.put("metric", map2); + return Result.ofSuccess(resultMap); + } + + @ResponseBody + @RequestMapping("/queryByAppAndResource.json") + public Result queryByAppAndResource(String app, String identity, Long startTime, Long endTime) { + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app can't be null or empty"); + } + if (StringUtil.isEmpty(identity)) { + return Result.ofFail(-1, "identity can't be null or empty"); + } + if (endTime == null) { + endTime = System.currentTimeMillis(); + } + if (startTime == null) { + startTime = endTime - 1000 * 60; + } + if (endTime - startTime > maxQueryIntervalMs) { + return Result.ofFail(-1, "time intervalMs is too big, must <= 1h"); + } + List entities = metricStore.queryByAppAndResourceBetween( + app, identity, startTime, endTime); + List vos = MetricVo.fromMetricEntities(entities, identity); + return Result.ofSuccess(sortMetricVoAndDistinct(vos)); + } + + private Iterable sortMetricVoAndDistinct(List vos) { + if (vos == null) { + return null; + } + Map map = new TreeMap<>(); + for (MetricVo vo : vos) { + MetricVo oldVo = map.get(vo.getTimestamp()); + if (oldVo == null || vo.getGmtCreate() > oldVo.getGmtCreate()) { + map.put(vo.getTimestamp(), vo); + } + } + return map.values(); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java new file mode 100755 index 00000000..f03925ee --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java @@ -0,0 +1,259 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller; + +import com.alibaba.csp.sentinel.dashboard.auth.AuthAction; +import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; +import com.alibaba.csp.sentinel.dashboard.client.CommandNotFoundException; +import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.SentinelVersion; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.ParamFlowRuleEntity; +import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.dashboard.repository.rule.RuleRepository; +import com.alibaba.csp.sentinel.dashboard.util.VersionUtils; +import com.alibaba.csp.sentinel.slots.block.RuleConstant; +import com.alibaba.csp.sentinel.util.StringUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Date; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +/** + * @author Eric Zhao + * @since 0.2.1 + */ +@RestController +@RequestMapping(value = "/paramFlow") +public class ParamFlowRuleController { + + private final Logger logger = LoggerFactory.getLogger(ParamFlowRuleController.class); + + @Autowired + private SentinelApiClient sentinelApiClient; + @Autowired + private AppManagement appManagement; + @Autowired + private RuleRepository repository; + + private boolean checkIfSupported(String app, String ip, int port) { + try { + return Optional.ofNullable(appManagement.getDetailApp(app)) + .flatMap(e -> e.getMachine(ip, port)) + .flatMap(m -> VersionUtils.parseVersion(m.getVersion()) + .map(v -> v.greaterOrEqual(version020))) + .orElse(true); + // If error occurred or cannot retrieve machine info, return true. + } catch (Exception ex) { + return true; + } + } + + @GetMapping("/rules") + @AuthAction(PrivilegeType.READ_RULE) + public Result> apiQueryAllRulesForMachine(@RequestParam String app, + @RequestParam String ip, + @RequestParam Integer port) { + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app cannot be null or empty"); + } + if (StringUtil.isEmpty(ip)) { + return Result.ofFail(-1, "ip cannot be null or empty"); + } + if (port == null || port <= 0) { + return Result.ofFail(-1, "Invalid parameter: port"); + } + if (!checkIfSupported(app, ip, port)) { + return unsupportedVersion(); + } + try { + return sentinelApiClient.fetchParamFlowRulesOfMachine(app, ip, port) + .thenApply(repository::saveAll) + .thenApply(Result::ofSuccess) + .get(); + } catch (ExecutionException ex) { + logger.error("Error when querying parameter flow rules", ex.getCause()); + if (isNotSupported(ex.getCause())) { + return unsupportedVersion(); + } else { + return Result.ofThrowable(-1, ex.getCause()); + } + } catch (Throwable throwable) { + logger.error("Error when querying parameter flow rules", throwable); + return Result.ofFail(-1, throwable.getMessage()); + } + } + + private boolean isNotSupported(Throwable ex) { + return ex instanceof CommandNotFoundException; + } + + @PostMapping("/rule") + @AuthAction(PrivilegeType.WRITE_RULE) + public Result apiAddParamFlowRule(@RequestBody ParamFlowRuleEntity entity) { + Result checkResult = checkEntityInternal(entity); + if (checkResult != null) { + return checkResult; + } + if (!checkIfSupported(entity.getApp(), entity.getIp(), entity.getPort())) { + return unsupportedVersion(); + } + entity.setId(null); + entity.getRule().setResource(entity.getResource().trim()); + Date date = new Date(); + entity.setGmtCreate(date); + entity.setGmtModified(date); + try { + entity = repository.save(entity); + publishRules(entity.getApp(), entity.getIp(), entity.getPort()).get(); + return Result.ofSuccess(entity); + } catch (ExecutionException ex) { + logger.error("Error when adding new parameter flow rules", ex.getCause()); + if (isNotSupported(ex.getCause())) { + return unsupportedVersion(); + } else { + return Result.ofThrowable(-1, ex.getCause()); + } + } catch (Throwable throwable) { + logger.error("Error when adding new parameter flow rules", throwable); + return Result.ofFail(-1, throwable.getMessage()); + } + } + + private Result checkEntityInternal(ParamFlowRuleEntity entity) { + if (entity == null) { + return Result.ofFail(-1, "bad rule body"); + } + if (StringUtil.isBlank(entity.getApp())) { + return Result.ofFail(-1, "app can't be null or empty"); + } + if (StringUtil.isBlank(entity.getIp())) { + return Result.ofFail(-1, "ip can't be null or empty"); + } + if (entity.getPort() == null || entity.getPort() <= 0) { + return Result.ofFail(-1, "port can't be null"); + } + if (entity.getRule() == null) { + return Result.ofFail(-1, "rule can't be null"); + } + if (StringUtil.isBlank(entity.getResource())) { + return Result.ofFail(-1, "resource name cannot be null or empty"); + } + if (entity.getCount() < 0) { + return Result.ofFail(-1, "count should be valid"); + } + if (entity.getGrade() != RuleConstant.FLOW_GRADE_QPS) { + return Result.ofFail(-1, "Unknown mode (blockGrade) for parameter flow control"); + } + if (entity.getParamIdx() == null || entity.getParamIdx() < 0) { + return Result.ofFail(-1, "paramIdx should be valid"); + } + if (entity.getDurationInSec() <= 0) { + return Result.ofFail(-1, "durationInSec should be valid"); + } + if (entity.getControlBehavior() < 0) { + return Result.ofFail(-1, "controlBehavior should be valid"); + } + return null; + } + + @PutMapping("/rule/{id}") + @AuthAction(PrivilegeType.WRITE_RULE) + public Result apiUpdateParamFlowRule(@PathVariable("id") Long id, + @RequestBody ParamFlowRuleEntity entity) { + if (id == null || id <= 0) { + return Result.ofFail(-1, "Invalid id"); + } + ParamFlowRuleEntity oldEntity = repository.findById(id); + if (oldEntity == null) { + return Result.ofFail(-1, "id " + id + " does not exist"); + } + + Result checkResult = checkEntityInternal(entity); + if (checkResult != null) { + return checkResult; + } + if (!checkIfSupported(entity.getApp(), entity.getIp(), entity.getPort())) { + return unsupportedVersion(); + } + entity.setId(id); + Date date = new Date(); + entity.setGmtCreate(oldEntity.getGmtCreate()); + entity.setGmtModified(date); + try { + entity = repository.save(entity); + publishRules(entity.getApp(), entity.getIp(), entity.getPort()).get(); + return Result.ofSuccess(entity); + } catch (ExecutionException ex) { + logger.error("Error when updating parameter flow rules, id=" + id, ex.getCause()); + if (isNotSupported(ex.getCause())) { + return unsupportedVersion(); + } else { + return Result.ofThrowable(-1, ex.getCause()); + } + } catch (Throwable throwable) { + logger.error("Error when updating parameter flow rules, id=" + id, throwable); + return Result.ofFail(-1, throwable.getMessage()); + } + } + + @DeleteMapping("/rule/{id}") + @AuthAction(PrivilegeType.DELETE_RULE) + public Result apiDeleteRule(@PathVariable("id") Long id) { + if (id == null) { + return Result.ofFail(-1, "id cannot be null"); + } + ParamFlowRuleEntity oldEntity = repository.findById(id); + if (oldEntity == null) { + return Result.ofSuccess(null); + } + + try { + repository.delete(id); + publishRules(oldEntity.getApp(), oldEntity.getIp(), oldEntity.getPort()).get(); + return Result.ofSuccess(id); + } catch (ExecutionException ex) { + logger.error("Error when deleting parameter flow rules", ex.getCause()); + if (isNotSupported(ex.getCause())) { + return unsupportedVersion(); + } else { + return Result.ofThrowable(-1, ex.getCause()); + } + } catch (Throwable throwable) { + logger.error("Error when deleting parameter flow rules", throwable); + return Result.ofFail(-1, throwable.getMessage()); + } + } + + private CompletableFuture publishRules(String app, String ip, Integer port) { + List rules = repository.findAllByMachine(MachineInfo.of(app, ip, port)); + return sentinelApiClient.setParamFlowRuleOfMachine(app, ip, port, rules); + } + + private Result unsupportedVersion() { + return Result.ofFail(4041, + "Sentinel client not supported for parameter flow control (unsupported version or dependency absent)"); + } + + private final SentinelVersion version020 = new SentinelVersion().setMinorVersion(2); +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ResourceController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ResourceController.java new file mode 100755 index 00000000..70382c7e --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ResourceController.java @@ -0,0 +1,91 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller; + +import java.util.List; +import java.util.stream.Collectors; + +import com.alibaba.csp.sentinel.util.StringUtil; +import com.alibaba.csp.sentinel.command.vo.NodeVo; + +import com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode; +import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.dashboard.domain.vo.ResourceVo; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author Carpenter Lee + */ +@RestController +@RequestMapping(value = "/resource") +public class ResourceController { + + private static Logger logger = LoggerFactory.getLogger(ResourceController.class); + + @Autowired + private SentinelApiClient httpFetcher; + + /** + * Fetch real time statistics info of the machine. + * + * @param ip ip to fetch + * @param port port of the ip + * @param type one of [root, default, cluster], 'root' means fetching from tree root node, 'default' means + * fetching from tree default node, 'cluster' means fetching from cluster node. + * @param searchKey key to search + * @return node statistics info. + */ + @GetMapping("/machineResource.json") + public Result> fetchResourceChainListOfMachine(String ip, Integer port, String type, + String searchKey) { + if (StringUtil.isEmpty(ip) || port == null) { + return Result.ofFail(-1, "invalid param, give ip, port"); + } + final String ROOT = "root"; + final String DEFAULT = "default"; + if (StringUtil.isEmpty(type)) { + type = ROOT; + } + if (ROOT.equalsIgnoreCase(type) || DEFAULT.equalsIgnoreCase(type)) { + List nodeVos = httpFetcher.fetchResourceOfMachine(ip, port, type); + if (nodeVos == null) { + return Result.ofSuccess(null); + } + ResourceTreeNode treeNode = ResourceTreeNode.fromNodeVoList(nodeVos); + treeNode.searchIgnoreCase(searchKey); + return Result.ofSuccess(ResourceVo.fromResourceTreeNode(treeNode)); + } else { + // Normal (cluster node). + List nodeVos = httpFetcher.fetchClusterNodeOfMachine(ip, port, true); + if (nodeVos == null) { + return Result.ofSuccess(null); + } + if (StringUtil.isNotEmpty(searchKey)) { + nodeVos = nodeVos.stream().filter(node -> node.getResource() + .toLowerCase().contains(searchKey.toLowerCase())) + .collect(Collectors.toList()); + } + return Result.ofSuccess(ResourceVo.fromNodeVoList(nodeVos)); + } + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java new file mode 100755 index 00000000..daa0b98b --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java @@ -0,0 +1,250 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller; + +import java.util.Date; +import java.util.List; + +import com.alibaba.csp.sentinel.dashboard.auth.AuthAction; +import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; +import com.alibaba.csp.sentinel.dashboard.repository.rule.RuleRepository; +import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.SystemRuleEntity; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.domain.Result; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author leyou(lihao) + */ +@RestController +@RequestMapping("/system") +public class SystemController { + + private final Logger logger = LoggerFactory.getLogger(SystemController.class); + + @Autowired + private RuleRepository repository; + @Autowired + private SentinelApiClient sentinelApiClient; + + private Result checkBasicParams(String app, String ip, Integer port) { + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app can't be null or empty"); + } + if (StringUtil.isEmpty(ip)) { + return Result.ofFail(-1, "ip can't be null or empty"); + } + if (port == null) { + return Result.ofFail(-1, "port can't be null"); + } + if (port <= 0 || port > 65535) { + return Result.ofFail(-1, "port should be in (0, 65535)"); + } + return null; + } + + @GetMapping("/rules.json") + @AuthAction(PrivilegeType.READ_RULE) + public Result> apiQueryMachineRules(String app, String ip, + Integer port) { + Result> checkResult = checkBasicParams(app, ip, port); + if (checkResult != null) { + return checkResult; + } + try { + List rules = sentinelApiClient.fetchSystemRuleOfMachine(app, ip, port); + rules = repository.saveAll(rules); + return Result.ofSuccess(rules); + } catch (Throwable throwable) { + logger.error("Query machine system rules error", throwable); + return Result.ofThrowable(-1, throwable); + } + } + + private int countNotNullAndNotNegative(Number... values) { + int notNullCount = 0; + for (int i = 0; i < values.length; i++) { + if (values[i] != null && values[i].doubleValue() >= 0) { + notNullCount++; + } + } + return notNullCount; + } + + @RequestMapping("/new.json") + @AuthAction(PrivilegeType.WRITE_RULE) + public Result apiAdd(String app, String ip, Integer port, + Double highestSystemLoad, Double highestCpuUsage, Long avgRt, + Long maxThread, Double qps) { + + Result checkResult = checkBasicParams(app, ip, port); + if (checkResult != null) { + return checkResult; + } + + int notNullCount = countNotNullAndNotNegative(highestSystemLoad, avgRt, maxThread, qps, highestCpuUsage); + if (notNullCount != 1) { + return Result.ofFail(-1, "only one of [highestSystemLoad, avgRt, maxThread, qps,highestCpuUsage] " + + "value must be set > 0, but " + notNullCount + " values get"); + } + if (null != highestCpuUsage && highestCpuUsage > 1) { + return Result.ofFail(-1, "highestCpuUsage must between [0.0, 1.0]"); + } + SystemRuleEntity entity = new SystemRuleEntity(); + entity.setApp(app.trim()); + entity.setIp(ip.trim()); + entity.setPort(port); + // -1 is a fake value + if (null != highestSystemLoad) { + entity.setHighestSystemLoad(highestSystemLoad); + } else { + entity.setHighestSystemLoad(-1D); + } + + if (null != highestCpuUsage) { + entity.setHighestCpuUsage(highestCpuUsage); + } else { + entity.setHighestCpuUsage(-1D); + } + + if (avgRt != null) { + entity.setAvgRt(avgRt); + } else { + entity.setAvgRt(-1L); + } + if (maxThread != null) { + entity.setMaxThread(maxThread); + } else { + entity.setMaxThread(-1L); + } + if (qps != null) { + entity.setQps(qps); + } else { + entity.setQps(-1D); + } + Date date = new Date(); + entity.setGmtCreate(date); + entity.setGmtModified(date); + try { + entity = repository.save(entity); + } catch (Throwable throwable) { + logger.error("Add SystemRule error", throwable); + return Result.ofThrowable(-1, throwable); + } + if (!publishRules(app, ip, port)) { + logger.warn("Publish system rules fail after rule add"); + } + return Result.ofSuccess(entity); + } + + @GetMapping("/save.json") + @AuthAction(PrivilegeType.WRITE_RULE) + public Result apiUpdateIfNotNull(Long id, String app, Double highestSystemLoad, + Double highestCpuUsage, Long avgRt, Long maxThread, Double qps) { + if (id == null) { + return Result.ofFail(-1, "id can't be null"); + } + SystemRuleEntity entity = repository.findById(id); + if (entity == null) { + return Result.ofFail(-1, "id " + id + " dose not exist"); + } + + if (StringUtil.isNotBlank(app)) { + entity.setApp(app.trim()); + } + if (highestSystemLoad != null) { + if (highestSystemLoad < 0) { + return Result.ofFail(-1, "highestSystemLoad must >= 0"); + } + entity.setHighestSystemLoad(highestSystemLoad); + } + if (highestCpuUsage != null) { + if (highestCpuUsage < 0) { + return Result.ofFail(-1, "highestCpuUsage must >= 0"); + } + if (highestCpuUsage > 1) { + return Result.ofFail(-1, "highestCpuUsage must <= 1"); + } + entity.setHighestCpuUsage(highestCpuUsage); + } + if (avgRt != null) { + if (avgRt < 0) { + return Result.ofFail(-1, "avgRt must >= 0"); + } + entity.setAvgRt(avgRt); + } + if (maxThread != null) { + if (maxThread < 0) { + return Result.ofFail(-1, "maxThread must >= 0"); + } + entity.setMaxThread(maxThread); + } + if (qps != null) { + if (qps < 0) { + return Result.ofFail(-1, "qps must >= 0"); + } + entity.setQps(qps); + } + Date date = new Date(); + entity.setGmtModified(date); + try { + entity = repository.save(entity); + } catch (Throwable throwable) { + logger.error("save error:", throwable); + return Result.ofThrowable(-1, throwable); + } + if (!publishRules(entity.getApp(), entity.getIp(), entity.getPort())) { + logger.info("publish system rules fail after rule update"); + } + return Result.ofSuccess(entity); + } + + @RequestMapping("/delete.json") + @AuthAction(PrivilegeType.DELETE_RULE) + public Result delete(Long id) { + if (id == null) { + return Result.ofFail(-1, "id can't be null"); + } + SystemRuleEntity oldEntity = repository.findById(id); + if (oldEntity == null) { + return Result.ofSuccess(null); + } + try { + repository.delete(id); + } catch (Throwable throwable) { + logger.error("delete error:", throwable); + return Result.ofThrowable(-1, throwable); + } + if (!publishRules(oldEntity.getApp(), oldEntity.getIp(), oldEntity.getPort())) { + logger.info("publish system rules fail after rule delete"); + } + return Result.ofSuccess(id); + } + + private boolean publishRules(String app, String ip, Integer port) { + List rules = repository.findAllByMachine(MachineInfo.of(app, ip, port)); + return sentinelApiClient.setSystemRuleOfMachine(app, ip, port, rules); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/VersionController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/VersionController.java new file mode 100755 index 00000000..69d66ea1 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/VersionController.java @@ -0,0 +1,49 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller; + +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.util.StringUtil; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author hisenyuan + * @since 1.7.0 + */ +@RestController +public class VersionController { + + private static final String VERSION_PATTERN = "-"; + + @Value("${sentinel.dashboard.version:}") + private String sentinelDashboardVersion; + + @GetMapping("/version") + public Result apiGetVersion() { + if (StringUtil.isNotBlank(sentinelDashboardVersion)) { + String res = sentinelDashboardVersion; + if (sentinelDashboardVersion.contains(VERSION_PATTERN)) { + res = sentinelDashboardVersion.substring(0, sentinelDashboardVersion.indexOf(VERSION_PATTERN)); + } + return Result.ofSuccess(res); + } else { + return Result.ofFail(1, "getVersion failed: empty version"); + } + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterAssignController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterAssignController.java new file mode 100755 index 00000000..dc2e14f5 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterAssignController.java @@ -0,0 +1,104 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller.cluster; + +import java.util.Collections; +import java.util.Set; + +import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppFullAssignRequest; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppSingleServerAssignRequest; +import com.alibaba.csp.sentinel.dashboard.service.ClusterAssignService; +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author Eric Zhao + * @since 1.4.1 + */ +@RestController +@RequestMapping("/cluster/assign") +public class ClusterAssignController { + + private final Logger logger = LoggerFactory.getLogger(ClusterAssignController.class); + + @Autowired + private ClusterAssignService clusterAssignService; + + @PostMapping("/all_server/{app}") + public Result apiAssignAllClusterServersOfApp(@PathVariable String app, + @RequestBody + ClusterAppFullAssignRequest assignRequest) { + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app cannot be null or empty"); + } + if (assignRequest == null || assignRequest.getClusterMap() == null + || assignRequest.getRemainingList() == null) { + return Result.ofFail(-1, "bad request body"); + } + try { + return Result.ofSuccess(clusterAssignService.applyAssignToApp(app, assignRequest.getClusterMap(), + assignRequest.getRemainingList())); + } catch (Throwable throwable) { + logger.error("Error when assigning full cluster servers for app: " + app, throwable); + return Result.ofFail(-1, throwable.getMessage()); + } + } + + @PostMapping("/single_server/{app}") + public Result apiAssignSingleClusterServersOfApp(@PathVariable String app, + @RequestBody ClusterAppSingleServerAssignRequest assignRequest) { + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app cannot be null or empty"); + } + if (assignRequest == null || assignRequest.getClusterMap() == null) { + return Result.ofFail(-1, "bad request body"); + } + try { + return Result.ofSuccess(clusterAssignService.applyAssignToApp(app, Collections.singletonList(assignRequest.getClusterMap()), + assignRequest.getRemainingList())); + } catch (Throwable throwable) { + logger.error("Error when assigning single cluster servers for app: " + app, throwable); + return Result.ofFail(-1, throwable.getMessage()); + } + } + + @PostMapping("/unbind_server/{app}") + public Result apiUnbindClusterServersOfApp(@PathVariable String app, + @RequestBody Set machineIds) { + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app cannot be null or empty"); + } + if (machineIds == null || machineIds.isEmpty()) { + return Result.ofFail(-1, "bad request body"); + } + try { + return Result.ofSuccess(clusterAssignService.unbindClusterServers(app, machineIds)); + } catch (Throwable throwable) { + logger.error("Error when unbinding cluster server {} for app <{}>", machineIds, app, throwable); + return Result.ofFail(-1, throwable.getMessage()); + } + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterConfigController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterConfigController.java new file mode 100755 index 00000000..e9b9aed0 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterConfigController.java @@ -0,0 +1,245 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller.cluster; + +import java.util.List; +import java.util.Optional; +import java.util.concurrent.ExecutionException; + +import com.alibaba.csp.sentinel.cluster.ClusterStateManager; +import com.alibaba.csp.sentinel.dashboard.client.CommandNotFoundException; +import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; +import com.alibaba.csp.sentinel.util.StringUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.SentinelVersion; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterClientModifyRequest; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterModifyRequest; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterServerModifyRequest; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.AppClusterClientStateWrapVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.AppClusterServerStateWrapVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStatePairVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStateVO; +import com.alibaba.csp.sentinel.dashboard.service.ClusterConfigService; +import com.alibaba.csp.sentinel.dashboard.util.ClusterEntityUtils; +import com.alibaba.csp.sentinel.dashboard.util.VersionUtils; +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +@RestController +@RequestMapping(value = "/cluster") +public class ClusterConfigController { + + private final Logger logger = LoggerFactory.getLogger(ClusterConfigController.class); + + private final SentinelVersion version140 = new SentinelVersion().setMajorVersion(1).setMinorVersion(4); + + @Autowired + private AppManagement appManagement; + + @Autowired + private ClusterConfigService clusterConfigService; + + @PostMapping("/config/modify_single") + public Result apiModifyClusterConfig(@RequestBody String payload) { + if (StringUtil.isBlank(payload)) { + return Result.ofFail(-1, "empty request body"); + } + try { + JSONObject body = JSON.parseObject(payload); + if (body.containsKey(KEY_MODE)) { + int mode = body.getInteger(KEY_MODE); + switch (mode) { + case ClusterStateManager.CLUSTER_CLIENT: + ClusterClientModifyRequest data = JSON.parseObject(payload, ClusterClientModifyRequest.class); + Result res = checkValidRequest(data); + if (res != null) { + return res; + } + clusterConfigService.modifyClusterClientConfig(data).get(); + return Result.ofSuccess(true); + case ClusterStateManager.CLUSTER_SERVER: + ClusterServerModifyRequest d = JSON.parseObject(payload, ClusterServerModifyRequest.class); + Result r = checkValidRequest(d); + if (r != null) { + return r; + } + // TODO: bad design here, should refactor! + clusterConfigService.modifyClusterServerConfig(d).get(); + return Result.ofSuccess(true); + default: + return Result.ofFail(-1, "invalid mode"); + } + } + return Result.ofFail(-1, "invalid parameter"); + } catch (ExecutionException ex) { + logger.error("Error when modifying cluster config", ex.getCause()); + return errorResponse(ex); + } catch (Throwable ex) { + logger.error("Error when modifying cluster config", ex); + return Result.ofFail(-1, ex.getMessage()); + } + } + + private Result errorResponse(ExecutionException ex) { + if (isNotSupported(ex.getCause())) { + return unsupportedVersion(); + } else { + return Result.ofThrowable(-1, ex.getCause()); + } + } + + @GetMapping("/state_single") + public Result apiGetClusterState(@RequestParam String app, + @RequestParam String ip, + @RequestParam Integer port) { + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app cannot be null or empty"); + } + if (StringUtil.isEmpty(ip)) { + return Result.ofFail(-1, "ip cannot be null or empty"); + } + if (port == null || port <= 0) { + return Result.ofFail(-1, "Invalid parameter: port"); + } + if (!checkIfSupported(app, ip, port)) { + return unsupportedVersion(); + } + try { + return clusterConfigService.getClusterUniversalState(app, ip, port) + .thenApply(Result::ofSuccess) + .get(); + } catch (ExecutionException ex) { + logger.error("Error when fetching cluster state", ex.getCause()); + return errorResponse(ex); + } catch (Throwable throwable) { + logger.error("Error when fetching cluster state", throwable); + return Result.ofFail(-1, throwable.getMessage()); + } + } + + @GetMapping("/server_state/{app}") + public Result> apiGetClusterServerStateOfApp(@PathVariable String app) { + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app cannot be null or empty"); + } + try { + return clusterConfigService.getClusterUniversalState(app) + .thenApply(ClusterEntityUtils::wrapToAppClusterServerState) + .thenApply(Result::ofSuccess) + .get(); + } catch (ExecutionException ex) { + logger.error("Error when fetching cluster server state of app: " + app, ex.getCause()); + return errorResponse(ex); + } catch (Throwable throwable) { + logger.error("Error when fetching cluster server state of app: " + app, throwable); + return Result.ofFail(-1, throwable.getMessage()); + } + } + + @GetMapping("/client_state/{app}") + public Result> apiGetClusterClientStateOfApp(@PathVariable String app) { + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app cannot be null or empty"); + } + try { + return clusterConfigService.getClusterUniversalState(app) + .thenApply(ClusterEntityUtils::wrapToAppClusterClientState) + .thenApply(Result::ofSuccess) + .get(); + } catch (ExecutionException ex) { + logger.error("Error when fetching cluster token client state of app: " + app, ex.getCause()); + return errorResponse(ex); + } catch (Throwable throwable) { + logger.error("Error when fetching cluster token client state of app: " + app, throwable); + return Result.ofFail(-1, throwable.getMessage()); + } + } + + @GetMapping("/state/{app}") + public Result> apiGetClusterStateOfApp(@PathVariable String app) { + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app cannot be null or empty"); + } + try { + return clusterConfigService.getClusterUniversalState(app) + .thenApply(Result::ofSuccess) + .get(); + } catch (ExecutionException ex) { + logger.error("Error when fetching cluster state of app: " + app, ex.getCause()); + return errorResponse(ex); + } catch (Throwable throwable) { + logger.error("Error when fetching cluster state of app: " + app, throwable); + return Result.ofFail(-1, throwable.getMessage()); + } + } + + private boolean isNotSupported(Throwable ex) { + return ex instanceof CommandNotFoundException; + } + + private boolean checkIfSupported(String app, String ip, int port) { + try { + return Optional.ofNullable(appManagement.getDetailApp(app)) + .flatMap(e -> e.getMachine(ip, port)) + .flatMap(m -> VersionUtils.parseVersion(m.getVersion()) + .map(v -> v.greaterOrEqual(version140))) + .orElse(true); + // If error occurred or cannot retrieve machine info, return true. + } catch (Exception ex) { + return true; + } + } + + private Result checkValidRequest(ClusterModifyRequest request) { + if (StringUtil.isEmpty(request.getApp())) { + return Result.ofFail(-1, "app cannot be empty"); + } + if (StringUtil.isEmpty(request.getIp())) { + return Result.ofFail(-1, "ip cannot be empty"); + } + if (request.getPort() == null || request.getPort() < 0) { + return Result.ofFail(-1, "invalid port"); + } + if (request.getMode() == null || request.getMode() < 0) { + return Result.ofFail(-1, "invalid mode"); + } + if (!checkIfSupported(request.getApp(), request.getIp(), request.getPort())) { + return unsupportedVersion(); + } + return null; + } + + private Result unsupportedVersion() { + return Result.ofFail(4041, "Sentinel client not supported for cluster flow control (unsupported version or dependency absent)"); + } + + private static final String KEY_MODE = "mode"; +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/gateway/GatewayApiController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/gateway/GatewayApiController.java new file mode 100755 index 00000000..c7a405d9 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/gateway/GatewayApiController.java @@ -0,0 +1,260 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller.gateway; + +import com.alibaba.csp.sentinel.dashboard.auth.AuthAction; +import com.alibaba.csp.sentinel.dashboard.auth.AuthService; +import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiPredicateItemEntity; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.AddApiReqVo; +import com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.ApiPredicateItemVo; +import com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.UpdateApiReqVo; +import com.alibaba.csp.sentinel.dashboard.repository.gateway.InMemApiDefinitionStore; +import com.alibaba.csp.sentinel.util.StringUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.*; + +import static com.alibaba.csp.sentinel.adapter.gateway.common.SentinelGatewayConstants.*; + +/** + * Gateway api Controller for manage gateway api definitions. + * + * @author cdfive + * @since 1.7.0 + */ +@RestController +@RequestMapping(value = "/gateway/api") +public class GatewayApiController { + + private final Logger logger = LoggerFactory.getLogger(GatewayApiController.class); + + @Autowired + private InMemApiDefinitionStore repository; + + @Autowired + private SentinelApiClient sentinelApiClient; + + @GetMapping("/list.json") + @AuthAction(AuthService.PrivilegeType.READ_RULE) + public Result> queryApis(String app, String ip, Integer port) { + + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app can't be null or empty"); + } + if (StringUtil.isEmpty(ip)) { + return Result.ofFail(-1, "ip can't be null or empty"); + } + if (port == null) { + return Result.ofFail(-1, "port can't be null"); + } + + try { + List apis = sentinelApiClient.fetchApis(app, ip, port).get(); + repository.saveAll(apis); + return Result.ofSuccess(apis); + } catch (Throwable throwable) { + logger.error("queryApis error:", throwable); + return Result.ofThrowable(-1, throwable); + } + } + + @PostMapping("/new.json") + @AuthAction(AuthService.PrivilegeType.WRITE_RULE) + public Result addApi(HttpServletRequest request, @RequestBody AddApiReqVo reqVo) { + + String app = reqVo.getApp(); + if (StringUtil.isBlank(app)) { + return Result.ofFail(-1, "app can't be null or empty"); + } + + ApiDefinitionEntity entity = new ApiDefinitionEntity(); + entity.setApp(app.trim()); + + String ip = reqVo.getIp(); + if (StringUtil.isBlank(ip)) { + return Result.ofFail(-1, "ip can't be null or empty"); + } + entity.setIp(ip.trim()); + + Integer port = reqVo.getPort(); + if (port == null) { + return Result.ofFail(-1, "port can't be null"); + } + entity.setPort(port); + + // API名称 + String apiName = reqVo.getApiName(); + if (StringUtil.isBlank(apiName)) { + return Result.ofFail(-1, "apiName can't be null or empty"); + } + entity.setApiName(apiName.trim()); + + // 匹配规则列表 + List predicateItems = reqVo.getPredicateItems(); + if (CollectionUtils.isEmpty(predicateItems)) { + return Result.ofFail(-1, "predicateItems can't empty"); + } + + List predicateItemEntities = new ArrayList<>(); + for (ApiPredicateItemVo predicateItem : predicateItems) { + ApiPredicateItemEntity predicateItemEntity = new ApiPredicateItemEntity(); + + // 匹配模式 + Integer matchStrategy = predicateItem.getMatchStrategy(); + if (!Arrays.asList(URL_MATCH_STRATEGY_EXACT, URL_MATCH_STRATEGY_PREFIX, URL_MATCH_STRATEGY_REGEX).contains(matchStrategy)) { + return Result.ofFail(-1, "invalid matchStrategy: " + matchStrategy); + } + predicateItemEntity.setMatchStrategy(matchStrategy); + + // 匹配串 + String pattern = predicateItem.getPattern(); + if (StringUtil.isBlank(pattern)) { + return Result.ofFail(-1, "pattern can't be null or empty"); + } + predicateItemEntity.setPattern(pattern); + + predicateItemEntities.add(predicateItemEntity); + } + entity.setPredicateItems(new LinkedHashSet<>(predicateItemEntities)); + + // 检查API名称不能重复 + List allApis = repository.findAllByMachine(MachineInfo.of(app.trim(), ip.trim(), port)); + if (allApis.stream().map(o -> o.getApiName()).anyMatch(o -> o.equals(apiName.trim()))) { + return Result.ofFail(-1, "apiName exists: " + apiName); + } + + Date date = new Date(); + entity.setGmtCreate(date); + entity.setGmtModified(date); + + try { + entity = repository.save(entity); + } catch (Throwable throwable) { + logger.error("add gateway api error:", throwable); + return Result.ofThrowable(-1, throwable); + } + + if (!publishApis(app, ip, port)) { + logger.warn("publish gateway apis fail after add"); + } + + return Result.ofSuccess(entity); + } + + @PostMapping("/save.json") + @AuthAction(AuthService.PrivilegeType.WRITE_RULE) + public Result updateApi(@RequestBody UpdateApiReqVo reqVo) { + String app = reqVo.getApp(); + if (StringUtil.isBlank(app)) { + return Result.ofFail(-1, "app can't be null or empty"); + } + + Long id = reqVo.getId(); + if (id == null) { + return Result.ofFail(-1, "id can't be null"); + } + + ApiDefinitionEntity entity = repository.findById(id); + if (entity == null) { + return Result.ofFail(-1, "api does not exist, id=" + id); + } + + // 匹配规则列表 + List predicateItems = reqVo.getPredicateItems(); + if (CollectionUtils.isEmpty(predicateItems)) { + return Result.ofFail(-1, "predicateItems can't empty"); + } + + List predicateItemEntities = new ArrayList<>(); + for (ApiPredicateItemVo predicateItem : predicateItems) { + ApiPredicateItemEntity predicateItemEntity = new ApiPredicateItemEntity(); + + // 匹配模式 + int matchStrategy = predicateItem.getMatchStrategy(); + if (!Arrays.asList(URL_MATCH_STRATEGY_EXACT, URL_MATCH_STRATEGY_PREFIX, URL_MATCH_STRATEGY_REGEX).contains(matchStrategy)) { + return Result.ofFail(-1, "Invalid matchStrategy: " + matchStrategy); + } + predicateItemEntity.setMatchStrategy(matchStrategy); + + // 匹配串 + String pattern = predicateItem.getPattern(); + if (StringUtil.isBlank(pattern)) { + return Result.ofFail(-1, "pattern can't be null or empty"); + } + predicateItemEntity.setPattern(pattern); + + predicateItemEntities.add(predicateItemEntity); + } + entity.setPredicateItems(new LinkedHashSet<>(predicateItemEntities)); + + Date date = new Date(); + entity.setGmtModified(date); + + try { + entity = repository.save(entity); + } catch (Throwable throwable) { + logger.error("update gateway api error:", throwable); + return Result.ofThrowable(-1, throwable); + } + + if (!publishApis(app, entity.getIp(), entity.getPort())) { + logger.warn("publish gateway apis fail after update"); + } + + return Result.ofSuccess(entity); + } + + @PostMapping("/delete.json") + @AuthAction(AuthService.PrivilegeType.DELETE_RULE) + + public Result deleteApi(Long id) { + if (id == null) { + return Result.ofFail(-1, "id can't be null"); + } + + ApiDefinitionEntity oldEntity = repository.findById(id); + if (oldEntity == null) { + return Result.ofSuccess(null); + } + + try { + repository.delete(id); + } catch (Throwable throwable) { + logger.error("delete gateway api error:", throwable); + return Result.ofThrowable(-1, throwable); + } + + if (!publishApis(oldEntity.getApp(), oldEntity.getIp(), oldEntity.getPort())) { + logger.warn("publish gateway apis fail after delete"); + } + + return Result.ofSuccess(id); + } + + private boolean publishApis(String app, String ip, Integer port) { + List apis = repository.findAllByMachine(MachineInfo.of(app, ip, port)); + return sentinelApiClient.modifyApis(app, ip, port, apis); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/gateway/GatewayFlowRuleController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/gateway/GatewayFlowRuleController.java new file mode 100755 index 00000000..01891637 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/gateway/GatewayFlowRuleController.java @@ -0,0 +1,433 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller.gateway; + + +import com.alibaba.csp.sentinel.dashboard.auth.AuthAction; +import com.alibaba.csp.sentinel.dashboard.auth.AuthService; +import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayFlowRuleEntity; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayParamFlowItemEntity; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.rule.AddFlowRuleReqVo; +import com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.rule.GatewayParamFlowItemVo; +import com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.rule.UpdateFlowRuleReqVo; +import com.alibaba.csp.sentinel.dashboard.repository.gateway.InMemGatewayFlowRuleStore; +import com.alibaba.csp.sentinel.util.StringUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import static com.alibaba.csp.sentinel.slots.block.RuleConstant.*; +import static com.alibaba.csp.sentinel.adapter.gateway.common.SentinelGatewayConstants.*; +import static com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayFlowRuleEntity.*; + +/** + * Gateway flow rule Controller for manage gateway flow rules. + * + * @author cdfive + * @since 1.7.0 + */ +@RestController +@RequestMapping(value = "/gateway/flow") +public class GatewayFlowRuleController { + + private final Logger logger = LoggerFactory.getLogger(GatewayFlowRuleController.class); + + @Autowired + private InMemGatewayFlowRuleStore repository; + + @Autowired + private SentinelApiClient sentinelApiClient; + + @GetMapping("/list.json") + @AuthAction(AuthService.PrivilegeType.READ_RULE) + public Result> queryFlowRules(String app, String ip, Integer port) { + + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app can't be null or empty"); + } + if (StringUtil.isEmpty(ip)) { + return Result.ofFail(-1, "ip can't be null or empty"); + } + if (port == null) { + return Result.ofFail(-1, "port can't be null"); + } + + try { + List rules = sentinelApiClient.fetchGatewayFlowRules(app, ip, port).get(); + repository.saveAll(rules); + return Result.ofSuccess(rules); + } catch (Throwable throwable) { + logger.error("query gateway flow rules error:", throwable); + return Result.ofThrowable(-1, throwable); + } + } + + @PostMapping("/new.json") + @AuthAction(AuthService.PrivilegeType.WRITE_RULE) + public Result addFlowRule(@RequestBody AddFlowRuleReqVo reqVo) { + + String app = reqVo.getApp(); + if (StringUtil.isBlank(app)) { + return Result.ofFail(-1, "app can't be null or empty"); + } + + GatewayFlowRuleEntity entity = new GatewayFlowRuleEntity(); + entity.setApp(app.trim()); + + String ip = reqVo.getIp(); + if (StringUtil.isBlank(ip)) { + return Result.ofFail(-1, "ip can't be null or empty"); + } + entity.setIp(ip.trim()); + + Integer port = reqVo.getPort(); + if (port == null) { + return Result.ofFail(-1, "port can't be null"); + } + entity.setPort(port); + + // API类型, Route ID或API分组 + Integer resourceMode = reqVo.getResourceMode(); + if (resourceMode == null) { + return Result.ofFail(-1, "resourceMode can't be null"); + } + if (!Arrays.asList(RESOURCE_MODE_ROUTE_ID, RESOURCE_MODE_CUSTOM_API_NAME).contains(resourceMode)) { + return Result.ofFail(-1, "invalid resourceMode: " + resourceMode); + } + entity.setResourceMode(resourceMode); + + // API名称 + String resource = reqVo.getResource(); + if (StringUtil.isBlank(resource)) { + return Result.ofFail(-1, "resource can't be null or empty"); + } + entity.setResource(resource.trim()); + + // 针对请求属性 + GatewayParamFlowItemVo paramItem = reqVo.getParamItem(); + if (paramItem != null) { + GatewayParamFlowItemEntity itemEntity = new GatewayParamFlowItemEntity(); + entity.setParamItem(itemEntity); + + // 参数属性 0-ClientIP 1-Remote Host 2-Header 3-URL参数 4-Cookie + Integer parseStrategy = paramItem.getParseStrategy(); + if (!Arrays.asList(PARAM_PARSE_STRATEGY_CLIENT_IP, PARAM_PARSE_STRATEGY_HOST, PARAM_PARSE_STRATEGY_HEADER + , PARAM_PARSE_STRATEGY_URL_PARAM, PARAM_PARSE_STRATEGY_COOKIE).contains(parseStrategy)) { + return Result.ofFail(-1, "invalid parseStrategy: " + parseStrategy); + } + itemEntity.setParseStrategy(paramItem.getParseStrategy()); + + // 当参数属性为2-Header 3-URL参数 4-Cookie时,参数名称必填 + if (Arrays.asList(PARAM_PARSE_STRATEGY_HEADER, PARAM_PARSE_STRATEGY_URL_PARAM, PARAM_PARSE_STRATEGY_COOKIE).contains(parseStrategy)) { + // 参数名称 + String fieldName = paramItem.getFieldName(); + if (StringUtil.isBlank(fieldName)) { + return Result.ofFail(-1, "fieldName can't be null or empty"); + } + itemEntity.setFieldName(paramItem.getFieldName()); + + String pattern = paramItem.getPattern(); + // 如果匹配串不为空,验证匹配模式 + if (StringUtil.isNotEmpty(pattern)) { + itemEntity.setPattern(pattern); + + Integer matchStrategy = paramItem.getMatchStrategy(); + if (!Arrays.asList(PARAM_MATCH_STRATEGY_EXACT, PARAM_MATCH_STRATEGY_CONTAINS, PARAM_MATCH_STRATEGY_REGEX).contains(matchStrategy)) { + return Result.ofFail(-1, "invalid matchStrategy: " + matchStrategy); + } + itemEntity.setMatchStrategy(matchStrategy); + } + } + } + + // 阈值类型 0-线程数 1-QPS + Integer grade = reqVo.getGrade(); + if (grade == null) { + return Result.ofFail(-1, "grade can't be null"); + } + if (!Arrays.asList(FLOW_GRADE_THREAD, FLOW_GRADE_QPS).contains(grade)) { + return Result.ofFail(-1, "invalid grade: " + grade); + } + entity.setGrade(grade); + + // QPS阈值 + Double count = reqVo.getCount(); + if (count == null) { + return Result.ofFail(-1, "count can't be null"); + } + if (count < 0) { + return Result.ofFail(-1, "count should be at lease zero"); + } + entity.setCount(count); + + // 间隔 + Long interval = reqVo.getInterval(); + if (interval == null) { + return Result.ofFail(-1, "interval can't be null"); + } + if (interval <= 0) { + return Result.ofFail(-1, "interval should be greater than zero"); + } + entity.setInterval(interval); + + // 间隔单位 + Integer intervalUnit = reqVo.getIntervalUnit(); + if (intervalUnit == null) { + return Result.ofFail(-1, "intervalUnit can't be null"); + } + if (!Arrays.asList(INTERVAL_UNIT_SECOND, INTERVAL_UNIT_MINUTE, INTERVAL_UNIT_HOUR, INTERVAL_UNIT_DAY).contains(intervalUnit)) { + return Result.ofFail(-1, "Invalid intervalUnit: " + intervalUnit); + } + entity.setIntervalUnit(intervalUnit); + + // 流控方式 0-快速失败 2-匀速排队 + Integer controlBehavior = reqVo.getControlBehavior(); + if (controlBehavior == null) { + return Result.ofFail(-1, "controlBehavior can't be null"); + } + if (!Arrays.asList(CONTROL_BEHAVIOR_DEFAULT, CONTROL_BEHAVIOR_RATE_LIMITER).contains(controlBehavior)) { + return Result.ofFail(-1, "invalid controlBehavior: " + controlBehavior); + } + entity.setControlBehavior(controlBehavior); + + if (CONTROL_BEHAVIOR_DEFAULT == controlBehavior) { + // 0-快速失败, 则Burst size必填 + Integer burst = reqVo.getBurst(); + if (burst == null) { + return Result.ofFail(-1, "burst can't be null"); + } + if (burst < 0) { + return Result.ofFail(-1, "invalid burst: " + burst); + } + entity.setBurst(burst); + } else if (CONTROL_BEHAVIOR_RATE_LIMITER == controlBehavior) { + // 1-匀速排队, 则超时时间必填 + Integer maxQueueingTimeoutMs = reqVo.getMaxQueueingTimeoutMs(); + if (maxQueueingTimeoutMs == null) { + return Result.ofFail(-1, "maxQueueingTimeoutMs can't be null"); + } + if (maxQueueingTimeoutMs < 0) { + return Result.ofFail(-1, "invalid maxQueueingTimeoutMs: " + maxQueueingTimeoutMs); + } + entity.setMaxQueueingTimeoutMs(maxQueueingTimeoutMs); + } + + Date date = new Date(); + entity.setGmtCreate(date); + entity.setGmtModified(date); + + try { + entity = repository.save(entity); + } catch (Throwable throwable) { + logger.error("add gateway flow rule error:", throwable); + return Result.ofThrowable(-1, throwable); + } + + if (!publishRules(app, ip, port)) { + logger.warn("publish gateway flow rules fail after add"); + } + + return Result.ofSuccess(entity); + } + + @PostMapping("/save.json") + @AuthAction(AuthService.PrivilegeType.WRITE_RULE) + public Result updateFlowRule(@RequestBody UpdateFlowRuleReqVo reqVo) { + + String app = reqVo.getApp(); + if (StringUtil.isBlank(app)) { + return Result.ofFail(-1, "app can't be null or empty"); + } + + Long id = reqVo.getId(); + if (id == null) { + return Result.ofFail(-1, "id can't be null"); + } + + GatewayFlowRuleEntity entity = repository.findById(id); + if (entity == null) { + return Result.ofFail(-1, "gateway flow rule does not exist, id=" + id); + } + + // 针对请求属性 + GatewayParamFlowItemVo paramItem = reqVo.getParamItem(); + if (paramItem != null) { + GatewayParamFlowItemEntity itemEntity = new GatewayParamFlowItemEntity(); + entity.setParamItem(itemEntity); + + // 参数属性 0-ClientIP 1-Remote Host 2-Header 3-URL参数 4-Cookie + Integer parseStrategy = paramItem.getParseStrategy(); + if (!Arrays.asList(PARAM_PARSE_STRATEGY_CLIENT_IP, PARAM_PARSE_STRATEGY_HOST, PARAM_PARSE_STRATEGY_HEADER + , PARAM_PARSE_STRATEGY_URL_PARAM, PARAM_PARSE_STRATEGY_COOKIE).contains(parseStrategy)) { + return Result.ofFail(-1, "invalid parseStrategy: " + parseStrategy); + } + itemEntity.setParseStrategy(paramItem.getParseStrategy()); + + // 当参数属性为2-Header 3-URL参数 4-Cookie时,参数名称必填 + if (Arrays.asList(PARAM_PARSE_STRATEGY_HEADER, PARAM_PARSE_STRATEGY_URL_PARAM, PARAM_PARSE_STRATEGY_COOKIE).contains(parseStrategy)) { + // 参数名称 + String fieldName = paramItem.getFieldName(); + if (StringUtil.isBlank(fieldName)) { + return Result.ofFail(-1, "fieldName can't be null or empty"); + } + itemEntity.setFieldName(paramItem.getFieldName()); + + String pattern = paramItem.getPattern(); + // 如果匹配串不为空,验证匹配模式 + if (StringUtil.isNotEmpty(pattern)) { + itemEntity.setPattern(pattern); + + Integer matchStrategy = paramItem.getMatchStrategy(); + if (!Arrays.asList(PARAM_MATCH_STRATEGY_EXACT, PARAM_MATCH_STRATEGY_CONTAINS, PARAM_MATCH_STRATEGY_REGEX).contains(matchStrategy)) { + return Result.ofFail(-1, "invalid matchStrategy: " + matchStrategy); + } + itemEntity.setMatchStrategy(matchStrategy); + } + } + } else { + entity.setParamItem(null); + } + + // 阈值类型 0-线程数 1-QPS + Integer grade = reqVo.getGrade(); + if (grade == null) { + return Result.ofFail(-1, "grade can't be null"); + } + if (!Arrays.asList(FLOW_GRADE_THREAD, FLOW_GRADE_QPS).contains(grade)) { + return Result.ofFail(-1, "invalid grade: " + grade); + } + entity.setGrade(grade); + + // QPS阈值 + Double count = reqVo.getCount(); + if (count == null) { + return Result.ofFail(-1, "count can't be null"); + } + if (count < 0) { + return Result.ofFail(-1, "count should be at lease zero"); + } + entity.setCount(count); + + // 间隔 + Long interval = reqVo.getInterval(); + if (interval == null) { + return Result.ofFail(-1, "interval can't be null"); + } + if (interval <= 0) { + return Result.ofFail(-1, "interval should be greater than zero"); + } + entity.setInterval(interval); + + // 间隔单位 + Integer intervalUnit = reqVo.getIntervalUnit(); + if (intervalUnit == null) { + return Result.ofFail(-1, "intervalUnit can't be null"); + } + if (!Arrays.asList(INTERVAL_UNIT_SECOND, INTERVAL_UNIT_MINUTE, INTERVAL_UNIT_HOUR, INTERVAL_UNIT_DAY).contains(intervalUnit)) { + return Result.ofFail(-1, "Invalid intervalUnit: " + intervalUnit); + } + entity.setIntervalUnit(intervalUnit); + + // 流控方式 0-快速失败 2-匀速排队 + Integer controlBehavior = reqVo.getControlBehavior(); + if (controlBehavior == null) { + return Result.ofFail(-1, "controlBehavior can't be null"); + } + if (!Arrays.asList(CONTROL_BEHAVIOR_DEFAULT, CONTROL_BEHAVIOR_RATE_LIMITER).contains(controlBehavior)) { + return Result.ofFail(-1, "invalid controlBehavior: " + controlBehavior); + } + entity.setControlBehavior(controlBehavior); + + if (CONTROL_BEHAVIOR_DEFAULT == controlBehavior) { + // 0-快速失败, 则Burst size必填 + Integer burst = reqVo.getBurst(); + if (burst == null) { + return Result.ofFail(-1, "burst can't be null"); + } + if (burst < 0) { + return Result.ofFail(-1, "invalid burst: " + burst); + } + entity.setBurst(burst); + } else if (CONTROL_BEHAVIOR_RATE_LIMITER == controlBehavior) { + // 2-匀速排队, 则超时时间必填 + Integer maxQueueingTimeoutMs = reqVo.getMaxQueueingTimeoutMs(); + if (maxQueueingTimeoutMs == null) { + return Result.ofFail(-1, "maxQueueingTimeoutMs can't be null"); + } + if (maxQueueingTimeoutMs < 0) { + return Result.ofFail(-1, "invalid maxQueueingTimeoutMs: " + maxQueueingTimeoutMs); + } + entity.setMaxQueueingTimeoutMs(maxQueueingTimeoutMs); + } + + Date date = new Date(); + entity.setGmtModified(date); + + try { + entity = repository.save(entity); + } catch (Throwable throwable) { + logger.error("update gateway flow rule error:", throwable); + return Result.ofThrowable(-1, throwable); + } + + if (!publishRules(app, entity.getIp(), entity.getPort())) { + logger.warn("publish gateway flow rules fail after update"); + } + + return Result.ofSuccess(entity); + } + + + @PostMapping("/delete.json") + @AuthAction(AuthService.PrivilegeType.DELETE_RULE) + public Result deleteFlowRule(Long id) { + + if (id == null) { + return Result.ofFail(-1, "id can't be null"); + } + + GatewayFlowRuleEntity oldEntity = repository.findById(id); + if (oldEntity == null) { + return Result.ofSuccess(null); + } + + try { + repository.delete(id); + } catch (Throwable throwable) { + logger.error("delete gateway flow rule error:", throwable); + return Result.ofThrowable(-1, throwable); + } + + if (!publishRules(oldEntity.getApp(), oldEntity.getIp(), oldEntity.getPort())) { + logger.warn("publish gateway flow rules fail after delete"); + } + + return Result.ofSuccess(id); + } + + private boolean publishRules(String app, String ip, Integer port) { + List rules = repository.findAllByMachine(MachineInfo.of(app, ip, port)); + return sentinelApiClient.modifyGatewayFlowRules(app, ip, port, rules); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java new file mode 100755 index 00000000..c79261cd --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java @@ -0,0 +1,226 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.controller.v2; + +import java.util.Date; +import java.util.List; + +import com.alibaba.csp.sentinel.dashboard.auth.AuthAction; +import com.alibaba.csp.sentinel.dashboard.auth.AuthService; +import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; +import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; +import com.alibaba.csp.sentinel.dashboard.repository.rule.InMemoryRuleRepositoryAdapter; +import com.alibaba.csp.sentinel.dashboard.rule.DynamicRuleProvider; +import com.alibaba.csp.sentinel.dashboard.rule.DynamicRulePublisher; +import com.alibaba.csp.sentinel.dashboard.domain.Result; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * Flow rule controller (v2). + * + * @author Eric Zhao + * @since 1.4.0 + */ +@RestController +@RequestMapping(value = "/v2/flow") +public class FlowControllerV2 { + + private final Logger logger = LoggerFactory.getLogger(FlowControllerV2.class); + + @Autowired + private InMemoryRuleRepositoryAdapter repository; + + @Autowired + @Qualifier("flowRuleDefaultProvider") + private DynamicRuleProvider> ruleProvider; + @Autowired + @Qualifier("flowRuleDefaultPublisher") + private DynamicRulePublisher> rulePublisher; + + @GetMapping("/rules") + @AuthAction(PrivilegeType.READ_RULE) + public Result> apiQueryMachineRules(@RequestParam String app) { + + if (StringUtil.isEmpty(app)) { + return Result.ofFail(-1, "app can't be null or empty"); + } + try { + List rules = ruleProvider.getRules(app); + if (rules != null && !rules.isEmpty()) { + for (FlowRuleEntity entity : rules) { + entity.setApp(app); + if (entity.getClusterConfig() != null && entity.getClusterConfig().getFlowId() != null) { + entity.setId(entity.getClusterConfig().getFlowId()); + } + } + } + rules = repository.saveAll(rules); + return Result.ofSuccess(rules); + } catch (Throwable throwable) { + logger.error("Error when querying flow rules", throwable); + return Result.ofThrowable(-1, throwable); + } + } + + private Result checkEntityInternal(FlowRuleEntity entity) { + if (entity == null) { + return Result.ofFail(-1, "invalid body"); + } + if (StringUtil.isBlank(entity.getApp())) { + return Result.ofFail(-1, "app can't be null or empty"); + } + if (StringUtil.isBlank(entity.getLimitApp())) { + return Result.ofFail(-1, "limitApp can't be null or empty"); + } + if (StringUtil.isBlank(entity.getResource())) { + return Result.ofFail(-1, "resource can't be null or empty"); + } + if (entity.getGrade() == null) { + return Result.ofFail(-1, "grade can't be null"); + } + if (entity.getGrade() != 0 && entity.getGrade() != 1) { + return Result.ofFail(-1, "grade must be 0 or 1, but " + entity.getGrade() + " got"); + } + if (entity.getCount() == null || entity.getCount() < 0) { + return Result.ofFail(-1, "count should be at lease zero"); + } + if (entity.getStrategy() == null) { + return Result.ofFail(-1, "strategy can't be null"); + } + if (entity.getStrategy() != 0 && StringUtil.isBlank(entity.getRefResource())) { + return Result.ofFail(-1, "refResource can't be null or empty when strategy!=0"); + } + if (entity.getControlBehavior() == null) { + return Result.ofFail(-1, "controlBehavior can't be null"); + } + int controlBehavior = entity.getControlBehavior(); + if (controlBehavior == 1 && entity.getWarmUpPeriodSec() == null) { + return Result.ofFail(-1, "warmUpPeriodSec can't be null when controlBehavior==1"); + } + if (controlBehavior == 2 && entity.getMaxQueueingTimeMs() == null) { + return Result.ofFail(-1, "maxQueueingTimeMs can't be null when controlBehavior==2"); + } + if (entity.isClusterMode() && entity.getClusterConfig() == null) { + return Result.ofFail(-1, "cluster config should be valid"); + } + return null; + } + + @PostMapping("/rule") + @AuthAction(value = PrivilegeType.WRITE_RULE) + public Result apiAddFlowRule(@RequestBody FlowRuleEntity entity) { + + Result checkResult = checkEntityInternal(entity); + if (checkResult != null) { + return checkResult; + } + entity.setId(null); + Date date = new Date(); + entity.setGmtCreate(date); + entity.setGmtModified(date); + entity.setLimitApp(entity.getLimitApp().trim()); + entity.setResource(entity.getResource().trim()); + try { + entity = repository.save(entity); + publishRules(entity.getApp()); + } catch (Throwable throwable) { + logger.error("Failed to add flow rule", throwable); + return Result.ofThrowable(-1, throwable); + } + return Result.ofSuccess(entity); + } + + @PutMapping("/rule/{id}") + @AuthAction(PrivilegeType.WRITE_RULE) + + public Result apiUpdateFlowRule(@PathVariable("id") Long id, + @RequestBody FlowRuleEntity entity) { + if (id == null || id <= 0) { + return Result.ofFail(-1, "Invalid id"); + } + FlowRuleEntity oldEntity = repository.findById(id); + if (oldEntity == null) { + return Result.ofFail(-1, "id " + id + " does not exist"); + } + if (entity == null) { + return Result.ofFail(-1, "invalid body"); + } + + entity.setApp(oldEntity.getApp()); + entity.setIp(oldEntity.getIp()); + entity.setPort(oldEntity.getPort()); + Result checkResult = checkEntityInternal(entity); + if (checkResult != null) { + return checkResult; + } + + entity.setId(id); + Date date = new Date(); + entity.setGmtCreate(oldEntity.getGmtCreate()); + entity.setGmtModified(date); + try { + entity = repository.save(entity); + if (entity == null) { + return Result.ofFail(-1, "save entity fail"); + } + publishRules(oldEntity.getApp()); + } catch (Throwable throwable) { + logger.error("Failed to update flow rule", throwable); + return Result.ofThrowable(-1, throwable); + } + return Result.ofSuccess(entity); + } + + @DeleteMapping("/rule/{id}") + @AuthAction(PrivilegeType.DELETE_RULE) + public Result apiDeleteRule(@PathVariable("id") Long id) { + if (id == null || id <= 0) { + return Result.ofFail(-1, "Invalid id"); + } + FlowRuleEntity oldEntity = repository.findById(id); + if (oldEntity == null) { + return Result.ofSuccess(null); + } + + try { + repository.delete(id); + publishRules(oldEntity.getApp()); + } catch (Exception e) { + return Result.ofFail(-1, e.getMessage()); + } + return Result.ofSuccess(id); + } + + private void publishRules(/*@NonNull*/ String app) throws Exception { + List rules = repository.findAllByApp(app); + rulePublisher.publish(app, rules); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/ApplicationEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/ApplicationEntity.java new file mode 100755 index 00000000..44c10daa --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/ApplicationEntity.java @@ -0,0 +1,106 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.datasource.entity; + +import java.util.Date; + +import com.alibaba.csp.sentinel.dashboard.discovery.AppInfo; + +/** + * @author leyou + */ +public class ApplicationEntity { + + private Long id; + private Date gmtCreate; + private Date gmtModified; + private String app; + private Integer appType; + private String activeConsole; + private Date lastFetch; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public Integer getAppType() { + return appType; + } + + public void setAppType(Integer appType) { + this.appType = appType; + } + + public String getActiveConsole() { + return activeConsole; + } + + public Date getLastFetch() { + return lastFetch; + } + + public void setLastFetch(Date lastFetch) { + this.lastFetch = lastFetch; + } + + public void setActiveConsole(String activeConsole) { + this.activeConsole = activeConsole; + } + + public AppInfo toAppInfo() { + return new AppInfo(app, appType); + } + + @Override + public String toString() { + return "ApplicationEntity{" + + "id=" + id + + ", gmtCreate=" + gmtCreate + + ", gmtModified=" + gmtModified + + ", app='" + app + '\'' + + ", activeConsole='" + activeConsole + '\'' + + ", lastFetch=" + lastFetch + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MachineEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MachineEntity.java new file mode 100755 index 00000000..5b91f339 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MachineEntity.java @@ -0,0 +1,125 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.datasource.entity; + +import java.util.Date; + +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; + +/** + * @author leyou + */ +public class MachineEntity { + private Long id; + private Date gmtCreate; + private Date gmtModified; + private String app; + private String ip; + private String hostname; + private Date timestamp; + private Integer port; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public String getHostname() { + return hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public Date getTimestamp() { + return timestamp; + } + + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public MachineInfo toMachineInfo() { + MachineInfo machineInfo = new MachineInfo(); + + machineInfo.setApp(app); + machineInfo.setHostname(hostname); + machineInfo.setIp(ip); + machineInfo.setPort(port); + machineInfo.setLastHeartbeat(timestamp.getTime()); + machineInfo.setHeartbeatVersion(timestamp.getTime()); + + return machineInfo; + } + + @Override + public String toString() { + return "MachineEntity{" + + "id=" + id + + ", gmtCreate=" + gmtCreate + + ", gmtModified=" + gmtModified + + ", app='" + app + '\'' + + ", ip='" + ip + '\'' + + ", hostname='" + hostname + '\'' + + ", timestamp=" + timestamp + + ", port=" + port + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MetricEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MetricEntity.java new file mode 100755 index 00000000..f08a41a6 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MetricEntity.java @@ -0,0 +1,220 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.datasource.entity; + +import java.util.Date; + +/** + * @author leyou + */ +public class MetricEntity { + private Long id; + private Date gmtCreate; + private Date gmtModified; + private String app; + /** + * 监控信息的时间戳 + */ + private Date timestamp; + private String resource; + private Long passQps; + private Long successQps; + private Long blockQps; + private Long exceptionQps; + + /** + * summary rt of all success exit qps. + */ + private double rt; + + /** + * 本次聚合的总条数 + */ + private int count; + + private int resourceCode; + + public static MetricEntity copyOf(MetricEntity oldEntity) { + MetricEntity entity = new MetricEntity(); + entity.setId(oldEntity.getId()); + entity.setGmtCreate(oldEntity.getGmtCreate()); + entity.setGmtModified(oldEntity.getGmtModified()); + entity.setApp(oldEntity.getApp()); + entity.setTimestamp(oldEntity.getTimestamp()); + entity.setResource(oldEntity.getResource()); + entity.setPassQps(oldEntity.getPassQps()); + entity.setBlockQps(oldEntity.getBlockQps()); + entity.setSuccessQps(oldEntity.getSuccessQps()); + entity.setExceptionQps(oldEntity.getExceptionQps()); + entity.setRt(oldEntity.getRt()); + entity.setCount(oldEntity.getCount()); + entity.setResource(oldEntity.getResource()); + return entity; + } + + public synchronized void addPassQps(Long passQps) { + this.passQps += passQps; + } + + public synchronized void addBlockQps(Long blockQps) { + this.blockQps += blockQps; + } + + public synchronized void addExceptionQps(Long exceptionQps) { + this.exceptionQps += exceptionQps; + } + + public synchronized void addCount(int count) { + this.count += count; + } + + public synchronized void addRtAndSuccessQps(double avgRt, Long successQps) { + this.rt += avgRt * successQps; + this.successQps += successQps; + } + + /** + * {@link #rt} = {@code avgRt * successQps} + * + * @param avgRt average rt of {@code successQps} + * @param successQps + */ + public synchronized void setRtAndSuccessQps(double avgRt, Long successQps) { + this.rt = avgRt * successQps; + this.successQps = successQps; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public Date getTimestamp() { + return timestamp; + } + + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + this.resourceCode = resource.hashCode(); + } + + public Long getPassQps() { + return passQps; + } + + public void setPassQps(Long passQps) { + this.passQps = passQps; + } + + public Long getBlockQps() { + return blockQps; + } + + public void setBlockQps(Long blockQps) { + this.blockQps = blockQps; + } + + public Long getExceptionQps() { + return exceptionQps; + } + + public void setExceptionQps(Long exceptionQps) { + this.exceptionQps = exceptionQps; + } + + public double getRt() { + return rt; + } + + public void setRt(double rt) { + this.rt = rt; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public int getResourceCode() { + return resourceCode; + } + + public Long getSuccessQps() { + return successQps; + } + + public void setSuccessQps(Long successQps) { + this.successQps = successQps; + } + + @Override + public String toString() { + return "MetricEntity{" + + "id=" + id + + ", gmtCreate=" + gmtCreate + + ", gmtModified=" + gmtModified + + ", app='" + app + '\'' + + ", timestamp=" + timestamp + + ", resource='" + resource + '\'' + + ", passQps=" + passQps + + ", blockQps=" + blockQps + + ", successQps=" + successQps + + ", exceptionQps=" + exceptionQps + + ", rt=" + rt + + ", count=" + count + + ", resourceCode=" + resourceCode + + '}'; + } + +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MetricPositionEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MetricPositionEntity.java new file mode 100755 index 00000000..2be29eb8 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MetricPositionEntity.java @@ -0,0 +1,121 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.datasource.entity; + +import java.util.Date; + +/** + * @author leyou + */ +public class MetricPositionEntity { + private long id; + private Date gmtCreate; + private Date gmtModified; + private String app; + private String ip; + /** + * Sentinel在该应用上使用的端口 + */ + private int port; + + /** + * 机器名,冗余字段 + */ + private String hostname; + + /** + * 上一次拉取的最晚时间戳 + */ + private Date lastFetch; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getHostname() { + return hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public Date getLastFetch() { + return lastFetch; + } + + public void setLastFetch(Date lastFetch) { + this.lastFetch = lastFetch; + } + + @Override + public String toString() { + return "MetricPositionEntity{" + + "id=" + id + + ", gmtCreate=" + gmtCreate + + ", gmtModified=" + gmtModified + + ", app='" + app + '\'' + + ", ip='" + ip + '\'' + + ", port=" + port + + ", hostname='" + hostname + '\'' + + ", lastFetch=" + lastFetch + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/SentinelVersion.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/SentinelVersion.java new file mode 100755 index 00000000..08fcaf25 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/SentinelVersion.java @@ -0,0 +1,129 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.datasource.entity; + +/** + * @author Eric Zhao + * @since 0.2.1 + */ +public class SentinelVersion { + private int majorVersion; + private int minorVersion; + private int fixVersion; + private String postfix; + + public SentinelVersion() { + this(0, 0, 0); + } + + public SentinelVersion(int major, int minor, int fix) { + this(major, minor, fix, null); + } + + public SentinelVersion(int major, int minor, int fix, String postfix) { + this.majorVersion = major; + this.minorVersion = minor; + this.fixVersion = fix; + this.postfix = postfix; + } + + /** + * 000, 000, 000 + */ + public int getFullVersion() { + return majorVersion * 1000000 + minorVersion * 1000 + fixVersion; + } + + public int getMajorVersion() { + return majorVersion; + } + + public SentinelVersion setMajorVersion(int majorVersion) { + this.majorVersion = majorVersion; + return this; + } + + public int getMinorVersion() { + return minorVersion; + } + + public SentinelVersion setMinorVersion(int minorVersion) { + this.minorVersion = minorVersion; + return this; + } + + public int getFixVersion() { + return fixVersion; + } + + public SentinelVersion setFixVersion(int fixVersion) { + this.fixVersion = fixVersion; + return this; + } + + public String getPostfix() { + return postfix; + } + + public SentinelVersion setPostfix(String postfix) { + this.postfix = postfix; + return this; + } + + public boolean greaterThan(SentinelVersion version) { + if (version == null) { + return true; + } + return getFullVersion() > version.getFullVersion(); + } + + public boolean greaterOrEqual(SentinelVersion version) { + if (version == null) { + return true; + } + return getFullVersion() >= version.getFullVersion(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { return true; } + if (o == null || getClass() != o.getClass()) { return false; } + + SentinelVersion that = (SentinelVersion)o; + + if (getFullVersion() != that.getFullVersion()) { return false; } + return postfix != null ? postfix.equals(that.postfix) : that.postfix == null; + } + + @Override + public int hashCode() { + int result = majorVersion; + result = 31 * result + minorVersion; + result = 31 * result + fixVersion; + result = 31 * result + (postfix != null ? postfix.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "SentinelVersion{" + + "majorVersion=" + majorVersion + + ", minorVersion=" + minorVersion + + ", fixVersion=" + fixVersion + + ", postfix='" + postfix + '\'' + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/gateway/ApiDefinitionEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/gateway/ApiDefinitionEntity.java new file mode 100755 index 00000000..b042e0ad --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/gateway/ApiDefinitionEntity.java @@ -0,0 +1,208 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway; + +import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiDefinition; +import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPathPredicateItem; +import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPredicateItem; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.RuleEntity; +import com.alibaba.csp.sentinel.slots.block.Rule; + +import java.util.Date; +import java.util.LinkedHashSet; +import java.util.Objects; +import java.util.Set; + +/** + * Entity for {@link ApiDefinition}. + * + * @author cdfive + * @since 1.7.0 + */ +public class ApiDefinitionEntity implements RuleEntity { + + private Long id; + private String app; + private String ip; + private Integer port; + + private Date gmtCreate; + private Date gmtModified; + + private String apiName; + private Set predicateItems; + + public static ApiDefinitionEntity fromApiDefinition(String app, String ip, Integer port, ApiDefinition apiDefinition) { + ApiDefinitionEntity entity = new ApiDefinitionEntity(); + entity.setApp(app); + entity.setIp(ip); + entity.setPort(port); + entity.setApiName(apiDefinition.getApiName()); + + Set predicateItems = new LinkedHashSet<>(); + entity.setPredicateItems(predicateItems); + + Set apiPredicateItems = apiDefinition.getPredicateItems(); + if (apiPredicateItems != null) { + for (ApiPredicateItem apiPredicateItem : apiPredicateItems) { + ApiPredicateItemEntity itemEntity = new ApiPredicateItemEntity(); + predicateItems.add(itemEntity); + ApiPathPredicateItem pathPredicateItem = (ApiPathPredicateItem) apiPredicateItem; + itemEntity.setPattern(pathPredicateItem.getPattern()); + itemEntity.setMatchStrategy(pathPredicateItem.getMatchStrategy()); + } + } + + return entity; + } + + public ApiDefinition toApiDefinition() { + ApiDefinition apiDefinition = new ApiDefinition(); + apiDefinition.setApiName(apiName); + + Set apiPredicateItems = new LinkedHashSet<>(); + apiDefinition.setPredicateItems(apiPredicateItems); + + if (predicateItems != null) { + for (ApiPredicateItemEntity predicateItem : predicateItems) { + ApiPathPredicateItem apiPredicateItem = new ApiPathPredicateItem(); + apiPredicateItems.add(apiPredicateItem); + apiPredicateItem.setMatchStrategy(predicateItem.getMatchStrategy()); + apiPredicateItem.setPattern(predicateItem.getPattern()); + } + } + + return apiDefinition; + } + + public ApiDefinitionEntity() { + + } + + public ApiDefinitionEntity(String apiName, Set predicateItems) { + this.apiName = apiName; + this.predicateItems = predicateItems; + } + + public String getApiName() { + return apiName; + } + + public void setApiName(String apiName) { + this.apiName = apiName; + } + + public Set getPredicateItems() { + return predicateItems; + } + + public void setPredicateItems(Set predicateItems) { + this.predicateItems = predicateItems; + } + + @Override + public Long getId() { + return id; + } + + @Override + public void setId(Long id) { + this.id = id; + } + + @Override + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + @Override + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + @Override + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + @Override + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + @Override + public Rule toRule() { + return null; + } + + @Override + public boolean equals(Object o) { + if (this == o) { return true; } + if (o == null || getClass() != o.getClass()) { return false; } + ApiDefinitionEntity entity = (ApiDefinitionEntity) o; + return Objects.equals(id, entity.id) && + Objects.equals(app, entity.app) && + Objects.equals(ip, entity.ip) && + Objects.equals(port, entity.port) && + Objects.equals(gmtCreate, entity.gmtCreate) && + Objects.equals(gmtModified, entity.gmtModified) && + Objects.equals(apiName, entity.apiName) && + Objects.equals(predicateItems, entity.predicateItems); + } + + @Override + public int hashCode() { + return Objects.hash(id, app, ip, port, gmtCreate, gmtModified, apiName, predicateItems); + } + + @Override + public String toString() { + return "ApiDefinitionEntity{" + + "id=" + id + + ", app='" + app + '\'' + + ", ip='" + ip + '\'' + + ", port=" + port + + ", gmtCreate=" + gmtCreate + + ", gmtModified=" + gmtModified + + ", apiName='" + apiName + '\'' + + ", predicateItems=" + predicateItems + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/gateway/ApiPredicateItemEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/gateway/ApiPredicateItemEntity.java new file mode 100755 index 00000000..1d6058cd --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/gateway/ApiPredicateItemEntity.java @@ -0,0 +1,79 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway; + +import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPredicateItem; + +import java.util.Objects; + +/** + * Entity for {@link ApiPredicateItem}. + * + * @author cdfive + * @since 1.7.0 + */ +public class ApiPredicateItemEntity { + + private String pattern; + + private Integer matchStrategy; + + public ApiPredicateItemEntity() { + } + + public ApiPredicateItemEntity(String pattern, int matchStrategy) { + this.pattern = pattern; + this.matchStrategy = matchStrategy; + } + + public String getPattern() { + return pattern; + } + + public void setPattern(String pattern) { + this.pattern = pattern; + } + + public Integer getMatchStrategy() { + return matchStrategy; + } + + public void setMatchStrategy(Integer matchStrategy) { + this.matchStrategy = matchStrategy; + } + + @Override + public boolean equals(Object o) { + if (this == o) { return true; } + if (o == null || getClass() != o.getClass()) { return false; } + ApiPredicateItemEntity that = (ApiPredicateItemEntity) o; + return Objects.equals(pattern, that.pattern) && + Objects.equals(matchStrategy, that.matchStrategy); + } + + @Override + public int hashCode() { + return Objects.hash(pattern, matchStrategy); + } + + @Override + public String toString() { + return "ApiPredicateItemEntity{" + + "pattern='" + pattern + '\'' + + ", matchStrategy=" + matchStrategy + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/gateway/GatewayFlowRuleEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/gateway/GatewayFlowRuleEntity.java new file mode 100755 index 00000000..391ea41f --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/gateway/GatewayFlowRuleEntity.java @@ -0,0 +1,354 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway; + +import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule; +import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayParamFlowItem; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.RuleEntity; +import com.alibaba.csp.sentinel.slots.block.Rule; + +import java.util.Date; +import java.util.Objects; + +/** + * Entity for {@link GatewayFlowRule}. + * + * @author cdfive + * @since 1.7.0 + */ +public class GatewayFlowRuleEntity implements RuleEntity { + + /**间隔单位*/ + /**0-秒*/ + public static final int INTERVAL_UNIT_SECOND = 0; + /**1-分*/ + public static final int INTERVAL_UNIT_MINUTE = 1; + /**2-时*/ + public static final int INTERVAL_UNIT_HOUR = 2; + /**3-天*/ + public static final int INTERVAL_UNIT_DAY = 3; + + private Long id; + private String app; + private String ip; + private Integer port; + + private Date gmtCreate; + private Date gmtModified; + + private String resource; + private Integer resourceMode; + + private Integer grade; + private Double count; + private Long interval; + private Integer intervalUnit; + + private Integer controlBehavior; + private Integer burst; + + private Integer maxQueueingTimeoutMs; + + private GatewayParamFlowItemEntity paramItem; + + public static Long calIntervalSec(Long interval, Integer intervalUnit) { + switch (intervalUnit) { + case INTERVAL_UNIT_SECOND: + return interval; + case INTERVAL_UNIT_MINUTE: + return interval * 60; + case INTERVAL_UNIT_HOUR: + return interval * 60 * 60; + case INTERVAL_UNIT_DAY: + return interval * 60 * 60 * 24; + default: + break; + } + + throw new IllegalArgumentException("Invalid intervalUnit: " + intervalUnit); + } + + public static Object[] parseIntervalSec(Long intervalSec) { + if (intervalSec % (60 * 60 * 24) == 0) { + return new Object[] {intervalSec / (60 * 60 * 24), INTERVAL_UNIT_DAY}; + } + + if (intervalSec % (60 * 60 ) == 0) { + return new Object[] {intervalSec / (60 * 60), INTERVAL_UNIT_HOUR}; + } + + if (intervalSec % 60 == 0) { + return new Object[] {intervalSec / 60, INTERVAL_UNIT_MINUTE}; + } + + return new Object[] {intervalSec, INTERVAL_UNIT_SECOND}; + } + + public GatewayFlowRule toGatewayFlowRule() { + GatewayFlowRule rule = new GatewayFlowRule(); + rule.setResource(resource); + rule.setResourceMode(resourceMode); + + rule.setGrade(grade); + rule.setCount(count); + rule.setIntervalSec(calIntervalSec(interval, intervalUnit)); + + rule.setControlBehavior(controlBehavior); + + if (burst != null) { + rule.setBurst(burst); + } + + if (maxQueueingTimeoutMs != null) { + rule.setMaxQueueingTimeoutMs(maxQueueingTimeoutMs); + } + + if (paramItem != null) { + GatewayParamFlowItem ruleItem = new GatewayParamFlowItem(); + rule.setParamItem(ruleItem); + ruleItem.setParseStrategy(paramItem.getParseStrategy()); + ruleItem.setFieldName(paramItem.getFieldName()); + ruleItem.setPattern(paramItem.getPattern()); + + if (paramItem.getMatchStrategy() != null) { + ruleItem.setMatchStrategy(paramItem.getMatchStrategy()); + } + } + + return rule; + } + + public static GatewayFlowRuleEntity fromGatewayFlowRule(String app, String ip, Integer port, GatewayFlowRule rule) { + GatewayFlowRuleEntity entity = new GatewayFlowRuleEntity(); + entity.setApp(app); + entity.setIp(ip); + entity.setPort(port); + + entity.setResource(rule.getResource()); + entity.setResourceMode(rule.getResourceMode()); + + entity.setGrade(rule.getGrade()); + entity.setCount(rule.getCount()); + Object[] intervalSecResult = parseIntervalSec(rule.getIntervalSec()); + entity.setInterval((Long) intervalSecResult[0]); + entity.setIntervalUnit((Integer) intervalSecResult[1]); + + entity.setControlBehavior(rule.getControlBehavior()); + entity.setBurst(rule.getBurst()); + entity.setMaxQueueingTimeoutMs(rule.getMaxQueueingTimeoutMs()); + + GatewayParamFlowItem paramItem = rule.getParamItem(); + if (paramItem != null) { + GatewayParamFlowItemEntity itemEntity = new GatewayParamFlowItemEntity(); + entity.setParamItem(itemEntity); + itemEntity.setParseStrategy(paramItem.getParseStrategy()); + itemEntity.setFieldName(paramItem.getFieldName()); + itemEntity.setPattern(paramItem.getPattern()); + itemEntity.setMatchStrategy(paramItem.getMatchStrategy()); + } + + return entity; + } + + @Override + public Long getId() { + return id; + } + + @Override + public void setId(Long id) { + this.id = id; + } + + @Override + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + @Override + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + @Override + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + @Override + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + @Override + public Rule toRule() { + return null; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + public GatewayParamFlowItemEntity getParamItem() { + return paramItem; + } + + public void setParamItem(GatewayParamFlowItemEntity paramItem) { + this.paramItem = paramItem; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public Integer getResourceMode() { + return resourceMode; + } + + public void setResourceMode(Integer resourceMode) { + this.resourceMode = resourceMode; + } + + public Integer getGrade() { + return grade; + } + + public void setGrade(Integer grade) { + this.grade = grade; + } + + public Double getCount() { + return count; + } + + public void setCount(Double count) { + this.count = count; + } + + public Long getInterval() { + return interval; + } + + public void setInterval(Long interval) { + this.interval = interval; + } + + public Integer getIntervalUnit() { + return intervalUnit; + } + + public void setIntervalUnit(Integer intervalUnit) { + this.intervalUnit = intervalUnit; + } + + public Integer getControlBehavior() { + return controlBehavior; + } + + public void setControlBehavior(Integer controlBehavior) { + this.controlBehavior = controlBehavior; + } + + public Integer getBurst() { + return burst; + } + + public void setBurst(Integer burst) { + this.burst = burst; + } + + public Integer getMaxQueueingTimeoutMs() { + return maxQueueingTimeoutMs; + } + + public void setMaxQueueingTimeoutMs(Integer maxQueueingTimeoutMs) { + this.maxQueueingTimeoutMs = maxQueueingTimeoutMs; + } + + @Override + public boolean equals(Object o) { + if (this == o) { return true; } + if (o == null || getClass() != o.getClass()) { return false; } + GatewayFlowRuleEntity that = (GatewayFlowRuleEntity) o; + return Objects.equals(id, that.id) && + Objects.equals(app, that.app) && + Objects.equals(ip, that.ip) && + Objects.equals(port, that.port) && + Objects.equals(gmtCreate, that.gmtCreate) && + Objects.equals(gmtModified, that.gmtModified) && + Objects.equals(resource, that.resource) && + Objects.equals(resourceMode, that.resourceMode) && + Objects.equals(grade, that.grade) && + Objects.equals(count, that.count) && + Objects.equals(interval, that.interval) && + Objects.equals(intervalUnit, that.intervalUnit) && + Objects.equals(controlBehavior, that.controlBehavior) && + Objects.equals(burst, that.burst) && + Objects.equals(maxQueueingTimeoutMs, that.maxQueueingTimeoutMs) && + Objects.equals(paramItem, that.paramItem); + } + + @Override + public int hashCode() { + return Objects.hash(id, app, ip, port, gmtCreate, gmtModified, resource, resourceMode, grade, count, interval, intervalUnit, controlBehavior, burst, maxQueueingTimeoutMs, paramItem); + } + + @Override + public String toString() { + return "GatewayFlowRuleEntity{" + + "id=" + id + + ", app='" + app + '\'' + + ", ip='" + ip + '\'' + + ", port=" + port + + ", gmtCreate=" + gmtCreate + + ", gmtModified=" + gmtModified + + ", resource='" + resource + '\'' + + ", resourceMode=" + resourceMode + + ", grade=" + grade + + ", count=" + count + + ", interval=" + interval + + ", intervalUnit=" + intervalUnit + + ", controlBehavior=" + controlBehavior + + ", burst=" + burst + + ", maxQueueingTimeoutMs=" + maxQueueingTimeoutMs + + ", paramItem=" + paramItem + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/gateway/GatewayParamFlowItemEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/gateway/GatewayParamFlowItemEntity.java new file mode 100755 index 00000000..4da71c8e --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/gateway/GatewayParamFlowItemEntity.java @@ -0,0 +1,95 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway; + +import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayParamFlowItem; + +import java.util.Objects; + +/** + * Entity for {@link GatewayParamFlowItem}. + * + * @author cdfive + * @since 1.7.0 + */ +public class GatewayParamFlowItemEntity { + + private Integer parseStrategy; + + private String fieldName; + + private String pattern; + + private Integer matchStrategy; + + public Integer getParseStrategy() { + return parseStrategy; + } + + public void setParseStrategy(Integer parseStrategy) { + this.parseStrategy = parseStrategy; + } + + public String getFieldName() { + return fieldName; + } + + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + + public String getPattern() { + return pattern; + } + + public void setPattern(String pattern) { + this.pattern = pattern; + } + + public Integer getMatchStrategy() { + return matchStrategy; + } + + public void setMatchStrategy(Integer matchStrategy) { + this.matchStrategy = matchStrategy; + } + + @Override + public boolean equals(Object o) { + if (this == o) { return true; } + if (o == null || getClass() != o.getClass()) { return false; } + GatewayParamFlowItemEntity that = (GatewayParamFlowItemEntity) o; + return Objects.equals(parseStrategy, that.parseStrategy) && + Objects.equals(fieldName, that.fieldName) && + Objects.equals(pattern, that.pattern) && + Objects.equals(matchStrategy, that.matchStrategy); + } + + @Override + public int hashCode() { + return Objects.hash(parseStrategy, fieldName, pattern, matchStrategy); + } + + @Override + public String toString() { + return "GatewayParamFlowItemEntity{" + + "parseStrategy=" + parseStrategy + + ", fieldName='" + fieldName + '\'' + + ", pattern='" + pattern + '\'' + + ", matchStrategy=" + matchStrategy + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AbstractRuleEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AbstractRuleEntity.java new file mode 100755 index 00000000..6f60647d --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AbstractRuleEntity.java @@ -0,0 +1,112 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.datasource.entity.rule; + +import java.util.Date; + +import com.alibaba.csp.sentinel.slots.block.AbstractRule; +import com.alibaba.csp.sentinel.slots.block.Rule; + +/** + * @author Eric Zhao + * @since 0.2.1 + */ +public abstract class AbstractRuleEntity implements RuleEntity { + + protected Long id; + + protected String app; + protected String ip; + protected Integer port; + + protected T rule; + + private Date gmtCreate; + private Date gmtModified; + + @Override + public Long getId() { + return id; + } + + @Override + public void setId(Long id) { + this.id = id; + } + + @Override + public String getApp() { + return app; + } + + public AbstractRuleEntity setApp(String app) { + this.app = app; + return this; + } + + @Override + public String getIp() { + return ip; + } + + public AbstractRuleEntity setIp(String ip) { + this.ip = ip; + return this; + } + + @Override + public Integer getPort() { + return port; + } + + public AbstractRuleEntity setPort(Integer port) { + this.port = port; + return this; + } + + public T getRule() { + return rule; + } + + public AbstractRuleEntity setRule(T rule) { + this.rule = rule; + return this; + } + + @Override + public Date getGmtCreate() { + return gmtCreate; + } + + public AbstractRuleEntity setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + return this; + } + + public Date getGmtModified() { + return gmtModified; + } + + public AbstractRuleEntity setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + return this; + } + + @Override + public T toRule() { + return rule; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AuthorityRuleEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AuthorityRuleEntity.java new file mode 100755 index 00000000..a085d898 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AuthorityRuleEntity.java @@ -0,0 +1,62 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.datasource.entity.rule; + +import com.alibaba.csp.sentinel.slots.block.authority.AuthorityRule; +import com.alibaba.csp.sentinel.util.AssertUtil; +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * @author Eric Zhao + * @since 0.2.1 + */ +public class AuthorityRuleEntity extends AbstractRuleEntity { + + public AuthorityRuleEntity() { + } + + public AuthorityRuleEntity(AuthorityRule authorityRule) { + AssertUtil.notNull(authorityRule, "Authority rule should not be null"); + this.rule = authorityRule; + } + + public static AuthorityRuleEntity fromAuthorityRule(String app, String ip, Integer port, AuthorityRule rule) { + AuthorityRuleEntity entity = new AuthorityRuleEntity(rule); + entity.setApp(app); + entity.setIp(ip); + entity.setPort(port); + return entity; + } + + @JsonIgnore + @JSONField(serialize = false) + public String getLimitApp() { + return rule.getLimitApp(); + } + + @JsonIgnore + @JSONField(serialize = false) + public String getResource() { + return rule.getResource(); + } + + @JsonIgnore + @JSONField(serialize = false) + public int getStrategy() { + return rule.getStrategy(); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/DegradeRuleEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/DegradeRuleEntity.java new file mode 100755 index 00000000..2b86a373 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/DegradeRuleEntity.java @@ -0,0 +1,158 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.datasource.entity.rule; + +import java.util.Date; + +import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule; + +/** + * @author leyou + */ +public class DegradeRuleEntity implements RuleEntity { + private Long id; + private String app; + private String ip; + private Integer port; + private String resource; + private String limitApp; + private Double count; + private Integer timeWindow; + /** + * 0 rt 限流; 1为异常; + */ + private Integer grade; + private Date gmtCreate; + private Date gmtModified; + + public static DegradeRuleEntity fromDegradeRule(String app, String ip, Integer port, DegradeRule rule) { + DegradeRuleEntity entity = new DegradeRuleEntity(); + entity.setApp(app); + entity.setIp(ip); + entity.setPort(port); + entity.setResource(rule.getResource()); + entity.setLimitApp(rule.getLimitApp()); + entity.setCount(rule.getCount()); + entity.setTimeWindow(rule.getTimeWindow()); + entity.setGrade(rule.getGrade()); + return entity; + } + + @Override + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + @Override + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + @Override + public Long getId() { + return id; + } + + @Override + public void setId(Long id) { + this.id = id; + } + + @Override + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public String getLimitApp() { + return limitApp; + } + + public void setLimitApp(String limitApp) { + this.limitApp = limitApp; + } + + public Double getCount() { + return count; + } + + public void setCount(Double count) { + this.count = count; + } + + public Integer getTimeWindow() { + return timeWindow; + } + + public void setTimeWindow(Integer timeWindow) { + this.timeWindow = timeWindow; + } + + public Integer getGrade() { + return grade; + } + + public void setGrade(Integer grade) { + this.grade = grade; + } + + @Override + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + @Override + public DegradeRule toRule() { + DegradeRule rule = new DegradeRule(); + rule.setResource(resource); + rule.setLimitApp(limitApp); + rule.setCount(count); + rule.setTimeWindow(timeWindow); + rule.setGrade(grade); + return rule; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/FlowRuleEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/FlowRuleEntity.java new file mode 100755 index 00000000..a076bd42 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/FlowRuleEntity.java @@ -0,0 +1,249 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.datasource.entity.rule; + +import java.util.Date; + +import com.alibaba.csp.sentinel.slots.block.flow.ClusterFlowConfig; +import com.alibaba.csp.sentinel.slots.block.flow.FlowRule; + +/** + * @author leyou + */ +public class FlowRuleEntity implements RuleEntity { + + private Long id; + private String app; + private String ip; + private Integer port; + private String limitApp; + private String resource; + /** + * 0为线程数;1为qps + */ + private Integer grade; + private Double count; + /** + * 0为直接限流;1为关联限流;2为链路限流 + ***/ + private Integer strategy; + private String refResource; + /** + * 0. default, 1. warm up, 2. rate limiter + */ + private Integer controlBehavior; + private Integer warmUpPeriodSec; + /** + * max queueing time in rate limiter behavior + */ + private Integer maxQueueingTimeMs; + + private boolean clusterMode; + /** + * Flow rule config for cluster mode. + */ + private ClusterFlowConfig clusterConfig; + + private Date gmtCreate; + private Date gmtModified; + + public static FlowRuleEntity fromFlowRule(String app, String ip, Integer port, FlowRule rule) { + FlowRuleEntity entity = new FlowRuleEntity(); + entity.setApp(app); + entity.setIp(ip); + entity.setPort(port); + entity.setLimitApp(rule.getLimitApp()); + entity.setResource(rule.getResource()); + entity.setGrade(rule.getGrade()); + entity.setCount(rule.getCount()); + entity.setStrategy(rule.getStrategy()); + entity.setRefResource(rule.getRefResource()); + entity.setControlBehavior(rule.getControlBehavior()); + entity.setWarmUpPeriodSec(rule.getWarmUpPeriodSec()); + entity.setMaxQueueingTimeMs(rule.getMaxQueueingTimeMs()); + entity.setClusterMode(rule.isClusterMode()); + entity.setClusterConfig(rule.getClusterConfig()); + return entity; + } + + @Override + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + @Override + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + @Override + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + @Override + public Long getId() { + return id; + } + + @Override + public void setId(Long id) { + this.id = id; + } + + public String getLimitApp() { + return limitApp; + } + + public void setLimitApp(String limitApp) { + this.limitApp = limitApp; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public Integer getGrade() { + return grade; + } + + public void setGrade(Integer grade) { + this.grade = grade; + } + + public Double getCount() { + return count; + } + + public void setCount(Double count) { + this.count = count; + } + + public Integer getStrategy() { + return strategy; + } + + public void setStrategy(Integer strategy) { + this.strategy = strategy; + } + + public String getRefResource() { + return refResource; + } + + public void setRefResource(String refResource) { + this.refResource = refResource; + } + + public Integer getControlBehavior() { + return controlBehavior; + } + + public void setControlBehavior(Integer controlBehavior) { + this.controlBehavior = controlBehavior; + } + + public Integer getWarmUpPeriodSec() { + return warmUpPeriodSec; + } + + public void setWarmUpPeriodSec(Integer warmUpPeriodSec) { + this.warmUpPeriodSec = warmUpPeriodSec; + } + + public Integer getMaxQueueingTimeMs() { + return maxQueueingTimeMs; + } + + public void setMaxQueueingTimeMs(Integer maxQueueingTimeMs) { + this.maxQueueingTimeMs = maxQueueingTimeMs; + } + + public boolean isClusterMode() { + return clusterMode; + } + + public FlowRuleEntity setClusterMode(boolean clusterMode) { + this.clusterMode = clusterMode; + return this; + } + + public ClusterFlowConfig getClusterConfig() { + return clusterConfig; + } + + public FlowRuleEntity setClusterConfig(ClusterFlowConfig clusterConfig) { + this.clusterConfig = clusterConfig; + return this; + } + + @Override + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + @Override + public FlowRule toRule() { + FlowRule flowRule = new FlowRule(); + flowRule.setCount(this.count); + flowRule.setGrade(this.grade); + flowRule.setResource(this.resource); + flowRule.setLimitApp(this.limitApp); + flowRule.setRefResource(this.refResource); + flowRule.setStrategy(this.strategy); + if (this.controlBehavior != null) { + flowRule.setControlBehavior(controlBehavior); + } + if (this.warmUpPeriodSec != null) { + flowRule.setWarmUpPeriodSec(warmUpPeriodSec); + } + if (this.maxQueueingTimeMs != null) { + flowRule.setMaxQueueingTimeMs(maxQueueingTimeMs); + } + flowRule.setClusterMode(clusterMode); + flowRule.setClusterConfig(clusterConfig); + return flowRule; + } + +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/ParamFlowRuleEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/ParamFlowRuleEntity.java new file mode 100755 index 00000000..56bd773c --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/ParamFlowRuleEntity.java @@ -0,0 +1,120 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.datasource.entity.rule; + +import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowClusterConfig; +import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowItem; +import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowRule; +import com.alibaba.csp.sentinel.util.AssertUtil; +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * @author Eric Zhao + * @since 0.2.1 + */ +public class ParamFlowRuleEntity extends AbstractRuleEntity { + + public ParamFlowRuleEntity() { + } + + public ParamFlowRuleEntity(ParamFlowRule rule) { + AssertUtil.notNull(rule, "Authority rule should not be null"); + this.rule = rule; + } + + public static ParamFlowRuleEntity fromAuthorityRule(String app, String ip, Integer port, ParamFlowRule rule) { + ParamFlowRuleEntity entity = new ParamFlowRuleEntity(rule); + entity.setApp(app); + entity.setIp(ip); + entity.setPort(port); + return entity; + } + + @JsonIgnore + @JSONField(serialize = false) + public String getLimitApp() { + return rule.getLimitApp(); + } + + @JsonIgnore + @JSONField(serialize = false) + public String getResource() { + return rule.getResource(); + } + + @JsonIgnore + @JSONField(serialize = false) + public int getGrade() { + return rule.getGrade(); + } + + @JsonIgnore + @JSONField(serialize = false) + public Integer getParamIdx() { + return rule.getParamIdx(); + } + + @JsonIgnore + @JSONField(serialize = false) + public double getCount() { + return rule.getCount(); + } + + @JsonIgnore + @JSONField(serialize = false) + public List getParamFlowItemList() { + return rule.getParamFlowItemList(); + } + + @JsonIgnore + @JSONField(serialize = false) + public int getControlBehavior() { + return rule.getControlBehavior(); + } + + @JsonIgnore + @JSONField(serialize = false) + public int getMaxQueueingTimeMs() { + return rule.getMaxQueueingTimeMs(); + } + + @JsonIgnore + @JSONField(serialize = false) + public int getBurstCount() { + return rule.getBurstCount(); + } + + @JsonIgnore + @JSONField(serialize = false) + public long getDurationInSec() { + return rule.getDurationInSec(); + } + + @JsonIgnore + @JSONField(serialize = false) + public boolean isClusterMode() { + return rule.isClusterMode(); + } + + @JsonIgnore + @JSONField(serialize = false) + public ParamFlowClusterConfig getClusterConfig() { + return rule.getClusterConfig(); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/RuleEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/RuleEntity.java new file mode 100755 index 00000000..0ad764fe --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/RuleEntity.java @@ -0,0 +1,40 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.datasource.entity.rule; + +import java.util.Date; + +import com.alibaba.csp.sentinel.slots.block.Rule; + +/** + * @author leyou + */ +public interface RuleEntity { + + Long getId(); + + void setId(Long id); + + String getApp(); + + String getIp(); + + Integer getPort(); + + Date getGmtCreate(); + + Rule toRule(); +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/SystemRuleEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/SystemRuleEntity.java new file mode 100755 index 00000000..483ebcb5 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/SystemRuleEntity.java @@ -0,0 +1,158 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.datasource.entity.rule; + +import com.alibaba.csp.sentinel.slots.system.SystemRule; + +import java.util.Date; + +/** + * @author leyou + */ +public class SystemRuleEntity implements RuleEntity { + + private Long id; + + private String app; + private String ip; + private Integer port; + private Double highestSystemLoad; + private Long avgRt; + private Long maxThread; + private Double qps; + private Double highestCpuUsage; + + private Date gmtCreate; + private Date gmtModified; + + public static SystemRuleEntity fromSystemRule(String app, String ip, Integer port, SystemRule rule) { + SystemRuleEntity entity = new SystemRuleEntity(); + entity.setApp(app); + entity.setIp(ip); + entity.setPort(port); + entity.setHighestSystemLoad(rule.getHighestSystemLoad()); + entity.setHighestCpuUsage(rule.getHighestCpuUsage()); + entity.setAvgRt(rule.getAvgRt()); + entity.setMaxThread(rule.getMaxThread()); + entity.setQps(rule.getQps()); + return entity; + } + + @Override + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + @Override + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + @Override + public Long getId() { + return id; + } + + @Override + public void setId(Long id) { + this.id = id; + } + + @Override + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public Double getHighestSystemLoad() { + return highestSystemLoad; + } + + public void setHighestSystemLoad(Double highestSystemLoad) { + this.highestSystemLoad = highestSystemLoad; + } + + public Long getAvgRt() { + return avgRt; + } + + public void setAvgRt(Long avgRt) { + this.avgRt = avgRt; + } + + public Long getMaxThread() { + return maxThread; + } + + public void setMaxThread(Long maxThread) { + this.maxThread = maxThread; + } + + public Double getQps() { + return qps; + } + + public void setQps(Double qps) { + this.qps = qps; + } + + public Double getHighestCpuUsage() { + return highestCpuUsage; + } + + public void setHighestCpuUsage(Double highestCpuUsage) { + this.highestCpuUsage = highestCpuUsage; + } + + @Override + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + @Override + public SystemRule toRule() { + SystemRule rule = new SystemRule(); + rule.setHighestSystemLoad(highestSystemLoad); + rule.setAvgRt(avgRt); + rule.setMaxThread(maxThread); + rule.setQps(qps); + rule.setHighestCpuUsage(highestCpuUsage); + return rule; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/AppInfo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/AppInfo.java new file mode 100755 index 00000000..f7697698 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/AppInfo.java @@ -0,0 +1,135 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.discovery; + +import java.util.Comparator; +import java.util.HashSet; +import java.util.Optional; +import java.util.Iterator; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import com.alibaba.csp.sentinel.dashboard.config.DashboardConfig; + +public class AppInfo { + + private String app = ""; + + private Integer appType = 0; + + private Set machines = ConcurrentHashMap.newKeySet(); + + public AppInfo() {} + + public AppInfo(String app) { + this.app = app; + } + + public AppInfo(String app, Integer appType) { + this.app = app; + this.appType = appType; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public Integer getAppType() { + return appType; + } + + public void setAppType(Integer appType) { + this.appType = appType; + } + + /** + * Get the current machines. + * + * @return a new copy of the current machines. + */ + public Set getMachines() { + return new HashSet<>(machines); + } + + @Override + public String toString() { + return "AppInfo{" + "app='" + app + ", machines=" + machines + '}'; + } + + public boolean addMachine(MachineInfo machineInfo) { + machines.remove(machineInfo); + return machines.add(machineInfo); + } + + public synchronized boolean removeMachine(String ip, int port) { + Iterator it = machines.iterator(); + while (it.hasNext()) { + MachineInfo machine = it.next(); + if (machine.getIp().equals(ip) && machine.getPort() == port) { + it.remove(); + return true; + } + } + return false; + } + + public Optional getMachine(String ip, int port) { + return machines.stream() + .filter(e -> e.getIp().equals(ip) && e.getPort().equals(port)) + .findFirst(); + } + + private boolean heartbeatJudge(final int threshold) { + if (machines.size() == 0) { + return false; + } + if (threshold > 0) { + long healthyCount = machines.stream() + .filter(MachineInfo::isHealthy) + .count(); + if (healthyCount == 0) { + // No healthy machines. + return machines.stream() + .max(Comparator.comparingLong(MachineInfo::getLastHeartbeat)) + .map(e -> System.currentTimeMillis() - e.getLastHeartbeat() < threshold) + .orElse(false); + } + } + return true; + } + + /** + * Check whether current application has no healthy machines and should not be displayed. + * + * @return true if the application should be displayed in the sidebar, otherwise false + */ + public boolean isShown() { + return heartbeatJudge(DashboardConfig.getHideAppNoMachineMillis()); + } + + /** + * Check whether current application has no healthy machines and should be removed. + * + * @return true if the application is dead and should be removed, otherwise false + */ + public boolean isDead() { + return !heartbeatJudge(DashboardConfig.getRemoveAppNoMachineMillis()); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/AppManagement.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/AppManagement.java new file mode 100755 index 00000000..9e44336f --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/AppManagement.java @@ -0,0 +1,70 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.discovery; + +import java.util.List; +import java.util.Set; + +import javax.annotation.PostConstruct; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; + +@Component +public class AppManagement implements MachineDiscovery { + + @Autowired + private ApplicationContext context; + + private MachineDiscovery machineDiscovery; + + @PostConstruct + public void init() { + machineDiscovery = context.getBean(SimpleMachineDiscovery.class); + } + + @Override + public Set getBriefApps() { + return machineDiscovery.getBriefApps(); + } + + @Override + public long addMachine(MachineInfo machineInfo) { + return machineDiscovery.addMachine(machineInfo); + } + + @Override + public boolean removeMachine(String app, String ip, int port) { + return machineDiscovery.removeMachine(app, ip, port); + } + + @Override + public List getAppNames() { + return machineDiscovery.getAppNames(); + } + + @Override + public AppInfo getDetailApp(String app) { + return machineDiscovery.getDetailApp(app); + } + + @Override + public void removeApp(String app) { + machineDiscovery.removeApp(app); + } + +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineDiscovery.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineDiscovery.java new file mode 100755 index 00000000..260b0d8c --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineDiscovery.java @@ -0,0 +1,51 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.discovery; + +import java.util.List; +import java.util.Set; + +public interface MachineDiscovery { + + String UNKNOWN_APP_NAME = "CLUSTER_NOT_STARTED"; + + List getAppNames(); + + Set getBriefApps(); + + AppInfo getDetailApp(String app); + + /** + * Remove the given app from the application registry. + * + * @param app application name + * @since 1.5.0 + */ + void removeApp(String app); + + long addMachine(MachineInfo machineInfo); + + /** + * Remove the given machine instance from the application registry. + * + * @param app the application name of the machine + * @param ip machine IP + * @param port machine port + * @return true if removed, otherwise false + * @since 1.5.0 + */ + boolean removeMachine(String app, String ip, int port); +} \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineInfo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineInfo.java new file mode 100755 index 00000000..afcc8124 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineInfo.java @@ -0,0 +1,185 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.discovery; + +import java.util.Objects; + +import com.alibaba.csp.sentinel.dashboard.config.DashboardConfig; +import com.alibaba.csp.sentinel.util.StringUtil; + +public class MachineInfo implements Comparable { + + private String app = ""; + private Integer appType = 0; + private String hostname = ""; + private String ip = ""; + private Integer port = -1; + private long lastHeartbeat; + private long heartbeatVersion; + + /** + * Indicates the version of Sentinel client (since 0.2.0). + */ + private String version; + + public static MachineInfo of(String app, String ip, Integer port) { + MachineInfo machineInfo = new MachineInfo(); + machineInfo.setApp(app); + machineInfo.setIp(ip); + machineInfo.setPort(port); + return machineInfo; + } + + public String toHostPort() { + return ip + ":" + port; + } + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public Integer getAppType() { + return appType; + } + + public void setAppType(Integer appType) { + this.appType = appType; + } + + public String getHostname() { + return hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public long getHeartbeatVersion() { + return heartbeatVersion; + } + + public void setHeartbeatVersion(long heartbeatVersion) { + this.heartbeatVersion = heartbeatVersion; + } + + public String getVersion() { + return version; + } + + public MachineInfo setVersion(String version) { + this.version = version; + return this; + } + + public boolean isHealthy() { + long delta = System.currentTimeMillis() - lastHeartbeat; + return delta < DashboardConfig.getUnhealthyMachineMillis(); + } + + /** + * whether dead should be removed + * + * @return + */ + public boolean isDead() { + if (DashboardConfig.getAutoRemoveMachineMillis() > 0) { + long delta = System.currentTimeMillis() - lastHeartbeat; + return delta > DashboardConfig.getAutoRemoveMachineMillis(); + } + return false; + } + + public long getLastHeartbeat() { + return lastHeartbeat; + } + + public void setLastHeartbeat(long lastHeartbeat) { + this.lastHeartbeat = lastHeartbeat; + } + + @Override + public int compareTo(MachineInfo o) { + if (this == o) { + return 0; + } + if (!port.equals(o.getPort())) { + return port.compareTo(o.getPort()); + } + if (!StringUtil.equals(app, o.getApp())) { + return app.compareToIgnoreCase(o.getApp()); + } + return ip.compareToIgnoreCase(o.getIp()); + } + + @Override + public String toString() { + return new StringBuilder("MachineInfo {") + .append("app='").append(app).append('\'') + .append(",appType='").append(appType).append('\'') + .append(", hostname='").append(hostname).append('\'') + .append(", ip='").append(ip).append('\'') + .append(", port=").append(port) + .append(", heartbeatVersion=").append(heartbeatVersion) + .append(", lastHeartbeat=").append(lastHeartbeat) + .append(", version='").append(version).append('\'') + .append(", healthy=").append(isHealthy()) + .append('}').toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { return true; } + if (!(o instanceof MachineInfo)) { return false; } + MachineInfo that = (MachineInfo)o; + return Objects.equals(app, that.app) && + Objects.equals(ip, that.ip) && + Objects.equals(port, that.port); + } + + @Override + public int hashCode() { + return Objects.hash(app, ip, port); + } + + /** + * Information for log + * + * @return + */ + public String toLogString() { + return app + "|" + ip + "|" + port + "|" + version; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java new file mode 100755 index 00000000..a4ab83ac --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java @@ -0,0 +1,77 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.discovery; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import com.alibaba.csp.sentinel.util.AssertUtil; + +import org.springframework.stereotype.Component; + +/** + * @author leyou + */ +@Component +public class SimpleMachineDiscovery implements MachineDiscovery { + + private final ConcurrentMap apps = new ConcurrentHashMap<>(); + + @Override + public long addMachine(MachineInfo machineInfo) { + AssertUtil.notNull(machineInfo, "machineInfo cannot be null"); + AppInfo appInfo = apps.computeIfAbsent(machineInfo.getApp(), o -> new AppInfo(machineInfo.getApp(), machineInfo.getAppType())); + appInfo.addMachine(machineInfo); + return 1; + } + + @Override + public boolean removeMachine(String app, String ip, int port) { + AssertUtil.assertNotBlank(app, "app name cannot be blank"); + AppInfo appInfo = apps.get(app); + if (appInfo != null) { + return appInfo.removeMachine(ip, port); + } + return false; + } + + @Override + public List getAppNames() { + return new ArrayList<>(apps.keySet()); + } + + @Override + public AppInfo getDetailApp(String app) { + AssertUtil.assertNotBlank(app, "app name cannot be blank"); + return apps.get(app); + } + + @Override + public Set getBriefApps() { + return new HashSet<>(apps.values()); + } + + @Override + public void removeApp(String app) { + AssertUtil.assertNotBlank(app, "app name cannot be blank"); + apps.remove(app); + } + +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/ResourceTreeNode.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/ResourceTreeNode.java new file mode 100755 index 00000000..be576160 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/ResourceTreeNode.java @@ -0,0 +1,242 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.alibaba.csp.sentinel.command.vo.NodeVo; + +/** + * @author leyou + */ +public class ResourceTreeNode { + private String id; + private String parentId; + private String resource; + + private Integer threadNum; + private Long passQps; + private Long blockQps; + private Long totalQps; + private Long averageRt; + private Long successQps; + private Long exceptionQps; + private Long oneMinutePass; + private Long oneMinuteBlock; + private Long oneMinuteException; + private Long oneMinuteTotal; + + private boolean visible = true; + + private List children = new ArrayList<>(); + + public static ResourceTreeNode fromNodeVoList(List nodeVos) { + if (nodeVos == null || nodeVos.isEmpty()) { + return null; + } + ResourceTreeNode root = null; + Map map = new HashMap<>(); + for (NodeVo vo : nodeVos) { + ResourceTreeNode node = fromNodeVo(vo); + map.put(node.id, node); + // real root + if (node.parentId == null || node.parentId.isEmpty()) { + root = node; + } else if (map.containsKey(node.parentId)) { + map.get(node.parentId).children.add(node); + } else { + // impossible + } + } + return root; + } + + public static ResourceTreeNode fromNodeVo(NodeVo vo) { + ResourceTreeNode node = new ResourceTreeNode(); + node.id = vo.getId(); + node.parentId = vo.getParentId(); + node.resource = vo.getResource(); + node.threadNum = vo.getThreadNum(); + node.passQps = vo.getPassQps(); + node.blockQps = vo.getBlockQps(); + node.totalQps = vo.getTotalQps(); + node.averageRt = vo.getAverageRt(); + node.successQps = vo.getSuccessQps(); + node.exceptionQps = vo.getExceptionQps(); + node.oneMinutePass = vo.getOneMinutePass(); + node.oneMinuteBlock = vo.getOneMinuteBlock(); + node.oneMinuteException = vo.getOneMinuteException(); + node.oneMinuteTotal = vo.getOneMinuteTotal(); + return node; + } + + public void searchIgnoreCase(String searchKey) { + search(this, searchKey); + } + + /** + * This node is visible only when searchKey matches this.resource or at least + * one of this's children is visible + */ + private boolean search(ResourceTreeNode node, String searchKey) { + // empty matches all + if (searchKey == null || searchKey.isEmpty() || + node.resource.toLowerCase().contains(searchKey.toLowerCase())) { + node.visible = true; + } else { + node.visible = false; + } + + boolean found = false; + for (ResourceTreeNode c : node.children) { + found |= search(c, searchKey); + } + node.visible |= found; + return node.visible; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getParentId() { + return parentId; + } + + public void setParentId(String parentId) { + this.parentId = parentId; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public Integer getThreadNum() { + return threadNum; + } + + public void setThreadNum(Integer threadNum) { + this.threadNum = threadNum; + } + + public Long getPassQps() { + return passQps; + } + + public void setPassQps(Long passQps) { + this.passQps = passQps; + } + + public Long getBlockQps() { + return blockQps; + } + + public void setBlockQps(Long blockQps) { + this.blockQps = blockQps; + } + + public Long getTotalQps() { + return totalQps; + } + + public void setTotalQps(Long totalQps) { + this.totalQps = totalQps; + } + + public Long getAverageRt() { + return averageRt; + } + + public void setAverageRt(Long averageRt) { + this.averageRt = averageRt; + } + + public Long getSuccessQps() { + return successQps; + } + + public void setSuccessQps(Long successQps) { + this.successQps = successQps; + } + + public Long getExceptionQps() { + return exceptionQps; + } + + public void setExceptionQps(Long exceptionQps) { + this.exceptionQps = exceptionQps; + } + + public Long getOneMinutePass() { + return oneMinutePass; + } + + public void setOneMinutePass(Long oneMinutePass) { + this.oneMinutePass = oneMinutePass; + } + + public Long getOneMinuteBlock() { + return oneMinuteBlock; + } + + public void setOneMinuteBlock(Long oneMinuteBlock) { + this.oneMinuteBlock = oneMinuteBlock; + } + + public Long getOneMinuteException() { + return oneMinuteException; + } + + public void setOneMinuteException(Long oneMinuteException) { + this.oneMinuteException = oneMinuteException; + } + + public Long getOneMinuteTotal() { + return oneMinuteTotal; + } + + public void setOneMinuteTotal(Long oneMinuteTotal) { + this.oneMinuteTotal = oneMinuteTotal; + } + + public boolean isVisible() { + return visible; + } + + public void setVisible(boolean visible) { + this.visible = visible; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } +} + diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/Result.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/Result.java new file mode 100755 index 00000000..2dbf476f --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/Result.java @@ -0,0 +1,103 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain; + +/** + * @author leyou + * @author Eric Zhao + */ +public class Result { + + private boolean success; + private int code; + private String msg; + private R data; + + public static Result ofSuccess(R data) { + return new Result() + .setSuccess(true) + .setMsg("success") + .setData(data); + } + + public static Result ofSuccessMsg(String msg) { + return new Result() + .setSuccess(true) + .setMsg(msg); + } + + public static Result ofFail(int code, String msg) { + Result result = new Result<>(); + result.setSuccess(false); + result.setCode(code); + result.setMsg(msg); + return result; + } + + public static Result ofThrowable(int code, Throwable throwable) { + Result result = new Result<>(); + result.setSuccess(false); + result.setCode(code); + result.setMsg(throwable.getClass().getName() + ", " + throwable.getMessage()); + return result; + } + + public boolean isSuccess() { + return success; + } + + public Result setSuccess(boolean success) { + this.success = success; + return this; + } + + public int getCode() { + return code; + } + + public Result setCode(int code) { + this.code = code; + return this; + } + + public String getMsg() { + return msg; + } + + public Result setMsg(String msg) { + this.msg = msg; + return this; + } + + public R getData() { + return data; + } + + public Result setData(R data) { + this.data = data; + return this; + } + + @Override + public String toString() { + return "Result{" + + "success=" + success + + ", code=" + code + + ", msg='" + msg + '\'' + + ", data=" + data + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppAssignResultVO.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppAssignResultVO.java new file mode 100755 index 00000000..b7b48ccf --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppAssignResultVO.java @@ -0,0 +1,66 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster; + +import java.util.Set; + +/** + * @author Eric Zhao + * @since 1.4.1 + */ +public class ClusterAppAssignResultVO { + + private Set failedServerSet; + private Set failedClientSet; + + private Integer totalCount; + + public Set getFailedServerSet() { + return failedServerSet; + } + + public ClusterAppAssignResultVO setFailedServerSet(Set failedServerSet) { + this.failedServerSet = failedServerSet; + return this; + } + + public Set getFailedClientSet() { + return failedClientSet; + } + + public ClusterAppAssignResultVO setFailedClientSet(Set failedClientSet) { + this.failedClientSet = failedClientSet; + return this; + } + + public Integer getTotalCount() { + return totalCount; + } + + public ClusterAppAssignResultVO setTotalCount(Integer totalCount) { + this.totalCount = totalCount; + return this; + } + + @Override + public String toString() { + return "ClusterAppAssignResultVO{" + + "failedServerSet=" + failedServerSet + + ", failedClientSet=" + failedClientSet + + ", totalCount=" + totalCount + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppFullAssignRequest.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppFullAssignRequest.java new file mode 100755 index 00000000..96a3dc93 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppFullAssignRequest.java @@ -0,0 +1,58 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster; + +import java.util.List; +import java.util.Set; + +import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterAppAssignMap; + +/** + * @author Eric Zhao + * @since 1.4.1 + */ +public class ClusterAppFullAssignRequest { + + private List clusterMap; + private Set remainingList; + + public List getClusterMap() { + return clusterMap; + } + + public ClusterAppFullAssignRequest setClusterMap( + List clusterMap) { + this.clusterMap = clusterMap; + return this; + } + + public Set getRemainingList() { + return remainingList; + } + + public ClusterAppFullAssignRequest setRemainingList(Set remainingList) { + this.remainingList = remainingList; + return this; + } + + @Override + public String toString() { + return "ClusterAppFullAssignRequest{" + + "clusterMap=" + clusterMap + + ", remainingList=" + remainingList + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppSingleServerAssignRequest.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppSingleServerAssignRequest.java new file mode 100755 index 00000000..f9d9bbc0 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppSingleServerAssignRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster; + +import java.util.Set; + +import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterAppAssignMap; + +/** + * @author Eric Zhao + * @since 1.4.1 + */ +public class ClusterAppSingleServerAssignRequest { + + private ClusterAppAssignMap clusterMap; + private Set remainingList; + + public ClusterAppAssignMap getClusterMap() { + return clusterMap; + } + + public ClusterAppSingleServerAssignRequest setClusterMap(ClusterAppAssignMap clusterMap) { + this.clusterMap = clusterMap; + return this; + } + + public Set getRemainingList() { + return remainingList; + } + + public ClusterAppSingleServerAssignRequest setRemainingList(Set remainingList) { + this.remainingList = remainingList; + return this; + } + + @Override + public String toString() { + return "ClusterAppSingleServerAssignRequest{" + + "clusterMap=" + clusterMap + + ", remainingList=" + remainingList + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterClientInfoVO.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterClientInfoVO.java new file mode 100755 index 00000000..a9437e76 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterClientInfoVO.java @@ -0,0 +1,76 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster; + +/** + * @author Eric Zhao + * @since 1.4.1 + */ +public class ClusterClientInfoVO { + + private String serverHost; + private Integer serverPort; + + private Integer clientState; + + private Integer requestTimeout; + + public String getServerHost() { + return serverHost; + } + + public ClusterClientInfoVO setServerHost(String serverHost) { + this.serverHost = serverHost; + return this; + } + + public Integer getServerPort() { + return serverPort; + } + + public ClusterClientInfoVO setServerPort(Integer serverPort) { + this.serverPort = serverPort; + return this; + } + + public Integer getClientState() { + return clientState; + } + + public ClusterClientInfoVO setClientState(Integer clientState) { + this.clientState = clientState; + return this; + } + + public Integer getRequestTimeout() { + return requestTimeout; + } + + public ClusterClientInfoVO setRequestTimeout(Integer requestTimeout) { + this.requestTimeout = requestTimeout; + return this; + } + + @Override + public String toString() { + return "ClusterClientInfoVO{" + + "serverHost='" + serverHost + '\'' + + ", serverPort=" + serverPort + + ", clientState=" + clientState + + ", requestTimeout=" + requestTimeout + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterGroupEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterGroupEntity.java new file mode 100755 index 00000000..eef25521 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterGroupEntity.java @@ -0,0 +1,91 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster; + +import java.util.HashSet; +import java.util.Set; + +/** + * @author Eric Zhao + * @since 1.4.1 + */ +public class ClusterGroupEntity { + + private String machineId; + + private String ip; + private Integer port; + + private Set clientSet = new HashSet<>(); + + private Boolean belongToApp; + + public String getMachineId() { + return machineId; + } + + public ClusterGroupEntity setMachineId(String machineId) { + this.machineId = machineId; + return this; + } + + public String getIp() { + return ip; + } + + public ClusterGroupEntity setIp(String ip) { + this.ip = ip; + return this; + } + + public Integer getPort() { + return port; + } + + public ClusterGroupEntity setPort(Integer port) { + this.port = port; + return this; + } + + public Set getClientSet() { + return clientSet; + } + + public ClusterGroupEntity setClientSet(Set clientSet) { + this.clientSet = clientSet; + return this; + } + + public Boolean getBelongToApp() { + return belongToApp; + } + + public ClusterGroupEntity setBelongToApp(Boolean belongToApp) { + this.belongToApp = belongToApp; + return this; + } + + @Override + public String toString() { + return "ClusterGroupEntity{" + + "machineId='" + machineId + '\'' + + ", ip='" + ip + '\'' + + ", port=" + port + + ", clientSet=" + clientSet + + ", belongToApp=" + belongToApp + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterStateSingleVO.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterStateSingleVO.java new file mode 100755 index 00000000..7678c519 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterStateSingleVO.java @@ -0,0 +1,63 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster; + +/** + * @author Eric Zhao + * @since 1.4.1 + */ +public class ClusterStateSingleVO { + + private String address; + private Integer mode; + private String target; + + public String getAddress() { + return address; + } + + public ClusterStateSingleVO setAddress(String address) { + this.address = address; + return this; + } + + public Integer getMode() { + return mode; + } + + public ClusterStateSingleVO setMode(Integer mode) { + this.mode = mode; + return this; + } + + public String getTarget() { + return target; + } + + public ClusterStateSingleVO setTarget(String target) { + this.target = target; + return this; + } + + @Override + public String toString() { + return "ClusterStateSingleVO{" + + "address='" + address + '\'' + + ", mode=" + mode + + ", target='" + target + '\'' + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ConnectionDescriptorVO.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ConnectionDescriptorVO.java new file mode 100755 index 00000000..71d9e74d --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ConnectionDescriptorVO.java @@ -0,0 +1,53 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster; + + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +public class ConnectionDescriptorVO { + + private String address; + private String host; + + public String getAddress() { + return address; + } + + public ConnectionDescriptorVO setAddress(String address) { + this.address = address; + return this; + } + + public String getHost() { + return host; + } + + public ConnectionDescriptorVO setHost(String host) { + this.host = host; + return this; + } + + @Override + public String toString() { + return "ConnectionDescriptorVO{" + + "address='" + address + '\'' + + ", host='" + host + '\'' + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ConnectionGroupVO.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ConnectionGroupVO.java new file mode 100755 index 00000000..af3aa906 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ConnectionGroupVO.java @@ -0,0 +1,66 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster; + +import java.util.List; + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +public class ConnectionGroupVO { + + private String namespace; + private List connectionSet; + private Integer connectedCount; + + public String getNamespace() { + return namespace; + } + + public ConnectionGroupVO setNamespace(String namespace) { + this.namespace = namespace; + return this; + } + + public List getConnectionSet() { + return connectionSet; + } + + public ConnectionGroupVO setConnectionSet( + List connectionSet) { + this.connectionSet = connectionSet; + return this; + } + + public Integer getConnectedCount() { + return connectedCount; + } + + public ConnectionGroupVO setConnectedCount(Integer connectedCount) { + this.connectedCount = connectedCount; + return this; + } + + @Override + public String toString() { + return "ConnectionGroupVO{" + + "namespace='" + namespace + '\'' + + ", connectionSet=" + connectionSet + + ", connectedCount=" + connectedCount + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/config/ClusterClientConfig.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/config/ClusterClientConfig.java new file mode 100755 index 00000000..2cd6bb3b --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/config/ClusterClientConfig.java @@ -0,0 +1,75 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster.config; + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +public class ClusterClientConfig { + + private String serverHost; + private Integer serverPort; + + private Integer requestTimeout; + private Integer connectTimeout; + + public String getServerHost() { + return serverHost; + } + + public ClusterClientConfig setServerHost(String serverHost) { + this.serverHost = serverHost; + return this; + } + + public Integer getServerPort() { + return serverPort; + } + + public ClusterClientConfig setServerPort(Integer serverPort) { + this.serverPort = serverPort; + return this; + } + + public Integer getRequestTimeout() { + return requestTimeout; + } + + public ClusterClientConfig setRequestTimeout(Integer requestTimeout) { + this.requestTimeout = requestTimeout; + return this; + } + + public Integer getConnectTimeout() { + return connectTimeout; + } + + public ClusterClientConfig setConnectTimeout(Integer connectTimeout) { + this.connectTimeout = connectTimeout; + return this; + } + + @Override + public String toString() { + return "ClusterClientConfig{" + + "serverHost='" + serverHost + '\'' + + ", serverPort=" + serverPort + + ", requestTimeout=" + requestTimeout + + ", connectTimeout=" + connectTimeout + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/config/ServerFlowConfig.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/config/ServerFlowConfig.java new file mode 100755 index 00000000..3390ea14 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/config/ServerFlowConfig.java @@ -0,0 +1,108 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster.config; + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +public class ServerFlowConfig { + + public static final double DEFAULT_EXCEED_COUNT = 1.0d; + public static final double DEFAULT_MAX_OCCUPY_RATIO = 1.0d; + + public static final int DEFAULT_INTERVAL_MS = 1000; + public static final int DEFAULT_SAMPLE_COUNT= 10; + public static final double DEFAULT_MAX_ALLOWED_QPS= 30000; + + private final String namespace; + + private Double exceedCount = DEFAULT_EXCEED_COUNT; + private Double maxOccupyRatio = DEFAULT_MAX_OCCUPY_RATIO; + private Integer intervalMs = DEFAULT_INTERVAL_MS; + private Integer sampleCount = DEFAULT_SAMPLE_COUNT; + + private Double maxAllowedQps = DEFAULT_MAX_ALLOWED_QPS; + + public ServerFlowConfig() { + this("default"); + } + + public ServerFlowConfig(String namespace) { + this.namespace = namespace; + } + + public String getNamespace() { + return namespace; + } + + public Double getExceedCount() { + return exceedCount; + } + + public ServerFlowConfig setExceedCount(Double exceedCount) { + this.exceedCount = exceedCount; + return this; + } + + public Double getMaxOccupyRatio() { + return maxOccupyRatio; + } + + public ServerFlowConfig setMaxOccupyRatio(Double maxOccupyRatio) { + this.maxOccupyRatio = maxOccupyRatio; + return this; + } + + public Integer getIntervalMs() { + return intervalMs; + } + + public ServerFlowConfig setIntervalMs(Integer intervalMs) { + this.intervalMs = intervalMs; + return this; + } + + public Integer getSampleCount() { + return sampleCount; + } + + public ServerFlowConfig setSampleCount(Integer sampleCount) { + this.sampleCount = sampleCount; + return this; + } + + public Double getMaxAllowedQps() { + return maxAllowedQps; + } + + public ServerFlowConfig setMaxAllowedQps(Double maxAllowedQps) { + this.maxAllowedQps = maxAllowedQps; + return this; + } + + @Override + public String toString() { + return "ServerFlowConfig{" + + "namespace='" + namespace + '\'' + + ", exceedCount=" + exceedCount + + ", maxOccupyRatio=" + maxOccupyRatio + + ", intervalMs=" + intervalMs + + ", sampleCount=" + sampleCount + + ", maxAllowedQps=" + maxAllowedQps + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/config/ServerTransportConfig.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/config/ServerTransportConfig.java new file mode 100755 index 00000000..58fe12a7 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/config/ServerTransportConfig.java @@ -0,0 +1,64 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster.config; + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +public class ServerTransportConfig { + + public static final int DEFAULT_PORT = 18730; + public static final int DEFAULT_IDLE_SECONDS = 600; + + private Integer port; + private Integer idleSeconds; + + public ServerTransportConfig() { + this(DEFAULT_PORT, DEFAULT_IDLE_SECONDS); + } + + public ServerTransportConfig(Integer port, Integer idleSeconds) { + this.port = port; + this.idleSeconds = idleSeconds; + } + + public Integer getPort() { + return port; + } + + public ServerTransportConfig setPort(Integer port) { + this.port = port; + return this; + } + + public Integer getIdleSeconds() { + return idleSeconds; + } + + public ServerTransportConfig setIdleSeconds(Integer idleSeconds) { + this.idleSeconds = idleSeconds; + return this; + } + + @Override + public String toString() { + return "ServerTransportConfig{" + + "port=" + port + + ", idleSeconds=" + idleSeconds + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterAppAssignMap.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterAppAssignMap.java new file mode 100755 index 00000000..3dbf96b1 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterAppAssignMap.java @@ -0,0 +1,112 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster.request; + +import java.util.Set; + +/** + * @author Eric Zhao + * @since 1.4.1 + */ +public class ClusterAppAssignMap { + + private String machineId; + private String ip; + private Integer port; + + private Boolean belongToApp; + + private Set clientSet; + + private Set namespaceSet; + private Double maxAllowedQps; + + public String getMachineId() { + return machineId; + } + + public ClusterAppAssignMap setMachineId(String machineId) { + this.machineId = machineId; + return this; + } + + public String getIp() { + return ip; + } + + public ClusterAppAssignMap setIp(String ip) { + this.ip = ip; + return this; + } + + public Integer getPort() { + return port; + } + + public ClusterAppAssignMap setPort(Integer port) { + this.port = port; + return this; + } + + public Set getClientSet() { + return clientSet; + } + + public ClusterAppAssignMap setClientSet(Set clientSet) { + this.clientSet = clientSet; + return this; + } + + public Set getNamespaceSet() { + return namespaceSet; + } + + public ClusterAppAssignMap setNamespaceSet(Set namespaceSet) { + this.namespaceSet = namespaceSet; + return this; + } + + public Boolean getBelongToApp() { + return belongToApp; + } + + public ClusterAppAssignMap setBelongToApp(Boolean belongToApp) { + this.belongToApp = belongToApp; + return this; + } + + public Double getMaxAllowedQps() { + return maxAllowedQps; + } + + public ClusterAppAssignMap setMaxAllowedQps(Double maxAllowedQps) { + this.maxAllowedQps = maxAllowedQps; + return this; + } + + @Override + public String toString() { + return "ClusterAppAssignMap{" + + "machineId='" + machineId + '\'' + + ", ip='" + ip + '\'' + + ", port=" + port + + ", belongToApp=" + belongToApp + + ", clientSet=" + clientSet + + ", namespaceSet=" + namespaceSet + + ", maxAllowedQps=" + maxAllowedQps + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterClientModifyRequest.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterClientModifyRequest.java new file mode 100755 index 00000000..e6ff5610 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterClientModifyRequest.java @@ -0,0 +1,82 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster.request; + +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ClusterClientConfig; + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +public class ClusterClientModifyRequest implements ClusterModifyRequest { + + private String app; + private String ip; + private Integer port; + + private Integer mode; + private ClusterClientConfig clientConfig; + + @Override + public String getApp() { + return app; + } + + public ClusterClientModifyRequest setApp(String app) { + this.app = app; + return this; + } + + @Override + public String getIp() { + return ip; + } + + public ClusterClientModifyRequest setIp(String ip) { + this.ip = ip; + return this; + } + + @Override + public Integer getPort() { + return port; + } + + public ClusterClientModifyRequest setPort(Integer port) { + this.port = port; + return this; + } + + @Override + public Integer getMode() { + return mode; + } + + public ClusterClientModifyRequest setMode(Integer mode) { + this.mode = mode; + return this; + } + + public ClusterClientConfig getClientConfig() { + return clientConfig; + } + + public ClusterClientModifyRequest setClientConfig( + ClusterClientConfig clientConfig) { + this.clientConfig = clientConfig; + return this; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterModifyRequest.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterModifyRequest.java new file mode 100755 index 00000000..9f855ef7 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterModifyRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster.request; + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +public interface ClusterModifyRequest { + + String getApp(); + + String getIp(); + + Integer getPort(); + + Integer getMode(); +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterServerModifyRequest.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterServerModifyRequest.java new file mode 100755 index 00000000..9389f693 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterServerModifyRequest.java @@ -0,0 +1,119 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster.request; + +import java.util.Set; + +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerFlowConfig; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerTransportConfig; + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +public class ClusterServerModifyRequest implements ClusterModifyRequest { + + private String app; + private String ip; + private Integer port; + + private Integer mode; + private ServerFlowConfig flowConfig; + private ServerTransportConfig transportConfig; + private Set namespaceSet; + + @Override + public String getApp() { + return app; + } + + public ClusterServerModifyRequest setApp(String app) { + this.app = app; + return this; + } + + @Override + public String getIp() { + return ip; + } + + public ClusterServerModifyRequest setIp(String ip) { + this.ip = ip; + return this; + } + + @Override + public Integer getPort() { + return port; + } + + public ClusterServerModifyRequest setPort(Integer port) { + this.port = port; + return this; + } + + @Override + public Integer getMode() { + return mode; + } + + public ClusterServerModifyRequest setMode(Integer mode) { + this.mode = mode; + return this; + } + + public ServerFlowConfig getFlowConfig() { + return flowConfig; + } + + public ClusterServerModifyRequest setFlowConfig( + ServerFlowConfig flowConfig) { + this.flowConfig = flowConfig; + return this; + } + + public ServerTransportConfig getTransportConfig() { + return transportConfig; + } + + public ClusterServerModifyRequest setTransportConfig( + ServerTransportConfig transportConfig) { + this.transportConfig = transportConfig; + return this; + } + + public Set getNamespaceSet() { + return namespaceSet; + } + + public ClusterServerModifyRequest setNamespaceSet(Set namespaceSet) { + this.namespaceSet = namespaceSet; + return this; + } + + @Override + public String toString() { + return "ClusterServerModifyRequest{" + + "app='" + app + '\'' + + ", ip='" + ip + '\'' + + ", port=" + port + + ", mode=" + mode + + ", flowConfig=" + flowConfig + + ", transportConfig=" + transportConfig + + ", namespaceSet=" + namespaceSet + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/AppClusterClientStateWrapVO.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/AppClusterClientStateWrapVO.java new file mode 100755 index 00000000..4076d23b --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/AppClusterClientStateWrapVO.java @@ -0,0 +1,79 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster.state; + +/** + * @author Eric Zhao + * @since 1.4.1 + */ +public class AppClusterClientStateWrapVO { + + /** + * {ip}@{transport_command_port}. + */ + private String id; + + private Integer commandPort; + private String ip; + + private ClusterClientStateVO state; + + public String getId() { + return id; + } + + public AppClusterClientStateWrapVO setId(String id) { + this.id = id; + return this; + } + + public String getIp() { + return ip; + } + + public AppClusterClientStateWrapVO setIp(String ip) { + this.ip = ip; + return this; + } + + public ClusterClientStateVO getState() { + return state; + } + + public AppClusterClientStateWrapVO setState(ClusterClientStateVO state) { + this.state = state; + return this; + } + + public Integer getCommandPort() { + return commandPort; + } + + public AppClusterClientStateWrapVO setCommandPort(Integer commandPort) { + this.commandPort = commandPort; + return this; + } + + @Override + public String toString() { + return "AppClusterClientStateWrapVO{" + + "id='" + id + '\'' + + ", commandPort=" + commandPort + + ", ip='" + ip + '\'' + + ", state=" + state + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/AppClusterServerStateWrapVO.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/AppClusterServerStateWrapVO.java new file mode 100755 index 00000000..ed39e7bc --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/AppClusterServerStateWrapVO.java @@ -0,0 +1,102 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster.state; + +/** + * @author Eric Zhao + * @since 1.4.1 + */ +public class AppClusterServerStateWrapVO { + + /** + * {ip}@{transport_command_port}. + */ + private String id; + + private String ip; + private Integer port; + + private Integer connectedCount; + + private Boolean belongToApp; + + private ClusterServerStateVO state; + + public String getId() { + return id; + } + + public AppClusterServerStateWrapVO setId(String id) { + this.id = id; + return this; + } + + public String getIp() { + return ip; + } + + public AppClusterServerStateWrapVO setIp(String ip) { + this.ip = ip; + return this; + } + + public Integer getPort() { + return port; + } + + public AppClusterServerStateWrapVO setPort(Integer port) { + this.port = port; + return this; + } + + public Boolean getBelongToApp() { + return belongToApp; + } + + public AppClusterServerStateWrapVO setBelongToApp(Boolean belongToApp) { + this.belongToApp = belongToApp; + return this; + } + + public Integer getConnectedCount() { + return connectedCount; + } + + public AppClusterServerStateWrapVO setConnectedCount(Integer connectedCount) { + this.connectedCount = connectedCount; + return this; + } + + public ClusterServerStateVO getState() { + return state; + } + + public AppClusterServerStateWrapVO setState(ClusterServerStateVO state) { + this.state = state; + return this; + } + + @Override + public String toString() { + return "AppClusterServerStateWrapVO{" + + "id='" + id + '\'' + + ", ip='" + ip + '\'' + + ", port='" + port + '\'' + + ", belongToApp=" + belongToApp + + ", state=" + state + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterClientStateVO.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterClientStateVO.java new file mode 100755 index 00000000..ac61b0b9 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterClientStateVO.java @@ -0,0 +1,46 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster.state; + +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterClientInfoVO; + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +public class ClusterClientStateVO { + + /** + * Cluster token client state. + */ + private ClusterClientInfoVO clientConfig; + + public ClusterClientInfoVO getClientConfig() { + return clientConfig; + } + + public ClusterClientStateVO setClientConfig(ClusterClientInfoVO clientConfig) { + this.clientConfig = clientConfig; + return this; + } + + @Override + public String toString() { + return "ClusterClientStateVO{" + + "clientConfig=" + clientConfig + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterRequestLimitVO.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterRequestLimitVO.java new file mode 100755 index 00000000..6c5da420 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterRequestLimitVO.java @@ -0,0 +1,63 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster.state; + +/** + * @author Eric Zhao + * @since 1.4.1 + */ +public class ClusterRequestLimitVO { + + private String namespace; + private Double currentQps; + private Double maxAllowedQps; + + public String getNamespace() { + return namespace; + } + + public ClusterRequestLimitVO setNamespace(String namespace) { + this.namespace = namespace; + return this; + } + + public Double getCurrentQps() { + return currentQps; + } + + public ClusterRequestLimitVO setCurrentQps(Double currentQps) { + this.currentQps = currentQps; + return this; + } + + public Double getMaxAllowedQps() { + return maxAllowedQps; + } + + public ClusterRequestLimitVO setMaxAllowedQps(Double maxAllowedQps) { + this.maxAllowedQps = maxAllowedQps; + return this; + } + + @Override + public String toString() { + return "ClusterRequestLimitVO{" + + "namespace='" + namespace + '\'' + + ", currentQps=" + currentQps + + ", maxAllowedQps=" + maxAllowedQps + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterServerStateVO.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterServerStateVO.java new file mode 100755 index 00000000..a76a7ff0 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterServerStateVO.java @@ -0,0 +1,129 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster.state; + +import java.util.List; +import java.util.Set; + +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ConnectionGroupVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerFlowConfig; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerTransportConfig; + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +public class ClusterServerStateVO { + + private String appName; + + private ServerTransportConfig transport; + private ServerFlowConfig flow; + private Set namespaceSet; + + private Integer port; + + private List connection; + private List requestLimitData; + + private Boolean embedded; + + public String getAppName() { + return appName; + } + + public ClusterServerStateVO setAppName(String appName) { + this.appName = appName; + return this; + } + + public ServerTransportConfig getTransport() { + return transport; + } + + public ClusterServerStateVO setTransport(ServerTransportConfig transport) { + this.transport = transport; + return this; + } + + public ServerFlowConfig getFlow() { + return flow; + } + + public ClusterServerStateVO setFlow(ServerFlowConfig flow) { + this.flow = flow; + return this; + } + + public Set getNamespaceSet() { + return namespaceSet; + } + + public ClusterServerStateVO setNamespaceSet(Set namespaceSet) { + this.namespaceSet = namespaceSet; + return this; + } + + public Integer getPort() { + return port; + } + + public ClusterServerStateVO setPort(Integer port) { + this.port = port; + return this; + } + + public List getConnection() { + return connection; + } + + public ClusterServerStateVO setConnection(List connection) { + this.connection = connection; + return this; + } + + public List getRequestLimitData() { + return requestLimitData; + } + + public ClusterServerStateVO setRequestLimitData(List requestLimitData) { + this.requestLimitData = requestLimitData; + return this; + } + + public Boolean getEmbedded() { + return embedded; + } + + public ClusterServerStateVO setEmbedded(Boolean embedded) { + this.embedded = embedded; + return this; + } + + @Override + public String toString() { + return "ClusterServerStateVO{" + + "appName='" + appName + '\'' + + ", transport=" + transport + + ", flow=" + flow + + ", namespaceSet=" + namespaceSet + + ", port=" + port + + ", connection=" + connection + + ", requestLimitData=" + requestLimitData + + ", embedded=" + embedded + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterStateSimpleEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterStateSimpleEntity.java new file mode 100755 index 00000000..c5537aab --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterStateSimpleEntity.java @@ -0,0 +1,74 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster.state; + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +public class ClusterStateSimpleEntity { + + private Integer mode; + private Long lastModified; + private Boolean clientAvailable; + private Boolean serverAvailable; + + public Integer getMode() { + return mode; + } + + public ClusterStateSimpleEntity setMode(Integer mode) { + this.mode = mode; + return this; + } + + public Long getLastModified() { + return lastModified; + } + + public ClusterStateSimpleEntity setLastModified(Long lastModified) { + this.lastModified = lastModified; + return this; + } + + public Boolean getClientAvailable() { + return clientAvailable; + } + + public ClusterStateSimpleEntity setClientAvailable(Boolean clientAvailable) { + this.clientAvailable = clientAvailable; + return this; + } + + public Boolean getServerAvailable() { + return serverAvailable; + } + + public ClusterStateSimpleEntity setServerAvailable(Boolean serverAvailable) { + this.serverAvailable = serverAvailable; + return this; + } + + @Override + public String toString() { + return "ClusterStateSimpleEntity{" + + "mode=" + mode + + ", lastModified=" + lastModified + + ", clientAvailable=" + clientAvailable + + ", serverAvailable=" + serverAvailable + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterUniversalStatePairVO.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterUniversalStatePairVO.java new file mode 100755 index 00000000..11276560 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterUniversalStatePairVO.java @@ -0,0 +1,72 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster.state; + +/** + * @author Eric Zhao + * @since 1.4.1 + */ +public class ClusterUniversalStatePairVO { + + private String ip; + private Integer commandPort; + + private ClusterUniversalStateVO state; + + public ClusterUniversalStatePairVO() {} + + public ClusterUniversalStatePairVO(String ip, Integer commandPort, ClusterUniversalStateVO state) { + this.ip = ip; + this.commandPort = commandPort; + this.state = state; + } + + public String getIp() { + return ip; + } + + public ClusterUniversalStatePairVO setIp(String ip) { + this.ip = ip; + return this; + } + + public Integer getCommandPort() { + return commandPort; + } + + public ClusterUniversalStatePairVO setCommandPort(Integer commandPort) { + this.commandPort = commandPort; + return this; + } + + public ClusterUniversalStateVO getState() { + return state; + } + + public ClusterUniversalStatePairVO setState(ClusterUniversalStateVO state) { + this.state = state; + return this; + } + + @Override + public String toString() { + return "ClusterUniversalStatePairVO{" + + "ip='" + ip + '\'' + + ", commandPort=" + commandPort + + ", state=" + state + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterUniversalStateVO.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterUniversalStateVO.java new file mode 100755 index 00000000..3e9a787d --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterUniversalStateVO.java @@ -0,0 +1,64 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.cluster.state; + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +public class ClusterUniversalStateVO { + + private ClusterStateSimpleEntity stateInfo; + private ClusterClientStateVO client; + private ClusterServerStateVO server; + + public ClusterClientStateVO getClient() { + return client; + } + + public ClusterUniversalStateVO setClient(ClusterClientStateVO client) { + this.client = client; + return this; + } + + public ClusterServerStateVO getServer() { + return server; + } + + public ClusterUniversalStateVO setServer(ClusterServerStateVO server) { + this.server = server; + return this; + } + + public ClusterStateSimpleEntity getStateInfo() { + return stateInfo; + } + + public ClusterUniversalStateVO setStateInfo( + ClusterStateSimpleEntity stateInfo) { + this.stateInfo = stateInfo; + return this; + } + + @Override + public String toString() { + return "ClusterUniversalStateVO{" + + "stateInfo=" + stateInfo + + ", client=" + client + + ", server=" + server + + '}'; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MachineInfoVo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MachineInfoVo.java new file mode 100755 index 00000000..66428c14 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MachineInfoVo.java @@ -0,0 +1,123 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.vo; + +import java.util.ArrayList; +import java.util.List; + +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; + +/** + * @author leyou + */ +public class MachineInfoVo { + + private String app; + private String hostname; + private String ip; + private int port; + private long heartbeatVersion; + private long lastHeartbeat; + private boolean healthy; + + private String version; + + public static List fromMachineInfoList(List machines) { + List list = new ArrayList<>(); + for (MachineInfo machine : machines) { + list.add(fromMachineInfo(machine)); + } + return list; + } + + public static MachineInfoVo fromMachineInfo(MachineInfo machine) { + MachineInfoVo vo = new MachineInfoVo(); + vo.setApp(machine.getApp()); + vo.setHostname(machine.getHostname()); + vo.setIp(machine.getIp()); + vo.setPort(machine.getPort()); + vo.setLastHeartbeat(machine.getLastHeartbeat()); + vo.setHeartbeatVersion(machine.getHeartbeatVersion()); + vo.setVersion(machine.getVersion()); + vo.setHealthy(machine.isHealthy()); + return vo; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public String getHostname() { + return hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public long getLastHeartbeat() { + return lastHeartbeat; + } + + public void setLastHeartbeat(long lastHeartbeat) { + this.lastHeartbeat = lastHeartbeat; + } + + public void setHeartbeatVersion(long heartbeatVersion) { + this.heartbeatVersion = heartbeatVersion; + } + + public long getHeartbeatVersion() { + return heartbeatVersion; + } + + public String getVersion() { + return version; + } + + public MachineInfoVo setVersion(String version) { + this.version = version; + return this; + } + + public boolean isHealthy() { + return healthy; + } + + public void setHealthy(boolean healthy) { + this.healthy = healthy; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MetricVo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MetricVo.java new file mode 100755 index 00000000..af64941e --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MetricVo.java @@ -0,0 +1,208 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.vo; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.MetricEntity; + +/** + * @author leyou + */ +public class MetricVo implements Comparable { + private Long id; + private String app; + private Long timestamp; + private Long gmtCreate = System.currentTimeMillis(); + private String resource; + private Long passQps; + private Long blockQps; + private Long successQps; + private Long exceptionQps; + /** + * average rt + */ + private Double rt; + private Integer count; + + public MetricVo() { + } + + public static List fromMetricEntities(Collection entities) { + List list = new ArrayList<>(); + if (entities != null) { + for (MetricEntity entity : entities) { + list.add(fromMetricEntity(entity)); + } + } + return list; + } + + /** + * 保留资源名为identity的结果。 + * + * @param entities 通过hashCode查找到的MetricEntities + * @param identity 真正需要查找的资源名 + * @return + */ + public static List fromMetricEntities(Collection entities, String identity) { + List list = new ArrayList<>(); + if (entities != null) { + for (MetricEntity entity : entities) { + if (entity.getResource().equals(identity)) { + list.add(fromMetricEntity(entity)); + } + } + } + return list; + } + + public static MetricVo fromMetricEntity(MetricEntity entity) { + MetricVo vo = new MetricVo(); + vo.id = entity.getId(); + vo.app = entity.getApp(); + vo.timestamp = entity.getTimestamp().getTime(); + vo.gmtCreate = entity.getGmtCreate().getTime(); + vo.resource = entity.getResource(); + vo.passQps = entity.getPassQps(); + vo.blockQps = entity.getBlockQps(); + vo.successQps = entity.getSuccessQps(); + vo.exceptionQps = entity.getExceptionQps(); + if (entity.getSuccessQps() != 0) { + vo.rt = entity.getRt() / entity.getSuccessQps(); + } else { + vo.rt = 0D; + } + vo.count = entity.getCount(); + return vo; + } + + public static MetricVo parse(String line) { + String[] strs = line.split("\\|"); + long timestamp = Long.parseLong(strs[0]); + String identity = strs[1]; + long passQps = Long.parseLong(strs[2]); + long blockQps = Long.parseLong(strs[3]); + long exception = Long.parseLong(strs[4]); + double rt = Double.parseDouble(strs[5]); + long successQps = Long.parseLong(strs[6]); + MetricVo vo = new MetricVo(); + vo.timestamp = timestamp; + vo.resource = identity; + vo.passQps = passQps; + vo.blockQps = blockQps; + vo.successQps = successQps; + vo.exceptionQps = exception; + vo.rt = rt; + vo.count = 1; + return vo; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public Long getTimestamp() { + return timestamp; + } + + public void setTimestamp(Long timestamp) { + this.timestamp = timestamp; + } + + public Long getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Long gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public Long getPassQps() { + return passQps; + } + + public void setPassQps(Long passQps) { + this.passQps = passQps; + } + + public Long getBlockQps() { + return blockQps; + } + + public void setBlockQps(Long blockQps) { + this.blockQps = blockQps; + } + + public Long getSuccessQps() { + return successQps; + } + + public void setSuccessQps(Long successQps) { + this.successQps = successQps; + } + + public Long getExceptionQps() { + return exceptionQps; + } + + public void setExceptionQps(Long exceptionQps) { + this.exceptionQps = exceptionQps; + } + + public Double getRt() { + return rt; + } + + public void setRt(Double rt) { + this.rt = rt; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + @Override + public int compareTo(MetricVo o) { + return Long.compare(this.timestamp, o.timestamp); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/ResourceVo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/ResourceVo.java new file mode 100755 index 00000000..a8ffe24e --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/ResourceVo.java @@ -0,0 +1,236 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.vo; + +import java.util.ArrayList; +import java.util.List; + +import com.alibaba.csp.sentinel.command.vo.NodeVo; + +import com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode; + +/** + * @author leyou + */ +public class ResourceVo { + private String parentTtId; + private String ttId; + private String resource; + + private Integer threadNum; + private Long passQps; + private Long blockQps; + private Long totalQps; + private Long averageRt; + private Long passRequestQps; + private Long exceptionQps; + private Long oneMinutePass; + private Long oneMinuteBlock; + private Long oneMinuteException; + private Long oneMinuteTotal; + + private boolean visible = true; + + public ResourceVo() { + } + + public static List fromNodeVoList(List nodeVos) { + if (nodeVos == null) { + return null; + } + List list = new ArrayList<>(); + for (NodeVo nodeVo : nodeVos) { + ResourceVo vo = new ResourceVo(); + vo.parentTtId = nodeVo.getParentId(); + vo.ttId = nodeVo.getId(); + vo.resource = nodeVo.getResource(); + vo.threadNum = nodeVo.getThreadNum(); + vo.passQps = nodeVo.getPassQps(); + vo.blockQps = nodeVo.getBlockQps(); + vo.totalQps = nodeVo.getTotalQps(); + vo.averageRt = nodeVo.getAverageRt(); + vo.exceptionQps = nodeVo.getExceptionQps(); + vo.oneMinutePass = nodeVo.getOneMinutePass(); + vo.oneMinuteBlock = nodeVo.getOneMinuteBlock(); + vo.oneMinuteException = nodeVo.getOneMinuteException(); + vo.oneMinuteTotal = nodeVo.getOneMinuteTotal(); + list.add(vo); + } + return list; + } + + public static List fromResourceTreeNode(ResourceTreeNode root) { + if (root == null) { + return null; + } + List list = new ArrayList<>(); + visit(root, list, false, true); + //if(!list.isEmpty()){ + // list.remove(0); + //} + return list; + } + + /** + * This node is visible when this.visible==true or one of this's parents is visible, + * root node is always invisible. + */ + private static void visit(ResourceTreeNode node, List list, boolean parentVisible, boolean isRoot) { + boolean visible = !isRoot && (node.isVisible() || parentVisible); + //boolean visible = node.isVisible(); + if (visible) { + ResourceVo vo = new ResourceVo(); + vo.parentTtId = node.getParentId(); + vo.ttId = node.getId(); + vo.resource = node.getResource(); + vo.threadNum = node.getThreadNum(); + vo.passQps = node.getPassQps(); + vo.blockQps = node.getBlockQps(); + vo.totalQps = node.getTotalQps(); + vo.averageRt = node.getAverageRt(); + vo.exceptionQps = node.getExceptionQps(); + vo.oneMinutePass = node.getOneMinutePass(); + vo.oneMinuteBlock = node.getOneMinuteBlock(); + vo.oneMinuteException = node.getOneMinuteException(); + vo.oneMinuteTotal = node.getOneMinuteTotal(); + vo.visible = node.isVisible(); + list.add(vo); + } + for (ResourceTreeNode c : node.getChildren()) { + visit(c, list, visible, false); + } + } + + public String getParentTtId() { + return parentTtId; + } + + public void setParentTtId(String parentTtId) { + this.parentTtId = parentTtId; + } + + public String getTtId() { + return ttId; + } + + public void setTtId(String ttId) { + this.ttId = ttId; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public Integer getThreadNum() { + return threadNum; + } + + public void setThreadNum(Integer threadNum) { + this.threadNum = threadNum; + } + + public Long getPassQps() { + return passQps; + } + + public void setPassQps(Long passQps) { + this.passQps = passQps; + } + + public Long getBlockQps() { + return blockQps; + } + + public void setBlockQps(Long blockQps) { + this.blockQps = blockQps; + } + + public Long getTotalQps() { + return totalQps; + } + + public void setTotalQps(Long totalQps) { + this.totalQps = totalQps; + } + + public Long getAverageRt() { + return averageRt; + } + + public void setAverageRt(Long averageRt) { + this.averageRt = averageRt; + } + + public Long getPassRequestQps() { + return passRequestQps; + } + + public void setPassRequestQps(Long passRequestQps) { + this.passRequestQps = passRequestQps; + } + + public Long getExceptionQps() { + return exceptionQps; + } + + public void setExceptionQps(Long exceptionQps) { + this.exceptionQps = exceptionQps; + } + + public Long getOneMinuteException() { + return oneMinuteException; + } + + public void setOneMinuteException(Long oneMinuteException) { + this.oneMinuteException = oneMinuteException; + } + + public Long getOneMinutePass() { + return oneMinutePass; + } + + public void setOneMinutePass(Long oneMinutePass) { + this.oneMinutePass = oneMinutePass; + } + + public Long getOneMinuteBlock() { + return oneMinuteBlock; + } + + public void setOneMinuteBlock(Long oneMinuteBlock) { + this.oneMinuteBlock = oneMinuteBlock; + } + + public Long getOneMinuteTotal() { + return oneMinuteTotal; + } + + public void setOneMinuteTotal(Long oneMinuteTotal) { + this.oneMinuteTotal = oneMinuteTotal; + } + + public boolean isVisible() { + return visible; + } + + public void setVisible(boolean visible) { + this.visible = visible; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/api/AddApiReqVo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/api/AddApiReqVo.java new file mode 100755 index 00000000..445f445c --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/api/AddApiReqVo.java @@ -0,0 +1,78 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api; + +import java.util.List; + +/** + * Value Object for add gateway api. + * + * @author cdfive + * @since 1.7.0 + */ +public class AddApiReqVo { + + private String app; + + private String ip; + + private Integer port; + + private String apiName; + + private List predicateItems; + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public String getApiName() { + return apiName; + } + + public void setApiName(String apiName) { + this.apiName = apiName; + } + + public List getPredicateItems() { + return predicateItems; + } + + public void setPredicateItems(List predicateItems) { + this.predicateItems = predicateItems; + } +} + diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/api/ApiPredicateItemVo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/api/ApiPredicateItemVo.java new file mode 100755 index 00000000..d621ddf5 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/api/ApiPredicateItemVo.java @@ -0,0 +1,45 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api; + +/** + * Value Object for add or update gateway api. + * + * @author cdfive + * @since 1.7.0 + */ +public class ApiPredicateItemVo { + + private String pattern; + + private Integer matchStrategy; + + public String getPattern() { + return pattern; + } + + public void setPattern(String pattern) { + this.pattern = pattern; + } + + public Integer getMatchStrategy() { + return matchStrategy; + } + + public void setMatchStrategy(Integer matchStrategy) { + this.matchStrategy = matchStrategy; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/api/UpdateApiReqVo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/api/UpdateApiReqVo.java new file mode 100755 index 00000000..3dfd96a2 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/api/UpdateApiReqVo.java @@ -0,0 +1,57 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api; + +import java.util.List; + +/** + * Value Object for update gateway api. + * + * @author cdfive + * @since 1.7.0 + */ +public class UpdateApiReqVo { + + private Long id; + + private String app; + + private List predicateItems; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public List getPredicateItems() { + return predicateItems; + } + + public void setPredicateItems(List predicateItems) { + this.predicateItems = predicateItems; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/rule/AddFlowRuleReqVo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/rule/AddFlowRuleReqVo.java new file mode 100755 index 00000000..57cc9e2a --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/rule/AddFlowRuleReqVo.java @@ -0,0 +1,155 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.rule; + +/** + * Value Object for add gateway flow rule. + * + * @author cdfive + * @since 1.7.0 + */ +public class AddFlowRuleReqVo { + + private String app; + + private String ip; + + private Integer port; + + private String resource; + + private Integer resourceMode; + + private Integer grade; + + private Double count; + + private Long interval; + + private Integer intervalUnit; + + private Integer controlBehavior; + + private Integer burst; + + private Integer maxQueueingTimeoutMs; + + private GatewayParamFlowItemVo paramItem; + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public Integer getResourceMode() { + return resourceMode; + } + + public void setResourceMode(Integer resourceMode) { + this.resourceMode = resourceMode; + } + + public Integer getGrade() { + return grade; + } + + public void setGrade(Integer grade) { + this.grade = grade; + } + + public Double getCount() { + return count; + } + + public void setCount(Double count) { + this.count = count; + } + + public Long getInterval() { + return interval; + } + + public void setInterval(Long interval) { + this.interval = interval; + } + + public Integer getIntervalUnit() { + return intervalUnit; + } + + public void setIntervalUnit(Integer intervalUnit) { + this.intervalUnit = intervalUnit; + } + + public Integer getControlBehavior() { + return controlBehavior; + } + + public void setControlBehavior(Integer controlBehavior) { + this.controlBehavior = controlBehavior; + } + + public Integer getBurst() { + return burst; + } + + public void setBurst(Integer burst) { + this.burst = burst; + } + + public Integer getMaxQueueingTimeoutMs() { + return maxQueueingTimeoutMs; + } + + public void setMaxQueueingTimeoutMs(Integer maxQueueingTimeoutMs) { + this.maxQueueingTimeoutMs = maxQueueingTimeoutMs; + } + + public GatewayParamFlowItemVo getParamItem() { + return paramItem; + } + + public void setParamItem(GatewayParamFlowItemVo paramItem) { + this.paramItem = paramItem; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/rule/GatewayParamFlowItemVo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/rule/GatewayParamFlowItemVo.java new file mode 100755 index 00000000..af24fed9 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/rule/GatewayParamFlowItemVo.java @@ -0,0 +1,65 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.rule; + +/** + * Value Object for add or update gateway flow rule. + * + * @author cdfive + * @since 1.7.0 + */ +public class GatewayParamFlowItemVo { + + private Integer parseStrategy; + + private String fieldName; + + private String pattern; + + private Integer matchStrategy; + + public Integer getParseStrategy() { + return parseStrategy; + } + + public void setParseStrategy(Integer parseStrategy) { + this.parseStrategy = parseStrategy; + } + + public String getFieldName() { + return fieldName; + } + + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + + public String getPattern() { + return pattern; + } + + public void setPattern(String pattern) { + this.pattern = pattern; + } + + public Integer getMatchStrategy() { + return matchStrategy; + } + + public void setMatchStrategy(Integer matchStrategy) { + this.matchStrategy = matchStrategy; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/rule/UpdateFlowRuleReqVo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/rule/UpdateFlowRuleReqVo.java new file mode 100755 index 00000000..8d1988fe --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/rule/UpdateFlowRuleReqVo.java @@ -0,0 +1,125 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.rule; + +/** + * Value Object for update gateway flow rule. + * + * @author cdfive + * @since 1.7.0 + */ +public class UpdateFlowRuleReqVo { + + private Long id; + + private String app; + + private Integer grade; + + private Double count; + + private Long interval; + + private Integer intervalUnit; + + private Integer controlBehavior; + + private Integer burst; + + private Integer maxQueueingTimeoutMs; + + private GatewayParamFlowItemVo paramItem; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public Integer getGrade() { + return grade; + } + + public void setGrade(Integer grade) { + this.grade = grade; + } + + public Double getCount() { + return count; + } + + public void setCount(Double count) { + this.count = count; + } + + public Long getInterval() { + return interval; + } + + public void setInterval(Long interval) { + this.interval = interval; + } + + public Integer getIntervalUnit() { + return intervalUnit; + } + + public void setIntervalUnit(Integer intervalUnit) { + this.intervalUnit = intervalUnit; + } + + public Integer getControlBehavior() { + return controlBehavior; + } + + public void setControlBehavior(Integer controlBehavior) { + this.controlBehavior = controlBehavior; + } + + public Integer getBurst() { + return burst; + } + + public void setBurst(Integer burst) { + this.burst = burst; + } + + public Integer getMaxQueueingTimeoutMs() { + return maxQueueingTimeoutMs; + } + + public void setMaxQueueingTimeoutMs(Integer maxQueueingTimeoutMs) { + this.maxQueueingTimeoutMs = maxQueueingTimeoutMs; + } + + public GatewayParamFlowItemVo getParamItem() { + return paramItem; + } + + public void setParamItem(GatewayParamFlowItemVo paramItem) { + this.paramItem = paramItem; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java new file mode 100755 index 00000000..2c032249 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java @@ -0,0 +1,376 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.metric; + +import java.net.ConnectException; +import java.net.SocketTimeoutException; +import java.nio.charset.Charset; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.RejectedExecutionHandler; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.ThreadPoolExecutor.DiscardPolicy; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; + +import com.alibaba.csp.sentinel.Constants; +import com.alibaba.csp.sentinel.concurrent.NamedThreadFactory; +import com.alibaba.csp.sentinel.config.SentinelConfig; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.MetricEntity; +import com.alibaba.csp.sentinel.dashboard.discovery.AppInfo; +import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.node.metric.MetricNode; +import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.repository.metric.MetricsRepository; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.concurrent.FutureCallback; +import org.apache.http.entity.ContentType; +import org.apache.http.impl.client.DefaultRedirectStrategy; +import org.apache.http.impl.nio.client.CloseableHttpAsyncClient; +import org.apache.http.impl.nio.client.HttpAsyncClients; +import org.apache.http.impl.nio.reactor.IOReactorConfig; +import org.apache.http.protocol.HTTP; +import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * Fetch metric of machines. + * + * @author leyou + */ +@Component +public class MetricFetcher { + + public static final String NO_METRICS = "No metrics"; + private static final int HTTP_OK = 200; + private static final long MAX_LAST_FETCH_INTERVAL_MS = 1000 * 15; + private static final long FETCH_INTERVAL_SECOND = 6; + private static final Charset DEFAULT_CHARSET = Charset.forName(SentinelConfig.charset()); + private final static String METRIC_URL_PATH = "metric"; + private static Logger logger = LoggerFactory.getLogger(MetricFetcher.class); + private final long intervalSecond = 1; + + private Map appLastFetchTime = new ConcurrentHashMap<>(); + + @Autowired + private MetricsRepository metricStore; + @Autowired + private AppManagement appManagement; + + private CloseableHttpAsyncClient httpclient; + + @SuppressWarnings("PMD.ThreadPoolCreationRule") + private ScheduledExecutorService fetchScheduleService = Executors.newScheduledThreadPool(1, + new NamedThreadFactory("sentinel-dashboard-metrics-fetch-task")); + private ExecutorService fetchService; + private ExecutorService fetchWorker; + + public MetricFetcher() { + int cores = Runtime.getRuntime().availableProcessors() * 2; + long keepAliveTime = 0; + int queueSize = 2048; + RejectedExecutionHandler handler = new DiscardPolicy(); + fetchService = new ThreadPoolExecutor(cores, cores, + keepAliveTime, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(queueSize), + new NamedThreadFactory("sentinel-dashboard-metrics-fetchService"), handler); + fetchWorker = new ThreadPoolExecutor(cores, cores, + keepAliveTime, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(queueSize), + new NamedThreadFactory("sentinel-dashboard-metrics-fetchWorker"), handler); + IOReactorConfig ioConfig = IOReactorConfig.custom() + .setConnectTimeout(3000) + .setSoTimeout(3000) + .setIoThreadCount(Runtime.getRuntime().availableProcessors() * 2) + .build(); + + httpclient = HttpAsyncClients.custom() + .setRedirectStrategy(new DefaultRedirectStrategy() { + @Override + protected boolean isRedirectable(final String method) { + return false; + } + }).setMaxConnTotal(4000) + .setMaxConnPerRoute(1000) + .setDefaultIOReactorConfig(ioConfig) + .build(); + httpclient.start(); + start(); + } + + private void start() { + fetchScheduleService.scheduleAtFixedRate(() -> { + try { + fetchAllApp(); + } catch (Exception e) { + logger.info("fetchAllApp error:", e); + } + }, 10, intervalSecond, TimeUnit.SECONDS); + } + + private void writeMetric(Map map) { + if (map.isEmpty()) { + return; + } + Date date = new Date(); + for (MetricEntity entity : map.values()) { + entity.setGmtCreate(date); + entity.setGmtModified(date); + } + metricStore.saveAll(map.values()); + } + + /** + * Traverse each APP, and then pull the metric of all machines for that APP. + */ + private void fetchAllApp() { + List apps = appManagement.getAppNames(); + if (apps == null) { + return; + } + for (final String app : apps) { + fetchService.submit(() -> { + try { + doFetchAppMetric(app); + } catch (Exception e) { + logger.error("fetchAppMetric error", e); + } + }); + } + } + + /** + * fetch metric between [startTime, endTime], both side inclusive + */ + private void fetchOnce(String app, long startTime, long endTime, int maxWaitSeconds) { + if (maxWaitSeconds <= 0) { + throw new IllegalArgumentException("maxWaitSeconds must > 0, but " + maxWaitSeconds); + } + AppInfo appInfo = appManagement.getDetailApp(app); + // auto remove for app + if (appInfo.isDead()) { + logger.info("Dead app removed: {}", app); + appManagement.removeApp(app); + return; + } + Set machines = appInfo.getMachines(); + logger.debug("enter fetchOnce(" + app + "), machines.size()=" + machines.size() + + ", time intervalMs [" + startTime + ", " + endTime + "]"); + if (machines.isEmpty()) { + return; + } + final String msg = "fetch"; + AtomicLong unhealthy = new AtomicLong(); + final AtomicLong success = new AtomicLong(); + final AtomicLong fail = new AtomicLong(); + + long start = System.currentTimeMillis(); + /** app_resource_timeSecond -> metric */ + final Map metricMap = new ConcurrentHashMap<>(16); + final CountDownLatch latch = new CountDownLatch(machines.size()); + for (final MachineInfo machine : machines) { + // auto remove + if (machine.isDead()) { + latch.countDown(); + appManagement.getDetailApp(app).removeMachine(machine.getIp(), machine.getPort()); + logger.info("Dead machine removed: {}:{} of {}", machine.getIp(), machine.getPort(), app); + continue; + } + if (!machine.isHealthy()) { + latch.countDown(); + unhealthy.incrementAndGet(); + continue; + } + final String url = "http://" + machine.getIp() + ":" + machine.getPort() + "/" + METRIC_URL_PATH + + "?startTime=" + startTime + "&endTime=" + endTime + "&refetch=" + false; + final HttpGet httpGet = new HttpGet(url); + httpGet.setHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE); + httpclient.execute(httpGet, new FutureCallback() { + @Override + public void completed(final HttpResponse response) { + try { + handleResponse(response, machine, metricMap); + success.incrementAndGet(); + } catch (Exception e) { + logger.error(msg + " metric " + url + " error:", e); + } finally { + latch.countDown(); + } + } + + @Override + public void failed(final Exception ex) { + latch.countDown(); + fail.incrementAndGet(); + httpGet.abort(); + if (ex instanceof SocketTimeoutException) { + logger.error("Failed to fetch metric from <{}>: socket timeout", url); + } else if (ex instanceof ConnectException) { + logger.error("Failed to fetch metric from <{}> (ConnectionException: {})", url, ex.getMessage()); + } else { + logger.error(msg + " metric " + url + " error", ex); + } + } + + @Override + public void cancelled() { + latch.countDown(); + fail.incrementAndGet(); + httpGet.abort(); + } + }); + } + try { + latch.await(maxWaitSeconds, TimeUnit.SECONDS); + } catch (Exception e) { + logger.info(msg + " metric, wait http client error:", e); + } + long cost = System.currentTimeMillis() - start; + //logger.info("finished " + msg + " metric for " + app + ", time intervalMs [" + startTime + ", " + endTime + // + "], total machines=" + machines.size() + ", dead=" + dead + ", fetch success=" + // + success + ", fetch fail=" + fail + ", time cost=" + cost + " ms"); + writeMetric(metricMap); + } + + private void doFetchAppMetric(final String app) { + long now = System.currentTimeMillis(); + long lastFetchMs = now - MAX_LAST_FETCH_INTERVAL_MS; + if (appLastFetchTime.containsKey(app)) { + lastFetchMs = Math.max(lastFetchMs, appLastFetchTime.get(app).get() + 1000); + } + // trim milliseconds + lastFetchMs = lastFetchMs / 1000 * 1000; + long endTime = lastFetchMs + FETCH_INTERVAL_SECOND * 1000; + if (endTime > now - 1000 * 2) { + // to near + return; + } + // update last_fetch in advance. + appLastFetchTime.computeIfAbsent(app, a -> new AtomicLong()).set(endTime); + final long finalLastFetchMs = lastFetchMs; + final long finalEndTime = endTime; + try { + // do real fetch async + fetchWorker.submit(() -> { + try { + fetchOnce(app, finalLastFetchMs, finalEndTime, 5); + } catch (Exception e) { + logger.info("fetchOnce(" + app + ") error", e); + } + }); + } catch (Exception e) { + logger.info("submit fetchOnce(" + app + ") fail, intervalMs [" + lastFetchMs + ", " + endTime + "]", e); + } + } + + private void handleResponse(final HttpResponse response, MachineInfo machine, + Map metricMap) throws Exception { + int code = response.getStatusLine().getStatusCode(); + if (code != HTTP_OK) { + return; + } + Charset charset = null; + try { + String contentTypeStr = response.getFirstHeader("Content-type").getValue(); + if (StringUtil.isNotEmpty(contentTypeStr)) { + ContentType contentType = ContentType.parse(contentTypeStr); + charset = contentType.getCharset(); + } + } catch (Exception ignore) { + } + String body = EntityUtils.toString(response.getEntity(), charset != null ? charset : DEFAULT_CHARSET); + if (StringUtil.isEmpty(body) || body.startsWith(NO_METRICS)) { + //logger.info(machine.getApp() + ":" + machine.getIp() + ":" + machine.getPort() + ", bodyStr is empty"); + return; + } + String[] lines = body.split("\n"); + //logger.info(machine.getApp() + ":" + machine.getIp() + ":" + machine.getPort() + + // ", bodyStr.length()=" + body.length() + ", lines=" + lines.length); + handleBody(lines, machine, metricMap); + } + + private void handleBody(String[] lines, MachineInfo machine, Map map) { + //logger.info("handleBody() lines=" + lines.length + ", machine=" + machine); + if (lines.length < 1) { + return; + } + + for (String line : lines) { + try { + MetricNode node = MetricNode.fromThinString(line); + if (shouldFilterOut(node.getResource())) { + continue; + } + /* + * aggregation metrics by app_resource_timeSecond, ignore ip and port. + */ + String key = buildMetricKey(machine.getApp(), node.getResource(), node.getTimestamp()); + MetricEntity entity = map.get(key); + if (entity != null) { + entity.addPassQps(node.getPassQps()); + entity.addBlockQps(node.getBlockQps()); + entity.addRtAndSuccessQps(node.getRt(), node.getSuccessQps()); + entity.addExceptionQps(node.getExceptionQps()); + entity.addCount(1); + } else { + entity = new MetricEntity(); + entity.setApp(machine.getApp()); + entity.setTimestamp(new Date(node.getTimestamp())); + entity.setPassQps(node.getPassQps()); + entity.setBlockQps(node.getBlockQps()); + entity.setRtAndSuccessQps(node.getRt(), node.getSuccessQps()); + entity.setExceptionQps(node.getExceptionQps()); + entity.setCount(1); + entity.setResource(node.getResource()); + map.put(key, entity); + } + } catch (Exception e) { + logger.warn("handleBody line exception, machine: {}, line: {}", machine.toLogString(), line); + } + } + } + + private String buildMetricKey(String app, String resource, long timestamp) { + return app + "__" + resource + "__" + (timestamp / 1000); + } + + private boolean shouldFilterOut(String resource) { + return RES_EXCLUSION_SET.contains(resource); + } + + private static final Set RES_EXCLUSION_SET = new HashSet() {{ + add(Constants.TOTAL_IN_RESOURCE_NAME); + add(Constants.SYSTEM_LOAD_RESOURCE_NAME); + add(Constants.CPU_USAGE_RESOURCE_NAME); + }}; + +} + + + diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/gateway/InMemApiDefinitionStore.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/gateway/InMemApiDefinitionStore.java new file mode 100755 index 00000000..844acbd5 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/gateway/InMemApiDefinitionStore.java @@ -0,0 +1,39 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.repository.gateway; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity; +import com.alibaba.csp.sentinel.dashboard.repository.rule.InMemoryRuleRepositoryAdapter; +import org.springframework.stereotype.Component; + +import java.util.concurrent.atomic.AtomicLong; + +/** + * Store {@link ApiDefinitionEntity} in memory. + * + * @author cdfive + * @since 1.7.0 + */ +@Component +public class InMemApiDefinitionStore extends InMemoryRuleRepositoryAdapter { + + private static AtomicLong ids = new AtomicLong(0); + + @Override + protected long nextId() { + return ids.incrementAndGet(); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/gateway/InMemGatewayFlowRuleStore.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/gateway/InMemGatewayFlowRuleStore.java new file mode 100755 index 00000000..f1b63c42 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/gateway/InMemGatewayFlowRuleStore.java @@ -0,0 +1,39 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.repository.gateway; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayFlowRuleEntity; +import com.alibaba.csp.sentinel.dashboard.repository.rule.InMemoryRuleRepositoryAdapter; +import org.springframework.stereotype.Component; + +import java.util.concurrent.atomic.AtomicLong; + +/** + * Store {@link GatewayFlowRuleEntity} in memory. + * + * @author cdfive + * @since 1.7.0 + */ +@Component +public class InMemGatewayFlowRuleStore extends InMemoryRuleRepositoryAdapter { + + private static AtomicLong ids = new AtomicLong(0); + + @Override + protected long nextId() { + return ids.incrementAndGet(); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java new file mode 100755 index 00000000..bed4ea1c --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java @@ -0,0 +1,144 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.repository.metric; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.MetricEntity; +import com.alibaba.csp.sentinel.util.StringUtil; + +import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap; +import org.springframework.stereotype.Component; + +/** + * Caches metrics data in a period of time in memory. + * + * @author Carpenter Lee + * @author Eric Zhao + */ +@Component +public class InMemoryMetricsRepository implements MetricsRepository { + + private static final long MAX_METRIC_LIVE_TIME_MS = 1000 * 60 * 5; + + /** + * {@code app -> resource -> timestamp -> metric} + */ + private Map>> allMetrics = new ConcurrentHashMap<>(); + + + + @Override + public synchronized void save(MetricEntity entity) { + if (entity == null || StringUtil.isBlank(entity.getApp())) { + return; + } + allMetrics.computeIfAbsent(entity.getApp(), e -> new ConcurrentHashMap<>(16)) + .computeIfAbsent(entity.getResource(), e -> new ConcurrentLinkedHashMap.Builder() + .maximumWeightedCapacity(MAX_METRIC_LIVE_TIME_MS).weigher((key, value) -> { + // Metric older than {@link #MAX_METRIC_LIVE_TIME_MS} will be removed. + int weight = (int)(System.currentTimeMillis() - key); + // weight must be a number greater than or equal to one + return Math.max(weight, 1); + }).build()).put(entity.getTimestamp().getTime(), entity); + } + + @Override + public synchronized void saveAll(Iterable metrics) { + if (metrics == null) { + return; + } + metrics.forEach(this::save); + } + + @Override + public synchronized List queryByAppAndResourceBetween(String app, String resource, + long startTime, long endTime) { + List results = new ArrayList<>(); + if (StringUtil.isBlank(app)) { + return results; + } + Map> resourceMap = allMetrics.get(app); + if (resourceMap == null) { + return results; + } + ConcurrentLinkedHashMap metricsMap = resourceMap.get(resource); + if (metricsMap == null) { + return results; + } + for (Entry entry : metricsMap.entrySet()) { + if (entry.getKey() >= startTime && entry.getKey() <= endTime) { + results.add(entry.getValue()); + } + } + return results; + } + + @Override + public List listResourcesOfApp(String app) { + List results = new ArrayList<>(); + if (StringUtil.isBlank(app)) { + return results; + } + // resource -> timestamp -> metric + Map> resourceMap = allMetrics.get(app); + if (resourceMap == null) { + return results; + } + final long minTimeMs = System.currentTimeMillis() - 1000 * 60; + Map resourceCount = new ConcurrentHashMap<>(32); + + for (Entry> resourceMetrics : resourceMap.entrySet()) { + for (Entry metrics : resourceMetrics.getValue().entrySet()) { + if (metrics.getKey() < minTimeMs) { + continue; + } + MetricEntity newEntity = metrics.getValue(); + if (resourceCount.containsKey(resourceMetrics.getKey())) { + MetricEntity oldEntity = resourceCount.get(resourceMetrics.getKey()); + oldEntity.addPassQps(newEntity.getPassQps()); + oldEntity.addRtAndSuccessQps(newEntity.getRt(), newEntity.getSuccessQps()); + oldEntity.addBlockQps(newEntity.getBlockQps()); + oldEntity.addExceptionQps(newEntity.getExceptionQps()); + oldEntity.addCount(1); + } else { + resourceCount.put(resourceMetrics.getKey(), MetricEntity.copyOf(newEntity)); + } + } + } + // Order by last minute b_qps DESC. + return resourceCount.entrySet() + .stream() + .sorted((o1, o2) -> { + MetricEntity e1 = o1.getValue(); + MetricEntity e2 = o2.getValue(); + int t = e2.getBlockQps().compareTo(e1.getBlockQps()); + if (t != 0) { + return t; + } + return e2.getPassQps().compareTo(e1.getPassQps()); + }) + .map(Entry::getKey) + .collect(Collectors.toList()); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/metric/MetricsRepository.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/metric/MetricsRepository.java new file mode 100755 index 00000000..f54cc209 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/metric/MetricsRepository.java @@ -0,0 +1,60 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.repository.metric; + +import java.util.List; + +/** + * Repository interface for aggregated metrics data. + * + * @param type of metrics + * @author Eric Zhao + */ +public interface MetricsRepository { + + /** + * Save the metric to the storage repository. + * + * @param metric metric data to save + */ + void save(T metric); + + /** + * Save all metrics to the storage repository. + * + * @param metrics metrics to save + */ + void saveAll(Iterable metrics); + + /** + * Get all metrics by {@code appName} and {@code resourceName} between a period of time. + * + * @param app application name for Sentinel + * @param resource resource name + * @param startTime start timestamp + * @param endTime end timestamp + * @return all metrics in query conditions + */ + List queryByAppAndResourceBetween(String app, String resource, long startTime, long endTime); + + /** + * List resource name of provided application name. + * + * @param app application name + * @return list of resources + */ + List listResourcesOfApp(String app); +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemAuthorityRuleStore.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemAuthorityRuleStore.java new file mode 100755 index 00000000..bbeb8889 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemAuthorityRuleStore.java @@ -0,0 +1,39 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.repository.rule; + +import java.util.concurrent.atomic.AtomicLong; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AuthorityRuleEntity; + +import org.springframework.stereotype.Component; + +/** + * In-memory storage for authority rules. + * + * @author Eric Zhao + * @since 0.2.1 + */ +@Component +public class InMemAuthorityRuleStore extends InMemoryRuleRepositoryAdapter { + + private static AtomicLong ids = new AtomicLong(0); + + @Override + protected long nextId() { + return ids.incrementAndGet(); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemDegradeRuleStore.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemDegradeRuleStore.java new file mode 100755 index 00000000..0b9bf7e1 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemDegradeRuleStore.java @@ -0,0 +1,36 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.repository.rule; + +import java.util.concurrent.atomic.AtomicLong; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.DegradeRuleEntity; + +import org.springframework.stereotype.Component; + +/** + * @author leyou + */ +@Component +public class InMemDegradeRuleStore extends InMemoryRuleRepositoryAdapter { + + private static AtomicLong ids = new AtomicLong(0); + + @Override + protected long nextId() { + return ids.incrementAndGet(); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemFlowRuleStore.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemFlowRuleStore.java new file mode 100755 index 00000000..c5a2a347 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemFlowRuleStore.java @@ -0,0 +1,53 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.repository.rule; + +import java.util.concurrent.atomic.AtomicLong; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; +import com.alibaba.csp.sentinel.slots.block.flow.ClusterFlowConfig; + +import org.springframework.stereotype.Component; + +/** + * Store {@link FlowRuleEntity} in memory. + * + * @author leyou + */ +@Component +public class InMemFlowRuleStore extends InMemoryRuleRepositoryAdapter { + + private static AtomicLong ids = new AtomicLong(0); + + @Override + protected long nextId() { + return ids.incrementAndGet(); + } + + @Override + protected FlowRuleEntity preProcess(FlowRuleEntity entity) { + if (entity != null && entity.isClusterMode()) { + ClusterFlowConfig config = entity.getClusterConfig(); + if (config == null) { + config = new ClusterFlowConfig(); + entity.setClusterConfig(config); + } + // Set cluster rule id. + config.setFlowId(entity.getId()); + } + return entity; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemParamFlowRuleStore.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemParamFlowRuleStore.java new file mode 100755 index 00000000..5a82f138 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemParamFlowRuleStore.java @@ -0,0 +1,51 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.repository.rule; + +import java.util.concurrent.atomic.AtomicLong; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.ParamFlowRuleEntity; +import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowClusterConfig; + +import org.springframework.stereotype.Component; + +/** + * @author Eric Zhao + * @since 0.2.1 + */ +@Component +public class InMemParamFlowRuleStore extends InMemoryRuleRepositoryAdapter { + + private static AtomicLong ids = new AtomicLong(0); + + @Override + protected long nextId() { + return ids.incrementAndGet(); + } + + @Override + protected ParamFlowRuleEntity preProcess(ParamFlowRuleEntity entity) { + if (entity != null && entity.isClusterMode()) { + ParamFlowClusterConfig config = entity.getClusterConfig(); + if (config == null) { + config = new ParamFlowClusterConfig(); + } + // Set cluster rule id. + config.setFlowId(entity.getId()); + } + return entity; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemSystemRuleStore.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemSystemRuleStore.java new file mode 100755 index 00000000..8d3949b4 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemSystemRuleStore.java @@ -0,0 +1,36 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.repository.rule; + +import java.util.concurrent.atomic.AtomicLong; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.SystemRuleEntity; + +import org.springframework.stereotype.Component; + +/** + * @author leyou + */ +@Component +public class InMemSystemRuleStore extends InMemoryRuleRepositoryAdapter { + + private static AtomicLong ids = new AtomicLong(0); + + @Override + protected long nextId() { + return ids.incrementAndGet(); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemoryRuleRepositoryAdapter.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemoryRuleRepositoryAdapter.java new file mode 100755 index 00000000..08d623cc --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemoryRuleRepositoryAdapter.java @@ -0,0 +1,129 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.repository.rule; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.RuleEntity; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.util.AssertUtil; + +/** + * @author leyou + */ +public abstract class InMemoryRuleRepositoryAdapter implements RuleRepository { + + /** + * {@code >} + */ + private Map> machineRules = new ConcurrentHashMap<>(16); + private Map allRules = new ConcurrentHashMap<>(16); + + private Map> appRules = new ConcurrentHashMap<>(16); + + private static final int MAX_RULES_SIZE = 10000; + + @Override + public T save(T entity) { + if (entity.getId() == null) { + entity.setId(nextId()); + } + T processedEntity = preProcess(entity); + if (processedEntity != null) { + allRules.put(processedEntity.getId(), processedEntity); + machineRules.computeIfAbsent(MachineInfo.of(processedEntity.getApp(), processedEntity.getIp(), + processedEntity.getPort()), e -> new ConcurrentHashMap<>(32)) + .put(processedEntity.getId(), processedEntity); + appRules.computeIfAbsent(processedEntity.getApp(), v -> new ConcurrentHashMap<>(32)) + .put(processedEntity.getId(), processedEntity); + } + + return processedEntity; + } + + @Override + public List saveAll(List rules) { + // TODO: check here. + allRules.clear(); + machineRules.clear(); + appRules.clear(); + + if (rules == null) { + return null; + } + List savedRules = new ArrayList<>(rules.size()); + for (T rule : rules) { + savedRules.add(save(rule)); + } + return savedRules; + } + + @Override + public T delete(Long id) { + T entity = allRules.remove(id); + if (entity != null) { + if (appRules.get(entity.getApp()) != null) { + appRules.get(entity.getApp()).remove(id); + } + machineRules.get(MachineInfo.of(entity.getApp(), entity.getIp(), entity.getPort())).remove(id); + } + return entity; + } + + @Override + public T findById(Long id) { + return allRules.get(id); + } + + @Override + public List findAllByMachine(MachineInfo machineInfo) { + Map entities = machineRules.get(machineInfo); + if (entities == null) { + return new ArrayList<>(); + } + return new ArrayList<>(entities.values()); + } + + @Override + public List findAllByApp(String appName) { + AssertUtil.notEmpty(appName, "appName cannot be empty"); + Map entities = appRules.get(appName); + if (entities == null) { + return new ArrayList<>(); + } + return new ArrayList<>(entities.values()); + } + + public void clearAll() { + allRules.clear(); + machineRules.clear(); + appRules.clear(); + } + + protected T preProcess(T entity) { + return entity; + } + + /** + * Get next unused id. + * + * @return next unused id + */ + abstract protected long nextId(); +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/RuleRepository.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/RuleRepository.java new file mode 100755 index 00000000..266c2fab --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/RuleRepository.java @@ -0,0 +1,85 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.repository.rule; + +import java.util.List; + +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; + +/** + * Interface to store and find rules. + * + * @author leyou + */ +public interface RuleRepository { + + /** + * Save one. + * + * @param entity + * @return + */ + T save(T entity); + + /** + * Save all. + * + * @param rules + * @return rules saved. + */ + List saveAll(List rules); + + /** + * Delete by id + * + * @param id + * @return entity deleted + */ + T delete(ID id); + + /** + * Find by id. + * + * @param id + * @return + */ + T findById(ID id); + + /** + * Find all by machine. + * + * @param machineInfo + * @return + */ + List findAllByMachine(MachineInfo machineInfo); + + /** + * Find all by application. + * + * @param appName valid app name + * @return all rules of the application + * @since 1.4.0 + */ + List findAllByApp(String appName); + + ///** + // * Find all by app and enable switch. + // * @param app + // * @param enable + // * @return + // */ + //List findAllByAppAndEnable(String app, boolean enable); +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/DynamicRuleProvider.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/DynamicRuleProvider.java new file mode 100755 index 00000000..7ee38ad1 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/DynamicRuleProvider.java @@ -0,0 +1,25 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.rule; + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +public interface DynamicRuleProvider { + + T getRules(String appName) throws Exception; +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/DynamicRulePublisher.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/DynamicRulePublisher.java new file mode 100755 index 00000000..940d76af --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/DynamicRulePublisher.java @@ -0,0 +1,32 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.rule; + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +public interface DynamicRulePublisher { + + /** + * Publish rules to remote rule configuration center for given application name. + * + * @param app app name + * @param rules list of rules to push + * @throws Exception if some error occurs + */ + void publish(String app, T rules) throws Exception; +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiProvider.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiProvider.java new file mode 100755 index 00000000..9f9ce5cc --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiProvider.java @@ -0,0 +1,59 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.rule; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @author Eric Zhao + */ +@Component("flowRuleDefaultProvider") +public class FlowRuleApiProvider implements DynamicRuleProvider> { + + @Autowired + private SentinelApiClient sentinelApiClient; + @Autowired + private AppManagement appManagement; + + @Override + public List getRules(String appName) throws Exception { + if (StringUtil.isBlank(appName)) { + return new ArrayList<>(); + } + List list = appManagement.getDetailApp(appName).getMachines() + .stream() + .filter(MachineInfo::isHealthy) + .sorted((e1, e2) -> Long.compare(e2.getLastHeartbeat(), e1.getLastHeartbeat())).collect(Collectors.toList()); + if (list.isEmpty()) { + return new ArrayList<>(); + } else { + MachineInfo machine = list.get(0); + return sentinelApiClient.fetchFlowRuleOfMachine(machine.getApp(), machine.getIp(), machine.getPort()); + } + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiPublisher.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiPublisher.java new file mode 100755 index 00000000..9afbcf34 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiPublisher.java @@ -0,0 +1,60 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.rule; + +import java.util.List; +import java.util.Set; + +import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +@Component("flowRuleDefaultPublisher") +public class FlowRuleApiPublisher implements DynamicRulePublisher> { + + @Autowired + private SentinelApiClient sentinelApiClient; + @Autowired + private AppManagement appManagement; + + @Override + public void publish(String app, List rules) throws Exception { + if (StringUtil.isBlank(app)) { + return; + } + if (rules == null) { + return; + } + Set set = appManagement.getDetailApp(app).getMachines(); + + for (MachineInfo machine : set) { + if (!machine.isHealthy()) { + continue; + } + // TODO: parse the results + sentinelApiClient.setFlowRuleOfMachine(app, machine.getIp(), machine.getPort(), rules); + } + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignService.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignService.java new file mode 100755 index 00000000..79a796ed --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignService.java @@ -0,0 +1,58 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.service; + +import java.util.List; +import java.util.Set; + +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterAppAssignMap; + +/** + * @author Eric Zhao + * @since 1.4.1 + */ +public interface ClusterAssignService { + + /** + * Unbind a specific cluster server and its clients. + * + * @param app app name + * @param machineId valid machine ID ({@code host@commandPort}) + * @return assign result + */ + ClusterAppAssignResultVO unbindClusterServer(String app, String machineId); + + /** + * Unbind a set of cluster servers and its clients. + * + * @param app app name + * @param machineIdSet set of valid machine ID ({@code host@commandPort}) + * @return assign result + */ + ClusterAppAssignResultVO unbindClusterServers(String app, Set machineIdSet); + + /** + * Apply cluster server and client assignment for provided app. + * + * @param app app name + * @param clusterMap cluster assign map (server -> clients) + * @param remainingSet unassigned set of machine ID + * @return assign result + */ + ClusterAppAssignResultVO applyAssignToApp(String app, List clusterMap, + Set remainingSet); +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignServiceImpl.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignServiceImpl.java new file mode 100755 index 00000000..494e7afd --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignServiceImpl.java @@ -0,0 +1,270 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.service; + +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import com.alibaba.csp.sentinel.cluster.ClusterStateManager; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStatePairVO; +import com.alibaba.csp.sentinel.util.AssertUtil; +import com.alibaba.csp.sentinel.util.function.Tuple2; + +import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterGroupEntity; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ClusterClientConfig; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerFlowConfig; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerTransportConfig; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterAppAssignMap; +import com.alibaba.csp.sentinel.dashboard.util.MachineUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author Eric Zhao + * @since 1.4.1 + */ +@Service +public class ClusterAssignServiceImpl implements ClusterAssignService { + + private final Logger LOGGER = LoggerFactory.getLogger(ClusterAssignServiceImpl.class); + + @Autowired + private SentinelApiClient sentinelApiClient; + @Autowired + private ClusterConfigService clusterConfigService; + + private boolean isMachineInApp(/*@NonEmpty*/ String machineId) { + return machineId.contains(":"); + } + + private ClusterAppAssignResultVO handleUnbindClusterServerNotInApp(String app, String machineId) { + Set failedSet = new HashSet<>(); + try { + List list = clusterConfigService.getClusterUniversalState(app) + .get(10, TimeUnit.SECONDS); + Set toModifySet = list.stream() + .filter(e -> e.getState().getStateInfo().getMode() == ClusterStateManager.CLUSTER_CLIENT) + .filter(e -> machineId.equals(e.getState().getClient().getClientConfig().getServerHost() + ':' + + e.getState().getClient().getClientConfig().getServerPort())) + .map(e -> e.getIp() + '@' + e.getCommandPort()) + .collect(Collectors.toSet()); + // Modify mode to NOT-STARTED for all associated token clients. + modifyToNonStarted(toModifySet, failedSet); + } catch (Exception ex) { + Throwable e = ex instanceof ExecutionException ? ex.getCause() : ex; + LOGGER.error("Failed to unbind machine <{}>", machineId, e); + failedSet.add(machineId); + } + return new ClusterAppAssignResultVO() + .setFailedClientSet(failedSet) + .setFailedServerSet(new HashSet<>()); + } + + private void modifyToNonStarted(Set toModifySet, Set failedSet) { + toModifySet.parallelStream() + .map(MachineUtils::parseCommandIpAndPort) + .filter(Optional::isPresent) + .map(Optional::get) + .map(e -> { + CompletableFuture f = modifyMode(e.r1, e.r2, ClusterStateManager.CLUSTER_NOT_STARTED); + return Tuple2.of(e.r1 + '@' + e.r2, f); + }) + .forEach(f -> handleFutureSync(f, failedSet)); + } + + @Override + public ClusterAppAssignResultVO unbindClusterServer(String app, String machineId) { + AssertUtil.assertNotBlank(app, "app cannot be blank"); + AssertUtil.assertNotBlank(machineId, "machineId cannot be blank"); + + if (isMachineInApp(machineId)) { + return handleUnbindClusterServerNotInApp(app, machineId); + } + Set failedSet = new HashSet<>(); + try { + ClusterGroupEntity entity = clusterConfigService.getClusterUniversalStateForAppMachine(app, machineId) + .get(10, TimeUnit.SECONDS); + Set toModifySet = new HashSet<>(); + toModifySet.add(machineId); + if (entity.getClientSet() != null) { + toModifySet.addAll(entity.getClientSet()); + } + // Modify mode to NOT-STARTED for all chosen token servers and associated token clients. + modifyToNonStarted(toModifySet, failedSet); + } catch (Exception ex) { + Throwable e = ex instanceof ExecutionException ? ex.getCause() : ex; + LOGGER.error("Failed to unbind machine <{}>", machineId, e); + failedSet.add(machineId); + } + return new ClusterAppAssignResultVO() + .setFailedClientSet(failedSet) + .setFailedServerSet(new HashSet<>()); + } + + @Override + public ClusterAppAssignResultVO unbindClusterServers(String app, Set machineIdSet) { + AssertUtil.assertNotBlank(app, "app cannot be blank"); + AssertUtil.isTrue(machineIdSet != null && !machineIdSet.isEmpty(), "machineIdSet cannot be empty"); + ClusterAppAssignResultVO result = new ClusterAppAssignResultVO() + .setFailedClientSet(new HashSet<>()) + .setFailedServerSet(new HashSet<>()); + for (String machineId : machineIdSet) { + ClusterAppAssignResultVO resultVO = unbindClusterServer(app, machineId); + result.getFailedClientSet().addAll(resultVO.getFailedClientSet()); + result.getFailedServerSet().addAll(resultVO.getFailedServerSet()); + } + return result; + } + + @Override + public ClusterAppAssignResultVO applyAssignToApp(String app, List clusterMap, + Set remainingSet) { + AssertUtil.assertNotBlank(app, "app cannot be blank"); + AssertUtil.notNull(clusterMap, "clusterMap cannot be null"); + Set failedServerSet = new HashSet<>(); + Set failedClientSet = new HashSet<>(); + + // Assign server and apply config. + clusterMap.stream() + .filter(Objects::nonNull) + .filter(ClusterAppAssignMap::getBelongToApp) + .map(e -> { + String ip = e.getIp(); + int commandPort = parsePort(e); + CompletableFuture f = modifyMode(ip, commandPort, ClusterStateManager.CLUSTER_SERVER) + .thenCompose(v -> applyServerConfigChange(app, ip, commandPort, e)); + return Tuple2.of(e.getMachineId(), f); + }) + .forEach(t -> handleFutureSync(t, failedServerSet)); + + // Assign client of servers and apply config. + clusterMap.parallelStream() + .filter(Objects::nonNull) + .forEach(e -> applyAllClientConfigChange(app, e, failedClientSet)); + + // Unbind remaining (unassigned) machines. + applyAllRemainingMachineSet(app, remainingSet, failedClientSet); + + return new ClusterAppAssignResultVO() + .setFailedClientSet(failedClientSet) + .setFailedServerSet(failedServerSet); + } + + private void applyAllRemainingMachineSet(String app, Set remainingSet, Set failedSet) { + if (remainingSet == null || remainingSet.isEmpty()) { + return; + } + remainingSet.parallelStream() + .filter(Objects::nonNull) + .map(MachineUtils::parseCommandIpAndPort) + .filter(Optional::isPresent) + .map(Optional::get) + .map(ipPort -> { + String ip = ipPort.r1; + int commandPort = ipPort.r2; + CompletableFuture f = modifyMode(ip, commandPort, ClusterStateManager.CLUSTER_NOT_STARTED); + return Tuple2.of(ip + '@' + commandPort, f); + }) + .forEach(t -> handleFutureSync(t, failedSet)); + } + + private void applyAllClientConfigChange(String app, ClusterAppAssignMap assignMap, + Set failedSet) { + Set clientSet = assignMap.getClientSet(); + if (clientSet == null || clientSet.isEmpty()) { + return; + } + final String serverIp = assignMap.getIp(); + final int serverPort = assignMap.getPort(); + clientSet.stream() + .map(MachineUtils::parseCommandIpAndPort) + .filter(Optional::isPresent) + .map(Optional::get) + .map(ipPort -> { + CompletableFuture f = sentinelApiClient + .modifyClusterMode(ipPort.r1, ipPort.r2, ClusterStateManager.CLUSTER_CLIENT) + .thenCompose(v -> sentinelApiClient.modifyClusterClientConfig(app, ipPort.r1, ipPort.r2, + new ClusterClientConfig().setRequestTimeout(20) + .setServerHost(serverIp) + .setServerPort(serverPort) + )); + return Tuple2.of(ipPort.r1 + '@' + ipPort.r2, f); + }) + .forEach(t -> handleFutureSync(t, failedSet)); + } + + private void handleFutureSync(Tuple2> t, Set failedSet) { + try { + t.r2.get(10, TimeUnit.SECONDS); + } catch (Exception ex) { + if (ex instanceof ExecutionException) { + LOGGER.error("Request for <{}> failed", t.r1, ex.getCause()); + } else { + LOGGER.error("Request for <{}> failed", t.r1, ex); + } + failedSet.add(t.r1); + } + } + + private CompletableFuture applyServerConfigChange(String app, String ip, int commandPort, + ClusterAppAssignMap assignMap) { + ServerTransportConfig transportConfig = new ServerTransportConfig() + .setPort(assignMap.getPort()) + .setIdleSeconds(600); + return sentinelApiClient.modifyClusterServerTransportConfig(app, ip, commandPort, transportConfig) + .thenCompose(v -> applyServerFlowConfigChange(app, ip, commandPort, assignMap)) + .thenCompose(v -> applyServerNamespaceSetConfig(app, ip, commandPort, assignMap)); + } + + private CompletableFuture applyServerFlowConfigChange(String app, String ip, int commandPort, + ClusterAppAssignMap assignMap) { + Double maxAllowedQps = assignMap.getMaxAllowedQps(); + if (maxAllowedQps == null || maxAllowedQps <= 0 || maxAllowedQps > 20_0000) { + return CompletableFuture.completedFuture(null); + } + return sentinelApiClient.modifyClusterServerFlowConfig(app, ip, commandPort, + new ServerFlowConfig().setMaxAllowedQps(maxAllowedQps)); + } + + private CompletableFuture applyServerNamespaceSetConfig(String app, String ip, int commandPort, + ClusterAppAssignMap assignMap) { + Set namespaceSet = assignMap.getNamespaceSet(); + if (namespaceSet == null || namespaceSet.isEmpty()) { + return CompletableFuture.completedFuture(null); + } + return sentinelApiClient.modifyClusterServerNamespaceSet(app, ip, commandPort, namespaceSet); + } + + private CompletableFuture modifyMode(String ip, int port, int mode) { + return sentinelApiClient.modifyClusterMode(ip, port, mode); + } + + private int parsePort(ClusterAppAssignMap assignMap) { + return MachineUtils.parseCommandPort(assignMap.getMachineId()) + .orElse(ServerTransportConfig.DEFAULT_PORT); + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterConfigService.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterConfigService.java new file mode 100755 index 00000000..1691deb0 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterConfigService.java @@ -0,0 +1,179 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; + +import com.alibaba.csp.sentinel.cluster.ClusterStateManager; +import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.discovery.AppInfo; +import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterServerModifyRequest; +import com.alibaba.csp.sentinel.dashboard.util.AsyncUtils; +import com.alibaba.csp.sentinel.dashboard.util.ClusterEntityUtils; +import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterGroupEntity; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterClientModifyRequest; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterClientStateVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStatePairVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStateVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ClusterClientConfig; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerFlowConfig; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerTransportConfig; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author Eric Zhao + * @since 1.4.0 + */ +@Service +public class ClusterConfigService { + + @Autowired + private SentinelApiClient sentinelApiClient; + @Autowired + private AppManagement appManagement; + + public CompletableFuture modifyClusterClientConfig(ClusterClientModifyRequest request) { + if (notClientRequestValid(request)) { + throw new IllegalArgumentException("Invalid request"); + } + String app = request.getApp(); + String ip = request.getIp(); + int port = request.getPort(); + return sentinelApiClient.modifyClusterClientConfig(app, ip, port, request.getClientConfig()) + .thenCompose(v -> sentinelApiClient.modifyClusterMode(ip, port, ClusterStateManager.CLUSTER_CLIENT)); + } + + private boolean notClientRequestValid(/*@NonNull */ ClusterClientModifyRequest request) { + ClusterClientConfig config = request.getClientConfig(); + return config == null || StringUtil.isEmpty(config.getServerHost()) + || config.getServerPort() == null || config.getServerPort() <= 0 + || config.getRequestTimeout() == null || config.getRequestTimeout() <= 0; + } + + public CompletableFuture modifyClusterServerConfig(ClusterServerModifyRequest request) { + ServerTransportConfig transportConfig = request.getTransportConfig(); + ServerFlowConfig flowConfig = request.getFlowConfig(); + Set namespaceSet = request.getNamespaceSet(); + if (invalidTransportConfig(transportConfig)) { + throw new IllegalArgumentException("Invalid transport config in request"); + } + if (invalidFlowConfig(flowConfig)) { + throw new IllegalArgumentException("Invalid flow config in request"); + } + if (namespaceSet == null) { + throw new IllegalArgumentException("namespace set cannot be null"); + } + String app = request.getApp(); + String ip = request.getIp(); + int port = request.getPort(); + return sentinelApiClient.modifyClusterServerNamespaceSet(app, ip, port, namespaceSet) + .thenCompose(v -> sentinelApiClient.modifyClusterServerTransportConfig(app, ip, port, transportConfig)) + .thenCompose(v -> sentinelApiClient.modifyClusterServerFlowConfig(app, ip, port, flowConfig)) + .thenCompose(v -> sentinelApiClient.modifyClusterMode(ip, port, ClusterStateManager.CLUSTER_SERVER)); + } + + /** + * Get cluster state list of all available machines of provided application. + * + * @param app application name + * @return cluster state list of all available machines of the application + * @since 1.4.1 + */ + public CompletableFuture> getClusterUniversalState(String app) { + if (StringUtil.isBlank(app)) { + return AsyncUtils.newFailedFuture(new IllegalArgumentException("app cannot be empty")); + } + AppInfo appInfo = appManagement.getDetailApp(app); + if (appInfo == null || appInfo.getMachines() == null) { + return CompletableFuture.completedFuture(new ArrayList<>()); + } + + List> futures = appInfo.getMachines().stream() + .filter(e -> e.isHealthy()) + .map(machine -> getClusterUniversalState(app, machine.getIp(), machine.getPort()) + .thenApply(e -> new ClusterUniversalStatePairVO(machine.getIp(), machine.getPort(), e))) + .collect(Collectors.toList()); + + return AsyncUtils.sequenceSuccessFuture(futures); + } + + public CompletableFuture getClusterUniversalStateForAppMachine(String app, String machineId) { + if (StringUtil.isBlank(app)) { + return AsyncUtils.newFailedFuture(new IllegalArgumentException("app cannot be empty")); + } + AppInfo appInfo = appManagement.getDetailApp(app); + if (appInfo == null || appInfo.getMachines() == null) { + return AsyncUtils.newFailedFuture(new IllegalArgumentException("app does not have machines")); + } + + boolean machineOk = appInfo.getMachines().stream() + .filter(e -> e.isHealthy()) + .map(e -> e.getIp() + '@' + e.getPort()) + .anyMatch(e -> e.equals(machineId)); + if (!machineOk) { + return AsyncUtils.newFailedFuture(new IllegalStateException("machine does not exist or disconnected")); + } + + return getClusterUniversalState(app) + .thenApply(ClusterEntityUtils::wrapToClusterGroup) + .thenCompose(e -> e.stream() + .filter(e1 -> e1.getMachineId().equals(machineId)) + .findAny() + .map(CompletableFuture::completedFuture) + .orElse(AsyncUtils.newFailedFuture(new IllegalStateException("not a server: " + machineId))) + ); + } + + public CompletableFuture getClusterUniversalState(String app, String ip, int port) { + return sentinelApiClient.fetchClusterMode(ip, port) + .thenApply(e -> new ClusterUniversalStateVO().setStateInfo(e)) + .thenCompose(vo -> { + if (vo.getStateInfo().getClientAvailable()) { + return sentinelApiClient.fetchClusterClientInfoAndConfig(ip, port) + .thenApply(cc -> vo.setClient(new ClusterClientStateVO().setClientConfig(cc))); + } else { + return CompletableFuture.completedFuture(vo); + } + }).thenCompose(vo -> { + if (vo.getStateInfo().getServerAvailable()) { + return sentinelApiClient.fetchClusterServerBasicInfo(ip, port) + .thenApply(vo::setServer); + } else { + return CompletableFuture.completedFuture(vo); + } + }); + } + + private boolean invalidTransportConfig(ServerTransportConfig transportConfig) { + return transportConfig == null || transportConfig.getPort() == null || transportConfig.getPort() <= 0 + || transportConfig.getIdleSeconds() == null || transportConfig.getIdleSeconds() <= 0; + } + + private boolean invalidFlowConfig(ServerFlowConfig flowConfig) { + return flowConfig == null || flowConfig.getSampleCount() == null || flowConfig.getSampleCount() <= 0 + || flowConfig.getIntervalMs() == null || flowConfig.getIntervalMs() <= 0 + || flowConfig.getIntervalMs() % flowConfig.getSampleCount() != 0 + || flowConfig.getMaxAllowedQps() == null || flowConfig.getMaxAllowedQps() < 0; + } +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/AsyncUtils.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/AsyncUtils.java new file mode 100755 index 00000000..9881cdac --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/AsyncUtils.java @@ -0,0 +1,72 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.util; + +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Eric Zhao + * @since 1.4.1 + */ +public final class AsyncUtils { + + private static final Logger LOG = LoggerFactory.getLogger(AsyncUtils.class); + + public static CompletableFuture newFailedFuture(Throwable ex) { + CompletableFuture future = new CompletableFuture<>(); + future.completeExceptionally(ex); + return future; + } + + public static CompletableFuture> sequenceFuture(List> futures) { + return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])) + .thenApply(v -> futures.stream() + .map(AsyncUtils::getValue) + .filter(Objects::nonNull) + .collect(Collectors.toList()) + ); + } + + public static CompletableFuture> sequenceSuccessFuture(List> futures) { + return CompletableFuture.supplyAsync(() -> futures.parallelStream() + .map(AsyncUtils::getValue) + .filter(Objects::nonNull) + .collect(Collectors.toList()) + ); + } + + public static T getValue(CompletableFuture future) { + try { + return future.get(10, TimeUnit.SECONDS); + } catch (Exception ex) { + LOG.error("getValue for async result failed", ex); + } + return null; + } + + public static boolean isSuccessFuture(CompletableFuture future) { + return future.isDone() && !future.isCompletedExceptionally() && !future.isCancelled(); + } + + private AsyncUtils() {} +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/ClusterEntityUtils.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/ClusterEntityUtils.java new file mode 100755 index 00000000..ced801fa --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/ClusterEntityUtils.java @@ -0,0 +1,168 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.alibaba.csp.sentinel.cluster.ClusterStateManager; +import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterGroupEntity; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ConnectionGroupVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.AppClusterClientStateWrapVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.AppClusterServerStateWrapVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterClientStateVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterServerStateVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStatePairVO; + +/** + * @author Eric Zhao + * @since 1.4.1 + */ +public final class ClusterEntityUtils { + + public static List wrapToAppClusterServerState( + List list) { + if (list == null || list.isEmpty()) { + return new ArrayList<>(); + } + Map map = new HashMap<>(); + Set tokenServerSet = new HashSet<>(); + // Handle token servers that belong to current app. + for (ClusterUniversalStatePairVO stateVO : list) { + int mode = stateVO.getState().getStateInfo().getMode(); + + if (mode == ClusterStateManager.CLUSTER_SERVER) { + String ip = stateVO.getIp(); + String serverId = ip + '@' + stateVO.getCommandPort(); + ClusterServerStateVO serverStateVO = stateVO.getState().getServer(); + map.computeIfAbsent(serverId, v -> new AppClusterServerStateWrapVO() + .setId(serverId) + .setIp(ip) + .setPort(serverStateVO.getPort()) + .setState(serverStateVO) + .setBelongToApp(true) + .setConnectedCount(serverStateVO.getConnection().stream() + .mapToInt(ConnectionGroupVO::getConnectedCount) + .sum() + ) + ); + tokenServerSet.add(ip + ":" + serverStateVO.getPort()); + } + } + // Handle token servers from other app. + for (ClusterUniversalStatePairVO stateVO : list) { + int mode = stateVO.getState().getStateInfo().getMode(); + + if (mode == ClusterStateManager.CLUSTER_CLIENT) { + ClusterClientStateVO clientState = stateVO.getState().getClient(); + if (clientState == null) { + continue; + } + String serverIp = clientState.getClientConfig().getServerHost(); + int serverPort = clientState.getClientConfig().getServerPort(); + if (tokenServerSet.contains(serverIp + ":" + serverPort)) { + continue; + } + // We are not able to get the commandPort of foreign token server directly. + String serverId = String.format("%s:%d", serverIp, serverPort); + map.computeIfAbsent(serverId, v -> new AppClusterServerStateWrapVO() + .setId(serverId) + .setIp(serverIp) + .setPort(serverPort) + .setBelongToApp(false) + ); + } + } + return new ArrayList<>(map.values()); + } + + public static List wrapToAppClusterClientState( + List list) { + if (list == null || list.isEmpty()) { + return new ArrayList<>(); + } + Map map = new HashMap<>(); + for (ClusterUniversalStatePairVO stateVO : list) { + int mode = stateVO.getState().getStateInfo().getMode(); + + if (mode == ClusterStateManager.CLUSTER_CLIENT) { + String ip = stateVO.getIp(); + String clientId = ip + '@' + stateVO.getCommandPort(); + ClusterClientStateVO clientStateVO = stateVO.getState().getClient(); + map.computeIfAbsent(clientId, v -> new AppClusterClientStateWrapVO() + .setId(clientId) + .setIp(ip) + .setState(clientStateVO) + .setCommandPort(stateVO.getCommandPort()) + ); + } + } + return new ArrayList<>(map.values()); + } + + public static List wrapToClusterGroup(List list) { + if (list == null || list.isEmpty()) { + return new ArrayList<>(); + } + Map map = new HashMap<>(); + for (ClusterUniversalStatePairVO stateVO : list) { + int mode = stateVO.getState().getStateInfo().getMode(); + String ip = stateVO.getIp(); + if (mode == ClusterStateManager.CLUSTER_SERVER) { + String serverAddress = getIp(ip); + int port = stateVO.getState().getServer().getPort(); + map.computeIfAbsent(serverAddress, v -> new ClusterGroupEntity() + .setBelongToApp(true).setMachineId(ip + '@' + stateVO.getCommandPort()) + .setIp(ip).setPort(port) + ); + } + } + for (ClusterUniversalStatePairVO stateVO : list) { + int mode = stateVO.getState().getStateInfo().getMode(); + String ip = stateVO.getIp(); + if (mode == ClusterStateManager.CLUSTER_CLIENT) { + String targetServer = stateVO.getState().getClient().getClientConfig().getServerHost(); + Integer targetPort = stateVO.getState().getClient().getClientConfig().getServerPort(); + if (StringUtil.isBlank(targetServer) || targetPort == null || targetPort <= 0) { + continue; + } + + ClusterGroupEntity group = map.computeIfAbsent(targetServer, + v -> new ClusterGroupEntity() + .setBelongToApp(true).setMachineId(targetServer) + .setIp(targetServer).setPort(targetPort) + ); + group.getClientSet().add(ip + '@' + stateVO.getCommandPort()); + } + } + return new ArrayList<>(map.values()); + } + + private static String getIp(String str) { + if (str.contains(":")) { + return str.split(":")[0]; + } + return str; + } + + private ClusterEntityUtils() {} +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/MachineUtils.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/MachineUtils.java new file mode 100755 index 00000000..5b3073cf --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/MachineUtils.java @@ -0,0 +1,59 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.util; + +import java.util.Optional; + +import com.alibaba.csp.sentinel.util.StringUtil; +import com.alibaba.csp.sentinel.util.function.Tuple2; + +/** + * @author Eric Zhao + */ +public final class MachineUtils { + + public static Optional parseCommandPort(String machineIp) { + try { + if (!machineIp.contains("@")) { + return Optional.empty(); + } + String[] str = machineIp.split("@"); + if (str.length <= 1) { + return Optional.empty(); + } + return Optional.of(Integer.parseInt(str[1])); + } catch (Exception ex) { + return Optional.empty(); + } + } + + public static Optional> parseCommandIpAndPort(String machineIp) { + try { + if (StringUtil.isEmpty(machineIp) || !machineIp.contains("@")) { + return Optional.empty(); + } + String[] str = machineIp.split("@"); + if (str.length <= 1) { + return Optional.empty(); + } + return Optional.of(Tuple2.of(str[0], Integer.parseInt(str[1]))); + } catch (Exception ex) { + return Optional.empty(); + } + } + + private MachineUtils() {} +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/VersionUtils.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/VersionUtils.java new file mode 100755 index 00000000..cb013a12 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/VersionUtils.java @@ -0,0 +1,95 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.csp.sentinel.dashboard.util; + +import java.util.Optional; + +import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.SentinelVersion; + +/** + * Util class for parsing version. + * + * @author Eric Zhao + * @since 0.2.1 + */ +public final class VersionUtils { + + /** + * Parse version of Sentinel from raw string. + * + * @param versionFull version string + * @return parsed {@link SentinelVersion} if the version is valid; empty if + * there is something wrong with the format + */ + public static Optional parseVersion(String s) { + if (StringUtil.isBlank(s)) { + return Optional.empty(); + } + try { + String versionFull = s; + SentinelVersion version = new SentinelVersion(); + + // postfix + int index = versionFull.indexOf("-"); + if (index == 0) { + // Start with "-" + return Optional.empty(); + } + if (index == versionFull.length() - 1) { + // End with "-" + } else if (index > 0) { + version.setPostfix(versionFull.substring(index + 1)); + } + + if (index >= 0) { + versionFull = versionFull.substring(0, index); + } + + // x.x.x + int segment = 0; + int[] ver = new int[3]; + while (segment < ver.length) { + index = versionFull.indexOf('.'); + if (index < 0) { + if (versionFull.length() > 0) { + ver[segment] = Integer.valueOf(versionFull); + } + break; + } + ver[segment] = Integer.valueOf(versionFull.substring(0, index)); + versionFull = versionFull.substring(index + 1); + segment ++; + } + + if (ver[0] < 1) { + // Wrong format, return empty. + return Optional.empty(); + } else { + return Optional.of(version + .setMajorVersion(ver[0]) + .setMinorVersion(ver[1]) + .setFixVersion(ver[2])); + } + } catch (Exception ex) { + // Parse fail, return empty. + return Optional.empty(); + } + } + + private VersionUtils() {} +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/resources/application.yml b/pig-visual/pig-sentinel-dashboard/src/main/resources/application.yml new file mode 100755 index 00000000..86d17709 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/resources/application.yml @@ -0,0 +1,26 @@ +server: + port: 5003 + servlet: + encoding: + force: true + +logging: + level: + org: + springframework: + web: info + file: + name: ${user.home}/logs/csp/sentinel-dashboard.log + pattern: + file: '%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n' + +auth: + username: sentinel + password: sentinel + filter: + exclude-urls: /,/auth/login,/auth/logout,/registry/machine,/version + exclude-url-suffixes: htm,html,js,css,map,ico,ttf,woff,png + +sentinel: + dashboard: + version: 1.7.1 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/.gitignore b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/.gitignore new file mode 100755 index 00000000..104d9996 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +tmp/ \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/.jshintrc b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/.jshintrc new file mode 100755 index 00000000..6c66001a --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/.jshintrc @@ -0,0 +1,67 @@ +{ + /* + * ENVIRONMENTS + * ================= + */ + + // Define globals exposed by modern browsers. + "browser": true, + + // Define globals exposed by jQuery. + "jquery": true, + + // Define globals exposed by Node.js. + "node": true, + + // Allow ES6. + "esversion": 6, + + /* + * ENFORCING OPTIONS + * ================= + */ + + // Force all variable names to use either camelCase style or UPPER_CASE + // with underscores. + "camelcase": true, + + // Prohibit use of == and != in favor of === and !==. + "eqeqeq": true, + + // Enforce tab width of 2 spaces. + "indent": 2, + + // Prohibit use of a variable before it is defined. + "latedef": true, + + // Enforce line length to 100 characters + "maxlen": 100, + + // Require capitalized names for constructor functions. + "newcap": true, + + // Enforce use of single quotation marks for strings. + "quotmark": "single", + + // Enforce placing 'use strict' at the top function scope + // 前端项目中外层使用 strict 即可,覆盖此条规则 + "strict": false, + + // Prohibit use of explicitly undeclared variables. + "undef": true, + + // Warn when variables are defined but never used. + "unused": true, + + /* + * RELAXING OPTIONS + * ================= + */ + + // Suppress warnings about == null comparisons. + "eqnull": true, + "globals": { + "$": false, + "angular": false + } +} \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/app.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/app.js new file mode 100755 index 00000000..bc3747af --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/app.js @@ -0,0 +1,365 @@ +'use strict'; + +/** + * @ngdoc overview + * @name sentinelDashboardApp + * @description + * # sentinelDashboardApp + * + * Main module of the application. + */ + +angular + .module('sentinelDashboardApp', [ + 'oc.lazyLoad', + 'ui.router', + 'ui.bootstrap', + 'angular-loading-bar', + 'ngDialog', + 'ui.bootstrap.datetimepicker', + 'ui-notification', + 'rzTable', + 'angular-clipboard', + 'selectize', + 'angularUtils.directives.dirPagination' + ]) + .factory('AuthInterceptor', ['$window', '$state', function ($window, $state) { + var authInterceptor = { + 'responseError' : function(response) { + if (response.status === 401) { + // If not auth, clear session in localStorage and jump to the login page + $window.localStorage.removeItem('session_sentinel_admin'); + $state.go('login'); + } + + return response; + }, + 'response' : function(response) { + return response; + }, + 'request' : function(config) { + return config; + }, + 'requestError' : function(config){ + return config; + } + }; + return authInterceptor; + }]) + .config(['$stateProvider', '$urlRouterProvider', '$ocLazyLoadProvider', '$httpProvider', + function ($stateProvider, $urlRouterProvider, $ocLazyLoadProvider, $httpProvider) { + $httpProvider.interceptors.push('AuthInterceptor'); + + $ocLazyLoadProvider.config({ + debug: false, + events: true, + }); + + $urlRouterProvider.otherwise('/dashboard/home'); + + $stateProvider + .state('login', { + url: '/login', + templateUrl: 'app/views/login.html', + controller: 'LoginCtl', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/login.js', + ] + }); + }] + } + }) + + .state('dashboard', { + url: '/dashboard', + templateUrl: 'app/views/dashboard/main.html', + resolve: { + loadMyDirectives: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load( + { + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/directives/header/header.js', + 'app/scripts/directives/sidebar/sidebar.js', + 'app/scripts/directives/sidebar/sidebar-search/sidebar-search.js', + ] + }); + }] + } + }) + + .state('dashboard.home', { + url: '/home', + templateUrl: 'app/views/dashboard/home.html', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/main.js', + ] + }); + }] + } + }) + + .state('dashboard.flowV1', { + templateUrl: 'app/views/flow_v1.html', + url: '/flow/:app', + controller: 'FlowControllerV1', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/flow_v1.js', + ] + }); + }] + } + }) + + .state('dashboard.flow', { + templateUrl: 'app/views/flow_v2.html', + url: '/v2/flow/:app', + controller: 'FlowControllerV2', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/flow_v2.js', + ] + }); + }] + } + }) + + .state('dashboard.paramFlow', { + templateUrl: 'app/views/param_flow.html', + url: '/paramFlow/:app', + controller: 'ParamFlowController', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/param_flow.js', + ] + }); + }] + } + }) + + .state('dashboard.clusterAppAssignManage', { + templateUrl: 'app/views/cluster_app_assign_manage.html', + url: '/cluster/assign_manage/:app', + controller: 'SentinelClusterAppAssignManageController', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/cluster_app_assign_manage.js', + ] + }); + }] + } + }) + + .state('dashboard.clusterAppServerList', { + templateUrl: 'app/views/cluster_app_server_list.html', + url: '/cluster/server/:app', + controller: 'SentinelClusterAppServerListController', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/cluster_app_server_list.js', + ] + }); + }] + } + }) + + .state('dashboard.clusterAppClientList', { + templateUrl: 'app/views/cluster_app_client_list.html', + url: '/cluster/client/:app', + controller: 'SentinelClusterAppTokenClientListController', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/cluster_app_token_client_list.js', + ] + }); + }] + } + }) + + .state('dashboard.clusterSingle', { + templateUrl: 'app/views/cluster_single_config.html', + url: '/cluster/single/:app', + controller: 'SentinelClusterSingleController', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/cluster_single.js', + ] + }); + }] + } + }) + + .state('dashboard.authority', { + templateUrl: 'app/views/authority.html', + url: '/authority/:app', + controller: 'AuthorityRuleController', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/authority.js', + ] + }); + }] + } + }) + + .state('dashboard.degrade', { + templateUrl: 'app/views/degrade.html', + url: '/degrade/:app', + controller: 'DegradeCtl', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/degrade.js', + ] + }); + }] + } + }) + + .state('dashboard.system', { + templateUrl: 'app/views/system.html', + url: '/system/:app', + controller: 'SystemCtl', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/system.js', + ] + }); + }] + } + }) + + .state('dashboard.machine', { + templateUrl: 'app/views/machine.html', + url: '/app/:app', + controller: 'MachineCtl', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/machine.js', + ] + }); + }] + } + }) + + .state('dashboard.identity', { + templateUrl: 'app/views/identity.html', + url: '/identity/:app', + controller: 'IdentityCtl', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/identity.js', + ] + }); + }] + } + }) + + .state('dashboard.gatewayIdentity', { + templateUrl: 'app/views/gateway/identity.html', + url: '/gateway/identity/:app', + controller: 'GatewayIdentityCtl', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/gateway/identity.js', + ] + }); + }] + } + }) + + .state('dashboard.metric', { + templateUrl: 'app/views/metric.html', + url: '/metric/:app', + controller: 'MetricCtl', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/metric.js', + ] + }); + }] + } + }) + + .state('dashboard.gatewayApi', { + templateUrl: 'app/views/gateway/api.html', + url: '/gateway/api/:app', + controller: 'GatewayApiCtl', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/gateway/api.js', + ] + }); + }] + } + }) + + .state('dashboard.gatewayFlow', { + templateUrl: 'app/views/gateway/flow.html', + url: '/gateway/flow/:app', + controller: 'GatewayFlowCtl', + resolve: { + loadMyFiles: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load({ + name: 'sentinelDashboardApp', + files: [ + 'app/scripts/controllers/gateway/flow.js', + ] + }); + }] + } + }); + }]); \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/authority.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/authority.js new file mode 100755 index 00000000..3d86302f --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/authority.js @@ -0,0 +1,227 @@ +/** + * Authority rule controller. + */ +angular.module('sentinelDashboardApp').controller('AuthorityRuleController', ['$scope', '$stateParams', 'AuthorityRuleService', 'ngDialog', + 'MachineService', + function ($scope, $stateParams, AuthorityRuleService, ngDialog, + MachineService) { + $scope.app = $stateParams.app; + + $scope.rulesPageConfig = { + pageSize: 10, + currentPageIndex: 1, + totalPage: 1, + totalCount: 0, + }; + $scope.macsInputConfig = { + searchField: ['text', 'value'], + persist: true, + create: false, + maxItems: 1, + render: { + item: function (data, escape) { + return '
' + escape(data.text) + '
'; + } + }, + onChange: function (value, oldValue) { + $scope.macInputModel = value; + } + }; + + function getMachineRules() { + if (!$scope.macInputModel) { + return; + } + let mac = $scope.macInputModel.split(':'); + AuthorityRuleService.queryMachineRules($scope.app, mac[0], mac[1]) + .success(function (data) { + if (data.code === 0 && data.data) { + $scope.loadError = undefined; + $scope.rules = data.data; + $scope.rulesPageConfig.totalCount = $scope.rules.length; + } else { + $scope.rules = []; + $scope.rulesPageConfig.totalCount = 0; + $scope.loadError = {message: data.msg}; + } + }) + .error((data, header, config, status) => { + $scope.loadError = {message: "未知错误"}; + }); + }; + $scope.getMachineRules = getMachineRules; + getMachineRules(); + + var authorityRuleDialog; + + $scope.editRule = function (rule) { + $scope.currentRule = angular.copy(rule); + $scope.authorityRuleDialog = { + title: '编辑授权规则', + type: 'edit', + confirmBtnText: '保存', + }; + authorityRuleDialog = ngDialog.open({ + template: '/app/views/dialog/authority-rule-dialog.html', + width: 680, + overlay: true, + scope: $scope + }); + }; + + $scope.addNewRule = function () { + var mac = $scope.macInputModel.split(':'); + $scope.currentRule = { + app: $scope.app, + ip: mac[0], + port: mac[1], + rule: { + strategy: 0, + limitApp: '', + } + }; + $scope.authorityRuleDialog = { + title: '新增授权规则', + type: 'add', + confirmBtnText: '新增', + showAdvanceButton: true, + }; + authorityRuleDialog = ngDialog.open({ + template: '/app/views/dialog/authority-rule-dialog.html', + width: 680, + overlay: true, + scope: $scope + }); + }; + + $scope.saveRule = function () { + if (!AuthorityRuleService.checkRuleValid($scope.currentRule.rule)) { + return; + } + if ($scope.authorityRuleDialog.type === 'add') { + addNewRuleAndPush($scope.currentRule); + } else if ($scope.authorityRuleDialog.type === 'edit') { + saveRuleAndPush($scope.currentRule, true); + } + }; + + function addNewRuleAndPush(rule) { + AuthorityRuleService.addNewRule(rule).success((data) => { + if (data.success) { + getMachineRules(); + authorityRuleDialog.close(); + } else { + alert('添加规则失败:' + data.msg); + } + }).error((data) => { + if (data) { + alert('添加规则失败:' + data.msg); + } else { + alert("添加规则失败:未知错误"); + } + }); + } + + function saveRuleAndPush(rule, edit) { + AuthorityRuleService.saveRule(rule).success(function (data) { + if (data.success) { + alert("修改规则成功"); + getMachineRules(); + if (edit) { + authorityRuleDialog.close(); + } else { + confirmDialog.close(); + } + } else { + alert('修改规则失败:' + data.msg); + } + }).error((data) => { + if (data) { + alert('修改规则失败:' + data.msg); + } else { + alert("修改规则失败:未知错误"); + } + }); + } + + function deleteRuleAndPush(entity) { + if (entity.id === undefined || isNaN(entity.id)) { + alert('规则 ID 不合法!'); + return; + } + AuthorityRuleService.deleteRule(entity).success((data) => { + if (data.code == 0) { + getMachineRules(); + confirmDialog.close(); + } else { + alert('删除规则失败:' + data.msg); + } + }).error((data) => { + if (data) { + alert('删除规则失败:' + data.msg); + } else { + alert("删除规则失败:未知错误"); + } + }); + }; + + var confirmDialog; + $scope.deleteRule = function (ruleEntity) { + $scope.currentRule = ruleEntity; + $scope.confirmDialog = { + title: '删除授权规则', + type: 'delete_rule', + attentionTitle: '请确认是否删除如下授权限流规则', + attention: '资源名: ' + ruleEntity.rule.resource + ', 流控应用: ' + ruleEntity.rule.limitApp + + ', 类型: ' + (ruleEntity.rule.strategy === 0 ? '白名单' : '黑名单'), + confirmBtnText: '删除', + }; + confirmDialog = ngDialog.open({ + template: '/app/views/dialog/confirm-dialog.html', + scope: $scope, + overlay: true + }); + }; + + $scope.confirm = function () { + if ($scope.confirmDialog.type === 'delete_rule') { + deleteRuleAndPush($scope.currentRule); + } else { + console.error('error'); + } + }; + + queryAppMachines(); + + function queryAppMachines() { + MachineService.getAppMachines($scope.app).success( + function (data) { + if (data.code == 0) { + // $scope.machines = data.data; + if (data.data) { + $scope.machines = []; + $scope.macsInputOptions = []; + data.data.forEach(function (item) { + if (item.healthy) { + $scope.macsInputOptions.push({ + text: item.ip + ':' + item.port, + value: item.ip + ':' + item.port + }); + } + }); + } + if ($scope.macsInputOptions.length > 0) { + $scope.macInputModel = $scope.macsInputOptions[0].value; + } + } else { + $scope.macsInputOptions = []; + } + } + ); + }; + $scope.$watch('macInputModel', function () { + if ($scope.macInputModel) { + getMachineRules(); + } + }); + }]); \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_app_assign_manage.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_app_assign_manage.js new file mode 100755 index 00000000..6f9367d6 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_app_assign_manage.js @@ -0,0 +1,283 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('SentinelClusterAppAssignManageController', ['$scope', '$stateParams', 'ngDialog', + 'MachineService', 'ClusterStateService', + function ($scope, $stateParams, ngDialog, MachineService, ClusterStateService) { + $scope.app = $stateParams.app; + const UNSUPPORTED_CODE = 4041; + + const CLUSTER_MODE_CLIENT = 0; + const CLUSTER_MODE_SERVER = 1; + const DEFAULT_CLUSTER_SERVER_PORT = 18730; + + $scope.tmp = { + curClientChosen: [], + curRemainingClientChosen: [], + curChosenServer: {}, + }; + + function convertSetToString(set) { + if (set === undefined) { + return ''; + } + let s = ''; + for (let i = 0; i < set.length; i++) { + s = s + set[i]; + if (i < set.length - 1) { + s = s + ','; + } + } + return s; + } + + function convertStrToNamespaceSet(str) { + if (str === undefined || str === '') { + return []; + } + let arr = []; + let spliced = str.split(','); + spliced.forEach((v) => { + arr.push(v.trim()); + }); + return arr; + } + + function processAppSingleData(data) { + if (data.state.server && data.state.server.namespaceSet) { + data.state.server.namespaceSetStr = convertSetToString(data.state.server.namespaceSet); + data.mode = data.state.stateInfo.mode; + } + } + + function removeFromArr(arr, v) { + for (let i = 0; i < arr.length; i++) { + if (arr[i] === v) { + arr.splice(i, 1); + break; + } + } + } + + function resetChosen() { + $scope.tmp.curClientChosen = []; + $scope.tmp.curRemainingClientChosen = []; + } + + function generateMachineId(e) { + return e.ip + '@' + e.commandPort; + } + + function applyClusterMap(appClusterMachineList) { + if (!appClusterMachineList) { + return; + } + let tmpMap = new Map(); + $scope.clusterMap = []; + $scope.remainingClientAddressList = []; + let tmpServerList = []; + let tmpClientList = []; + appClusterMachineList.forEach((e) => { + if (e.mode === CLUSTER_MODE_CLIENT) { + tmpClientList.push(e); + } else if (e.mode === CLUSTER_MODE_SERVER) { + tmpServerList.push(e); + } else { + $scope.remainingClientAddressList.push(generateMachineId(e)); + } + }); + tmpServerList.forEach((e) => { + let ip = e.ip; + let machineId = ip + '@' + e.commandPort; + let group = { + ip: ip, + machineId: machineId, + port: e.state.server.port, + clientSet: [], + namespaceSetStr: e.state.server.namespaceSetStr, + belongToApp: true, + }; + if (!tmpMap.has(ip)) { + tmpMap.set(ip, group); + } + }); + tmpClientList.forEach((e) => { + let ip = e.ip; + let machineId = ip + '@' + e.commandPort; + + let targetServer = e.state.client.clientConfig.serverHost; + let targetPort = e.state.client.clientConfig.serverPort; + if (targetServer === undefined || targetServer === '' || + targetPort === undefined || targetPort <= 0) { + $scope.remainingClientAddressList.push(generateMachineId(e)); + return; + } + + if (!tmpMap.has(targetServer)) { + let group = { + ip: targetServer, + machineId: targetServer, + port: targetPort, + clientSet: [machineId], + belongToApp: false, + }; + tmpMap.set(targetServer, group); + } else { + let g = tmpMap.get(targetServer); + g.clientSet.push(machineId); + } + }); + tmpMap.forEach((v) => { + if (v !== undefined) { + $scope.clusterMap.push(v); + } + }); + } + + $scope.onCurrentServerChange = () => { + resetChosen(); + }; + + $scope.remainingClientAddressList = []; + + $scope.moveToServerGroup = () => { + let chosenServer = $scope.tmp.curChosenServer; + if (!chosenServer || !chosenServer.machineId) { + return; + } + $scope.tmp.curRemainingClientChosen.forEach(e => { + chosenServer.clientSet.push(e); + removeFromArr($scope.remainingClientAddressList, e); + }); + resetChosen(); + }; + + $scope.moveToRemainingSharePool = () => { + $scope.tmp.curClientChosen.forEach(e => { + $scope.remainingClientAddressList.push(e); + removeFromArr($scope.tmp.curChosenServer.clientSet, e); + }); + resetChosen(); + }; + + function parseIpFromMachineId(machineId) { + if (machineId.indexOf('@') === -1) { + return machineId; + } + let arr = machineId.split('@'); + return arr[0]; + } + + $scope.addToServerList = () => { + let group; + $scope.tmp.curRemainingClientChosen.forEach(e => { + group = { + machineId: e, + ip: parseIpFromMachineId(e), + port: DEFAULT_CLUSTER_SERVER_PORT, + clientSet: [], + namespaceSetStr: 'default,' + $scope.app, + belongToApp: true, + }; + $scope.clusterMap.push(group); + removeFromArr($scope.remainingClientAddressList, e); + $scope.tmp.curChosenServer = group; + }); + resetChosen(); + }; + + $scope.removeFromServerList = () => { + let chosenServer = $scope.tmp.curChosenServer; + if (!chosenServer || !chosenServer.machineId) { + return; + } + chosenServer.clientSet.forEach((e) => { + if (e !== undefined) { + $scope.remainingClientAddressList.push(e); + } + }); + + if (chosenServer.belongToApp || chosenServer.machineId.indexOf('@') !== -1) { + $scope.remainingClientAddressList.push(chosenServer.machineId); + } else { + alert('提示:非本应用内机器将不会置回空闲列表中'); + } + + removeFromArr($scope.clusterMap, chosenServer); + + resetChosen(); + + if ($scope.clusterMap.length > 0) { + $scope.tmp.curChosenServer = $scope.clusterMap[0]; + $scope.onCurrentServerChange(); + } else { + $scope.tmp.curChosenServer = {}; + } + }; + + function retrieveClusterAppInfo() { + ClusterStateService.fetchClusterUniversalStateOfApp($scope.app).success(function (data) { + if (data.code === 0 && data.data) { + $scope.loadError = undefined; + $scope.appClusterMachineList = data.data; + $scope.appClusterMachineList.forEach(processAppSingleData); + applyClusterMap($scope.appClusterMachineList); + if ($scope.clusterMap.length > 0) { + $scope.tmp.curChosenServer = $scope.clusterMap[0]; + $scope.onCurrentServerChange(); + } + } else { + $scope.appClusterMachineList = {}; + if (data.code === UNSUPPORTED_CODE) { + $scope.loadError = {message: '该应用的 Sentinel 客户端不支持集群限流,请升级至 1.4.0 以上版本并引入相关依赖。'} + } else { + $scope.loadError = {message: data.msg}; + } + } + }).error(() => { + $scope.loadError = {message: '未知错误'}; + }); + } + + retrieveClusterAppInfo(); + + $scope.saveAndApplyAssign = () => { + let ok = confirm('是否确认执行变更?'); + if (!ok) { + return; + } + let cm = $scope.clusterMap; + if (!cm) { + cm = []; + } + cm.forEach((e) => { + e.namespaceSet = convertStrToNamespaceSet(e.namespaceSetStr); + }); + cm.namespaceSet = convertStrToNamespaceSet(cm.namespaceSetStr); + let request = { + clusterMap: cm, + remainingList: $scope.remainingClientAddressList, + }; + ClusterStateService.applyClusterFullAssignOfApp($scope.app, request).success((data) => { + if (data.code === 0 && data.data) { + let failedServerSet = data.data.failedServerSet; + let failedClientSet = data.data.failedClientSet; + if (failedClientSet.length === 0 && failedServerSet.length === 0) { + alert('全部推送成功'); + } else { + alert('推送完毕。token server 失败列表:' + JSON.stringify(failedServerSet) + + '; token client 失败列表:' + JSON.stringify(failedClientSet)); + } + + retrieveClusterAppInfo(); + } else { + if (data.code === UNSUPPORTED_CODE) { + alert('该应用的 Sentinel 客户端不支持集群限流,请升级至 1.4.0 以上版本并引入相关依赖。'); + } else { + alert('推送失败:' + data.msg); + } + } + }).error(() => { + alert('未知错误'); + }); + }; + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_app_server_list.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_app_server_list.js new file mode 100755 index 00000000..7e1708c0 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_app_server_list.js @@ -0,0 +1,570 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('SentinelClusterAppServerListController', ['$scope', '$stateParams', 'ngDialog', + 'MachineService', 'ClusterStateService', + function ($scope, $stateParams, ngDialog, MachineService, ClusterStateService) { + $scope.app = $stateParams.app; + const UNSUPPORTED_CODE = 4041; + + const CLUSTER_MODE_CLIENT = 0; + const CLUSTER_MODE_SERVER = 1; + const DEFAULT_CLUSTER_SERVER_PORT = 18730; + const DEFAULT_NAMESPACE = 'default'; + const DEFAULT_MAX_ALLOWED_QPS = 20000; + + // tmp for dialog temporary data. + $scope.tmp = { + curClientChosen: [], + curRemainingClientChosen: [], + curChosenServer: {}, + }; + + $scope.remainingMachineList = []; + + function convertSetToString(set) { + if (set === undefined) { + return ''; + } + if (set.length === 1 && set[0] === DEFAULT_NAMESPACE) { + return DEFAULT_NAMESPACE; + } + let s = ''; + for (let i = 0; i < set.length; i++) { + let ns = set[i]; + if (ns !== DEFAULT_NAMESPACE) { + s = s + ns; + if (i < set.length - 1) { + s = s + ','; + } + } + } + return s; + } + + function convertStrToNamespaceSet(str) { + if (str === undefined || str === '') { + return []; + } + let arr = []; + let spliced = str.split(','); + spliced.forEach((v) => { + arr.push(v.trim()); + }); + return arr; + } + + function processAppSingleData(data) { + if (data.state.server && data.state.server.namespaceSet) { + data.state.server.namespaceSetStr = convertSetToString(data.state.server.namespaceSet); + data.mode = data.state.stateInfo.mode; + } + } + + function removeFromArr(arr, v) { + for (let i = 0; i < arr.length; i++) { + if (arr[i] === v) { + arr.splice(i, 1); + break; + } + } + } + + function removeFromArrIf(arr, f) { + for (let i = 0; i < arr.length; i++) { + if (f(arr[i]) === true) { + arr.splice(i, 1); + break; + } + } + } + + function resetAssignDialogChosen() { + $scope.tmp.curClientChosen = []; + $scope.tmp.curRemainingClientChosen = []; + } + + function generateMachineId(e) { + return e.ip + '@' + e.commandPort; + } + + function applyClusterMap(appClusterMachineList) { + if (!appClusterMachineList) { + return; + } + let tmpMap = new Map(); + let serverCommandPortMap = new Map(); + $scope.clusterMap = []; + $scope.remainingMachineList = []; + let tmpServerList = []; + let tmpClientList = []; + appClusterMachineList.forEach((e) => { + if (e.mode === CLUSTER_MODE_CLIENT) { + tmpClientList.push(e); + } else if (e.mode === CLUSTER_MODE_SERVER) { + tmpServerList.push(e); + } else { + $scope.remainingMachineList.push(generateMachineId(e)); + } + }); + tmpServerList.forEach((e) => { + let ip = e.ip; + let machineId = ip + '@' + e.commandPort; + let group = { + ip: ip, + machineId: machineId, + port: e.state.server.port, + clientSet: [], + namespaceSetStr: e.state.server.namespaceSetStr, + maxAllowedQps: e.state.server.flow.maxAllowedQps, + belongToApp: true, + }; + if (!tmpMap.has(machineId)) { + tmpMap.set(machineId, group); + } + serverCommandPortMap.set(ip + ':' + e.state.server.port, e.commandPort); + }); + tmpClientList.forEach((e) => { + let ip = e.ip; + let machineId = ip + '@' + e.commandPort; + + let targetServer = e.state.client.clientConfig.serverHost; + let targetPort = e.state.client.clientConfig.serverPort; + if (targetServer === undefined || targetServer === '' || + targetPort === undefined || targetPort <= 0) { + $scope.remainingMachineList.push(generateMachineId(e)); + return; + } + + let serverHostPort = targetServer + ':' + targetPort; + + if (serverCommandPortMap.has(serverHostPort)) { + let serverCommandPort = serverCommandPortMap.get(serverHostPort); + let g; + if (serverCommandPort < 0) { + // Not belong to this app. + g = tmpMap.get(serverHostPort); + } else { + // Belong to this app. + g = tmpMap.get(targetServer + '@' + serverCommandPort); + } + g.clientSet.push(machineId); + } else { + let group = { + ip: targetServer, + machineId: serverHostPort, + port: targetPort, + clientSet: [machineId], + belongToApp: false, + }; + tmpMap.set(serverHostPort, group); + // Indicates that it's not belonging to current app. + serverCommandPortMap.set(serverHostPort, -1); + } + + // if (!tmpMap.has(serverHostPort)) { + // let group = { + // ip: targetServer, + // machineId: targetServer, + // port: targetPort, + // clientSet: [machineId], + // belongToApp: false, + // }; + // tmpMap.set(targetServer, group); + // } else { + // let g = tmpMap.get(targetServer); + // g.clientSet.push(machineId); + // } + }); + tmpMap.forEach((v) => { + if (v !== undefined) { + $scope.clusterMap.push(v); + } + }); + } + + $scope.notChosenServer = (id) => { + return id !== $scope.serverAssignDialogData.serverData.currentServer; + }; + + $scope.onCurrentServerChange = () => { + resetAssignDialogChosen(); + }; + + $scope.moveToServerGroup = () => { + $scope.tmp.curRemainingClientChosen.forEach(e => { + $scope.serverAssignDialogData.serverData.clientSet.push(e); + removeFromArr($scope.remainingMachineList, e); + }); + resetAssignDialogChosen(); + }; + + $scope.moveToRemainingSharePool = () => { + $scope.tmp.curClientChosen.forEach(e => { + $scope.remainingMachineList.push(e); + removeFromArr($scope.serverAssignDialogData.serverData.clientSet, e); + }); + resetAssignDialogChosen(); + }; + + function parseIpFromMachineId(machineId) { + if (machineId.indexOf(':') !== -1) { + return machineId.split(':')[0]; + } + if (machineId.indexOf('@') === -1) { + return machineId; + } + let arr = machineId.split('@'); + return arr[0]; + } + + function retrieveClusterAssignInfoOfApp() { + ClusterStateService.fetchClusterUniversalStateOfApp($scope.app).success(function (data) { + if (data.code === 0 && data.data) { + $scope.loadError = undefined; + $scope.appClusterMachineList = data.data; + $scope.appClusterMachineList.forEach(processAppSingleData); + applyClusterMap($scope.appClusterMachineList); + } else { + $scope.appClusterMachineList = {}; + if (data.code === UNSUPPORTED_CODE) { + $scope.loadError = {message: '该应用的 Sentinel 客户端不支持集群限流,请升级至 1.4.0 以上版本并引入相关依赖。'} + } else { + $scope.loadError = {message: data.msg}; + } + } + }).error(() => { + $scope.loadError = {message: '未知错误'}; + }); + } + + + $scope.newServerDialog = () => { + retrieveClusterAssignInfoOfApp(); + $scope.serverAssignDialogData = { + title: '新增 Token Server', + type: 'add', + confirmBtnText: '保存', + serverData: { + serverType: 0, + clientSet: [], + serverPort: DEFAULT_CLUSTER_SERVER_PORT, + maxAllowedQps: DEFAULT_MAX_ALLOWED_QPS, + } + }; + $scope.serverAssignDialog = ngDialog.open({ + template: '/app/views/dialog/cluster/cluster-server-assign-dialog.html', + width: 1000, + overlay: true, + scope: $scope + }); + }; + + $scope.modifyServerAssignConfig = (serverVO) => { + let id = serverVO.id; + ClusterStateService.fetchClusterUniversalStateOfApp($scope.app).success(function (data) { + if (data.code === 0 && data.data) { + $scope.loadError = undefined; + $scope.appClusterMachineList = data.data; + $scope.appClusterMachineList.forEach(processAppSingleData); + applyClusterMap($scope.appClusterMachineList); + let clusterMap = $scope.clusterMap; + let d; + for (let i = 0; i < clusterMap.length; i++) { + if (clusterMap[i].machineId === id) { + d = clusterMap[i]; + } + } + if (!d) { + alert('状态错误'); + return; + } + $scope.serverAssignDialogData = { + title: 'Token Server 分配编辑', + type: 'edit', + confirmBtnText: '保存', + serverData: { + currentServer: d.machineId, + belongToApp: serverVO.belongToApp, + serverPort: d.port, + clientSet: d.clientSet, + } + }; + if (d.maxAllowedQps !== undefined) { + $scope.serverAssignDialogData.serverData.maxAllowedQps = d.maxAllowedQps; + } + $scope.serverAssignDialog = ngDialog.open({ + template: '/app/views/dialog/cluster/cluster-server-assign-dialog.html', + width: 1000, + overlay: true, + scope: $scope + }); + } else { + if (data.code === UNSUPPORTED_CODE) { + $scope.loadError = {message: '该应用的 Sentinel 客户端不支持集群限流,请升级至 1.4.0 以上版本并引入相关依赖。'} + } else { + $scope.loadError = {message: data.msg}; + } + } + }).error(() => { + $scope.loadError = {message: '未知错误'}; + }); + }; + + function getRemainingMachineList() { + return $scope.remainingMachineList.filter((e) => $scope.notChosenServer(e)); + } + + function doApplyNewSingleServerAssign() { + let ok = confirm('是否确认执行变更?'); + if (!ok) { + return; + } + let serverData = $scope.serverAssignDialogData.serverData; + let belongToApp = serverData.serverType == 0; // don't modify here! + let machineId = serverData.currentServer; + let request = { + clusterMap: { + machineId: machineId, + ip: parseIpFromMachineId(machineId), + port: serverData.serverPort, + clientSet: serverData.clientSet, + belongToApp: belongToApp, + maxAllowedQps: serverData.maxAllowedQps, + }, + remainingList: getRemainingMachineList(), + }; + ClusterStateService.applyClusterSingleServerAssignOfApp($scope.app, request).success((data) => { + if (data.code === 0 && data.data) { + let failedServerSet = data.data.failedServerSet; + let failedClientSet = data.data.failedClientSet; + if (failedClientSet.length === 0 && failedServerSet.length === 0) { + alert('全部推送成功'); + } else { + let failedSet = []; + if (failedServerSet) { + failedServerSet.forEach((e) => { + failedSet.push(e); + }); + } + if (failedClientSet) { + failedClientSet.forEach((e) => { + failedSet.push(e); + }); + } + + alert('推送完毕。失败机器列表:' + JSON.stringify(failedSet)); + } + + location.reload(); + } else { + if (data.code === UNSUPPORTED_CODE) { + alert('该应用的 Sentinel 客户端不支持集群限流,请升级至 1.4.0 以上版本并引入相关依赖。'); + } else { + alert('推送失败:' + data.msg); + } + } + }).error(() => { + alert('未知错误'); + }); + } + + function doApplySingleServerAssignEdit() { + let ok = confirm('是否确认执行变更?'); + if (!ok) { + return; + } + let serverData = $scope.serverAssignDialogData.serverData; + let machineId = serverData.currentServer; + let request = { + clusterMap: { + machineId: machineId, + ip: parseIpFromMachineId(machineId), + port: serverData.serverPort, + clientSet: serverData.clientSet, + belongToApp: serverData.belongToApp, + }, + remainingList: $scope.remainingMachineList, + }; + if (serverData.maxAllowedQps !== undefined) { + request.clusterMap.maxAllowedQps = serverData.maxAllowedQps; + } + ClusterStateService.applyClusterSingleServerAssignOfApp($scope.app, request).success((data) => { + if (data.code === 0 && data.data) { + let failedServerSet = data.data.failedServerSet; + let failedClientSet = data.data.failedClientSet; + if (failedClientSet.length === 0 && failedServerSet.length === 0) { + alert('全部推送成功'); + } else { + let failedSet = []; + failedServerSet.forEach(failedSet.push); + failedClientSet.forEach(failedSet.push); + alert('推送完毕。失败机器列表:' + JSON.stringify(failedSet)); + } + + location.reload(); + } else { + if (data.code === UNSUPPORTED_CODE) { + alert('该应用的 Sentinel 客户端不支持集群限流,请升级至 1.4.0 以上版本并引入相关依赖。'); + } else { + alert('推送失败:' + data.msg); + } + } + }).error(() => { + alert('未知错误'); + }); + } + + $scope.saveAssignForDialog = () => { + if (!checkAssignDialogValid()) { + return; + } + if ($scope.serverAssignDialogData.type === 'add') { + doApplyNewSingleServerAssign(); + } else if ($scope.serverAssignDialogData.type === 'edit') { + doApplySingleServerAssignEdit(); + } else { + alert('未知的操作'); + } + }; + + function checkAssignDialogValid() { + let serverData = $scope.serverAssignDialogData.serverData; + if (serverData.currentServer === undefined || serverData.currentServer === '') { + alert('请指定有效的 Token Server'); + return false; + } + if (serverData.serverPort === undefined || serverData.serverPort <= 0 || serverData.serverPort > 65535) { + alert('请输入合法的端口值'); + return false; + } + if (serverData.maxAllowedQps !== undefined && serverData.maxAllowedQps < 0) { + alert('请输入合法的最大允许 QPS'); + return false; + } + return true; + } + + $scope.viewConnectionDetail = (serverVO) => { + $scope.connectionDetailDialogData = { + serverData: serverVO + }; + $scope.connectionDetailDialog = ngDialog.open({ + template: '/app/views/dialog/cluster/cluster-server-connection-detail-dialog.html', + width: 700, + overlay: true, + scope: $scope + }); + }; + + function generateRequestLimitDataStr(limitData) { + if (limitData.length === 1 && limitData[0].namespace === DEFAULT_NAMESPACE) { + return 'default: ' + limitData[0].currentQps + ' / ' + limitData[0].maxAllowedQps; + } + for (let i = 0; i < limitData.length; i++) { + let crl = limitData[i]; + if (crl.namespace === $scope.app) { + return '' + crl.currentQps + ' / ' + crl.maxAllowedQps; + } + } + return '0'; + } + + function processServerListData(serverVO) { + if (serverVO.state && serverVO.state.namespaceSet) { + serverVO.state.namespaceSetStr = convertSetToString(serverVO.state.namespaceSet); + } + if (serverVO.state && serverVO.state.requestLimitData) { + serverVO.state.requestLimitDataStr = generateRequestLimitDataStr(serverVO.state.requestLimitData); + } + } + + $scope.generateConnectionSet = (data) => { + let connectionSet = data; + let s = ''; + if (connectionSet) { + s = s + '['; + for (let i = 0; i < connectionSet.length; i++) { + s = s + connectionSet[i].address; + if (i < connectionSet.length - 1) { + s = s + ', '; + } + } + s = s + ']'; + } else { + s = '[]'; + } + return s; + }; + + function retrieveClusterServerInfo() { + ClusterStateService.fetchClusterServerStateOfApp($scope.app).success(function (data) { + if (data.code === 0 && data.data) { + $scope.loadError = undefined; + $scope.serverVOList = data.data; + $scope.serverVOList.forEach(processServerListData); + } else { + $scope.serverVOList = {}; + if (data.code === UNSUPPORTED_CODE) { + $scope.loadError = {message: '该应用的 Sentinel 客户端不支持集群限流,请升级至 1.4.0 以上版本并引入相关依赖。'} + } else { + $scope.loadError = {message: data.msg}; + } + } + }).error(() => { + $scope.loadError = {message: '未知错误'}; + }); + } + + retrieveClusterServerInfo(); + + let confirmUnbindServerDialog; + $scope.unbindServer = (id) => { + $scope.pendingUnbindIds = [id]; + $scope.confirmDialog = { + title: '移除 Token Server', + type: 'unbind_token_server', + attentionTitle: '请确认是否移除以下 Token Server(该 server 下的 client 也会解除分配)', + attention: id + '', + confirmBtnText: '移除', + }; + confirmUnbindServerDialog = ngDialog.open({ + template: '/app/views/dialog/confirm-dialog.html', + scope: $scope, + overlay: true + }); + }; + + function apiUnbindServerAssign(ids) { + ClusterStateService.applyClusterServerBatchUnbind($scope.app, ids).success((data) => { + if (data.code === 0 && data.data) { + let failedServerSet = data.data.failedServerSet; + let failedClientSet = data.data.failedClientSet; + if (failedClientSet.length === 0 && failedServerSet.length === 0) { + alert('成功'); + } else { + alert('操作推送完毕,部分失败机器列表:' + JSON.stringify(failedClientSet)); + } + + location.reload(); + } else { + if (data.code === UNSUPPORTED_CODE) { + alert('该应用的 Sentinel 客户端不支持集群限流,请升级至 1.4.0 以上版本并引入相关依赖。'); + } else { + alert('推送失败:' + data.msg); + } + } + }).error(() => { + alert('未知错误'); + }); + // confirmUnbindServerDialog.close(); + } + + // Confirm function for confirm dialog. + $scope.confirm = () => { + if ($scope.confirmDialog.type === 'unbind_token_server') { + apiUnbindServerAssign($scope.pendingUnbindIds); + } else { + console.error('Error dialog when unbinding token server'); + } + }; + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_app_server_manage.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_app_server_manage.js new file mode 100755 index 00000000..6f9367d6 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_app_server_manage.js @@ -0,0 +1,283 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('SentinelClusterAppAssignManageController', ['$scope', '$stateParams', 'ngDialog', + 'MachineService', 'ClusterStateService', + function ($scope, $stateParams, ngDialog, MachineService, ClusterStateService) { + $scope.app = $stateParams.app; + const UNSUPPORTED_CODE = 4041; + + const CLUSTER_MODE_CLIENT = 0; + const CLUSTER_MODE_SERVER = 1; + const DEFAULT_CLUSTER_SERVER_PORT = 18730; + + $scope.tmp = { + curClientChosen: [], + curRemainingClientChosen: [], + curChosenServer: {}, + }; + + function convertSetToString(set) { + if (set === undefined) { + return ''; + } + let s = ''; + for (let i = 0; i < set.length; i++) { + s = s + set[i]; + if (i < set.length - 1) { + s = s + ','; + } + } + return s; + } + + function convertStrToNamespaceSet(str) { + if (str === undefined || str === '') { + return []; + } + let arr = []; + let spliced = str.split(','); + spliced.forEach((v) => { + arr.push(v.trim()); + }); + return arr; + } + + function processAppSingleData(data) { + if (data.state.server && data.state.server.namespaceSet) { + data.state.server.namespaceSetStr = convertSetToString(data.state.server.namespaceSet); + data.mode = data.state.stateInfo.mode; + } + } + + function removeFromArr(arr, v) { + for (let i = 0; i < arr.length; i++) { + if (arr[i] === v) { + arr.splice(i, 1); + break; + } + } + } + + function resetChosen() { + $scope.tmp.curClientChosen = []; + $scope.tmp.curRemainingClientChosen = []; + } + + function generateMachineId(e) { + return e.ip + '@' + e.commandPort; + } + + function applyClusterMap(appClusterMachineList) { + if (!appClusterMachineList) { + return; + } + let tmpMap = new Map(); + $scope.clusterMap = []; + $scope.remainingClientAddressList = []; + let tmpServerList = []; + let tmpClientList = []; + appClusterMachineList.forEach((e) => { + if (e.mode === CLUSTER_MODE_CLIENT) { + tmpClientList.push(e); + } else if (e.mode === CLUSTER_MODE_SERVER) { + tmpServerList.push(e); + } else { + $scope.remainingClientAddressList.push(generateMachineId(e)); + } + }); + tmpServerList.forEach((e) => { + let ip = e.ip; + let machineId = ip + '@' + e.commandPort; + let group = { + ip: ip, + machineId: machineId, + port: e.state.server.port, + clientSet: [], + namespaceSetStr: e.state.server.namespaceSetStr, + belongToApp: true, + }; + if (!tmpMap.has(ip)) { + tmpMap.set(ip, group); + } + }); + tmpClientList.forEach((e) => { + let ip = e.ip; + let machineId = ip + '@' + e.commandPort; + + let targetServer = e.state.client.clientConfig.serverHost; + let targetPort = e.state.client.clientConfig.serverPort; + if (targetServer === undefined || targetServer === '' || + targetPort === undefined || targetPort <= 0) { + $scope.remainingClientAddressList.push(generateMachineId(e)); + return; + } + + if (!tmpMap.has(targetServer)) { + let group = { + ip: targetServer, + machineId: targetServer, + port: targetPort, + clientSet: [machineId], + belongToApp: false, + }; + tmpMap.set(targetServer, group); + } else { + let g = tmpMap.get(targetServer); + g.clientSet.push(machineId); + } + }); + tmpMap.forEach((v) => { + if (v !== undefined) { + $scope.clusterMap.push(v); + } + }); + } + + $scope.onCurrentServerChange = () => { + resetChosen(); + }; + + $scope.remainingClientAddressList = []; + + $scope.moveToServerGroup = () => { + let chosenServer = $scope.tmp.curChosenServer; + if (!chosenServer || !chosenServer.machineId) { + return; + } + $scope.tmp.curRemainingClientChosen.forEach(e => { + chosenServer.clientSet.push(e); + removeFromArr($scope.remainingClientAddressList, e); + }); + resetChosen(); + }; + + $scope.moveToRemainingSharePool = () => { + $scope.tmp.curClientChosen.forEach(e => { + $scope.remainingClientAddressList.push(e); + removeFromArr($scope.tmp.curChosenServer.clientSet, e); + }); + resetChosen(); + }; + + function parseIpFromMachineId(machineId) { + if (machineId.indexOf('@') === -1) { + return machineId; + } + let arr = machineId.split('@'); + return arr[0]; + } + + $scope.addToServerList = () => { + let group; + $scope.tmp.curRemainingClientChosen.forEach(e => { + group = { + machineId: e, + ip: parseIpFromMachineId(e), + port: DEFAULT_CLUSTER_SERVER_PORT, + clientSet: [], + namespaceSetStr: 'default,' + $scope.app, + belongToApp: true, + }; + $scope.clusterMap.push(group); + removeFromArr($scope.remainingClientAddressList, e); + $scope.tmp.curChosenServer = group; + }); + resetChosen(); + }; + + $scope.removeFromServerList = () => { + let chosenServer = $scope.tmp.curChosenServer; + if (!chosenServer || !chosenServer.machineId) { + return; + } + chosenServer.clientSet.forEach((e) => { + if (e !== undefined) { + $scope.remainingClientAddressList.push(e); + } + }); + + if (chosenServer.belongToApp || chosenServer.machineId.indexOf('@') !== -1) { + $scope.remainingClientAddressList.push(chosenServer.machineId); + } else { + alert('提示:非本应用内机器将不会置回空闲列表中'); + } + + removeFromArr($scope.clusterMap, chosenServer); + + resetChosen(); + + if ($scope.clusterMap.length > 0) { + $scope.tmp.curChosenServer = $scope.clusterMap[0]; + $scope.onCurrentServerChange(); + } else { + $scope.tmp.curChosenServer = {}; + } + }; + + function retrieveClusterAppInfo() { + ClusterStateService.fetchClusterUniversalStateOfApp($scope.app).success(function (data) { + if (data.code === 0 && data.data) { + $scope.loadError = undefined; + $scope.appClusterMachineList = data.data; + $scope.appClusterMachineList.forEach(processAppSingleData); + applyClusterMap($scope.appClusterMachineList); + if ($scope.clusterMap.length > 0) { + $scope.tmp.curChosenServer = $scope.clusterMap[0]; + $scope.onCurrentServerChange(); + } + } else { + $scope.appClusterMachineList = {}; + if (data.code === UNSUPPORTED_CODE) { + $scope.loadError = {message: '该应用的 Sentinel 客户端不支持集群限流,请升级至 1.4.0 以上版本并引入相关依赖。'} + } else { + $scope.loadError = {message: data.msg}; + } + } + }).error(() => { + $scope.loadError = {message: '未知错误'}; + }); + } + + retrieveClusterAppInfo(); + + $scope.saveAndApplyAssign = () => { + let ok = confirm('是否确认执行变更?'); + if (!ok) { + return; + } + let cm = $scope.clusterMap; + if (!cm) { + cm = []; + } + cm.forEach((e) => { + e.namespaceSet = convertStrToNamespaceSet(e.namespaceSetStr); + }); + cm.namespaceSet = convertStrToNamespaceSet(cm.namespaceSetStr); + let request = { + clusterMap: cm, + remainingList: $scope.remainingClientAddressList, + }; + ClusterStateService.applyClusterFullAssignOfApp($scope.app, request).success((data) => { + if (data.code === 0 && data.data) { + let failedServerSet = data.data.failedServerSet; + let failedClientSet = data.data.failedClientSet; + if (failedClientSet.length === 0 && failedServerSet.length === 0) { + alert('全部推送成功'); + } else { + alert('推送完毕。token server 失败列表:' + JSON.stringify(failedServerSet) + + '; token client 失败列表:' + JSON.stringify(failedClientSet)); + } + + retrieveClusterAppInfo(); + } else { + if (data.code === UNSUPPORTED_CODE) { + alert('该应用的 Sentinel 客户端不支持集群限流,请升级至 1.4.0 以上版本并引入相关依赖。'); + } else { + alert('推送失败:' + data.msg); + } + } + }).error(() => { + alert('未知错误'); + }); + }; + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_app_server_monitor.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_app_server_monitor.js new file mode 100755 index 00000000..202fca1b --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_app_server_monitor.js @@ -0,0 +1,97 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('SentinelClusterAppServerMonitorController', ['$scope', '$stateParams', 'ngDialog', + 'MachineService', 'ClusterStateService', + function ($scope, $stateParams, ngDialog, MachineService, ClusterStateService) { + $scope.app = $stateParams.app; + const UNSUPPORTED_CODE = 4041; + + const CLUSTER_MODE_SERVER = 1; + + $scope.tmp = { + curChosenServer: {}, + }; + + function convertSetToString(set) { + if (set === undefined) { + return ''; + } + let s = ''; + for (let i = 0; i < set.length; i++) { + s = s + set[i]; + if (i < set.length - 1) { + s = s + ','; + } + } + return s; + } + + function processServerData(serverVO) { + if (serverVO.state && serverVO.state.namespaceSet) { + serverVO.state.namespaceSetStr = convertSetToString(serverVO.state.namespaceSet); + } + } + + $scope.generateConnectionSet = (data) => { + let connectionSet = data; + let s = ''; + if (connectionSet) { + s = s + '['; + for (let i = 0; i < connectionSet.length; i++) { + s = s + connectionSet[i].address; + if (i < connectionSet.length - 1) { + s = s + ', '; + } + } + s = s + ']'; + } else { + s = '[]'; + } + return s; + }; + + $scope.onChosenServerChange = () => { + + }; + + function retrieveClusterServerInfo() { + ClusterStateService.fetchClusterServerStateOfApp($scope.app).success(function (data) { + if (data.code === 0 && data.data) { + $scope.loadError = undefined; + $scope.serverVOList = data.data; + $scope.serverVOList.forEach(processServerData); + + if ($scope.serverVOList.length > 0) { + $scope.tmp.curChosenServer = $scope.serverVOList[0]; + $scope.onChosenServerChange(); + } + } else { + $scope.serverVOList = {}; + if (data.code === UNSUPPORTED_CODE) { + $scope.loadError = {message: '该应用的 Sentinel 客户端不支持集群限流,请升级至 1.4.0 以上版本并引入相关依赖。'} + } else { + $scope.loadError = {message: data.msg}; + } + } + }).error(() => { + $scope.loadError = {message: '未知错误'}; + }); + } + + retrieveClusterServerInfo(); + + $scope.macsInputConfig = { + searchField: ['text', 'value'], + persist: true, + create: false, + maxItems: 1, + render: { + item: function (data, escape) { + return '
' + escape(data.text) + '
'; + } + }, + onChange: function (value, oldValue) { + $scope.macInputModel = value; + } + }; + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_app_token_client_list.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_app_token_client_list.js new file mode 100755 index 00000000..177161b8 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_app_token_client_list.js @@ -0,0 +1,121 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('SentinelClusterAppTokenClientListController', ['$scope', '$stateParams', 'ngDialog', + 'MachineService', 'ClusterStateService', + function ($scope, $stateParams, ngDialog, MachineService, ClusterStateService) { + $scope.app = $stateParams.app; + + const UNSUPPORTED_CODE = 4041; + const CLUSTER_MODE_CLIENT = 0; + const CLUSTER_MODE_SERVER = 1; + + function processClientData(clientVO) { + + } + + $scope.modifyClientConfigDialog = (clientVO) => { + if (!clientVO) { + return; + } + $scope.ccDialogData = { + ip: clientVO.ip, + commandPort: clientVO.commandPort, + clientId: clientVO.id, + serverHost: clientVO.state.clientConfig.serverHost, + serverPort: clientVO.state.clientConfig.serverPort, + requestTimeout: clientVO.state.clientConfig.requestTimeout, + }; + $scope.ccDialog = ngDialog.open({ + template: '/app/views/dialog/cluster/cluster-client-config-dialog.html', + width: 700, + overlay: true, + scope: $scope + }); + }; + + function checkValidClientConfig(config) { + if (!config.serverHost || config.serverHost.trim() == '') { + alert('请输入有效的 Token Server IP'); + return false; + } + if (config.serverPort === undefined || config.serverPort <= 0 || config.serverPort > 65535) { + alert('请输入有效的 Token Server 端口'); + return false; + } + if (config.requestTimeout === undefined || config.requestTimeout <= 0) { + alert('请输入有效的请求超时时长'); + return false; + } + return true; + } + + $scope.doModifyClientConfig = () => { + if (!checkValidClientConfig($scope.ccDialogData)) { + return; + } + let id = $scope.ccDialogData.id; + let request = { + app: $scope.app, + ip: $scope.ccDialogData.ip, + port: $scope.ccDialogData.commandPort, + mode: CLUSTER_MODE_CLIENT, + clientConfig: { + serverHost: $scope.ccDialogData.serverHost, + serverPort: $scope.ccDialogData.serverPort, + requestTimeout: $scope.ccDialogData.requestTimeout, + } + }; + ClusterStateService.modifyClusterConfig(request).success((data) => { + if (data.code === 0 && data.data) { + alert('修改 Token Client 配置成功'); + window.location.reload(); + } else { + if (data.code === UNSUPPORTED_CODE) { + alert('机器 ' + id + ' 的 Sentinel 没有引入集群限流客户端,请升级至 1.4.0 以上版本并引入相关依赖。'); + } else { + alert('修改失败:' + data.msg); + } + } + }).error((data, header, config, status) => { + alert('未知错误'); + }); + }; + + function retrieveClusterTokenClientInfo() { + ClusterStateService.fetchClusterClientStateOfApp($scope.app) + .success((data) => { + if (data.code === 0 && data.data) { + $scope.loadError = undefined; + $scope.clientVOList = data.data; + $scope.clientVOList.forEach(processClientData); + } else { + $scope.clientVOList = []; + if (data.code === UNSUPPORTED_CODE) { + $scope.loadError = {message: '该应用的 Sentinel 客户端不支持集群限流,请升级至 1.4.0 以上版本并引入相关依赖。'} + } else { + $scope.loadError = {message: data.msg}; + } + } + }) + .error(() => { + $scope.loadError = {message: '未知错误'}; + }); + } + + retrieveClusterTokenClientInfo(); + + $scope.macsInputConfig = { + searchField: ['text', 'value'], + persist: true, + create: false, + maxItems: 1, + render: { + item: function (data, escape) { + return '
' + escape(data.text) + '
'; + } + }, + onChange: function (value, oldValue) { + $scope.macInputModel = value; + } + }; + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_single.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_single.js new file mode 100755 index 00000000..7392229d --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/cluster_single.js @@ -0,0 +1,262 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('SentinelClusterSingleController', ['$scope', '$stateParams', 'ngDialog', + 'MachineService', 'ClusterStateService', + function ($scope, $stateParams, ngDialog, MachineService, ClusterStateService) { + $scope.app = $stateParams.app; + const UNSUPPORTED_CODE = 4041; + + const CLUSTER_MODE_CLIENT = 0; + const CLUSTER_MODE_SERVER = 1; + + $scope.macsInputConfig = { + searchField: ['text', 'value'], + persist: true, + create: false, + maxItems: 1, + render: { + item: function (data, escape) { + return '
' + escape(data.text) + '
'; + } + }, + onChange: function (value, oldValue) { + $scope.macInputModel = value; + } + }; + + function convertSetToString(set) { + if (set === undefined) { + return ''; + } + let s = ''; + for (let i = 0; i < set.length; i++) { + s = s + set[i]; + if (i < set.length - 1) { + s = s + ','; + } + } + return s; + } + + function convertStrToNamespaceSet(str) { + if (str === undefined || str === '') { + return []; + } + let arr = []; + let spliced = str.split(','); + spliced.forEach((v) => { + arr.push(v.trim()); + }); + return arr; + } + + function fetchMachineClusterState() { + if (!$scope.macInputModel || $scope.macInputModel === '') { + return; + } + let mac = $scope.macInputModel.split(':'); + ClusterStateService.fetchClusterUniversalStateSingle($scope.app, mac[0], mac[1]).success(function (data) { + if (data.code == 0 && data.data) { + $scope.loadError = undefined; + $scope.stateVO = data.data; + $scope.stateVO.currentMode = $scope.stateVO.stateInfo.mode; + if ($scope.stateVO.server && $scope.stateVO.server.namespaceSet) { + $scope.stateVO.server.namespaceSetStr = convertSetToString($scope.stateVO.server.namespaceSet); + } + } else { + $scope.stateVO = {}; + if (data.code === UNSUPPORTED_CODE) { + $scope.loadError = {message: '机器 ' + mac[0] + ':' + mac[1] + ' 的 Sentinel 客户端版本不支持集群限流,请升级至 1.4.0 以上版本并引入相关依赖。'} + } else { + $scope.loadError = {message: data.msg}; + } + } + }).error((data, header, config, status) => { + $scope.loadError = {message: '未知错误'}; + }); + } + + fetchMachineClusterState(); + + function checkValidClientConfig(stateVO) { + if (!stateVO.client || !stateVO.client.clientConfig) { + alert('不合法的配置'); + return false; + } + let config = stateVO.client.clientConfig; + if (!config.serverHost || config.serverHost.trim() == '') { + alert('请输入有效的 Token Server IP'); + return false; + } + if (config.serverPort === undefined || config.serverPort <= 0 || config.serverPort > 65535) { + alert('请输入有效的 Token Server 端口'); + return false; + } + if (config.requestTimeout === undefined || config.requestTimeout <= 0) { + alert('请输入有效的请求超时时长'); + return false; + } + return true; + } + + function sendClusterClientRequest(stateVO) { + if (!checkValidClientConfig(stateVO)) { + return; + } + if (!$scope.macInputModel) { + return; + } + let mac = $scope.macInputModel.split(':'); + let request = { + app: $scope.app, + ip: mac[0], + port: mac[1], + }; + request.mode = CLUSTER_MODE_CLIENT; + request.clientConfig = stateVO.client.clientConfig; + ClusterStateService.modifyClusterConfig(request).success(function (data) { + if (data.code == 0 && data.data) { + alert('修改集群限流客户端配置成功'); + window.location.reload(); + } else { + if (data.code === UNSUPPORTED_CODE) { + alert('机器 ' + mac[0] + ':' + mac[1] + ' 的 Sentinel 客户端版本不支持集群限流客户端,请升级至 1.4.0 以上版本并引入相关依赖。'); + } else { + alert('修改失败:' + data.msg); + } + } + }).error((data, header, config, status) => { + alert('未知错误'); + }); + } + + function checkValidServerConfig(stateVO) { + if (!stateVO.server || !stateVO.server.transport) { + alert('不合法的配置'); + return false; + } + if (stateVO.server.namespaceSetStr === undefined || stateVO.server.namespaceSetStr == '') { + alert('请输入有效的命名空间集合(多个 namespace 以 , 分隔)'); + return false; + } + let transportConfig = stateVO.server.transport; + if (transportConfig.port === undefined || transportConfig.port <= 0 || transportConfig.port > 65535) { + alert('请输入有效的 Token Server 端口'); + return false; + } + let flowConfig = stateVO.server.flow; + if (flowConfig.maxAllowedQps === undefined || flowConfig.maxAllowedQps < 0) { + alert('请输入有效的最大允许 QPS'); + return false; + } + // if (transportConfig.idleSeconds === undefined || transportConfig.idleSeconds <= 0) { + // alert('请输入有效的连接清理时长 (idleSeconds)'); + // return false; + // } + return true; + } + + function sendClusterServerRequest(stateVO) { + if (!checkValidServerConfig(stateVO)) { + return; + } + if (!$scope.macInputModel) { + return; + } + let mac = $scope.macInputModel.split(':'); + let request = { + app: $scope.app, + ip: mac[0], + port: mac[1], + }; + request.mode = CLUSTER_MODE_SERVER; + request.flowConfig = stateVO.server.flow; + request.transportConfig = stateVO.server.transport; + request.namespaceSet = convertStrToNamespaceSet(stateVO.server.namespaceSetStr); + ClusterStateService.modifyClusterConfig(request).success(function (data) { + if (data.code == 0 && data.data) { + alert('修改集群限流服务端配置成功'); + window.location.reload(); + } else { + if (data.code === UNSUPPORTED_CODE) { + alert('机器 ' + mac[0] + ':' + mac[1] + ' 的 Sentinel 客户端版本不支持集群限流服务端,请升级至 1.4.0 以上版本并引入相关依赖。'); + } else { + alert('修改失败:' + data.msg); + } + } + }).error((data, header, config, status) => { + alert('未知错误'); + }); + } + + + $scope.saveConfig = () => { + let ok = confirm('是否确定修改集群限流配置?'); + if (!ok) { + return; + } + let mode = $scope.stateVO.stateInfo.mode; + if (mode != 1 && mode != 0) { + alert('未知的集群限流模式'); + return; + } + if (mode == 0) { + sendClusterClientRequest($scope.stateVO); + } else { + sendClusterServerRequest($scope.stateVO); + } + }; + + function queryAppMachines() { + MachineService.getAppMachines($scope.app).success( + function (data) { + if (data.code === 0) { + // $scope.machines = data.data; + if (data.data) { + $scope.machines = []; + $scope.macsInputOptionsOrigin = []; + $scope.macsInputOptions = []; + data.data.forEach(function (item) { + if (item.healthy) { + $scope.macsInputOptionsOrigin.push({ + text: item.ip + ':' + item.port, + value: item.ip + ':' + item.port + }); + } + }); + $scope.macsInputOptions = $scope.macsInputOptionsOrigin; + } + if ($scope.macsInputOptions.length > 0) { + $scope.macInputModel = $scope.macsInputOptions[0].value; + } + } else { + $scope.macsInputOptions = []; + } + } + ); + } + queryAppMachines(); + + $scope.$watch('searchKey', function () { + if (!$scope.macsInputOptions) { + return; + } + if ($scope.searchKey) { + $scope.macsInputOptions = $scope.macsInputOptionsOrigin + .filter((e) => e.value.indexOf($scope.searchKey) !== -1); + } else { + $scope.macsInputOptions = $scope.macsInputOptionsOrigin; + } + if ($scope.macsInputOptions.length > 0) { + $scope.macInputModel = $scope.macsInputOptions[0].value; + } else { + $scope.macInputModel = ''; + } + }); + + $scope.$watch('macInputModel', function () { + if ($scope.macInputModel) { + fetchMachineClusterState(); + } + }); + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/degrade.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/degrade.js new file mode 100755 index 00000000..8a05323e --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/degrade.js @@ -0,0 +1,202 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('DegradeCtl', ['$scope', '$stateParams', 'DegradeService', 'ngDialog', 'MachineService', + function ($scope, $stateParams, DegradeService, ngDialog, MachineService) { + //初始化 + $scope.app = $stateParams.app; + $scope.rulesPageConfig = { + pageSize: 10, + currentPageIndex: 1, + totalPage: 1, + totalCount: 0, + }; + $scope.macsInputConfig = { + searchField: ['text', 'value'], + persist: true, + create: false, + maxItems: 1, + render: { + item: function (data, escape) { + return '
' + escape(data.text) + '
'; + } + }, + onChange: function (value, oldValue) { + $scope.macInputModel = value; + } + }; + getMachineRules(); + function getMachineRules() { + if (!$scope.macInputModel) { + return; + } + var mac = $scope.macInputModel.split(':'); + DegradeService.queryMachineRules($scope.app, mac[0], mac[1]).success( + function (data) { + if (data.code == 0 && data.data) { + $scope.rules = data.data; + $scope.rulesPageConfig.totalCount = $scope.rules.length; + } else { + $scope.rules = []; + $scope.rulesPageConfig.totalCount = 0; + } + }); + }; + $scope.getMachineRules = getMachineRules; + + var degradeRuleDialog; + $scope.editRule = function (rule) { + $scope.currentRule = angular.copy(rule); + $scope.degradeRuleDialog = { + title: '编辑降级规则', + type: 'edit', + confirmBtnText: '保存' + }; + degradeRuleDialog = ngDialog.open({ + template: '/app/views/dialog/degrade-rule-dialog.html', + width: 680, + overlay: true, + scope: $scope + }); + }; + + $scope.addNewRule = function () { + var mac = $scope.macInputModel.split(':'); + $scope.currentRule = { + grade: 0, + app: $scope.app, + ip: mac[0], + port: mac[1], + limitApp: 'default' + }; + $scope.degradeRuleDialog = { + title: '新增降级规则', + type: 'add', + confirmBtnText: '新增' + }; + degradeRuleDialog = ngDialog.open({ + template: '/app/views/dialog/degrade-rule-dialog.html', + width: 680, + overlay: true, + scope: $scope + }); + }; + + $scope.saveRule = function () { + if (!DegradeService.checkRuleValid($scope.currentRule)) { + return; + } + if ($scope.degradeRuleDialog.type === 'add') { + addNewRule($scope.currentRule); + } else if ($scope.degradeRuleDialog.type === 'edit') { + saveRule($scope.currentRule, true); + } + }; + + function parseDegradeMode(grade) { + switch (grade) { + case 0: + return 'RT'; + case 1: + return '异常比例'; + case 2: + return '异常数'; + default: + return '未知'; + } + } + + var confirmDialog; + $scope.deleteRule = function (rule) { + $scope.currentRule = rule; + $scope.confirmDialog = { + title: '删除降级规则', + type: 'delete_rule', + attentionTitle: '请确认是否删除如下降级规则', + attention: '资源名: ' + rule.resource + + ', 降级模式: ' + parseDegradeMode(rule.grade) + ', 阈值: ' + rule.count, + confirmBtnText: '删除', + }; + confirmDialog = ngDialog.open({ + template: '/app/views/dialog/confirm-dialog.html', + scope: $scope, + overlay: true + }); + }; + + $scope.confirm = function () { + if ($scope.confirmDialog.type == 'delete_rule') { + deleteRule($scope.currentRule); + } else { + console.error('error'); + } + }; + + function deleteRule(rule) { + DegradeService.deleteRule(rule).success(function (data) { + if (data.code == 0) { + getMachineRules(); + confirmDialog.close(); + } else { + alert('失败!'); + } + }); + }; + + function addNewRule(rule) { + DegradeService.newRule(rule).success(function (data) { + if (data.code == 0) { + getMachineRules(); + degradeRuleDialog.close(); + } else { + alert('失败!'); + } + }); + }; + + function saveRule(rule, edit) { + DegradeService.saveRule(rule).success(function (data) { + if (data.code == 0) { + getMachineRules(); + if (edit) { + degradeRuleDialog.close(); + } else { + confirmDialog.close(); + } + } else { + alert('失败!'); + } + }); + } + queryAppMachines(); + function queryAppMachines() { + MachineService.getAppMachines($scope.app).success( + function (data) { + if (data.code == 0) { + // $scope.machines = data.data; + if (data.data) { + $scope.machines = []; + $scope.macsInputOptions = []; + data.data.forEach(function (item) { + if (item.healthy) { + $scope.macsInputOptions.push({ + text: item.ip + ':' + item.port, + value: item.ip + ':' + item.port + }); + } + }); + } + if ($scope.macsInputOptions.length > 0) { + $scope.macInputModel = $scope.macsInputOptions[0].value; + } + } else { + $scope.macsInputOptions = []; + } + } + ); + }; + $scope.$watch('macInputModel', function () { + if ($scope.macInputModel) { + getMachineRules(); + } + }); + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/flow_v1.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/flow_v1.js new file mode 100755 index 00000000..3c644937 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/flow_v1.js @@ -0,0 +1,220 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('FlowControllerV1', ['$scope', '$stateParams', 'FlowServiceV1', 'ngDialog', + 'MachineService', + function ($scope, $stateParams, FlowService, ngDialog, + MachineService) { + $scope.app = $stateParams.app; + + $scope.rulesPageConfig = { + pageSize: 10, + currentPageIndex: 1, + totalPage: 1, + totalCount: 0, + }; + $scope.macsInputConfig = { + searchField: ['text', 'value'], + persist: true, + create: false, + maxItems: 1, + render: { + item: function (data, escape) { + return '
' + escape(data.text) + '
'; + } + }, + onChange: function (value, oldValue) { + $scope.macInputModel = value; + } + }; + + $scope.generateThresholdTypeShow = (rule) => { + if (!rule.clusterMode) { + return '单机'; + } + if (rule.clusterConfig.thresholdType === 0) { + return '集群均摊'; + } else if (rule.clusterConfig.thresholdType === 1) { + return '集群总体'; + } else { + return '集群'; + } + }; + + getMachineRules(); + function getMachineRules() { + if (!$scope.macInputModel) { + return; + } + var mac = $scope.macInputModel.split(':'); + FlowService.queryMachineRules($scope.app, mac[0], mac[1]).success( + function (data) { + if (data.code == 0 && data.data) { + $scope.rules = data.data; + $scope.rulesPageConfig.totalCount = $scope.rules.length; + } else { + $scope.rules = []; + $scope.rulesPageConfig.totalCount = 0; + } + }); + }; + $scope.getMachineRules = getMachineRules; + + var flowRuleDialog; + $scope.editRule = function (rule) { + $scope.currentRule = angular.copy(rule); + $scope.flowRuleDialog = { + title: '编辑流控规则', + type: 'edit', + confirmBtnText: '保存', + showAdvanceButton: rule.controlBehavior == 0 && rule.strategy == 0 + }; + flowRuleDialog = ngDialog.open({ + template: '/app/views/dialog/flow-rule-dialog.html', + width: 680, + overlay: true, + scope: $scope + }); + }; + + $scope.addNewRule = function () { + var mac = $scope.macInputModel.split(':'); + $scope.currentRule = { + grade: 1, + strategy: 0, + controlBehavior: 0, + app: $scope.app, + ip: mac[0], + port: mac[1], + limitApp: 'default', + clusterMode: false, + clusterConfig: { + thresholdType: 0 + } + }; + $scope.flowRuleDialog = { + title: '新增流控规则', + type: 'add', + confirmBtnText: '新增', + showAdvanceButton: true, + }; + flowRuleDialog = ngDialog.open({ + template: '/app/views/dialog/flow-rule-dialog.html', + width: 680, + overlay: true, + scope: $scope + }); + }; + + $scope.saveRule = function () { + if (!FlowService.checkRuleValid($scope.currentRule)) { + return; + } + if ($scope.flowRuleDialog.type === 'add') { + addNewRule($scope.currentRule); + } else if ($scope.flowRuleDialog.type === 'edit') { + saveRule($scope.currentRule, true); + } + }; + + var confirmDialog; + $scope.deleteRule = function (rule) { + $scope.currentRule = rule; + $scope.confirmDialog = { + title: '删除流控规则', + type: 'delete_rule', + attentionTitle: '请确认是否删除如下流控规则', + attention: '资源名: ' + rule.resource + ', 流控应用: ' + rule.limitApp + + ', 阈值类型: ' + (rule.grade == 0 ? '线程数' : 'QPS') + ', 阈值: ' + rule.count, + confirmBtnText: '删除', + }; + confirmDialog = ngDialog.open({ + template: '/app/views/dialog/confirm-dialog.html', + scope: $scope, + overlay: true + }); + }; + + $scope.confirm = function () { + if ($scope.confirmDialog.type === 'delete_rule') { + deleteRule($scope.currentRule); + } else { + console.error('error'); + } + }; + + function deleteRule(rule) { + FlowService.deleteRule(rule).success(function (data) { + if (data.code == 0) { + getMachineRules(); + confirmDialog.close(); + } else { + alert('失败:' + data.msg); + } + }); + }; + + function addNewRule(rule) { + FlowService.newRule(rule).success(function (data) { + if (data.code === 0) { + getMachineRules(); + flowRuleDialog.close(); + } else { + alert('失败:' + data.msg); + } + }); + }; + + $scope.onOpenAdvanceClick = function () { + $scope.flowRuleDialog.showAdvanceButton = false; + }; + $scope.onCloseAdvanceClick = function () { + $scope.flowRuleDialog.showAdvanceButton = true; + }; + + function saveRule(rule, edit) { + FlowService.saveRule(rule).success(function (data) { + if (data.code === 0) { + getMachineRules(); + if (edit) { + flowRuleDialog.close(); + } else { + confirmDialog.close(); + } + } else { + alert('失败:' + data.msg); + } + }); + } + queryAppMachines(); + function queryAppMachines() { + MachineService.getAppMachines($scope.app).success( + function (data) { + if (data.code == 0) { + // $scope.machines = data.data; + if (data.data) { + $scope.machines = []; + $scope.macsInputOptions = []; + data.data.forEach(function (item) { + if (item.healthy) { + $scope.macsInputOptions.push({ + text: item.ip + ':' + item.port, + value: item.ip + ':' + item.port + }); + } + }); + } + if ($scope.macsInputOptions.length > 0) { + $scope.macInputModel = $scope.macsInputOptions[0].value; + } + } else { + $scope.macsInputOptions = []; + } + } + ); + }; + $scope.$watch('macInputModel', function () { + if ($scope.macInputModel) { + getMachineRules(); + } + }); + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/flow_v2.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/flow_v2.js new file mode 100755 index 00000000..3280675b --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/flow_v2.js @@ -0,0 +1,221 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('FlowControllerV2', ['$scope', '$stateParams', 'FlowServiceV2', 'ngDialog', + 'MachineService', + function ($scope, $stateParams, FlowService, ngDialog, + MachineService) { + $scope.app = $stateParams.app; + + $scope.rulesPageConfig = { + pageSize: 10, + currentPageIndex: 1, + totalPage: 1, + totalCount: 0, + }; + $scope.macsInputConfig = { + searchField: ['text', 'value'], + persist: true, + create: false, + maxItems: 1, + render: { + item: function (data, escape) { + return '
' + escape(data.text) + '
'; + } + }, + onChange: function (value, oldValue) { + $scope.macInputModel = value; + } + }; + + $scope.generateThresholdTypeShow = (rule) => { + if (!rule.clusterMode) { + return '单机'; + } + if (rule.clusterConfig.thresholdType === 0) { + return '集群均摊'; + } else if (rule.clusterConfig.thresholdType === 1) { + return '集群总体'; + } else { + return '集群'; + } + }; + + getMachineRules(); + function getMachineRules() { + if (!$scope.macInputModel) { + return; + } + var mac = $scope.macInputModel.split(':'); + FlowService.queryMachineRules($scope.app, mac[0], mac[1]).success( + function (data) { + if (data.code == 0 && data.data) { + $scope.rules = data.data; + $scope.rulesPageConfig.totalCount = $scope.rules.length; + } else { + $scope.rules = []; + $scope.rulesPageConfig.totalCount = 0; + } + }); + }; + $scope.getMachineRules = getMachineRules; + + var flowRuleDialog; + $scope.editRule = function (rule) { + $scope.currentRule = angular.copy(rule); + $scope.flowRuleDialog = { + title: '编辑流控规则', + type: 'edit', + confirmBtnText: '保存', + showAdvanceButton: rule.controlBehavior == 0 && rule.strategy == 0 + }; + flowRuleDialog = ngDialog.open({ + template: '/app/views/dialog/flow-rule-dialog.html', + width: 680, + overlay: true, + scope: $scope + }); + }; + + $scope.addNewRule = function () { + var mac = $scope.macInputModel.split(':'); + $scope.currentRule = { + grade: 1, + strategy: 0, + controlBehavior: 0, + app: $scope.app, + ip: mac[0], + port: mac[1], + limitApp: 'default', + clusterMode: false, + clusterConfig: { + thresholdType: 0, + fallbackToLocalWhenFail: true + } + }; + $scope.flowRuleDialog = { + title: '新增流控规则', + type: 'add', + confirmBtnText: '新增', + showAdvanceButton: true, + }; + flowRuleDialog = ngDialog.open({ + template: '/app/views/dialog/flow-rule-dialog.html', + width: 680, + overlay: true, + scope: $scope + }); + }; + + $scope.saveRule = function () { + if (!FlowService.checkRuleValid($scope.currentRule)) { + return; + } + if ($scope.flowRuleDialog.type === 'add') { + addNewRule($scope.currentRule); + } else if ($scope.flowRuleDialog.type === 'edit') { + saveRule($scope.currentRule, true); + } + }; + + var confirmDialog; + $scope.deleteRule = function (rule) { + $scope.currentRule = rule; + $scope.confirmDialog = { + title: '删除流控规则', + type: 'delete_rule', + attentionTitle: '请确认是否删除如下流控规则', + attention: '资源名: ' + rule.resource + ', 流控应用: ' + rule.limitApp + + ', 阈值类型: ' + (rule.grade == 0 ? '线程数' : 'QPS') + ', 阈值: ' + rule.count, + confirmBtnText: '删除', + }; + confirmDialog = ngDialog.open({ + template: '/app/views/dialog/confirm-dialog.html', + scope: $scope, + overlay: true + }); + }; + + $scope.confirm = function () { + if ($scope.confirmDialog.type === 'delete_rule') { + deleteRule($scope.currentRule); + } else { + console.error('error'); + } + }; + + function deleteRule(rule) { + FlowService.deleteRule(rule).success(function (data) { + if (data.code == 0) { + getMachineRules(); + confirmDialog.close(); + } else { + alert('失败!'); + } + }); + }; + + function addNewRule(rule) { + FlowService.newRule(rule).success(function (data) { + if (data.code == 0) { + getMachineRules(); + flowRuleDialog.close(); + } else { + alert('失败!'); + } + }); + }; + + $scope.onOpenAdvanceClick = function () { + $scope.flowRuleDialog.showAdvanceButton = false; + }; + $scope.onCloseAdvanceClick = function () { + $scope.flowRuleDialog.showAdvanceButton = true; + }; + + function saveRule(rule, edit) { + FlowService.saveRule(rule).success(function (data) { + if (data.code == 0) { + getMachineRules(); + if (edit) { + flowRuleDialog.close(); + } else { + confirmDialog.close(); + } + } else { + alert('失败!'); + } + }); + } + queryAppMachines(); + function queryAppMachines() { + MachineService.getAppMachines($scope.app).success( + function (data) { + if (data.code == 0) { + // $scope.machines = data.data; + if (data.data) { + $scope.machines = []; + $scope.macsInputOptions = []; + data.data.forEach(function (item) { + if (item.healthy) { + $scope.macsInputOptions.push({ + text: item.ip + ':' + item.port, + value: item.ip + ':' + item.port + }); + } + }); + } + if ($scope.macsInputOptions.length > 0) { + $scope.macInputModel = $scope.macsInputOptions[0].value; + } + } else { + $scope.macsInputOptions = []; + } + } + ); + }; + $scope.$watch('macInputModel', function () { + if ($scope.macInputModel) { + getMachineRules(); + } + }); + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/gateway/api.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/gateway/api.js new file mode 100755 index 00000000..ccf2497c --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/gateway/api.js @@ -0,0 +1,245 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('GatewayApiCtl', ['$scope', '$stateParams', 'GatewayApiService', 'ngDialog', 'MachineService', + function ($scope, $stateParams, GatewayApiService, ngDialog, MachineService) { + $scope.app = $stateParams.app; + + $scope.apisPageConfig = { + pageSize: 10, + currentPageIndex: 1, + totalPage: 1, + totalCount: 0, + }; + + $scope.macsInputConfig = { + searchField: ['text', 'value'], + persist: true, + create: false, + maxItems: 1, + render: { + item: function (data, escape) { + return '
' + escape(data.text) + '
'; + } + }, + onChange: function (value, oldValue) { + $scope.macInputModel = value; + } + }; + + getApis(); + function getApis() { + if (!$scope.macInputModel) { + return; + } + + var mac = $scope.macInputModel.split(':'); + GatewayApiService.queryApis($scope.app, mac[0], mac[1]).success( + function (data) { + if (data.code == 0 && data.data) { + // To merge rows for api who has more than one predicateItems, here we build data manually + $scope.apis = []; + + data.data.forEach(function(api) { + api["predicateItems"].forEach(function (item, index) { + var newItem = {}; + newItem["id"] = api["id"]; + newItem["app"] = api["app"]; + newItem["ip"] = api["ip"]; + newItem["port"] = api["port"]; + newItem["apiName"] = api["apiName"]; + newItem["pattern"] = item["pattern"]; + newItem["matchStrategy"] = item["matchStrategy"]; + // The itemSize indicates how many rows to merge, by using rowspan="{{api.itemSize}}" in tag + newItem["itemSize"] = api["predicateItems"].length; + // Mark the flag of first item to zero, indicates the start row to merge + newItem["firstFlag"] = index == 0 ? 0 : 1; + // Still hold the data of predicateItems, in order to bind data in edit dialog html + newItem["predicateItems"] = api["predicateItems"]; + $scope.apis.push(newItem); + }); + }); + + $scope.apisPageConfig.totalCount = data.data.length; + } else { + $scope.apis = []; + $scope.apisPageConfig.totalCount = 0; + } + }); + }; + $scope.getApis = getApis; + + var gatewayApiDialog; + $scope.editApi = function (api) { + $scope.currentApi = angular.copy(api); + $scope.gatewayApiDialog = { + title: '编辑自定义 API', + type: 'edit', + confirmBtnText: '保存' + }; + gatewayApiDialog = ngDialog.open({ + template: '/app/views/dialog/gateway/api-dialog.html', + width: 900, + overlay: true, + scope: $scope + }); + }; + + $scope.addNewApi = function () { + var mac = $scope.macInputModel.split(':'); + $scope.currentApi = { + grade: 0, + app: $scope.app, + ip: mac[0], + port: mac[1], + predicateItems: [{matchStrategy: 0, pattern: ''}] + }; + $scope.gatewayApiDialog = { + title: '新增自定义 API', + type: 'add', + confirmBtnText: '新增' + }; + gatewayApiDialog = ngDialog.open({ + template: '/app/views/dialog/gateway/api-dialog.html', + width: 900, + overlay: true, + scope: $scope + }); + }; + + $scope.saveApi = function () { + var apiNames = []; + if ($scope.gatewayApiDialog.type === 'add') { + apiNames = $scope.apis.map(function (item, index, array) { + return item["apiName"]; + }).filter(function (item, index, array) { + return array.indexOf(item) === index; + }); + } + + if (!GatewayApiService.checkApiValid($scope.currentApi, apiNames)) { + return; + } + + if ($scope.gatewayApiDialog.type === 'add') { + addNewApi($scope.currentApi); + } else if ($scope.gatewayApiDialog.type === 'edit') { + saveApi($scope.currentApi, true); + } + }; + + function addNewApi(api) { + GatewayApiService.newApi(api).success(function (data) { + if (data.code == 0) { + getApis(); + gatewayApiDialog.close(); + } else { + alert('新增自定义API失败!' + data.msg); + } + }); + }; + + function saveApi(api, edit) { + GatewayApiService.saveApi(api).success(function (data) { + if (data.code == 0) { + getApis(); + if (edit) { + gatewayApiDialog.close(); + } else { + confirmDialog.close(); + } + } else { + alert('修改自定义API失败!' + data.msg); + } + }); + }; + + var confirmDialog; + $scope.deleteApi = function (api) { + $scope.currentApi = api; + $scope.confirmDialog = { + title: '删除自定义API', + type: 'delete_api', + attentionTitle: '请确认是否删除如下自定义API', + attention: 'API名称: ' + api.apiName, + confirmBtnText: '删除', + }; + confirmDialog = ngDialog.open({ + template: '/app/views/dialog/confirm-dialog.html', + scope: $scope, + overlay: true + }); + }; + + $scope.confirm = function () { + if ($scope.confirmDialog.type == 'delete_api') { + deleteApi($scope.currentApi); + } else { + console.error('error'); + } + }; + + function deleteApi(api) { + GatewayApiService.deleteApi(api).success(function (data) { + if (data.code == 0) { + getApis(); + confirmDialog.close(); + } else { + alert('删除自定义API失败!' + data.msg); + } + }); + }; + + $scope.addNewMatchPattern = function() { + var total; + if ($scope.currentApi.predicateItems == null) { + $scope.currentApi.predicateItems = []; + total = 0; + } else { + total = $scope.currentApi.predicateItems.length; + } + $scope.currentApi.predicateItems.splice(total + 1, 0, {matchStrategy: 0, pattern: ''}); + }; + + $scope.removeMatchPattern = function($index) { + if ($scope.currentApi.predicateItems.length <= 1) { + // Should never happen since no remove button will display when only one predicateItem. + alert('至少有一个匹配规则'); + return; + } + $scope.currentApi.predicateItems.splice($index, 1); + }; + + queryAppMachines(); + function queryAppMachines() { + MachineService.getAppMachines($scope.app).success( + function (data) { + if (data.code == 0) { + // $scope.machines = data.data; + if (data.data) { + $scope.machines = []; + $scope.macsInputOptions = []; + data.data.forEach(function (item) { + if (item.healthy) { + $scope.macsInputOptions.push({ + text: item.ip + ':' + item.port, + value: item.ip + ':' + item.port + }); + } + }); + } + if ($scope.macsInputOptions.length > 0) { + $scope.macInputModel = $scope.macsInputOptions[0].value; + } + } else { + $scope.macsInputOptions = []; + } + } + ); + }; + $scope.$watch('macInputModel', function () { + if ($scope.macInputModel) { + getApis(); + } + }); + }] +); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/gateway/flow.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/gateway/flow.js new file mode 100755 index 00000000..c492cf9c --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/gateway/flow.js @@ -0,0 +1,251 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('GatewayFlowCtl', ['$scope', '$stateParams', 'GatewayFlowService', 'GatewayApiService', 'ngDialog', 'MachineService', + function ($scope, $stateParams, GatewayFlowService, GatewayApiService, ngDialog, MachineService) { + $scope.app = $stateParams.app; + + $scope.rulesPageConfig = { + pageSize: 10, + currentPageIndex: 1, + totalPage: 1, + totalCount: 0, + }; + + $scope.macsInputConfig = { + searchField: ['text', 'value'], + persist: true, + create: false, + maxItems: 1, + render: { + item: function (data, escape) { + return '
' + escape(data.text) + '
'; + } + }, + onChange: function (value, oldValue) { + $scope.macInputModel = value; + } + }; + + getMachineRules(); + function getMachineRules() { + if (!$scope.macInputModel) { + return; + } + + var mac = $scope.macInputModel.split(':'); + GatewayFlowService.queryRules($scope.app, mac[0], mac[1]).success( + function (data) { + if (data.code == 0 && data.data) { + $scope.rules = data.data; + $scope.rulesPageConfig.totalCount = $scope.rules.length; + } else { + $scope.rules = []; + $scope.rulesPageConfig.totalCount = 0; + } + }); + }; + $scope.getMachineRules = getMachineRules; + + getApiNames(); + function getApiNames() { + if (!$scope.macInputModel) { + return; + } + + var mac = $scope.macInputModel.split(':'); + GatewayApiService.queryApis($scope.app, mac[0], mac[1]).success( + function (data) { + if (data.code == 0 && data.data) { + $scope.apiNames = []; + + data.data.forEach(function (api) { + $scope.apiNames.push(api["apiName"]); + }); + } + }); + } + + $scope.intervalUnits = [{val: 0, desc: '秒'}, {val: 1, desc: '分'}, {val: 2, desc: '时'}, {val: 3, desc: '天'}]; + + var gatewayFlowRuleDialog; + $scope.editRule = function (rule) { + $scope.currentRule = angular.copy(rule); + $scope.gatewayFlowRuleDialog = { + title: '编辑网关流控规则', + type: 'edit', + confirmBtnText: '保存' + }; + gatewayFlowRuleDialog = ngDialog.open({ + template: '/app/views/dialog/gateway/flow-rule-dialog.html', + width: 780, + overlay: true, + scope: $scope + }); + }; + + $scope.addNewRule = function () { + var mac = $scope.macInputModel.split(':'); + $scope.currentRule = { + grade: 1, + app: $scope.app, + ip: mac[0], + port: mac[1], + resourceMode: 0, + interval: 1, + intervalUnit: 0, + controlBehavior: 0, + burst: 0, + maxQueueingTimeoutMs: 0 + }; + + $scope.gatewayFlowRuleDialog = { + title: '新增网关流控规则', + type: 'add', + confirmBtnText: '新增' + }; + + gatewayFlowRuleDialog = ngDialog.open({ + template: '/app/views/dialog/gateway/flow-rule-dialog.html', + width: 780, + overlay: true, + scope: $scope + }); + }; + + $scope.saveRule = function () { + if (!GatewayFlowService.checkRuleValid($scope.currentRule)) { + return; + } + if ($scope.gatewayFlowRuleDialog.type === 'add') { + addNewRule($scope.currentRule); + } else if ($scope.gatewayFlowRuleDialog.type === 'edit') { + saveRule($scope.currentRule, true); + } + }; + + $scope.useRouteID = function() { + $scope.currentRule.resource = ''; + }; + + $scope.useCustormAPI = function() { + $scope.currentRule.resource = ''; + }; + + $scope.useParamItem = function () { + $scope.currentRule.paramItem = { + parseStrategy: 0, + matchStrategy: 0 + }; + }; + + $scope.notUseParamItem = function () { + $scope.currentRule.paramItem = null; + }; + + $scope.useParamItemVal = function() { + $scope.currentRule.paramItem.pattern = ""; + $scope.currentRule.paramItem.matchStrategy = 0; + }; + + $scope.notUseParamItemVal = function() { + $scope.currentRule.paramItem.pattern = null; + $scope.currentRule.paramItem.matchStrategy = null; + }; + + function addNewRule(rule) { + GatewayFlowService.newRule(rule).success(function (data) { + if (data.code == 0) { + getMachineRules(); + gatewayFlowRuleDialog.close(); + } else { + alert('新增网关流控规则失败!' + data.msg); + } + }); + }; + + function saveRule(rule, edit) { + GatewayFlowService.saveRule(rule).success(function (data) { + if (data.code == 0) { + getMachineRules(); + if (edit) { + gatewayFlowRuleDialog.close(); + } else { + confirmDialog.close(); + } + } else { + alert('修改网关流控规则失败!' + data.msg); + } + }); + }; + + var confirmDialog; + $scope.deleteRule = function (rule) { + $scope.currentRule = rule; + $scope.confirmDialog = { + title: '删除网关流控规则', + type: 'delete_rule', + attentionTitle: '请确认是否删除如下规则', + attention: 'API名称: ' + rule.resource + ', ' + (rule.grade == 1 ? 'QPS阈值' : '线程数') + ': ' + rule.count, + confirmBtnText: '删除', + }; + confirmDialog = ngDialog.open({ + template: '/app/views/dialog/confirm-dialog.html', + scope: $scope, + overlay: true + }); + }; + + $scope.confirm = function () { + if ($scope.confirmDialog.type == 'delete_rule') { + deleteRule($scope.currentRule); + } else { + console.error('error'); + } + }; + + function deleteRule(rule) { + GatewayFlowService.deleteRule(rule).success(function (data) { + if (data.code == 0) { + getMachineRules(); + confirmDialog.close(); + } else { + alert('删除网关流控规则失败!' + data.msg); + } + }); + }; + + queryAppMachines(); + + function queryAppMachines() { + MachineService.getAppMachines($scope.app).success( + function (data) { + if (data.code == 0) { + if (data.data) { + $scope.machines = []; + $scope.macsInputOptions = []; + data.data.forEach(function (item) { + if (item.healthy) { + $scope.macsInputOptions.push({ + text: item.ip + ':' + item.port, + value: item.ip + ':' + item.port + }); + } + }); + } + if ($scope.macsInputOptions.length > 0) { + $scope.macInputModel = $scope.macsInputOptions[0].value; + } + } else { + $scope.macsInputOptions = []; + } + } + ); + }; + $scope.$watch('macInputModel', function () { + if ($scope.macInputModel) { + getMachineRules(); + getApiNames(); + } + }); + }] +); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/gateway/identity.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/gateway/identity.js new file mode 100755 index 00000000..52871b4a --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/gateway/identity.js @@ -0,0 +1,299 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('GatewayIdentityCtl', ['$scope', '$stateParams', 'IdentityService', + 'ngDialog', 'GatewayFlowService', 'GatewayApiService', 'DegradeService', 'MachineService', + '$interval', '$location', '$timeout', + function ($scope, $stateParams, IdentityService, ngDialog, + GatewayFlowService, GatewayApiService, DegradeService, MachineService, $interval, $location, $timeout) { + + $scope.app = $stateParams.app; + + $scope.currentPage = 1; + $scope.pageSize = 16; + $scope.totalPage = 1; + $scope.totalCount = 0; + $scope.identities = []; + + $scope.searchKey = ''; + + $scope.macsInputConfig = { + searchField: ['text', 'value'], + persist: true, + create: false, + maxItems: 1, + render: { + item: function (data, escape) { + return '
' + escape(data.text) + '
'; + } + }, + onChange: function (value, oldValue) { + $scope.macInputModel = value; + } + }; + $scope.table = null; + + getApiNames(); + function getApiNames() { + if (!$scope.macInputModel) { + return; + } + + var mac = $scope.macInputModel.split(':'); + GatewayApiService.queryApis($scope.app, mac[0], mac[1]).success( + function (data) { + if (data.code == 0 && data.data) { + $scope.apiNames = []; + + data.data.forEach(function (api) { + $scope.apiNames.push(api["apiName"]); + }); + } + }); + } + + var gatewayFlowRuleDialog; + var gatewayFlowRuleDialogScope; + $scope.addNewGatewayFlowRule = function (resource) { + if (!$scope.macInputModel) { + return; + } + var mac = $scope.macInputModel.split(':'); + gatewayFlowRuleDialogScope = $scope.$new(true); + + gatewayFlowRuleDialogScope.apiNames = $scope.apiNames; + + gatewayFlowRuleDialogScope.intervalUnits = [{val: 0, desc: '秒'}, {val: 1, desc: '分'}, {val: 2, desc: '时'}, {val: 3, desc: '天'}]; + + gatewayFlowRuleDialogScope.currentRule = { + grade: 1, + app: $scope.app, + ip: mac[0], + port: mac[1], + resourceMode: gatewayFlowRuleDialogScope.apiNames.indexOf(resource) == -1 ? 0 : 1, + resource: resource, + interval: 1, + intervalUnit: 0, + controlBehavior: 0, + burst: 0, + maxQueueingTimeoutMs: 0 + }; + + gatewayFlowRuleDialogScope.gatewayFlowRuleDialog = { + title: '新增网关流控规则', + type: 'add', + confirmBtnText: '新增', + saveAndContinueBtnText: '新增并继续添加', + showAdvanceButton: true + }; + + gatewayFlowRuleDialogScope.useRouteID = function() { + gatewayFlowRuleDialogScope.currentRule.resource = ''; + }; + + gatewayFlowRuleDialogScope.useCustormAPI = function() { + gatewayFlowRuleDialogScope.currentRule.resource = ''; + }; + + gatewayFlowRuleDialogScope.useParamItem = function () { + gatewayFlowRuleDialogScope.currentRule.paramItem = { + parseStrategy: 0, + matchStrategy: 0 + }; + }; + + gatewayFlowRuleDialogScope.notUseParamItem = function () { + gatewayFlowRuleDialogScope.currentRule.paramItem = null; + }; + + gatewayFlowRuleDialogScope.useParamItemVal = function() { + gatewayFlowRuleDialogScope.currentRule.paramItem.pattern = ""; + }; + + gatewayFlowRuleDialogScope.notUseParamItemVal = function() { + gatewayFlowRuleDialogScope.currentRule.paramItem.pattern = null; + }; + + gatewayFlowRuleDialogScope.saveRule = saveGatewayFlowRule; + gatewayFlowRuleDialogScope.saveRuleAndContinue = saveGatewayFlowRuleAndContinue; + gatewayFlowRuleDialogScope.onOpenAdvanceClick = function () { + gatewayFlowRuleDialogScope.gatewayFlowRuleDialog.showAdvanceButton = false; + }; + gatewayFlowRuleDialogScope.onCloseAdvanceClick = function () { + gatewayFlowRuleDialogScope.gatewayFlowRuleDialog.showAdvanceButton = true; + }; + + gatewayFlowRuleDialog = ngDialog.open({ + template: '/app/views/dialog/gateway/flow-rule-dialog.html', + width: 780, + overlay: true, + scope: gatewayFlowRuleDialogScope + }); + }; + + function saveGatewayFlowRule() { + if (!GatewayFlowService.checkRuleValid(gatewayFlowRuleDialogScope.currentRule)) { + return; + } + GatewayFlowService.newRule(gatewayFlowRuleDialogScope.currentRule).success(function (data) { + if (data.code === 0) { + gatewayFlowRuleDialog.close(); + let url = '/dashboard/gateway/flow/' + $scope.app; + $location.path(url); + } else { + alert('失败!'); + } + }).error((data, header, config, status) => { + alert('未知错误'); + }); + } + + function saveGatewayFlowRuleAndContinue() { + if (!GatewayFlowService.checkRuleValid(gatewayFlowRuleDialogScope.currentRule)) { + return; + } + GatewayFlowService.newRule(gatewayFlowRuleDialogScope.currentRule).success(function (data) { + if (data.code == 0) { + gatewayFlowRuleDialog.close(); + } else { + alert('失败!'); + } + }); + } + + var degradeRuleDialog; + $scope.addNewDegradeRule = function (resource) { + if (!$scope.macInputModel) { + return; + } + var mac = $scope.macInputModel.split(':'); + degradeRuleDialogScope = $scope.$new(true); + degradeRuleDialogScope.currentRule = { + enable: false, + grade: 0, + strategy: 0, + resource: resource, + limitApp: 'default', + app: $scope.app, + ip: mac[0], + port: mac[1] + }; + + degradeRuleDialogScope.degradeRuleDialog = { + title: '新增降级规则', + type: 'add', + confirmBtnText: '新增', + saveAndContinueBtnText: '新增并继续添加' + }; + degradeRuleDialogScope.saveRule = saveDegradeRule; + degradeRuleDialogScope.saveRuleAndContinue = saveDegradeRuleAndContinue; + + degradeRuleDialog = ngDialog.open({ + template: '/app/views/dialog/degrade-rule-dialog.html', + width: 680, + overlay: true, + scope: degradeRuleDialogScope + }); + }; + + function saveDegradeRule() { + if (!DegradeService.checkRuleValid(degradeRuleDialogScope.currentRule)) { + return; + } + DegradeService.newRule(degradeRuleDialogScope.currentRule).success(function (data) { + if (data.code == 0) { + degradeRuleDialog.close(); + var url = '/dashboard/degrade/' + $scope.app; + $location.path(url); + } else { + alert('失败!'); + } + }); + } + + function saveDegradeRuleAndContinue() { + if (!DegradeService.checkRuleValid(degradeRuleDialogScope.currentRule)) { + return; + } + DegradeService.newRule(degradeRuleDialogScope.currentRule).success(function (data) { + if (data.code == 0) { + degradeRuleDialog.close(); + } else { + alert('失败!'); + } + }); + } + + var searchHandler; + $scope.searchChange = function (searchKey) { + $timeout.cancel(searchHandler); + searchHandler = $timeout(function () { + $scope.searchKey = searchKey; + reInitIdentityDatas(); + }, 600); + }; + + function queryAppMachines() { + MachineService.getAppMachines($scope.app).success( + function (data) { + if (data.code === 0) { + if (data.data) { + $scope.machines = []; + $scope.macsInputOptions = []; + data.data.forEach(function (item) { + if (item.healthy) { + $scope.macsInputOptions.push({ + text: item.ip + ':' + item.port, + value: item.ip + ':' + item.port + }); + } + }); + } + if ($scope.macsInputOptions.length > 0) { + $scope.macInputModel = $scope.macsInputOptions[0].value; + } + } else { + $scope.macsInputOptions = []; + } + } + ); + } + + // Fetch all machines by current app name. + queryAppMachines(); + + $scope.$watch('macInputModel', function () { + if ($scope.macInputModel) { + reInitIdentityDatas(); + } + }); + + $scope.$on('$destroy', function () { + $interval.cancel(intervalId); + }); + + var intervalId; + function reInitIdentityDatas() { + getApiNames(); + queryIdentities(); + }; + + function queryIdentities() { + var mac = $scope.macInputModel.split(':'); + if (mac == null || mac.length < 2) { + return; + } + + IdentityService.fetchClusterNodeOfMachine(mac[0], mac[1], $scope.searchKey).success( + function (data) { + if (data.code == 0 && data.data) { + $scope.identities = data.data; + $scope.totalCount = $scope.identities.length; + } else { + $scope.identities = []; + $scope.totalCount = 0; + } + } + ); + }; + $scope.queryIdentities = queryIdentities; + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/home.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/home.js new file mode 100755 index 00000000..1df5862c --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/home.js @@ -0,0 +1,11 @@ +/** + * @ngdoc function + * @name sentinelDashboardApp.controller:MainCtrl + * @description + * # MainCtrl + * Controller of the sentinelDashboardApp + */ +angular.module('sentinelDashboardApp') + .controller('HomeCtrl', ['$scope', '$position', function ($scope, $position) { + // do noting + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/identity.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/identity.js new file mode 100755 index 00000000..f8116be7 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/identity.js @@ -0,0 +1,476 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('IdentityCtl', ['$scope', '$stateParams', 'IdentityService', + 'ngDialog', 'FlowServiceV1', 'DegradeService', 'AuthorityRuleService', 'ParamFlowService', 'MachineService', + '$interval', '$location', '$timeout', + function ($scope, $stateParams, IdentityService, ngDialog, + FlowService, DegradeService, AuthorityRuleService, ParamFlowService, MachineService, $interval, $location, $timeout) { + + $scope.app = $stateParams.app; + + $scope.currentPage = 1; + $scope.pageSize = 16; + $scope.totalPage = 1; + $scope.totalCount = 0; + $scope.identities = []; + // 数据自动刷新频率, 默认10s + var DATA_REFRESH_INTERVAL = 30; + + $scope.isExpand = true; + $scope.searchKey = ''; + $scope.firstExpandAll = false; + $scope.isTreeView = true; + + $scope.macsInputConfig = { + searchField: ['text', 'value'], + persist: true, + create: false, + maxItems: 1, + render: { + item: function (data, escape) { + return '
' + escape(data.text) + '
'; + } + }, + onChange: function (value, oldValue) { + $scope.macInputModel = value; + } + }; + $scope.table = null; + + var flowRuleDialog; + var flowRuleDialogScope; + $scope.addNewFlowRule = function (resource) { + if (!$scope.macInputModel) { + return; + } + var mac = $scope.macInputModel.split(':'); + flowRuleDialogScope = $scope.$new(true); + flowRuleDialogScope.currentRule = { + enable: false, + strategy: 0, + grade: 1, + controlBehavior: 0, + resource: resource, + limitApp: 'default', + clusterMode: false, + clusterConfig: { + thresholdType: 0 + }, + app: $scope.app, + ip: mac[0], + port: mac[1] + }; + + flowRuleDialogScope.flowRuleDialog = { + title: '新增流控规则', + type: 'add', + confirmBtnText: '新增', + saveAndContinueBtnText: '新增并继续添加', + showAdvanceButton: true + }; + // $scope.flowRuleDialog = { + // showAdvanceButton : true + // }; + flowRuleDialogScope.saveRule = saveFlowRule; + flowRuleDialogScope.saveRuleAndContinue = saveFlowRuleAndContinue; + flowRuleDialogScope.onOpenAdvanceClick = function () { + flowRuleDialogScope.flowRuleDialog.showAdvanceButton = false; + }; + flowRuleDialogScope.onCloseAdvanceClick = function () { + flowRuleDialogScope.flowRuleDialog.showAdvanceButton = true; + }; + + flowRuleDialog = ngDialog.open({ + template: '/app/views/dialog/flow-rule-dialog.html', + width: 680, + overlay: true, + scope: flowRuleDialogScope + }); + }; + + function saveFlowRule() { + if (!FlowService.checkRuleValid(flowRuleDialogScope.currentRule)) { + return; + } + FlowService.newRule(flowRuleDialogScope.currentRule).success(function (data) { + if (data.code === 0) { + flowRuleDialog.close(); + let url = '/dashboard/flow/' + $scope.app; + $location.path(url); + } else { + alert('失败:' + data.msg); + } + }).error((data, header, config, status) => { + alert('未知错误'); + }); + } + + function saveFlowRuleAndContinue() { + if (!FlowService.checkRuleValid(flowRuleDialogScope.currentRule)) { + return; + } + FlowService.newRule(flowRuleDialogScope.currentRule).success(function (data) { + if (data.code === 0) { + flowRuleDialog.close(); + } else { + alert('失败:' + data.msg); + } + }); + } + + var degradeRuleDialog; + var degradeRuleDialogScope; + $scope.addNewDegradeRule = function (resource) { + if (!$scope.macInputModel) { + return; + } + var mac = $scope.macInputModel.split(':'); + degradeRuleDialogScope = $scope.$new(true); + degradeRuleDialogScope.currentRule = { + enable: false, + grade: 0, + strategy: 0, + resource: resource, + limitApp: 'default', + app: $scope.app, + ip: mac[0], + port: mac[1] + }; + + degradeRuleDialogScope.degradeRuleDialog = { + title: '新增降级规则', + type: 'add', + confirmBtnText: '新增', + saveAndContinueBtnText: '新增并继续添加' + }; + degradeRuleDialogScope.saveRule = saveDegradeRule; + degradeRuleDialogScope.saveRuleAndContinue = saveDegradeRuleAndContinue; + + degradeRuleDialog = ngDialog.open({ + template: '/app/views/dialog/degrade-rule-dialog.html', + width: 680, + overlay: true, + scope: degradeRuleDialogScope + }); + }; + + function saveDegradeRule() { + if (!DegradeService.checkRuleValid(degradeRuleDialogScope.currentRule)) { + return; + } + DegradeService.newRule(degradeRuleDialogScope.currentRule).success(function (data) { + if (data.code === 0) { + degradeRuleDialog.close(); + var url = '/dashboard/degrade/' + $scope.app; + $location.path(url); + } else { + alert('失败:' + data.msg); + } + }); + } + + function saveDegradeRuleAndContinue() { + if (!DegradeService.checkRuleValid(degradeRuleDialogScope.currentRule)) { + return; + } + DegradeService.newRule(degradeRuleDialogScope.currentRule).success(function (data) { + if (data.code === 0) { + degradeRuleDialog.close(); + } else { + alert('失败:' + data.msg); + } + }); + } + + let authorityRuleDialog; + let authorityRuleDialogScope; + + function saveAuthorityRule() { + let ruleEntity = authorityRuleDialogScope.currentRule; + if (!AuthorityRuleService.checkRuleValid(ruleEntity.rule)) { + return; + } + AuthorityRuleService.addNewRule(ruleEntity).success((data) => { + if (data.success) { + authorityRuleDialog.close(); + let url = '/dashboard/authority/' + $scope.app; + $location.path(url); + } else { + alert('添加规则失败:' + data.msg); + } + }).error((data) => { + if (data) { + alert('添加规则失败:' + data.msg); + } else { + alert("添加规则失败:未知错误"); + } + }); + } + + function saveAuthorityRuleAndContinue() { + let ruleEntity = authorityRuleDialogScope.currentRule; + if (!AuthorityRuleService.checkRuleValid(ruleEntity.rule)) { + return; + } + AuthorityRuleService.addNewRule(ruleEntity).success((data) => { + if (data.success) { + authorityRuleDialog.close(); + } else { + alert('添加规则失败:' + data.msg); + } + }).error((data) => { + if (data) { + alert('添加规则失败:' + data.msg); + } else { + alert("添加规则失败:未知错误"); + } + }); + } + + $scope.addNewAuthorityRule = function (resource) { + if (!$scope.macInputModel) { + return; + } + let mac = $scope.macInputModel.split(':'); + authorityRuleDialogScope = $scope.$new(true); + authorityRuleDialogScope.currentRule = { + app: $scope.app, + ip: mac[0], + port: mac[1], + rule: { + resource: resource, + strategy: 0, + limitApp: '', + } + }; + + authorityRuleDialogScope.authorityRuleDialog = { + title: '新增授权规则', + type: 'add', + confirmBtnText: '新增', + saveAndContinueBtnText: '新增并继续添加' + }; + authorityRuleDialogScope.saveRule = saveAuthorityRule; + authorityRuleDialogScope.saveRuleAndContinue = saveAuthorityRuleAndContinue; + + authorityRuleDialog = ngDialog.open({ + template: '/app/views/dialog/authority-rule-dialog.html', + width: 680, + overlay: true, + scope: authorityRuleDialogScope + }); + }; + + let paramFlowRuleDialog; + let paramFlowRuleDialogScope; + + function saveParamFlowRule() { + let ruleEntity = paramFlowRuleDialogScope.currentRule; + if (!ParamFlowService.checkRuleValid(ruleEntity.rule)) { + return; + } + ParamFlowService.addNewRule(ruleEntity).success((data) => { + if (data.success) { + paramFlowRuleDialog.close(); + let url = '/dashboard/paramFlow/' + $scope.app; + $location.path(url); + } else { + alert('添加热点规则失败:' + data.msg); + } + }).error((data) => { + if (data) { + alert('添加热点规则失败:' + data.msg); + } else { + alert("添加热点规则失败:未知错误"); + } + }); + } + + function saveParamFlowRuleAndContinue() { + let ruleEntity = paramFlowRuleDialogScope.currentRule; + if (!ParamFlowService.checkRuleValid(ruleEntity.rule)) { + return; + } + ParamFlowService.addNewRule(ruleEntity).success((data) => { + if (data.success) { + paramFlowRuleDialog.close(); + } else { + alert('添加热点规则失败:' + data.msg); + } + }).error((data) => { + if (data) { + alert('添加热点规则失败:' + data.msg); + } else { + alert("添加热点规则失败:未知错误"); + } + }); + } + + $scope.addNewParamFlowRule = function (resource) { + if (!$scope.macInputModel) { + return; + } + let mac = $scope.macInputModel.split(':'); + paramFlowRuleDialogScope = $scope.$new(true); + paramFlowRuleDialogScope.currentRule = { + app: $scope.app, + ip: mac[0], + port: mac[1], + rule: { + resource: resource, + grade: 1, + paramFlowItemList: [], + count: 0, + limitApp: 'default', + controlBehavior: 0, + durationInSec: 1, + burstCount: 0, + maxQueueingTimeMs: 0, + clusterMode: false, + clusterConfig: { + thresholdType: 0, + fallbackToLocalWhenFail: true, + } + } + }; + + paramFlowRuleDialogScope.paramFlowRuleDialog = { + title: '新增热点规则', + type: 'add', + confirmBtnText: '新增', + saveAndContinueBtnText: '新增并继续添加', + supportAdvanced: false, + showAdvanceButton: true + }; + paramFlowRuleDialogScope.saveRule = saveParamFlowRule; + paramFlowRuleDialogScope.saveRuleAndContinue = saveParamFlowRuleAndContinue; + // paramFlowRuleDialogScope.onOpenAdvanceClick = function () { + // paramFlowRuleDialogScope.paramFlowRuleDialog.showAdvanceButton = false; + // }; + // paramFlowRuleDialogScope.onCloseAdvanceClick = function () { + // paramFlowRuleDialogScope.paramFlowRuleDialog.showAdvanceButton = true; + // }; + + paramFlowRuleDialog = ngDialog.open({ + template: '/app/views/dialog/param-flow-rule-dialog.html', + width: 680, + overlay: true, + scope: paramFlowRuleDialogScope + }); + }; + + var searchHandler; + $scope.searchChange = function (searchKey) { + $timeout.cancel(searchHandler); + searchHandler = $timeout(function () { + $scope.searchKey = searchKey; + $scope.isExpand = true; + $scope.firstExpandAll = true; + reInitIdentityDatas(); + $scope.firstExpandAll = false; + }, 600); + }; + + $scope.initTreeTable = function () { + // if (!$scope.table) { + com_github_culmat_jsTreeTable.register(window); + $scope.table = window.treeTable($('#identities')); + // } + }; + + $scope.expandAll = function () { + $scope.isExpand = true; + }; + $scope.collapseAll = function () { + $scope.isExpand = false; + }; + $scope.treeView = function () { + $scope.isTreeView = true; + queryIdentities(); + }; + $scope.listView = function () { + $scope.isTreeView = false; + queryIdentities(); + }; + + function queryAppMachines() { + MachineService.getAppMachines($scope.app).success( + function (data) { + if (data.code === 0) { + if (data.data) { + $scope.machines = []; + $scope.macsInputOptions = []; + data.data.forEach(function (item) { + if (item.healthy) { + $scope.macsInputOptions.push({ + text: item.ip + ':' + item.port, + value: item.ip + ':' + item.port + }); + } + }); + } + if ($scope.macsInputOptions.length > 0) { + $scope.macInputModel = $scope.macsInputOptions[0].value; + } + } else { + $scope.macsInputOptions = []; + } + } + ); + } + + // Fetch all machines by current app name. + queryAppMachines(); + + $scope.$watch('macInputModel', function () { + if ($scope.macInputModel) { + reInitIdentityDatas(); + } + }); + + $scope.$on('$destroy', function () { + $interval.cancel(intervalId); + }); + + var intervalId; + function reInitIdentityDatas() { + // $interval.cancel(intervalId); + queryIdentities(); + // intervalId = $interval(function () { + // queryIdentities(); + // }, DATA_REFRESH_INTERVAL * 1000); + }; + + function queryIdentities() { + var mac = $scope.macInputModel.split(':'); + if (mac == null || mac.length < 2) { + return; + } + if ($scope.isTreeView) { + IdentityService.fetchIdentityOfMachine(mac[0], mac[1], $scope.searchKey).success( + function (data) { + if (data.code == 0 && data.data) { + $scope.identities = data.data; + $scope.totalCount = $scope.identities.length; + } else { + $scope.identities = []; + $scope.totalCount = 0; + } + } + ); + } else { + IdentityService.fetchClusterNodeOfMachine(mac[0], mac[1], $scope.searchKey).success( + function (data) { + if (data.code == 0 && data.data) { + $scope.identities = data.data; + $scope.totalCount = $scope.identities.length; + } else { + $scope.identities = []; + $scope.totalCount = 0; + } + } + ); + } + }; + $scope.queryIdentities = queryIdentities; + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/login.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/login.js new file mode 100755 index 00000000..3d49d3c1 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/login.js @@ -0,0 +1,33 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('LoginCtl', ['$scope', '$state', '$window', 'AuthService', + function ($scope, $state, $window, AuthService) { + // If auth passed, jump to the index page directly + if ($window.localStorage.getItem('session_sentinel_admin')) { + $state.go('dashboard'); + } + + $scope.login = function () { + if (!$scope.username) { + alert('请输入用户名'); + return; + } + + if (!$scope.password) { + alert('请输入密码'); + return; + } + + var param = {"username": $scope.username, "password": $scope.password}; + + AuthService.login(param).success(function (data) { + if (data.code == 0) { + $window.localStorage.setItem('session_sentinel_admin', JSON.stringify(data.data)); + $state.go('dashboard'); + } else { + alert(data.msg); + } + }); + }; + }] +); \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/machine.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/machine.js new file mode 100755 index 00000000..16180470 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/machine.js @@ -0,0 +1,65 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('MachineCtl', ['$scope', '$stateParams', 'MachineService', + function ($scope, $stateParams, MachineService) { + $scope.app = $stateParams.app; + $scope.propertyName = ''; + $scope.reverse = false; + $scope.currentPage = 1; + $scope.machines = []; + $scope.machinesPageConfig = { + pageSize: 10, + currentPageIndex: 1, + totalPage: 1, + totalCount: 0, + }; + + $scope.sortBy = function (propertyName) { + // console.log('machine sortBy ' + propertyName); + $scope.reverse = ($scope.propertyName === propertyName) ? !$scope.reverse : false; + $scope.propertyName = propertyName; + }; + + $scope.reloadMachines = function() { + MachineService.getAppMachines($scope.app).success( + function (data) { + // console.log('get machines: ' + data.data[0].hostname) + if (data.code == 0 && data.data) { + $scope.machines = data.data; + var healthy = 0; + $scope.machines.forEach(function (item) { + if (item.healthy) { + healthy++; + } + if (!item.hostname) { + item.hostname = '未知' + } + }) + $scope.healthyCount = healthy; + $scope.machinesPageConfig.totalCount = $scope.machines.length; + } else { + $scope.machines = []; + $scope.healthyCount = 0; + } + } + ); + }; + + $scope.removeMachine = function(ip, port) { + if (!confirm("confirm to remove machine [" + ip + ":" + port + "]?")) { + return; + } + MachineService.removeAppMachine($scope.app, ip, port).success( + function(data) { + if (data.code == 0) { + $scope.reloadMachines(); + } else { + alert("remove failed"); + } + } + ); + }; + + $scope.reloadMachines(); + + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/main.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/main.js new file mode 100755 index 00000000..37500f7e --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/main.js @@ -0,0 +1,10 @@ +/** + * @ngdoc function + * @name sentinelDashboardApp.controller:MainCtrl + * @description + * # MainCtrl + * Controller of the sentinelDashboardApp + */ +angular.module('sentinelDashboardApp') + .controller('DashboardCtrl', ['$scope', '$position', function ($scope, $position) { + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/metric.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/metric.js new file mode 100755 index 00000000..b7e2539d --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/metric.js @@ -0,0 +1,263 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interval', '$timeout', + function ($scope, $stateParams, MetricService, $interval, $timeout) { + + $scope.endTime = new Date(); + $scope.startTime = new Date(); + $scope.startTime.setMinutes($scope.endTime.getMinutes() - 30); + $scope.startTimeFmt = formatDate($scope.startTime); + $scope.endTimeFmt = formatDate($scope.endTime); + function formatDate(date) { + return moment(date).format('YYYY/MM/DD HH:mm:ss'); + } + $scope.changeStartTime = function (startTime) { + $scope.startTime = new Date(startTime); + $scope.startTimeFmt = formatDate(startTime); + }; + $scope.changeEndTime = function (endTime) { + $scope.endTime = new Date(endTime); + $scope.endTimeFmt = formatDate(endTime); + }; + + $scope.app = $stateParams.app; + // 数据自动刷新频率 + var DATA_REFRESH_INTERVAL = 1000 * 10; + + $scope.servicePageConfig = { + pageSize: 6, + currentPageIndex: 1, + totalPage: 1, + totalCount: 0, + }; + $scope.servicesChartConfigs = []; + + $scope.pageChanged = function (newPageNumber) { + $scope.servicePageConfig.currentPageIndex = newPageNumber; + reInitIdentityDatas(); + }; + + var searchT; + $scope.searchService = function () { + $timeout.cancel(searchT); + searchT = $timeout(function () { + reInitIdentityDatas(); + }, 600); + } + + var intervalId; + reInitIdentityDatas(); + function reInitIdentityDatas() { + $interval.cancel(intervalId); + queryIdentityDatas(); + intervalId = $interval(function () { + queryIdentityDatas(); + }, DATA_REFRESH_INTERVAL); + }; + + $scope.$on('$destroy', function () { + $interval.cancel(intervalId); + }); + $scope.initAllChart = function () { + $.each($scope.metrics, function (idx, metric) { + if (idx == $scope.metrics.length - 1) { + return; + } + const chart = new G2.Chart({ + container: 'chart' + idx, + forceFit: true, + width: 100, + height: 250, + padding: [10, 30, 70, 50] + }); + var maxQps = 0; + for (var i in metric.data) { + var item = metric.data[i]; + if (item.passQps > maxQps) { + maxQps = item.passQps; + } + if (item.blockQps > maxQps) { + maxQps = item.blockQps; + } + } + chart.source(metric.data); + chart.scale('timestamp', { + type: 'time', + mask: 'YYYY-MM-DD HH:mm:ss' + }); + chart.scale('passQps', { + min: 0, + max: maxQps, + fine: true, + alias: '通过 QPS' + // max: 10 + }); + chart.scale('blockQps', { + min: 0, + max: maxQps, + fine: true, + alias: '拒绝 QPS', + }); + chart.scale('rt', { + min: 0, + fine: true, + }); + chart.axis('rt', { + grid: null, + label: null + }); + chart.axis('blockQps', { + grid: null, + label: null + }); + + chart.axis('timestamp', { + label: { + textStyle: { + textAlign: 'center', // 文本对齐方向,可取值为: start center end + fill: '#404040', // 文本的颜色 + fontSize: '11', // 文本大小 + //textBaseline: 'top', // 文本基准线,可取 top middle bottom,默认为middle + }, + autoRotate: false, + formatter: function (text, item, index) { + return text.substring(11, 11 + 5); + } + } + }); + chart.legend({ + custom: true, + position: 'bottom', + allowAllCanceled: true, + itemFormatter: function (val) { + if ('passQps' === val) { + return '通过 QPS'; + } + if ('blockQps' === val) { + return '拒绝 QPS'; + } + return val; + }, + items: [ + { value: 'passQps', marker: { symbol: 'hyphen', stroke: 'green', radius: 5, lineWidth: 2 } }, + { value: 'blockQps', marker: { symbol: 'hyphen', stroke: 'blue', radius: 5, lineWidth: 2 } }, + //{ value: 'rt', marker: {symbol: 'hyphen', stroke: 'gray', radius: 5, lineWidth: 2} }, + ], + onClick: function (ev) { + const item = ev.item; + const value = item.value; + const checked = ev.checked; + const geoms = chart.getAllGeoms(); + for (var i = 0; i < geoms.length; i++) { + const geom = geoms[i]; + if (geom.getYScale().field === value) { + if (checked) { + geom.show(); + } else { + geom.hide(); + } + } + } + } + }); + chart.line().position('timestamp*passQps').size(1).color('green').shape('smooth'); + chart.line().position('timestamp*blockQps').size(1).color('blue').shape('smooth'); + //chart.line().position('timestamp*rt').size(1).color('gray').shape('smooth'); + G2.track(false); + chart.render(); + }); + }; + + $scope.metrics = []; + $scope.emptyObjs = []; + function queryIdentityDatas() { + var params = { + app: $scope.app, + pageIndex: $scope.servicePageConfig.currentPageIndex, + pageSize: $scope.servicePageConfig.pageSize, + desc: $scope.isDescOrder, + searchKey: $scope.serviceQuery + }; + MetricService.queryAppSortedIdentities(params).success(function (data) { + $scope.metrics = []; + $scope.emptyObjs = []; + if (data.code === 0 && data.data) { + var metricsObj = data.data.metric; + var identityNames = Object.keys(metricsObj); + if (identityNames.length < 1) { + $scope.emptyServices = true; + } else { + $scope.emptyServices = false; + } + $scope.servicePageConfig.totalPage = data.data.totalPage; + $scope.servicePageConfig.pageSize = data.data.pageSize; + var totalCount = data.data.totalCount; + $scope.servicePageConfig.totalCount = totalCount; + for (i = 0; i < totalCount; i++) { + $scope.emptyObjs.push({}); + } + $.each(identityNames, function (idx, identityName) { + var identityDatas = metricsObj[identityName]; + var metrics = {}; + metrics.resource = identityName; + // metrics.data = identityDatas; + metrics.data = fillZeros(identityDatas); + metrics.shortData = lastOfArray(identityDatas, 6); + $scope.metrics.push(metrics); + }); + // push an empty element in the last, for ng-init reasons. + $scope.metrics.push([]); + } else { + $scope.emptyServices = true; + console.log(data.msg); + } + }); + }; + function fillZeros(metricData) { + if (!metricData || metricData.length == 0) { + return []; + } + var filledData = []; + filledData.push(metricData[0]); + var lastTime = metricData[0].timestamp / 1000; + for (var i = 1; i < metricData.length; i++) { + var curTime = metricData[i].timestamp / 1000; + if (curTime > lastTime + 1) { + for (var j = lastTime + 1; j < curTime; j++) { + filledData.push({ + "timestamp": j * 1000, + "passQps": 0, + "blockQps": 0, + "successQps": 0, + "exception": 0, + "rt": 0, + "count": 0 + }) + } + } + filledData.push(metricData[i]); + lastTime = curTime; + } + return filledData; + } + function lastOfArray(arr, n) { + if (!arr.length) { + return []; + } + var rs = []; + for (i = 0; i < n && i < arr.length; i++) { + rs.push(arr[arr.length - 1 - i]); + } + return rs; + } + + $scope.isDescOrder = true; + $scope.setDescOrder = function () { + $scope.isDescOrder = true; + reInitIdentityDatas(); + } + $scope.setAscOrder = function () { + $scope.isDescOrder = false; + reInitIdentityDatas(); + } + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/param_flow.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/param_flow.js new file mode 100755 index 00000000..65d868a8 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/param_flow.js @@ -0,0 +1,328 @@ +/** + * Parameter flow control controller. + * + * @author Eric Zhao + */ +angular.module('sentinelDashboardApp').controller('ParamFlowController', ['$scope', '$stateParams', 'ParamFlowService', 'ngDialog', + 'MachineService', + function ($scope, $stateParams, ParamFlowService, ngDialog, + MachineService) { + const UNSUPPORTED_CODE = 4041; + $scope.app = $stateParams.app; + $scope.curExItem = {}; + + $scope.paramItemClassTypeList = [ + 'int', 'double', 'java.lang.String', 'long', 'float', 'char', 'byte' + ]; + + $scope.rulesPageConfig = { + pageSize: 10, + currentPageIndex: 1, + totalPage: 1, + totalCount: 0, + }; + $scope.macsInputConfig = { + searchField: ['text', 'value'], + persist: true, + create: false, + maxItems: 1, + render: { + item: function (data, escape) { + return '
' + escape(data.text) + '
'; + } + }, + onChange: function (value, oldValue) { + $scope.macInputModel = value; + } + }; + + function updateSingleParamItem(arr, v, t, c) { + for (let i = 0; i < arr.length; i++) { + if (arr[i].object === v && arr[i].classType === t) { + arr[i].count = c; + return; + } + } + arr.push({object: v, classType: t, count: c}); + } + + function removeSingleParamItem(arr, v, t) { + for (let i = 0; i < arr.length; i++) { + if (arr[i].object === v && arr[i].classType === t) { + arr.splice(i, 1); + break; + } + } + } + + function isNumberClass(classType) { + return classType === 'int' || classType === 'double' || + classType === 'float' || classType === 'long' || classType === 'short'; + } + + function isByteClass(classType) { + return classType === 'byte'; + } + + function notNumberAtLeastZero(num) { + return num === undefined || num === '' || isNaN(num) || num < 0; + } + + function notGoodNumber(num) { + return num === undefined || num === '' || isNaN(num); + } + + function notGoodNumberBetweenExclusive(num, l ,r) { + return num === undefined || num === '' || isNaN(num) || num < l || num > r; + } + + $scope.notValidParamItem = (curExItem) => { + if (isNumberClass(curExItem.classType) && notGoodNumber(curExItem.object)) { + return true; + } + if (isByteClass(curExItem.classType) && notGoodNumberBetweenExclusive(curExItem.object, -128, 127)) { + return true; + } + return curExItem.object === undefined || curExItem.classType === undefined || + notNumberAtLeastZero(curExItem.count); + }; + + $scope.addParamItem = () => { + updateSingleParamItem($scope.currentRule.rule.paramFlowItemList, + $scope.curExItem.object, $scope.curExItem.classType, $scope.curExItem.count); + let oldItem = $scope.curExItem; + $scope.curExItem = {classType: oldItem.classType}; + }; + + $scope.removeParamItem = (v, t) => { + removeSingleParamItem($scope.currentRule.rule.paramFlowItemList, v, t); + }; + + function getMachineRules() { + if (!$scope.macInputModel) { + return; + } + let mac = $scope.macInputModel.split(':'); + ParamFlowService.queryMachineRules($scope.app, mac[0], mac[1]) + .success(function (data) { + if (data.code === 0 && data.data) { + $scope.loadError = undefined; + $scope.rules = data.data; + $scope.rulesPageConfig.totalCount = $scope.rules.length; + } else { + $scope.rules = []; + $scope.rulesPageConfig.totalCount = 0; + if (data.code === UNSUPPORTED_CODE) { + $scope.loadError = {message: "机器 " + mac[0] + ":" + mac[1] + " 的 Sentinel 客户端版本不支持热点参数限流功能,请升级至 0.2.0 以上版本并引入 sentinel-parameter-flow-control 依赖。"} + } else { + $scope.loadError = {message: data.msg} + } + } + }) + .error((data, header, config, status) => { + $scope.loadError = {message: "未知错误"} + }); + } + $scope.getMachineRules = getMachineRules; + getMachineRules(); + + var paramFlowRuleDialog; + + $scope.editRule = function (rule) { + $scope.currentRule = angular.copy(rule); + if ($scope.currentRule.rule && $scope.currentRule.rule.durationInSec === undefined) { + $scope.currentRule.rule.durationInSec = 1; + } + $scope.paramFlowRuleDialog = { + title: '编辑热点规则', + type: 'edit', + confirmBtnText: '保存', + supportAdvanced: true, + showAdvanceButton: rule.rule.paramFlowItemList === undefined || rule.rule.paramFlowItemList.length <= 0 + }; + paramFlowRuleDialog = ngDialog.open({ + template: '/app/views/dialog/param-flow-rule-dialog.html', + width: 680, + overlay: true, + scope: $scope + }); + $scope.curExItem = {}; + }; + + $scope.addNewRule = function () { + var mac = $scope.macInputModel.split(':'); + $scope.currentRule = { + app: $scope.app, + ip: mac[0], + port: mac[1], + rule: { + grade: 1, + paramFlowItemList: [], + count: 0, + limitApp: 'default', + controlBehavior: 0, + durationInSec: 1, + burstCount: 0, + maxQueueingTimeMs: 0, + clusterMode: false, + clusterConfig: { + thresholdType: 0, + fallbackToLocalWhenFail: true, + } + } + }; + $scope.paramFlowRuleDialog = { + title: '新增热点规则', + type: 'add', + confirmBtnText: '新增', + supportAdvanced: true, + showAdvanceButton: true, + }; + paramFlowRuleDialog = ngDialog.open({ + template: '/app/views/dialog/param-flow-rule-dialog.html', + width: 680, + overlay: true, + scope: $scope + }); + $scope.curExItem = {}; + }; + + $scope.onOpenAdvanceClick = function () { + $scope.paramFlowRuleDialog.showAdvanceButton = false; + }; + $scope.onCloseAdvanceClick = function () { + $scope.paramFlowRuleDialog.showAdvanceButton = true; + }; + + $scope.saveRule = function () { + if (!ParamFlowService.checkRuleValid($scope.currentRule.rule)) { + return; + } + if ($scope.paramFlowRuleDialog.type === 'add') { + addNewRuleAndPush($scope.currentRule); + } else if ($scope.paramFlowRuleDialog.type === 'edit') { + saveRuleAndPush($scope.currentRule, true); + } + }; + + function addNewRuleAndPush(rule) { + ParamFlowService.addNewRule(rule).success((data) => { + if (data.success) { + getMachineRules(); + paramFlowRuleDialog.close(); + } else { + alert('添加规则失败:' + data.msg); + } + }).error((data) => { + if (data) { + alert('添加规则失败:' + data.msg); + } else { + alert("添加规则失败:未知错误"); + } + }); + } + + function saveRuleAndPush(rule, edit) { + ParamFlowService.saveRule(rule).success(function (data) { + if (data.success) { + alert("修改规则成功"); + getMachineRules(); + if (edit) { + paramFlowRuleDialog.close(); + } else { + confirmDialog.close(); + } + } else { + alert('修改规则失败:' + data.msg); + } + }).error((data) => { + if (data) { + alert('修改规则失败:' + data.msg); + } else { + alert("修改规则失败:未知错误"); + } + }); + } + + function deleteRuleAndPush(entity) { + if (entity.id === undefined || isNaN(entity.id)) { + alert('规则 ID 不合法!'); + return; + } + ParamFlowService.deleteRule(entity).success((data) => { + if (data.code == 0) { + getMachineRules(); + confirmDialog.close(); + } else { + alert('删除规则失败:' + data.msg); + } + }).error((data) => { + if (data) { + alert('删除规则失败:' + data.msg); + } else { + alert("删除规则失败:未知错误"); + } + }); + }; + + var confirmDialog; + $scope.deleteRule = function (ruleEntity) { + $scope.currentRule = ruleEntity; + console.log('deleting: ' + ruleEntity); + $scope.confirmDialog = { + title: '删除热点规则', + type: 'delete_rule', + attentionTitle: '请确认是否删除如下热点参数限流规则', + attention: '资源名: ' + ruleEntity.rule.resource + ', 热点参数索引: ' + ruleEntity.rule.paramIdx + + ', 限流模式: ' + (ruleEntity.rule.grade === 1 ? 'QPS' : '未知') + ', 限流阈值: ' + ruleEntity.rule.count, + confirmBtnText: '删除', + }; + confirmDialog = ngDialog.open({ + template: '/app/views/dialog/confirm-dialog.html', + scope: $scope, + overlay: true + }); + }; + + $scope.confirm = function () { + if ($scope.confirmDialog.type === 'delete_rule') { + deleteRuleAndPush($scope.currentRule); + } else { + console.error('error'); + } + }; + + queryAppMachines(); + + function queryAppMachines() { + MachineService.getAppMachines($scope.app).success( + function (data) { + if (data.code == 0) { + // $scope.machines = data.data; + if (data.data) { + $scope.machines = []; + $scope.macsInputOptions = []; + data.data.forEach(function (item) { + if (item.healthy) { + $scope.macsInputOptions.push({ + text: item.ip + ':' + item.port, + value: item.ip + ':' + item.port + }); + } + }); + } + if ($scope.macsInputOptions.length > 0) { + $scope.macInputModel = $scope.macsInputOptions[0].value; + } + } else { + $scope.macsInputOptions = []; + } + } + ); + }; + $scope.$watch('macInputModel', function () { + if ($scope.macInputModel) { + getMachineRules(); + } + }); + }]); \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/system.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/system.js new file mode 100755 index 00000000..5b3107ff --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/system.js @@ -0,0 +1,239 @@ +var app = angular.module('sentinelDashboardApp'); + +app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialog', 'MachineService', + function ($scope, $stateParams, SystemService, + ngDialog, MachineService) { + //初始化 + $scope.app = $stateParams.app; + $scope.rulesPageConfig = { + pageSize: 10, + currentPageIndex: 1, + totalPage: 1, + totalCount: 0, + }; + $scope.macsInputConfig = { + searchField: ['text', 'value'], + persist: true, + create: false, + maxItems: 1, + render: { + item: function (data, escape) { + return '
' + escape(data.text) + '
'; + } + }, + onChange: function (value, oldValue) { + $scope.macInputModel = value; + } + }; + + getMachineRules(); + function getMachineRules() { + if (!$scope.macInputModel) { + return; + } + let mac = $scope.macInputModel.split(':'); + SystemService.queryMachineRules($scope.app, mac[0], mac[1]).success( + function (data) { + if (data.code === 0 && data.data) { + $scope.rules = data.data; + $.each($scope.rules, function (idx, rule) { + if (rule.highestSystemLoad >= 0) { + rule.grade = 0; + } else if (rule.avgRt >= 0) { + rule.grade = 1; + } else if (rule.maxThread >= 0) { + rule.grade = 2; + } else if (rule.qps >= 0) { + rule.grade = 3; + } else if (rule.highestCpuUsage >= 0) { + rule.grade = 4; + } + }); + $scope.rulesPageConfig.totalCount = $scope.rules.length; + } else { + $scope.rules = []; + $scope.rulesPageConfig.totalCount = 0; + } + }); + } + + $scope.getMachineRules = getMachineRules; + var systemRuleDialog; + $scope.editRule = function (rule) { + $scope.currentRule = angular.copy(rule); + $scope.systemRuleDialog = { + title: '编辑系统保护规则', + type: 'edit', + confirmBtnText: '保存' + }; + systemRuleDialog = ngDialog.open({ + template: '/app/views/dialog/system-rule-dialog.html', + width: 680, + overlay: true, + scope: $scope + }); + }; + + $scope.addNewRule = function () { + var mac = $scope.macInputModel.split(':'); + $scope.currentRule = { + grade: 0, + app: $scope.app, + ip: mac[0], + port: mac[1], + }; + $scope.systemRuleDialog = { + title: '新增系统保护规则', + type: 'add', + confirmBtnText: '新增' + }; + systemRuleDialog = ngDialog.open({ + template: '/app/views/dialog/system-rule-dialog.html', + width: 680, + overlay: true, + scope: $scope + }); + }; + + $scope.saveRule = function () { + if ($scope.systemRuleDialog.type === 'add') { + addNewRule($scope.currentRule); + } else if ($scope.systemRuleDialog.type === 'edit') { + saveRule($scope.currentRule, true); + } + }; + + var confirmDialog; + $scope.deleteRule = function (rule) { + $scope.currentRule = rule; + var ruleTypeDesc = ''; + var ruleTypeCount = null; + if (rule.highestSystemLoad != -1) { + ruleTypeDesc = 'LOAD'; + ruleTypeCount = rule.highestSystemLoad; + } else if (rule.avgRt != -1) { + ruleTypeDesc = 'RT'; + ruleTypeCount = rule.avgRt; + } else if (rule.maxThread != -1) { + ruleTypeDesc = '线程数'; + ruleTypeCount = rule.maxThread; + } else if (rule.qps != -1) { + ruleTypeDesc = 'QPS'; + ruleTypeCount = rule.qps; + }else if (rule.highestCpuUsage != -1) { + ruleTypeDesc = 'CPU 使用率'; + ruleTypeCount = rule.highestCpuUsage; + } + + $scope.confirmDialog = { + title: '删除系统保护规则', + type: 'delete_rule', + attentionTitle: '请确认是否删除如下系统保护规则', + attention: '阈值类型: ' + ruleTypeDesc + ', 阈值: ' + ruleTypeCount, + confirmBtnText: '删除', + }; + confirmDialog = ngDialog.open({ + template: '/app/views/dialog/confirm-dialog.html', + scope: $scope, + overlay: true + }); + }; + + + $scope.confirm = function () { + if ($scope.confirmDialog.type === 'delete_rule') { + deleteRule($scope.currentRule); + // } else if ($scope.confirmDialog.type == 'enable_rule') { + // $scope.currentRule.enable = true; + // saveRule($scope.currentRule); + // } else if ($scope.confirmDialog.type == 'disable_rule') { + // $scope.currentRule.enable = false; + // saveRule($scope.currentRule); + // } else if ($scope.confirmDialog.type == 'enable_all') { + // enableAll($scope.app); + // } else if ($scope.confirmDialog.type == 'disable_all') { + // disableAll($scope.app); + } else { + console.error('error'); + } + }; + + function deleteRule(rule) { + SystemService.deleteRule(rule).success(function (data) { + if (data.code === 0) { + getMachineRules(); + confirmDialog.close(); + } else if (data.msg != null) { + alert('失败:' + data.msg); + } else { + alert('失败:未知错误'); + } + }); + } + + function addNewRule(rule) { + if (rule.grade == 4 && (rule.highestCpuUsage < 0 || rule.highestCpuUsage > 1)) { + alert('CPU 使用率模式的取值范围应为 [0.0, 1.0],对应 0% - 100%'); + return; + } + SystemService.newRule(rule).success(function (data) { + if (data.code === 0) { + getMachineRules(); + systemRuleDialog.close(); + } else if (data.msg != null) { + alert('失败:' + data.msg); + } else { + alert('失败:未知错误'); + } + }); + } + + function saveRule(rule, edit) { + SystemService.saveRule(rule).success(function (data) { + if (data.code === 0) { + getMachineRules(); + if (edit) { + systemRuleDialog.close(); + } else { + confirmDialog.close(); + } + } else if (data.msg != null) { + alert('失败:' + data.msg); + } else { + alert('失败:未知错误'); + } + }); + } + queryAppMachines(); + function queryAppMachines() { + MachineService.getAppMachines($scope.app).success( + function (data) { + if (data.code === 0) { + // $scope.machines = data.data; + if (data.data) { + $scope.machines = []; + $scope.macsInputOptions = []; + data.data.forEach(function (item) { + if (item.healthy) { + $scope.macsInputOptions.push({ + text: item.ip + ':' + item.port, + value: item.ip + ':' + item.port + }); + } + }); + } + if ($scope.macsInputOptions.length > 0) { + $scope.macInputModel = $scope.macsInputOptions[0].value; + } + } else { + $scope.macsInputOptions = []; + } + } + ); + }; + $scope.$watch('macInputModel', function () { + if ($scope.macInputModel) { + getMachineRules(); + } + }); + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/header/header.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/header/header.html new file mode 100755 index 00000000..4584e89b --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/header/header.html @@ -0,0 +1,15 @@ +
+ + + +
\ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/header/header.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/header/header.js new file mode 100755 index 00000000..b10c672d --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/header/header.js @@ -0,0 +1,53 @@ +/** + * @ngdoc directive + * @name izzyposWebApp.directive:adminPosHeader + * @description + * # adminPosHeader + */ +angular.module('sentinelDashboardApp') + .directive('header', ['VersionService', 'AuthService', function () { + return { + templateUrl: 'app/scripts/directives/header/header.html', + restrict: 'E', + replace: true, + controller: function ($scope, $state, $window, VersionService, AuthService) { + VersionService.version().success(function (data) { + if (data.code == 0) { + $scope.dashboardVersion = data.data; + } + }); + + if (!$window.localStorage.getItem("session_sentinel_admin")) { + AuthService.check().success(function (data) { + if (data.code == 0) { + $window.localStorage.setItem('session_sentinel_admin', JSON.stringify(data.data)); + handleLogout($scope, data.data.id) + } else { + $state.go('login'); + } + }); + } else { + handleLogout($scope, JSON.parse($window.localStorage.getItem("session_sentinel_admin")).id) + } + + function handleLogout($scope, id) { + if (id == 'FAKE_EMP_ID') { + $scope.showLogout = false; + } else { + $scope.showLogout = true; + } + } + + $scope.logout = function () { + AuthService.logout().success(function (data) { + if (data.code == 0) { + $window.localStorage.removeItem("session_sentinel_admin"); + $state.go('login'); + } else { + alert('logout error'); + } + }); + } + } + } + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar-search/sidebar-search.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar-search/sidebar-search.html new file mode 100755 index 00000000..18b2b3a9 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar-search/sidebar-search.html @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar-search/sidebar-search.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar-search/sidebar-search.js new file mode 100755 index 00000000..31acca6e --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar-search/sidebar-search.js @@ -0,0 +1,20 @@ +/** + * @ngdoc directive + * @name izzyposWebApp.directive:adminPosHeader + * @description + * # adminPosHeader + */ + +angular.module('sentinelDashboardApp') + .directive('sidebarSearch', function () { + return { + templateUrl: 'app/scripts/directives/sidebar/sidebar-search/sidebar-search.html', + restrict: 'E', + replace: true, + scope: { + }, + controller: function ($scope) { + $scope.selectedMenu = 'home'; + } + } + }); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.html new file mode 100755 index 00000000..a7212629 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.html @@ -0,0 +1,91 @@ + \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.js new file mode 100755 index 00000000..7ef57401 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.js @@ -0,0 +1,71 @@ +angular.module('sentinelDashboardApp') + .directive('sidebar', ['$location', '$stateParams', 'AppService', function () { + return { + templateUrl: 'app/scripts/directives/sidebar/sidebar.html', + restrict: 'E', + replace: true, + scope: { + }, + controller: function ($scope, $stateParams, $location, AppService) { + $scope.app = $stateParams.app; + $scope.collapseVar = 0; + + // app + AppService.getApps().success( + function (data) { + if (data.code === 0) { + let path = $location.path().split('/'); + let initHashApp = path[path.length - 1]; + $scope.apps = data.data; + $scope.apps = $scope.apps.map(function (item) { + if (item.app === initHashApp) { + item.active = true; + } + let healthyCount = 0; + for (let i in item.machines) { + if (item.machines[i].healthy) { + healthyCount++; + } + } + item.healthyCount = healthyCount; + // Handle appType + item.isGateway = item.appType === 1 || item.appType === 11 || item.appType === 12; + + if (item.shown) { + return item; + } + }); + } + } + ); + + // toggle side bar + $scope.click = function ($event) { + let entry = angular.element($event.target).scope().entry; + entry.active = !entry.active;// toggle this clicked app bar + + $scope.apps.forEach(function (item) { // collapse other app bars + if (item !== entry) { + item.active = false; + } + }); + }; + + /** + * @deprecated + */ + $scope.addSearchApp = function () { + let findApp = false; + for (let i = 0; i < $scope.apps.length; i++) { + if ($scope.apps[i].app === $scope.searchApp) { + findApp = true; + break; + } + } + if (!findApp) { + $scope.apps.push({ app: $scope.searchApp }); + } + }; + } + }; + }]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/filters/filters.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/filters/filters.js new file mode 100755 index 00000000..f39b08f7 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/filters/filters.js @@ -0,0 +1,17 @@ +var app = angular.module('sentinelDashboardApp'); + +app.filter('range', [function () { + return function (input, length) { + if (isNaN(length) || length <= 0) { + return []; + } + + input = []; + for (var index = 1; index <= length; index++) { + input.push(index); + } + + return input; + }; + +}]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/libs/treeTable.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/libs/treeTable.js new file mode 100755 index 00000000..1eff197d --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/libs/treeTable.js @@ -0,0 +1,292 @@ +var com_github_culmat_jsTreeTable = (function(){ + + function depthFirst(tree, func, childrenAttr) { + childrenAttr = childrenAttr || 'children' + function i_depthFirst(node) { + if (node[childrenAttr]) { + $.each(node[childrenAttr], function(i, child) { + i_depthFirst(child) + }) + } + func(node) + } + $.each(tree, function(i, root) { + i_depthFirst(root) + }) + return tree + } + + /* + * make a deep copy of the object + */ + function copy(data){ + return JSON.parse(JSON.stringify(data)) + } + + function makeTree (data, idAttr, refAttr, childrenAttr) { + var data_tmp = data + idAttr = idAttr || 'id' + refAttr = refAttr || 'parent' + childrenAttr = childrenAttr || 'children' + + var byName = [] + $.each(data_tmp, function(i, entry) { + byName[entry[idAttr]] = entry + }) + var tree = [] + $.each(data_tmp, function(i, entry) { + var parents = entry[refAttr] + if(!$.isArray(parents)){ + parents = [parents] + } + if(parents.length == 0){ + tree.push(entry) + } else { + var inTree = false; + $.each(parents, function(i,parentID){ + var parent = byName[parentID] + if (parent) { + if (!parent[childrenAttr]) { + parent[childrenAttr] = [] + } + if($.inArray(entry, parent[childrenAttr])< 0) + parent[childrenAttr].push(entry) + inTree = true + } + }) + if(!inTree){ + tree.push(entry) + } + } + }) + return tree + } + + function renderTree(tree, childrenAttr, idAttr, attrs, renderer, tableAttributes) { + childrenAttr = childrenAttr || 'children' + idAttr = idAttr || 'id' + tableAttributes = tableAttributes || {} + var maxLevel = 0; + var ret = [] + + var table = $("") + $.each(tableAttributes, function(key, value){ + if(key == 'class' && value != 'jsTT') { + table.addClass(value) + } else { + table.attr(key, value) + } + }) + var thead = $("") + var tr = $("") + var tbody = $("") + + table.append(thead) + thead.append(tr) + table.append(tbody) + if (attrs) { + $.each(attrs, function(attr, desc) { + $(tr).append($('')) + }) + } else { + $(tr).append($('')) + $.each(tree[0], function(key, value) { + if (key != childrenAttr && key != idAttr) + $(tr).append($('')) + }) + } + + function render(node, parent) { + var tr = $("") + $(tr).attr('data-tt-id', node[idAttr]) + $(tr).attr('data-tt-level', node['data-tt-level']) + if(!node[childrenAttr] || node[childrenAttr].length == 0) + $(tr).attr('data-tt-isleaf', true) + else + $(tr).attr('data-tt-isnode', true) + if (parent) { + $(tr).attr('data-tt-parent-id', parent[idAttr]) + } + if (renderer) { + renderer($(tr), node) + }else if (attrs) { + $.each(attrs, function(attr, desc) { + $(tr).append($('')) + }) + } else { + $(tr).append($('')) + $.each(node, function(key, value) { + if (key != childrenAttr && key != idAttr && key != 'data-tt-level') + $(tr).append($('')) + }) + } + tbody.append(tr) + } + + function i_renderTree(subTree, childrenAttr, level, parent) { + maxLevel = Math.max(maxLevel, level) + $.each(subTree, function(i, node) { + node['data-tt-level'] = level + render(node, parent) + if (node[childrenAttr]) { + $.each(node[childrenAttr], function(i, child) { + i_renderTree([ child ], childrenAttr, level + 1, node) + }) + } + }) + } + i_renderTree(tree, childrenAttr, 1) + if (tree[0]) + tree[0].maxLevel = maxLevel + return table + } + + function attr2attr(nodes, attrs){ + $.each(nodes, function(i, node) { + $.each(attrs, function(j, at) { + node[at] = $(node).attr(at) + }) + }) + return nodes + } + + function treeTable(table){ + table.addClass('jsTT') + table.expandLevel = function (n) { + $("tr[data-tt-level]", table).each(function(index) { + var level = parseInt($(this).attr('data-tt-level')) + if (level > n-1) { + this.trCollapse(true) + } else if (level == n-1){ + this.trExpand(true) + } + }) + } + function getLevel(node){ + var level = node.attr('data-tt-level') + if(level != undefined ) return parseInt(level) + var parentID = node.attr('data-tt-parent-id') + if( parentID == undefined){ + return 0 + } else { + return getLevel($('tr[data-tt-id="'+parentID+'"]', table).first()) + 1 + } + } + $("tr[data-tt-id]", table).each(function(i,node){ + node = $(node) + node.attr('data-tt-level', getLevel(node)) + }) + var dat = $("tr[data-tt-level]", table).get() + $.each(dat, function(j, d) { + d.trChildrenVisible = true + d.trChildren = [] + }) + dat = attr2attr(dat, ['data-tt-id', 'data-tt-parent-id']) + dat = makeTree(dat, 'data-tt-id', 'data-tt-parent-id', 'trChildren') + + var imgExpand = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAAHlJREFUeNrcU1sNgDAQ6wgmcAM2MICGGlg1gJnNzWQcvwQGy1j4oUl/7tH0mpwzM7SgQyO+EZAUWh2MkkzSWhJwuRAlHYsJwEwyvs1gABDuzqoJcTw5qxaIJN0bgQRgIjnlmn1heSO5PE6Y2YXe+5Cr5+h++gs12AcAS6FS+7YOsj4AAAAASUVORK5CYII=" + var imgCollapse = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAAHFJREFUeNpi/P//PwMlgImBQsA44C6gvhfa29v3MzAwOODRc6CystIRbxi0t7fjDJjKykpGYrwwi1hxnLHQ3t7+jIGBQRJJ6HllZaUUKYEYRYBPOB0gBShKwKGA////48VtbW3/8clTnBIH3gCKkzJgAGvBX0dDm0sCAAAAAElFTkSuQmCC" + $("tr[data-tt-level]", table).each(function(index, tr) { + var level = $(tr).attr('data-tt-level') + var td = $("td",tr).first() + if(tr.trChildren.length>0){ + td.prepend($('')) + } else { + td.prepend($('')) + } + td.prepend($('')) + // td.css('white-space','nowrap') + tr.trExpand = function(changeState){ + if(this.trChildren.length < 1) return + if(changeState) { + this.trChildrenVisible = true + $('#state', this).get(0).src= imgCollapse + } + var doit = changeState || this.trChildrenVisible + $.each(this.trChildren, function(i, ctr) { + if(doit) $(ctr).css('display', 'table-row') + ctr.trExpand() + }) + } + tr.trCollapse = function(changeState){ + if(this.trChildren.length < 1) return + if(changeState) { + this.trChildrenVisible = false + $('#state', this).get(0).src= imgExpand + } + $.each(this.trChildren, function(i, ctr) { + $(ctr).css('display', 'none') + ctr.trCollapse() + }) + } + $(tr).click(function() { + this.trChildrenVisible ? this.trCollapse(true) : this.trExpand(true) + }) + }) + return table + } + + function appendTreetable(tree, options) { + function inALine(nodes) { + var tr = $('') + $.each(nodes, function(i, node){ + tr.append($('
' + desc + '' + idAttr + '' + key + '
' + node[attr] + '' + node[idAttr] + '' + value + '
').append(node)) + }) + return $('').append(tr) + + } + options = options || {} + options.idAttr = (options.idAttr || 'id') + options.childrenAttr = (options.childrenAttr || 'children') + var controls = (options.controls || []) + + if (!options.mountPoint) + options.mountPoint = $('body') + + if (options.depthFirst) + depthFirst(tree, options.depthFirst, options.childrenAttr) + var rendered = renderTree(tree, options.childrenAttr, options.idAttr, + options.renderedAttr, options.renderer, options.tableAttributes) + + treeTable(rendered) + if (options.replaceContent) { + options.mountPoint.html('') + } + var initialExpandLevel = options.initialExpandLevel ? parseInt(options.initialExpandLevel) : -1 + initialExpandLevel = Math.min(initialExpandLevel, tree[0].maxLevel) + rendered.expandLevel(initialExpandLevel) + if(options.slider){ + var slider = $('
') + slider.width('200px') + slider.slider({ + min : 1, + max : tree[0].maxLevel, + range : "min", + value : initialExpandLevel, + slide : function(event, ui) { + rendered.expandLevel(ui.value) + } + }) + controls = [slider].concat(options.controls) + } + + if(controls.length >0){ + options.mountPoint.append(inALine(controls)) + } + options.mountPoint.append(rendered) + return rendered + } + + return { + depthFirst : depthFirst, + makeTree : makeTree, + renderTree : renderTree, + attr2attr : attr2attr, + treeTable : treeTable, + appendTreetable : appendTreetable, + jsTreeTable : '1.0', + register : function(target){ + $.each(this, function(key, value){ if(key != 'register') target[key] = value}) + } + } +})(); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/appservice.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/appservice.js new file mode 100755 index 00000000..47705836 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/appservice.js @@ -0,0 +1,12 @@ + +var app = angular.module('sentinelDashboardApp'); + +app.service('AppService', ['$http', function ($http) { + this.getApps = function () { + return $http({ + // url: 'app/mock_infos', + url: 'app/briefinfos.json', + method: 'GET' + }); + }; +}]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/auth_service.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/auth_service.js new file mode 100755 index 00000000..fec1cf4a --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/auth_service.js @@ -0,0 +1,25 @@ +var app = angular.module('sentinelDashboardApp'); + +app.service('AuthService', ['$http', function ($http) { + this.check = function () { + return $http({ + url: '/auth/check', + method: 'POST' + }); + }; + + this.login = function (param) { + return $http({ + url: '/auth/login', + params: param, + method: 'POST' + }); + }; + + this.logout = function () { + return $http({ + url: '/auth/logout', + method: 'POST' + }); + }; +}]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/authority_service.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/authority_service.js new file mode 100755 index 00000000..42a61012 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/authority_service.js @@ -0,0 +1,56 @@ +/** + * Authority rule service. + */ +angular.module('sentinelDashboardApp').service('AuthorityRuleService', ['$http', function ($http) { + this.queryMachineRules = function(app, ip, port) { + var param = { + app: app, + ip: ip, + port: port + }; + return $http({ + url: '/authority/rules', + params: param, + method: 'GET' + }); + }; + + this.addNewRule = function(rule) { + return $http({ + url: '/authority/rule', + data: rule, + method: 'POST' + }); + }; + + this.saveRule = function (entity) { + return $http({ + url: '/authority/rule/' + entity.id, + data: entity, + method: 'PUT' + }); + }; + + this.deleteRule = function (entity) { + return $http({ + url: '/authority/rule/' + entity.id, + method: 'DELETE' + }); + }; + + this.checkRuleValid = function checkRuleValid(rule) { + if (rule.resource === undefined || rule.resource === '') { + alert('资源名称不能为空'); + return false; + } + if (rule.limitApp === undefined || rule.limitApp === '') { + alert('流控针对应用不能为空'); + return false; + } + if (rule.strategy === undefined) { + alert('必须选择黑白名单模式'); + return false; + } + return true; + }; +}]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/cluster_state_service.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/cluster_state_service.js new file mode 100755 index 00000000..7bca8161 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/cluster_state_service.js @@ -0,0 +1,73 @@ +/** + * Cluster state control service. + * + * @author Eric Zhao + */ +angular.module('sentinelDashboardApp').service('ClusterStateService', ['$http', function ($http) { + + this.fetchClusterUniversalStateSingle = function(app, ip, port) { + var param = { + app: app, + ip: ip, + port: port + }; + return $http({ + url: '/cluster/state_single', + params: param, + method: 'GET' + }); + }; + + this.fetchClusterUniversalStateOfApp = function(app) { + return $http({ + url: '/cluster/state/' + app, + method: 'GET' + }); + }; + + this.fetchClusterServerStateOfApp = function(app) { + return $http({ + url: '/cluster/server_state/' + app, + method: 'GET' + }); + }; + + this.fetchClusterClientStateOfApp = function(app) { + return $http({ + url: '/cluster/client_state/' + app, + method: 'GET' + }); + }; + + this.modifyClusterConfig = function(config) { + return $http({ + url: '/cluster/config/modify_single', + data: config, + method: 'POST' + }); + }; + + this.applyClusterFullAssignOfApp = function(app, clusterMap) { + return $http({ + url: '/cluster/assign/all_server/' + app, + data: clusterMap, + method: 'POST' + }); + }; + + this.applyClusterSingleServerAssignOfApp = function(app, request) { + return $http({ + url: '/cluster/assign/single_server/' + app, + data: request, + method: 'POST' + }); + }; + + this.applyClusterServerBatchUnbind = function(app, machineSet) { + return $http({ + url: '/cluster/assign/unbind_server/' + app, + data: machineSet, + method: 'POST' + }); + }; +}]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/degradeservice.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/degradeservice.js new file mode 100755 index 00000000..146d841d --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/degradeservice.js @@ -0,0 +1,88 @@ +var app = angular.module('sentinelDashboardApp'); + +app.service('DegradeService', ['$http', function ($http) { + this.queryMachineRules = function (app, ip, port) { + var param = { + app: app, + ip: ip, + port: port + }; + return $http({ + url: 'degrade/rules.json', + params: param, + method: 'GET' + }); + }; + + this.newRule = function (rule) { + var param = { + id: rule.id, + resource: rule.resource, + limitApp: rule.limitApp, + count: rule.count, + timeWindow: rule.timeWindow, + grade: rule.grade, + app: rule.app, + ip: rule.ip, + port: rule.port + }; + return $http({ + url: '/degrade/new.json', + params: param, + method: 'GET' + }); + }; + + this.saveRule = function (rule) { + var param = { + id: rule.id, + resource: rule.resource, + limitApp: rule.limitApp, + grade: rule.grade, + count: rule.count, + timeWindow: rule.timeWindow, + }; + return $http({ + url: '/degrade/save.json', + params: param, + method: 'GET' + }); + }; + + this.deleteRule = function (rule) { + var param = { + id: rule.id, + app: rule.app + }; + return $http({ + url: '/degrade/delete.json', + params: param, + method: 'GET' + }); + }; + + this.checkRuleValid = function (rule) { + if (rule.resource === undefined || rule.resource === '') { + alert('资源名称不能为空'); + return false; + } + if (rule.grade === undefined || rule.grade < 0) { + alert('未知的降级策略'); + return false; + } + if (rule.count === undefined || rule.count === '' || rule.count < 0) { + alert('降级阈值不能为空或小于 0'); + return false; + } + if (rule.timeWindow === undefined || rule.timeWindow === '' || rule.timeWindow <= 0) { + alert('降级时间窗口必须大于 0'); + return false; + } + // 异常比率类型. + if (rule.grade == 1 && rule.count > 1) { + alert('异常比率超出范围:[0.0 - 1.0]'); + return false; + } + return true; + }; +}]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/flow_service_v1.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/flow_service_v1.js new file mode 100755 index 00000000..051a3c71 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/flow_service_v1.js @@ -0,0 +1,119 @@ +var app = angular.module('sentinelDashboardApp'); + +app.service('FlowServiceV1', ['$http', function ($http) { + this.queryMachineRules = function (app, ip, port) { + var param = { + app: app, + ip: ip, + port: port + }; + return $http({ + url: '/v1/flow/rules', + params: param, + method: 'GET' + }); + }; + + this.newRule = function (rule) { + var param = { + resource: rule.resource, + limitApp: rule.limitApp, + grade: rule.grade, + count: rule.count, + strategy: rule.strategy, + refResource: rule.refResource, + controlBehavior: rule.controlBehavior, + warmUpPeriodSec: rule.warmUpPeriodSec, + maxQueueingTimeMs: rule.maxQueueingTimeMs, + app: rule.app, + ip: rule.ip, + port: rule.port + }; + + return $http({ + url: '/v1/flow/rule', + data: rule, + method: 'POST' + }); + }; + + this.saveRule = function (rule) { + var param = { + id: rule.id, + resource: rule.resource, + limitApp: rule.limitApp, + grade: rule.grade, + count: rule.count, + strategy: rule.strategy, + refResource: rule.refResource, + controlBehavior: rule.controlBehavior, + warmUpPeriodSec: rule.warmUpPeriodSec, + maxQueueingTimeMs: rule.maxQueueingTimeMs, + }; + + return $http({ + url: '/v1/flow/save.json', + params: param, + method: 'PUT' + }); + }; + + this.deleteRule = function (rule) { + var param = { + id: rule.id, + app: rule.app + }; + + return $http({ + url: '/v1/flow/delete.json', + params: param, + method: 'DELETE' + }); + }; + + function notNumberAtLeastZero(num) { + return num === undefined || num === '' || isNaN(num) || num < 0; + } + + function notNumberGreaterThanZero(num) { + return num === undefined || num === '' || isNaN(num) || num <= 0; + } + + this.checkRuleValid = function (rule) { + if (rule.resource === undefined || rule.resource === '') { + alert('资源名称不能为空'); + return false; + } + if (rule.count === undefined || rule.count < 0) { + alert('限流阈值必须大于等于 0'); + return false; + } + if (rule.strategy === undefined || rule.strategy < 0) { + alert('无效的流控模式'); + return false; + } + if (rule.strategy == 1 || rule.strategy == 2) { + if (rule.refResource === undefined || rule.refResource == '') { + alert('请填写关联资源或入口'); + return false; + } + } + if (rule.controlBehavior === undefined || rule.controlBehavior < 0) { + alert('无效的流控整形方式'); + return false; + } + if (rule.controlBehavior == 1 && notNumberGreaterThanZero(rule.warmUpPeriodSec)) { + alert('预热时长必须大于 0'); + return false; + } + if (rule.controlBehavior == 2 && notNumberGreaterThanZero(rule.maxQueueingTimeMs)) { + alert('排队超时时间必须大于 0'); + return false; + } + if (rule.clusterMode && (rule.clusterConfig === undefined || rule.clusterConfig.thresholdType === undefined)) { + alert('集群限流配置不正确'); + return false; + } + return true; + }; +}]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/flow_service_v2.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/flow_service_v2.js new file mode 100755 index 00000000..716d66d2 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/flow_service_v2.js @@ -0,0 +1,85 @@ +var app = angular.module('sentinelDashboardApp'); + +app.service('FlowServiceV2', ['$http', function ($http) { + this.queryMachineRules = function (app, ip, port) { + var param = { + app: app, + ip: ip, + port: port + }; + return $http({ + url: '/v2/flow/rules', + params: param, + method: 'GET' + }); + }; + + this.newRule = function (rule) { + return $http({ + url: '/v2/flow/rule', + data: rule, + method: 'POST' + }); + }; + + this.saveRule = function (rule) { + return $http({ + url: '/v2/flow/rule/' + rule.id, + data: rule, + method: 'PUT' + }); + }; + + this.deleteRule = function (rule) { + return $http({ + url: '/v2/flow/rule/' + rule.id, + method: 'DELETE' + }); + }; + + function notNumberAtLeastZero(num) { + return num === undefined || num === '' || isNaN(num) || num < 0; + } + + function notNumberGreaterThanZero(num) { + return num === undefined || num === '' || isNaN(num) || num <= 0; + } + + this.checkRuleValid = function (rule) { + if (rule.resource === undefined || rule.resource === '') { + alert('资源名称不能为空'); + return false; + } + if (rule.count === undefined || rule.count < 0) { + alert('限流阈值必须大于等于 0'); + return false; + } + if (rule.strategy === undefined || rule.strategy < 0) { + alert('无效的流控模式'); + return false; + } + if (rule.strategy == 1 || rule.strategy == 2) { + if (rule.refResource === undefined || rule.refResource == '') { + alert('请填写关联资源或入口'); + return false; + } + } + if (rule.controlBehavior === undefined || rule.controlBehavior < 0) { + alert('无效的流控整形方式'); + return false; + } + if (rule.controlBehavior == 1 && notNumberGreaterThanZero(rule.warmUpPeriodSec)) { + alert('预热时长必须大于 0'); + return false; + } + if (rule.controlBehavior == 2 && notNumberGreaterThanZero(rule.maxQueueingTimeMs)) { + alert('排队超时时间必须大于 0'); + return false; + } + if (rule.clusterMode && (rule.clusterConfig === undefined || rule.clusterConfig.thresholdType === undefined)) { + alert('集群限流配置不正确'); + return false; + } + return true; + }; +}]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/gateway/api_service.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/gateway/api_service.js new file mode 100755 index 00000000..373f71db --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/gateway/api_service.js @@ -0,0 +1,73 @@ +var app = angular.module('sentinelDashboardApp'); + +app.service('GatewayApiService', ['$http', function ($http) { + this.queryApis = function (app, ip, port) { + var param = { + app: app, + ip: ip, + port: port + }; + return $http({ + url: '/gateway/api/list.json', + params: param, + method: 'GET' + }); + }; + + this.newApi = function (api) { + return $http({ + url: '/gateway/api/new.json', + data: api, + method: 'POST' + }); + }; + + this.saveApi = function (api) { + return $http({ + url: '/gateway/api/save.json', + data: api, + method: 'POST' + }); + }; + + this.deleteApi = function (api) { + var param = { + id: api.id, + app: api.app + }; + return $http({ + url: '/gateway/api/delete.json', + params: param, + method: 'POST' + }); + }; + + this.checkApiValid = function (api, apiNames) { + if (api.apiName === undefined || api.apiName === '') { + alert('API名称不能为空'); + return false; + } + + if (api.predicateItems == null || api.predicateItems.length === 0) { + // Should never happen since no remove button will display when only one predicateItem. + alert('至少有一个匹配规则'); + return false; + } + + for (var i = 0; i < api.predicateItems.length; i++) { + var predicateItem = api.predicateItems[i]; + var pattern = predicateItem.pattern; + if (pattern === undefined || pattern === '') { + alert('匹配串不能为空,请检查'); + return false; + } + } + + if (apiNames.indexOf(api.apiName) !== -1) { + alert('API名称(' + api.apiName + ')已存在'); + return false; + } + + return true; + }; +}]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/gateway/flow_service.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/gateway/flow_service.js new file mode 100755 index 00000000..b026b32f --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/gateway/flow_service.js @@ -0,0 +1,76 @@ +var app = angular.module('sentinelDashboardApp'); + +app.service('GatewayFlowService', ['$http', function ($http) { + this.queryRules = function (app, ip, port) { + var param = { + app: app, + ip: ip, + port: port + }; + + return $http({ + url: '/gateway/flow/list.json', + params: param, + method: 'GET' + }); + }; + + this.newRule = function (rule) { + return $http({ + url: '/gateway/flow/new.json', + data: rule, + method: 'POST' + }); + }; + + this.saveRule = function (rule) { + return $http({ + url: '/gateway/flow/save.json', + data: rule, + method: 'POST' + }); + }; + + this.deleteRule = function (rule) { + var param = { + id: rule.id, + app: rule.app + }; + + return $http({ + url: '/gateway/flow/delete.json', + params: param, + method: 'POST' + }); + }; + + this.checkRuleValid = function (rule) { + if (rule.resource === undefined || rule.resource === '') { + alert('API名称不能为空'); + return false; + } + + if (rule.paramItem != null) { + if (rule.paramItem.parseStrategy == 2 || + rule.paramItem.parseStrategy == 3 || + rule.paramItem.parseStrategy == 4) { + if (rule.paramItem.fieldName === undefined || rule.paramItem.fieldName === '') { + alert('当参数属性为Header、URL参数、Cookie时,参数名称不能为空'); + return false; + } + + if (rule.paramItem.pattern === '') { + alert('匹配串不能为空'); + return false; + } + } + } + + if (rule.count === undefined || rule.count < 0) { + alert((rule.grade === 1 ? 'QPS阈值' : '线程数') + '必须大于等于 0'); + return false; + } + + return true; + }; +}]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/identityservice.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/identityservice.js new file mode 100755 index 00000000..926c0021 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/identityservice.js @@ -0,0 +1,30 @@ +var app = angular.module('sentinelDashboardApp'); + +app.service('IdentityService', ['$http', function ($http) { + + this.fetchIdentityOfMachine = function (ip, port, searchKey) { + var param = { + ip: ip, + port: port, + searchKey: searchKey + }; + return $http({ + url: 'resource/machineResource.json', + params: param, + method: 'GET' + }); + }; + this.fetchClusterNodeOfMachine = function (ip, port, searchKey) { + var param = { + ip: ip, + port: port, + type: 'cluster', + searchKey: searchKey + }; + return $http({ + url: 'resource/machineResource.json', + params: param, + method: 'GET' + }); + }; +}]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/machineservice.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/machineservice.js new file mode 100755 index 00000000..2d3b5e8b --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/machineservice.js @@ -0,0 +1,25 @@ +var app = angular.module('sentinelDashboardApp'); + +app.service('MachineService', ['$http', '$httpParamSerializerJQLike', + function ($http, $httpParamSerializerJQLike) { + this.getAppMachines = function (app) { + return $http({ + url: 'app/' + app + '/machines.json', + method: 'GET' + }); + }; + this.removeAppMachine = function (app, ip, port) { + return $http({ + url: 'app/' + app + '/machine/remove.json', + method: 'POST', + headers: { + 'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8' + }, + data: $httpParamSerializerJQLike({ + ip: ip, + port: port + }) + }); + }; + }] +); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/metricservice.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/metricservice.js new file mode 100755 index 00000000..8d8a38e0 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/metricservice.js @@ -0,0 +1,36 @@ +var app = angular.module('sentinelDashboardApp'); + +app.service('MetricService', ['$http', function ($http) { + + this.queryAppSortedIdentities = function (params) { + return $http({ + url: '/metric/queryTopResourceMetric.json', + params: params, + method: 'GET' + }); + }; + + this.queryByAppAndIdentity = function (params) { + return $http({ + url: '/metric/queryByAppAndResource.json', + params: params, + method: 'GET' + }); + }; + + this.queryByMachineAndIdentity = function (ip, port, identity, startTime, endTime) { + var param = { + ip: ip, + port: port, + identity: identity, + startTime: startTime.getTime(), + endTime: endTime.getTime() + }; + + return $http({ + url: '/metric/queryByAppAndResource.json', + params: param, + method: 'GET' + }); + }; +}]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/param_flow_service.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/param_flow_service.js new file mode 100755 index 00000000..2e235554 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/param_flow_service.js @@ -0,0 +1,104 @@ +/** + * Parameter flow control service. + * + * @author Eric Zhao + */ +angular.module('sentinelDashboardApp').service('ParamFlowService', ['$http', function ($http) { + this.queryMachineRules = function(app, ip, port) { + var param = { + app: app, + ip: ip, + port: port + }; + return $http({ + url: '/paramFlow/rules', + params: param, + method: 'GET' + }); + }; + + this.addNewRule = function(rule) { + return $http({ + url: '/paramFlow/rule', + data: rule, + method: 'POST' + }); + }; + + this.saveRule = function (entity) { + return $http({ + url: '/paramFlow/rule/' + entity.id, + data: entity, + method: 'PUT' + }); + }; + + this.deleteRule = function (entity) { + return $http({ + url: '/paramFlow/rule/' + entity.id, + method: 'DELETE' + }); + }; + + function isNumberClass(classType) { + return classType === 'int' || classType === 'double' || + classType === 'float' || classType === 'long' || classType === 'short'; + } + + function isByteClass(classType) { + return classType === 'byte'; + } + + function notNumberAtLeastZero(num) { + return num === undefined || num === '' || isNaN(num) || num < 0; + } + + function notGoodNumber(num) { + return num === undefined || num === '' || isNaN(num); + } + + function notGoodNumberBetweenExclusive(num, l ,r) { + return num === undefined || num === '' || isNaN(num) || num < l || num > r; + } + + function notValidParamItem(curExItem) { + if (isNumberClass(curExItem.classType) && notGoodNumber(curExItem.object)) { + return true; + } + if (isByteClass(curExItem.classType) && notGoodNumberBetweenExclusive(curExItem.object, -128, 127)) { + return true; + } + return curExItem.object === undefined || curExItem.classType === undefined || + notNumberAtLeastZero(curExItem.count); + } + + this.checkRuleValid = function (rule) { + if (!rule.resource || rule.resource === '') { + alert('资源名称不能为空'); + return false; + } + if (rule.grade != 1) { + alert('未知的限流模式'); + return false; + } + if (rule.count < 0) { + alert('限流阈值必须大于等于 0'); + return false; + } + if (rule.paramIdx === undefined || rule.paramIdx === '' || isNaN(rule.paramIdx) || rule.paramIdx < 0) { + alert('热点参数索引必须大于等于 0'); + return false; + } + if (rule.paramFlowItemList !== undefined) { + for (var i = 0; i < rule.paramFlowItemList.length; i++) { + var item = rule.paramFlowItemList[i]; + if (notValidParamItem(item)) { + alert('热点参数例外项不合法,请检查值和类型是否正确:参数为 ' + item.object + ', 类型为 ' + + item.classType + ', 限流阈值为 ' + item.count); + return false; + } + } + } + return true; + }; +}]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/systemservice.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/systemservice.js new file mode 100755 index 00000000..8b476793 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/systemservice.js @@ -0,0 +1,77 @@ +var app = angular.module('sentinelDashboardApp'); + +app.service('SystemService', ['$http', function ($http) { + this.queryMachineRules = function (app, ip, port) { + var param = { + app: app, + ip: ip, + port: port + }; + return $http({ + url: 'system/rules.json', + params: param, + method: 'GET' + }); + }; + + this.newRule = function (rule) { + var param = { + app: rule.app, + ip: rule.ip, + port: rule.port + }; + if (rule.grade == 0) {// avgLoad + param.highestSystemLoad = rule.highestSystemLoad; + } else if (rule.grade == 1) {// avgRt + param.avgRt = rule.avgRt; + } else if (rule.grade == 2) {// maxThread + param.maxThread = rule.maxThread; + } else if (rule.grade == 3) {// qps + param.qps = rule.qps; + } else if (rule.grade == 4) {// cpu + param.highestCpuUsage = rule.highestCpuUsage; + } + + return $http({ + url: '/system/new.json', + params: param, + method: 'GET' + }); + }; + + this.saveRule = function (rule) { + var param = { + id: rule.id, + }; + if (rule.grade == 0) {// avgLoad + param.highestSystemLoad = rule.highestSystemLoad; + } else if (rule.grade == 1) {// avgRt + param.avgRt = rule.avgRt; + } else if (rule.grade == 2) {// maxThread + param.maxThread = rule.maxThread; + } else if (rule.grade == 3) {// qps + param.qps = rule.qps; + } else if (rule.grade == 4) {// cpu + param.highestCpuUsage = rule.highestCpuUsage; + } + + return $http({ + url: '/system/save.json', + params: param, + method: 'GET' + }); + }; + + this.deleteRule = function (rule) { + var param = { + id: rule.id, + app: rule.app + }; + + return $http({ + url: '/system/delete.json', + params: param, + method: 'GET' + }); + }; +}]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/version_service.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/version_service.js new file mode 100755 index 00000000..1322f563 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/version_service.js @@ -0,0 +1,10 @@ +var app = angular.module('sentinelDashboardApp'); + +app.service('VersionService', ['$http', function ($http) { + this.version = function () { + return $http({ + url: '/version', + method: 'GET' + }); + }; +}]); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/main.css b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/main.css new file mode 100755 index 00000000..bb1db2bf --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/main.css @@ -0,0 +1,1756 @@ +.browsehappy { + margin: 0.2em 0; + background: #ccc; + color: #000; + padding: 0.2em 0; +} + +body { + padding: 0; +} + +/* Everything but the jumbotron gets side spacing for mobile first views */ + +.header, +.marketing, +.footer { + padding-left: 15px; + padding-right: 15px; +} + + +/* Custom page header */ + +.header { + border-bottom: 1px solid #e5e5e5; + margin-bottom: 10px; +} + + +/* Make the masthead heading the same height as the navigation */ + +.header h3 { + margin-top: 0; + margin-bottom: 0; + line-height: 40px; + padding-bottom: 19px; +} + + +/* Custom page footer */ + +.footer { + padding-top: 19px; + color: #777; + border-top: 1px solid #e5e5e5; +} + +.container-narrow > hr { + margin: 30px 0; +} + + +/* Main marketing message and sign up button */ + +.jumbotron { + text-align: center; + border-bottom: 1px solid #e5e5e5; +} + +.jumbotron .btn { + font-size: 21px; + padding: 14px 24px; +} + + +/* Supporting marketing content */ + +.marketing { + margin: 40px 0; +} + +.marketing p + h4 { + margin-top: 28px; +} + + +/* Responsive: Portrait tablets and up */ + +@media screen and (min-width: 768px) { + .container { + width: inherit; + margin-left: 60px; + margin-right: 5px; + } + /* Remove the padding we set earlier */ + .header, + .marketing, + .footer { + padding-left: 0; + padding-right: 0; + } + /* Space out the masthead */ + .header { + margin-bottom: 30px; + } + /* Remove the bottom border on the jumbotron for visual effect */ + .jumbotron { + border-bottom: 0; + } +} + +.navbar-inverse { + background-color: #1d9d74; + border-color: #1b926c; +} + +.navbar-inverse .navbar-nav > li > a { + color: #b0ddce; + font-size: 15px; +} + +.navbar-inverse .navbar-nav>.open>a, +.navbar-inverse .navbar-nav>.open>a:focus, +.navbar-inverse .navbar-nav>.open>a:hover { + background-color: #1b926c; +} + +@media (min-width: 900px) { + .navbar-left { + float: left !important; + } + .navbar-right { + float: right !important; + margin-right: 0%; + } + .navbar-right ~ .navbar-right { + margin-right: 0; + } +} + +.dropdown-menu { + min-width: 100px !important; +} + +.nav-sidebar li.active a { + background: #DDD; +} + +.dropdown-menu>li>a:hover, .dropdown-menu>li>a:focus { + background: #1d9d74; + /*background: #d9d9d9;*/ + color: white; +} + +.broadcast-message, +.broadcast-message-preview { + padding: 10px; + text-align: center; + background: #555; + color: #BBB; + margin-top: 50px; +} + +.card { + position: relative; + border: 1px solid #d9d9d9; + border-radius: 3px; + color: #666; + background-color: #fff; + width: 100%; + border-radius: 5px; +} + +.card .card-header { + padding: 9px 0; + height: 40px; + background: #555; + color: #fff; + text-align: center; + border-top-left-radius: 4px; + border-top-right-radius: 4px; +} + +.card .card-body { + padding: 12px 10px; +} + +.card .card-footer { + height: 20px; + font-size: 10px; + color: #777; + margin-top: -15px; + margin-bottom: 5px; + margin-left: 20px; + margin-right: 20px; +} + +.card .detail-brand { + float: left; + width: 30%; + line-height: 98px; + font-size: 30px; + text-align: center; + color: white; +} + +.card .default { + background: #1d9d74; +} + +.card .info { + background: #6EBEE7; +} + +.card .warn { + background: #ED7F54; +} + +.card .danger { + background: #6583BE; +} + +.card .detail .text-default { + color: #1d9d74; +} + +.card .detail .text-info { + color: #6EBEE7; +} + +.card .detail .text-warn { + color: #ED7F54; +} + +.card .detail .text-danger { + color: #6583BE; +} + +.card .detail { + float: right; + width: 70%; + line-height: 98px; + text-align: center; +} + +.card .detail .text { + font-size: 12px; +} + +.card .detail .number { + font-size: 30px; + font-weight: 500; +} + +.h100 { + height: 100px; +} + +.inline { + display: inline; +} + +.separator { + height: 1px; + background-color: #e5e5e5; + margin-top: 10px; +} + +.card > .card-body > table > thead > tr > td, +.card > .card-body > table > tbody > tr > td { + word-wrap: break-word; + word-break: break-all; +} + +.card > .card-body > table > thead > tr > td { + font-weight: 500; + font-size: 13px; + text-align: center; +} + +.card > .card-body > table > thead > tr > td > span { + font-weight: 500; + font-size: 10px; +} + +.card > .card-body > table > tbody > tr > td { + font-size: 12px; + text-align: center; +} + +.card > .card-body > table > tbody > tr > td > a { + color: #666; +} + +.thumbnails > .card > .card-body > table > thead > tr > td, +.thumbnails > .card > .card-body > table > tbody > tr > td { + font-size: 12px; + color: #777; + word-wrap: break-word; + word-break: break-all; +} + +.thumbnails > .card > .card-body > table > thead > tr > td:nth-child(n+2) { + text-align: center; +} + +.thumbnails > .card > .card-body > table > tbody > tr > td:nth-child(n+2) { + font-weight: 700; + text-align: center; +} + +.thumbnails > .card > .card-body > table > thead > tr > td:nth-child(1), +.thumbnails > .card > .card-body > table > tbody > tr > td:nth-child(1) { + text-align: left; +} + +.tools-header { + background: whitesmoke; + padding: 9px 0; + height: 40px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; +} + +.tools-header .brand { + font-size: 13px; + margin: 2px 10px; + font-weight: 700; + float: left; +} + +.tools-header .brand > a { + color: #666; +} + +.tools-header > button, +.tools-header > select, +.tools-header > a { + float: right; + max-width: 80px; + margin: 1px 10px; + height: 25px; + padding: 0 10px; + line-height: 25px; + color: #666; +} + +.tools-header .paged { + margin-right: 0px; +} + +.btn { + height: 32px; +} + +.btn.btn-main { + color: #ffffff; + background-color: #337ab7; + border-color: #337ab7; +} + +.btn:focus, +.btn:active { + outline: none !important; +} + +.btn-default:hover, +.btn-default:focus, +.btn-default:active { + color: #1d9d74; + border-color: #1d9d74; + background: white; +} + + +.btn.btn-danger-tag { + color: #ffffff; + background-color: #d9534f; + border-color: #d43f3a; + line-height: 1px; + font-size: 11px; + padding: 4px 4px; +} + +.btn.btn-danger { + color: #333; + background-color: #fff; + border-color: #ccc; +} + +.btn.btn-danger:hover, +.btn.btn-danger:focus, +.btn.btn-danger:active { + color: #d9534f; + border-color: #d9534f; + background: white; +} + +.form-control { + height : 32px; +} + +.form-control:focus { + border-color: #337ab7; + box-shadow: 0px 0px 0px rgba(0, 0, 0, 0.075) inset, 0px 0px 0px rgba(29, 157, 116, 1); +} + +.form-control { + border-radius: 8px; +} + +.input-label:before { + display: inline-block; + content: "*"; + color: #f44336; + font-family: SimSun; + font-size: 12px; + -webkit-transform: TranslateX(-10px); + -ms-transform: TranslateX(-10px); + transform: TranslateX(-10px); +} + +.label.label-main { + color: #ffffff; + background-color: #1d9d74; + border-color: #1d9d74; +} + +.badge-main { + color: #ffffff; + background-color: #1d9d74; + border-color: #1d9d74; +} + +.bootstrap-tagsinput { + background-color: #fff; + border: 1px solid #ccc; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + display: inline-block; + padding: 4px 6px; + color: #555; + vertical-align: middle; + border-radius: 4px; + /* max-width: 100%; */ + width: 85%; + height: 100px; + line-height: 20px; + cursor: text; +} + +.bootstrap-tagsinput > .dropdown-menu { + min-width: 40px; + font-size: 12px; +} + +.bootstrap-tagsinput > .dropdown-menu>.active>a, +.bootstrap-tagsinput > .dropdown-menu>.active>a:focus, +.bootstrap-tagsinput > .dropdown-menu>.active>a:hover { + background-color: #1d9d74; + background-image: -webkit-linear-gradient(top, #1d9d74 0, #1d9d74 100%); + background-image: -o-linear-gradient(top, #1d9d74 0, #1d9d74 100%); + background-image: -webkit-gradient(linear, left top, left bottom, from(#1d9d74), to(#1d9d74)); + background-image: linear-gradient(to bottom, #1d9d74 0, #1d9d74 100%); + filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#1d9d74', endColorstr='#1d9d74', GradientType=0); + background-repeat: repeat-x; +} + +.bootstrap-tagsinput > .dropdown-menu>.active>a, +.bootstrap-tagsinput > .dropdown-menu>.active>a:focus, +.bootstrap-tagsinput > .dropdown-menu>.active>a:hover { + color: #fff; + text-decoration: none; + background-color: #1d9d74; + outline: 0; +} + +.bootstrap-tagsinput > .dropdown-menu>.active>a, +.bootstrap-tagsinput > .dropdown-menu>.active>a:hover, +.bootstrap-tagsinput > .dropdown-menu>.active>a:focus { + color: white; + text-decoration: none; + outline: 0; + background-color: #1d9d74; +} + +.inputs-header { + padding: 9px 0; + height: 50px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; +} + +.inputs-header .brand { + font-size: 13px; + margin: 2px 10px; + font-weight: 700; + float: left; +} + +.inputs-header .brand > a { + color: #666; +} + +.inputs-header > input { + float: right; + margin: 1px 10px; + height: 30px; + padding: 0 10px; + color: #666; +} + +.inputs-header > a { + float: right; + margin: 1px 10px; + height: 30px; + padding: 5 5px; +} + +.inputs-header > select { + float: right; + max-width: 80px; + margin: 1px 10px; + height: 30px; + padding: 0 10px; + color: #666; + height: 25px; + font-size: 12px; +} + +.witdh-150 { + max-width: 150px; +} + +.witdh-200 { + max-width: 200px; +} + +.width-200 { + max-width: 200px; +} + +.witdh-300 { + max-width: 300px; +} + +.width-300 { + max-width: 300px; +} + +.card.highlight { + border-color: #d9534f; +} + +.card .pagination-footer { + height: 40px; + font-size: 10px; + color: #777; + margin-top: -15px; + margin-bottom: 5px; + margin-left: 20px; + margin-right: 20px; +} + +.card .pagination-footer .tools { + font-size: 12px; + margin: 11px 0; + float: right; + display: inline; + margin-right: 20px; +} + +.card > .pagination-footer > .tools > span > input { + height: 25px; + max-width: 50px; + display: inline; +} + +.pagination { + display: inline-block; + padding-left: 0; + margin: 8px 0; + float: right; + border-radius: 4px; +} + + +.pagination > a { + margin-right: 5px; + height: 28px; + width: 28px; + padding: 5px 0px; +} + +.pagination > .btn.active { + color: #ffffff; + background-color: #1d9d74; + border-color: #1d9d74; +} + + + + +.datepicker > .table > thead > tr > td, .datepicker > .table > tbody > tr > td, +.timepicker > .table > thead > tr > td, .timepicker > .table > tbody > tr > td { + padding: 5px 3px; +} + +.datepicker > .table > thead > tr > td > .btn, .datepicker > .table > tbody > tr > td > .btn, +.timepicker > .table > thead > tr > td > .btn, .timepicker > .table > tbody > tr > td > .btn { + border: 1px solid #FFFDFD; +} + +.datepicker > .table > thead > tr > td > .btn-default:hover, +.datepicker > .table > thead > tr > td > .btn-default:focus, +.datepicker > .table > thead > tr > td > .btn-default:active, +.datepicker > .table > tbody > tr > td > .btn-default:hover, +.datepicker > .table > tbody > tr > td > .btn-default:focus, +.datepicker > .table > tbody > tr > td > .btn-default:active, +.timepicker > .table > thead > tr > td > .btn-default:hover, +.timepicker > .table > thead > tr > td > .btn-default:focus, +.timepicker > .table > thead > tr > td > .btn-default:active, +.timepicker > .table > tbody > tr > td > .btn-default:hover, +.timepicker > .table > tbody > tr > td > .btn-default:focus, +.timepicker > .table > tbody > tr > td > .btn-default:active { + color: #1d9d74; + border-color: #1d9d74; + background: white; +} + +.datepicker > .table > thead > tr > td > a, .datepicker > .table > tbody > tr > td > a, +.timepicker > .table > thead > tr > td > a, .timepicker > .table > tbody > tr > td > a { + height: 25px; + width: 25px; + padding: 3px 0px; +} + +.datepicker > .table > tbody > tr:first-child > td > a { + padding: 4px 0px; +} + +.datepicker > .table > thead > tr > td > a.btn.active, +.datepicker > .table > tbody > tr > td > a.btn.active, +.timepicker > .table > thead > tr > td > a.btn.active, +.timepicker > .table > tbody > tr > td > a.btn.active { +/* color: #ffffff; + background-color: #1d9d74; + border-color: #1d9d74;*/ + color: #1d9d74; + border-color: #1d9d74; + background: white; + box-shadow: inset 0 0px 0px rgba(0,0,0,0.125); +} + +.datepicker > .table > thead > tr > td:not(:first-child):last-child > a, +.timepicker > .table > thead > tr > td:not(:first-child):last-child > a { + height: 25px; + width: 50px; + padding: 5px 0px; +} + +.datepicker > .table > tbody > tr > td > a, +.timepicker > .table > tbody > tr > td > a { + margin-left: 8px; +} + + +.selectize-input-200 > .selectize-input { + min-width: 250px; +} + +.highlight-border { + border-color: #337ab7; + box-shadow: 0px 0px 0px rgba(0, 0, 0, 0.075) inset, 0px 0px 0px rgba(29, 157, 116, 1); +}.browsehappy { + margin: 0.2em 0; + background: #ccc; + color: #000; + padding: 0.2em 0; +} + +body { + padding: 0; +} + + +/* Everything but the jumbotron gets side spacing for mobile first views */ + +.header, +.marketing, +.footer { + padding-left: 15px; + padding-right: 15px; +} + + +/* Custom page header */ + +.header { + border-bottom: 1px solid #e5e5e5; + margin-bottom: 10px; +} + + +/* Make the masthead heading the same height as the navigation */ + +.header h3 { + margin-top: 0; + margin-bottom: 0; + line-height: 40px; + padding-bottom: 19px; +} + + +/* Custom page footer */ + +.footer { + padding-top: 19px; + color: #777; + border-top: 1px solid #e5e5e5; +} + +.container-narrow > hr { + margin: 30px 0; +} + + +/* Main marketing message and sign up button */ + +.jumbotron { + text-align: center; + border-bottom: 1px solid #e5e5e5; +} + +.jumbotron .btn { + font-size: 21px; + padding: 14px 24px; +} + + +/* Supporting marketing content */ + +.marketing { + margin: 40px 0; +} + +.marketing p + h4 { + margin-top: 28px; +} + + +/* Responsive: Portrait tablets and up */ + +@media screen and (min-width: 768px) { + .container { + width: inherit; + margin-left: 60px; + margin-right: 5px; + } + /* Remove the padding we set earlier */ + .header, + .marketing, + .footer { + padding-left: 0; + padding-right: 0; + } + /* Space out the masthead */ + .header { + margin-bottom: 30px; + } + /* Remove the bottom border on the jumbotron for visual effect */ + .jumbotron { + border-bottom: 0; + } +} + +.navbar-inverse { + background-color: #1d9d74; + border-color: #1b926c; +} + +.navbar-inverse .navbar-nav > li > a { + color: #b0ddce; + font-size: 15px; +} + +.navbar-inverse .navbar-nav>.open>a, +.navbar-inverse .navbar-nav>.open>a:focus, +.navbar-inverse .navbar-nav>.open>a:hover { + background-color: #1b926c; +} + +@media (min-width: 900px) { + .navbar-left { + float: left !important; + } + .navbar-right { + float: right !important; + margin-right: 0%; + } + .navbar-right ~ .navbar-right { + margin-right: 0; + } +} + +.dropdown-menu { + min-width: 100px !important; +} + +.nav-sidebar li.active a { + background: #DDD; +} + +.dropdown-menu>li>a:hover, .dropdown-menu>li>a:focus { + background: #1d9d74; + /*background: #d9d9d9;*/ + color: white; +} + +.broadcast-message, +.broadcast-message-preview { + padding: 10px; + text-align: center; + background: #555; + color: #BBB; + margin-top: 50px; +} + +.card { + position: relative; + border: 1px solid #d9d9d9; + border-radius: 3px; + color: #666; + background-color: #fff; + width: 100%; + border-radius: 5px; +} + +.card .card-header { + padding: 9px 0; + height: 40px; + background: #555; + color: #fff; + text-align: center; + border-top-left-radius: 4px; + border-top-right-radius: 4px; +} + +.card .card-body { + padding: 12px 10px; +} + +.card .card-footer { + height: 20px; + font-size: 10px; + color: #777; + margin-top: -15px; + margin-bottom: 5px; + margin-left: 20px; + margin-right: 20px; +} + +.card .detail-brand { + float: left; + width: 30%; + line-height: 98px; + font-size: 30px; + text-align: center; + color: white; +} + +.card .default { + background: #1d9d74; +} + +.card .info { + background: #6EBEE7; +} + +.card .warn { + background: #ED7F54; +} + +.card .danger { + background: #6583BE; +} + +.card .detail .text-default { + color: #1d9d74; +} + +.card .detail .text-info { + color: #6EBEE7; +} + +.card .detail .text-warn { + color: #ED7F54; +} + +.card .detail .text-danger { + color: #6583BE; +} + +.card .detail { + float: right; + width: 70%; + line-height: 98px; + text-align: center; +} + +.card .detail .text { + font-size: 12px; +} + +.card .detail .number { + font-size: 30px; + font-weight: 500; +} + +.h100 { + height: 100px; +} + +.inline { + display: inline; +} + +.separator { + height: 1px; + background-color: #e5e5e5; + margin-top: 10px; +} + +.card > .card-body > table > thead > tr > td, +.card > .card-body > table > tbody > tr > td { + word-wrap: break-word; + word-break: break-all; +} + +.card > .card-body > table > thead > tr > td { + font-weight: 500; + font-size: 13px; + text-align: center; +} + +.card > .card-body > table > thead > tr > td > span { + font-weight: 500; + font-size: 10px; +} + +.card > .card-body > table > tbody > tr > td { + font-size: 12px; + text-align: center; +} + +.card > .card-body > table > tbody > tr > td > a { + color: #666; +} + +.thumbnails > .card > .card-body > table > thead > tr > td, +.thumbnails > .card > .card-body > table > tbody > tr > td { + font-size: 12px; + color: #777; + word-wrap: break-word; + word-break: break-all; +} + +.thumbnails > .card > .card-body > table > thead > tr > td:nth-child(n+2) { + text-align: center; +} + +.thumbnails > .card > .card-body > table > tbody > tr > td:nth-child(n+2) { + font-weight: 700; + text-align: center; +} + +.thumbnails > .card > .card-body > table > thead > tr > td:nth-child(1), +.thumbnails > .card > .card-body > table > tbody > tr > td:nth-child(1) { + text-align: left; +} + +.tools-header { + background: whitesmoke; + padding: 9px 0; + height: 40px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; +} + +.tools-header .brand { + font-size: 13px; + margin: 2px 10px; + font-weight: 700; + float: left; +} + +.tools-header .brand > a { + color: #666; +} + +.tools-header > button, +.tools-header > select, +.tools-header > a { + float: right; + max-width: 80px; + margin: 1px 10px; + height: 25px; + padding: 0 10px; + line-height: 25px; + color: #666; +} + +.tools-header .paged { + margin-right: 0px; +} + +.btn.btn-main { + color: #ffffff; + background-color: #1d9d74; + border-color: #1d9d74; +} + +.btn:focus, +.btn:active { + outline: none !important; +} + +.btn-default:hover, +.btn-default:focus, +.btn-default:active { + color: #1d9d74; + border-color: #1d9d74; + background: white; +} + +.btn-default-inverse { + color: #1d9d74; + border-color: #1d9d74; + background: white; +} + +.btn-default-inverse:hover, +.btn-default-inverse:focus, +.btn-default:active { + color: #1d9d74; + border-color: #1d9d74; + background: white; +} + +.btn.btn-danger-tag { + color: #ffffff; + background-color: #d9534f; + border-color: #d43f3a; + line-height: 1px; + font-size: 11px; + padding: 4px 4px; +} + +.btn.btn-danger { + color: #333; + background-color: #fff; + border-color: #ccc; +} + +.btn.btn-danger:hover, +.btn.btn-danger:focus, +.btn.btn-danger:active { + color: #d9534f; + border-color: #d9534f; + background: white; +} + +.form-control { + height : 32px; +} + +.form-control:focus { + border-color: #1d9d74; + box-shadow: 0px 0px 0px rgba(0, 0, 0, 0.075) inset, 0px 0px 0px rgba(29, 157, 116, 1); +} + +.form-control { + border-radius: 8px; +} + +.input-label:before { + display: inline-block; + content: "*"; + color: #f44336; + font-family: SimSun; + font-size: 12px; + -webkit-transform: TranslateX(-10px); + -ms-transform: TranslateX(-10px); + transform: TranslateX(-10px); +} + +.label.label-main { + color: #ffffff; + background-color: #1d9d74; + border-color: #1d9d74; +} + +.badge-main { + color: #ffffff; + background-color: #1d9d74; + border-color: #1d9d74; +} + +.bootstrap-tagsinput { + background-color: #fff; + border: 1px solid #ccc; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + display: inline-block; + padding: 4px 6px; + color: #555; + vertical-align: middle; + border-radius: 4px; + /* max-width: 100%; */ + width: 85%; + height: 100px; + line-height: 20px; + cursor: text; +} + +.bootstrap-tagsinput > .dropdown-menu { + min-width: 40px; + font-size: 12px; +} + +.bootstrap-tagsinput > .dropdown-menu>.active>a, +.bootstrap-tagsinput > .dropdown-menu>.active>a:focus, +.bootstrap-tagsinput > .dropdown-menu>.active>a:hover { + background-color: #1d9d74; + background-image: -webkit-linear-gradient(top, #1d9d74 0, #1d9d74 100%); + background-image: -o-linear-gradient(top, #1d9d74 0, #1d9d74 100%); + background-image: -webkit-gradient(linear, left top, left bottom, from(#1d9d74), to(#1d9d74)); + background-image: linear-gradient(to bottom, #1d9d74 0, #1d9d74 100%); + filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#1d9d74', endColorstr='#1d9d74', GradientType=0); + background-repeat: repeat-x; +} + +.bootstrap-tagsinput > .dropdown-menu>.active>a, +.bootstrap-tagsinput > .dropdown-menu>.active>a:focus, +.bootstrap-tagsinput > .dropdown-menu>.active>a:hover { + color: #fff; + text-decoration: none; + background-color: #1d9d74; + outline: 0; +} + +.bootstrap-tagsinput > .dropdown-menu>.active>a, +.bootstrap-tagsinput > .dropdown-menu>.active>a:hover, +.bootstrap-tagsinput > .dropdown-menu>.active>a:focus { + color: white; + text-decoration: none; + outline: 0; + background-color: #1d9d74; +} + +.inputs-header { + padding: 9px 0; + height: 50px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; +} + +.inputs-header .brand { + font-size: 13px; + margin: 2px 10px; + font-weight: 700; + float: left; +} + +.inputs-header .brand > a { + color: #666; +} + +.inputs-header > input { + float: right; + margin: 1px 10px; + height: 30px; + padding: 0 10px; + color: #666; +} + +.inputs-header > a { + float: right; + margin: 1px 10px; + height: 30px; + padding: 5 5px; +} + +.inputs-header > select { + float: right; + max-width: 80px; + margin: 1px 10px; + height: 30px; + padding: 0 10px; + color: #666; + height: 25px; + font-size: 12px; +} + +.witdh-150 { + max-width: 150px; +} + +.witdh-200 { + max-width: 200px; +} + +.card.highlight { + border-color: #d9534f; +} + +.card .pagination-footer { + height: 40px; + font-size: 10px; + color: #777; + margin-top: -15px; + margin-bottom: 5px; + margin-left: 20px; + margin-right: 20px; +} + +.card .pagination-footer .tools { + font-size: 12px; + margin: 11px 0; + float: right; + display: inline; + margin-right: 20px; +} + +.card > .pagination-footer > .tools > span > input { + height: 25px; + max-width: 50px; + display: inline; +} + +.pagination { + display: inline-block; + padding-left: 0; + margin: 8px 0; + float: right; + border-radius: 4px; +} + + +.pagination > a { + margin-right: 5px; + height: 28px; + width: 28px; + padding: 5px 0px; +} + +.pagination > .btn.active { + color: #ffffff; + background-color: #449d44; + border-color: #449d44; +} + + + + +.datepicker > .table > thead > tr > td, .datepicker > .table > tbody > tr > td, +.timepicker > .table > thead > tr > td, .timepicker > .table > tbody > tr > td { + padding: 5px 3px; +} + +.datepicker > .table > thead > tr > td > .btn, .datepicker > .table > tbody > tr > td > .btn, +.timepicker > .table > thead > tr > td > .btn, .timepicker > .table > tbody > tr > td > .btn { + border: 1px solid #FFFDFD; +} + +.datepicker > .table > thead > tr > td > .btn-default:hover, +.datepicker > .table > thead > tr > td > .btn-default:focus, +.datepicker > .table > thead > tr > td > .btn-default:active, +.datepicker > .table > tbody > tr > td > .btn-default:hover, +.datepicker > .table > tbody > tr > td > .btn-default:focus, +.datepicker > .table > tbody > tr > td > .btn-default:active, +.timepicker > .table > thead > tr > td > .btn-default:hover, +.timepicker > .table > thead > tr > td > .btn-default:focus, +.timepicker > .table > thead > tr > td > .btn-default:active, +.timepicker > .table > tbody > tr > td > .btn-default:hover, +.timepicker > .table > tbody > tr > td > .btn-default:focus, +.timepicker > .table > tbody > tr > td > .btn-default:active { + color: #1d9d74; + border-color: #1d9d74; + background: white; +} + +.datepicker > .table > thead > tr > td > a, .datepicker > .table > tbody > tr > td > a, +.timepicker > .table > thead > tr > td > a, .timepicker > .table > tbody > tr > td > a { + height: 25px; + width: 25px; + padding: 3px 0px; +} + +.datepicker > .table > tbody > tr:first-child > td > a { + padding: 4px 0px; +} + +.datepicker > .table > thead > tr > td > a.btn.active, +.datepicker > .table > tbody > tr > td > a.btn.active, +.timepicker > .table > thead > tr > td > a.btn.active, +.timepicker > .table > tbody > tr > td > a.btn.active { +/* color: #ffffff; + background-color: #1d9d74; + border-color: #1d9d74;*/ + color: #1d9d74; + border-color: #1d9d74; + background: white; + box-shadow: inset 0 0px 0px rgba(0,0,0,0.125); +} + +.datepicker > .table > thead > tr > td:not(:first-child):last-child > a, +.timepicker > .table > thead > tr > td:not(:first-child):last-child > a { + height: 25px; + width: 50px; + padding: 5px 0px; +} + +.datepicker > .table > tbody > tr > td > a, +.timepicker > .table > tbody > tr > td > a { + margin-left: 8px; +} + + +.selectize-input-200 > .selectize-input { + min-width: 250px; +} + +.highlight-border { + border-color: #1d9d74; + box-shadow: 0px 0px 0px rgba(0, 0, 0, 0.075) inset, 0px 0px 0px rgba(29, 157, 116, 1); +} + + +.sortorder:after { + content: '\25b2'; +} +.sortorder.reverse:after { + content: '\25bc'; +} + + + +.input-control select { + -moz-appearance: none; + -webkit-appearance: none; + appearance: none; + position: relative; + border: 1px #d9d9d9 solid; + width: 100%; + height: 100%; + padding: .3125rem; + z-index: 0; +} + +.navbar-inverse { + background-color: #337ab7; + border-color: #337ab7; +} + +.sidebar { + z-index: 1; + width: 220px; + /*position: fixed;*/ + top: 0; + left: 0; + height: 100%; +} + +#page-wrapper { + position: inherit; + margin: 70px 0 0 220px; + padding: 12px 30px; + border-left: 0px solid #e7e7e7; +} + +.sidebar .sidebar-nav.navbar-collapse { + padding-right: 0; + padding-left: 0; + background-color: #F5F5F5; + position: relative; + color: black; + width: 100%; + padding: 0; + margin: 0; + list-style: none inside none; +} + +.sidebar a { + color: #555; +} + +.sidebar ul li:hover { + color:red; +} + +.form-control { + border-radius: 8px; +} + +.form-control:focus { + border-color: #337ab7; + box-shadow: 0px 0px 0px rgba(0, 0, 0, 0.075) inset, 0px 0px 0px rgba(29, 157, 116, 1); +} + +.highlight-border { + border-color: #337ab7; + box-shadow: 0px 0px 0px rgba(0, 0, 0, 0.075) inset, 0px 0px 0px rgba(29, 157, 116, 1); +}.browsehappy { + margin: 0.2em 0; + background: #ccc; + color: #000; + padding: 0.2em 0; +} + +.btn.btn-main { + color: #ffffff; + background-color: #337ab7; + border-color: #337ab7; +} + +.btn-default-inverse { + color: #337ab7; + border-color: #337ab7; + background: white; +} + +.btn-default-inverse:hover, +.btn-default-inverse:focus, +.btn-default:active { + color: #337ab7; + border-color: #337ab7; + background: white; +} + +.btn-danger-inverse { + color: #d9534f; + border-color: #d9534f; + background: white; +} + +.btn-danger-inverse:hover, +.btn-danger-inverse:focus, +.btn-danger:active { + color: #d9534f; + border-color: #d9534f; + background: white; +} + +.btn-tab-active, +.btn-tab-active:hover, +.btn-tab-active:focus, +.btn-tab-default:hover, +.btn-tab-default:focus, +.btn-tab-default:active { + color: #337ab7; + border-color: #337ab7; + background: white; + font-weight: 600; +} +.btn-tab-default { + color: #777; + background: white; + font-weight: 600; +} + +.pagination > .btn.active { + color: #ffffff; + background-color: #337ab7; + border-color: #337ab7; +} + +.btn-default:hover, .btn-default:focus, .btn-default:active { + color: #337ab7; + border-color: #337ab7; + background: white; +} + +.bootstrap-switch.bootstrap-switch-on { + border-color: #337ab7; +} + +.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-success, .bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-success { + color: #fff; + background: #337ab7; +} + +.selectize-input-200 > .selectize-input { + min-width: 200px; + border-color: #337ab7; +} + +.btn-outline-primary { + color: #007bff; + background-color: transparent; + background-image: none; + border-color: #007bff; +} + +.btn-outline-primary:hover { + color: #fff; + background-color: #007bff; + border-color: #007bff; +} + +.btn-outline-primary:focus, .btn-outline-primary.focus { + box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.5); +} + +.btn-outline-primary.disabled, .btn-outline-primary:disabled { + color: #007bff; + background-color: transparent; +} + +.btn-outline-primary:not(:disabled):not(.disabled):active, .btn-outline-primary:not(:disabled):not(.disabled).active, +.show > .btn-outline-primary.dropdown-toggle { + color: #fff; + background-color: #007bff; + border-color: #007bff; +} + +.btn-outline-primary:not(:disabled):not(.disabled):active:focus, .btn-outline-primary:not(:disabled):not(.disabled).active:focus, +.show > .btn-outline-primary.dropdown-toggle:focus { + box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.5); +} + +.btn-outline-secondary { + color: #6c757d; + background-color: transparent; + background-image: none; + border-color: #6c757d; +} + +.btn-outline-secondary:hover { + color: #fff; + background-color: #6c757d; + border-color: #6c757d; +} + +.btn-outline-secondary:focus, .btn-outline-secondary.focus { + box-shadow: 0 0 0 0.2rem rgba(108, 117, 125, 0.5); +} + +.btn-outline-secondary.disabled, .btn-outline-secondary:disabled { + color: #6c757d; + background-color: transparent; +} + +.btn-outline-secondary:not(:disabled):not(.disabled):active, .btn-outline-secondary:not(:disabled):not(.disabled).active, +.show > .btn-outline-secondary.dropdown-toggle { + color: #fff; + background-color: #6c757d; + border-color: #6c757d; +} + +.btn-outline-secondary:not(:disabled):not(.disabled):active:focus, .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, +.show > .btn-outline-secondary.dropdown-toggle:focus { + box-shadow: 0 0 0 0.2rem rgba(108, 117, 125, 0.5); +} + +.btn-outline-success { + color: #28a745; + background-color: transparent; + background-image: none; + border-color: #28a745; +} + +.btn-outline-success:hover { + color: #fff; + background-color: #28a745; + border-color: #28a745; +} + +.btn-outline-success:focus, .btn-outline-success.focus { + box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.5); +} + +.btn-outline-success.disabled, .btn-outline-success:disabled { + color: #28a745; + background-color: transparent; +} + +.btn-outline-success:not(:disabled):not(.disabled):active, .btn-outline-success:not(:disabled):not(.disabled).active, +.show > .btn-outline-success.dropdown-toggle { + color: #fff; + background-color: #28a745; + border-color: #28a745; +} + +.btn-outline-success:not(:disabled):not(.disabled):active:focus, .btn-outline-success:not(:disabled):not(.disabled).active:focus, +.show > .btn-outline-success.dropdown-toggle:focus { + box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.5); +} + +.btn-outline-info { + color: #17a2b8; + background-color: transparent; + background-image: none; + border-color: #17a2b8; +} + +.btn-outline-info:hover { + color: #fff; + background-color: #17a2b8; + border-color: #17a2b8; +} + +.btn-outline-info:focus, .btn-outline-info.focus { + box-shadow: 0 0 0 0.2rem rgba(23, 162, 184, 0.5); +} + +.btn-outline-info.disabled, .btn-outline-info:disabled { + color: #17a2b8; + background-color: transparent; +} + +.btn-outline-info:not(:disabled):not(.disabled):active, .btn-outline-info:not(:disabled):not(.disabled).active, +.show > .btn-outline-info.dropdown-toggle { + color: #fff; + background-color: #17a2b8; + border-color: #17a2b8; +} + +.btn-outline-info:not(:disabled):not(.disabled):active:focus, .btn-outline-info:not(:disabled):not(.disabled).active:focus, +.show > .btn-outline-info.dropdown-toggle:focus { + box-shadow: 0 0 0 0.2rem rgba(23, 162, 184, 0.5); +} + +.btn-outline-warning { + color: #ffc107; + background-color: transparent; + background-image: none; + border-color: #ffc107; +} + +.btn-outline-warning:hover { + color: #212529; + background-color: #ffc107; + border-color: #ffc107; +} + +.btn-outline-warning:focus, .btn-outline-warning.focus { + box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.5); +} + +.btn-outline-warning.disabled, .btn-outline-warning:disabled { + color: #ffc107; + background-color: transparent; +} + +.btn-outline-warning:not(:disabled):not(.disabled):active, .btn-outline-warning:not(:disabled):not(.disabled).active, +.show > .btn-outline-warning.dropdown-toggle { + color: #212529; + background-color: #ffc107; + border-color: #ffc107; +} + +.btn-outline-warning:not(:disabled):not(.disabled):active:focus, .btn-outline-warning:not(:disabled):not(.disabled).active:focus, +.show > .btn-outline-warning.dropdown-toggle:focus { + box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.5); +} + +.btn-outline-danger { + color: #dc3545; + background-color: transparent; + background-image: none; + border-color: #dc3545; +} + +.btn-outline-danger:hover { + color: #fff; + background-color: #dc3545; + border-color: #dc3545; +} + +.btn-outline-danger:focus, .btn-outline-danger.focus { + box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.5); +} + +.btn-outline-danger.disabled, .btn-outline-danger:disabled { + color: #dc3545; + background-color: transparent; +} + +.btn-outline-danger:not(:disabled):not(.disabled):active, .btn-outline-danger:not(:disabled):not(.disabled).active, +.show > .btn-outline-danger.dropdown-toggle { + color: #fff; + background-color: #dc3545; + border-color: #dc3545; +} + +.btn-outline-danger:not(:disabled):not(.disabled):active:focus, .btn-outline-danger:not(:disabled):not(.disabled).active:focus, +.show > .btn-outline-danger.dropdown-toggle:focus { + box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.5); +} + +.btn-outline-light { + color: #f8f9fa; + background-color: transparent; + background-image: none; + border-color: #f8f9fa; +} + +.btn-outline-light:hover { + color: #212529; + background-color: #f8f9fa; + border-color: #f8f9fa; +} + +.btn-outline-light:focus, .btn-outline-light.focus { + box-shadow: 0 0 0 0.2rem rgba(248, 249, 250, 0.5); +} + +.btn-outline-light.disabled, .btn-outline-light:disabled { + color: #f8f9fa; + background-color: transparent; +} + +.btn-outline-light:not(:disabled):not(.disabled):active, .btn-outline-light:not(:disabled):not(.disabled).active, +.show > .btn-outline-light.dropdown-toggle { + color: #212529; + background-color: #f8f9fa; + border-color: #f8f9fa; +} + +.btn-outline-light:not(:disabled):not(.disabled):active:focus, .btn-outline-light:not(:disabled):not(.disabled).active:focus, +.show > .btn-outline-light.dropdown-toggle:focus { + box-shadow: 0 0 0 0.2rem rgba(248, 249, 250, 0.5); +} + +.btn-outline-dark { + color: #343a40; + background-color: transparent; + background-image: none; + border-color: #343a40; +} + +.btn-outline-dark:hover { + color: #fff; + background-color: #343a40; + border-color: #343a40; +} + +.btn-outline-dark:focus, .btn-outline-dark.focus { + box-shadow: 0 0 0 0.2rem rgba(52, 58, 64, 0.5); +} + +.btn-outline-dark.disabled, .btn-outline-dark:disabled { + color: #343a40; + background-color: transparent; +} + +.btn-outline-dark:not(:disabled):not(.disabled):active, .btn-outline-dark:not(:disabled):not(.disabled).active, +.show > .btn-outline-dark.dropdown-toggle { + color: #fff; + background-color: #343a40; + border-color: #343a40; +} + +.btn-outline-dark:not(:disabled):not(.disabled):active:focus, .btn-outline-dark:not(:disabled):not(.disabled).active:focus, +.show > .btn-outline-dark.dropdown-toggle:focus { + box-shadow: 0 0 0 0.2rem rgba(52, 58, 64, 0.5); +} \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/page.css b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/page.css new file mode 100755 index 00000000..af3ba447 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/page.css @@ -0,0 +1,399 @@ +/*! + * Start Bootstrap - SB Admin 2 Bootstrap Admin Theme (http://startbootstrap.com) + * Code licensed under the Apache License v2.0. + * For details, see http://www.apache.org/licenses/LICENSE-2.0. + */ + +body { + background-color: #f8f8f8; +} + +.example { + padding: .625rem 1.825rem .625rem 2.5rem; + border: 1px #ccc dashed; + position: relative; + margin: 0 0 .625rem 0; + background-color: #ffffff; +} + +dl dt, +dl dd { + line-height: 1.25rem; +} +dl dt { + font-style: normal; + font-weight: 700; +} +dl dd { + margin-left: .9375rem; +} +dl.horizontal dt { + float: left; + width: 10rem; + overflow: hidden; + clear: left; + text-align: right; + text-overflow: ellipsis; + white-space: nowrap; +} +dl.horizontal dd { + margin-left: 11.25rem; +} + +#wrapper { + width: 100%; +} + +#page-wrapper { + padding: 0 15px; + min-height: 568px; + background-color: #fff; +} + +@media(min-width:768px) { + #page-wrapper { + position: inherit; + margin: 0 0 0 250px; + padding: 0 30px; + border-left: 1px solid #e7e7e7; + } +} + +.navbar-top-links { + margin-right: 0; +} + +.navbar-top-links li { + display: inline-block; +} + +.navbar-top-links li:last-child { + margin-right: 15px; +} + +.navbar-top-links li a { + padding: 15px; + min-height: 50px; +} + +.navbar-top-links .dropdown-menu li { + display: block; +} + +.navbar-top-links .dropdown-menu li:last-child { + margin-right: 0; +} + +.navbar-top-links .dropdown-menu li a { + padding: 3px 20px; + min-height: 0; +} + +.navbar-top-links .dropdown-menu li a div { + white-space: normal; +} + +.navbar-top-links .dropdown-messages, +.navbar-top-links .dropdown-tasks, +.navbar-top-links .dropdown-alerts { + width: 310px; + min-width: 0; +} + +.navbar-top-links .dropdown-messages { + margin-left: 5px; +} + +.navbar-top-links .dropdown-tasks { + margin-left: -59px; +} + +.navbar-top-links .dropdown-alerts { + margin-left: -123px; +} + +.navbar-top-links .dropdown-user { + right: 0; + left: auto; +} + +.sidebar .sidebar-nav.navbar-collapse { + padding-right: 0; + padding-left: 0; + background-color: #71b1d1; + color: #ffffff; + position: relative; + width: 100%; + padding: 0; + margin: 0; + list-style: none inside none; +} + +.sidebar .sidebar-search { + padding: 15px; +} + +.sidebar ul li { + border-bottom: 1px solid #e7e7e7; +} + +.sidebar ul li a.active { + background-color: #ffffff; + color: #ffffff; +} + +.sidebar a{ + color: #fff; +} + +.sidebar .arrow { + float: right; +} + +.sidebar .fa.arrow:before { + content: "\f104"; +} + +.sidebar .active>a>.fa.arrow:before { + content: "\f107"; +} + +.sidebar .nav-second-level li, +.sidebar .nav-third-level li { + border-bottom: 0!important; +} + +.sidebar .nav-second-level li a { + padding-left: 37px; +} + +.sidebar .nav-third-level li a { + padding-left: 52px; +} + +@media(min-width:768px) { + .sidebar { + z-index: 1; + position: absolute; + width: 250px; + margin-top: 51px; + } + + .navbar-top-links .dropdown-messages, + .navbar-top-links .dropdown-tasks, + .navbar-top-links .dropdown-alerts { + margin-left: auto; + } +} + + +.btn-outline { + color: inherit; + background-color: transparent; + transition: all .5s; +} + +.btn-primary.btn-outline { + color: #428bca; +} + +.btn-success.btn-outline { + color: #5cb85c; +} + +.btn-info.btn-outline { + color: #5bc0de; +} + +.btn-warning.btn-outline { + color: #f0ad4e; +} + +.btn-danger.btn-outline { + color: #d9534f; +} + +.btn-primary.btn-outline:hover, +.btn-success.btn-outline:hover, +.btn-info.btn-outline:hover, +.btn-warning.btn-outline:hover, +.btn-danger.btn-outline:hover { + color: #fff; +} + +.chat { + margin: 0; + padding: 0; + list-style: none; +} + +.chat li { + margin-bottom: 10px; + padding-bottom: 5px; + border-bottom: 1px dotted #999; +} + +.chat li.left .chat-body { + margin-left: 60px; +} + +.chat li.right .chat-body { + margin-right: 60px; +} + +.chat li .chat-body p { + margin: 0; +} + +.panel .slidedown .glyphicon, +.chat .glyphicon { + margin-right: 5px; +} + +.chat-panel .panel-body { + height: 350px; + overflow-y: scroll; +} + +.login-panel { + margin-top: 25%; +} + +.flot-chart { + display: block; + height: 400px; +} + +.flot-chart-content { + width: 100%; + height: 100%; +} + +.dataTables_wrapper { + position: relative; + clear: both; +} + +table.dataTable thead .sorting, +table.dataTable thead .sorting_asc, +table.dataTable thead .sorting_desc, +table.dataTable thead .sorting_asc_disabled, +table.dataTable thead .sorting_desc_disabled { + background: 0 0; +} + +table.dataTable thead .sorting_asc:after { + content: "\f0de"; + float: right; + font-family: fontawesome; +} + +table.dataTable thead .sorting_desc:after { + content: "\f0dd"; + float: right; + font-family: fontawesome; +} + +table.dataTable thead .sorting:after { + content: "\f0dc"; + float: right; + font-family: fontawesome; + color: rgba(50,50,50,.5); +} + +.btn-circle { + width: 30px; + height: 30px; + padding: 6px 0; + border-radius: 15px; + text-align: center; + font-size: 12px; + line-height: 1.428571429; +} + +.btn-circle.btn-lg { + width: 50px; + height: 50px; + padding: 10px 16px; + border-radius: 25px; + font-size: 18px; + line-height: 1.33; +} + +.btn-circle.btn-xl { + width: 70px; + height: 70px; + padding: 10px 16px; + border-radius: 35px; + font-size: 24px; + line-height: 1.33; +} + +.show-grid [class^=col-] { + padding-top: 10px; + padding-bottom: 10px; + border: 1px solid #ddd; + background-color: #eee!important; +} + +.show-grid { + margin: 15px 0; +} + +.huge { + font-size: 40px; +} + +.panel-green { + border-color: #5cb85c; +} + +.panel-green .panel-heading { + border-color: #5cb85c; + color: #fff; + background-color: #5cb85c; +} + +.panel-green a { + color: #5cb85c; +} + +.panel-green a:hover { + color: #3d8b3d; +} + +.panel-red { + border-color: #d9534f; +} + +.panel-red .panel-heading { + border-color: #d9534f; + color: #fff; + background-color: #d9534f; +} + +.panel-red a { + color: #d9534f; +} + +.panel-red a:hover { + color: #b52b27; +} + +.panel-yellow { + border-color: #f0ad4e; +} + +.panel-yellow .panel-heading { + border-color: #f0ad4e; + color: #fff; + background-color: #f0ad4e; +} + +.panel-yellow a { + color: #f0ad4e; +} + +.panel-yellow a:hover { + color: #df8a13; +} \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/timeline.css b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/timeline.css new file mode 100755 index 00000000..92161ebe --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/timeline.css @@ -0,0 +1,180 @@ +.timeline { + position: relative; + padding: 20px 0 20px; + list-style: none; +} + +.timeline:before { + content: " "; + position: absolute; + top: 0; + bottom: 0; + left: 50%; + width: 3px; + margin-left: -1.5px; + background-color: #eeeeee; +} + +.timeline > li { + position: relative; + margin-bottom: 20px; +} + +.timeline > li:before, +.timeline > li:after { + content: " "; + display: table; +} + +.timeline > li:after { + clear: both; +} + +.timeline > li:before, +.timeline > li:after { + content: " "; + display: table; +} + +.timeline > li:after { + clear: both; +} + +.timeline > li > .timeline-panel { + float: left; + position: relative; + width: 46%; + padding: 20px; + border: 1px solid #d4d4d4; + border-radius: 2px; + -webkit-box-shadow: 0 1px 6px rgba(0,0,0,0.175); + box-shadow: 0 1px 6px rgba(0,0,0,0.175); +} + +.timeline > li > .timeline-panel:before { + content: " "; + display: inline-block; + position: absolute; + top: 26px; + right: -15px; + border-top: 15px solid transparent; + border-right: 0 solid #ccc; + border-bottom: 15px solid transparent; + border-left: 15px solid #ccc; +} + +.timeline > li > .timeline-panel:after { + content: " "; + display: inline-block; + position: absolute; + top: 27px; + right: -14px; + border-top: 14px solid transparent; + border-right: 0 solid #fff; + border-bottom: 14px solid transparent; + border-left: 14px solid #fff; +} + +.timeline > li > .timeline-badge { + z-index: 100; + position: absolute; + top: 16px; + left: 50%; + width: 50px; + height: 50px; + margin-left: -25px; + border-radius: 50% 50% 50% 50%; + text-align: center; + font-size: 1.4em; + line-height: 50px; + color: #fff; + background-color: #999999; +} + +.timeline > li.timeline-inverted > .timeline-panel { + float: right; +} + +.timeline > li.timeline-inverted > .timeline-panel:before { + right: auto; + left: -15px; + border-right-width: 15px; + border-left-width: 0; +} + +.timeline > li.timeline-inverted > .timeline-panel:after { + right: auto; + left: -14px; + border-right-width: 14px; + border-left-width: 0; +} + +.timeline-badge.primary { + background-color: #2e6da4 !important; +} + +.timeline-badge.success { + background-color: #3f903f !important; +} + +.timeline-badge.warning { + background-color: #f0ad4e !important; +} + +.timeline-badge.danger { + background-color: #d9534f !important; +} + +.timeline-badge.info { + background-color: #5bc0de !important; +} + +.timeline-title { + margin-top: 0; + color: inherit; +} + +.timeline-body > p, +.timeline-body > ul { + margin-bottom: 0; +} + +.timeline-body > p + p { + margin-top: 5px; +} + +@media(max-width:767px) { + ul.timeline:before { + left: 40px; + } + + ul.timeline > li > .timeline-panel { + width: calc(100% - 90px); + width: -moz-calc(100% - 90px); + width: -webkit-calc(100% - 90px); + } + + ul.timeline > li > .timeline-badge { + top: 16px; + left: 15px; + margin-left: 0; + } + + ul.timeline > li > .timeline-panel { + float: right; + } + + ul.timeline > li > .timeline-panel:before { + right: auto; + left: -15px; + border-right-width: 15px; + border-left-width: 0; + } + + ul.timeline > li > .timeline-panel:after { + right: auto; + left: -14px; + border-right-width: 14px; + border-left-width: 0; + } +} \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/authority.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/authority.html new file mode 100755 index 00000000..5dbddedd --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/authority.html @@ -0,0 +1,85 @@ +
+
+ {{app}} +
+
+ +
+
+ +
+ +
+
+
+
+
+ 授权规则 + + +
+ +
+
+ + +
+
+ + + + + + + + + + + + + + + + +
+ 资源名 + + 流控应用 + + 授权类型 + + 操作 +
{{ruleEntity.rule.resource}}{{ruleEntity.rule.limitApp }} + 白名单 + 黑名单 + + + +
+ + + + + + + + + + + + diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster/client.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster/client.html new file mode 100755 index 00000000..7fc751da --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster/client.html @@ -0,0 +1,30 @@ +
+
+
+ +
+

未连接

+

连接中

+

已连接

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
\ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster/server.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster/server.html new file mode 100755 index 00000000..8c045876 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster/server.html @@ -0,0 +1,29 @@ +
+
+
+ +
+

独立模式 (Alone)

+

嵌入模式 (Embedded)

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
\ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_app_assign_manage.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_app_assign_manage.html new file mode 100755 index 00000000..550ff230 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_app_assign_manage.html @@ -0,0 +1,118 @@ +
+
+ {{app}} +
+
+ +
+
+
+
+
+
+ 集群限流 - 机器分配/管控 +
+ + +
+
+
+
+
+

{{loadError.message}}

+
+
+
+
+
+ + +
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+ + +
+ +
+
+
+ + +
+
+ +
+
+ +
+ +
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+ +
+ +
+ +
+ +
+ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_app_client_list.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_app_client_list.html new file mode 100755 index 00000000..b779e30e --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_app_client_list.html @@ -0,0 +1,73 @@ +
+
+ {{app}} +
+ +
+ +
+
+
+
+
+
+ 集群限流 - Token Client 列表 +
+ + +
+
+
+
+
+

{{loadError.message}}

+
+
+
+
+
+ + +
+ + + + + + + + + + + + + + + + + + + + +
Client IDServer IPServer 端口连接状态操作
{{clientVO.id}}{{clientVO.state.clientConfig.serverHost}}{{clientVO.state.clientConfig.serverPort}} + 未连接 + 连接中 + 已连接 + + +
+
+ +
+ +
+ +
+ +
+ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_app_server_list.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_app_server_list.html new file mode 100755 index 00000000..d47b31f7 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_app_server_list.html @@ -0,0 +1,96 @@ +
+
+ {{app}} +
+
+ + + Token Client 列表 + +
+
+ +
+
+
+
+
+
+ 集群限流 - Token Server 列表 + +
+ + +
+
+
+
+
+

{{loadError.message}}

+
+
+
+
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Server IDPort命名空间集合运行模式总连接数QPS 总览操作
+ {{serverVO.id}} + {{serverVO.id}}(自主指定) + {{serverVO.port}} + {{serverVO.state.namespaceSetStr}} + 未知 + + 未知 + 嵌入模式 + 独立模式 + + {{serverVO.connectedCount}} + 未知 + + {{serverVO.state.requestLimitDataStr}} + 未知 + + + + +
+
+ +
+ +
+ +
+ +
+ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_app_server_overview.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_app_server_overview.html new file mode 100755 index 00000000..4e411a2b --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_app_server_overview.html @@ -0,0 +1,88 @@ +
+
+ {{app}} +
+
+ +
+
+
+
+
+
+ 集群限流 - Token Server 总览 +
+ + +
+
+
+
+
+

{{loadError.message}}

+
+
+
+
+
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Server IDPort命名空间集合总连接数连接情况QPS 总览
{{serverVO.id}}{{serverVO.port}} + {{serverVO.state.namespaceSetStr}} + + {{serverVO.connectedCount}} + +

+ namespace: {{cg.namespace}}, 连接数: {{cg.connectedCount}}, clients: + {{generateConnectionSet(cg.connectionSet)}} +

+
+

+ namespace: {{crl.namespace}}, 当前 QPS: {{crl.currentQps}}, 最大允许 QPS: + {{crl.maxAllowedQps}} +

+
+
+ +
+ +
+ +
+ +
+ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_single_config.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_single_config.html new file mode 100755 index 00000000..a82f1ab3 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_single_config.html @@ -0,0 +1,95 @@ + +
+
+ {{app}} +
+
+ +
+
+
+
+
+
+ 集群限流 + +
+ +
+
+ + +
+
+
+
+
+

{{loadError.message}}

+
+
+
+
+
+ + +
+
+
+ +

Client

+

Server

+

未开启

+
+
+ +
+
+  Client   +  Server +
+
+
+
+ +
+ +
+
+
+
+
+

该机器未引入 Sentinel 集群限流客户端或服务端的相关依赖,请引入相关依赖。

+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+ +
+ +
+ +
+ +
+ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dashboard/home.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dashboard/home.html new file mode 100755 index 00000000..9a81bf5b --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dashboard/home.html @@ -0,0 +1,13 @@ +
+
+
+

欢迎使用 Sentinel 控制台

+
+ +
+ + +
+
+ +
diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dashboard/main.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dashboard/main.html new file mode 100755 index 00000000..c5abed5d --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dashboard/main.html @@ -0,0 +1,10 @@ +
+ +
+ + +
+
+
+ +
diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/degrade.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/degrade.html new file mode 100755 index 00000000..1ed7458f --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/degrade.html @@ -0,0 +1,104 @@ +
+
+ {{app}} +
+
+ +
+
+ +
+ +
+
+
+
+
+ 降级规则 + + + +
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 资源名 + + 降级模式 + + 阈值 + + 时间窗口(s) + + 操作 +
{{rule.resource}} + RT + 异常比例 + 异常数 + + {{rule.count}} + + {{rule.timeWindow}}s + + + +
+
+ + + +
+ +
+ +
+ +
+ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/authority-rule-dialog.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/authority-rule-dialog.html new file mode 100755 index 00000000..bd69085f --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/authority-rule-dialog.html @@ -0,0 +1,46 @@ +
+ {{authorityRuleDialog.title}} +
+
+
+
+
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+
+  白名单   +  黑名单 +
+
+
+ +
+
+
+
+ + + +
+
+
+
diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/cluster/cluster-client-config-dialog.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/cluster/cluster-client-config-dialog.html new file mode 100755 index 00000000..128ab785 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/cluster/cluster-client-config-dialog.html @@ -0,0 +1,40 @@ +
+ 修改 Token Client 配置 +
+
+
+
+
+ +
+

{{ccDialogData.clientId}}

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+ + +
+
+
+
diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/cluster/cluster-server-assign-dialog.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/cluster/cluster-server-assign-dialog.html new file mode 100755 index 00000000..350c2e41 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/cluster/cluster-server-assign-dialog.html @@ -0,0 +1,139 @@ +
+ {{serverAssignDialogData.title}} +
+
+
+
+
+
+ +
+

{{serverAssignDialogData.serverData.currentServer}}

+
+ + +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+
+  应用内机器   +  外部指定机器 +
+
+ +
+
+

若指定外部 server,请先在相应页面对外部 server 进行配置,然后在此页面指定。

+
+
+
+ +
+
+ +
+ +
+ + +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+ + +
+ +
+
+
+
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+
+ + + +
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+
+ + +
+
+
+
diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/cluster/cluster-server-connection-detail-dialog.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/cluster/cluster-server-connection-detail-dialog.html new file mode 100755 index 00000000..afbf29ad --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/cluster/cluster-server-connection-detail-dialog.html @@ -0,0 +1,37 @@ +
+ 连接详情 +
+
+
+
+
+ +
+

{{connectionDetailDialogData.serverData.id}}

+
+
+
+ +
+ + + + + + + + + + + + + + + + +
命名空间连接数连接详情
{{cg.namespace}}{{cg.connectedCount}}{{generateConnectionSet(cg.connectionSet)}}
+
+
+
+
+
diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/confirm-dialog.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/confirm-dialog.html new file mode 100755 index 00000000..b7bf3d67 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/confirm-dialog.html @@ -0,0 +1,20 @@ +
+ {{confirmDialog.title}} +
+
+
+

+ {{confirmDialog.attentionTitle}}: +
+
+ {{confirmDialog.attention}} +

+
+
+
+ + +
+
+
+
diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/degrade-rule-dialog.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/degrade-rule-dialog.html new file mode 100755 index 00000000..7dddbbb8 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/degrade-rule-dialog.html @@ -0,0 +1,60 @@ +
+ {{degradeRuleDialog.title}} +
+
+
+
+
+ +
+ + +
+
+ + + + + + + + +
+ +
+
+  RT   +  异常比例   +  异常数 +
+
+
+ +
+ + + +
+ + + +
+ +
+ +
+
+
+
+
+
+ + + +
+
+
+
diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/flow-rule-dialog.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/flow-rule-dialog.html new file mode 100755 index 00000000..f832ce3e --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/flow-rule-dialog.html @@ -0,0 +1,148 @@ +
+ {{flowRuleDialog.title}} +
+
+
+
+
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+
+  QPS   +  线程数 +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+
+ +
+
+  单机均摊   +  总体阈值 +
+
+
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+  直接   +  关联   +  链路   +
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+
+  快速失败   +  Warm Up   +  排队等待 +
+
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+ + + +
+
+
+
\ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/gateway/api-dialog.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/gateway/api-dialog.html new file mode 100755 index 00000000..8c8d4615 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/gateway/api-dialog.html @@ -0,0 +1,49 @@ +
+ {{gatewayApiDialog.title}} +
+
+
+
+ +
+ + +
+
+ +
+ +
+
+  精确   +  前缀   +  正则   +
+
+ +
+ +
+
+ +
+
+ +
+ +
+
+
+
+ + + +
+
+
+
diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/gateway/flow-rule-dialog.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/gateway/flow-rule-dialog.html new file mode 100755 index 00000000..7dca16d7 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/gateway/flow-rule-dialog.html @@ -0,0 +1,172 @@ +
+ {{gatewayFlowRuleDialog.title}} +
+
+
+
+
+ +
+
+  Route ID   +  Route ID   +  API 分组   +  API 分组   +
+
+
+ +
+ +
+ + + + + +
+
+ +
+ +
+ +
+
+ +
+ +
+
+  Client IP   +  Remote Host   +  Header   +  URL 参数   +  Cookie   +
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+  精确   +  子串   +  正则   +
+
+ +
+ +
+
+ +
+ +
+
+  QPS   +  线程数   +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+  快速失败   +  匀速排队   +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+ + + +
+
+
+
diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/param-flow-rule-dialog.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/param-flow-rule-dialog.html new file mode 100755 index 00000000..02f00b08 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/param-flow-rule-dialog.html @@ -0,0 +1,166 @@ +
+ {{paramFlowRuleDialog.title}} +
+
+
+
+
+ +
+ + +
+
+ +
+ +

QPS 模式

+
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+
+ +
+
+  单机均摊   +  总体阈值 +
+
+
+
+ +
+ +
+
+ +  若选择,则 Token Server 不可用时将退化到单机限流 +
+
+
+ + +
+
+
+
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+ + +
+ +
+ +
+ +
+
+ +
+
+ + + + + + + + + + + + + + + +
参数值参数类型限流阈值操作
+

{{paramItem.classType}}

+
+ + + +
+
+
+ +
+
+ + + +
+
+
+
+ + + +
+
+
+
diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/system-rule-dialog.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/system-rule-dialog.html new file mode 100755 index 00000000..3dd9cd97 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/system-rule-dialog.html @@ -0,0 +1,58 @@ +
+ {{systemRuleDialog.title}} +
+
+
+
+ +
+ +
+
+ +  LOAD   + +  RT   + +  线程数   + +  入口 QPS   + +  CPU 使用率   + +
+
+ +  LOAD   + +  RT   + +  线程数   + +  入口 QPS   + +  CPU 使用率   + +
+
+
+
+ +
+ + + + + +
+
+
+
+
+
+ + +
+
+
+
diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/flow_v1.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/flow_v1.html new file mode 100755 index 00000000..22b79c6f --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/flow_v1.html @@ -0,0 +1,117 @@ +
+
+ {{app}} +
+
+ + + +
+
+ +
+ +
+
+
+
+
+ 流控规则 + + + +
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ 资源名 + + 来源应用 + + 流控模式 + + 阈值类型 + + 阈值 + + 阈值模式 + + 流控效果 + + 操作 +
{{rule.resource}}{{rule.limitApp }} + 直接 + 关联 + 链路 + + {{rule.grade==0 ? '线程数' : 'QPS'}} + + {{rule.count}} + + {{generateThresholdTypeShow(rule)}} + + 快速失败 + Warm Up + 排队等待 + 预热排队 + + + +
+
+ + + +
+ +
+ +
+ +
+ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/flow_v2.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/flow_v2.html new file mode 100755 index 00000000..7e0dcc81 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/flow_v2.html @@ -0,0 +1,113 @@ +
+
+ {{app}} +
+
+ + + 回到单机页面 + +
+
+ +
+ +
+
+
+
+
+ 流控规则 + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ 资源名 + + 来源应用 + + 流控模式 + + 阈值类型 + + 阈值 + + 阈值模式 + + 流控效果 + + 操作 +
{{rule.resource}}{{rule.limitApp }} + 直接 + 关联 + 链路 + + {{rule.grade == 0 ? '线程数' : 'QPS'}} + + {{rule.count}} + + {{generateThresholdTypeShow(rule)}} + + 快速失败 + Warm Up + 排队等待 + 预热排队 + + + +
+
+ + + +
+ +
+ +
+ +
+ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/gateway/api.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/gateway/api.html new file mode 100755 index 00000000..b4e101c9 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/gateway/api.html @@ -0,0 +1,87 @@ +
+
+ {{app}} +
+
+ +
+
+ +
+ +
+
+
+
+
+ API 分组管理 + + +
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + +
+ API 名称 + + 匹配模式 + + 匹配串 + + 操作 +
{{api.apiName}} + 精确 + 前缀 + 正则 + {{api.pattern}} + + +
+
+ + + +
+ +
+ +
+ +
+ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/gateway/flow.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/gateway/flow.html new file mode 100755 index 00000000..62708c41 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/gateway/flow.html @@ -0,0 +1,94 @@ +
+
+ {{app}} +
+
+ +
+
+ +
+ +
+
+
+
+
+ 网关流控规则 + + +
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + +
+ API 名称 + + API 类型 + + 阈值类型 + + 单机阈值 + + 操作 +
{{rule.resource}} + Route ID + API 分组 + + QPS + 线程数 + {{rule.count}} + + +
+
+ + + +
+ +
+ +
+ +
+ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/gateway/identity.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/gateway/identity.html new file mode 100755 index 00000000..0736adc2 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/gateway/identity.html @@ -0,0 +1,98 @@ +
+
+ {{app}} +
+
+ +
+ +
+
+
+
+
+ 请求链路 + + +
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ API 名称 + + API 类型 + 通过 QPS拒绝 QPS线程数平均 RT分钟通过分钟拒绝操作
+ {{resource.resource}} + + Route ID + 自定义 API + {{resource.passQps}}{{resource.blockQps}}{{resource.threadNum}}{{resource.averageRt}}{{resource.oneMinutePass}} + {{resource.oneMinuteBlock}} {{resource.oneMinuteBlock}} +
+ + +
+
+
+ + + +
+ +
+ +
+ +
+ \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/identity.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/identity.html new file mode 100755 index 00000000..1dcf6e92 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/identity.html @@ -0,0 +1,110 @@ +
+
+ {{app}} +
+
+ + +
+
+ + +
+
+ +
+ +
+
+
+
+
+ 簇点链路 + + + +
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 资源名 + 通过QPS拒绝QPS线程数平均RT分钟通过分钟拒绝操作
+ + + {{resource.resource}} + + {{resource.passQps}}{{resource.blockQps}}{{resource.threadNum}}{{resource.averageRt}}{{resource.oneMinutePass}} + {{resource.oneMinuteBlock}} {{resource.oneMinuteBlock}} +
+ + + + +
+
+
+ + + +
+ +
+ +
+ +
+ \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/login.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/login.html new file mode 100755 index 00000000..b5079789 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/login.html @@ -0,0 +1,34 @@ +
+
+ Sentinel Logo + +
+
+
+
+
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ + +
+
+
+
+
\ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/machine.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/machine.html new file mode 100755 index 00000000..6cfcff9c --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/machine.html @@ -0,0 +1,76 @@ +
+
+ {{app}} +
+
+ + + + + +
+
+
+
+
+
+ 机器列表 + 实例总数 {{machines.length}}, 健康 {{healthyCount}}, 失联 {{machines.length - healthyCount}}. + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
机器名IP 地址端口号Sentinel 客户端版本健康状态心跳时间操作
{{entry.hostname}}{{entry.ip}} {{entry.port}} {{entry.version}} 健康失联{{entry.lastHeartbeat | date: 'yyyy/MM/dd HH:mm:ss'}} + +
+
+ + + +
+ +
+ +
+ +
+ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/metric.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/metric.html new file mode 100755 index 00000000..4f0fc7f5 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/metric.html @@ -0,0 +1,117 @@ +
+
+ {{app}} +
+
+ +
+
+
+
+
+
+ + + + {{metricTypeDesc}} 实时监控 + + + + + +
+ + +
+
+
+
+ + +
+
+  {{metric.resource}} + + + +
+ + +
+
+
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
时间通过 QPS拒绝QPS响应时间(ms)
{{tableObj.timestamp | date: 'HH:mm:ss'}}{{tableObj.passQps | number : 1}}{{tableObj.blockQps | number : 1}}{{tableObj.rt | number : 1}}
-
+
+
+
+ +
+ +
+ + +
+ +
+ +
+ +
+
  • +
    + + + +
    +
    + +
    + +
    + +
    diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/pagination.tpl.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/pagination.tpl.html new file mode 100755 index 00000000..6ebbee2f --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/pagination.tpl.html @@ -0,0 +1,18 @@ + diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/param_flow.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/param_flow.html new file mode 100755 index 00000000..c94219b6 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/param_flow.html @@ -0,0 +1,118 @@ +
    +
    + {{app}} +
    +
    + +
    +
    + +
    + +
    +
    +
    +
    +
    + 热点参数限流规则 + + +
    + +
    +
    + + +
    +
    +
    +
    +
    +

    {{loadError.message}}

    +
    +
    +
    +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + + + + + + +
    + 资源名 + + 参数索引 + + 流控模式 + + 阈值 + + 是否集群 + + 例外项数目 + + 操作 +
    {{ruleEntity.rule.resource}}{{ruleEntity.rule.paramIdx}} + {{ruleEntity.rule.grade == 1 ? 'QPS' : '未知'}} + + {{ruleEntity.rule.count}} + + + + + {{ruleEntity.rule.paramFlowItemList == undefined ? 0 : ruleEntity.rule.paramFlowItemList.length}} + + + +
    +
    + + + + + +
    + +
    + +
    + +
    + + \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/system.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/system.html new file mode 100755 index 00000000..6f4e4b84 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/system.html @@ -0,0 +1,92 @@ +
    +
    + {{app}} +
    +
    + +
    +
    + +
    + +
    +
    +
    +
    +
    + 系统规则 + + + +
    + +
    +
    + + +
    + + + + + + + + + + + + + + + +
    + 阈值类型 + + 单机阈值 + + 操作 +
    + 系统 load + 平均 RT + 并发数 + 入口 QPS + CPU 使用率 + + {{rule.highestSystemLoad}} + {{rule.avgRt}} + {{rule.maxThread}} + {{rule.qps}} + {{rule.highestCpuUsage}} + + + +
    +
    + + + +
    + +
    + +
    + +
    + diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/assets/img/sentinel-logo.png b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/assets/img/sentinel-logo.png new file mode 100755 index 00000000..60e8826c Binary files /dev/null and b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/assets/img/sentinel-logo.png differ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/gulpfile.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/gulpfile.js new file mode 100755 index 00000000..6bf496fd --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/gulpfile.js @@ -0,0 +1,134 @@ +const gulp = require('gulp'); +const plugins = require('gulp-load-plugins')(); +const open = require('open'); +const app = { + srcPath: 'app/', // 源代码 + devPath: 'tmp/', // 开发打包 + prdPath: 'dist/' // 生产打包 +}; + +const JS_LIBS = [ + 'node_modules/angular-ui-router/release/angular-ui-router.js', + 'node_modules/oclazyload/dist/ocLazyLoad.min.js', + 'node_modules/angular-loading-bar/build/loading-bar.min.js', + 'node_modules/angular-bootstrap/ui-bootstrap-tpls.min.js', + 'node_modules/moment/moment.js', + 'node_modules/angular-date-time-input/src/dateTimeInput.js', + 'node_modules/angularjs-bootstrap-datetimepicker/src/js/datetimepicker.js', + 'node_modules/angular-table-resize/dist/angular-table-resize.min.js', + 'node_modules/angular-clipboard/angular-clipboard.js', + 'node_modules/selectize/dist/js/standalone/selectize.js', + 'node_modules/angular-selectize2/dist/selectize.js', + 'node_modules/bootstrap-switch/dist/js/bootstrap-switch.min.js', + 'node_modules/ng-dialog/js/ngDialog.js', + 'node_modules/angular-ui-notification/dist/angular-ui-notification.min.js', + 'node_modules/angular-utils-pagination/dirPagination.js', + 'app/scripts/libs/treeTable.js', +]; + +const CSS_APP = [ + 'node_modules/angular-loading-bar/build/loading-bar.min.css', + 'node_modules/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.css', + 'node_modules/ng-dialog/css/ngDialog.min.css', + 'node_modules/ng-dialog/css/ngDialog-theme-default.css', + 'node_modules/angularjs-bootstrap-datetimepicker/src/css/datetimepicker.css', + 'node_modules/angular-ui-notification/dist/angular-ui-notification.min.css', + 'node_modules/angular-table-resize/dist/angular-table-resize.css', + 'node_modules/selectize/dist/css/selectize.css', + 'app/styles/page.css', + 'app/styles/timeline.css', + 'app/styles/main.css' +]; + +const JS_APP = [ + 'app/scripts/app.js', + 'app/scripts/filters/filters.js', + 'app/scripts/services/version_service.js', + 'app/scripts/services/auth_service.js', + 'app/scripts/services/appservice.js', + 'app/scripts/services/flow_service_v1.js', + 'app/scripts/services/flow_service_v2.js', + 'app/scripts/services/degradeservice.js', + 'app/scripts/services/systemservice.js', + 'app/scripts/services/machineservice.js', + 'app/scripts/services/identityservice.js', + 'app/scripts/services/metricservice.js', + 'app/scripts/services/param_flow_service.js', + 'app/scripts/services/authority_service.js', + 'app/scripts/services/cluster_state_service.js', + 'app/scripts/services/gateway/api_service.js', + 'app/scripts/services/gateway/flow_service.js', +]; + +gulp.task('lib', function () { + gulp.src(JS_LIBS) + .pipe(plugins.concat('app.vendor.js')) + .pipe(gulp.dest(app.devPath + 'js')) + .pipe(plugins.uglify()) + .pipe(gulp.dest(app.prdPath + 'js')) + .pipe(plugins.connect.reload()); +}); + +/* +* css任务 +* 在src下创建style文件夹,里面存放less文件。 +*/ +gulp.task('css', function () { + gulp.src(CSS_APP) + .pipe(plugins.concat('app.css')) + .pipe(gulp.dest(app.devPath + 'css')) + .pipe(plugins.cssmin()) + .pipe(gulp.dest(app.prdPath + 'css')) + .pipe(plugins.connect.reload()); +}); + +/* +* js任务 +* 在src目录下创建script文件夹,里面存放所有的js文件 +*/ +gulp.task('js', function () { + gulp.src(JS_APP) + .pipe(plugins.concat('app.js')) + .pipe(gulp.dest(app.devPath + 'js')) + .pipe(plugins.uglify()) + .pipe(gulp.dest(app.prdPath + 'js')) + .pipe(plugins.connect.reload()); +}); + +/* +* js任务 +* 在src目录下创建script文件夹,里面存放所有的js文件 +*/ +gulp.task('jshint', function () { + gulp.src(JS_APP) + .pipe(plugins.jshint()) + .pipe(plugins.jshint.reporter()); +}); + +// 每次发布的时候,可能需要把之前目录内的内容清除,避免旧的文件对新的容有所影响。 需要在每次发布前删除dist和build目录 +gulp.task('clean', function () { + gulp.src([app.devPath, app.prdPath]) + .pipe(plugins.clean()); +}); + +// 总任务 +gulp.task('build', ['clean', 'jshint', 'lib', 'js', 'css']); + +// 服务 +gulp.task('serve', ['build'], function () { + plugins.connect.server({ //启动一个服务器 + root: [app.devPath], // 服务器从哪个路径开始读取,默认从开发路径读取 + livereload: true, // 自动刷新 + port: 1234 + }); + // 打开浏览器 + setTimeout(() => { + open('http://localhost:8080/index_dev.htm') + }, 200); + // 监听 + gulp.watch(app.srcPath + '**/*.js', ['js']); + gulp.watch(app.srcPath + '**/*.css', ['css']); +}); + +// 定义default任务 +gulp.task('default', ['serve']); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/index.htm b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/index.htm new file mode 100755 index 00000000..3c833412 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/index.htm @@ -0,0 +1,28 @@ + + + + + + Sentinel Dashboard + + + + + + + + + +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/index_dev.htm b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/index_dev.htm new file mode 100755 index 00000000..a2a85efc --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/index_dev.htm @@ -0,0 +1,28 @@ + + + + + + Sentinel 控制台 + + + + + + + + + +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/css/bootstrap.min.css b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/css/bootstrap.min.css new file mode 100755 index 00000000..c547283b --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/css/bootstrap.min.css @@ -0,0 +1,7 @@ +/*! + * Bootstrap v3.0.3 (http://getbootstrap.com) + * Copyright 2013 Twitter, Inc. + * Licensed under http://www.apache.org/licenses/LICENSE-2.0 + */ + +/*! normalize.css v2.1.3 | MIT License | git.io/normalize */article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,video{display:inline-block}audio:not([controls]){display:none;height:0}[hidden],template{display:none}html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}a{background:transparent}a:focus{outline:thin dotted}a:active,a:hover{outline:0}h1{margin:.67em 0;font-size:2em}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}hr{height:0;-moz-box-sizing:content-box;box-sizing:content-box}mark{color:#000;background:#ff0}code,kbd,pre,samp{font-family:monospace,serif;font-size:1em}pre{white-space:pre-wrap}q{quotes:"\201C" "\201D" "\2018" "\2019"}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:0}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid #c0c0c0}legend{padding:0;border:0}button,input,select,textarea{margin:0;font-family:inherit;font-size:100%}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}button[disabled],html input[disabled]{cursor:default}input[type="checkbox"],input[type="radio"]{padding:0;box-sizing:border-box}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}textarea{overflow:auto;vertical-align:top}table{border-collapse:collapse;border-spacing:0}@media print{*{color:#000!important;text-shadow:none!important;background:transparent!important;box-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%!important}@page{margin:2cm .5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}select{background:#fff!important}.navbar{display:none}.table td,.table th{background-color:#fff!important}.btn>.caret,.dropup>.btn>.caret{border-top-color:#000!important}.label{border:1px solid #000}.table{border-collapse:collapse!important}.table-bordered th,.table-bordered td{border:1px solid #ddd!important}}*,*:before,*:after{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html{font-size:62.5%;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:1.428571429;color:#333;background-color:#fff}input,button,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit}a{color:#428bca;text-decoration:none}a:hover,a:focus{color:#2a6496;text-decoration:underline}a:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}img{vertical-align:middle}.img-responsive{display:block;height:auto;max-width:100%}.img-rounded{border-radius:6px}.img-thumbnail{display:inline-block;height:auto;max-width:100%;padding:4px;line-height:1.428571429;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.img-circle{border-radius:50%}hr{margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-weight:500;line-height:1.1;color:inherit}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small,.h1 small,.h2 small,.h3 small,.h4 small,.h5 small,.h6 small,h1 .small,h2 .small,h3 .small,h4 .small,h5 .small,h6 .small,.h1 .small,.h2 .small,.h3 .small,.h4 .small,.h5 .small,.h6 .small{font-weight:normal;line-height:1;color:#999}h1,h2,h3{margin-top:20px;margin-bottom:10px}h1 small,h2 small,h3 small,h1 .small,h2 .small,h3 .small{font-size:65%}h4,h5,h6{margin-top:10px;margin-bottom:10px}h4 small,h5 small,h6 small,h4 .small,h5 .small,h6 .small{font-size:75%}h1,.h1{font-size:36px}h2,.h2{font-size:30px}h3,.h3{font-size:24px}h4,.h4{font-size:18px}h5,.h5{font-size:14px}h6,.h6{font-size:12px}p{margin:0 0 10px}.lead{margin-bottom:20px;font-size:16px;font-weight:200;line-height:1.4}@media(min-width:768px){.lead{font-size:21px}}small,.small{font-size:85%}cite{font-style:normal}.text-muted{color:#999}.text-primary{color:#428bca}.text-primary:hover{color:#3071a9}.text-warning{color:#8a6d3b}.text-warning:hover{color:#66512c}.text-danger{color:#a94442}.text-danger:hover{color:#843534}.text-success{color:#3c763d}.text-success:hover{color:#2b542c}.text-info{color:#31708f}.text-info:hover{color:#245269}.text-left{text-align:left}.text-right{text-align:right}.text-center{text-align:center}.page-header{padding-bottom:9px;margin:40px 0 20px;border-bottom:1px solid #eee}ul,ol{margin-top:0;margin-bottom:10px}ul ul,ol ul,ul ol,ol ol{margin-bottom:0}.list-unstyled{padding-left:0;list-style:none}.list-inline{padding-left:0;list-style:none}.list-inline>li{display:inline-block;padding-right:5px;padding-left:5px}.list-inline>li:first-child{padding-left:0}dl{margin-top:0;margin-bottom:20px}dt,dd{line-height:1.428571429}dt{font-weight:bold}dd{margin-left:0}@media(min-width:768px){.dl-horizontal dt{float:left;width:160px;overflow:hidden;clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:180px}.dl-horizontal dd:before,.dl-horizontal dd:after{display:table;content:" "}.dl-horizontal dd:after{clear:both}.dl-horizontal dd:before,.dl-horizontal dd:after{display:table;content:" "}.dl-horizontal dd:after{clear:both}}abbr[title],abbr[data-original-title]{cursor:help;border-bottom:1px dotted #999}.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:10px 20px;margin:0 0 20px;border-left:5px solid #eee}blockquote p{font-size:17.5px;font-weight:300;line-height:1.25}blockquote p:last-child{margin-bottom:0}blockquote small,blockquote .small{display:block;line-height:1.428571429;color:#999}blockquote small:before,blockquote .small:before{content:'\2014 \00A0'}blockquote.pull-right{padding-right:15px;padding-left:0;border-right:5px solid #eee;border-left:0}blockquote.pull-right p,blockquote.pull-right small,blockquote.pull-right .small{text-align:right}blockquote.pull-right small:before,blockquote.pull-right .small:before{content:''}blockquote.pull-right small:after,blockquote.pull-right .small:after{content:'\00A0 \2014'}blockquote:before,blockquote:after{content:""}address{margin-bottom:20px;font-style:normal;line-height:1.428571429}code,kbd,pre,samp{font-family:Menlo,Monaco,Consolas,"Courier New",monospace}code{padding:2px 4px;font-size:90%;color:#c7254e;white-space:nowrap;background-color:#f9f2f4;border-radius:4px}pre{display:block;padding:9.5px;margin:0 0 10px;font-size:13px;line-height:1.428571429;color:#333;word-break:break-all;word-wrap:break-word;background-color:#f5f5f5;border:1px solid #ccc;border-radius:4px}pre code{padding:0;font-size:inherit;color:inherit;white-space:pre-wrap;background-color:transparent;border-radius:0}.pre-scrollable{max-height:340px;overflow-y:scroll}.container{padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}.container:before,.container:after{display:table;content:" "}.container:after{clear:both}.container:before,.container:after{display:table;content:" "}.container:after{clear:both}@media(min-width:768px){.container{width:750px}}@media(min-width:992px){.container{width:970px}}@media(min-width:1200px){.container{width:1170px}}.row{margin-right:-15px;margin-left:-15px}.row:before,.row:after{display:table;content:" "}.row:after{clear:both}.row:before,.row:after{display:table;content:" "}.row:after{clear:both}.col-xs-1,.col-sm-1,.col-md-1,.col-lg-1,.col-xs-2,.col-sm-2,.col-md-2,.col-lg-2,.col-xs-3,.col-sm-3,.col-md-3,.col-lg-3,.col-xs-4,.col-sm-4,.col-md-4,.col-lg-4,.col-xs-5,.col-sm-5,.col-md-5,.col-lg-5,.col-xs-6,.col-sm-6,.col-md-6,.col-lg-6,.col-xs-7,.col-sm-7,.col-md-7,.col-lg-7,.col-xs-8,.col-sm-8,.col-md-8,.col-lg-8,.col-xs-9,.col-sm-9,.col-md-9,.col-lg-9,.col-xs-10,.col-sm-10,.col-md-10,.col-lg-10,.col-xs-11,.col-sm-11,.col-md-11,.col-lg-11,.col-xs-12,.col-sm-12,.col-md-12,.col-lg-12{position:relative;min-height:1px;padding-right:15px;padding-left:15px}.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11,.col-xs-12{float:left}.col-xs-12{width:100%}.col-xs-11{width:91.66666666666666%}.col-xs-10{width:83.33333333333334%}.col-xs-9{width:75%}.col-xs-8{width:66.66666666666666%}.col-xs-7{width:58.333333333333336%}.col-xs-6{width:50%}.col-xs-5{width:41.66666666666667%}.col-xs-4{width:33.33333333333333%}.col-xs-3{width:25%}.col-xs-2{width:16.666666666666664%}.col-xs-1{width:8.333333333333332%}.col-xs-pull-12{right:100%}.col-xs-pull-11{right:91.66666666666666%}.col-xs-pull-10{right:83.33333333333334%}.col-xs-pull-9{right:75%}.col-xs-pull-8{right:66.66666666666666%}.col-xs-pull-7{right:58.333333333333336%}.col-xs-pull-6{right:50%}.col-xs-pull-5{right:41.66666666666667%}.col-xs-pull-4{right:33.33333333333333%}.col-xs-pull-3{right:25%}.col-xs-pull-2{right:16.666666666666664%}.col-xs-pull-1{right:8.333333333333332%}.col-xs-pull-0{right:0}.col-xs-push-12{left:100%}.col-xs-push-11{left:91.66666666666666%}.col-xs-push-10{left:83.33333333333334%}.col-xs-push-9{left:75%}.col-xs-push-8{left:66.66666666666666%}.col-xs-push-7{left:58.333333333333336%}.col-xs-push-6{left:50%}.col-xs-push-5{left:41.66666666666667%}.col-xs-push-4{left:33.33333333333333%}.col-xs-push-3{left:25%}.col-xs-push-2{left:16.666666666666664%}.col-xs-push-1{left:8.333333333333332%}.col-xs-push-0{left:0}.col-xs-offset-12{margin-left:100%}.col-xs-offset-11{margin-left:91.66666666666666%}.col-xs-offset-10{margin-left:83.33333333333334%}.col-xs-offset-9{margin-left:75%}.col-xs-offset-8{margin-left:66.66666666666666%}.col-xs-offset-7{margin-left:58.333333333333336%}.col-xs-offset-6{margin-left:50%}.col-xs-offset-5{margin-left:41.66666666666667%}.col-xs-offset-4{margin-left:33.33333333333333%}.col-xs-offset-3{margin-left:25%}.col-xs-offset-2{margin-left:16.666666666666664%}.col-xs-offset-1{margin-left:8.333333333333332%}.col-xs-offset-0{margin-left:0}@media(min-width:768px){.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11,.col-sm-12{float:left}.col-sm-12{width:100%}.col-sm-11{width:91.66666666666666%}.col-sm-10{width:83.33333333333334%}.col-sm-9{width:75%}.col-sm-8{width:66.66666666666666%}.col-sm-7{width:58.333333333333336%}.col-sm-6{width:50%}.col-sm-5{width:41.66666666666667%}.col-sm-4{width:33.33333333333333%}.col-sm-3{width:25%}.col-sm-2{width:16.666666666666664%}.col-sm-1{width:8.333333333333332%}.col-sm-pull-12{right:100%}.col-sm-pull-11{right:91.66666666666666%}.col-sm-pull-10{right:83.33333333333334%}.col-sm-pull-9{right:75%}.col-sm-pull-8{right:66.66666666666666%}.col-sm-pull-7{right:58.333333333333336%}.col-sm-pull-6{right:50%}.col-sm-pull-5{right:41.66666666666667%}.col-sm-pull-4{right:33.33333333333333%}.col-sm-pull-3{right:25%}.col-sm-pull-2{right:16.666666666666664%}.col-sm-pull-1{right:8.333333333333332%}.col-sm-pull-0{right:0}.col-sm-push-12{left:100%}.col-sm-push-11{left:91.66666666666666%}.col-sm-push-10{left:83.33333333333334%}.col-sm-push-9{left:75%}.col-sm-push-8{left:66.66666666666666%}.col-sm-push-7{left:58.333333333333336%}.col-sm-push-6{left:50%}.col-sm-push-5{left:41.66666666666667%}.col-sm-push-4{left:33.33333333333333%}.col-sm-push-3{left:25%}.col-sm-push-2{left:16.666666666666664%}.col-sm-push-1{left:8.333333333333332%}.col-sm-push-0{left:0}.col-sm-offset-12{margin-left:100%}.col-sm-offset-11{margin-left:91.66666666666666%}.col-sm-offset-10{margin-left:83.33333333333334%}.col-sm-offset-9{margin-left:75%}.col-sm-offset-8{margin-left:66.66666666666666%}.col-sm-offset-7{margin-left:58.333333333333336%}.col-sm-offset-6{margin-left:50%}.col-sm-offset-5{margin-left:41.66666666666667%}.col-sm-offset-4{margin-left:33.33333333333333%}.col-sm-offset-3{margin-left:25%}.col-sm-offset-2{margin-left:16.666666666666664%}.col-sm-offset-1{margin-left:8.333333333333332%}.col-sm-offset-0{margin-left:0}}@media(min-width:992px){.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11,.col-md-12{float:left}.col-md-12{width:100%}.col-md-11{width:91.66666666666666%}.col-md-10{width:83.33333333333334%}.col-md-9{width:75%}.col-md-8{width:66.66666666666666%}.col-md-7{width:58.333333333333336%}.col-md-6{width:50%}.col-md-5{width:41.66666666666667%}.col-md-4{width:33.33333333333333%}.col-md-3{width:25%}.col-md-2{width:16.666666666666664%}.col-md-1{width:8.333333333333332%}.col-md-pull-12{right:100%}.col-md-pull-11{right:91.66666666666666%}.col-md-pull-10{right:83.33333333333334%}.col-md-pull-9{right:75%}.col-md-pull-8{right:66.66666666666666%}.col-md-pull-7{right:58.333333333333336%}.col-md-pull-6{right:50%}.col-md-pull-5{right:41.66666666666667%}.col-md-pull-4{right:33.33333333333333%}.col-md-pull-3{right:25%}.col-md-pull-2{right:16.666666666666664%}.col-md-pull-1{right:8.333333333333332%}.col-md-pull-0{right:0}.col-md-push-12{left:100%}.col-md-push-11{left:91.66666666666666%}.col-md-push-10{left:83.33333333333334%}.col-md-push-9{left:75%}.col-md-push-8{left:66.66666666666666%}.col-md-push-7{left:58.333333333333336%}.col-md-push-6{left:50%}.col-md-push-5{left:41.66666666666667%}.col-md-push-4{left:33.33333333333333%}.col-md-push-3{left:25%}.col-md-push-2{left:16.666666666666664%}.col-md-push-1{left:8.333333333333332%}.col-md-push-0{left:0}.col-md-offset-12{margin-left:100%}.col-md-offset-11{margin-left:91.66666666666666%}.col-md-offset-10{margin-left:83.33333333333334%}.col-md-offset-9{margin-left:75%}.col-md-offset-8{margin-left:66.66666666666666%}.col-md-offset-7{margin-left:58.333333333333336%}.col-md-offset-6{margin-left:50%}.col-md-offset-5{margin-left:41.66666666666667%}.col-md-offset-4{margin-left:33.33333333333333%}.col-md-offset-3{margin-left:25%}.col-md-offset-2{margin-left:16.666666666666664%}.col-md-offset-1{margin-left:8.333333333333332%}.col-md-offset-0{margin-left:0}}@media(min-width:1200px){.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11,.col-lg-12{float:left}.col-lg-12{width:100%}.col-lg-11{width:91.66666666666666%}.col-lg-10{width:83.33333333333334%}.col-lg-9{width:75%}.col-lg-8{width:66.66666666666666%}.col-lg-7{width:58.333333333333336%}.col-lg-6{width:50%}.col-lg-5{width:41.66666666666667%}.col-lg-4{width:33.33333333333333%}.col-lg-3{width:25%}.col-lg-2{width:16.666666666666664%}.col-lg-1{width:8.333333333333332%}.col-lg-pull-12{right:100%}.col-lg-pull-11{right:91.66666666666666%}.col-lg-pull-10{right:83.33333333333334%}.col-lg-pull-9{right:75%}.col-lg-pull-8{right:66.66666666666666%}.col-lg-pull-7{right:58.333333333333336%}.col-lg-pull-6{right:50%}.col-lg-pull-5{right:41.66666666666667%}.col-lg-pull-4{right:33.33333333333333%}.col-lg-pull-3{right:25%}.col-lg-pull-2{right:16.666666666666664%}.col-lg-pull-1{right:8.333333333333332%}.col-lg-pull-0{right:0}.col-lg-push-12{left:100%}.col-lg-push-11{left:91.66666666666666%}.col-lg-push-10{left:83.33333333333334%}.col-lg-push-9{left:75%}.col-lg-push-8{left:66.66666666666666%}.col-lg-push-7{left:58.333333333333336%}.col-lg-push-6{left:50%}.col-lg-push-5{left:41.66666666666667%}.col-lg-push-4{left:33.33333333333333%}.col-lg-push-3{left:25%}.col-lg-push-2{left:16.666666666666664%}.col-lg-push-1{left:8.333333333333332%}.col-lg-push-0{left:0}.col-lg-offset-12{margin-left:100%}.col-lg-offset-11{margin-left:91.66666666666666%}.col-lg-offset-10{margin-left:83.33333333333334%}.col-lg-offset-9{margin-left:75%}.col-lg-offset-8{margin-left:66.66666666666666%}.col-lg-offset-7{margin-left:58.333333333333336%}.col-lg-offset-6{margin-left:50%}.col-lg-offset-5{margin-left:41.66666666666667%}.col-lg-offset-4{margin-left:33.33333333333333%}.col-lg-offset-3{margin-left:25%}.col-lg-offset-2{margin-left:16.666666666666664%}.col-lg-offset-1{margin-left:8.333333333333332%}.col-lg-offset-0{margin-left:0}}table{max-width:100%;background-color:transparent}th{text-align:left}.table{width:100%;margin-bottom:20px}.table>thead>tr>th,.table>tbody>tr>th,.table>tfoot>tr>th,.table>thead>tr>td,.table>tbody>tr>td,.table>tfoot>tr>td{padding:8px;line-height:1.428571429;vertical-align:top;border-top:1px solid #ddd}.table>thead>tr>th{vertical-align:bottom;border-bottom:2px solid #ddd}.table>caption+thead>tr:first-child>th,.table>colgroup+thead>tr:first-child>th,.table>thead:first-child>tr:first-child>th,.table>caption+thead>tr:first-child>td,.table>colgroup+thead>tr:first-child>td,.table>thead:first-child>tr:first-child>td{border-top:0}.table>tbody+tbody{border-top:2px solid #ddd}.table .table{background-color:#fff}.table-condensed>thead>tr>th,.table-condensed>tbody>tr>th,.table-condensed>tfoot>tr>th,.table-condensed>thead>tr>td,.table-condensed>tbody>tr>td,.table-condensed>tfoot>tr>td{padding:5px}.table-bordered{border:1px solid #ddd}.table-bordered>thead>tr>th,.table-bordered>tbody>tr>th,.table-bordered>tfoot>tr>th,.table-bordered>thead>tr>td,.table-bordered>tbody>tr>td,.table-bordered>tfoot>tr>td{border:1px solid #ddd}.table-bordered>thead>tr>th,.table-bordered>thead>tr>td{border-bottom-width:2px}.table-striped>tbody>tr:nth-child(odd)>td,.table-striped>tbody>tr:nth-child(odd)>th{background-color:#f9f9f9}.table-hover>tbody>tr:hover>td,.table-hover>tbody>tr:hover>th{background-color:#f5f5f5}table col[class*="col-"]{position:static;display:table-column;float:none}table td[class*="col-"],table th[class*="col-"]{display:table-cell;float:none}.table>thead>tr>.active,.table>tbody>tr>.active,.table>tfoot>tr>.active,.table>thead>.active>td,.table>tbody>.active>td,.table>tfoot>.active>td,.table>thead>.active>th,.table>tbody>.active>th,.table>tfoot>.active>th{background-color:#f5f5f5}.table-hover>tbody>tr>.active:hover,.table-hover>tbody>.active:hover>td,.table-hover>tbody>.active:hover>th{background-color:#e8e8e8}.table>thead>tr>.success,.table>tbody>tr>.success,.table>tfoot>tr>.success,.table>thead>.success>td,.table>tbody>.success>td,.table>tfoot>.success>td,.table>thead>.success>th,.table>tbody>.success>th,.table>tfoot>.success>th{background-color:#dff0d8}.table-hover>tbody>tr>.success:hover,.table-hover>tbody>.success:hover>td,.table-hover>tbody>.success:hover>th{background-color:#d0e9c6}.table>thead>tr>.danger,.table>tbody>tr>.danger,.table>tfoot>tr>.danger,.table>thead>.danger>td,.table>tbody>.danger>td,.table>tfoot>.danger>td,.table>thead>.danger>th,.table>tbody>.danger>th,.table>tfoot>.danger>th{background-color:#f2dede}.table-hover>tbody>tr>.danger:hover,.table-hover>tbody>.danger:hover>td,.table-hover>tbody>.danger:hover>th{background-color:#ebcccc}.table>thead>tr>.warning,.table>tbody>tr>.warning,.table>tfoot>tr>.warning,.table>thead>.warning>td,.table>tbody>.warning>td,.table>tfoot>.warning>td,.table>thead>.warning>th,.table>tbody>.warning>th,.table>tfoot>.warning>th{background-color:#fcf8e3}.table-hover>tbody>tr>.warning:hover,.table-hover>tbody>.warning:hover>td,.table-hover>tbody>.warning:hover>th{background-color:#faf2cc}@media(max-width:767px){.table-responsive{width:100%;margin-bottom:15px;overflow-x:scroll;overflow-y:hidden;border:1px solid #ddd;-ms-overflow-style:-ms-autohiding-scrollbar;-webkit-overflow-scrolling:touch}.table-responsive>.table{margin-bottom:0}.table-responsive>.table>thead>tr>th,.table-responsive>.table>tbody>tr>th,.table-responsive>.table>tfoot>tr>th,.table-responsive>.table>thead>tr>td,.table-responsive>.table>tbody>tr>td,.table-responsive>.table>tfoot>tr>td{white-space:nowrap}.table-responsive>.table-bordered{border:0}.table-responsive>.table-bordered>thead>tr>th:first-child,.table-responsive>.table-bordered>tbody>tr>th:first-child,.table-responsive>.table-bordered>tfoot>tr>th:first-child,.table-responsive>.table-bordered>thead>tr>td:first-child,.table-responsive>.table-bordered>tbody>tr>td:first-child,.table-responsive>.table-bordered>tfoot>tr>td:first-child{border-left:0}.table-responsive>.table-bordered>thead>tr>th:last-child,.table-responsive>.table-bordered>tbody>tr>th:last-child,.table-responsive>.table-bordered>tfoot>tr>th:last-child,.table-responsive>.table-bordered>thead>tr>td:last-child,.table-responsive>.table-bordered>tbody>tr>td:last-child,.table-responsive>.table-bordered>tfoot>tr>td:last-child{border-right:0}.table-responsive>.table-bordered>tbody>tr:last-child>th,.table-responsive>.table-bordered>tfoot>tr:last-child>th,.table-responsive>.table-bordered>tbody>tr:last-child>td,.table-responsive>.table-bordered>tfoot>tr:last-child>td{border-bottom:0}}fieldset{padding:0;margin:0;border:0}legend{display:block;width:100%;padding:0;margin-bottom:20px;font-size:21px;line-height:inherit;color:#333;border:0;border-bottom:1px solid #e5e5e5}label{display:inline-block;margin-bottom:5px;font-weight:bold}input[type="search"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}input[type="radio"],input[type="checkbox"]{margin:4px 0 0;margin-top:1px \9;line-height:normal}input[type="file"]{display:block}select[multiple],select[size]{height:auto}select optgroup{font-family:inherit;font-size:inherit;font-style:inherit}input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}input[type="number"]::-webkit-outer-spin-button,input[type="number"]::-webkit-inner-spin-button{height:auto}output{display:block;padding-top:7px;font-size:14px;line-height:1.428571429;color:#555;vertical-align:middle}.form-control{display:block;width:100%;height:34px;padding:6px 12px;font-size:14px;line-height:1.428571429;color:#555;vertical-align:middle;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.form-control:focus{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(102,175,233,0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(102,175,233,0.6)}.form-control:-moz-placeholder{color:#999}.form-control::-moz-placeholder{color:#999;opacity:1}.form-control:-ms-input-placeholder{color:#999}.form-control::-webkit-input-placeholder{color:#999}.form-control[disabled],.form-control[readonly],fieldset[disabled] .form-control{cursor:not-allowed;background-color:#eee}textarea.form-control{height:auto}.form-group{margin-bottom:15px}.radio,.checkbox{display:block;min-height:20px;padding-left:20px;margin-top:10px;margin-bottom:10px;vertical-align:middle}.radio label,.checkbox label{display:inline;margin-bottom:0;font-weight:normal;cursor:pointer}.radio input[type="radio"],.radio-inline input[type="radio"],.checkbox input[type="checkbox"],.checkbox-inline input[type="checkbox"]{float:left;margin-left:-20px}.radio+.radio,.checkbox+.checkbox{margin-top:-5px}.radio-inline,.checkbox-inline{display:inline-block;padding-left:20px;margin-bottom:0;font-weight:normal;vertical-align:middle;cursor:pointer}.radio-inline+.radio-inline,.checkbox-inline+.checkbox-inline{margin-top:0;margin-left:10px}input[type="radio"][disabled],input[type="checkbox"][disabled],.radio[disabled],.radio-inline[disabled],.checkbox[disabled],.checkbox-inline[disabled],fieldset[disabled] input[type="radio"],fieldset[disabled] input[type="checkbox"],fieldset[disabled] .radio,fieldset[disabled] .radio-inline,fieldset[disabled] .checkbox,fieldset[disabled] .checkbox-inline{cursor:not-allowed}.input-sm{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.input-sm{height:30px;line-height:30px}textarea.input-sm{height:auto}.input-lg{height:46px;padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}select.input-lg{height:46px;line-height:46px}textarea.input-lg{height:auto}.has-warning .help-block,.has-warning .control-label,.has-warning .radio,.has-warning .checkbox,.has-warning .radio-inline,.has-warning .checkbox-inline{color:#8a6d3b}.has-warning .form-control{border-color:#8a6d3b;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-warning .form-control:focus{border-color:#66512c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #c0a16b;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #c0a16b}.has-warning .input-group-addon{color:#8a6d3b;background-color:#fcf8e3;border-color:#8a6d3b}.has-error .help-block,.has-error .control-label,.has-error .radio,.has-error .checkbox,.has-error .radio-inline,.has-error .checkbox-inline{color:#a94442}.has-error .form-control{border-color:#a94442;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-error .form-control:focus{border-color:#843534;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #ce8483;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #ce8483}.has-error .input-group-addon{color:#a94442;background-color:#f2dede;border-color:#a94442}.has-success .help-block,.has-success .control-label,.has-success .radio,.has-success .checkbox,.has-success .radio-inline,.has-success .checkbox-inline{color:#3c763d}.has-success .form-control{border-color:#3c763d;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-success .form-control:focus{border-color:#2b542c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #67b168;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #67b168}.has-success .input-group-addon{color:#3c763d;background-color:#dff0d8;border-color:#3c763d}.form-control-static{margin-bottom:0}.help-block{display:block;margin-top:5px;margin-bottom:10px;color:#737373}@media(min-width:768px){.form-inline .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.form-inline .form-control{display:inline-block}.form-inline select.form-control{width:auto}.form-inline .radio,.form-inline .checkbox{display:inline-block;padding-left:0;margin-top:0;margin-bottom:0}.form-inline .radio input[type="radio"],.form-inline .checkbox input[type="checkbox"]{float:none;margin-left:0}}.form-horizontal .control-label,.form-horizontal .radio,.form-horizontal .checkbox,.form-horizontal .radio-inline,.form-horizontal .checkbox-inline{padding-top:7px;margin-top:0;margin-bottom:0}.form-horizontal .radio,.form-horizontal .checkbox{min-height:27px}.form-horizontal .form-group{margin-right:-15px;margin-left:-15px}.form-horizontal .form-group:before,.form-horizontal .form-group:after{display:table;content:" "}.form-horizontal .form-group:after{clear:both}.form-horizontal .form-group:before,.form-horizontal .form-group:after{display:table;content:" "}.form-horizontal .form-group:after{clear:both}.form-horizontal .form-control-static{padding-top:7px}@media(min-width:768px){.form-horizontal .control-label{text-align:right}}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-size:14px;font-weight:normal;line-height:1.428571429;text-align:center;white-space:nowrap;vertical-align:middle;cursor:pointer;background-image:none;border:1px solid transparent;border-radius:4px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.btn:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn:hover,.btn:focus{color:#333;text-decoration:none}.btn:active,.btn.active{background-image:none;outline:0;-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}.btn.disabled,.btn[disabled],fieldset[disabled] .btn{pointer-events:none;cursor:not-allowed;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;box-shadow:none}.btn-default{color:#333;background-color:#fff;border-color:#ccc}.btn-default:hover,.btn-default:focus,.btn-default:active,.btn-default.active,.open .dropdown-toggle.btn-default{color:#333;background-color:#ebebeb;border-color:#adadad}.btn-default:active,.btn-default.active,.open .dropdown-toggle.btn-default{background-image:none}.btn-default.disabled,.btn-default[disabled],fieldset[disabled] .btn-default,.btn-default.disabled:hover,.btn-default[disabled]:hover,fieldset[disabled] .btn-default:hover,.btn-default.disabled:focus,.btn-default[disabled]:focus,fieldset[disabled] .btn-default:focus,.btn-default.disabled:active,.btn-default[disabled]:active,fieldset[disabled] .btn-default:active,.btn-default.disabled.active,.btn-default[disabled].active,fieldset[disabled] .btn-default.active{background-color:#fff;border-color:#ccc}.btn-default .badge{color:#fff;background-color:#fff}.btn-primary{color:#fff;background-color:#428bca;border-color:#357ebd}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.open .dropdown-toggle.btn-primary{color:#fff;background-color:#3276b1;border-color:#285e8e}.btn-primary:active,.btn-primary.active,.open .dropdown-toggle.btn-primary{background-image:none}.btn-primary.disabled,.btn-primary[disabled],fieldset[disabled] .btn-primary,.btn-primary.disabled:hover,.btn-primary[disabled]:hover,fieldset[disabled] .btn-primary:hover,.btn-primary.disabled:focus,.btn-primary[disabled]:focus,fieldset[disabled] .btn-primary:focus,.btn-primary.disabled:active,.btn-primary[disabled]:active,fieldset[disabled] .btn-primary:active,.btn-primary.disabled.active,.btn-primary[disabled].active,fieldset[disabled] .btn-primary.active{background-color:#428bca;border-color:#357ebd}.btn-primary .badge{color:#428bca;background-color:#fff}.btn-warning{color:#fff;background-color:#f0ad4e;border-color:#eea236}.btn-warning:hover,.btn-warning:focus,.btn-warning:active,.btn-warning.active,.open .dropdown-toggle.btn-warning{color:#fff;background-color:#ed9c28;border-color:#d58512}.btn-warning:active,.btn-warning.active,.open .dropdown-toggle.btn-warning{background-image:none}.btn-warning.disabled,.btn-warning[disabled],fieldset[disabled] .btn-warning,.btn-warning.disabled:hover,.btn-warning[disabled]:hover,fieldset[disabled] .btn-warning:hover,.btn-warning.disabled:focus,.btn-warning[disabled]:focus,fieldset[disabled] .btn-warning:focus,.btn-warning.disabled:active,.btn-warning[disabled]:active,fieldset[disabled] .btn-warning:active,.btn-warning.disabled.active,.btn-warning[disabled].active,fieldset[disabled] .btn-warning.active{background-color:#f0ad4e;border-color:#eea236}.btn-warning .badge{color:#f0ad4e;background-color:#fff}.btn-danger{color:#fff;background-color:#d9534f;border-color:#d43f3a}.btn-danger:hover,.btn-danger:focus,.btn-danger:active,.btn-danger.active,.open .dropdown-toggle.btn-danger{color:#fff;background-color:#d2322d;border-color:#ac2925}.btn-danger:active,.btn-danger.active,.open .dropdown-toggle.btn-danger{background-image:none}.btn-danger.disabled,.btn-danger[disabled],fieldset[disabled] .btn-danger,.btn-danger.disabled:hover,.btn-danger[disabled]:hover,fieldset[disabled] .btn-danger:hover,.btn-danger.disabled:focus,.btn-danger[disabled]:focus,fieldset[disabled] .btn-danger:focus,.btn-danger.disabled:active,.btn-danger[disabled]:active,fieldset[disabled] .btn-danger:active,.btn-danger.disabled.active,.btn-danger[disabled].active,fieldset[disabled] .btn-danger.active{background-color:#d9534f;border-color:#d43f3a}.btn-danger .badge{color:#d9534f;background-color:#fff}.btn-success{color:#fff;background-color:#5cb85c;border-color:#4cae4c}.btn-success:hover,.btn-success:focus,.btn-success:active,.btn-success.active,.open .dropdown-toggle.btn-success{color:#fff;background-color:#47a447;border-color:#398439}.btn-success:active,.btn-success.active,.open .dropdown-toggle.btn-success{background-image:none}.btn-success.disabled,.btn-success[disabled],fieldset[disabled] .btn-success,.btn-success.disabled:hover,.btn-success[disabled]:hover,fieldset[disabled] .btn-success:hover,.btn-success.disabled:focus,.btn-success[disabled]:focus,fieldset[disabled] .btn-success:focus,.btn-success.disabled:active,.btn-success[disabled]:active,fieldset[disabled] .btn-success:active,.btn-success.disabled.active,.btn-success[disabled].active,fieldset[disabled] .btn-success.active{background-color:#5cb85c;border-color:#4cae4c}.btn-success .badge{color:#5cb85c;background-color:#fff}.btn-info{color:#fff;background-color:#5bc0de;border-color:#46b8da}.btn-info:hover,.btn-info:focus,.btn-info:active,.btn-info.active,.open .dropdown-toggle.btn-info{color:#fff;background-color:#39b3d7;border-color:#269abc}.btn-info:active,.btn-info.active,.open .dropdown-toggle.btn-info{background-image:none}.btn-info.disabled,.btn-info[disabled],fieldset[disabled] .btn-info,.btn-info.disabled:hover,.btn-info[disabled]:hover,fieldset[disabled] .btn-info:hover,.btn-info.disabled:focus,.btn-info[disabled]:focus,fieldset[disabled] .btn-info:focus,.btn-info.disabled:active,.btn-info[disabled]:active,fieldset[disabled] .btn-info:active,.btn-info.disabled.active,.btn-info[disabled].active,fieldset[disabled] .btn-info.active{background-color:#5bc0de;border-color:#46b8da}.btn-info .badge{color:#5bc0de;background-color:#fff}.btn-link{font-weight:normal;color:#428bca;cursor:pointer;border-radius:0}.btn-link,.btn-link:active,.btn-link[disabled],fieldset[disabled] .btn-link{background-color:transparent;-webkit-box-shadow:none;box-shadow:none}.btn-link,.btn-link:hover,.btn-link:focus,.btn-link:active{border-color:transparent}.btn-link:hover,.btn-link:focus{color:#2a6496;text-decoration:underline;background-color:transparent}.btn-link[disabled]:hover,fieldset[disabled] .btn-link:hover,.btn-link[disabled]:focus,fieldset[disabled] .btn-link:focus{color:#999;text-decoration:none}.btn-lg{padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}.btn-sm{padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.btn-xs{padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.btn-block{display:block;width:100%;padding-right:0;padding-left:0}.btn-block+.btn-block{margin-top:5px}input[type="submit"].btn-block,input[type="reset"].btn-block,input[type="button"].btn-block{width:100%}.fade{opacity:0;-webkit-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{display:none}.collapse.in{display:block}.collapsing{position:relative;height:0;overflow:hidden;-webkit-transition:height .35s ease;transition:height .35s ease}@font-face{font-family:'Glyphicons Halflings';src:url('../fonts/glyphicons-halflings-regular.eot');src:url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),url('../fonts/glyphicons-halflings-regular.woff') format('woff'),url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'),url('../fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg')}.glyphicon{position:relative;top:1px;display:inline-block;font-family:'Glyphicons Halflings';-webkit-font-smoothing:antialiased;font-style:normal;font-weight:normal;line-height:1;-moz-osx-font-smoothing:grayscale}.glyphicon:empty{width:1em}.glyphicon-asterisk:before{content:"\2a"}.glyphicon-plus:before{content:"\2b"}.glyphicon-euro:before{content:"\20ac"}.glyphicon-minus:before{content:"\2212"}.glyphicon-cloud:before{content:"\2601"}.glyphicon-envelope:before{content:"\2709"}.glyphicon-pencil:before{content:"\270f"}.glyphicon-glass:before{content:"\e001"}.glyphicon-music:before{content:"\e002"}.glyphicon-search:before{content:"\e003"}.glyphicon-heart:before{content:"\e005"}.glyphicon-star:before{content:"\e006"}.glyphicon-star-empty:before{content:"\e007"}.glyphicon-user:before{content:"\e008"}.glyphicon-film:before{content:"\e009"}.glyphicon-th-large:before{content:"\e010"}.glyphicon-th:before{content:"\e011"}.glyphicon-th-list:before{content:"\e012"}.glyphicon-ok:before{content:"\e013"}.glyphicon-remove:before{content:"\e014"}.glyphicon-zoom-in:before{content:"\e015"}.glyphicon-zoom-out:before{content:"\e016"}.glyphicon-off:before{content:"\e017"}.glyphicon-signal:before{content:"\e018"}.glyphicon-cog:before{content:"\e019"}.glyphicon-trash:before{content:"\e020"}.glyphicon-home:before{content:"\e021"}.glyphicon-file:before{content:"\e022"}.glyphicon-time:before{content:"\e023"}.glyphicon-road:before{content:"\e024"}.glyphicon-download-alt:before{content:"\e025"}.glyphicon-download:before{content:"\e026"}.glyphicon-upload:before{content:"\e027"}.glyphicon-inbox:before{content:"\e028"}.glyphicon-play-circle:before{content:"\e029"}.glyphicon-repeat:before{content:"\e030"}.glyphicon-refresh:before{content:"\e031"}.glyphicon-list-alt:before{content:"\e032"}.glyphicon-lock:before{content:"\e033"}.glyphicon-flag:before{content:"\e034"}.glyphicon-headphones:before{content:"\e035"}.glyphicon-volume-off:before{content:"\e036"}.glyphicon-volume-down:before{content:"\e037"}.glyphicon-volume-up:before{content:"\e038"}.glyphicon-qrcode:before{content:"\e039"}.glyphicon-barcode:before{content:"\e040"}.glyphicon-tag:before{content:"\e041"}.glyphicon-tags:before{content:"\e042"}.glyphicon-book:before{content:"\e043"}.glyphicon-bookmark:before{content:"\e044"}.glyphicon-print:before{content:"\e045"}.glyphicon-camera:before{content:"\e046"}.glyphicon-font:before{content:"\e047"}.glyphicon-bold:before{content:"\e048"}.glyphicon-italic:before{content:"\e049"}.glyphicon-text-height:before{content:"\e050"}.glyphicon-text-width:before{content:"\e051"}.glyphicon-align-left:before{content:"\e052"}.glyphicon-align-center:before{content:"\e053"}.glyphicon-align-right:before{content:"\e054"}.glyphicon-align-justify:before{content:"\e055"}.glyphicon-list:before{content:"\e056"}.glyphicon-indent-left:before{content:"\e057"}.glyphicon-indent-right:before{content:"\e058"}.glyphicon-facetime-video:before{content:"\e059"}.glyphicon-picture:before{content:"\e060"}.glyphicon-map-marker:before{content:"\e062"}.glyphicon-adjust:before{content:"\e063"}.glyphicon-tint:before{content:"\e064"}.glyphicon-edit:before{content:"\e065"}.glyphicon-share:before{content:"\e066"}.glyphicon-check:before{content:"\e067"}.glyphicon-move:before{content:"\e068"}.glyphicon-step-backward:before{content:"\e069"}.glyphicon-fast-backward:before{content:"\e070"}.glyphicon-backward:before{content:"\e071"}.glyphicon-play:before{content:"\e072"}.glyphicon-pause:before{content:"\e073"}.glyphicon-stop:before{content:"\e074"}.glyphicon-forward:before{content:"\e075"}.glyphicon-fast-forward:before{content:"\e076"}.glyphicon-step-forward:before{content:"\e077"}.glyphicon-eject:before{content:"\e078"}.glyphicon-chevron-left:before{content:"\e079"}.glyphicon-chevron-right:before{content:"\e080"}.glyphicon-plus-sign:before{content:"\e081"}.glyphicon-minus-sign:before{content:"\e082"}.glyphicon-remove-sign:before{content:"\e083"}.glyphicon-ok-sign:before{content:"\e084"}.glyphicon-question-sign:before{content:"\e085"}.glyphicon-info-sign:before{content:"\e086"}.glyphicon-screenshot:before{content:"\e087"}.glyphicon-remove-circle:before{content:"\e088"}.glyphicon-ok-circle:before{content:"\e089"}.glyphicon-ban-circle:before{content:"\e090"}.glyphicon-arrow-left:before{content:"\e091"}.glyphicon-arrow-right:before{content:"\e092"}.glyphicon-arrow-up:before{content:"\e093"}.glyphicon-arrow-down:before{content:"\e094"}.glyphicon-share-alt:before{content:"\e095"}.glyphicon-resize-full:before{content:"\e096"}.glyphicon-resize-small:before{content:"\e097"}.glyphicon-exclamation-sign:before{content:"\e101"}.glyphicon-gift:before{content:"\e102"}.glyphicon-leaf:before{content:"\e103"}.glyphicon-fire:before{content:"\e104"}.glyphicon-eye-open:before{content:"\e105"}.glyphicon-eye-close:before{content:"\e106"}.glyphicon-warning-sign:before{content:"\e107"}.glyphicon-plane:before{content:"\e108"}.glyphicon-calendar:before{content:"\e109"}.glyphicon-random:before{content:"\e110"}.glyphicon-comment:before{content:"\e111"}.glyphicon-magnet:before{content:"\e112"}.glyphicon-chevron-up:before{content:"\e113"}.glyphicon-chevron-down:before{content:"\e114"}.glyphicon-retweet:before{content:"\e115"}.glyphicon-shopping-cart:before{content:"\e116"}.glyphicon-folder-close:before{content:"\e117"}.glyphicon-folder-open:before{content:"\e118"}.glyphicon-resize-vertical:before{content:"\e119"}.glyphicon-resize-horizontal:before{content:"\e120"}.glyphicon-hdd:before{content:"\e121"}.glyphicon-bullhorn:before{content:"\e122"}.glyphicon-bell:before{content:"\e123"}.glyphicon-certificate:before{content:"\e124"}.glyphicon-thumbs-up:before{content:"\e125"}.glyphicon-thumbs-down:before{content:"\e126"}.glyphicon-hand-right:before{content:"\e127"}.glyphicon-hand-left:before{content:"\e128"}.glyphicon-hand-up:before{content:"\e129"}.glyphicon-hand-down:before{content:"\e130"}.glyphicon-circle-arrow-right:before{content:"\e131"}.glyphicon-circle-arrow-left:before{content:"\e132"}.glyphicon-circle-arrow-up:before{content:"\e133"}.glyphicon-circle-arrow-down:before{content:"\e134"}.glyphicon-globe:before{content:"\e135"}.glyphicon-wrench:before{content:"\e136"}.glyphicon-tasks:before{content:"\e137"}.glyphicon-filter:before{content:"\e138"}.glyphicon-briefcase:before{content:"\e139"}.glyphicon-fullscreen:before{content:"\e140"}.glyphicon-dashboard:before{content:"\e141"}.glyphicon-paperclip:before{content:"\e142"}.glyphicon-heart-empty:before{content:"\e143"}.glyphicon-link:before{content:"\e144"}.glyphicon-phone:before{content:"\e145"}.glyphicon-pushpin:before{content:"\e146"}.glyphicon-usd:before{content:"\e148"}.glyphicon-gbp:before{content:"\e149"}.glyphicon-sort:before{content:"\e150"}.glyphicon-sort-by-alphabet:before{content:"\e151"}.glyphicon-sort-by-alphabet-alt:before{content:"\e152"}.glyphicon-sort-by-order:before{content:"\e153"}.glyphicon-sort-by-order-alt:before{content:"\e154"}.glyphicon-sort-by-attributes:before{content:"\e155"}.glyphicon-sort-by-attributes-alt:before{content:"\e156"}.glyphicon-unchecked:before{content:"\e157"}.glyphicon-expand:before{content:"\e158"}.glyphicon-collapse-down:before{content:"\e159"}.glyphicon-collapse-up:before{content:"\e160"}.glyphicon-log-in:before{content:"\e161"}.glyphicon-flash:before{content:"\e162"}.glyphicon-log-out:before{content:"\e163"}.glyphicon-new-window:before{content:"\e164"}.glyphicon-record:before{content:"\e165"}.glyphicon-save:before{content:"\e166"}.glyphicon-open:before{content:"\e167"}.glyphicon-saved:before{content:"\e168"}.glyphicon-import:before{content:"\e169"}.glyphicon-export:before{content:"\e170"}.glyphicon-send:before{content:"\e171"}.glyphicon-floppy-disk:before{content:"\e172"}.glyphicon-floppy-saved:before{content:"\e173"}.glyphicon-floppy-remove:before{content:"\e174"}.glyphicon-floppy-save:before{content:"\e175"}.glyphicon-floppy-open:before{content:"\e176"}.glyphicon-credit-card:before{content:"\e177"}.glyphicon-transfer:before{content:"\e178"}.glyphicon-cutlery:before{content:"\e179"}.glyphicon-header:before{content:"\e180"}.glyphicon-compressed:before{content:"\e181"}.glyphicon-earphone:before{content:"\e182"}.glyphicon-phone-alt:before{content:"\e183"}.glyphicon-tower:before{content:"\e184"}.glyphicon-stats:before{content:"\e185"}.glyphicon-sd-video:before{content:"\e186"}.glyphicon-hd-video:before{content:"\e187"}.glyphicon-subtitles:before{content:"\e188"}.glyphicon-sound-stereo:before{content:"\e189"}.glyphicon-sound-dolby:before{content:"\e190"}.glyphicon-sound-5-1:before{content:"\e191"}.glyphicon-sound-6-1:before{content:"\e192"}.glyphicon-sound-7-1:before{content:"\e193"}.glyphicon-copyright-mark:before{content:"\e194"}.glyphicon-registration-mark:before{content:"\e195"}.glyphicon-cloud-download:before{content:"\e197"}.glyphicon-cloud-upload:before{content:"\e198"}.glyphicon-tree-conifer:before{content:"\e199"}.glyphicon-tree-deciduous:before{content:"\e200"}.caret{display:inline-block;width:0;height:0;margin-left:2px;vertical-align:middle;border-top:4px solid;border-right:4px solid transparent;border-left:4px solid transparent}.dropdown{position:relative}.dropdown-toggle:focus{outline:0}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;font-size:14px;list-style:none;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);border-radius:4px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.175);box-shadow:0 6px 12px rgba(0,0,0,0.175);background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:normal;line-height:1.428571429;color:#333;white-space:nowrap}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus{color:#262626;text-decoration:none;background-color:#f5f5f5}.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;background-color:#428bca;outline:0}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{color:#999}.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{text-decoration:none;cursor:not-allowed;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.open>.dropdown-menu{display:block}.open>a{outline:0}.dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.428571429;color:#999}.dropdown-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:990}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px solid;content:""}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:1px}@media(min-width:768px){.navbar-right .dropdown-menu{right:0;left:auto}}.btn-group,.btn-group-vertical{position:relative;display:inline-block;vertical-align:middle}.btn-group>.btn,.btn-group-vertical>.btn{position:relative;float:left}.btn-group>.btn:hover,.btn-group-vertical>.btn:hover,.btn-group>.btn:focus,.btn-group-vertical>.btn:focus,.btn-group>.btn:active,.btn-group-vertical>.btn:active,.btn-group>.btn.active,.btn-group-vertical>.btn.active{z-index:2}.btn-group>.btn:focus,.btn-group-vertical>.btn:focus{outline:0}.btn-group .btn+.btn,.btn-group .btn+.btn-group,.btn-group .btn-group+.btn,.btn-group .btn-group+.btn-group{margin-left:-1px}.btn-toolbar:before,.btn-toolbar:after{display:table;content:" "}.btn-toolbar:after{clear:both}.btn-toolbar:before,.btn-toolbar:after{display:table;content:" "}.btn-toolbar:after{clear:both}.btn-toolbar .btn-group{float:left}.btn-toolbar>.btn+.btn,.btn-toolbar>.btn-group+.btn,.btn-toolbar>.btn+.btn-group,.btn-toolbar>.btn-group+.btn-group{margin-left:5px}.btn-group>.btn:not(:first-child):not(:last-child):not(.dropdown-toggle){border-radius:0}.btn-group>.btn:first-child{margin-left:0}.btn-group>.btn:first-child:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn:last-child:not(:first-child),.btn-group>.dropdown-toggle:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.btn-group>.btn-group{float:left}.btn-group>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group>.btn-group:first-child>.btn:last-child,.btn-group>.btn-group:first-child>.dropdown-toggle{border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn-group:last-child>.btn:first-child{border-bottom-left-radius:0;border-top-left-radius:0}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn-group-xs>.btn{padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.btn-group-sm>.btn{padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.btn-group-lg>.btn{padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}.btn-group>.btn+.dropdown-toggle{padding-right:8px;padding-left:8px}.btn-group>.btn-lg+.dropdown-toggle{padding-right:12px;padding-left:12px}.btn-group.open .dropdown-toggle{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}.btn-group.open .dropdown-toggle.btn-link{-webkit-box-shadow:none;box-shadow:none}.btn .caret{margin-left:0}.btn-lg .caret{border-width:5px 5px 0;border-bottom-width:0}.dropup .btn-lg .caret{border-width:0 5px 5px}.btn-group-vertical>.btn,.btn-group-vertical>.btn-group,.btn-group-vertical>.btn-group>.btn{display:block;float:none;width:100%;max-width:100%}.btn-group-vertical>.btn-group:before,.btn-group-vertical>.btn-group:after{display:table;content:" "}.btn-group-vertical>.btn-group:after{clear:both}.btn-group-vertical>.btn-group:before,.btn-group-vertical>.btn-group:after{display:table;content:" "}.btn-group-vertical>.btn-group:after{clear:both}.btn-group-vertical>.btn-group>.btn{float:none}.btn-group-vertical>.btn+.btn,.btn-group-vertical>.btn+.btn-group,.btn-group-vertical>.btn-group+.btn,.btn-group-vertical>.btn-group+.btn-group{margin-top:-1px;margin-left:0}.btn-group-vertical>.btn:not(:first-child):not(:last-child){border-radius:0}.btn-group-vertical>.btn:first-child:not(:last-child){border-top-right-radius:4px;border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn:last-child:not(:first-child){border-top-right-radius:0;border-bottom-left-radius:4px;border-top-left-radius:0}.btn-group-vertical>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group-vertical>.btn-group:first-child>.btn:last-child,.btn-group-vertical>.btn-group:first-child>.dropdown-toggle{border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn-group:last-child>.btn:first-child{border-top-right-radius:0;border-top-left-radius:0}.btn-group-justified{display:table;width:100%;border-collapse:separate;table-layout:fixed}.btn-group-justified>.btn,.btn-group-justified>.btn-group{display:table-cell;float:none;width:1%}.btn-group-justified>.btn-group .btn{width:100%}[data-toggle="buttons"]>.btn>input[type="radio"],[data-toggle="buttons"]>.btn>input[type="checkbox"]{display:none}.input-group{position:relative;display:table;border-collapse:separate}.input-group[class*="col-"]{float:none;padding-right:0;padding-left:0}.input-group .form-control{width:100%;margin-bottom:0}.input-group-lg>.form-control,.input-group-lg>.input-group-addon,.input-group-lg>.input-group-btn>.btn{height:46px;padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}select.input-group-lg>.form-control,select.input-group-lg>.input-group-addon,select.input-group-lg>.input-group-btn>.btn{height:46px;line-height:46px}textarea.input-group-lg>.form-control,textarea.input-group-lg>.input-group-addon,textarea.input-group-lg>.input-group-btn>.btn{height:auto}.input-group-sm>.form-control,.input-group-sm>.input-group-addon,.input-group-sm>.input-group-btn>.btn{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.input-group-sm>.form-control,select.input-group-sm>.input-group-addon,select.input-group-sm>.input-group-btn>.btn{height:30px;line-height:30px}textarea.input-group-sm>.form-control,textarea.input-group-sm>.input-group-addon,textarea.input-group-sm>.input-group-btn>.btn{height:auto}.input-group-addon,.input-group-btn,.input-group .form-control{display:table-cell}.input-group-addon:not(:first-child):not(:last-child),.input-group-btn:not(:first-child):not(:last-child),.input-group .form-control:not(:first-child):not(:last-child){border-radius:0}.input-group-addon,.input-group-btn{width:1%;white-space:nowrap;vertical-align:middle}.input-group-addon{padding:6px 12px;font-size:14px;font-weight:normal;line-height:1;color:#555;text-align:center;background-color:#eee;border:1px solid #ccc;border-radius:4px}.input-group-addon.input-sm{padding:5px 10px;font-size:12px;border-radius:3px}.input-group-addon.input-lg{padding:10px 16px;font-size:18px;border-radius:6px}.input-group-addon input[type="radio"],.input-group-addon input[type="checkbox"]{margin-top:0}.input-group .form-control:first-child,.input-group-addon:first-child,.input-group-btn:first-child>.btn,.input-group-btn:first-child>.dropdown-toggle,.input-group-btn:last-child>.btn:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.input-group-addon:first-child{border-right:0}.input-group .form-control:last-child,.input-group-addon:last-child,.input-group-btn:last-child>.btn,.input-group-btn:last-child>.dropdown-toggle,.input-group-btn:first-child>.btn:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.input-group-addon:last-child{border-left:0}.input-group-btn{position:relative;white-space:nowrap}.input-group-btn:first-child>.btn{margin-right:-1px}.input-group-btn:last-child>.btn{margin-left:-1px}.input-group-btn>.btn{position:relative}.input-group-btn>.btn+.btn{margin-left:-4px}.input-group-btn>.btn:hover,.input-group-btn>.btn:active{z-index:2}.nav{padding-left:0;margin-bottom:0;list-style:none}.nav:before,.nav:after{display:table;content:" "}.nav:after{clear:both}.nav:before,.nav:after{display:table;content:" "}.nav:after{clear:both}.nav>li{position:relative;display:block}.nav>li>a{position:relative;display:block;padding:10px 15px}.nav>li>a:hover,.nav>li>a:focus{text-decoration:none;background-color:#eee}.nav>li.disabled>a{color:#999}.nav>li.disabled>a:hover,.nav>li.disabled>a:focus{color:#999;text-decoration:none;cursor:not-allowed;background-color:transparent}.nav .open>a,.nav .open>a:hover,.nav .open>a:focus{background-color:#eee;border-color:#428bca}.nav .nav-divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.nav>li>a>img{max-width:none}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs>li{float:left;margin-bottom:-1px}.nav-tabs>li>a{margin-right:2px;line-height:1.428571429;border:1px solid transparent;border-radius:4px 4px 0 0}.nav-tabs>li>a:hover{border-color:#eee #eee #ddd}.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active>a:focus{color:#555;cursor:default;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent}.nav-tabs.nav-justified{width:100%;border-bottom:0}.nav-tabs.nav-justified>li{float:none}.nav-tabs.nav-justified>li>a{margin-bottom:5px;text-align:center}.nav-tabs.nav-justified>.dropdown .dropdown-menu{top:auto;left:auto}@media(min-width:768px){.nav-tabs.nav-justified>li{display:table-cell;width:1%}.nav-tabs.nav-justified>li>a{margin-bottom:0}}.nav-tabs.nav-justified>li>a{margin-right:0;border-radius:4px}.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:hover,.nav-tabs.nav-justified>.active>a:focus{border:1px solid #ddd}@media(min-width:768px){.nav-tabs.nav-justified>li>a{border-bottom:1px solid #ddd;border-radius:4px 4px 0 0}.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:hover,.nav-tabs.nav-justified>.active>a:focus{border-bottom-color:#fff}}.nav-pills>li{float:left}.nav-pills>li>a{border-radius:4px}.nav-pills>li+li{margin-left:2px}.nav-pills>li.active>a,.nav-pills>li.active>a:hover,.nav-pills>li.active>a:focus{color:#fff;background-color:#428bca}.nav-stacked>li{float:none}.nav-stacked>li+li{margin-top:2px;margin-left:0}.nav-justified{width:100%}.nav-justified>li{float:none}.nav-justified>li>a{margin-bottom:5px;text-align:center}.nav-justified>.dropdown .dropdown-menu{top:auto;left:auto}@media(min-width:768px){.nav-justified>li{display:table-cell;width:1%}.nav-justified>li>a{margin-bottom:0}}.nav-tabs-justified{border-bottom:0}.nav-tabs-justified>li>a{margin-right:0;border-radius:4px}.nav-tabs-justified>.active>a,.nav-tabs-justified>.active>a:hover,.nav-tabs-justified>.active>a:focus{border:1px solid #ddd}@media(min-width:768px){.nav-tabs-justified>li>a{border-bottom:1px solid #ddd;border-radius:4px 4px 0 0}.nav-tabs-justified>.active>a,.nav-tabs-justified>.active>a:hover,.nav-tabs-justified>.active>a:focus{border-bottom-color:#fff}}.tab-content>.tab-pane{display:none}.tab-content>.active{display:block}.nav-tabs .dropdown-menu{margin-top:-1px;border-top-right-radius:0;border-top-left-radius:0}.navbar{position:relative;min-height:50px;margin-bottom:20px;border:1px solid transparent}.navbar:before,.navbar:after{display:table;content:" "}.navbar:after{clear:both}.navbar:before,.navbar:after{display:table;content:" "}.navbar:after{clear:both}@media(min-width:768px){.navbar{border-radius:4px}}.navbar-header:before,.navbar-header:after{display:table;content:" "}.navbar-header:after{clear:both}.navbar-header:before,.navbar-header:after{display:table;content:" "}.navbar-header:after{clear:both}@media(min-width:768px){.navbar-header{float:left}}.navbar-collapse{max-height:340px;padding-right:15px;padding-left:15px;overflow-x:visible;border-top:1px solid transparent;box-shadow:inset 0 1px 0 rgba(255,255,255,0.1);-webkit-overflow-scrolling:touch}.navbar-collapse:before,.navbar-collapse:after{display:table;content:" "}.navbar-collapse:after{clear:both}.navbar-collapse:before,.navbar-collapse:after{display:table;content:" "}.navbar-collapse:after{clear:both}.navbar-collapse.in{overflow-y:auto}@media(min-width:768px){.navbar-collapse{width:auto;border-top:0;box-shadow:none}.navbar-collapse.collapse{display:block!important;height:auto!important;padding-bottom:0;overflow:visible!important}.navbar-collapse.in{overflow-y:visible}.navbar-fixed-top .navbar-collapse,.navbar-static-top .navbar-collapse,.navbar-fixed-bottom .navbar-collapse{padding-right:0;padding-left:0}}.container>.navbar-header,.container>.navbar-collapse{margin-right:-15px;margin-left:-15px}@media(min-width:768px){.container>.navbar-header,.container>.navbar-collapse{margin-right:0;margin-left:0}}.navbar-static-top{z-index:1000;border-width:0 0 1px}@media(min-width:768px){.navbar-static-top{border-radius:0}}.navbar-fixed-top,.navbar-fixed-bottom{position:fixed;right:0;left:0;z-index:1030}@media(min-width:768px){.navbar-fixed-top,.navbar-fixed-bottom{border-radius:0}}.navbar-fixed-top{top:0;border-width:0 0 1px}.navbar-fixed-bottom{bottom:0;margin-bottom:0;border-width:1px 0 0}.navbar-brand{float:left;padding:15px 15px;font-size:18px;line-height:20px}.navbar-brand:hover,.navbar-brand:focus{text-decoration:none}@media(min-width:768px){.navbar>.container .navbar-brand{margin-left:-15px}}.navbar-toggle{position:relative;float:right;padding:9px 10px;margin-top:8px;margin-right:15px;margin-bottom:8px;background-color:transparent;background-image:none;border:1px solid transparent;border-radius:4px}.navbar-toggle .icon-bar{display:block;width:22px;height:2px;border-radius:1px}.navbar-toggle .icon-bar+.icon-bar{margin-top:4px}@media(min-width:768px){.navbar-toggle{display:none}}.navbar-nav{margin:7.5px -15px}.navbar-nav>li>a{padding-top:10px;padding-bottom:10px;line-height:20px}@media(max-width:767px){.navbar-nav .open .dropdown-menu{position:static;float:none;width:auto;margin-top:0;background-color:transparent;border:0;box-shadow:none}.navbar-nav .open .dropdown-menu>li>a,.navbar-nav .open .dropdown-menu .dropdown-header{padding:5px 15px 5px 25px}.navbar-nav .open .dropdown-menu>li>a{line-height:20px}.navbar-nav .open .dropdown-menu>li>a:hover,.navbar-nav .open .dropdown-menu>li>a:focus{background-image:none}}@media(min-width:768px){.navbar-nav{float:left;margin:0}.navbar-nav>li{float:left}.navbar-nav>li>a{padding-top:15px;padding-bottom:15px}.navbar-nav.navbar-right:last-child{margin-right:-15px}}@media(min-width:768px){.navbar-left{float:left!important}.navbar-right{float:right!important}}.navbar-form{padding:10px 15px;margin-top:8px;margin-right:-15px;margin-bottom:8px;margin-left:-15px;border-top:1px solid transparent;border-bottom:1px solid transparent;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1)}@media(min-width:768px){.navbar-form .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.navbar-form .form-control{display:inline-block}.navbar-form select.form-control{width:auto}.navbar-form .radio,.navbar-form .checkbox{display:inline-block;padding-left:0;margin-top:0;margin-bottom:0}.navbar-form .radio input[type="radio"],.navbar-form .checkbox input[type="checkbox"]{float:none;margin-left:0}}@media(max-width:767px){.navbar-form .form-group{margin-bottom:5px}}@media(min-width:768px){.navbar-form{width:auto;padding-top:0;padding-bottom:0;margin-right:0;margin-left:0;border:0;-webkit-box-shadow:none;box-shadow:none}.navbar-form.navbar-right:last-child{margin-right:-15px}}.navbar-nav>li>.dropdown-menu{margin-top:0;border-top-right-radius:0;border-top-left-radius:0}.navbar-fixed-bottom .navbar-nav>li>.dropdown-menu{border-bottom-right-radius:0;border-bottom-left-radius:0}.navbar-nav.pull-right>li>.dropdown-menu,.navbar-nav>li>.dropdown-menu.pull-right{right:0;left:auto}.navbar-btn{margin-top:8px;margin-bottom:8px}.navbar-btn.btn-sm{margin-top:10px;margin-bottom:10px}.navbar-btn.btn-xs{margin-top:14px;margin-bottom:14px}.navbar-text{margin-top:15px;margin-bottom:15px}@media(min-width:768px){.navbar-text{float:left;margin-right:15px;margin-left:15px}.navbar-text.navbar-right:last-child{margin-right:0}}.navbar-default{background-color:#f8f8f8;border-color:#e7e7e7}.navbar-default .navbar-brand{color:#777}.navbar-default .navbar-brand:hover,.navbar-default .navbar-brand:focus{color:#5e5e5e;background-color:transparent}.navbar-default .navbar-text{color:#777}.navbar-default .navbar-nav>li>a{color:#777}.navbar-default .navbar-nav>li>a:hover,.navbar-default .navbar-nav>li>a:focus{color:#333;background-color:transparent}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:hover,.navbar-default .navbar-nav>.active>a:focus{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav>.disabled>a,.navbar-default .navbar-nav>.disabled>a:hover,.navbar-default .navbar-nav>.disabled>a:focus{color:#ccc;background-color:transparent}.navbar-default .navbar-toggle{border-color:#ddd}.navbar-default .navbar-toggle:hover,.navbar-default .navbar-toggle:focus{background-color:#ddd}.navbar-default .navbar-toggle .icon-bar{background-color:#ccc}.navbar-default .navbar-collapse,.navbar-default .navbar-form{border-color:#e7e7e7}.navbar-default .navbar-nav>.open>a,.navbar-default .navbar-nav>.open>a:hover,.navbar-default .navbar-nav>.open>a:focus{color:#555;background-color:#e7e7e7}@media(max-width:767px){.navbar-default .navbar-nav .open .dropdown-menu>li>a{color:#777}.navbar-default .navbar-nav .open .dropdown-menu>li>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>li>a:focus{color:#333;background-color:transparent}.navbar-default .navbar-nav .open .dropdown-menu>.active>a,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:focus{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:focus{color:#ccc;background-color:transparent}}.navbar-default .navbar-link{color:#777}.navbar-default .navbar-link:hover{color:#333}.navbar-inverse{background-color:#222;border-color:#080808}.navbar-inverse .navbar-brand{color:#999}.navbar-inverse .navbar-brand:hover,.navbar-inverse .navbar-brand:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-text{color:#999}.navbar-inverse .navbar-nav>li>a{color:#999}.navbar-inverse .navbar-nav>li>a:hover,.navbar-inverse .navbar-nav>li>a:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav>.active>a,.navbar-inverse .navbar-nav>.active>a:hover,.navbar-inverse .navbar-nav>.active>a:focus{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav>.disabled>a,.navbar-inverse .navbar-nav>.disabled>a:hover,.navbar-inverse .navbar-nav>.disabled>a:focus{color:#444;background-color:transparent}.navbar-inverse .navbar-toggle{border-color:#333}.navbar-inverse .navbar-toggle:hover,.navbar-inverse .navbar-toggle:focus{background-color:#333}.navbar-inverse .navbar-toggle .icon-bar{background-color:#fff}.navbar-inverse .navbar-collapse,.navbar-inverse .navbar-form{border-color:#101010}.navbar-inverse .navbar-nav>.open>a,.navbar-inverse .navbar-nav>.open>a:hover,.navbar-inverse .navbar-nav>.open>a:focus{color:#fff;background-color:#080808}@media(max-width:767px){.navbar-inverse .navbar-nav .open .dropdown-menu>.dropdown-header{border-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu .divider{background-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a{color:#999}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:focus{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:focus{color:#444;background-color:transparent}}.navbar-inverse .navbar-link{color:#999}.navbar-inverse .navbar-link:hover{color:#fff}.breadcrumb{padding:8px 15px;margin-bottom:20px;list-style:none;background-color:#f5f5f5;border-radius:4px}.breadcrumb>li{display:inline-block}.breadcrumb>li+li:before{padding:0 5px;color:#ccc;content:"/\00a0"}.breadcrumb>.active{color:#999}.pagination{display:inline-block;padding-left:0;margin:20px 0;border-radius:4px}.pagination>li{display:inline}.pagination>li>a,.pagination>li>span{position:relative;float:left;padding:6px 12px;margin-left:-1px;line-height:1.428571429;text-decoration:none;background-color:#fff;border:1px solid #ddd}.pagination>li:first-child>a,.pagination>li:first-child>span{margin-left:0;border-bottom-left-radius:4px;border-top-left-radius:4px}.pagination>li:last-child>a,.pagination>li:last-child>span{border-top-right-radius:4px;border-bottom-right-radius:4px}.pagination>li>a:hover,.pagination>li>span:hover,.pagination>li>a:focus,.pagination>li>span:focus{background-color:#eee}.pagination>.active>a,.pagination>.active>span,.pagination>.active>a:hover,.pagination>.active>span:hover,.pagination>.active>a:focus,.pagination>.active>span:focus{z-index:2;color:#fff;cursor:default;background-color:#428bca;border-color:#428bca}.pagination>.disabled>span,.pagination>.disabled>span:hover,.pagination>.disabled>span:focus,.pagination>.disabled>a,.pagination>.disabled>a:hover,.pagination>.disabled>a:focus{color:#999;cursor:not-allowed;background-color:#fff;border-color:#ddd}.pagination-lg>li>a,.pagination-lg>li>span{padding:10px 16px;font-size:18px}.pagination-lg>li:first-child>a,.pagination-lg>li:first-child>span{border-bottom-left-radius:6px;border-top-left-radius:6px}.pagination-lg>li:last-child>a,.pagination-lg>li:last-child>span{border-top-right-radius:6px;border-bottom-right-radius:6px}.pagination-sm>li>a,.pagination-sm>li>span{padding:5px 10px;font-size:12px}.pagination-sm>li:first-child>a,.pagination-sm>li:first-child>span{border-bottom-left-radius:3px;border-top-left-radius:3px}.pagination-sm>li:last-child>a,.pagination-sm>li:last-child>span{border-top-right-radius:3px;border-bottom-right-radius:3px}.pager{padding-left:0;margin:20px 0;text-align:center;list-style:none}.pager:before,.pager:after{display:table;content:" "}.pager:after{clear:both}.pager:before,.pager:after{display:table;content:" "}.pager:after{clear:both}.pager li{display:inline}.pager li>a,.pager li>span{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;border-radius:15px}.pager li>a:hover,.pager li>a:focus{text-decoration:none;background-color:#eee}.pager .next>a,.pager .next>span{float:right}.pager .previous>a,.pager .previous>span{float:left}.pager .disabled>a,.pager .disabled>a:hover,.pager .disabled>a:focus,.pager .disabled>span{color:#999;cursor:not-allowed;background-color:#fff}.label{display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:bold;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em}.label[href]:hover,.label[href]:focus{color:#fff;text-decoration:none;cursor:pointer}.label:empty{display:none}.btn .label{position:relative;top:-1px}.label-default{background-color:#999}.label-default[href]:hover,.label-default[href]:focus{background-color:#808080}.label-primary{background-color:#428bca}.label-primary[href]:hover,.label-primary[href]:focus{background-color:#3071a9}.label-success{background-color:#5cb85c}.label-success[href]:hover,.label-success[href]:focus{background-color:#449d44}.label-info{background-color:#5bc0de}.label-info[href]:hover,.label-info[href]:focus{background-color:#31b0d5}.label-warning{background-color:#f0ad4e}.label-warning[href]:hover,.label-warning[href]:focus{background-color:#ec971f}.label-danger{background-color:#d9534f}.label-danger[href]:hover,.label-danger[href]:focus{background-color:#c9302c}.badge{display:inline-block;min-width:10px;padding:3px 7px;font-size:12px;font-weight:bold;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;background-color:#999;border-radius:10px}.badge:empty{display:none}.btn .badge{position:relative;top:-1px}a.badge:hover,a.badge:focus{color:#fff;text-decoration:none;cursor:pointer}a.list-group-item.active>.badge,.nav-pills>.active>a>.badge{color:#428bca;background-color:#fff}.nav-pills>li>a>.badge{margin-left:3px}.jumbotron{padding:30px;margin-bottom:30px;font-size:21px;font-weight:200;line-height:2.1428571435;color:inherit;background-color:#eee}.jumbotron h1,.jumbotron .h1{line-height:1;color:inherit}.jumbotron p{line-height:1.4}.container .jumbotron{border-radius:6px}.jumbotron .container{max-width:100%}@media screen and (min-width:768px){.jumbotron{padding-top:48px;padding-bottom:48px}.container .jumbotron{padding-right:60px;padding-left:60px}.jumbotron h1,.jumbotron .h1{font-size:63px}}.thumbnail{display:block;padding:4px;margin-bottom:20px;line-height:1.428571429;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.thumbnail>img,.thumbnail a>img{display:block;height:auto;max-width:100%;margin-right:auto;margin-left:auto}a.thumbnail:hover,a.thumbnail:focus,a.thumbnail.active{border-color:#428bca}.thumbnail .caption{padding:9px;color:#333}.alert{padding:15px;margin-bottom:20px;border:1px solid transparent;border-radius:4px}.alert h4{margin-top:0;color:inherit}.alert .alert-link{font-weight:bold}.alert>p,.alert>ul{margin-bottom:0}.alert>p+p{margin-top:5px}.alert-dismissable{padding-right:35px}.alert-dismissable .close{position:relative;top:-2px;right:-21px;color:inherit}.alert-success{color:#3c763d;background-color:#dff0d8;border-color:#d6e9c6}.alert-success hr{border-top-color:#c9e2b3}.alert-success .alert-link{color:#2b542c}.alert-info{color:#31708f;background-color:#d9edf7;border-color:#bce8f1}.alert-info hr{border-top-color:#a6e1ec}.alert-info .alert-link{color:#245269}.alert-warning{color:#8a6d3b;background-color:#fcf8e3;border-color:#faebcc}.alert-warning hr{border-top-color:#f7e1b5}.alert-warning .alert-link{color:#66512c}.alert-danger{color:#a94442;background-color:#f2dede;border-color:#ebccd1}.alert-danger hr{border-top-color:#e4b9c0}.alert-danger .alert-link{color:#843534}@-webkit-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}.progress{height:20px;margin-bottom:20px;overflow:hidden;background-color:#f5f5f5;border-radius:4px;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1)}.progress-bar{float:left;width:0;height:100%;font-size:12px;line-height:20px;color:#fff;text-align:center;background-color:#428bca;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-transition:width .6s ease;transition:width .6s ease}.progress-striped .progress-bar{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-size:40px 40px}.progress.active .progress-bar{-webkit-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-bar-success{background-color:#5cb85c}.progress-striped .progress-bar-success{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-bar-info{background-color:#5bc0de}.progress-striped .progress-bar-info{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-bar-warning{background-color:#f0ad4e}.progress-striped .progress-bar-warning{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-bar-danger{background-color:#d9534f}.progress-striped .progress-bar-danger{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.media,.media-body{overflow:hidden;zoom:1}.media,.media .media{margin-top:15px}.media:first-child{margin-top:0}.media-object{display:block}.media-heading{margin:0 0 5px}.media>.pull-left{margin-right:10px}.media>.pull-right{margin-left:10px}.media-list{padding-left:0;list-style:none}.list-group{padding-left:0;margin-bottom:20px}.list-group-item{position:relative;display:block;padding:10px 15px;margin-bottom:-1px;background-color:#fff;border:1px solid #ddd}.list-group-item:first-child{border-top-right-radius:4px;border-top-left-radius:4px}.list-group-item:last-child{margin-bottom:0;border-bottom-right-radius:4px;border-bottom-left-radius:4px}.list-group-item>.badge{float:right}.list-group-item>.badge+.badge{margin-right:5px}a.list-group-item{color:#555}a.list-group-item .list-group-item-heading{color:#333}a.list-group-item:hover,a.list-group-item:focus{text-decoration:none;background-color:#f5f5f5}a.list-group-item.active,a.list-group-item.active:hover,a.list-group-item.active:focus{z-index:2;color:#fff;background-color:#428bca;border-color:#428bca}a.list-group-item.active .list-group-item-heading,a.list-group-item.active:hover .list-group-item-heading,a.list-group-item.active:focus .list-group-item-heading{color:inherit}a.list-group-item.active .list-group-item-text,a.list-group-item.active:hover .list-group-item-text,a.list-group-item.active:focus .list-group-item-text{color:#e1edf7}.list-group-item-heading{margin-top:0;margin-bottom:5px}.list-group-item-text{margin-bottom:0;line-height:1.3}.panel{margin-bottom:20px;background-color:#fff;border:1px solid transparent;border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.05);box-shadow:0 1px 1px rgba(0,0,0,0.05)}.panel-body{padding:15px}.panel-body:before,.panel-body:after{display:table;content:" "}.panel-body:after{clear:both}.panel-body:before,.panel-body:after{display:table;content:" "}.panel-body:after{clear:both}.panel>.list-group{margin-bottom:0}.panel>.list-group .list-group-item{border-width:1px 0}.panel>.list-group .list-group-item:first-child{border-top-right-radius:0;border-top-left-radius:0}.panel>.list-group .list-group-item:last-child{border-bottom:0}.panel-heading+.list-group .list-group-item:first-child{border-top-width:0}.panel>.table,.panel>.table-responsive>.table{margin-bottom:0}.panel>.panel-body+.table,.panel>.panel-body+.table-responsive{border-top:1px solid #ddd}.panel>.table>tbody:first-child th,.panel>.table>tbody:first-child td{border-top:0}.panel>.table-bordered,.panel>.table-responsive>.table-bordered{border:0}.panel>.table-bordered>thead>tr>th:first-child,.panel>.table-responsive>.table-bordered>thead>tr>th:first-child,.panel>.table-bordered>tbody>tr>th:first-child,.panel>.table-responsive>.table-bordered>tbody>tr>th:first-child,.panel>.table-bordered>tfoot>tr>th:first-child,.panel>.table-responsive>.table-bordered>tfoot>tr>th:first-child,.panel>.table-bordered>thead>tr>td:first-child,.panel>.table-responsive>.table-bordered>thead>tr>td:first-child,.panel>.table-bordered>tbody>tr>td:first-child,.panel>.table-responsive>.table-bordered>tbody>tr>td:first-child,.panel>.table-bordered>tfoot>tr>td:first-child,.panel>.table-responsive>.table-bordered>tfoot>tr>td:first-child{border-left:0}.panel>.table-bordered>thead>tr>th:last-child,.panel>.table-responsive>.table-bordered>thead>tr>th:last-child,.panel>.table-bordered>tbody>tr>th:last-child,.panel>.table-responsive>.table-bordered>tbody>tr>th:last-child,.panel>.table-bordered>tfoot>tr>th:last-child,.panel>.table-responsive>.table-bordered>tfoot>tr>th:last-child,.panel>.table-bordered>thead>tr>td:last-child,.panel>.table-responsive>.table-bordered>thead>tr>td:last-child,.panel>.table-bordered>tbody>tr>td:last-child,.panel>.table-responsive>.table-bordered>tbody>tr>td:last-child,.panel>.table-bordered>tfoot>tr>td:last-child,.panel>.table-responsive>.table-bordered>tfoot>tr>td:last-child{border-right:0}.panel>.table-bordered>thead>tr:last-child>th,.panel>.table-responsive>.table-bordered>thead>tr:last-child>th,.panel>.table-bordered>tbody>tr:last-child>th,.panel>.table-responsive>.table-bordered>tbody>tr:last-child>th,.panel>.table-bordered>tfoot>tr:last-child>th,.panel>.table-responsive>.table-bordered>tfoot>tr:last-child>th,.panel>.table-bordered>thead>tr:last-child>td,.panel>.table-responsive>.table-bordered>thead>tr:last-child>td,.panel>.table-bordered>tbody>tr:last-child>td,.panel>.table-responsive>.table-bordered>tbody>tr:last-child>td,.panel>.table-bordered>tfoot>tr:last-child>td,.panel>.table-responsive>.table-bordered>tfoot>tr:last-child>td{border-bottom:0}.panel>.table-responsive{margin-bottom:0;border:0}.panel-heading{padding:10px 15px;border-bottom:1px solid transparent;border-top-right-radius:3px;border-top-left-radius:3px}.panel-heading>.dropdown .dropdown-toggle{color:inherit}.panel-title{margin-top:0;margin-bottom:0;font-size:16px;color:inherit}.panel-title>a{color:inherit}.panel-footer{padding:10px 15px;background-color:#f5f5f5;border-top:1px solid #ddd;border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel-group .panel{margin-bottom:0;overflow:hidden;border-radius:4px}.panel-group .panel+.panel{margin-top:5px}.panel-group .panel-heading{border-bottom:0}.panel-group .panel-heading+.panel-collapse .panel-body{border-top:1px solid #ddd}.panel-group .panel-footer{border-top:0}.panel-group .panel-footer+.panel-collapse .panel-body{border-bottom:1px solid #ddd}.panel-default{border-color:#ddd}.panel-default>.panel-heading{color:#333;background-color:#f5f5f5;border-color:#ddd}.panel-default>.panel-heading+.panel-collapse .panel-body{border-top-color:#ddd}.panel-default>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#ddd}.panel-primary{border-color:#428bca}.panel-primary>.panel-heading{color:#fff;background-color:#428bca;border-color:#428bca}.panel-primary>.panel-heading+.panel-collapse .panel-body{border-top-color:#428bca}.panel-primary>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#428bca}.panel-success{border-color:#d6e9c6}.panel-success>.panel-heading{color:#3c763d;background-color:#dff0d8;border-color:#d6e9c6}.panel-success>.panel-heading+.panel-collapse .panel-body{border-top-color:#d6e9c6}.panel-success>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#d6e9c6}.panel-warning{border-color:#faebcc}.panel-warning>.panel-heading{color:#8a6d3b;background-color:#fcf8e3;border-color:#faebcc}.panel-warning>.panel-heading+.panel-collapse .panel-body{border-top-color:#faebcc}.panel-warning>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#faebcc}.panel-danger{border-color:#ebccd1}.panel-danger>.panel-heading{color:#a94442;background-color:#f2dede;border-color:#ebccd1}.panel-danger>.panel-heading+.panel-collapse .panel-body{border-top-color:#ebccd1}.panel-danger>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#ebccd1}.panel-info{border-color:#bce8f1}.panel-info>.panel-heading{color:#31708f;background-color:#d9edf7;border-color:#bce8f1}.panel-info>.panel-heading+.panel-collapse .panel-body{border-top-color:#bce8f1}.panel-info>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#bce8f1}.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #e3e3e3;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);box-shadow:inset 0 1px 1px rgba(0,0,0,0.05)}.well blockquote{border-color:#ddd;border-color:rgba(0,0,0,0.15)}.well-lg{padding:24px;border-radius:6px}.well-sm{padding:9px;border-radius:3px}.close{float:right;font-size:21px;font-weight:bold;line-height:1;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.close:hover,.close:focus{color:#000;text-decoration:none;cursor:pointer;opacity:.5;filter:alpha(opacity=50)}button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.modal-open{overflow:hidden}.modal{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;display:none;overflow:auto;overflow-y:scroll}.modal.fade .modal-dialog{-webkit-transform:translate(0,-25%);-ms-transform:translate(0,-25%);transform:translate(0,-25%);-webkit-transition:-webkit-transform .3s ease-out;-moz-transition:-moz-transform .3s ease-out;-o-transition:-o-transform .3s ease-out;transition:transform .3s ease-out}.modal.in .modal-dialog{-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0)}.modal-dialog{position:relative;z-index:1050;width:auto;margin:10px}.modal-content{position:relative;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,0.2);border-radius:6px;outline:0;-webkit-box-shadow:0 3px 9px rgba(0,0,0,0.5);box-shadow:0 3px 9px rgba(0,0,0,0.5);background-clip:padding-box}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1030;background-color:#000}.modal-backdrop.fade{opacity:0;filter:alpha(opacity=0)}.modal-backdrop.in{opacity:.5;filter:alpha(opacity=50)}.modal-header{min-height:16.428571429px;padding:15px;border-bottom:1px solid #e5e5e5}.modal-header .close{margin-top:-2px}.modal-title{margin:0;line-height:1.428571429}.modal-body{position:relative;padding:20px}.modal-footer{padding:19px 20px 20px;margin-top:15px;text-align:right;border-top:1px solid #e5e5e5}.modal-footer:before,.modal-footer:after{display:table;content:" "}.modal-footer:after{clear:both}.modal-footer:before,.modal-footer:after{display:table;content:" "}.modal-footer:after{clear:both}.modal-footer .btn+.btn{margin-bottom:0;margin-left:5px}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.modal-footer .btn-block+.btn-block{margin-left:0}@media screen and (min-width:768px){.modal-dialog{width:600px;margin:30px auto}.modal-content{-webkit-box-shadow:0 5px 15px rgba(0,0,0,0.5);box-shadow:0 5px 15px rgba(0,0,0,0.5)}}.tooltip{position:absolute;z-index:1030;display:block;font-size:12px;line-height:1.4;opacity:0;filter:alpha(opacity=0);visibility:visible}.tooltip.in{opacity:.9;filter:alpha(opacity=90)}.tooltip.top{padding:5px 0;margin-top:-3px}.tooltip.right{padding:0 5px;margin-left:3px}.tooltip.bottom{padding:5px 0;margin-top:3px}.tooltip.left{padding:0 5px;margin-left:-3px}.tooltip-inner{max-width:200px;padding:3px 8px;color:#fff;text-align:center;text-decoration:none;background-color:#000;border-radius:4px}.tooltip-arrow{position:absolute;width:0;height:0;border-color:transparent;border-style:solid}.tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-top-color:#000;border-width:5px 5px 0}.tooltip.top-left .tooltip-arrow{bottom:0;left:5px;border-top-color:#000;border-width:5px 5px 0}.tooltip.top-right .tooltip-arrow{right:5px;bottom:0;border-top-color:#000;border-width:5px 5px 0}.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-right-color:#000;border-width:5px 5px 5px 0}.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-left-color:#000;border-width:5px 0 5px 5px}.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-bottom-color:#000;border-width:0 5px 5px}.tooltip.bottom-left .tooltip-arrow{top:0;left:5px;border-bottom-color:#000;border-width:0 5px 5px}.tooltip.bottom-right .tooltip-arrow{top:0;right:5px;border-bottom-color:#000;border-width:0 5px 5px}.popover{position:absolute;top:0;left:0;z-index:1010;display:none;max-width:276px;padding:1px;text-align:left;white-space:normal;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);background-clip:padding-box}.popover.top{margin-top:-10px}.popover.right{margin-left:10px}.popover.bottom{margin-top:10px}.popover.left{margin-left:-10px}.popover-title{padding:8px 14px;margin:0;font-size:14px;font-weight:normal;line-height:18px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;border-radius:5px 5px 0 0}.popover-content{padding:9px 14px}.popover .arrow,.popover .arrow:after{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.popover .arrow{border-width:11px}.popover .arrow:after{border-width:10px;content:""}.popover.top .arrow{bottom:-11px;left:50%;margin-left:-11px;border-top-color:#999;border-top-color:rgba(0,0,0,0.25);border-bottom-width:0}.popover.top .arrow:after{bottom:1px;margin-left:-10px;border-top-color:#fff;border-bottom-width:0;content:" "}.popover.right .arrow{top:50%;left:-11px;margin-top:-11px;border-right-color:#999;border-right-color:rgba(0,0,0,0.25);border-left-width:0}.popover.right .arrow:after{bottom:-10px;left:1px;border-right-color:#fff;border-left-width:0;content:" "}.popover.bottom .arrow{top:-11px;left:50%;margin-left:-11px;border-bottom-color:#999;border-bottom-color:rgba(0,0,0,0.25);border-top-width:0}.popover.bottom .arrow:after{top:1px;margin-left:-10px;border-bottom-color:#fff;border-top-width:0;content:" "}.popover.left .arrow{top:50%;right:-11px;margin-top:-11px;border-left-color:#999;border-left-color:rgba(0,0,0,0.25);border-right-width:0}.popover.left .arrow:after{right:1px;bottom:-10px;border-left-color:#fff;border-right-width:0;content:" "}.carousel{position:relative}.carousel-inner{position:relative;width:100%;overflow:hidden}.carousel-inner>.item{position:relative;display:none;-webkit-transition:.6s ease-in-out left;transition:.6s ease-in-out left}.carousel-inner>.item>img,.carousel-inner>.item>a>img{display:block;height:auto;max-width:100%;line-height:1}.carousel-inner>.active,.carousel-inner>.next,.carousel-inner>.prev{display:block}.carousel-inner>.active{left:0}.carousel-inner>.next,.carousel-inner>.prev{position:absolute;top:0;width:100%}.carousel-inner>.next{left:100%}.carousel-inner>.prev{left:-100%}.carousel-inner>.next.left,.carousel-inner>.prev.right{left:0}.carousel-inner>.active.left{left:-100%}.carousel-inner>.active.right{left:100%}.carousel-control{position:absolute;top:0;bottom:0;left:0;width:15%;font-size:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,0.6);opacity:.5;filter:alpha(opacity=50)}.carousel-control.left{background-image:-webkit-linear-gradient(left,color-stop(rgba(0,0,0,0.5) 0),color-stop(rgba(0,0,0,0.0001) 100%));background-image:linear-gradient(to right,rgba(0,0,0,0.5) 0,rgba(0,0,0,0.0001) 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000',endColorstr='#00000000',GradientType=1)}.carousel-control.right{right:0;left:auto;background-image:-webkit-linear-gradient(left,color-stop(rgba(0,0,0,0.0001) 0),color-stop(rgba(0,0,0,0.5) 100%));background-image:linear-gradient(to right,rgba(0,0,0,0.0001) 0,rgba(0,0,0,0.5) 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000',endColorstr='#80000000',GradientType=1)}.carousel-control:hover,.carousel-control:focus{color:#fff;text-decoration:none;outline:0;opacity:.9;filter:alpha(opacity=90)}.carousel-control .icon-prev,.carousel-control .icon-next,.carousel-control .glyphicon-chevron-left,.carousel-control .glyphicon-chevron-right{position:absolute;top:50%;z-index:5;display:inline-block}.carousel-control .icon-prev,.carousel-control .glyphicon-chevron-left{left:50%}.carousel-control .icon-next,.carousel-control .glyphicon-chevron-right{right:50%}.carousel-control .icon-prev,.carousel-control .icon-next{width:20px;height:20px;margin-top:-10px;margin-left:-10px;font-family:serif}.carousel-control .icon-prev:before{content:'\2039'}.carousel-control .icon-next:before{content:'\203a'}.carousel-indicators{position:absolute;bottom:10px;left:50%;z-index:15;width:60%;padding-left:0;margin-left:-30%;text-align:center;list-style:none}.carousel-indicators li{display:inline-block;width:10px;height:10px;margin:1px;text-indent:-999px;cursor:pointer;background-color:#000 \9;background-color:rgba(0,0,0,0);border:1px solid #fff;border-radius:10px}.carousel-indicators .active{width:12px;height:12px;margin:0;background-color:#fff}.carousel-caption{position:absolute;right:15%;bottom:20px;left:15%;z-index:10;padding-top:20px;padding-bottom:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,0.6)}.carousel-caption .btn{text-shadow:none}@media screen and (min-width:768px){.carousel-control .glyphicons-chevron-left,.carousel-control .glyphicons-chevron-right,.carousel-control .icon-prev,.carousel-control .icon-next{width:30px;height:30px;margin-top:-15px;margin-left:-15px;font-size:30px}.carousel-caption{right:20%;left:20%;padding-bottom:30px}.carousel-indicators{bottom:20px}}.clearfix:before,.clearfix:after{display:table;content:" "}.clearfix:after{clear:both}.center-block{display:block;margin-right:auto;margin-left:auto}.pull-right{float:right!important}.pull-left{float:left!important}.hide{display:none!important}.show{display:block!important}.invisible{visibility:hidden}.text-hide{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.hidden{display:none!important;visibility:hidden!important}.affix{position:fixed}@-ms-viewport{width:device-width}.visible-xs,tr.visible-xs,th.visible-xs,td.visible-xs{display:none!important}@media(max-width:767px){.visible-xs{display:block!important}table.visible-xs{display:table}tr.visible-xs{display:table-row!important}th.visible-xs,td.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-xs.visible-sm{display:block!important}table.visible-xs.visible-sm{display:table}tr.visible-xs.visible-sm{display:table-row!important}th.visible-xs.visible-sm,td.visible-xs.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-xs.visible-md{display:block!important}table.visible-xs.visible-md{display:table}tr.visible-xs.visible-md{display:table-row!important}th.visible-xs.visible-md,td.visible-xs.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-xs.visible-lg{display:block!important}table.visible-xs.visible-lg{display:table}tr.visible-xs.visible-lg{display:table-row!important}th.visible-xs.visible-lg,td.visible-xs.visible-lg{display:table-cell!important}}.visible-sm,tr.visible-sm,th.visible-sm,td.visible-sm{display:none!important}@media(max-width:767px){.visible-sm.visible-xs{display:block!important}table.visible-sm.visible-xs{display:table}tr.visible-sm.visible-xs{display:table-row!important}th.visible-sm.visible-xs,td.visible-sm.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-sm{display:block!important}table.visible-sm{display:table}tr.visible-sm{display:table-row!important}th.visible-sm,td.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-sm.visible-md{display:block!important}table.visible-sm.visible-md{display:table}tr.visible-sm.visible-md{display:table-row!important}th.visible-sm.visible-md,td.visible-sm.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-sm.visible-lg{display:block!important}table.visible-sm.visible-lg{display:table}tr.visible-sm.visible-lg{display:table-row!important}th.visible-sm.visible-lg,td.visible-sm.visible-lg{display:table-cell!important}}.visible-md,tr.visible-md,th.visible-md,td.visible-md{display:none!important}@media(max-width:767px){.visible-md.visible-xs{display:block!important}table.visible-md.visible-xs{display:table}tr.visible-md.visible-xs{display:table-row!important}th.visible-md.visible-xs,td.visible-md.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-md.visible-sm{display:block!important}table.visible-md.visible-sm{display:table}tr.visible-md.visible-sm{display:table-row!important}th.visible-md.visible-sm,td.visible-md.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-md{display:block!important}table.visible-md{display:table}tr.visible-md{display:table-row!important}th.visible-md,td.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-md.visible-lg{display:block!important}table.visible-md.visible-lg{display:table}tr.visible-md.visible-lg{display:table-row!important}th.visible-md.visible-lg,td.visible-md.visible-lg{display:table-cell!important}}.visible-lg,tr.visible-lg,th.visible-lg,td.visible-lg{display:none!important}@media(max-width:767px){.visible-lg.visible-xs{display:block!important}table.visible-lg.visible-xs{display:table}tr.visible-lg.visible-xs{display:table-row!important}th.visible-lg.visible-xs,td.visible-lg.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-lg.visible-sm{display:block!important}table.visible-lg.visible-sm{display:table}tr.visible-lg.visible-sm{display:table-row!important}th.visible-lg.visible-sm,td.visible-lg.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-lg.visible-md{display:block!important}table.visible-lg.visible-md{display:table}tr.visible-lg.visible-md{display:table-row!important}th.visible-lg.visible-md,td.visible-lg.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-lg{display:block!important}table.visible-lg{display:table}tr.visible-lg{display:table-row!important}th.visible-lg,td.visible-lg{display:table-cell!important}}.hidden-xs{display:block!important}table.hidden-xs{display:table}tr.hidden-xs{display:table-row!important}th.hidden-xs,td.hidden-xs{display:table-cell!important}@media(max-width:767px){.hidden-xs,tr.hidden-xs,th.hidden-xs,td.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-xs.hidden-sm,tr.hidden-xs.hidden-sm,th.hidden-xs.hidden-sm,td.hidden-xs.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-xs.hidden-md,tr.hidden-xs.hidden-md,th.hidden-xs.hidden-md,td.hidden-xs.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-xs.hidden-lg,tr.hidden-xs.hidden-lg,th.hidden-xs.hidden-lg,td.hidden-xs.hidden-lg{display:none!important}}.hidden-sm{display:block!important}table.hidden-sm{display:table}tr.hidden-sm{display:table-row!important}th.hidden-sm,td.hidden-sm{display:table-cell!important}@media(max-width:767px){.hidden-sm.hidden-xs,tr.hidden-sm.hidden-xs,th.hidden-sm.hidden-xs,td.hidden-sm.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-sm,tr.hidden-sm,th.hidden-sm,td.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-sm.hidden-md,tr.hidden-sm.hidden-md,th.hidden-sm.hidden-md,td.hidden-sm.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-sm.hidden-lg,tr.hidden-sm.hidden-lg,th.hidden-sm.hidden-lg,td.hidden-sm.hidden-lg{display:none!important}}.hidden-md{display:block!important}table.hidden-md{display:table}tr.hidden-md{display:table-row!important}th.hidden-md,td.hidden-md{display:table-cell!important}@media(max-width:767px){.hidden-md.hidden-xs,tr.hidden-md.hidden-xs,th.hidden-md.hidden-xs,td.hidden-md.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-md.hidden-sm,tr.hidden-md.hidden-sm,th.hidden-md.hidden-sm,td.hidden-md.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-md,tr.hidden-md,th.hidden-md,td.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-md.hidden-lg,tr.hidden-md.hidden-lg,th.hidden-md.hidden-lg,td.hidden-md.hidden-lg{display:none!important}}.hidden-lg{display:block!important}table.hidden-lg{display:table}tr.hidden-lg{display:table-row!important}th.hidden-lg,td.hidden-lg{display:table-cell!important}@media(max-width:767px){.hidden-lg.hidden-xs,tr.hidden-lg.hidden-xs,th.hidden-lg.hidden-xs,td.hidden-lg.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-lg.hidden-sm,tr.hidden-lg.hidden-sm,th.hidden-lg.hidden-sm,td.hidden-lg.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-lg.hidden-md,tr.hidden-lg.hidden-md,th.hidden-lg.hidden-md,td.hidden-lg.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-lg,tr.hidden-lg,th.hidden-lg,td.hidden-lg{display:none!important}}.visible-print,tr.visible-print,th.visible-print,td.visible-print{display:none!important}@media print{.visible-print{display:block!important}table.visible-print{display:table}tr.visible-print{display:table-row!important}th.visible-print,td.visible-print{display:table-cell!important}.hidden-print,tr.hidden-print,th.hidden-print,td.hidden-print{display:none!important}} \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/css/font-awesome.min.css b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/css/font-awesome.min.css new file mode 100755 index 00000000..540440ce --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/css/font-awesome.min.css @@ -0,0 +1,4 @@ +/*! + * Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome + * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) + */@font-face{font-family:'FontAwesome';src:url('../fonts/fontawesome-webfont.eot?v=4.7.0');src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'),url('../fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'),url('../fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'),url('../fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'),url('../fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571429em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14285714em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14285714em;width:2.14285714em;top:.14285714em;text-align:center}.fa-li.fa-lg{left:-1.85714286em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa.fa-pull-left{margin-right:.3em}.fa.fa-pull-right{margin-left:.3em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";-webkit-transform:scale(-1, 1);-ms-transform:scale(-1, 1);transform:scale(-1, 1)}.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scale(1, -1);-ms-transform:scale(1, -1);transform:scale(1, -1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-feed:before,.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper-pp:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-resistance:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-y-combinator-square:before,.fa-yc-square:before,.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-intersex:before,.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-genderless:before{content:"\f22d"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}.fa-yc:before,.fa-y-combinator:before{content:"\f23b"}.fa-optin-monster:before{content:"\f23c"}.fa-opencart:before{content:"\f23d"}.fa-expeditedssl:before{content:"\f23e"}.fa-battery-4:before,.fa-battery:before,.fa-battery-full:before{content:"\f240"}.fa-battery-3:before,.fa-battery-three-quarters:before{content:"\f241"}.fa-battery-2:before,.fa-battery-half:before{content:"\f242"}.fa-battery-1:before,.fa-battery-quarter:before{content:"\f243"}.fa-battery-0:before,.fa-battery-empty:before{content:"\f244"}.fa-mouse-pointer:before{content:"\f245"}.fa-i-cursor:before{content:"\f246"}.fa-object-group:before{content:"\f247"}.fa-object-ungroup:before{content:"\f248"}.fa-sticky-note:before{content:"\f249"}.fa-sticky-note-o:before{content:"\f24a"}.fa-cc-jcb:before{content:"\f24b"}.fa-cc-diners-club:before{content:"\f24c"}.fa-clone:before{content:"\f24d"}.fa-balance-scale:before{content:"\f24e"}.fa-hourglass-o:before{content:"\f250"}.fa-hourglass-1:before,.fa-hourglass-start:before{content:"\f251"}.fa-hourglass-2:before,.fa-hourglass-half:before{content:"\f252"}.fa-hourglass-3:before,.fa-hourglass-end:before{content:"\f253"}.fa-hourglass:before{content:"\f254"}.fa-hand-grab-o:before,.fa-hand-rock-o:before{content:"\f255"}.fa-hand-stop-o:before,.fa-hand-paper-o:before{content:"\f256"}.fa-hand-scissors-o:before{content:"\f257"}.fa-hand-lizard-o:before{content:"\f258"}.fa-hand-spock-o:before{content:"\f259"}.fa-hand-pointer-o:before{content:"\f25a"}.fa-hand-peace-o:before{content:"\f25b"}.fa-trademark:before{content:"\f25c"}.fa-registered:before{content:"\f25d"}.fa-creative-commons:before{content:"\f25e"}.fa-gg:before{content:"\f260"}.fa-gg-circle:before{content:"\f261"}.fa-tripadvisor:before{content:"\f262"}.fa-odnoklassniki:before{content:"\f263"}.fa-odnoklassniki-square:before{content:"\f264"}.fa-get-pocket:before{content:"\f265"}.fa-wikipedia-w:before{content:"\f266"}.fa-safari:before{content:"\f267"}.fa-chrome:before{content:"\f268"}.fa-firefox:before{content:"\f269"}.fa-opera:before{content:"\f26a"}.fa-internet-explorer:before{content:"\f26b"}.fa-tv:before,.fa-television:before{content:"\f26c"}.fa-contao:before{content:"\f26d"}.fa-500px:before{content:"\f26e"}.fa-amazon:before{content:"\f270"}.fa-calendar-plus-o:before{content:"\f271"}.fa-calendar-minus-o:before{content:"\f272"}.fa-calendar-times-o:before{content:"\f273"}.fa-calendar-check-o:before{content:"\f274"}.fa-industry:before{content:"\f275"}.fa-map-pin:before{content:"\f276"}.fa-map-signs:before{content:"\f277"}.fa-map-o:before{content:"\f278"}.fa-map:before{content:"\f279"}.fa-commenting:before{content:"\f27a"}.fa-commenting-o:before{content:"\f27b"}.fa-houzz:before{content:"\f27c"}.fa-vimeo:before{content:"\f27d"}.fa-black-tie:before{content:"\f27e"}.fa-fonticons:before{content:"\f280"}.fa-reddit-alien:before{content:"\f281"}.fa-edge:before{content:"\f282"}.fa-credit-card-alt:before{content:"\f283"}.fa-codiepie:before{content:"\f284"}.fa-modx:before{content:"\f285"}.fa-fort-awesome:before{content:"\f286"}.fa-usb:before{content:"\f287"}.fa-product-hunt:before{content:"\f288"}.fa-mixcloud:before{content:"\f289"}.fa-scribd:before{content:"\f28a"}.fa-pause-circle:before{content:"\f28b"}.fa-pause-circle-o:before{content:"\f28c"}.fa-stop-circle:before{content:"\f28d"}.fa-stop-circle-o:before{content:"\f28e"}.fa-shopping-bag:before{content:"\f290"}.fa-shopping-basket:before{content:"\f291"}.fa-hashtag:before{content:"\f292"}.fa-bluetooth:before{content:"\f293"}.fa-bluetooth-b:before{content:"\f294"}.fa-percent:before{content:"\f295"}.fa-gitlab:before{content:"\f296"}.fa-wpbeginner:before{content:"\f297"}.fa-wpforms:before{content:"\f298"}.fa-envira:before{content:"\f299"}.fa-universal-access:before{content:"\f29a"}.fa-wheelchair-alt:before{content:"\f29b"}.fa-question-circle-o:before{content:"\f29c"}.fa-blind:before{content:"\f29d"}.fa-audio-description:before{content:"\f29e"}.fa-volume-control-phone:before{content:"\f2a0"}.fa-braille:before{content:"\f2a1"}.fa-assistive-listening-systems:before{content:"\f2a2"}.fa-asl-interpreting:before,.fa-american-sign-language-interpreting:before{content:"\f2a3"}.fa-deafness:before,.fa-hard-of-hearing:before,.fa-deaf:before{content:"\f2a4"}.fa-glide:before{content:"\f2a5"}.fa-glide-g:before{content:"\f2a6"}.fa-signing:before,.fa-sign-language:before{content:"\f2a7"}.fa-low-vision:before{content:"\f2a8"}.fa-viadeo:before{content:"\f2a9"}.fa-viadeo-square:before{content:"\f2aa"}.fa-snapchat:before{content:"\f2ab"}.fa-snapchat-ghost:before{content:"\f2ac"}.fa-snapchat-square:before{content:"\f2ad"}.fa-pied-piper:before{content:"\f2ae"}.fa-first-order:before{content:"\f2b0"}.fa-yoast:before{content:"\f2b1"}.fa-themeisle:before{content:"\f2b2"}.fa-google-plus-circle:before,.fa-google-plus-official:before{content:"\f2b3"}.fa-fa:before,.fa-font-awesome:before{content:"\f2b4"}.fa-handshake-o:before{content:"\f2b5"}.fa-envelope-open:before{content:"\f2b6"}.fa-envelope-open-o:before{content:"\f2b7"}.fa-linode:before{content:"\f2b8"}.fa-address-book:before{content:"\f2b9"}.fa-address-book-o:before{content:"\f2ba"}.fa-vcard:before,.fa-address-card:before{content:"\f2bb"}.fa-vcard-o:before,.fa-address-card-o:before{content:"\f2bc"}.fa-user-circle:before{content:"\f2bd"}.fa-user-circle-o:before{content:"\f2be"}.fa-user-o:before{content:"\f2c0"}.fa-id-badge:before{content:"\f2c1"}.fa-drivers-license:before,.fa-id-card:before{content:"\f2c2"}.fa-drivers-license-o:before,.fa-id-card-o:before{content:"\f2c3"}.fa-quora:before{content:"\f2c4"}.fa-free-code-camp:before{content:"\f2c5"}.fa-telegram:before{content:"\f2c6"}.fa-thermometer-4:before,.fa-thermometer:before,.fa-thermometer-full:before{content:"\f2c7"}.fa-thermometer-3:before,.fa-thermometer-three-quarters:before{content:"\f2c8"}.fa-thermometer-2:before,.fa-thermometer-half:before{content:"\f2c9"}.fa-thermometer-1:before,.fa-thermometer-quarter:before{content:"\f2ca"}.fa-thermometer-0:before,.fa-thermometer-empty:before{content:"\f2cb"}.fa-shower:before{content:"\f2cc"}.fa-bathtub:before,.fa-s15:before,.fa-bath:before{content:"\f2cd"}.fa-podcast:before{content:"\f2ce"}.fa-window-maximize:before{content:"\f2d0"}.fa-window-minimize:before{content:"\f2d1"}.fa-window-restore:before{content:"\f2d2"}.fa-times-rectangle:before,.fa-window-close:before{content:"\f2d3"}.fa-times-rectangle-o:before,.fa-window-close-o:before{content:"\f2d4"}.fa-bandcamp:before{content:"\f2d5"}.fa-grav:before{content:"\f2d6"}.fa-etsy:before{content:"\f2d7"}.fa-imdb:before{content:"\f2d8"}.fa-ravelry:before{content:"\f2d9"}.fa-eercast:before{content:"\f2da"}.fa-microchip:before{content:"\f2db"}.fa-snowflake-o:before{content:"\f2dc"}.fa-superpowers:before{content:"\f2dd"}.fa-wpexplorer:before{content:"\f2de"}.fa-meetup:before{content:"\f2e0"}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/fonts/fontawesome-webfont.ttf b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/fonts/fontawesome-webfont.ttf new file mode 100755 index 00000000..35acda2f Binary files /dev/null and b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/fonts/fontawesome-webfont.ttf differ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/fonts/fontawesome-webfont.woff b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/fonts/fontawesome-webfont.woff new file mode 100755 index 00000000..400014a4 Binary files /dev/null and b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/fonts/fontawesome-webfont.woff differ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/fonts/fontawesome-webfont.woff2 b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/fonts/fontawesome-webfont.woff2 new file mode 100755 index 00000000..4d13fc60 Binary files /dev/null and b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/fonts/fontawesome-webfont.woff2 differ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/fonts/glyphicons-halflings-regular.ttf b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/fonts/glyphicons-halflings-regular.ttf new file mode 100755 index 00000000..a498ef4e Binary files /dev/null and b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/fonts/glyphicons-halflings-regular.ttf differ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/fonts/glyphicons-halflings-regular.woff b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/fonts/glyphicons-halflings-regular.woff new file mode 100755 index 00000000..d83c539b Binary files /dev/null and b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/fonts/glyphicons-halflings-regular.woff differ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/js/angular.min.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/js/angular.min.js new file mode 100755 index 00000000..b4f9b07e --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/js/angular.min.js @@ -0,0 +1,295 @@ +/* + AngularJS v1.4.8 + (c) 2010-2015 Google, Inc. http://angularjs.org + License: MIT +*/ +(function(S,X,u){'use strict';function G(a){return function(){var b=arguments[0],d;d="["+(a?a+":":"")+b+"] http://errors.angularjs.org/1.4.8/"+(a?a+"/":"")+b;for(b=1;b").append(a).html();try{return a[0].nodeType===Na?F(d):d.match(/^(<[^>]+>)/)[1].replace(/^<([\w\-]+)/,function(a,b){return"<"+F(b)})}catch(c){return F(d)}}function wc(a){try{return decodeURIComponent(a)}catch(b){}} +function xc(a){var b={};n((a||"").split("&"),function(a){var c,e,f;a&&(e=a=a.replace(/\+/g,"%20"),c=a.indexOf("="),-1!==c&&(e=a.substring(0,c),f=a.substring(c+1)),e=wc(e),y(e)&&(f=y(f)?wc(f):!0,qa.call(b,e)?I(b[e])?b[e].push(f):b[e]=[b[e],f]:b[e]=f))});return b}function Qb(a){var b=[];n(a,function(a,c){I(a)?n(a,function(a){b.push(ja(c,!0)+(!0===a?"":"="+ja(a,!0)))}):b.push(ja(c,!0)+(!0===a?"":"="+ja(a,!0)))});return b.length?b.join("&"):""}function ob(a){return ja(a,!0).replace(/%26/gi,"&").replace(/%3D/gi, +"=").replace(/%2B/gi,"+")}function ja(a,b){return encodeURIComponent(a).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%3B/gi,";").replace(/%20/g,b?"%20":"+")}function Yd(a,b){var d,c,e=Oa.length;for(c=0;c/,">"));}b=b||[];b.unshift(["$provide",function(b){b.value("$rootElement",a)}]);d.debugInfoEnabled&&b.push(["$compileProvider",function(a){a.debugInfoEnabled(!0)}]);b.unshift("ng");c=eb(b,d.strictDi);c.invoke(["$rootScope", +"$rootElement","$compile","$injector",function(a,b,c,d){a.$apply(function(){b.data("$injector",d);c(b)(a)})}]);return c},e=/^NG_ENABLE_DEBUG_INFO!/,f=/^NG_DEFER_BOOTSTRAP!/;S&&e.test(S.name)&&(d.debugInfoEnabled=!0,S.name=S.name.replace(e,""));if(S&&!f.test(S.name))return c();S.name=S.name.replace(f,"");fa.resumeBootstrap=function(a){n(a,function(a){b.push(a)});return c()};z(fa.resumeDeferredBootstrap)&&fa.resumeDeferredBootstrap()}function $d(){S.name="NG_ENABLE_DEBUG_INFO!"+S.name;S.location.reload()} +function ae(a){a=fa.element(a).injector();if(!a)throw Aa("test");return a.get("$$testability")}function zc(a,b){b=b||"_";return a.replace(be,function(a,c){return(c?b:"")+a.toLowerCase()})}function ce(){var a;if(!Ac){var b=pb();(oa=q(b)?S.jQuery:b?S[b]:u)&&oa.fn.on?(B=oa,M(oa.fn,{scope:Pa.scope,isolateScope:Pa.isolateScope,controller:Pa.controller,injector:Pa.injector,inheritedData:Pa.inheritedData}),a=oa.cleanData,oa.cleanData=function(b){var c;if(Rb)Rb=!1;else for(var e=0,f;null!=(f=b[e]);e++)(c= +oa._data(f,"events"))&&c.$destroy&&oa(f).triggerHandler("$destroy");a(b)}):B=N;fa.element=B;Ac=!0}}function qb(a,b,d){if(!a)throw Aa("areq",b||"?",d||"required");return a}function Qa(a,b,d){d&&I(a)&&(a=a[a.length-1]);qb(z(a),b,"not a function, got "+(a&&"object"===typeof a?a.constructor.name||"Object":typeof a));return a}function Ra(a,b){if("hasOwnProperty"===a)throw Aa("badname",b);}function Bc(a,b,d){if(!b)return a;b=b.split(".");for(var c,e=a,f=b.length,g=0;g")+c[2];for(c=c[0];c--;)d=d.lastChild;f=cb(f,d.childNodes);d=e.firstChild;d.textContent=""}else f.push(b.createTextNode(a));e.textContent="";e.innerHTML="";n(f,function(a){e.appendChild(a)});return e}function N(a){if(a instanceof N)return a;var b;E(a)&&(a=U(a), +b=!0);if(!(this instanceof N)){if(b&&"<"!=a.charAt(0))throw Ub("nosel");return new N(a)}if(b){b=X;var d;a=(d=Ef.exec(a))?[b.createElement(d[1])]:(d=Lc(a,b))?d.childNodes:[]}Mc(this,a)}function Vb(a){return a.cloneNode(!0)}function ub(a,b){b||vb(a);if(a.querySelectorAll)for(var d=a.querySelectorAll("*"),c=0,e=d.length;cl&&this.remove(t.key);return b}},get:function(a){if(l").parent()[0])});var f=O(a,b,a,c,d,e);K.$$addScopeClass(a);var g=null;return function(b,c,d){qb(b,"scope");e&&e.needsNewScope&&(b=b.$parent.$new());d=d||{};var h=d.parentBoundTranscludeFn,k=d.transcludeControllers;d=d.futureParentElement;h&&h.$$boundTransclude&&(h=h.$$boundTransclude);g||(g=(d= +d&&d[0])?"foreignobject"!==ta(d)&&d.toString().match(/SVG/)?"svg":"html":"html");d="html"!==g?B(Yb(g,B("
    ").append(a).html())):c?Pa.clone.call(a):a;if(k)for(var l in k)d.data("$"+l+"Controller",k[l].instance);K.$$addScopeInfo(d,b);c&&c(d,b);f&&f(b,d,d,h);return d}}function O(a,b,c,d,e,f){function g(a,c,d,e){var f,k,l,m,t,w,D;if(p)for(D=Array(c.length),m=0;mq.priority)break;if(P=q.scope)q.templateUrl||(H(P)?(Ua("new/isolated scope",O||R,q,Z),O=q):Ua("new/isolated scope",O,q,Z)),R=R||q;x=q.name;!q.templateUrl&&q.controller&&(P=q.controller,T=T||$(),Ua("'"+x+"' controller",T[x],q,Z),T[x]=q);if(P=q.transclude)ga=!0,q.$$tlb||(Ua("transclusion",n,q,Z),n=q),"element"==P?(aa=!0,A=q.priority,P=Z,Z=d.$$element=B(X.createComment(" "+x+": "+d[x]+" ")),b=Z[0],Y(f,ra.call(P,0), +b),Ia=K(P,e,A,g&&g.name,{nonTlbTranscludeDirective:n})):(P=B(Vb(b)).contents(),Z.empty(),Ia=K(P,e,u,u,{needsNewScope:q.$$isolateScope||q.$$newScope}));if(q.template)if(L=!0,Ua("template",J,q,Z),J=q,P=z(q.template)?q.template(Z,d):q.template,P=ja(P),q.replace){g=q;P=Tb.test(P)?Xc(Yb(q.templateNamespace,U(P))):[];b=P[0];if(1!=P.length||1!==b.nodeType)throw ha("tplrt",x,"");Y(f,Z,b);P={$attr:{}};var Wc=V(b,[],P),W=a.splice(F+1,a.length-(F+1));(O||R)&&y(Wc,O,R);a=a.concat(Wc).concat(W);S(d,P);M=a.length}else Z.html(P); +if(q.templateUrl)L=!0,Ua("template",J,q,Z),J=q,q.replace&&(g=q),D=Of(a.splice(F,a.length-F),Z,d,f,ga&&Ia,h,l,{controllerDirectives:T,newScopeDirective:R!==q&&R,newIsolateScopeDirective:O,templateDirective:J,nonTlbTranscludeDirective:n}),M=a.length;else if(q.compile)try{G=q.compile(Z,d,Ia),z(G)?t(null,G,N,Q):G&&t(G.pre,G.post,N,Q)}catch(da){c(da,ua(Z))}q.terminal&&(D.terminal=!0,A=Math.max(A,q.priority))}D.scope=R&&!0===R.scope;D.transcludeOnThisElement=ga;D.templateOnThisElement=L;D.transclude=Ia; +m.hasElementTranscludeDirective=aa;return D}function y(a,b,c){for(var d=0,e=a.length;dm.priority)&&-1!=m.restrict.indexOf(f)&&(k&&(m=Ob(m,{$$start:k,$$end:l})),b.push(m),h=m)}catch(D){c(D)}}return h}function G(b){if(e.hasOwnProperty(b))for(var c=a.get(b+"Directive"),d=0,f=c.length;d"+b+"";return c.childNodes[0].childNodes;default:return b}}function Q(a,b){if("srcdoc"==b)return L.HTML;var c=ta(a);if("xlinkHref"==b||"form"==c&&"action"==b||"img"!=c&&("src"==b||"ngSrc"==b))return L.RESOURCE_URL}function W(a,c,d,e,f){var g=Q(a,e);f=h[e]||f;var k=b(d,!0,g,f);if(k){if("multiple"===e&&"select"===ta(a))throw ha("selmulti",ua(a));c.push({priority:100,compile:function(){return{pre:function(a,c,h){c=h.$$observers||(h.$$observers=$());if(l.test(e))throw ha("nodomevents"); +var m=h[e];m!==d&&(k=m&&b(m,!0,g,f),d=m);k&&(h[e]=k(a),(c[e]||(c[e]=[])).$$inter=!0,(h.$$observers&&h.$$observers[e].$$scope||a).$watch(k,function(a,b){"class"===e&&a!=b?h.$updateClass(a,b):h.$set(e,a)}))}}}})}}function Y(a,b,c){var d=b[0],e=b.length,f=d.parentNode,g,h;if(a)for(g=0,h=a.length;g=b)return a;for(;b--;)8===a[b].nodeType&&Pf.call(a,b,1);return a}function Xe(){var a={},b=!1;this.register=function(b,c){Ra(b,"controller");H(b)?M(a,b):a[b]=c};this.allowGlobals=function(){b=!0};this.$get=["$injector","$window",function(d,c){function e(a,b,c,d){if(!a||!H(a.$scope))throw G("$controller")("noscp", +d,b);a.$scope[b]=c}return function(f,g,h,k){var l,m,r;h=!0===h;k&&E(k)&&(r=k);if(E(f)){k=f.match(Uc);if(!k)throw Qf("ctrlfmt",f);m=k[1];r=r||k[3];f=a.hasOwnProperty(m)?a[m]:Bc(g.$scope,m,!0)||(b?Bc(c,m,!0):u);Qa(f,m,!0)}if(h)return h=(I(f)?f[f.length-1]:f).prototype,l=Object.create(h||null),r&&e(g,r,l,m||f.name),M(function(){var a=d.invoke(f,l,g,m);a!==l&&(H(a)||z(a))&&(l=a,r&&e(g,r,l,m||f.name));return l},{instance:l,identifier:r});l=d.instantiate(f,g,m);r&&e(g,r,l,m||f.name);return l}}]}function Ye(){this.$get= +["$window",function(a){return B(a.document)}]}function Ze(){this.$get=["$log",function(a){return function(b,d){a.error.apply(a,arguments)}}]}function Zb(a){return H(a)?da(a)?a.toISOString():db(a):a}function df(){this.$get=function(){return function(a){if(!a)return"";var b=[];oc(a,function(a,c){null===a||q(a)||(I(a)?n(a,function(a,d){b.push(ja(c)+"="+ja(Zb(a)))}):b.push(ja(c)+"="+ja(Zb(a))))});return b.join("&")}}}function ef(){this.$get=function(){return function(a){function b(a,e,f){null===a||q(a)|| +(I(a)?n(a,function(a,c){b(a,e+"["+(H(a)?c:"")+"]")}):H(a)&&!da(a)?oc(a,function(a,c){b(a,e+(f?"":"[")+c+(f?"":"]"))}):d.push(ja(e)+"="+ja(Zb(a))))}if(!a)return"";var d=[];b(a,"",!0);return d.join("&")}}}function $b(a,b){if(E(a)){var d=a.replace(Rf,"").trim();if(d){var c=b("Content-Type");(c=c&&0===c.indexOf($c))||(c=(c=d.match(Sf))&&Tf[c[0]].test(d));c&&(a=uc(d))}}return a}function ad(a){var b=$(),d;E(a)?n(a.split("\n"),function(a){d=a.indexOf(":");var e=F(U(a.substr(0,d)));a=U(a.substr(d+1));e&& +(b[e]=b[e]?b[e]+", "+a:a)}):H(a)&&n(a,function(a,d){var f=F(d),g=U(a);f&&(b[f]=b[f]?b[f]+", "+g:g)});return b}function bd(a){var b;return function(d){b||(b=ad(a));return d?(d=b[F(d)],void 0===d&&(d=null),d):b}}function cd(a,b,d,c){if(z(c))return c(a,b,d);n(c,function(c){a=c(a,b,d)});return a}function cf(){var a=this.defaults={transformResponse:[$b],transformRequest:[function(a){return H(a)&&"[object File]"!==sa.call(a)&&"[object Blob]"!==sa.call(a)&&"[object FormData]"!==sa.call(a)?db(a):a}],headers:{common:{Accept:"application/json, text/plain, */*"}, +post:ia(ac),put:ia(ac),patch:ia(ac)},xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",paramSerializer:"$httpParamSerializer"},b=!1;this.useApplyAsync=function(a){return y(a)?(b=!!a,this):b};var d=!0;this.useLegacyPromiseExtensions=function(a){return y(a)?(d=!!a,this):d};var c=this.interceptors=[];this.$get=["$httpBackend","$$cookieReader","$cacheFactory","$rootScope","$q","$injector",function(e,f,g,h,k,l){function m(b){function c(a){var b=M({},a);b.data=cd(a.data,a.headers,a.status,f.transformResponse); +a=a.status;return 200<=a&&300>a?b:k.reject(b)}function e(a,b){var c,d={};n(a,function(a,e){z(a)?(c=a(b),null!=c&&(d[e]=c)):d[e]=a});return d}if(!fa.isObject(b))throw G("$http")("badreq",b);var f=M({method:"get",transformRequest:a.transformRequest,transformResponse:a.transformResponse,paramSerializer:a.paramSerializer},b);f.headers=function(b){var c=a.headers,d=M({},b.headers),f,g,h,c=M({},c.common,c[F(b.method)]);a:for(f in c){g=F(f);for(h in d)if(F(h)===g)continue a;d[f]=c[f]}return e(d,ia(b))}(b); +f.method=sb(f.method);f.paramSerializer=E(f.paramSerializer)?l.get(f.paramSerializer):f.paramSerializer;var g=[function(b){var d=b.headers,e=cd(b.data,bd(d),u,b.transformRequest);q(e)&&n(d,function(a,b){"content-type"===F(b)&&delete d[b]});q(b.withCredentials)&&!q(a.withCredentials)&&(b.withCredentials=a.withCredentials);return r(b,e).then(c,c)},u],h=k.when(f);for(n(v,function(a){(a.request||a.requestError)&&g.unshift(a.request,a.requestError);(a.response||a.responseError)&&g.push(a.response,a.responseError)});g.length;){b= +g.shift();var m=g.shift(),h=h.then(b,m)}d?(h.success=function(a){Qa(a,"fn");h.then(function(b){a(b.data,b.status,b.headers,f)});return h},h.error=function(a){Qa(a,"fn");h.then(null,function(b){a(b.data,b.status,b.headers,f)});return h}):(h.success=dd("success"),h.error=dd("error"));return h}function r(c,d){function g(a,c,d,e){function f(){l(c,a,d,e)}J&&(200<=a&&300>a?J.put(R,[a,c,ad(d),e]):J.remove(R));b?h.$applyAsync(f):(f(),h.$$phase||h.$apply())}function l(a,b,d,e){b=-1<=b?b:0;(200<=b&&300>b?n.resolve: +n.reject)({data:a,status:b,headers:bd(d),config:c,statusText:e})}function r(a){l(a.data,a.status,ia(a.headers()),a.statusText)}function v(){var a=m.pendingRequests.indexOf(c);-1!==a&&m.pendingRequests.splice(a,1)}var n=k.defer(),D=n.promise,J,K,O=c.headers,R=t(c.url,c.paramSerializer(c.params));m.pendingRequests.push(c);D.then(v,v);!c.cache&&!a.cache||!1===c.cache||"GET"!==c.method&&"JSONP"!==c.method||(J=H(c.cache)?c.cache:H(a.cache)?a.cache:A);J&&(K=J.get(R),y(K)?K&&z(K.then)?K.then(r,r):I(K)?l(K[1], +K[0],ia(K[2]),K[3]):l(K,200,{},"OK"):J.put(R,D));q(K)&&((K=ed(c.url)?f()[c.xsrfCookieName||a.xsrfCookieName]:u)&&(O[c.xsrfHeaderName||a.xsrfHeaderName]=K),e(c.method,R,d,g,O,c.timeout,c.withCredentials,c.responseType));return D}function t(a,b){0=k&&(p.resolve(v),A(C.$$intervalId),delete f[C.$$intervalId]);n||a.$apply()},h);f[C.$$intervalId]=p;return C}var f={};e.cancel=function(a){return a&&a.$$intervalId in f?(f[a.$$intervalId].reject("canceled"),b.clearInterval(a.$$intervalId),delete f[a.$$intervalId],!0):!1};return e}]}function bc(a){a=a.split("/");for(var b=a.length;b--;)a[b]=ob(a[b]);return a.join("/")}function fd(a,b){var d=wa(a);b.$$protocol=d.protocol;b.$$host=d.hostname;b.$$port=ea(d.port)||Vf[d.protocol]|| +null}function gd(a,b){var d="/"!==a.charAt(0);d&&(a="/"+a);var c=wa(a);b.$$path=decodeURIComponent(d&&"/"===c.pathname.charAt(0)?c.pathname.substring(1):c.pathname);b.$$search=xc(c.search);b.$$hash=decodeURIComponent(c.hash);b.$$path&&"/"!=b.$$path.charAt(0)&&(b.$$path="/"+b.$$path)}function pa(a,b){if(0===b.indexOf(a))return b.substr(a.length)}function Fa(a){var b=a.indexOf("#");return-1==b?a:a.substr(0,b)}function ib(a){return a.replace(/(#.+)|#$/,"$1")}function cc(a,b,d){this.$$html5=!0;d=d||""; +fd(a,this);this.$$parse=function(a){var d=pa(b,a);if(!E(d))throw Db("ipthprfx",a,b);gd(d,this);this.$$path||(this.$$path="/");this.$$compose()};this.$$compose=function(){var a=Qb(this.$$search),d=this.$$hash?"#"+ob(this.$$hash):"";this.$$url=bc(this.$$path)+(a?"?"+a:"")+d;this.$$absUrl=b+this.$$url.substr(1)};this.$$parseLinkUrl=function(c,e){if(e&&"#"===e[0])return this.hash(e.slice(1)),!0;var f,g;y(f=pa(a,c))?(g=f,g=y(f=pa(d,f))?b+(pa("/",f)||f):a+g):y(f=pa(b,c))?g=b+f:b==c+"/"&&(g=b);g&&this.$$parse(g); +return!!g}}function dc(a,b,d){fd(a,this);this.$$parse=function(c){var e=pa(a,c)||pa(b,c),f;q(e)||"#"!==e.charAt(0)?this.$$html5?f=e:(f="",q(e)&&(a=c,this.replace())):(f=pa(d,e),q(f)&&(f=e));gd(f,this);c=this.$$path;var e=a,g=/^\/[A-Z]:(\/.*)/;0===f.indexOf(e)&&(f=f.replace(e,""));g.exec(f)||(c=(f=g.exec(c))?f[1]:c);this.$$path=c;this.$$compose()};this.$$compose=function(){var b=Qb(this.$$search),e=this.$$hash?"#"+ob(this.$$hash):"";this.$$url=bc(this.$$path)+(b?"?"+b:"")+e;this.$$absUrl=a+(this.$$url? +d+this.$$url:"")};this.$$parseLinkUrl=function(b,d){return Fa(a)==Fa(b)?(this.$$parse(b),!0):!1}}function hd(a,b,d){this.$$html5=!0;dc.apply(this,arguments);this.$$parseLinkUrl=function(c,e){if(e&&"#"===e[0])return this.hash(e.slice(1)),!0;var f,g;a==Fa(c)?f=c:(g=pa(b,c))?f=a+d+g:b===c+"/"&&(f=b);f&&this.$$parse(f);return!!f};this.$$compose=function(){var b=Qb(this.$$search),e=this.$$hash?"#"+ob(this.$$hash):"";this.$$url=bc(this.$$path)+(b?"?"+b:"")+e;this.$$absUrl=a+d+this.$$url}}function Eb(a){return function(){return this[a]}} +function id(a,b){return function(d){if(q(d))return this[a];this[a]=b(d);this.$$compose();return this}}function hf(){var a="",b={enabled:!1,requireBase:!0,rewriteLinks:!0};this.hashPrefix=function(b){return y(b)?(a=b,this):a};this.html5Mode=function(a){return $a(a)?(b.enabled=a,this):H(a)?($a(a.enabled)&&(b.enabled=a.enabled),$a(a.requireBase)&&(b.requireBase=a.requireBase),$a(a.rewriteLinks)&&(b.rewriteLinks=a.rewriteLinks),this):b};this.$get=["$rootScope","$browser","$sniffer","$rootElement","$window", +function(d,c,e,f,g){function h(a,b,d){var e=l.url(),f=l.$$state;try{c.url(a,b,d),l.$$state=c.state()}catch(g){throw l.url(e),l.$$state=f,g;}}function k(a,b){d.$broadcast("$locationChangeSuccess",l.absUrl(),a,l.$$state,b)}var l,m;m=c.baseHref();var r=c.url(),t;if(b.enabled){if(!m&&b.requireBase)throw Db("nobase");t=r.substring(0,r.indexOf("/",r.indexOf("//")+2))+(m||"/");m=e.history?cc:hd}else t=Fa(r),m=dc;var A=t.substr(0,Fa(t).lastIndexOf("/")+1);l=new m(t,A,"#"+a);l.$$parseLinkUrl(r,r);l.$$state= +c.state();var v=/^\s*(javascript|mailto):/i;f.on("click",function(a){if(b.rewriteLinks&&!a.ctrlKey&&!a.metaKey&&!a.shiftKey&&2!=a.which&&2!=a.button){for(var e=B(a.target);"a"!==ta(e[0]);)if(e[0]===f[0]||!(e=e.parent())[0])return;var h=e.prop("href"),k=e.attr("href")||e.attr("xlink:href");H(h)&&"[object SVGAnimatedString]"===h.toString()&&(h=wa(h.animVal).href);v.test(h)||!h||e.attr("target")||a.isDefaultPrevented()||!l.$$parseLinkUrl(h,k)||(a.preventDefault(),l.absUrl()!=c.url()&&(d.$apply(),g.angular["ff-684208-preventDefault"]= +!0))}});ib(l.absUrl())!=ib(r)&&c.url(l.absUrl(),!0);var n=!0;c.onUrlChange(function(a,b){q(pa(A,a))?g.location.href=a:(d.$evalAsync(function(){var c=l.absUrl(),e=l.$$state,f;a=ib(a);l.$$parse(a);l.$$state=b;f=d.$broadcast("$locationChangeStart",a,c,b,e).defaultPrevented;l.absUrl()===a&&(f?(l.$$parse(c),l.$$state=e,h(c,!1,e)):(n=!1,k(c,e)))}),d.$$phase||d.$digest())});d.$watch(function(){var a=ib(c.url()),b=ib(l.absUrl()),f=c.state(),g=l.$$replace,m=a!==b||l.$$html5&&e.history&&f!==l.$$state;if(n|| +m)n=!1,d.$evalAsync(function(){var b=l.absUrl(),c=d.$broadcast("$locationChangeStart",b,a,l.$$state,f).defaultPrevented;l.absUrl()===b&&(c?(l.$$parse(a),l.$$state=f):(m&&h(b,g,f===l.$$state?null:l.$$state),k(a,f)))});l.$$replace=!1});return l}]}function jf(){var a=!0,b=this;this.debugEnabled=function(b){return y(b)?(a=b,this):a};this.$get=["$window",function(d){function c(a){a instanceof Error&&(a.stack?a=a.message&&-1===a.stack.indexOf(a.message)?"Error: "+a.message+"\n"+a.stack:a.stack:a.sourceURL&& +(a=a.message+"\n"+a.sourceURL+":"+a.line));return a}function e(a){var b=d.console||{},e=b[a]||b.log||x;a=!1;try{a=!!e.apply}catch(k){}return a?function(){var a=[];n(arguments,function(b){a.push(c(b))});return e.apply(b,a)}:function(a,b){e(a,null==b?"":b)}}return{log:e("log"),info:e("info"),warn:e("warn"),error:e("error"),debug:function(){var c=e("debug");return function(){a&&c.apply(b,arguments)}}()}}]}function Va(a,b){if("__defineGetter__"===a||"__defineSetter__"===a||"__lookupGetter__"===a||"__lookupSetter__"=== +a||"__proto__"===a)throw ba("isecfld",b);return a}function jd(a,b){a+="";if(!E(a))throw ba("iseccst",b);return a}function xa(a,b){if(a){if(a.constructor===a)throw ba("isecfn",b);if(a.window===a)throw ba("isecwindow",b);if(a.children&&(a.nodeName||a.prop&&a.attr&&a.find))throw ba("isecdom",b);if(a===Object)throw ba("isecobj",b);}return a}function kd(a,b){if(a){if(a.constructor===a)throw ba("isecfn",b);if(a===Wf||a===Xf||a===Yf)throw ba("isecff",b);}}function ld(a,b){if(a&&(a===(0).constructor||a=== +(!1).constructor||a==="".constructor||a==={}.constructor||a===[].constructor||a===Function.constructor))throw ba("isecaf",b);}function Zf(a,b){return"undefined"!==typeof a?a:b}function md(a,b){return"undefined"===typeof a?b:"undefined"===typeof b?a:a+b}function W(a,b){var d,c;switch(a.type){case s.Program:d=!0;n(a.body,function(a){W(a.expression,b);d=d&&a.expression.constant});a.constant=d;break;case s.Literal:a.constant=!0;a.toWatch=[];break;case s.UnaryExpression:W(a.argument,b);a.constant=a.argument.constant; +a.toWatch=a.argument.toWatch;break;case s.BinaryExpression:W(a.left,b);W(a.right,b);a.constant=a.left.constant&&a.right.constant;a.toWatch=a.left.toWatch.concat(a.right.toWatch);break;case s.LogicalExpression:W(a.left,b);W(a.right,b);a.constant=a.left.constant&&a.right.constant;a.toWatch=a.constant?[]:[a];break;case s.ConditionalExpression:W(a.test,b);W(a.alternate,b);W(a.consequent,b);a.constant=a.test.constant&&a.alternate.constant&&a.consequent.constant;a.toWatch=a.constant?[]:[a];break;case s.Identifier:a.constant= +!1;a.toWatch=[a];break;case s.MemberExpression:W(a.object,b);a.computed&&W(a.property,b);a.constant=a.object.constant&&(!a.computed||a.property.constant);a.toWatch=[a];break;case s.CallExpression:d=a.filter?!b(a.callee.name).$stateful:!1;c=[];n(a.arguments,function(a){W(a,b);d=d&&a.constant;a.constant||c.push.apply(c,a.toWatch)});a.constant=d;a.toWatch=a.filter&&!b(a.callee.name).$stateful?c:[a];break;case s.AssignmentExpression:W(a.left,b);W(a.right,b);a.constant=a.left.constant&&a.right.constant; +a.toWatch=[a];break;case s.ArrayExpression:d=!0;c=[];n(a.elements,function(a){W(a,b);d=d&&a.constant;a.constant||c.push.apply(c,a.toWatch)});a.constant=d;a.toWatch=c;break;case s.ObjectExpression:d=!0;c=[];n(a.properties,function(a){W(a.value,b);d=d&&a.value.constant;a.value.constant||c.push.apply(c,a.value.toWatch)});a.constant=d;a.toWatch=c;break;case s.ThisExpression:a.constant=!1,a.toWatch=[]}}function nd(a){if(1==a.length){a=a[0].expression;var b=a.toWatch;return 1!==b.length?b:b[0]!==a?b:u}} +function od(a){return a.type===s.Identifier||a.type===s.MemberExpression}function pd(a){if(1===a.body.length&&od(a.body[0].expression))return{type:s.AssignmentExpression,left:a.body[0].expression,right:{type:s.NGValueParameter},operator:"="}}function qd(a){return 0===a.body.length||1===a.body.length&&(a.body[0].expression.type===s.Literal||a.body[0].expression.type===s.ArrayExpression||a.body[0].expression.type===s.ObjectExpression)}function rd(a,b){this.astBuilder=a;this.$filter=b}function sd(a, +b){this.astBuilder=a;this.$filter=b}function Fb(a){return"constructor"==a}function ec(a){return z(a.valueOf)?a.valueOf():$f.call(a)}function kf(){var a=$(),b=$();this.$get=["$filter",function(d){function c(a,b){return null==a||null==b?a===b:"object"===typeof a&&(a=ec(a),"object"===typeof a)?!1:a===b||a!==a&&b!==b}function e(a,b,d,e,f){var g=e.inputs,h;if(1===g.length){var k=c,g=g[0];return a.$watch(function(a){var b=g(a);c(b,k)||(h=e(a,u,u,[b]),k=b&&ec(b));return h},b,d,f)}for(var l=[],m=[],r=0,n= +g.length;r=this.promise.$$state.status&&d&&d.length&&a(function(){for(var a,e,f=0,g=d.length;fa)for(b in l++,f)qa.call(e,b)||(n--,delete f[b])}else f!==e&&(f=e,l++);return l}}c.$stateful=!0;var d=this,e,f,g,k=1n&&(v=4-n,q[v]||(q[v]=[]),q[v].push({msg:z(a.exp)?"fn: "+(a.exp.name||a.exp.toString()):a.exp,newVal:f,oldVal:h}));else if(a===c){r=!1;break a}}catch(y){g(y)}if(!(l=A.$$watchersCount&&A.$$childHead||A!==this&&A.$$nextSibling))for(;A!==this&&!(l=A.$$nextSibling);)A=A.$parent}while(A=l);if((r||u.length)&&!n--)throw w.$$phase=null,d("infdig", +b,q);}while(r||u.length);for(w.$$phase=null;L.length;)try{L.shift()()}catch(x){g(x)}},$destroy:function(){if(!this.$$destroyed){var a=this.$parent;this.$broadcast("$destroy");this.$$destroyed=!0;this===w&&k.$$applicationDestroyed();A(this,-this.$$watchersCount);for(var b in this.$$listenerCount)v(this,this.$$listenerCount[b],b);a&&a.$$childHead==this&&(a.$$childHead=this.$$nextSibling);a&&a.$$childTail==this&&(a.$$childTail=this.$$prevSibling);this.$$prevSibling&&(this.$$prevSibling.$$nextSibling= +this.$$nextSibling);this.$$nextSibling&&(this.$$nextSibling.$$prevSibling=this.$$prevSibling);this.$destroy=this.$digest=this.$apply=this.$evalAsync=this.$applyAsync=x;this.$on=this.$watch=this.$watchGroup=function(){return x};this.$$listeners={};this.$$nextSibling=null;m(this)}},$eval:function(a,b){return h(a)(this,b)},$evalAsync:function(a,b){w.$$phase||u.length||k.defer(function(){u.length&&w.$digest()});u.push({scope:this,expression:a,locals:b})},$$postDigest:function(a){L.push(a)},$apply:function(a){try{t("$apply"); +try{return this.$eval(a)}finally{w.$$phase=null}}catch(b){g(b)}finally{try{w.$digest()}catch(c){throw g(c),c;}}},$applyAsync:function(a){function b(){c.$eval(a)}var c=this;a&&aa.push(b);C()},$on:function(a,b){var c=this.$$listeners[a];c||(this.$$listeners[a]=c=[]);c.push(b);var d=this;do d.$$listenerCount[a]||(d.$$listenerCount[a]=0),d.$$listenerCount[a]++;while(d=d.$parent);var e=this;return function(){var d=c.indexOf(b);-1!==d&&(c[d]=null,v(e,1,a))}},$emit:function(a,b){var c=[],d,e=this,f=!1,h= +{name:a,targetScope:e,stopPropagation:function(){f=!0},preventDefault:function(){h.defaultPrevented=!0},defaultPrevented:!1},k=cb([h],arguments,1),l,m;do{d=e.$$listeners[a]||c;h.currentScope=e;l=0;for(m=d.length;lHa)throw ya("iequirks");var c=ia(la);c.isEnabled=function(){return a};c.trustAs=d.trustAs;c.getTrusted=d.getTrusted;c.valueOf=d.valueOf;a||(c.trustAs=c.getTrusted=function(a,b){return b},c.valueOf=Ya);c.parseAs=function(a,d){var e=b(d);return e.literal&&e.constant?e:b(d,function(b){return c.getTrusted(a,b)})};var e=c.parseAs,f=c.getTrusted,g=c.trustAs;n(la,function(a, +b){var d=F(b);c[fb("parse_as_"+d)]=function(b){return e(a,b)};c[fb("get_trusted_"+d)]=function(b){return f(a,b)};c[fb("trust_as_"+d)]=function(b){return g(a,b)}});return c}]}function qf(){this.$get=["$window","$document",function(a,b){var d={},c=ea((/android (\d+)/.exec(F((a.navigator||{}).userAgent))||[])[1]),e=/Boxee/i.test((a.navigator||{}).userAgent),f=b[0]||{},g,h=/^(Moz|webkit|ms)(?=[A-Z])/,k=f.body&&f.body.style,l=!1,m=!1;if(k){for(var r in k)if(l=h.exec(r)){g=l[0];g=g.substr(0,1).toUpperCase()+ +g.substr(1);break}g||(g="WebkitOpacity"in k&&"webkit");l=!!("transition"in k||g+"Transition"in k);m=!!("animation"in k||g+"Animation"in k);!c||l&&m||(l=E(k.webkitTransition),m=E(k.webkitAnimation))}return{history:!(!a.history||!a.history.pushState||4>c||e),hasEvent:function(a){if("input"===a&&11>=Ha)return!1;if(q(d[a])){var b=f.createElement("div");d[a]="on"+a in b}return d[a]},csp:Ba(),vendorPrefix:g,transitions:l,animations:m,android:c}}]}function sf(){this.$get=["$templateCache","$http","$q","$sce", +function(a,b,d,c){function e(f,g){e.totalPendingRequests++;E(f)&&a.get(f)||(f=c.getTrustedResourceUrl(f));var h=b.defaults&&b.defaults.transformResponse;I(h)?h=h.filter(function(a){return a!==$b}):h===$b&&(h=null);return b.get(f,{cache:a,transformResponse:h})["finally"](function(){e.totalPendingRequests--}).then(function(b){a.put(f,b.data);return b.data},function(a){if(!g)throw ha("tpload",f,a.status,a.statusText);return d.reject(a)})}e.totalPendingRequests=0;return e}]}function tf(){this.$get=["$rootScope", +"$browser","$location",function(a,b,d){return{findBindings:function(a,b,d){a=a.getElementsByClassName("ng-binding");var g=[];n(a,function(a){var c=fa.element(a).data("$binding");c&&n(c,function(c){d?(new RegExp("(^|\\s)"+ud(b)+"(\\s|\\||$)")).test(c)&&g.push(a):-1!=c.indexOf(b)&&g.push(a)})});return g},findModels:function(a,b,d){for(var g=["ng-","data-ng-","ng\\:"],h=0;ha;a=Math.abs(a);var g=Infinity===a;if(!g&&!isFinite(a))return"";var h=a+"",k="",l=!1,m=[];g&&(k="\u221e");if(!g&&-1!==h.indexOf("e")){var r=h.match(/([\d\.]+)e(-?)(\d+)/);r&&"-"==r[2]&&r[3]>e+1?a=0:(k=h,l=!0)}if(g||l)0a&&(k=a.toFixed(e),a=parseFloat(k),k=k.replace(ic,c));else{g=(h.split(ic)[1]||"").length; +q(e)&&(e=Math.min(Math.max(b.minFrac,g),b.maxFrac));a=+(Math.round(+(a.toString()+"e"+e)).toString()+"e"+-e);var g=(""+a).split(ic),h=g[0],g=g[1]||"",r=0,t=b.lgSize,n=b.gSize;if(h.length>=t+n)for(r=h.length-t,l=0;la&&(c="-",a=-a);for(a=""+a;a.length-d)e+=d;0===e&&-12==d&&(e=12);return Gb(e,b,c)}}function Hb(a,b){return function(d,c){var e=d["get"+a](),f=sb(b?"SHORT"+a:a);return c[f][e]}}function Dd(a){var b=(new Date(a,0,1)).getDay();return new Date(a,0,(4>=b?5:12)-b)}function Ed(a){return function(b){var d=Dd(b.getFullYear());b=+new Date(b.getFullYear(),b.getMonth(),b.getDate()+(4-b.getDay()))- ++d;b=1+Math.round(b/6048E5);return Gb(b,a)}}function jc(a,b){return 0>=a.getFullYear()?b.ERAS[0]:b.ERAS[1]}function zd(a){function b(a){var b;if(b=a.match(d)){a=new Date(0);var f=0,g=0,h=b[8]?a.setUTCFullYear:a.setFullYear,k=b[8]?a.setUTCHours:a.setHours;b[9]&&(f=ea(b[9]+b[10]),g=ea(b[9]+b[11]));h.call(a,ea(b[1]),ea(b[2])-1,ea(b[3]));f=ea(b[4]||0)-f;g=ea(b[5]||0)-g;h=ea(b[6]||0);b=Math.round(1E3*parseFloat("0."+(b[7]||0)));k.call(a,f,g,h,b)}return a}var d=/^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/; +return function(c,d,f){var g="",h=[],k,l;d=d||"mediumDate";d=a.DATETIME_FORMATS[d]||d;E(c)&&(c=hg.test(c)?ea(c):b(c));Q(c)&&(c=new Date(c));if(!da(c)||!isFinite(c.getTime()))return c;for(;d;)(l=ig.exec(d))?(h=cb(h,l,1),d=h.pop()):(h.push(d),d=null);var m=c.getTimezoneOffset();f&&(m=vc(f,c.getTimezoneOffset()),c=Pb(c,f,!0));n(h,function(b){k=jg[b];g+=k?k(c,a.DATETIME_FORMATS,m):b.replace(/(^'|'$)/g,"").replace(/''/g,"'")});return g}}function cg(){return function(a,b){q(b)&&(b=2);return db(a,b)}}function dg(){return function(a, +b,d){b=Infinity===Math.abs(Number(b))?Number(b):ea(b);if(isNaN(b))return a;Q(a)&&(a=a.toString());if(!I(a)&&!E(a))return a;d=!d||isNaN(d)?0:ea(d);d=0>d?Math.max(0,a.length+d):d;return 0<=b?a.slice(d,d+b):0===d?a.slice(b,a.length):a.slice(Math.max(0,d+b),d)}}function Bd(a){function b(b,d){d=d?-1:1;return b.map(function(b){var c=1,h=Ya;if(z(b))h=b;else if(E(b)){if("+"==b.charAt(0)||"-"==b.charAt(0))c="-"==b.charAt(0)?-1:1,b=b.substring(1);if(""!==b&&(h=a(b),h.constant))var k=h(),h=function(a){return a[k]}}return{get:h, +descending:c*d}})}function d(a){switch(typeof a){case "number":case "boolean":case "string":return!0;default:return!1}}return function(a,e,f){if(!za(a))return a;I(e)||(e=[e]);0===e.length&&(e=["+"]);var g=b(e,f);g.push({get:function(){return{}},descending:f?-1:1});a=Array.prototype.map.call(a,function(a,b){return{value:a,predicateValues:g.map(function(c){var e=c.get(a);c=typeof e;if(null===e)c="string",e="null";else if("string"===c)e=e.toLowerCase();else if("object"===c)a:{if("function"===typeof e.valueOf&& +(e=e.valueOf(),d(e)))break a;if(qc(e)&&(e=e.toString(),d(e)))break a;e=b}return{value:e,type:c}})}});a.sort(function(a,b){for(var c=0,d=0,e=g.length;db||37<=b&&40>=b||m(a,this,this.value)});if(e.hasEvent("paste"))b.on("paste cut", +m)}b.on("change",k);c.$render=function(){var a=c.$isEmpty(c.$viewValue)?"":c.$viewValue;b.val()!==a&&b.val(a)}}function Kb(a,b){return function(d,c){var e,f;if(da(d))return d;if(E(d)){'"'==d.charAt(0)&&'"'==d.charAt(d.length-1)&&(d=d.substring(1,d.length-1));if(kg.test(d))return new Date(d);a.lastIndex=0;if(e=a.exec(d))return e.shift(),f=c?{yyyy:c.getFullYear(),MM:c.getMonth()+1,dd:c.getDate(),HH:c.getHours(),mm:c.getMinutes(),ss:c.getSeconds(),sss:c.getMilliseconds()/1E3}:{yyyy:1970,MM:1,dd:1,HH:0, +mm:0,ss:0,sss:0},n(e,function(a,c){c=s};g.$observe("min",function(a){s=n(a);h.$validate()})}if(y(g.max)||g.ngMax){var p;h.$validators.max=function(a){return!r(a)||q(p)||d(a)<=p};g.$observe("max",function(a){p=n(a);h.$validate()})}}}function Hd(a,b,d,c){(c.$$hasNativeValidators=H(b[0].validity))&&c.$parsers.push(function(a){var c=b.prop("validity")||{}; +return c.badInput&&!c.typeMismatch?u:a})}function Id(a,b,d,c,e){if(y(c)){a=a(c);if(!a.constant)throw lb("constexpr",d,c);return a(b)}return e}function lc(a,b){a="ngClass"+a;return["$animate",function(d){function c(a,b){var c=[],d=0;a:for(;d(?:<\/\1>|)$/,Tb=/<|&#?\w+;/, +Cf=/<([\w:-]+)/,Df=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,ka={option:[1,'"],thead:[1,"","
    "],col:[2,"","
    "],tr:[2,"","
    "],td:[3,"","
    "],_default:[0,"",""]};ka.optgroup=ka.option;ka.tbody=ka.tfoot=ka.colgroup=ka.caption=ka.thead;ka.th=ka.td;var Kf=Node.prototype.contains||function(a){return!!(this.compareDocumentPosition(a)& +16)},Pa=N.prototype={ready:function(a){function b(){d||(d=!0,a())}var d=!1;"complete"===X.readyState?setTimeout(b):(this.on("DOMContentLoaded",b),N(S).on("load",b))},toString:function(){var a=[];n(this,function(b){a.push(""+b)});return"["+a.join(", ")+"]"},eq:function(a){return 0<=a?B(this[a]):B(this[this.length+a])},length:0,push:mg,sort:[].sort,splice:[].splice},Cb={};n("multiple selected checked disabled readOnly required open".split(" "),function(a){Cb[F(a)]=a});var Rc={};n("input select option textarea button form details".split(" "), +function(a){Rc[a]=!0});var Zc={ngMinlength:"minlength",ngMaxlength:"maxlength",ngMin:"min",ngMax:"max",ngPattern:"pattern"};n({data:Wb,removeData:vb,hasData:function(a){for(var b in gb[a.ng339])return!0;return!1}},function(a,b){N[b]=a});n({data:Wb,inheritedData:Bb,scope:function(a){return B.data(a,"$scope")||Bb(a.parentNode||a,["$isolateScope","$scope"])},isolateScope:function(a){return B.data(a,"$isolateScope")||B.data(a,"$isolateScopeNoTemplate")},controller:Oc,injector:function(a){return Bb(a, +"$injector")},removeAttr:function(a,b){a.removeAttribute(b)},hasClass:yb,css:function(a,b,d){b=fb(b);if(y(d))a.style[b]=d;else return a.style[b]},attr:function(a,b,d){var c=a.nodeType;if(c!==Na&&2!==c&&8!==c)if(c=F(b),Cb[c])if(y(d))d?(a[b]=!0,a.setAttribute(b,c)):(a[b]=!1,a.removeAttribute(c));else return a[b]||(a.attributes.getNamedItem(b)||x).specified?c:u;else if(y(d))a.setAttribute(b,d);else if(a.getAttribute)return a=a.getAttribute(b,2),null===a?u:a},prop:function(a,b,d){if(y(d))a[b]=d;else return a[b]}, +text:function(){function a(a,d){if(q(d)){var c=a.nodeType;return 1===c||c===Na?a.textContent:""}a.textContent=d}a.$dv="";return a}(),val:function(a,b){if(q(b)){if(a.multiple&&"select"===ta(a)){var d=[];n(a.options,function(a){a.selected&&d.push(a.value||a.text)});return 0===d.length?null:d}return a.value}a.value=b},html:function(a,b){if(q(b))return a.innerHTML;ub(a,!0);a.innerHTML=b},empty:Pc},function(a,b){N.prototype[b]=function(b,c){var e,f,g=this.length;if(a!==Pc&&q(2==a.length&&a!==yb&&a!==Oc? +b:c)){if(H(b)){for(e=0;e <= >= && || ! = |".split(" "),function(a){Lb[a]=!0});var sg={n:"\n",f:"\f",r:"\r", +t:"\t",v:"\v","'":"'",'"':'"'},fc=function(a){this.options=a};fc.prototype={constructor:fc,lex:function(a){this.text=a;this.index=0;for(this.tokens=[];this.index=a&&"string"===typeof a},isWhitespace:function(a){return" "===a||"\r"===a|| +"\t"===a||"\n"===a||"\v"===a||"\u00a0"===a},isIdent:function(a){return"a"<=a&&"z">=a||"A"<=a&&"Z">=a||"_"===a||"$"===a},isExpOperator:function(a){return"-"===a||"+"===a||this.isNumber(a)},throwError:function(a,b,d){d=d||this.index;b=y(b)?"s "+b+"-"+this.index+" ["+this.text.substring(b,d)+"]":" "+d;throw ba("lexerr",a,b,this.text);},readNumber:function(){for(var a="",b=this.index;this.index","<=",">=");)a={type:s.BinaryExpression,operator:b.text,left:a,right:this.additive()};return a},additive:function(){for(var a=this.multiplicative(),b;b=this.expect("+","-");)a={type:s.BinaryExpression,operator:b.text,left:a,right:this.multiplicative()};return a},multiplicative:function(){for(var a=this.unary(),b;b=this.expect("*","/","%");)a={type:s.BinaryExpression,operator:b.text, +left:a,right:this.unary()};return a},unary:function(){var a;return(a=this.expect("+","-","!"))?{type:s.UnaryExpression,operator:a.text,prefix:!0,argument:this.unary()}:this.primary()},primary:function(){var a;this.expect("(")?(a=this.filterChain(),this.consume(")")):this.expect("[")?a=this.arrayDeclaration():this.expect("{")?a=this.object():this.constants.hasOwnProperty(this.peek().text)?a=bb(this.constants[this.consume().text]):this.peek().identifier?a=this.identifier():this.peek().constant?a=this.constant(): +this.throwError("not a primary expression",this.peek());for(var b;b=this.expect("(","[",".");)"("===b.text?(a={type:s.CallExpression,callee:a,arguments:this.parseArguments()},this.consume(")")):"["===b.text?(a={type:s.MemberExpression,object:a,property:this.expression(),computed:!0},this.consume("]")):"."===b.text?a={type:s.MemberExpression,object:a,property:this.identifier(),computed:!1}:this.throwError("IMPOSSIBLE");return a},filter:function(a){a=[a];for(var b={type:s.CallExpression,callee:this.identifier(), +arguments:a,filter:!0};this.expect(":");)a.push(this.expression());return b},parseArguments:function(){var a=[];if(")"!==this.peekToken().text){do a.push(this.expression());while(this.expect(","))}return a},identifier:function(){var a=this.consume();a.identifier||this.throwError("is not a valid identifier",a);return{type:s.Identifier,name:a.text}},constant:function(){return{type:s.Literal,value:this.consume().value}},arrayDeclaration:function(){var a=[];if("]"!==this.peekToken().text){do{if(this.peek("]"))break; +a.push(this.expression())}while(this.expect(","))}this.consume("]");return{type:s.ArrayExpression,elements:a}},object:function(){var a=[],b;if("}"!==this.peekToken().text){do{if(this.peek("}"))break;b={type:s.Property,kind:"init"};this.peek().constant?b.key=this.constant():this.peek().identifier?b.key=this.identifier():this.throwError("invalid key",this.peek());this.consume(":");b.value=this.expression();a.push(b)}while(this.expect(","))}this.consume("}");return{type:s.ObjectExpression,properties:a}}, +throwError:function(a,b){throw ba("syntax",b.text,a,b.index+1,this.text,this.text.substring(b.index));},consume:function(a){if(0===this.tokens.length)throw ba("ueoe",this.text);var b=this.expect(a);b||this.throwError("is unexpected, expecting ["+a+"]",this.peek());return b},peekToken:function(){if(0===this.tokens.length)throw ba("ueoe",this.text);return this.tokens[0]},peek:function(a,b,d,c){return this.peekAhead(0,a,b,d,c)},peekAhead:function(a,b,d,c,e){if(this.tokens.length>a){a=this.tokens[a]; +var f=a.text;if(f===b||f===d||f===c||f===e||!(b||d||c||e))return a}return!1},expect:function(a,b,d,c){return(a=this.peek(a,b,d,c))?(this.tokens.shift(),a):!1},constants:{"true":{type:s.Literal,value:!0},"false":{type:s.Literal,value:!1},"null":{type:s.Literal,value:null},undefined:{type:s.Literal,value:u},"this":{type:s.ThisExpression}}};rd.prototype={compile:function(a,b){var d=this,c=this.astBuilder.ast(a);this.state={nextId:0,filters:{},expensiveChecks:b,fn:{vars:[],body:[],own:{}},assign:{vars:[], +body:[],own:{}},inputs:[]};W(c,d.$filter);var e="",f;this.stage="assign";if(f=pd(c))this.state.computing="assign",e=this.nextId(),this.recurse(f,e),this.return_(e),e="fn.assign="+this.generateFunction("assign","s,v,l");f=nd(c.body);d.stage="inputs";n(f,function(a,b){var c="fn"+b;d.state[c]={vars:[],body:[],own:{}};d.state.computing=c;var e=d.nextId();d.recurse(a,e);d.return_(e);d.state.inputs.push(c);a.watchId=b});this.state.computing="fn";this.stage="main";this.recurse(c);e='"'+this.USE+" "+this.STRICT+ +'";\n'+this.filterPrefix()+"var fn="+this.generateFunction("fn","s,l,a,i")+e+this.watchFns()+"return fn;";e=(new Function("$filter","ensureSafeMemberName","ensureSafeObject","ensureSafeFunction","getStringValue","ensureSafeAssignContext","ifDefined","plus","text",e))(this.$filter,Va,xa,kd,jd,ld,Zf,md,a);this.state=this.stage=u;e.literal=qd(c);e.constant=c.constant;return e},USE:"use",STRICT:"strict",watchFns:function(){var a=[],b=this.state.inputs,d=this;n(b,function(b){a.push("var "+b+"="+d.generateFunction(b, +"s"))});b.length&&a.push("fn.inputs=["+b.join(",")+"];");return a.join("")},generateFunction:function(a,b){return"function("+b+"){"+this.varsPrefix(a)+this.body(a)+"};"},filterPrefix:function(){var a=[],b=this;n(this.state.filters,function(d,c){a.push(d+"=$filter("+b.escape(c)+")")});return a.length?"var "+a.join(",")+";":""},varsPrefix:function(a){return this.state[a].vars.length?"var "+this.state[a].vars.join(",")+";":""},body:function(a){return this.state[a].body.join("")},recurse:function(a,b, +d,c,e,f){var g,h,k=this,l,m;c=c||x;if(!f&&y(a.watchId))b=b||this.nextId(),this.if_("i",this.lazyAssign(b,this.computedMember("i",a.watchId)),this.lazyRecurse(a,b,d,c,e,!0));else switch(a.type){case s.Program:n(a.body,function(b,c){k.recurse(b.expression,u,u,function(a){h=a});c!==a.body.length-1?k.current().body.push(h,";"):k.return_(h)});break;case s.Literal:m=this.escape(a.value);this.assign(b,m);c(m);break;case s.UnaryExpression:this.recurse(a.argument,u,u,function(a){h=a});m=a.operator+"("+this.ifDefined(h, +0)+")";this.assign(b,m);c(m);break;case s.BinaryExpression:this.recurse(a.left,u,u,function(a){g=a});this.recurse(a.right,u,u,function(a){h=a});m="+"===a.operator?this.plus(g,h):"-"===a.operator?this.ifDefined(g,0)+a.operator+this.ifDefined(h,0):"("+g+")"+a.operator+"("+h+")";this.assign(b,m);c(m);break;case s.LogicalExpression:b=b||this.nextId();k.recurse(a.left,b);k.if_("&&"===a.operator?b:k.not(b),k.lazyRecurse(a.right,b));c(b);break;case s.ConditionalExpression:b=b||this.nextId();k.recurse(a.test, +b);k.if_(b,k.lazyRecurse(a.alternate,b),k.lazyRecurse(a.consequent,b));c(b);break;case s.Identifier:b=b||this.nextId();d&&(d.context="inputs"===k.stage?"s":this.assign(this.nextId(),this.getHasOwnProperty("l",a.name)+"?l:s"),d.computed=!1,d.name=a.name);Va(a.name);k.if_("inputs"===k.stage||k.not(k.getHasOwnProperty("l",a.name)),function(){k.if_("inputs"===k.stage||"s",function(){e&&1!==e&&k.if_(k.not(k.nonComputedMember("s",a.name)),k.lazyAssign(k.nonComputedMember("s",a.name),"{}"));k.assign(b,k.nonComputedMember("s", +a.name))})},b&&k.lazyAssign(b,k.nonComputedMember("l",a.name)));(k.state.expensiveChecks||Fb(a.name))&&k.addEnsureSafeObject(b);c(b);break;case s.MemberExpression:g=d&&(d.context=this.nextId())||this.nextId();b=b||this.nextId();k.recurse(a.object,g,u,function(){k.if_(k.notNull(g),function(){if(a.computed)h=k.nextId(),k.recurse(a.property,h),k.getStringValue(h),k.addEnsureSafeMemberName(h),e&&1!==e&&k.if_(k.not(k.computedMember(g,h)),k.lazyAssign(k.computedMember(g,h),"{}")),m=k.ensureSafeObject(k.computedMember(g, +h)),k.assign(b,m),d&&(d.computed=!0,d.name=h);else{Va(a.property.name);e&&1!==e&&k.if_(k.not(k.nonComputedMember(g,a.property.name)),k.lazyAssign(k.nonComputedMember(g,a.property.name),"{}"));m=k.nonComputedMember(g,a.property.name);if(k.state.expensiveChecks||Fb(a.property.name))m=k.ensureSafeObject(m);k.assign(b,m);d&&(d.computed=!1,d.name=a.property.name)}},function(){k.assign(b,"undefined")});c(b)},!!e);break;case s.CallExpression:b=b||this.nextId();a.filter?(h=k.filter(a.callee.name),l=[],n(a.arguments, +function(a){var b=k.nextId();k.recurse(a,b);l.push(b)}),m=h+"("+l.join(",")+")",k.assign(b,m),c(b)):(h=k.nextId(),g={},l=[],k.recurse(a.callee,h,g,function(){k.if_(k.notNull(h),function(){k.addEnsureSafeFunction(h);n(a.arguments,function(a){k.recurse(a,k.nextId(),u,function(a){l.push(k.ensureSafeObject(a))})});g.name?(k.state.expensiveChecks||k.addEnsureSafeObject(g.context),m=k.member(g.context,g.name,g.computed)+"("+l.join(",")+")"):m=h+"("+l.join(",")+")";m=k.ensureSafeObject(m);k.assign(b,m)}, +function(){k.assign(b,"undefined")});c(b)}));break;case s.AssignmentExpression:h=this.nextId();g={};if(!od(a.left))throw ba("lval");this.recurse(a.left,u,g,function(){k.if_(k.notNull(g.context),function(){k.recurse(a.right,h);k.addEnsureSafeObject(k.member(g.context,g.name,g.computed));k.addEnsureSafeAssignContext(g.context);m=k.member(g.context,g.name,g.computed)+a.operator+h;k.assign(b,m);c(b||m)})},1);break;case s.ArrayExpression:l=[];n(a.elements,function(a){k.recurse(a,k.nextId(),u,function(a){l.push(a)})}); +m="["+l.join(",")+"]";this.assign(b,m);c(m);break;case s.ObjectExpression:l=[];n(a.properties,function(a){k.recurse(a.value,k.nextId(),u,function(b){l.push(k.escape(a.key.type===s.Identifier?a.key.name:""+a.key.value)+":"+b)})});m="{"+l.join(",")+"}";this.assign(b,m);c(m);break;case s.ThisExpression:this.assign(b,"s");c("s");break;case s.NGValueParameter:this.assign(b,"v"),c("v")}},getHasOwnProperty:function(a,b){var d=a+"."+b,c=this.current().own;c.hasOwnProperty(d)||(c[d]=this.nextId(!1,a+"&&("+ +this.escape(b)+" in "+a+")"));return c[d]},assign:function(a,b){if(a)return this.current().body.push(a,"=",b,";"),a},filter:function(a){this.state.filters.hasOwnProperty(a)||(this.state.filters[a]=this.nextId(!0));return this.state.filters[a]},ifDefined:function(a,b){return"ifDefined("+a+","+this.escape(b)+")"},plus:function(a,b){return"plus("+a+","+b+")"},return_:function(a){this.current().body.push("return ",a,";")},if_:function(a,b,d){if(!0===a)b();else{var c=this.current().body;c.push("if(",a, +"){");b();c.push("}");d&&(c.push("else{"),d(),c.push("}"))}},not:function(a){return"!("+a+")"},notNull:function(a){return a+"!=null"},nonComputedMember:function(a,b){return a+"."+b},computedMember:function(a,b){return a+"["+b+"]"},member:function(a,b,d){return d?this.computedMember(a,b):this.nonComputedMember(a,b)},addEnsureSafeObject:function(a){this.current().body.push(this.ensureSafeObject(a),";")},addEnsureSafeMemberName:function(a){this.current().body.push(this.ensureSafeMemberName(a),";")}, +addEnsureSafeFunction:function(a){this.current().body.push(this.ensureSafeFunction(a),";")},addEnsureSafeAssignContext:function(a){this.current().body.push(this.ensureSafeAssignContext(a),";")},ensureSafeObject:function(a){return"ensureSafeObject("+a+",text)"},ensureSafeMemberName:function(a){return"ensureSafeMemberName("+a+",text)"},ensureSafeFunction:function(a){return"ensureSafeFunction("+a+",text)"},getStringValue:function(a){this.assign(a,"getStringValue("+a+",text)")},ensureSafeAssignContext:function(a){return"ensureSafeAssignContext("+ +a+",text)"},lazyRecurse:function(a,b,d,c,e,f){var g=this;return function(){g.recurse(a,b,d,c,e,f)}},lazyAssign:function(a,b){var d=this;return function(){d.assign(a,b)}},stringEscapeRegex:/[^ a-zA-Z0-9]/g,stringEscapeFn:function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)},escape:function(a){if(E(a))return"'"+a.replace(this.stringEscapeRegex,this.stringEscapeFn)+"'";if(Q(a))return a.toString();if(!0===a)return"true";if(!1===a)return"false";if(null===a)return"null";if("undefined"=== +typeof a)return"undefined";throw ba("esc");},nextId:function(a,b){var d="v"+this.state.nextId++;a||this.current().vars.push(d+(b?"="+b:""));return d},current:function(){return this.state[this.state.computing]}};sd.prototype={compile:function(a,b){var d=this,c=this.astBuilder.ast(a);this.expression=a;this.expensiveChecks=b;W(c,d.$filter);var e,f;if(e=pd(c))f=this.recurse(e);e=nd(c.body);var g;e&&(g=[],n(e,function(a,b){var c=d.recurse(a);a.input=c;g.push(c);a.watchId=b}));var h=[];n(c.body,function(a){h.push(d.recurse(a.expression))}); +e=0===c.body.length?function(){}:1===c.body.length?h[0]:function(a,b){var c;n(h,function(d){c=d(a,b)});return c};f&&(e.assign=function(a,b,c){return f(a,c,b)});g&&(e.inputs=g);e.literal=qd(c);e.constant=c.constant;return e},recurse:function(a,b,d){var c,e,f=this,g;if(a.input)return this.inputs(a.input,a.watchId);switch(a.type){case s.Literal:return this.value(a.value,b);case s.UnaryExpression:return e=this.recurse(a.argument),this["unary"+a.operator](e,b);case s.BinaryExpression:return c=this.recurse(a.left), +e=this.recurse(a.right),this["binary"+a.operator](c,e,b);case s.LogicalExpression:return c=this.recurse(a.left),e=this.recurse(a.right),this["binary"+a.operator](c,e,b);case s.ConditionalExpression:return this["ternary?:"](this.recurse(a.test),this.recurse(a.alternate),this.recurse(a.consequent),b);case s.Identifier:return Va(a.name,f.expression),f.identifier(a.name,f.expensiveChecks||Fb(a.name),b,d,f.expression);case s.MemberExpression:return c=this.recurse(a.object,!1,!!d),a.computed||(Va(a.property.name, +f.expression),e=a.property.name),a.computed&&(e=this.recurse(a.property)),a.computed?this.computedMember(c,e,b,d,f.expression):this.nonComputedMember(c,e,f.expensiveChecks,b,d,f.expression);case s.CallExpression:return g=[],n(a.arguments,function(a){g.push(f.recurse(a))}),a.filter&&(e=this.$filter(a.callee.name)),a.filter||(e=this.recurse(a.callee,!0)),a.filter?function(a,c,d,f){for(var r=[],n=0;n":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)>b(c,e,f,g);return d?{value:c}:c}},"binary<=":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)<=b(c,e,f,g);return d?{value:c}:c}},"binary>=":function(a,b,d){return function(c, +e,f,g){c=a(c,e,f,g)>=b(c,e,f,g);return d?{value:c}:c}},"binary&&":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)&&b(c,e,f,g);return d?{value:c}:c}},"binary||":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)||b(c,e,f,g);return d?{value:c}:c}},"ternary?:":function(a,b,d,c){return function(e,f,g,h){e=a(e,f,g,h)?b(e,f,g,h):d(e,f,g,h);return c?{value:e}:e}},value:function(a,b){return function(){return b?{context:u,name:u,value:a}:a}},identifier:function(a,b,d,c,e){return function(f,g,h,k){f= +g&&a in g?g:f;c&&1!==c&&f&&!f[a]&&(f[a]={});g=f?f[a]:u;b&&xa(g,e);return d?{context:f,name:a,value:g}:g}},computedMember:function(a,b,d,c,e){return function(f,g,h,k){var l=a(f,g,h,k),m,n;null!=l&&(m=b(f,g,h,k),m=jd(m),Va(m,e),c&&1!==c&&l&&!l[m]&&(l[m]={}),n=l[m],xa(n,e));return d?{context:l,name:m,value:n}:n}},nonComputedMember:function(a,b,d,c,e,f){return function(g,h,k,l){g=a(g,h,k,l);e&&1!==e&&g&&!g[b]&&(g[b]={});h=null!=g?g[b]:u;(d||Fb(b))&&xa(h,f);return c?{context:g,name:b,value:h}:h}},inputs:function(a, +b){return function(d,c,e,f){return f?f[b]:a(d,c,e)}}};var gc=function(a,b,d){this.lexer=a;this.$filter=b;this.options=d;this.ast=new s(this.lexer);this.astCompiler=d.csp?new sd(this.ast,b):new rd(this.ast,b)};gc.prototype={constructor:gc,parse:function(a){return this.astCompiler.compile(a,this.options.expensiveChecks)}};$();$();var $f=Object.prototype.valueOf,ya=G("$sce"),la={HTML:"html",CSS:"css",URL:"url",RESOURCE_URL:"resourceUrl",JS:"js"},ha=G("$compile"),Y=X.createElement("a"),wd=wa(S.location.href); +xd.$inject=["$document"];Jc.$inject=["$provide"];yd.$inject=["$locale"];Ad.$inject=["$locale"];var ic=".",jg={yyyy:ca("FullYear",4),yy:ca("FullYear",2,0,!0),y:ca("FullYear",1),MMMM:Hb("Month"),MMM:Hb("Month",!0),MM:ca("Month",2,1),M:ca("Month",1,1),dd:ca("Date",2),d:ca("Date",1),HH:ca("Hours",2),H:ca("Hours",1),hh:ca("Hours",2,-12),h:ca("Hours",1,-12),mm:ca("Minutes",2),m:ca("Minutes",1),ss:ca("Seconds",2),s:ca("Seconds",1),sss:ca("Milliseconds",3),EEEE:Hb("Day"),EEE:Hb("Day",!0),a:function(a,b){return 12> +a.getHours()?b.AMPMS[0]:b.AMPMS[1]},Z:function(a,b,d){a=-1*d;return a=(0<=a?"+":"")+(Gb(Math[0=a.getFullYear()?b.ERANAMES[0]:b.ERANAMES[1]}},ig=/((?:[^yMdHhmsaZEwG']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z|G+|w+))(.*)/,hg=/^\-?\d+$/;zd.$inject=["$locale"];var eg=na(F),fg=na(sb);Bd.$inject=["$parse"];var he=na({restrict:"E",compile:function(a,b){if(!b.href&&!b.xlinkHref)return function(a, +b){if("a"===b[0].nodeName.toLowerCase()){var e="[object SVGAnimatedString]"===sa.call(b.prop("href"))?"xlink:href":"href";b.on("click",function(a){b.attr(e)||a.preventDefault()})}}}}),tb={};n(Cb,function(a,b){function d(a,d,e){a.$watch(e[c],function(a){e.$set(b,!!a)})}if("multiple"!=a){var c=va("ng-"+b),e=d;"checked"===a&&(e=function(a,b,e){e.ngModel!==e[c]&&d(a,b,e)});tb[c]=function(){return{restrict:"A",priority:100,link:e}}}});n(Zc,function(a,b){tb[b]=function(){return{priority:100,link:function(a, +c,e){if("ngPattern"===b&&"/"==e.ngPattern.charAt(0)&&(c=e.ngPattern.match(lg))){e.$set("ngPattern",new RegExp(c[1],c[2]));return}a.$watch(e[b],function(a){e.$set(b,a)})}}}});n(["src","srcset","href"],function(a){var b=va("ng-"+a);tb[b]=function(){return{priority:99,link:function(d,c,e){var f=a,g=a;"href"===a&&"[object SVGAnimatedString]"===sa.call(c.prop("href"))&&(g="xlinkHref",e.$attr[g]="xlink:href",f=null);e.$observe(b,function(b){b?(e.$set(g,b),Ha&&f&&c.prop(f,e[g])):"href"===a&&e.$set(g,null)})}}}}); +var Ib={$addControl:x,$$renameControl:function(a,b){a.$name=b},$removeControl:x,$setValidity:x,$setDirty:x,$setPristine:x,$setSubmitted:x};Fd.$inject=["$element","$attrs","$scope","$animate","$interpolate"];var Nd=function(a){return["$timeout","$parse",function(b,d){function c(a){return""===a?d('this[""]').assign:d(a).assign||x}return{name:"form",restrict:a?"EAC":"E",require:["form","^^?form"],controller:Fd,compile:function(d,f){d.addClass(Wa).addClass(mb);var g=f.name?"name":a&&f.ngForm?"ngForm": +!1;return{pre:function(a,d,e,f){var n=f[0];if(!("action"in e)){var q=function(b){a.$apply(function(){n.$commitViewValue();n.$setSubmitted()});b.preventDefault()};d[0].addEventListener("submit",q,!1);d.on("$destroy",function(){b(function(){d[0].removeEventListener("submit",q,!1)},0,!1)})}(f[1]||n.$$parentForm).$addControl(n);var s=g?c(n.$name):x;g&&(s(a,n),e.$observe(g,function(b){n.$name!==b&&(s(a,u),n.$$parentForm.$$renameControl(n,b),s=c(n.$name),s(a,n))}));d.on("$destroy",function(){n.$$parentForm.$removeControl(n); +s(a,u);M(n,Ib)})}}}}}]},ie=Nd(),ve=Nd(!0),kg=/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/,tg=/^[A-Za-z][A-Za-z\d.+-]*:\/*(?:\w+(?::\w+)?@)?[^\s/]+(?::\d+)?(?:\/[\w#!:.?+=&%@\-/]*)?$/,ug=/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i,vg=/^\s*(\-|\+)?(\d+|(\d*(\.\d*)))([eE][+-]?\d+)?\s*$/,Od=/^(\d{4})-(\d{2})-(\d{2})$/,Pd=/^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d)(?::(\d\d)(\.\d{1,3})?)?$/,mc=/^(\d{4})-W(\d\d)$/,Qd=/^(\d{4})-(\d\d)$/, +Rd=/^(\d\d):(\d\d)(?::(\d\d)(\.\d{1,3})?)?$/,Sd={text:function(a,b,d,c,e,f){jb(a,b,d,c,e,f);kc(c)},date:kb("date",Od,Kb(Od,["yyyy","MM","dd"]),"yyyy-MM-dd"),"datetime-local":kb("datetimelocal",Pd,Kb(Pd,"yyyy MM dd HH mm ss sss".split(" ")),"yyyy-MM-ddTHH:mm:ss.sss"),time:kb("time",Rd,Kb(Rd,["HH","mm","ss","sss"]),"HH:mm:ss.sss"),week:kb("week",mc,function(a,b){if(da(a))return a;if(E(a)){mc.lastIndex=0;var d=mc.exec(a);if(d){var c=+d[1],e=+d[2],f=d=0,g=0,h=0,k=Dd(c),e=7*(e-1);b&&(d=b.getHours(),f= +b.getMinutes(),g=b.getSeconds(),h=b.getMilliseconds());return new Date(c,0,k.getDate()+e,d,f,g,h)}}return NaN},"yyyy-Www"),month:kb("month",Qd,Kb(Qd,["yyyy","MM"]),"yyyy-MM"),number:function(a,b,d,c,e,f){Hd(a,b,d,c);jb(a,b,d,c,e,f);c.$$parserName="number";c.$parsers.push(function(a){return c.$isEmpty(a)?null:vg.test(a)?parseFloat(a):u});c.$formatters.push(function(a){if(!c.$isEmpty(a)){if(!Q(a))throw lb("numfmt",a);a=a.toString()}return a});if(y(d.min)||d.ngMin){var g;c.$validators.min=function(a){return c.$isEmpty(a)|| +q(g)||a>=g};d.$observe("min",function(a){y(a)&&!Q(a)&&(a=parseFloat(a,10));g=Q(a)&&!isNaN(a)?a:u;c.$validate()})}if(y(d.max)||d.ngMax){var h;c.$validators.max=function(a){return c.$isEmpty(a)||q(h)||a<=h};d.$observe("max",function(a){y(a)&&!Q(a)&&(a=parseFloat(a,10));h=Q(a)&&!isNaN(a)?a:u;c.$validate()})}},url:function(a,b,d,c,e,f){jb(a,b,d,c,e,f);kc(c);c.$$parserName="url";c.$validators.url=function(a,b){var d=a||b;return c.$isEmpty(d)||tg.test(d)}},email:function(a,b,d,c,e,f){jb(a,b,d,c,e,f);kc(c); +c.$$parserName="email";c.$validators.email=function(a,b){var d=a||b;return c.$isEmpty(d)||ug.test(d)}},radio:function(a,b,d,c){q(d.name)&&b.attr("name",++nb);b.on("click",function(a){b[0].checked&&c.$setViewValue(d.value,a&&a.type)});c.$render=function(){b[0].checked=d.value==c.$viewValue};d.$observe("value",c.$render)},checkbox:function(a,b,d,c,e,f,g,h){var k=Id(h,a,"ngTrueValue",d.ngTrueValue,!0),l=Id(h,a,"ngFalseValue",d.ngFalseValue,!1);b.on("click",function(a){c.$setViewValue(b[0].checked,a&& +a.type)});c.$render=function(){b[0].checked=c.$viewValue};c.$isEmpty=function(a){return!1===a};c.$formatters.push(function(a){return ma(a,k)});c.$parsers.push(function(a){return a?k:l})},hidden:x,button:x,submit:x,reset:x,file:x},Dc=["$browser","$sniffer","$filter","$parse",function(a,b,d,c){return{restrict:"E",require:["?ngModel"],link:{pre:function(e,f,g,h){h[0]&&(Sd[F(g.type)]||Sd.text)(e,f,g,h[0],b,a,d,c)}}}}],wg=/^(true|false|\d+)$/,Ne=function(){return{restrict:"A",priority:100,compile:function(a, +b){return wg.test(b.ngValue)?function(a,b,e){e.$set("value",a.$eval(e.ngValue))}:function(a,b,e){a.$watch(e.ngValue,function(a){e.$set("value",a)})}}}},ne=["$compile",function(a){return{restrict:"AC",compile:function(b){a.$$addBindingClass(b);return function(b,c,e){a.$$addBindingInfo(c,e.ngBind);c=c[0];b.$watch(e.ngBind,function(a){c.textContent=q(a)?"":a})}}}}],pe=["$interpolate","$compile",function(a,b){return{compile:function(d){b.$$addBindingClass(d);return function(c,d,f){c=a(d.attr(f.$attr.ngBindTemplate)); +b.$$addBindingInfo(d,c.expressions);d=d[0];f.$observe("ngBindTemplate",function(a){d.textContent=q(a)?"":a})}}}}],oe=["$sce","$parse","$compile",function(a,b,d){return{restrict:"A",compile:function(c,e){var f=b(e.ngBindHtml),g=b(e.ngBindHtml,function(a){return(a||"").toString()});d.$$addBindingClass(c);return function(b,c,e){d.$$addBindingInfo(c,e.ngBindHtml);b.$watch(g,function(){c.html(a.getTrustedHtml(f(b))||"")})}}}}],Me=na({restrict:"A",require:"ngModel",link:function(a,b,d,c){c.$viewChangeListeners.push(function(){a.$eval(d.ngChange)})}}), +qe=lc("",!0),se=lc("Odd",0),re=lc("Even",1),te=La({compile:function(a,b){b.$set("ngCloak",u);a.removeClass("ng-cloak")}}),ue=[function(){return{restrict:"A",scope:!0,controller:"@",priority:500}}],Ic={},xg={blur:!0,focus:!0};n("click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress submit focus blur copy cut paste".split(" "),function(a){var b=va("ng-"+a);Ic[b]=["$parse","$rootScope",function(d,c){return{restrict:"A",compile:function(e,f){var g= +d(f[b],null,!0);return function(b,d){d.on(a,function(d){var e=function(){g(b,{$event:d})};xg[a]&&c.$$phase?b.$evalAsync(e):b.$apply(e)})}}}}]});var xe=["$animate",function(a){return{multiElement:!0,transclude:"element",priority:600,terminal:!0,restrict:"A",$$tlb:!0,link:function(b,d,c,e,f){var g,h,k;b.$watch(c.ngIf,function(b){b?h||f(function(b,e){h=e;b[b.length++]=X.createComment(" end ngIf: "+c.ngIf+" ");g={clone:b};a.enter(b,d.parent(),d)}):(k&&(k.remove(),k=null),h&&(h.$destroy(),h=null),g&&(k= +rb(g.clone),a.leave(k).then(function(){k=null}),g=null))})}}}],ye=["$templateRequest","$anchorScroll","$animate",function(a,b,d){return{restrict:"ECA",priority:400,terminal:!0,transclude:"element",controller:fa.noop,compile:function(c,e){var f=e.ngInclude||e.src,g=e.onload||"",h=e.autoscroll;return function(c,e,m,n,q){var s=0,v,u,p,C=function(){u&&(u.remove(),u=null);v&&(v.$destroy(),v=null);p&&(d.leave(p).then(function(){u=null}),u=p,p=null)};c.$watch(f,function(f){var m=function(){!y(h)||h&&!c.$eval(h)|| +b()},u=++s;f?(a(f,!0).then(function(a){if(u===s){var b=c.$new();n.template=a;a=q(b,function(a){C();d.enter(a,null,e).then(m)});v=b;p=a;v.$emit("$includeContentLoaded",f);c.$eval(g)}},function(){u===s&&(C(),c.$emit("$includeContentError",f))}),c.$emit("$includeContentRequested",f)):(C(),n.template=null)})}}}}],Pe=["$compile",function(a){return{restrict:"ECA",priority:-400,require:"ngInclude",link:function(b,d,c,e){/SVG/.test(d[0].toString())?(d.empty(),a(Lc(e.template,X).childNodes)(b,function(a){d.append(a)}, +{futureParentElement:d})):(d.html(e.template),a(d.contents())(b))}}}],ze=La({priority:450,compile:function(){return{pre:function(a,b,d){a.$eval(d.ngInit)}}}}),Le=function(){return{restrict:"A",priority:100,require:"ngModel",link:function(a,b,d,c){var e=b.attr(d.$attr.ngList)||", ",f="false"!==d.ngTrim,g=f?U(e):e;c.$parsers.push(function(a){if(!q(a)){var b=[];a&&n(a.split(g),function(a){a&&b.push(f?U(a):a)});return b}});c.$formatters.push(function(a){return I(a)?a.join(e):u});c.$isEmpty=function(a){return!a|| +!a.length}}}},mb="ng-valid",Jd="ng-invalid",Wa="ng-pristine",Jb="ng-dirty",Ld="ng-pending",lb=G("ngModel"),yg=["$scope","$exceptionHandler","$attrs","$element","$parse","$animate","$timeout","$rootScope","$q","$interpolate",function(a,b,d,c,e,f,g,h,k,l){this.$modelValue=this.$viewValue=Number.NaN;this.$$rawModelValue=u;this.$validators={};this.$asyncValidators={};this.$parsers=[];this.$formatters=[];this.$viewChangeListeners=[];this.$untouched=!0;this.$touched=!1;this.$pristine=!0;this.$dirty=!1; +this.$valid=!0;this.$invalid=!1;this.$error={};this.$$success={};this.$pending=u;this.$name=l(d.name||"",!1)(a);this.$$parentForm=Ib;var m=e(d.ngModel),r=m.assign,t=m,s=r,v=null,B,p=this;this.$$setOptions=function(a){if((p.$options=a)&&a.getterSetter){var b=e(d.ngModel+"()"),f=e(d.ngModel+"($$$p)");t=function(a){var c=m(a);z(c)&&(c=b(a));return c};s=function(a,b){z(m(a))?f(a,{$$$p:p.$modelValue}):r(a,p.$modelValue)}}else if(!m.assign)throw lb("nonassign",d.ngModel,ua(c));};this.$render=x;this.$isEmpty= +function(a){return q(a)||""===a||null===a||a!==a};var C=0;Gd({ctrl:this,$element:c,set:function(a,b){a[b]=!0},unset:function(a,b){delete a[b]},$animate:f});this.$setPristine=function(){p.$dirty=!1;p.$pristine=!0;f.removeClass(c,Jb);f.addClass(c,Wa)};this.$setDirty=function(){p.$dirty=!0;p.$pristine=!1;f.removeClass(c,Wa);f.addClass(c,Jb);p.$$parentForm.$setDirty()};this.$setUntouched=function(){p.$touched=!1;p.$untouched=!0;f.setClass(c,"ng-untouched","ng-touched")};this.$setTouched=function(){p.$touched= +!0;p.$untouched=!1;f.setClass(c,"ng-touched","ng-untouched")};this.$rollbackViewValue=function(){g.cancel(v);p.$viewValue=p.$$lastCommittedViewValue;p.$render()};this.$validate=function(){if(!Q(p.$modelValue)||!isNaN(p.$modelValue)){var a=p.$$rawModelValue,b=p.$valid,c=p.$modelValue,d=p.$options&&p.$options.allowInvalid;p.$$runValidators(a,p.$$lastCommittedViewValue,function(e){d||b===e||(p.$modelValue=e?a:u,p.$modelValue!==c&&p.$$writeModelToScope())})}};this.$$runValidators=function(a,b,c){function d(){var c= +!0;n(p.$validators,function(d,e){var g=d(a,b);c=c&&g;f(e,g)});return c?!0:(n(p.$asyncValidators,function(a,b){f(b,null)}),!1)}function e(){var c=[],d=!0;n(p.$asyncValidators,function(e,g){var h=e(a,b);if(!h||!z(h.then))throw lb("$asyncValidators",h);f(g,u);c.push(h.then(function(){f(g,!0)},function(a){d=!1;f(g,!1)}))});c.length?k.all(c).then(function(){g(d)},x):g(!0)}function f(a,b){h===C&&p.$setValidity(a,b)}function g(a){h===C&&c(a)}C++;var h=C;(function(){var a=p.$$parserName||"parse";if(q(B))f(a, +null);else return B||(n(p.$validators,function(a,b){f(b,null)}),n(p.$asyncValidators,function(a,b){f(b,null)})),f(a,B),B;return!0})()?d()?e():g(!1):g(!1)};this.$commitViewValue=function(){var a=p.$viewValue;g.cancel(v);if(p.$$lastCommittedViewValue!==a||""===a&&p.$$hasNativeValidators)p.$$lastCommittedViewValue=a,p.$pristine&&this.$setDirty(),this.$$parseAndValidate()};this.$$parseAndValidate=function(){var b=p.$$lastCommittedViewValue;if(B=q(b)?u:!0)for(var c=0;ce||c.$isEmpty(b)||b.length<=e}}}}},Gc=function(){return{restrict:"A",require:"?ngModel",link:function(a,b,d,c){if(c){var e=0;d.$observe("minlength",function(a){e=ea(a)||0;c.$validate()});c.$validators.minlength=function(a,b){return c.$isEmpty(b)||b.length>=e}}}}};S.angular.bootstrap? +console.log("WARNING: Tried to load angular more than once."):(ce(),ee(fa),fa.module("ngLocale",[],["$provide",function(a){function b(a){a+="";var b=a.indexOf(".");return-1==b?0:a.length-b-1}a.value("$locale",{DATETIME_FORMATS:{AMPMS:["AM","PM"],DAY:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),ERANAMES:["Before Christ","Anno Domini"],ERAS:["BC","AD"],FIRSTDAYOFWEEK:6,MONTH:"January February March April May June July August September October November December".split(" "),SHORTDAY:"Sun Mon Tue Wed Thu Fri Sat".split(" "), +SHORTMONTH:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),WEEKENDRANGE:[5,6],fullDate:"EEEE, MMMM d, y",longDate:"MMMM d, y",medium:"MMM d, y h:mm:ss a",mediumDate:"MMM d, y",mediumTime:"h:mm:ss a","short":"M/d/yy h:mm a",shortDate:"M/d/yy",shortTime:"h:mm a"},NUMBER_FORMATS:{CURRENCY_SYM:"$",DECIMAL_SEP:".",GROUP_SEP:",",PATTERNS:[{gSize:3,lgSize:3,maxFrac:3,minFrac:0,minInt:1,negPre:"-",negSuf:"",posPre:"",posSuf:""},{gSize:3,lgSize:3,maxFrac:2,minFrac:2,minInt:1,negPre:"-\u00a4", +negSuf:"",posPre:"\u00a4",posSuf:""}]},id:"en-us",pluralCat:function(a,c){var e=a|0,f=c;u===f&&(f=Math.min(b(a),3));Math.pow(10,f);return 1==e&&0==f?"one":"other"}})}]),B(X).ready(function(){Zd(X,yc)}))})(window,document);!window.angular.$$csp().noInlineStyle&&window.angular.element(document.head).prepend(''); +//# sourceMappingURL=angular.min.js.map diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/js/bootstrap.min.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/js/bootstrap.min.js new file mode 100755 index 00000000..1a6258ef --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/js/bootstrap.min.js @@ -0,0 +1,7 @@ +/*! + * Bootstrap v3.0.3 (http://getbootstrap.com) + * Copyright 2013 Twitter, Inc. + * Licensed under http://www.apache.org/licenses/LICENSE-2.0 + */ + +if("undefined"==typeof jQuery)throw new Error("Bootstrap requires jQuery");+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]}}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one(a.support.transition.end,function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b()})}(jQuery),+function(a){"use strict";var b='[data-dismiss="alert"]',c=function(c){a(c).on("click",b,this.close)};c.prototype.close=function(b){function c(){f.trigger("closed.bs.alert").remove()}var d=a(this),e=d.attr("data-target");e||(e=d.attr("href"),e=e&&e.replace(/.*(?=#[^\s]*$)/,""));var f=a(e);b&&b.preventDefault(),f.length||(f=d.hasClass("alert")?d:d.parent()),f.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(f.removeClass("in"),a.support.transition&&f.hasClass("fade")?f.one(a.support.transition.end,c).emulateTransitionEnd(150):c())};var d=a.fn.alert;a.fn.alert=function(b){return this.each(function(){var d=a(this),e=d.data("bs.alert");e||d.data("bs.alert",e=new c(this)),"string"==typeof b&&e[b].call(d)})},a.fn.alert.Constructor=c,a.fn.alert.noConflict=function(){return a.fn.alert=d,this},a(document).on("click.bs.alert.data-api",b,c.prototype.close)}(jQuery),+function(a){"use strict";var b=function(c,d){this.$element=a(c),this.options=a.extend({},b.DEFAULTS,d)};b.DEFAULTS={loadingText:"loading..."},b.prototype.setState=function(a){var b="disabled",c=this.$element,d=c.is("input")?"val":"html",e=c.data();a+="Text",e.resetText||c.data("resetText",c[d]()),c[d](e[a]||this.options[a]),setTimeout(function(){"loadingText"==a?c.addClass(b).attr(b,b):c.removeClass(b).removeAttr(b)},0)},b.prototype.toggle=function(){var a=this.$element.closest('[data-toggle="buttons"]'),b=!0;if(a.length){var c=this.$element.find("input");"radio"===c.prop("type")&&(c.prop("checked")&&this.$element.hasClass("active")?b=!1:a.find(".active").removeClass("active")),b&&c.prop("checked",!this.$element.hasClass("active")).trigger("change")}b&&this.$element.toggleClass("active")};var c=a.fn.button;a.fn.button=function(c){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof c&&c;e||d.data("bs.button",e=new b(this,f)),"toggle"==c?e.toggle():c&&e.setState(c)})},a.fn.button.Constructor=b,a.fn.button.noConflict=function(){return a.fn.button=c,this},a(document).on("click.bs.button.data-api","[data-toggle^=button]",function(b){var c=a(b.target);c.hasClass("btn")||(c=c.closest(".btn")),c.button("toggle"),b.preventDefault()})}(jQuery),+function(a){"use strict";var b=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=this.sliding=this.interval=this.$active=this.$items=null,"hover"==this.options.pause&&this.$element.on("mouseenter",a.proxy(this.pause,this)).on("mouseleave",a.proxy(this.cycle,this))};b.DEFAULTS={interval:5e3,pause:"hover",wrap:!0},b.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},b.prototype.getActiveIndex=function(){return this.$active=this.$element.find(".item.active"),this.$items=this.$active.parent().children(),this.$items.index(this.$active)},b.prototype.to=function(b){var c=this,d=this.getActiveIndex();return b>this.$items.length-1||0>b?void 0:this.sliding?this.$element.one("slid.bs.carousel",function(){c.to(b)}):d==b?this.pause().cycle():this.slide(b>d?"next":"prev",a(this.$items[b]))},b.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition.end&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},b.prototype.next=function(){return this.sliding?void 0:this.slide("next")},b.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},b.prototype.slide=function(b,c){var d=this.$element.find(".item.active"),e=c||d[b](),f=this.interval,g="next"==b?"left":"right",h="next"==b?"first":"last",i=this;if(!e.length){if(!this.options.wrap)return;e=this.$element.find(".item")[h]()}this.sliding=!0,f&&this.pause();var j=a.Event("slide.bs.carousel",{relatedTarget:e[0],direction:g});if(!e.hasClass("active")){if(this.$indicators.length&&(this.$indicators.find(".active").removeClass("active"),this.$element.one("slid.bs.carousel",function(){var b=a(i.$indicators.children()[i.getActiveIndex()]);b&&b.addClass("active")})),a.support.transition&&this.$element.hasClass("slide")){if(this.$element.trigger(j),j.isDefaultPrevented())return;e.addClass(b),e[0].offsetWidth,d.addClass(g),e.addClass(g),d.one(a.support.transition.end,function(){e.removeClass([b,g].join(" ")).addClass("active"),d.removeClass(["active",g].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger("slid.bs.carousel")},0)}).emulateTransitionEnd(600)}else{if(this.$element.trigger(j),j.isDefaultPrevented())return;d.removeClass("active"),e.addClass("active"),this.sliding=!1,this.$element.trigger("slid.bs.carousel")}return f&&this.cycle(),this}};var c=a.fn.carousel;a.fn.carousel=function(c){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},b.DEFAULTS,d.data(),"object"==typeof c&&c),g="string"==typeof c?c:f.slide;e||d.data("bs.carousel",e=new b(this,f)),"number"==typeof c?e.to(c):g?e[g]():f.interval&&e.pause().cycle()})},a.fn.carousel.Constructor=b,a.fn.carousel.noConflict=function(){return a.fn.carousel=c,this},a(document).on("click.bs.carousel.data-api","[data-slide], [data-slide-to]",function(b){var c,d=a(this),e=a(d.attr("data-target")||(c=d.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"")),f=a.extend({},e.data(),d.data()),g=d.attr("data-slide-to");g&&(f.interval=!1),e.carousel(f),(g=d.attr("data-slide-to"))&&e.data("bs.carousel").to(g),b.preventDefault()}),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var b=a(this);b.carousel(b.data())})})}(jQuery),+function(a){"use strict";var b=function(c,d){this.$element=a(c),this.options=a.extend({},b.DEFAULTS,d),this.transitioning=null,this.options.parent&&(this.$parent=a(this.options.parent)),this.options.toggle&&this.toggle()};b.DEFAULTS={toggle:!0},b.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},b.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b=a.Event("show.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.$parent&&this.$parent.find("> .panel > .in");if(c&&c.length){var d=c.data("bs.collapse");if(d&&d.transitioning)return;c.collapse("hide"),d||c.data("bs.collapse",null)}var e=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[e](0),this.transitioning=1;var f=function(){this.$element.removeClass("collapsing").addClass("in")[e]("auto"),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return f.call(this);var g=a.camelCase(["scroll",e].join("-"));this.$element.one(a.support.transition.end,a.proxy(f,this)).emulateTransitionEnd(350)[e](this.$element[0][g])}}},b.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse").removeClass("in"),this.transitioning=1;var d=function(){this.transitioning=0,this.$element.trigger("hidden.bs.collapse").removeClass("collapsing").addClass("collapse")};return a.support.transition?(this.$element[c](0).one(a.support.transition.end,a.proxy(d,this)).emulateTransitionEnd(350),void 0):d.call(this)}}},b.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()};var c=a.fn.collapse;a.fn.collapse=function(c){return this.each(function(){var d=a(this),e=d.data("bs.collapse"),f=a.extend({},b.DEFAULTS,d.data(),"object"==typeof c&&c);e||d.data("bs.collapse",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.collapse.Constructor=b,a.fn.collapse.noConflict=function(){return a.fn.collapse=c,this},a(document).on("click.bs.collapse.data-api","[data-toggle=collapse]",function(b){var c,d=a(this),e=d.attr("data-target")||b.preventDefault()||(c=d.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,""),f=a(e),g=f.data("bs.collapse"),h=g?"toggle":d.data(),i=d.attr("data-parent"),j=i&&a(i);g&&g.transitioning||(j&&j.find('[data-toggle=collapse][data-parent="'+i+'"]').not(d).addClass("collapsed"),d[f.hasClass("in")?"addClass":"removeClass"]("collapsed")),f.collapse(h)})}(jQuery),+function(a){"use strict";function b(){a(d).remove(),a(e).each(function(b){var d=c(a(this));d.hasClass("open")&&(d.trigger(b=a.Event("hide.bs.dropdown")),b.isDefaultPrevented()||d.removeClass("open").trigger("hidden.bs.dropdown"))})}function c(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}var d=".dropdown-backdrop",e="[data-toggle=dropdown]",f=function(b){a(b).on("click.bs.dropdown",this.toggle)};f.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=c(e),g=f.hasClass("open");if(b(),!g){if("ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a(''}),b.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),b.prototype.constructor=b,b.prototype.getDefaults=function(){return b.DEFAULTS},b.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content")[this.options.html?"html":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},b.prototype.hasContent=function(){return this.getTitle()||this.getContent()},b.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},b.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")},b.prototype.tip=function(){return this.$tip||(this.$tip=a(this.options.template)),this.$tip};var c=a.fn.popover;a.fn.popover=function(c){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof c&&c;e||d.data("bs.popover",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.popover.Constructor=b,a.fn.popover.noConflict=function(){return a.fn.popover=c,this}}(jQuery),+function(a){"use strict";function b(c,d){var e,f=a.proxy(this.process,this);this.$element=a(c).is("body")?a(window):a(c),this.$body=a("body"),this.$scrollElement=this.$element.on("scroll.bs.scroll-spy.data-api",f),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||(e=a(c).attr("href"))&&e.replace(/.*(?=#[^\s]+$)/,"")||"")+" .nav li > a",this.offsets=a([]),this.targets=a([]),this.activeTarget=null,this.refresh(),this.process()}b.DEFAULTS={offset:10},b.prototype.refresh=function(){var b=this.$element[0]==window?"offset":"position";this.offsets=a([]),this.targets=a([]);var c=this;this.$body.find(this.selector).map(function(){var d=a(this),e=d.data("target")||d.attr("href"),f=/^#\w/.test(e)&&a(e);return f&&f.length&&[[f[b]().top+(!a.isWindow(c.$scrollElement.get(0))&&c.$scrollElement.scrollTop()),e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){c.offsets.push(this[0]),c.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.$scrollElement[0].scrollHeight||this.$body[0].scrollHeight,d=c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(b>=d)return g!=(a=f.last()[0])&&this.activate(a);for(a=e.length;a--;)g!=f[a]&&b>=e[a]&&(!e[a+1]||b<=e[a+1])&&this.activate(f[a])},b.prototype.activate=function(b){this.activeTarget=b,a(this.selector).parents(".active").removeClass("active");var c=this.selector+'[data-target="'+b+'"],'+this.selector+'[href="'+b+'"]',d=a(c).parents("li").addClass("active");d.parent(".dropdown-menu").length&&(d=d.closest("li.dropdown").addClass("active")),d.trigger("activate.bs.scrollspy")};var c=a.fn.scrollspy;a.fn.scrollspy=function(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.scrollspy.Constructor=b,a.fn.scrollspy.noConflict=function(){return a.fn.scrollspy=c,this},a(window).on("load",function(){a('[data-spy="scroll"]').each(function(){var b=a(this);b.scrollspy(b.data())})})}(jQuery),+function(a){"use strict";var b=function(b){this.element=a(b)};b.prototype.show=function(){var b=this.element,c=b.closest("ul:not(.dropdown-menu)"),d=b.data("target");if(d||(d=b.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,"")),!b.parent("li").hasClass("active")){var e=c.find(".active:last a")[0],f=a.Event("show.bs.tab",{relatedTarget:e});if(b.trigger(f),!f.isDefaultPrevented()){var g=a(d);this.activate(b.parent("li"),c),this.activate(g,g.parent(),function(){b.trigger({type:"shown.bs.tab",relatedTarget:e})})}}},b.prototype.activate=function(b,c,d){function e(){f.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),b.addClass("active"),g?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu")&&b.closest("li.dropdown").addClass("active"),d&&d()}var f=c.find("> .active"),g=d&&a.support.transition&&f.hasClass("fade");g?f.one(a.support.transition.end,e).emulateTransitionEnd(150):e(),f.removeClass("in")};var c=a.fn.tab;a.fn.tab=function(c){return this.each(function(){var d=a(this),e=d.data("bs.tab");e||d.data("bs.tab",e=new b(this)),"string"==typeof c&&e[c]()})},a.fn.tab.Constructor=b,a.fn.tab.noConflict=function(){return a.fn.tab=c,this},a(document).on("click.bs.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(b){b.preventDefault(),a(this).tab("show")})}(jQuery),+function(a){"use strict";var b=function(c,d){this.options=a.extend({},b.DEFAULTS,d),this.$window=a(window).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(c),this.affixed=this.unpin=null,this.checkPosition()};b.RESET="affix affix-top affix-bottom",b.DEFAULTS={offset:0},b.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},b.prototype.checkPosition=function(){if(this.$element.is(":visible")){var c=a(document).height(),d=this.$window.scrollTop(),e=this.$element.offset(),f=this.options.offset,g=f.top,h=f.bottom;"object"!=typeof f&&(h=g=f),"function"==typeof g&&(g=f.top()),"function"==typeof h&&(h=f.bottom());var i=null!=this.unpin&&d+this.unpin<=e.top?!1:null!=h&&e.top+this.$element.height()>=c-h?"bottom":null!=g&&g>=d?"top":!1;this.affixed!==i&&(this.unpin&&this.$element.css("top",""),this.affixed=i,this.unpin="bottom"==i?e.top-d:null,this.$element.removeClass(b.RESET).addClass("affix"+(i?"-"+i:"")),"bottom"==i&&this.$element.offset({top:document.body.offsetHeight-h-this.$element.height()}))}};var c=a.fn.affix;a.fn.affix=function(c){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof c&&c;e||d.data("bs.affix",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.affix.Constructor=b,a.fn.affix.noConflict=function(){return a.fn.affix=c,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var b=a(this),c=b.data();c.offset=c.offset||{},c.offsetBottom&&(c.offset.bottom=c.offsetBottom),c.offsetTop&&(c.offset.top=c.offsetTop),b.affix(c)})})}(jQuery); \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/js/g2.min.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/js/g2.min.js new file mode 100755 index 00000000..74ec9541 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/js/g2.min.js @@ -0,0 +1 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.G2_3=e():t.G2_3=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=389)}([function(t,e,n){var i=n(127),r=n(16),a=i.mix({},i,{assign:i.mix,merge:i.deepMix,cloneDeep:i.clone,isFinite:isFinite,isNaN:isNaN,snapEqual:i.isNumberEqual,remove:i.pull,inArray:i.contains,toAllPadding:function(t){var e=0,n=0,i=0,r=0;return a.isNumber(t)||a.isString(t)?e=n=i=r=t:a.isArray(t)?(e=t[0],i=a.isNil(t[1])?t[0]:t[1],r=a.isNil(t[2])?t[0]:t[2],n=a.isNil(t[3])?i:t[3]):a.isObject(t)&&(e=t.top||0,i=t.right||0,r=t.bottom||0,n=t.left||0),[e,i,r,n]},getClipByRange:function(t){var e=t.tl,n=t.br;return new r.Rect({attrs:{x:e.x,y:e.y,width:n.x-e.x,height:n.y-e.y}})}});a.Array={groupToMap:i.groupToMap,group:i.group,merge:i.merge,values:i.valuesOfKey,getRange:i.getRange,firstValue:i.firstValue,remove:i.pull},t.exports=a},function(t,e,n){var i=n(81),r={};i.merge(r,i,{mixin:function(t,e){var n=t.CFG?"CFG":"ATTRS";if(t&&e){t._mixins=e,t[n]=t[n]||{};var i={};r.each(e,function(e){r.augment(t,e);var a=e[n];a&&r.merge(i,a)}),t[n]=r.merge(i,t[n])}}}),t.exports=r},function(t,e,n){var i=n(24),r=n(4);t.exports=function(t,e){if(t)if(r(t))for(var n=0,a=t.length;n0){var a=e.strokeOpacity;i.isNil(a)||1===a||(t.globalAlpha=a),t.stroke()}}this.afterPath(t)},afterPath:function(){},isHitBox:function(){return!0},isHit:function(t,e){var n=[t,e,1];if(this.invert(n),this.isHitBox()){var i=this.getBBox();if(i&&!o.box(i.minX,i.maxX,i.minY,i.maxY,n[0],n[1]))return!1}var r=this._attrs.clip;return r?(r.invert(n,this.get("canvas")),!!r.isPointInPath(n[0],n[1])&&this.isPointInPath(n[0],n[1])):this.isPointInPath(n[0],n[1])},calculateBox:function(){return null},getHitLineWidth:function(){var t=this._attrs,e=t.lineAppendWidth||0;return(t.lineWidth||0)+e},clearTotalMatrix:function(){this._cfg.totalMatrix=null,this._cfg.region=null},clearBBox:function(){this._cfg.box=null,this._cfg.region=null},getBBox:function(){var t=this._cfg.box;return t||((t=this.calculateBox())&&(t.x=t.minX,t.y=t.minY,t.width=t.maxX-t.minX,t.height=t.maxY-t.minY),this._cfg.box=t),t},clone:function(){var t=null,e=this._attrs,n={};return i.each(e,function(t,r){l[r]&&i.isArray(e[r])?n[r]=function(t){for(var e=[],n=0;n1){var y=f[1];y.change({nice:!1,min:0,max:Math.max.apply(null,y.values)})}s.scales=f;var x=new a[c](s);t[o]=x}},n._processData=function(){for(var t=this.get("data"),e=[],n=this._groupData(t),i=0;ia&&(a=c)}(re.max)&&e.change({min:r,max:a})},n._adjust=function(t){var e=this,n=e.get("adjusts"),i=this.viewTheme||u,r=e.getYScale(),a=e.getXScale(),s=a.field,c=r?r.field:null;l.each(n,function(n){var u=l.mix({xField:s,yField:c},n),h=l.upperFirst(n.type);if("Dodge"===h){var f=[];if(a.isCategory||a.isIdentity)f.push("x");else{if(r)throw new Error("dodge is not support linear attribute, please use category attribute!");f.push("y")}u.adjustNames=f,u.dodgeRatio=i.widthRatio.column}else if("Stack"===h){var p=e.get("coord");if(!r){u.height=p.getHeight();var g=e.getDefaultValue("size")||3;u.size=g}!p.isTransposed&&l.isNil(u.reverseOrder)&&(u.reverseOrder=!0)}new o[h](u).processAdjust(t),"Stack"===h&&r&&e._updateStackRange(c,r,t)})},n.setCoord=function(t){this.set("coord",t);var e=this.getAttr("position");this.get("shapeContainer").setMatrix(t.matrix),e&&(e.coord=t)},n.paint=function(){var t=this.get("dataArray"),e=[],n=this.getShapeFactory();n.setCoord(this.get("coord")),this.set("shapeFactory",n);var i=this.get("shapeContainer");this._beforeMapping(t);for(var r=0;r=0?e:n<=0?n:0},n._normalizeValues=function(t,e){var n=[];if(l.isArray(t))for(var i=0;i1)for(var h=0;h0)l.each(n,function(n){e+="-"+t[n]});else{var i,r=this.get("type"),a=this.getXScale(),o=this.getYScale(),s=a.field||"x",u=o.field||"y",c=t[u];i=a.isIdentity?a.value:t[s],e+="interval"===r||"schema"===r?"-"+i:"line"===r||"area"===r||"path"===r?"-"+r:"-"+i+"-"+c;var h=this._getGroupScales();l.isEmpty(h)||l.each(h,function(n){var i=n.field;"identity"!==n.type&&(e+="-"+t[i])})}return e},n.getDrawCfg=function(t){var e={origin:t,x:t.x,y:t.y,color:t.color,size:t.size,shape:t.shape,isInCircle:this.isInCircle(),opacity:t.opacity},n=this.get("styleOptions");return n&&n.style&&(e.style=this.getCallbackCfg(n.fields,n.style,t._origin)),this.get("generatePoints")&&(e.points=t.points,e.nextPoints=t.nextPoints),this.get("animate")&&(e._id=this._getShapeId(t._origin)),e},n.appendShapeInfo=function(t,e){t&&(t.setSilent("index",e),t.setSilent("coord",this.get("coord")),this.get("animate")&&this.get("animateCfg")&&t.setSilent("animateCfg",this.get("animateCfg")))},n._applyViewThemeShapeStyle=function(t,e,n){var i=this.viewTheme||u,r=n.name;e?e&&(e.indexOf("hollow")>-1||e.indexOf("liquid")>-1)&&(r="hollow"+l.upperFirst(r)):n.defaultShapeType.indexOf("hollow")>-1&&(r="hollow"+l.upperFirst(r));var a=i.shape[r]||{};t.style=l.mix({},a,t.style)},n.drawPoint=function(t,e,n,i){var r=t.shape,a=this.getDrawCfg(t);this._applyViewThemeShapeStyle(a,r,n);var o=n.drawShape(r,a,e);this.appendShapeInfo(o,i)},n.getAttr=function(t){return this.get("attrs")[t]},n.getXScale=function(){return this.getAttr("position").scales[0]},n.getYScale=function(){return this.getAttr("position").scales[1]},n.getShapes=function(){var t=[],e=this.get("shapeContainer").get("children");return l.each(e,function(e){e.get("origin")&&t.push(e)}),t},n.getAttrsForLegend=function(){var t=this.get("attrs"),e=[];return l.each(t,function(t){-1!==v.indexOf(t.type)&&e.push(t)}),e},n.getFieldsForLegend=function(){var t=[],e=this.get("attrOptions");return l.each(v,function(n){var i=e[n];i&&i.field&&l.isString(i.field)&&(t=t.concat(i.field.split("*")))}),l.uniq(t)},n.changeVisible=function(t,e){this.set("visible",t);var n=this.get("shapeContainer");n&&n.set("visible",t);var i=this.get("labelContainer");if(i&&i.set("visible",t),!e&&n){n.get("canvas").draw()}},n.reset=function(){this.set("attrOptions",{}),this.clearInner()},n.clearInner=function(){this.clearActivedShapes(),this.clearSelected();var t=this.get("shapeContainer");t&&t.clear();var e=this.get("labelContainer");e&&e.remove(),this.set("attrs",{}),this.set("groupScales",null),this.set("labelContainer",null),this.set("xDistance",null),this.set("isStacked",null)},n.clear=function(){this.clearInner(),this.set("scales",{})},n.destroy=function(){this.clear();var e=this.get("shapeContainer");e&&e.remove(),this.offEvents(),t.prototype.destroy.call(this)},n.bindEvents=function(){this.get("view")&&(this._bindActiveAction(),this._bindSelectedAction())},n.offEvents=function(){this.get("view")&&(this._offActiveAction(),this._offSelectedAction())},e}(s);t.exports=y},function(t,e,n){t.exports={Axis:n(306),Component:n(66),Guide:n(314),Label:n(323),Legend:n(324),Tooltip:n(330)}},function(t,e,n){function i(t,e){var n=t.getCenter();return Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2))}function r(t,e){for(var n=t.length,i=[t[0]],r=1;r=s[c]?1:0,p=h>Math.PI?1:0,g=n.convertPoint(l),d=i(n,g);if(d>=.5)if(h===2*Math.PI){var v={x:(l.x+s.x)/2,y:(l.y+s.y)/2},y=n.convertPoint(v);u.push(["A",d,d,0,p,f,y.x,y.y]),u.push(["A",d,d,0,p,f,g.x,g.y])}else u.push(["A",d,d,0,p,f,g.x,g.y]);return u}(n,o,t)):u.push(r(a,t));break;case"z":default:u.push(a)}}),function(t){a.each(t,function(e,n){if("a"===e[0].toLowerCase()){var i=t[n-1],r=t[n+1];r&&"a"===r[0].toLowerCase()?i&&"l"===i[0].toLowerCase()&&(i[0]="M"):i&&"a"===i[0].toLowerCase()&&r&&"l"===r[0].toLowerCase()&&(r[0]="M")}})}(u),u}};t.exports=s},function(t,e,n){var i=n(5);t.exports=function(t){return i(t)?"":t.toString()}},function(t,e){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports=function(t){var e=void 0===t?"undefined":n(t);return null!==t&&"object"===e||"function"===e}},function(t,e,n){t.exports={Canvas:n(181),Group:n(101),Shape:n(6),Arc:n(105),Circle:n(106),Dom:n(107),Ellipse:n(108),Fan:n(109),Image:n(110),Line:n(111),Marker:n(56),Path:n(112),Polygon:n(113),Polyline:n(114),Rect:n(115),Text:n(116),PathSegment:n(39),PathUtil:n(57),Event:n(100),version:"3.3.5"}},function(t,e,n){var i=n(48),r=n(12);t.exports=function(t){if(!i(t)||!r(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}},function(t,e,n){var i=n(1),r=/[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/gi,a=/[^\s\,]+/gi;t.exports={parseRadius:function(t){var e=0,n=0,r=0,a=0;return i.isArray(t)?1===t.length?e=n=r=a=t[0]:2===t.length?(e=r=t[0],n=a=t[1]):3===t.length?(e=t[0],n=a=t[1],r=t[2]):(e=t[0],n=t[1],r=t[2],a=t[3]):e=n=r=a=t,{r1:e,r2:n,r3:r,r4:a}},parsePath:function(t){return t=t||[],i.isArray(t)?t:i.isString(t)?(t=t.match(r),i.each(t,function(e,n){if((e=e.match(a))[0].length>1){var r=e[0].charAt(0);e.splice(1,0,e[0].substr(1)),e[0]=r}i.each(e,function(t,n){isNaN(t)||(e[n]=+t)}),t[n]=e}),t):void 0}}},function(t,e,n){"use strict";function i(t,e){return function(n){return t+n*e}}function r(t,e){var n=e-t;return n?i(t,n):Object(a.a)(isNaN(t)?e:t)}e.c=function(t,e){var n=e-t;return n?i(t,n>180||n<-180?n-360*Math.round(n/360):n):Object(a.a)(isNaN(t)?e:t)},e.b=function(t){return 1==(t=+t)?r:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(i){return Math.pow(t+i*e,n)}}(e,n,t):Object(a.a)(isNaN(e)?n:e)}},e.a=r;var a=n(121)},function(t,e,n){function i(t,e){return r(e)?e:t.invert(t.scale(e))}var r=n(10),a=n(4),o=n(5),s=n(8),l=n(2),u=function(){function t(t){var e=this;this.type="base",this.name=null,this.method=null,this.values=[],this.scales=[],this.linear=null;var n=null,i=this.callback;if(t.callback){var r=t.callback;n=function(){for(var t=arguments.length,n=new Array(t),a=0;a1&&(e=(t[1].value-t[0].value)/2);for(var n=[],i=0;i0){var s=e.value-a[r-1].value;s/=t.get("subTickCount")+1;for(var l=1;l<=n;l++){var u={text:"",value:r?a[r-1].value+l*s:l*s},c=t.getTickPoint(u.value),h=void 0;h=o&&o.length?o.length:parseInt(.6*i.length,10),t._addTickItem(l-1,c,h,"sub")}}})}},n._addTickLine=function(t,e){var n=r.mix({},e),i=[];r.each(t,function(t){i.push(["M",t.x1,t.y1]),i.push(["L",t.x2,t.y2])}),delete n.length,n.path=i;var a=this.get("group").addShape("path",{attrs:n});a.name="axis-ticks",a._id=this.get("_id")+"-ticks",a.set("coord",this.get("coord")),this.get("appendInfo")&&a.setSilent("appendInfo",this.get("appendInfo"))},n._renderTicks=function(){var t=this.get("tickItems"),e=this.get("subTickItems");if(!r.isEmpty(t)){var n=this.get("tickLine");this._addTickLine(t,n)}if(!r.isEmpty(e)){var i=this.get("subTickLine")||this.get("tickLine");this._addTickLine(e,i)}},n._renderGrid=function(){var t=this.get("grid");if(t){t.coord=this.get("coord"),t.appendInfo=this.get("appendInfo");var e=this.get("group");this.set("gridGroup",e.addGroup(a,t))}},n._renderLabels=function(){var t=this.get("labelRenderer"),e=this.get("labelItems");t&&(t.set("items",e),t._dryDraw())},n.paint=function(){var t=this.get("tickLine"),e=!0;t&&t.hasOwnProperty("alignWithLabel")&&(e=t.alignWithLabel),this._renderLine();var n=this.get("type");("cat"===n||"timeCat"===n)&&!1===e?this._processCatTicks():this._processTicks(),this._renderTicks(),this._renderGrid(),this._renderLabels();var i=this.get("label");i&&i.autoRotate&&this.autoRotateLabels(),i&&i.autoHide&&this.autoHideLabels()},n.parseTick=function(t,e,n){return{text:t,value:e/(n-1)}},n.getTextAnchor=function(t){return Math.abs(t[1]/t[0])>=1?"center":t[0]>0?"start":"end"},n.getMaxLabelWidth=function(t){var e=t.getLabels(),n=0;return r.each(e,function(t){var e=t.getBBox().width;ne)&&(this.min=e),(i(this.max)||this.max=t.min&&e<=t.max&&n.push(e)}),n.length||(n.push(t.min),n.push(t.max)),t.ticks=n}},n.scale=function(t){if(i(t))return NaN;var e=this.max,n=this.min;if(e===n)return 0;var r=(t-n)/(e-n),a=this.rangeMin();return a+r*(this.rangeMax()-a)},n.invert=function(t){var e=(t-this.rangeMin())/(this.rangeMax()-this.rangeMin());return this.min+e*(this.max-this.min)},e}(a);a.Linear=s,t.exports=s},function(t,e,n){var i=n(13);t.exports=function(t){return i(t)?Array.prototype.slice.call(t):[]}},function(t,e){t.exports=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-5;return Math.abs(t-e)n&&(r=2*Math.PI-t+e,a=t-n):(r=t-e,a=n-t),r>a?n:e}function a(t,e,n,i){var a=0;return n-e>=2*Math.PI&&(a=2*Math.PI),e=s.mod(e,2*Math.PI),n=s.mod(n,2*Math.PI)+a,t=s.mod(t,2*Math.PI),i?e>=n?t>n&&tn?t:r(t,e,n):e<=n?ee||tt.x&&(g=t.x),dt.y&&(v=t.y),y0&&p>0?h=Math.PI/2-g:f<0&&p<0?h=-Math.PI/2-g:f>=0&&p<0?h=-g-Math.PI/2:f<=0&&p>0&&(h=Math.PI/2-g);var d=function(t){var e,n=[],i=a.parsePath(t.path);if(!Array.isArray(i)||0===i.length||"M"!==i[0][0]&&"m"!==i[0][0])return!1;for(var r=i.length,s=0;s=0,p=f?n.toUpperCase():n,g=t,v=e.endPoint,y=g[1],x=g[2];switch(p){default:break;case"M":h=f?i(y,x,v):{x:y,y:x},this.command="M",this.params=[v,h],this.subStart=h,this.endPoint=h;break;case"L":h=f?i(y,x,v):{x:y,y:x},this.command="L",this.params=[v,h],this.subStart=e.subStart,this.endPoint=h,this.endTangent=function(){return[h.x-v.x,h.y-v.y]},this.startTangent=function(){return[v.x-h.x,v.y-h.y]};break;case"H":h=f?i(y,0,v):{x:y,y:v.y},this.command="L",this.params=[v,h],this.subStart=e.subStart,this.endPoint=h,this.endTangent=function(){return[h.x-v.x,h.y-v.y]},this.startTangent=function(){return[v.x-h.x,v.y-h.y]};break;case"V":h=f?i(0,y,v):{x:v.x,y:y},this.command="L",this.params=[v,h],this.subStart=e.subStart,this.endPoint=h,this.endTangent=function(){return[h.x-v.x,h.y-v.y]},this.startTangent=function(){return[v.x-h.x,v.y-h.y]};break;case"Q":f?(a=i(y,x,v),u=i(g[3],g[4],v)):(a={x:y,y:x},u={x:g[3],y:g[4]}),this.command="Q",this.params=[v,a,u],this.subStart=e.subStart,this.endPoint=u,this.endTangent=function(){return[u.x-a.x,u.y-a.y]},this.startTangent=function(){return[v.x-a.x,v.y-a.y]};break;case"T":u=f?i(y,x,v):{x:y,y:x},"Q"===e.command?(a=r(e.params[1],v),this.command="Q",this.params=[v,a,u],this.subStart=e.subStart,this.endPoint=u,this.endTangent=function(){return[u.x-a.x,u.y-a.y]},this.startTangent=function(){return[v.x-a.x,v.y-a.y]}):(this.command="TL",this.params=[v,u],this.subStart=e.subStart,this.endPoint=u,this.endTangent=function(){return[u.x-v.x,u.y-v.y]},this.startTangent=function(){return[v.x-u.x,v.y-u.y]});break;case"C":f?(a=i(y,x,v),u=i(g[3],g[4],v),c=i(g[5],g[6],v)):(a={x:y,y:x},u={x:g[3],y:g[4]},c={x:g[5],y:g[6]}),this.command="C",this.params=[v,a,u,c],this.subStart=e.subStart,this.endPoint=c,this.endTangent=function(){return[c.x-u.x,c.y-u.y]},this.startTangent=function(){return[v.x-a.x,v.y-a.y]};break;case"S":f?(u=i(y,x,v),c=i(g[3],g[4],v)):(u={x:y,y:x},c={x:g[3],y:g[4]}),"C"===e.command?(a=r(e.params[2],v),this.command="C",this.params=[v,a,u,c],this.subStart=e.subStart,this.endPoint=c,this.endTangent=function(){return[c.x-u.x,c.y-u.y]},this.startTangent=function(){return[v.x-a.x,v.y-a.y]}):(this.command="SQ",this.params=[v,u,c],this.subStart=e.subStart,this.endPoint=c,this.endTangent=function(){return[c.x-u.x,c.y-u.y]},this.startTangent=function(){return[v.x-u.x,v.y-u.y]});break;case"A":var m=y,_=x,b=g[3],w=g[4],S=g[5];h=f?i(g[6],g[7],v):{x:g[6],y:g[7]},this.command="A";var M=function(t,e,n,i,r,a,u){var c=l.mod(l.toRadian(u),2*Math.PI),h=t.x,f=t.y,p=e.x,g=e.y,d=Math.cos(c)*(h-p)/2+Math.sin(c)*(f-g)/2,v=-1*Math.sin(c)*(h-p)/2+Math.cos(c)*(f-g)/2,y=d*d/(r*r)+v*v/(a*a);y>1&&(r*=Math.sqrt(y),a*=Math.sqrt(y));var x=r*r*(v*v)+a*a*(d*d),m=Math.sqrt((r*r*(a*a)-x)/x);n===i&&(m*=-1),isNaN(m)&&(m=0);var _=m*r*v/a,b=m*-a*d/r,w=(h+p)/2+Math.cos(c)*_-Math.sin(c)*b,S=(f+g)/2+Math.sin(c)*_+Math.cos(c)*b,M=s([1,0],[(d-_)/r,(v-b)/a]),C=[(d-_)/r,(v-b)/a],A=[(-1*d-_)/r,(-1*v-b)/a],k=s(C,A);return o(C,A)<=-1&&(k=Math.PI),o(C,A)>=1&&(k=0),0===i&&k>0&&(k-=2*Math.PI),1===i&&k<0&&(k+=2*Math.PI),[t,w,S,r,a,M,k,c,i]}(v,h,w,S,m,_,b);this.params=M;var C=e.subStart;this.subStart=C,this.endPoint=h;var A=M[5]%(2*Math.PI);l.isNumberEqual(A,2*Math.PI)&&(A=0);var k=M[6]%(2*Math.PI);l.isNumberEqual(k,2*Math.PI)&&(k=0);var P=.001;this.startTangent=function(){0===S&&(P*=-1);var t=M[3]*Math.cos(A-P)+M[1],e=M[4]*Math.sin(A-P)+M[2];return[t-C.x,e-C.y]},this.endTangent=function(){var t=M[6];t-2*Math.PI<1e-4&&(t=0);var e=M[3]*Math.cos(A+t+P)+M[1],n=M[4]*Math.sin(A+t-P)+M[2];return[v.x-e,v.y-n]};break;case"Z":this.command="Z",this.params=[v,e.subStart],this.subStart=e.subStart,this.endPoint=e.subStart}},isInside:function(t,e,n){var i=this.command,r=this.params,a=this.box;if(a&&!u.box(a.minX,a.maxX,a.minY,a.maxY,t,e))return!1;switch(i){default:break;case"M":return!1;case"TL":case"L":case"Z":return u.line(r[0].x,r[0].y,r[1].x,r[1].y,n,t,e);case"SQ":case"Q":return u.quadraticline(r[0].x,r[0].y,r[1].x,r[1].y,r[2].x,r[2].y,n,t,e);case"C":return u.cubicline(r[0].x,r[0].y,r[1].x,r[1].y,r[2].x,r[2].y,r[3].x,r[3].y,n,t,e);case"A":var o=r,s=o[1],l=o[2],c=o[3],h=o[4],f=o[5],d=o[6],v=o[7],y=o[8],x=c>h?c:h,m=c>h?1:c/h,_=c>h?h/c:1;o=[t,e,1];var b=[1,0,0,0,1,0,0,0,1];return g.translate(b,b,[-s,-l]),g.rotate(b,b,-v),g.scale(b,b,[1/m,1/_]),p.transformMat3(o,o,b),u.arcline(0,0,x,f,f+d,1-y,n,o[0],o[1])}return!1},draw:function(t){var e,n,i,r=this.command,a=this.params;switch(r){default:break;case"M":t.moveTo(a[1].x,a[1].y);break;case"TL":case"L":t.lineTo(a[1].x,a[1].y);break;case"SQ":case"Q":e=a[1],n=a[2],t.quadraticCurveTo(e.x,e.y,n.x,n.y);break;case"C":e=a[1],n=a[2],i=a[3],t.bezierCurveTo(e.x,e.y,n.x,n.y,i.x,i.y);break;case"A":var o=a,s=o[1],l=o[2],u=o[3],c=o[4],h=o[5],f=o[6],p=o[7],g=o[8],d=u>c?u:c,v=u>c?1:u/c,y=u>c?c/u:1;t.translate(s,l),t.rotate(p),t.scale(v,y),t.arc(0,0,d,h,h+f,1-g),t.scale(1/v,1/y),t.rotate(-p),t.translate(-s,-l);break;case"Z":t.closePath()}},getBBox:function(t){var e,n,i,r,a=t/2,o=this.params;switch(this.command){default:case"M":case"Z":break;case"TL":case"L":this.box={minX:Math.min(o[0].x,o[1].x)-a,maxX:Math.max(o[0].x,o[1].x)+a,minY:Math.min(o[0].y,o[1].y)-a,maxY:Math.max(o[0].y,o[1].y)+a};break;case"SQ":case"Q":for(i=0,r=(n=h.extrema(o[0].x,o[1].x,o[2].x)).length;iS&&(S=A)}var k=f.yExtrema(y,p,g),P=1/0,T=-1/0,I=[m,_];for(i=2*-Math.PI;i<=2*Math.PI;i+=Math.PI){var O=k+i;1===x?mT&&(T=L)}this.box={minX:w-a,maxX:S+a,minY:P-a,maxY:T+a}}}}),t.exports=v},function(t,e,n){"use strict";e.a=function(t,e){return t=+t,e-=t,function(n){return t+e*n}}},function(t,e,n){var i=n(13),r=Array.prototype.indexOf;t.exports=function(t,e){return!!i(t)&&r.call(t,e)>-1}},function(t,e){t.exports=function(t){for(var e=[],n=0;n2&&void 0!==arguments[2]?arguments[2]:0,i=this.matrix,r=[t,e,n];return l.transformMat3(r,r,i),r}},{key:"invertMatrix",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=this.matrix,r=s.invert([],i),a=[t,e,n];return l.transformMat3(a,a,r),a}},{key:"convert",value:function(t){var e=this.convertPoint(t),n=e.x,i=e.y,r=this.applyMatrix(n,i,1);return{x:r[0],y:r[1]}}},{key:"invert",value:function(t){var e=this.invertMatrix(t.x,t.y,1);return this.invertPoint({x:e[0],y:e[1]})}},{key:"rotate",value:function(t){var e=this.matrix,n=this.center;return s.translate(e,e,[-n.x,-n.y]),s.rotate(e,e,t),s.translate(e,e,[n.x,n.y]),this}},{key:"reflect",value:function(t){switch(t){case"x":this._swapDim("x");break;case"y":this._swapDim("y");break;default:this._swapDim("y")}return this}},{key:"scale",value:function(t,e){var n=this.matrix,i=this.center;return s.translate(n,n,[-i.x,-i.y]),s.scale(n,n,[t,e]),s.translate(n,n,[i.x,i.y]),this}},{key:"translate",value:function(t,e){var n=this.matrix;return s.translate(n,n,[t,e]),this}},{key:"transpose",value:function(){return this.isTransposed=!this.isTransposed,this}}]),t}();t.exports=u},function(t,e,n){var i=n(0),r={splitPoints:function(t){var e=[],n=t.x,r=t.y;return r=i.isArray(r)?r:[r],i.each(r,function(t,r){var a={x:i.isArray(n)?n[r]:n,y:t};e.push(a)}),e},addFillAttrs:function(t,e){e.color&&(t.fill=e.color),i.isNumber(e.opacity)&&(t.opacity=t.fillOpacity=e.opacity)},addStrokeAttrs:function(t,e){e.color&&(t.stroke=e.color),i.isNumber(e.opacity)&&(t.opacity=t.strokeOpacity=e.opacity)}};t.exports=r},function(t,e,n){var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=n(4);t.exports=function t(e){if("object"!==(void 0===e?"undefined":i(e))||null===e)return e;var n=void 0;if(r(e)){n=[];for(var a=0,o=e.length;an?n:t}},function(t,e,n){var i=n(182);i.translate=function(t,e,n){var r=new Array(9);return i.fromTranslation(r,n),i.multiply(t,r,e)},i.rotate=function(t,e,n){var r=new Array(9);return i.fromRotation(r,n),i.multiply(t,r,e)},i.scale=function(t,e,n){var r=new Array(9);return i.fromScaling(r,n),i.multiply(t,r,e)},t.exports=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.setMatrixArrayType=function(t){e.ARRAY_TYPE=r=t},e.toRadian=function(t){return t*a},e.equals=function(t,e){return Math.abs(t-e)<=i*Math.max(1,Math.abs(t),Math.abs(e))};var i=e.EPSILON=1e-6,r=e.ARRAY_TYPE="undefined"!=typeof Float32Array?Float32Array:Array,a=(e.RANDOM=Math.random,Math.PI/180)},function(t,e,n){var i;!function(e){"use strict";function r(){}function a(t,e){for(var n=t.length;n--;)if(t[n].listener===e)return n;return-1}function o(t){return function(){return this[t].apply(this,arguments)}}function s(t){return"function"==typeof t||t instanceof RegExp||!(!t||"object"!=typeof t)&&s(t.listener)}var l=r.prototype,u=e.EventEmitter;l.getListeners=function(t){var e,n,i=this._getEvents();if(t instanceof RegExp){e={};for(n in i)i.hasOwnProperty(n)&&t.test(n)&&(e[n]=i[n])}else e=i[t]||(i[t]=[]);return e},l.flattenListeners=function(t){var e,n=[];for(e=0;e=0&&v=0&&r<=1&&h.push(r);else{var f=u*u-4*l*c;o.isNumberEqual(f,0)?h.push(-u/(2*l)):f>0&&(a=(-u-(s=Math.sqrt(f)))/(2*l),(r=(-u+s)/(2*l))>=0&&r<=1&&h.push(r),a>=0&&a<=1&&h.push(a))}return h},len:function(t,e,n,i,r,s,l,u,c){o.isNil(c)&&(c=1);for(var h=(c=c>1?1:c<0?0:c)/2,f=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],p=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],g=0,d=0;d<12;d++){var v=h*f[d]+h,y=a(v,t,n,r,l),x=a(v,e,i,s,u),m=y*y+x*x;g+=p[d]*Math.sqrt(m)}return h*g}}},function(t,e,n){var i=n(1),r=n(6),a=n(27),o=n(39),s=function t(e){t.superclass.constructor.call(this,e)};s.Symbols={circle:function(t,e,n){return[["M",t,e],["m",-n,0],["a",n,n,0,1,0,2*n,0],["a",n,n,0,1,0,2*-n,0]]},square:function(t,e,n){return[["M",t-n,e-n],["L",t+n,e-n],["L",t+n,e+n],["L",t-n,e+n],["Z"]]},diamond:function(t,e,n){return[["M",t-n,e],["L",t,e-n],["L",t+n,e],["L",t,e+n],["Z"]]},triangle:function(t,e,n){var i=n*Math.sin(1/3*Math.PI);return[["M",t-n,e+i],["L",t,e-i],["L",t+n,e+i],["z"]]},"triangle-down":function(t,e,n){var i=n*Math.sin(1/3*Math.PI);return[["M",t-n,e-i],["L",t+n,e-i],["L",t,e+i],["Z"]]}},s.ATTRS={path:null,lineWidth:1},i.extend(s,r),i.augment(s,{type:"marker",canFill:!0,canStroke:!0,getDefaultAttrs:function(){return{x:0,y:0,lineWidth:1}},calculateBox:function(){var t=this._attrs,e=t.x,n=t.y,i=t.radius,r=this.getHitLineWidth()/2+i;return{minX:e-r,minY:n-r,maxX:e+r,maxY:n+r}},_getPath:function(){var t=this._attrs,e=t.x,n=t.y,r=t.radius||t.r,a=t.symbol||"circle";return(i.isFunction(a)?a:s.Symbols[a])(e,n,r)},createPath:function(t){var e=this._cfg.segments;if(!e||this._cfg.hasUpdate){var n=a.parsePath(this._getPath());t.beginPath();var i;e=[];for(var r=0;r2&&(n.push([i].concat(a.splice(0,2))),o="l",i="m"===i?"l":"L"),"o"===o&&1===a.length&&n.push([i,a[0]]),"r"===o)n.push([i].concat(a));else for(;a.length>=e[o]&&(n.push([i].concat(a.splice(0,e[o]))),e[o]););}),n},f=function(t,e){for(var n=[],i=0,r=t.length;r-2*!e>i;i+=2){var a=[{x:+t[i-2],y:+t[i-1]},{x:+t[i],y:+t[i+1]},{x:+t[i+2],y:+t[i+3]},{x:+t[i+4],y:+t[i+5]}];e?i?r-4===i?a[3]={x:+t[0],y:+t[1]}:r-2===i&&(a[2]={x:+t[0],y:+t[1]},a[3]={x:+t[2],y:+t[3]}):a[0]={x:+t[r-2],y:+t[r-1]}:r-4===i?a[3]=a[2]:i||(a[0]={x:+t[i],y:+t[i+1]}),n.push(["C",(-a[0].x+6*a[1].x+a[2].x)/6,(-a[0].y+6*a[1].y+a[2].y)/6,(a[1].x+6*a[2].x-a[3].x)/6,(a[1].y+6*a[2].y-a[3].y)/6,a[2].x,a[2].y])}return n},p=function(t,e,n,i,r){var a=[];if(null===r&&null===i&&(i=n),t=+t,e=+e,n=+n,i=+i,null!==r){var o=Math.PI/180,s=t+n*Math.cos(-i*o),l=t+n*Math.cos(-r*o);a=[["M",s,e+n*Math.sin(-i*o)],["A",n,n,0,+(r-i>180),0,l,e+n*Math.sin(-r*o)]]}else a=[["M",t,e],["m",0,-i],["a",n,i,0,1,1,0,2*i],["a",n,i,0,1,1,0,-2*i],["z"]];return a},g=function(t){if(!(t=h(t))||!t.length)return[["M",0,0]];var e,n,i=[],r=0,a=0,o=0,s=0,l=0;"M"===t[0][0]&&(o=r=+t[0][1],s=a=+t[0][2],l++,i[0]=["M",r,a]);for(var u,c,g=3===t.length&&"M"===t[0][0]&&"R"===t[1][0].toUpperCase()&&"Z"===t[2][0].toUpperCase(),d=l,v=t.length;d1&&(i*=w=Math.sqrt(w),r*=w);var S=i*i,M=r*r,C=(o===s?-1:1)*Math.sqrt(Math.abs((S*M-S*b*b-M*_*_)/(S*b*b+M*_*_)));g=C*i*b/r+(e+l)/2,d=C*-r*_/i+(n+u)/2,f=Math.asin(((n-d)/r).toFixed(9)),p=Math.asin(((u-d)/r).toFixed(9)),f=ep&&(f-=2*Math.PI),!s&&p>f&&(p-=2*Math.PI)}var A=p-f;if(Math.abs(A)>v){var k=p,P=l,T=u;p=f+v*(s&&p>f?1:-1),x=t(l=g+i*Math.cos(p),u=d+r*Math.sin(p),i,r,a,0,s,P,T,[p,k,g,d])}A=p-f;var I=Math.cos(f),O=Math.sin(f),L=Math.cos(p),E=Math.sin(p),D=Math.tan(A/4),F=4/3*i*D,B=4/3*r*D,R=[e,n],j=[e+F*O,n-B*I],N=[l+F*E,u-B*L],z=[l,u];if(j[0]=2*R[0]-j[0],j[1]=2*R[1]-j[1],c)return[j,N,z].concat(x);for(var Y=[],V=0,X=(x=[j,N,z].concat(x).join().split(",")).length;V7){t[e].shift();for(var a=t[e];a.length;)s[e]="A",r&&(l[e]="A"),t.splice(e++,0,["C"].concat(a.splice(0,6)));t.splice(e,1),n=Math.max(i.length,r&&r.length||0)}},p=function(t,e,a,o,s){t&&e&&"M"===t[s][0]&&"M"!==e[s][0]&&(e.splice(s,0,["M",o.x,o.y]),a.bx=0,a.by=0,a.x=t[s][1],a.y=t[s][2],n=Math.max(i.length,r&&r.length||0))};n=Math.max(i.length,r&&r.length||0);for(var y=0;y1?1:l<0?0:l)/2,c=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],h=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],f=0,p=0;p<12;p++){var g=u*c[p]+u,d=_(g,t,n,r,o),v=_(g,e,i,a,s),y=d*d+v*v;f+=h[p]*Math.sqrt(y)}return u*f},w=function(t,e,n,i,r,a,o,s){if(!(Math.max(t,n)Math.max(r,o)||Math.max(e,i)Math.max(a,s))){var l=(t-n)*(a-s)-(e-i)*(r-o);if(l){var u=((t*i-e*n)*(r-o)-(t-n)*(r*s-a*o))/l,c=((t*i-e*n)*(a-s)-(e-i)*(r*s-a*o))/l,h=+u.toFixed(2),f=+c.toFixed(2);if(!(h<+Math.min(t,n).toFixed(2)||h>+Math.max(t,n).toFixed(2)||h<+Math.min(r,o).toFixed(2)||h>+Math.max(r,o).toFixed(2)||f<+Math.min(e,i).toFixed(2)||f>+Math.max(e,i).toFixed(2)||f<+Math.min(a,s).toFixed(2)||f>+Math.max(a,s).toFixed(2)))return{x:u,y:c}}}},S=function(t,e,n){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height},M=function(t,e,n,i,r){if(r)return[["M",+t+ +r,e],["l",n-2*r,0],["a",r,r,0,0,1,r,r],["l",0,i-2*r],["a",r,r,0,0,1,-r,r],["l",2*r-n,0],["a",r,r,0,0,1,-r,-r],["l",0,2*r-i],["a",r,r,0,0,1,r,-r],["z"]];var a=[["M",t,e],["l",n,0],["l",0,i],["l",-n,0],["z"]];return a.parsePathArray=m,a},C=function(t,e,n,i){return null===t&&(t=e=n=i=0),null===e&&(e=t.y,n=t.width,i=t.height,t=t.x),{x:t,y:e,width:n,w:n,height:i,h:i,x2:t+n,y2:e+i,cx:t+n/2,cy:e+i/2,r1:Math.min(n,i)/2,r2:Math.max(n,i)/2,r0:Math.sqrt(n*n+i*i)/2,path:M(t,e,n,i),vb:[t,e,n,i].join(" ")}},A=function(t,e,n,i,r,a,o,l){s.isArray(t)||(t=[t,e,n,i,r,a,o,l]);var u=function(t,e,n,i,r,a,o,s){for(var l,u,c,h,f=[],p=[[],[]],g=0;g<2;++g)if(0===g?(u=6*t-12*n+6*r,l=-3*t+9*n-9*r+3*o,c=3*n-3*t):(u=6*e-12*i+6*a,l=-3*e+9*i-9*a+3*s,c=3*i-3*e),Math.abs(l)<1e-12){if(Math.abs(u)<1e-12)continue;(h=-c/u)>0&&h<1&&f.push(h)}else{var d=u*u-4*c*l,v=Math.sqrt(d);if(!(d<0)){var y=(-u+v)/(2*l);y>0&&y<1&&f.push(y);var x=(-u-v)/(2*l);x>0&&x<1&&f.push(x)}}for(var m,_=f.length,b=_;_--;)m=1-(h=f[_]),p[0][_]=m*m*m*t+3*m*m*h*n+3*m*h*h*r+h*h*h*o,p[1][_]=m*m*m*e+3*m*m*h*i+3*m*h*h*a+h*h*h*s;return p[0][b]=t,p[1][b]=e,p[0][b+1]=o,p[1][b+1]=s,p[0].length=p[1].length=b+2,{min:{x:Math.min.apply(0,p[0]),y:Math.min.apply(0,p[1])},max:{x:Math.max.apply(0,p[0]),y:Math.max.apply(0,p[1])}}}.apply(null,t);return C(u.min.x,u.min.y,u.max.x-u.min.x,u.max.y-u.min.y)},k=function(t,e,n,i,r,a,o,s,l){var u=1-l,c=Math.pow(u,3),h=Math.pow(u,2),f=l*l,p=f*l,g=t+2*l*(n-t)+f*(r-2*n+t),d=e+2*l*(i-e)+f*(a-2*i+e),v=n+2*l*(r-n)+f*(o-2*r+n),y=i+2*l*(a-i)+f*(s-2*a+i);return{x:c*t+3*h*l*n+3*u*l*l*r+p*o,y:c*e+3*h*l*i+3*u*l*l*a+p*s,m:{x:g,y:d},n:{x:v,y:y},start:{x:u*t+l*n,y:u*e+l*i},end:{x:u*r+l*o,y:u*a+l*s},alpha:90-180*Math.atan2(g-v,d-y)/Math.PI}},P=function(t,e,n){if(!function(t,e){return t=C(t),e=C(e),S(e,t.x,t.y)||S(e,t.x2,t.y)||S(e,t.x,t.y2)||S(e,t.x2,t.y2)||S(t,e.x,e.y)||S(t,e.x2,e.y)||S(t,e.x,e.y2)||S(t,e.x2,e.y2)||(t.xe.x||e.xt.x)&&(t.ye.y||e.yt.y)}(A(t),A(e)))return n?0:[];for(var i=~~(b.apply(0,t)/8),r=~~(b.apply(0,e)/8),a=[],o=[],s={},l=n?0:[],u=0;u=0&&P<=1&&T>=0&&T<=1&&(n?l++:l.push({x:M.x,y:M.y,t1:P,t2:T}))}}return l},T=function(t,e,n){if(1===n)return[[].concat(t)];var r=[];if("L"===e[0]||"C"===e[0]||"Q"===e[0])r=r.concat(function(t,e,n){var r=[[t[1],t[2]]];n=n||2;var a=[];"A"===e[0]?(r.push(e[6]),r.push(e[7])):"C"===e[0]?(r.push([e[1],e[2]]),r.push([e[3],e[4]]),r.push([e[5],e[6]])):"S"===e[0]||"Q"===e[0]?(r.push([e[1],e[2]]),r.push([e[3],e[4]])):r.push([e[1],e[2]]);for(var o=r,s=1/n,l=0;l=3&&(3===t.length&&e.push("Q"),e=e.concat(t[1])),2===t.length&&e.push("L"),e=e.concat(t[t.length-1])})}(t,e,n));else{var a=[].concat(t);"M"===a[0]&&(a[0]="L");for(var o=0;o<=n-1;o++)r.push(a)}return r},I=function(t,e){if(t.length!==e.length)return!1;var n=!0;return s.each(t,function(t,i){if(t!==e[i])return n=!1,!1}),n};t.exports={parsePathString:h,parsePathArray:m,pathTocurve:y,pathToAbsolute:g,catmullRomToBezier:f,rectPath:M,fillPath:function(t,e){if(1===t.length)return t;var n=t.length-1,i=e.length-1,r=n/i,a=[];if(1===t.length&&"M"===t[0][0]){for(var o=0;o=0;f--)s=o[f].index,"add"===o[f].type?t.splice(s,0,[].concat(t[s])):t.splice(s,1)}var p=a-(i=t.length);if(i0)){t[i]=e[i];break}n=a(n,t[i-1],1)}t[i]=["Q"].concat(n.reduce(function(t,e){return t.concat(e)},[]));break;case"T":t[i]=["T"].concat(n[0]);break;case"C":if(n.length<3){if(!(i>0)){t[i]=e[i];break}n=a(n,t[i-1],2)}t[i]=["C"].concat(n.reduce(function(t,e){return t.concat(e)},[]));break;case"S":if(n.length<2){if(!(i>0)){t[i]=e[i];break}n=a(n,t[i-1],1)}t[i]=["S"].concat(n.reduce(function(t,e){return t.concat(e)},[]));break;default:t[i]=e[i]}return t},intersection:function(t,e){return function(t,e,n){t=y(t),e=y(e);for(var i,r,a,o,s,l,u,c,h,f,p=n?0:[],g=0,d=t.length;g=0&&e._call.call(null,t),e=e._next;--p}function l(){x=(y=_.now())+m,p=g=0;try{s()}finally{p=0,function(){var t,e,n=h,i=1/0;for(;n;)n._call?(i>n._time&&(i=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:h=e);f=t,c(i)}(),x=0}}function u(){var t=_.now(),e=t-y;e>v&&(m-=e,y=t)}function c(t){if(!p){g&&(g=clearTimeout(g));t-x>24?(t<1/0&&(g=setTimeout(l,t-_.now()-m)),d&&(d=clearInterval(d))):(d||(y=_.now(),d=setInterval(u,v)),p=1,b(l))}}e.b=i,e.a=a,e.c=o,e.d=s;var h,f,p=0,g=0,d=0,v=1e3,y=0,x=0,m=0,_="object"==typeof performance&&performance.now?performance:Date,b="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};a.prototype=o.prototype={constructor:a,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?i():+n)+(null==e?0:+e),this._next||f===this||(f?f._next=this:h=this,f=this),this._call=t,this._time=n,c()},stop:function(){this._call&&(this._call=null,this._time=1/0,c())}}},function(t,e,n){"use strict";var i=n(19),r=n(119),a=n(122),o=n(123),s=n(40),l=n(124),u=n(125),c=n(121);e.a=function(t,e){var n,h=typeof e;return null==e||"boolean"===h?Object(c.a)(e):("number"===h?s.a:"string"===h?(n=Object(i.a)(e))?(e=n,r.a):u.a:e instanceof i.a?r.a:e instanceof Date?o.a:Array.isArray(e)?a.a:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?l.a:s.a)(t,e)}},function(t,e,n){"use strict";function i(){}function r(t){var e;return t=(t+"").trim().toLowerCase(),(e=_.exec(t))?(e=parseInt(e[1],16),new u(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1)):(e=b.exec(t))?a(parseInt(e[1],16)):(e=w.exec(t))?new u(e[1],e[2],e[3],1):(e=S.exec(t))?new u(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=M.exec(t))?o(e[1],e[2],e[3],e[4]):(e=C.exec(t))?o(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=A.exec(t))?c(e[1],e[2]/100,e[3]/100,1):(e=k.exec(t))?c(e[1],e[2]/100,e[3]/100,e[4]):P.hasOwnProperty(t)?a(P[t]):"transparent"===t?new u(NaN,NaN,NaN,0):null}function a(t){return new u(t>>16&255,t>>8&255,255&t,1)}function o(t,e,n,i){return i<=0&&(t=e=n=NaN),new u(t,e,n,i)}function s(t){return t instanceof i||(t=r(t)),t?(t=t.rgb(),new u(t.r,t.g,t.b,t.opacity)):new u}function l(t,e,n,i){return 1===arguments.length?s(t):new u(t,e,n,null==i?1:i)}function u(t,e,n,i){this.r=+t,this.g=+e,this.b=+n,this.opacity=+i}function c(t,e,n,i){return i<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new f(t,e,n,i)}function h(t,e,n,a){return 1===arguments.length?function(t){if(t instanceof f)return new f(t.h,t.s,t.l,t.opacity);if(t instanceof i||(t=r(t)),!t)return new f;if(t instanceof f)return t;var e=(t=t.rgb()).r/255,n=t.g/255,a=t.b/255,o=Math.min(e,n,a),s=Math.max(e,n,a),l=NaN,u=s-o,c=(s+o)/2;return u?(l=e===s?(n-a)/u+6*(n0&&c<1?0:l,new f(l,u,c,t.opacity)}(t):new f(t,e,n,null==a?1:a)}function f(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}function p(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}e.a=i,n.d(e,"d",function(){return d}),n.d(e,"c",function(){return v}),e.e=r,e.h=s,e.g=l,e.b=u,e.f=h;var g=n(61),d=.7,v=1/d,y="\\s*([+-]?\\d+)\\s*",x="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",m="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",_=/^#([0-9a-f]{3})$/,b=/^#([0-9a-f]{6})$/,w=new RegExp("^rgb\\("+[y,y,y]+"\\)$"),S=new RegExp("^rgb\\("+[m,m,m]+"\\)$"),M=new RegExp("^rgba\\("+[y,y,y,x]+"\\)$"),C=new RegExp("^rgba\\("+[m,m,m,x]+"\\)$"),A=new RegExp("^hsl\\("+[x,m,m]+"\\)$"),k=new RegExp("^hsla\\("+[x,m,m,x]+"\\)$"),P={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Object(g.a)(i,r,{displayable:function(){return this.rgb().displayable()},toString:function(){return this.rgb()+""}}),Object(g.a)(u,l,Object(g.b)(i,{brighter:function(t){return t=null==t?v:Math.pow(v,t),new u(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?d:Math.pow(d,t),new u(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return 0<=this.r&&this.r<=255&&0<=this.g&&this.g<=255&&0<=this.b&&this.b<=255&&0<=this.opacity&&this.opacity<=1},toString:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}})),Object(g.a)(f,h,Object(g.b)(i,{brighter:function(t){return t=null==t?v:Math.pow(v,t),new f(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?d:Math.pow(d,t),new f(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*e,r=2*n-i;return new u(p(t>=240?t-240:t+120,r,i),p(t,r,i),p(t<120?t+240:t-120,r,i),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1}}))},function(t,e,n){"use strict";e.b=function(t,e){var n=Object.create(t.prototype);for(var i in e)n[i]=e[i];return n},e.a=function(t,e,n){t.prototype=e.prototype=n,n.constructor=t}},function(t,e,n){"use strict";function i(t,e,n,i,r){var a=t*t,o=a*t;return((1-3*t+3*a-o)*e+(4-6*a+3*o)*n+(1+3*t+3*a-3*o)*i+o*r)/6}e.a=i,e.b=function(t){var e=t.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,e-1):Math.floor(n*e),a=t[r],o=t[r+1],s=r>0?t[r-1]:2*a-o,l=r0&&e.lineToLabel(t)})},n.lineToLabel=function(){},n.getLabelPoint=function(t,e,n){function i(e,n){return o.isArray(e)&&(e=1===t.text.length?e.length<=2?e[e.length-1]:function(t){var e=0;return o.each(t,function(t){e+=t}),e/t.length}(e):e[n]),e}var r=this.get("coord"),a=t.text.length,s={text:t.text[n]};if(e&&"polygon"===this.get("geomType")){var l=function(t,e){for(var n,i,r=-1,a=0,o=0,s=t.length-1,l=0;++ru&&(u=t.x)}),s.x=(s.x+u)/2}"pyramid"===e.shape&&!e.nextPoints&&e.points&&e.points.forEach(function(t){t=r.convert(t),(o.isArray(t.x)&&-1===e.x.indexOf(t.x)||o.isNumber(t.x)&&e.x!==t.x)&&(s.x=(s.x+t.x)/2)}),t.position&&this.setLabelPosition(s,e,n,t.position);var c=this.getLabelOffset(t,n,a);return t.offsetX&&(c.x+=t.offsetX),t.offsetY&&(c.y+=t.offsetY),this.transLabelPoint(s),s.start={x:s.x,y:s.y},s.x+=c.x,s.y+=c.y,s.color=e.color,s},n.setLabelPosition=function(){},n.transLabelPoint=function(t){var e=this.get("coord").applyMatrix(t.x,t.y,1);t.x=e[0],t.y=e[1]},n.getOffsetVector=function(t){var e=t.offset||0,n=this.get("coord");return n.isTransposed?n.applyMatrix(e,0):n.applyMatrix(0,e)},n.getDefaultOffset=function(t){var e=this.get("coord"),n=this.getOffsetVector(t);return e.isTransposed?n[0]:n[1]},n.getLabelOffset=function(t,e,n){var i=this.getDefaultOffset(t),r=this.get("coord").isTransposed,a=r?"x":"y",o=r?1:-1,s={x:0,y:0};return s[a]=e>0||1===n?i*o:i*o*-1,s},n.getLabelAlign=function(t,e,n){var i="center";if(this.get("coord").isTransposed){var r=this.getDefaultOffset(t);i=r<0?"right":0===r?"center":"left",n>1&&0===e&&("right"===i?i="left":"left"===i&&(i="right"))}return i},n._getLabelValue=function(t,e){o.isArray(e)||(e=[e]);var n=[];return o.each(e,function(e){var i=t[e.field];if(o.isArray(i)){var r=[];o.each(i,function(t){r.push(e.getText(t))}),i=r}else i=e.getText(i);(o.isNil(i)||""===i)&&n.push(null),n.push(i)}),n},n._getLabelCfgs=function(t){var e=this,n=this.get("labelCfg"),i=n.scales,r=this.get("label"),a=[];n.globalCfg&&n.globalCfg.type&&e.set("type",n.globalCfg.type),o.each(t,function(t,s){var l={},u=t._origin,c=e._getLabelValue(u,i);if(n.callback){var h=i.map(function(t){return u[t.field]});l=n.callback.apply(null,h)}if(l||0===l){if(o.isString(l)||o.isNumber(l)?l={text:l}:(l.text=l.content||c[0],delete l.content),l=o.mix({},r,n.globalCfg||{},l),t.point=u,l.htmlTemplate&&(l.useHtml=!0,l.text=l.htmlTemplate.call(null,l.text,t,s),delete l.htmlTemplate),l.formatter&&(l.text=l.formatter.call(null,l.text,t,s),delete l.formatter),l.label){var f=l.label;delete l.label,l=o.mix(l,f)}if(l.textStyle){delete l.textStyle.offset;var p=l.textStyle;o.isFunction(p)&&(l.textStyle=p.call(null,l.text,t,s))}l.labelLine&&(l.labelLine=o.mix({},r.labelLine,l.labelLine)),l.textStyle=o.mix({},r.textStyle,l.textStyle),delete l.items,a.push(l)}else a.push(null)}),this.set("labelItemCfgs",a)},n.showLabels=function(t,e){var n=this.get("labelRenderer"),i=this.getLabelsItems(t,e);e=[].concat(e);var r=this.get("type");i=this.adjustItems(i,e),this.drawLines(i),n.set("items",i.filter(function(t,n){return!!t||(e.splice(n,1),!1)})),r&&(n.set("shapes",e),n.set("type",r),n.set("points",t)),n.set("canvas",this.get("canvas")),n.draw()},n.destroy=function(){this.get("labelRenderer").destroy(),t.prototype.destroy.call(this)},e}(i);t.exports=l},function(t,e,n){function i(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var r=n(53),a=n(3),o=function(t){function e(e){var n,r=i(i(n=t.call(this)||this)),o={visible:!0},s=r.getDefaultCfg();return r._attrs=o,a.deepMix(o,s,e),n}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){return{}},n.get=function(t){return this._attrs[t]},n.set=function(t,e){this._attrs[t]=e},n.changeVisible=function(){},n.destroy=function(){this._attrs={},this.removeAllListeners(),this.destroyed=!0},e}(r);t.exports=o},function(t,e,n){var i=n(3),r=n(158),a=n(327),o=n(14).FONT_FAMILY,s=i.Event,l=i.Group,u=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return i.mix({},e,{type:"continuous-legend",items:null,layout:"vertical",width:20,height:156,textStyle:{fill:"#333",textAlign:"center",textBaseline:"middle",stroke:"#fff",lineWidth:5,fontFamily:o},hoverTextStyle:{fill:"rgba(0,0,0,0.25)"},slidable:!0,triggerAttr:{fill:"#fff",shadowBlur:10,shadowColor:"rgba(0,0,0,0.65)",radius:2},_range:[0,100],middleBackgroundStyle:{fill:"#D9D9D9"},textOffset:4,lineStyle:{lineWidth:1,stroke:"#fff"},pointerStyle:{fill:"rgb(230, 230, 230)"}})},n._calStartPoint=function(){var t={x:10,y:this.get("titleGap")-8},e=this.get("titleShape");if(e){var n=e.getBBox();t.y+=n.height}return t},n.beforeRender=function(){var e=this.get("items");i.isArray(e)&&!i.isEmpty(e)&&(t.prototype.beforeRender.call(this),this.set("firstItem",e[0]),this.set("lastItem",e[e.length-1]))},n._formatItemValue=function(t){var e=this.get("formatter")||this.get("itemFormatter");return e&&(t=e.call(this,t)),t},n.render=function(){t.prototype.render.call(this),this.get("slidable")?this._renderSlider():this._renderUnslidable()},n._renderSlider=function(){var t=new l,e=new l,n=new l,i=this._calStartPoint(),r=this.get("group").addGroup(a,{minHandleElement:t,maxHandleElement:e,backgroundElement:n,layout:this.get("layout"),range:this.get("_range"),width:this.get("width"),height:this.get("height")});r.translate(i.x,i.y),this.set("slider",r);this._renderSliderShape().attr("clip",r.get("middleHandleElement")),this._renderTrigger()},n._addMiddleBar=function(t,e,n){return t.addShape(e,{attrs:i.mix({},n,this.get("middleBackgroundStyle"))}),t.addShape(e,{attrs:n})},n._renderTrigger=function(){var t=this.get("firstItem"),e=this.get("lastItem"),n=this.get("layout"),r=this.get("textStyle"),a=this.get("triggerAttr"),o=i.mix({},a),s=i.mix({},a),l=i.mix({text:this._formatItemValue(t.value)+""},r),u=i.mix({text:this._formatItemValue(e.value)+""},r);"vertical"===n?(this._addVerticalTrigger("min",o,l),this._addVerticalTrigger("max",s,u)):(this._addHorizontalTrigger("min",o,l),this._addHorizontalTrigger("max",s,u))},n._addVerticalTrigger=function(t,e,n){var r=this.get("slider").get(t+"HandleElement"),a=this.get("width"),o=r.addShape("rect",{attrs:i.mix({x:a/2-8-2,y:"min"===t?0:-8,width:18,height:8},e)}),s=r.addShape("text",{attrs:i.mix(n,{x:a+this.get("textOffset"),y:"max"===t?-4:4,textAlign:"start",lineHeight:1,textBaseline:"middle"})}),l="vertical"===this.get("layout")?"ns-resize":"ew-resize";o.attr("cursor",l),s.attr("cursor",l),this.set(t+"ButtonElement",o),this.set(t+"TextElement",s)},n._addHorizontalTrigger=function(t,e,n){var r=this.get("slider").get(t+"HandleElement"),a=r.addShape("rect",{attrs:i.mix({x:"min"===t?-8:0,y:-8-this.get("height")/2,width:8,height:16},e)}),o=r.addShape("text",{attrs:i.mix(n,{x:"min"===t?-12:12,y:4+this.get("textOffset")+10,textAlign:"min"===t?"end":"start",textBaseline:"middle"})}),s="vertical"===this.get("layout")?"ns-resize":"ew-resize";a.attr("cursor",s),o.attr("cursor",s),this.set(t+"ButtonElement",a),this.set(t+"TextElement",o)},n._bindEvents=function(){var t=this;if(this.get("slidable")){this.get("slider").on("sliderchange",function(e){var n=e.range,i=t.get("firstItem").value,r=t.get("lastItem").value,a=i+n[0]/100*(r-i),o=i+n[1]/100*(r-i);t._updateElement(a,o);var l=new s("itemfilter",e,!0,!0);l.range=[a,o],t.emit("itemfilter",l)})}this.get("hoverable")&&(this.get("group").on("mousemove",i.wrapBehavior(this,"_onMouseMove")),this.get("group").on("mouseleave",i.wrapBehavior(this,"_onMouseLeave")))},n._updateElement=function(t,e){var n=this.get("minTextElement"),i=this.get("maxTextElement");e>1&&(t=parseInt(t,10),e=parseInt(e,10)),n.attr("text",this._formatItemValue(t)+""),i.attr("text",this._formatItemValue(e)+"")},n._onMouseLeave=function(){var t=this.get("group").findById("hoverPointer");t&&t.destroy();var e=this.get("group").findById("hoverText");e&&e.destroy(),this.get("canvas").draw()},n._onMouseMove=function(t){var e,n=this.get("height"),i=this.get("width"),r=this.get("items"),a=this.get("canvas").get("el").getBoundingClientRect(),o=this.get("group").getBBox();if("vertical"===this.get("layout")){var s=5;"color-legend"===this.get("type")&&(s=30);var l=this.get("titleGap"),u=this.get("titleShape");u&&(l+=u.getBBox().maxY-u.getBBox().minY);var c=t.clientY||t.event.clientY;c=c-a.y-this.get("group").attr("matrix")[7]+o.y-s+l,e=r[0].value+(1-c/n)*(r[r.length-1].value-r[0].value)}else{var h=t.clientX||t.event.clientX;h=h-a.x-this.get("group").attr("matrix")[6],e=r[0].value+h/i*(r[r.length-1].value-r[0].value)}e=e.toFixed(2),this.activate(e),this.emit("mousehover",{value:e})},n.activate=function(t){if(t){var e=this.get("group").findById("hoverPointer"),n=this.get("group").findById("hoverText"),r=this.get("items");if(!(tr[r.length-1].value)){var a,o=this.get("height"),s=this.get("width"),l=this.get("titleShape"),u=this.get("titleGap"),c=[],h=(t-r[0].value)/(r[r.length-1].value-r[0].value);if("vertical"===this.get("layout")){var f=0,p=0;"color-legend"===this.get("type")&&(f=u,l&&(f+=l.getBBox().height)),this.get("slidable")&&("color-legend"===this.get("type")?f-=13:(f=u-15,l&&(f+=l.getBBox().height)),p+=10),c=[[p,(h=(1-h)*o)+f],[p-10,h+f-5],[p-10,h+f+5]],a=i.mix({},{x:s+this.get("textOffset")/2+p,y:h+f,text:this._formatItemValue(t)+""},this.get("textStyle"),{textAlign:"start"})}else{var g=0,d=0;"color-legend"===this.get("type")&&(g=u,l&&(g+=l.getBBox().height)),this.get("slidable")&&("color-legend"===this.get("type")?g-=7:(g=u,l||(g-=7)),d+=10),c=[[(h*=s)+d,g],[h+d-5,g-10],[h+d+5,g-10]],a=i.mix({},{x:h-5,y:o+this.get("textOffset")+g,text:this._formatItemValue(t)+""},this.get("textStyle"))}var v=i.mix(a,this.get("hoverTextStyle"));n?n.attr(v):(n=this.get("group").addShape("text",{attrs:v})).set("id","hoverText"),e?e.attr(i.mix({points:c},this.get("pointerStyle"))):(e=this.get("group").addShape("Polygon",{attrs:i.mix({points:c},this.get("pointerStyle"))})).set("id","hoverPointer"),this.get("canvas").draw()}}},n.deactivate=function(){var t=this.get("group").findById("hoverPointer");t&&t.destroy();var e=this.get("group").findById("hoverText");e&&e.destroy(),this.get("canvas").draw()},e}(r);t.exports=u},function(t,e,n){var i=n(66),r=n(3),a=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return r.mix({},e,{x:0,y:0,items:null,titleContent:null,showTitle:!0,plotRange:null,offset:10,timeStamp:0,inPlot:!0,crosshairs:null})},n.isContentChange=function(t,e){var n=this.get("titleContent"),i=this.get("items"),a=!(t===n&&i.length===e.length);return a||r.each(e,function(t,e){var n=i[e];for(var o in t)if(t.hasOwnProperty(o)&&!r.isObject(t[o])&&t[o]!==n[o]){a=!0;break}if(a)return!1}),a},n.setContent=function(t,e){var n=(new Date).valueOf();return this.set("items",e),this.set("titleContent",t),this.set("timeStamp",n),this.render(),this},n.setPosition=function(t,e){this.set("x",t),this.set("y",e)},n.render=function(){},n.clear=function(){},n.show=function(){this.set("visible",!0)},n.hide=function(){this.set("visible",!1)},n.destroy=function(){},e}(i);t.exports=a},function(t,e,n){"use strict";function i(t,e){this._groups=t,this._parents=e}function r(){return new i([[document.documentElement]],F)}n.d(e,"c",function(){return F}),e.a=i;var a=n(402),o=n(403),s=n(404),l=n(405),u=n(382),c=n(407),h=n(408),f=n(409),p=n(410),g=n(411),d=n(412),v=n(413),y=n(414),x=n(415),m=n(416),_=n(417),b=n(384),w=n(418),S=n(419),M=n(420),C=n(421),A=n(422),k=n(423),P=n(424),T=n(425),I=n(426),O=n(427),L=n(428),E=n(374),D=n(429),F=[null];i.prototype=r.prototype={constructor:i,select:a.a,selectAll:o.a,filter:s.a,data:l.a,enter:u.b,exit:c.a,merge:h.a,order:f.a,sort:p.a,call:g.a,nodes:d.a,node:v.a,size:y.a,empty:x.a,each:m.a,attr:_.a,style:b.a,property:w.a,classed:S.a,text:M.a,html:C.a,raise:A.a,lower:k.a,append:P.a,insert:T.a,remove:I.a,clone:O.a,datum:L.a,on:E.b,dispatch:D.a},e.b=r},function(t,e,n){"use strict";function i(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}n.d(e,"c",function(){return u}),n.d(e,"d",function(){return c}),n.d(e,"b",function(){return p}),n.d(e,"a",function(){return g}),e.g=function(t,e){var n=i(t,e);if(n.state>l)throw new Error("too late; already scheduled");return n},e.h=function(t,e){var n=i(t,e);if(n.state>c)throw new Error("too late; already started");return n},e.f=i;var r=n(438),a=n(170),o=Object(r.a)("start","end","interrupt"),s=[],l=0,u=1,c=2,h=3,f=4,p=5,g=6;e.e=function(t,e,n,i,r,d){var v=t.__transition;if(v){if(n in v)return}else t.__transition={};!function(t,e,n){function i(p){var d,v,y,x;if(n.state!==u)return o();for(d in l)if((x=l[d]).name===n.name){if(x.state===h)return Object(a.timeout)(i);x.state===f?(x.state=g,x.timer.stop(),x.on.call("interrupt",t,t.__data__,x.index,x.group),delete l[d]):+d0?new Date(t).getTime():new Date(t.replace(/-/gi,"/")).getTime()),r(t)&&(t=t.getTime()),t}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(401);n.d(e,"create",function(){return i.a});var r=n(360);n.d(e,"creator",function(){return r.a});var a=n(430);n.d(e,"local",function(){return a.a});var o=n(381);n.d(e,"matcher",function(){return o.a});var s=n(431);n.d(e,"mouse",function(){return s.a});var l=n(370);n.d(e,"namespace",function(){return l.a});var u=n(371);n.d(e,"namespaces",function(){return u.a});var c=n(361);n.d(e,"clientPoint",function(){return c.a});var h=n(379);n.d(e,"select",function(){return h.a});var f=n(432);n.d(e,"selectAll",function(){return f.a});var p=n(69);n.d(e,"selection",function(){return p.b});var g=n(372);n.d(e,"selector",function(){return g.a});var d=n(380);n.d(e,"selectorAll",function(){return d.a});var v=n(384);n.d(e,"style",function(){return v.b});var y=n(433);n.d(e,"touch",function(){return y.a});var x=n(434);n.d(e,"touches",function(){return x.a});var m=n(373);n.d(e,"window",function(){return m.a});var _=n(374);n.d(e,"event",function(){return _.c}),n.d(e,"customEvent",function(){return _.a})},function(t,e,n){t.exports={Position:n(292),Color:n(293),Shape:n(294),Size:n(295),Opacity:n(296),ColorUtil:n(149)}},function(t,e,n){var i=n(75),r=n(17);r.Linear=n(33),r.Identity=n(175),r.Cat=n(77),r.Time=n(176),r.TimeCat=n(178),r.Log=n(179),r.Pow=n(180);var a=function(t){if(r.hasOwnProperty(t)){var e=i(t);r[e]=function(e){return new r[t](e)}}};for(var o in r)a(o);var s=["cat","timeCat"];r.isCategory=function(t){return s.indexOf(t)>=0},t.exports=r},function(t,e,n){var i=n(23);t.exports=function(t){var e=i(t);return e.charAt(0).toLowerCase()+e.substring(1)}},function(t,e){function n(t,e){var n=t.length;if(0===n)return NaN;var i=t[0];if(e=t[n-1])return t[n-1];for(var r=1;rt[n-1])return NaN;if(er&&(e=parseFloat(e.toFixed(n)))}else for(;t>10;)e*=10,t/=10;return e}(t*=i);i*=o,t/=o}var s=(t="floor"===n?a.snapFloor(e,t):"ceil"===n?a.snapCeiling(e,t):a.snapTo(e,t))*i;if(Math.abs(i)<1&&s.toString().length>r){s=t/parseInt(1/i)*(i>0?1:-1)}return s},snapMultiple:function(t,e,n){return("ceil"===n?Math.ceil(t/e):"floor"===n?Math.floor(t/e):Math.round(t/e))*e},snapTo:function(t,e){var r=n(t,e),a=i(t,e);if(isNaN(r)||isNaN(a)){if(t[0]>=e)return t[0];var o=t[t.length-1];if(o<=e)return o}return Math.abs(e-r)20&&(r=20),parseFloat(t.toFixed(r))}};t.exports=a},function(t,e,n){var i=n(17),r=n(78),a=n(2),o=n(9),s=n(10),l=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n._initDefaultCfg=function(){t.prototype._initDefaultCfg.call(this),this.type="cat",this.isCategory=!0,this.isRounding=!0},n.init=function(){var t=this.values,e=this.tickCount;if(a(t,function(e,n){t[n]=e.toString()}),!this.ticks){var n=t;if(e){n=r({maxCount:e,data:t,isRounding:this.isRounding}).ticks}this.ticks=n}},n.getText=function(e){return-1===this.values.indexOf(e)&&o(e)&&(e=this.values[Math.round(e)]),t.prototype.getText.call(this,e)},n.translate=function(t){var e=this.values.indexOf(t);return-1===e&&o(t)?e=t:-1===e&&(e=NaN),e},n.scale=function(t){var e,n=this.rangeMin(),i=this.rangeMax();return(s(t)||-1!==this.values.indexOf(t))&&(t=this.translate(t)),e=this.values.length>1?t/(this.values.length-1):t,n+e*(i-n)},n.invert=function(t){if(s(t))return t;var e=this.rangeMin(),n=this.rangeMax();tn&&(t=n);var i=(t-e)/(n-e),r=Math.round(i*(this.values.length-1))%this.values.length;return r=r||0,this.values[r]},e}(i);i.Cat=l,t.exports=l},function(t,e,n){var i=n(2);t.exports=function(t){var e,n={},r=[],a=t.isRounding,o=function(t){var e=[];return i(t,function(t){e=e.concat(t)}),e}(t.data),s=o.length,l=t.maxCount||8;if(a?2===(e=function(t,e){var n;for(n=e;n>0&&t%n!=0;n--);if(1===n)for(n=e;n>0&&(t-1)%n!=0;n--);return n}(s-1,l-1)+1)?e=l:e3?0:(t-t%10!=10)*t%10]}};var x={D:function(t){return t.getDate()},DD:function(t){return s(t.getDate())},Do:function(t,e){return e.DoFn(t.getDate())},d:function(t){return t.getDay()},dd:function(t){return s(t.getDay())},ddd:function(t,e){return e.dayNamesShort[t.getDay()]},dddd:function(t,e){return e.dayNames[t.getDay()]},M:function(t){return t.getMonth()+1},MM:function(t){return s(t.getMonth()+1)},MMM:function(t,e){return e.monthNamesShort[t.getMonth()]},MMMM:function(t,e){return e.monthNames[t.getMonth()]},YY:function(t){return String(t.getFullYear()).substr(2)},YYYY:function(t){return s(t.getFullYear(),4)},h:function(t){return t.getHours()%12||12},hh:function(t){return s(t.getHours()%12||12)},H:function(t){return t.getHours()},HH:function(t){return s(t.getHours())},m:function(t){return t.getMinutes()},mm:function(t){return s(t.getMinutes())},s:function(t){return t.getSeconds()},ss:function(t){return s(t.getSeconds())},S:function(t){return Math.round(t.getMilliseconds()/100)},SS:function(t){return s(Math.round(t.getMilliseconds()/10),2)},SSS:function(t){return s(t.getMilliseconds(),3)},a:function(t,e){return t.getHours()<12?e.amPm[0]:e.amPm[1]},A:function(t,e){return t.getHours()<12?e.amPm[0].toUpperCase():e.amPm[1].toUpperCase()},ZZ:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+s(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)}},m={D:[c,function(t,e){t.day=e}],Do:[new RegExp(c.source+h.source),function(t,e){t.day=parseInt(e,10)}],M:[c,function(t,e){t.month=e-1}],YY:[c,function(t,e){var n=+(""+(new Date).getFullYear()).substr(0,2);t.year=""+(e>68?n-1:n)+e}],h:[c,function(t,e){t.hour=e}],m:[c,function(t,e){t.minute=e}],s:[c,function(t,e){t.second=e}],YYYY:[/\d{4}/,function(t,e){t.year=e}],S:[/\d/,function(t,e){t.millisecond=100*e}],SS:[/\d{2}/,function(t,e){t.millisecond=10*e}],SSS:[/\d{3}/,function(t,e){t.millisecond=e}],d:[c,p],ddd:[h,p],MMM:[h,o("monthNamesShort")],MMMM:[h,o("monthNames")],a:[h,function(t,e,n){var i=e.toLowerCase();i===n.amPm[0]?t.isPm=!1:i===n.amPm[1]&&(t.isPm=!0)}],ZZ:[/([\+\-]\d\d:?\d\d|Z)/,function(t,e){"Z"===e&&(e="+00:00");var n,i=(e+"").match(/([\+\-]|\d\d)/gi);i&&(n=60*i[1]+parseInt(i[2],10),t.timezoneOffset="+"===i[0]?n:-n)}]};m.dd=m.d,m.dddd=m.ddd,m.DD=m.D,m.mm=m.m,m.hh=m.H=m.HH=m.h,m.MM=m.M,m.ss=m.s,m.A=m.a,l.masks={default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"},l.format=function(t,e,n){var i=n||l.i18n;if("number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date in fecha.format");var r=[];return e=(e=l.masks[e]||e||l.masks.default).replace(f,function(t,e){return r.push(e),"??"}),(e=e.replace(u,function(e){return e in x?x[e](t,i):e.slice(1,e.length-1)})).replace(/\?\?/g,function(){return r.shift()})},l.parse=function(t,e,n){var i=n||l.i18n;if("string"!=typeof e)throw new Error("Invalid format in fecha.parse");if(e=l.masks[e]||e,t.length>1e3)return!1;var r=!0,a={};if(e.replace(u,function(e){if(m[e]){var n=m[e],o=t.search(n[0]);~o?t.replace(n[0],function(e){return n[1](a,e,i),t=t.substr(o+e.length),e}):r=!1}return m[e]?"":e.slice(1,e.length-1)}),!r)return!1;var o=new Date;!0===a.isPm&&null!=a.hour&&12!=+a.hour?a.hour=+a.hour+12:!1===a.isPm&&12==+a.hour&&(a.hour=0);var s;return null!=a.timezoneOffset?(a.minute=+(a.minute||0)-+a.timezoneOffset,s=new Date(Date.UTC(a.year||o.getFullYear(),a.month||0,a.day||1,a.hour||0,a.minute||0,a.second||0,a.millisecond||0))):s=new Date(a.year||o.getFullYear(),a.month||0,a.day||1,a.hour||0,a.minute||0,a.second||0,a.millisecond||0),s},void 0!==t&&t.exports?t.exports=l:void 0!==(i=function(){return l}.call(e,n,e,t))&&(t.exports=i)}()},function(t,e,n){var i=n(12);t.exports=function(t){return i(t,"Date")}},function(t,e,n){t.exports={isFunction:n(11),isObject:n(24),isBoolean:n(82),isNil:n(5),isString:n(10),isArray:n(4),isNumber:n(9),isEmpty:n(83),uniqueId:n(86),clone:n(46),deepMix:n(47),assign:n(8),merge:n(47),upperFirst:n(87),each:n(2),isEqual:n(49),toArray:n(34),extend:n(88),augment:n(89),remove:n(90),isNumberEqual:n(35),toRadian:n(91),toDegree:n(92),mod:n(93),clamp:n(50),createDom:n(94),modifyCSS:n(95),requestAnimationFrame:n(96),getRatio:function(){return window.devicePixelRatio?window.devicePixelRatio:2},mat3:n(51),vec2:n(97),vec3:n(98),transform:n(99)}},function(t,e,n){var i=n(12);t.exports=function(t){return i(t,"Boolean")}},function(t,e,n){var i=n(5),r=n(13),a=n(84),o=n(85),s=Object.prototype.hasOwnProperty;t.exports=function(t){if(i(t))return!0;if(r(t))return!t.length;var e=a(t);if("Map"===e||"Set"===e)return!t.size;if(o(t))return!Object.keys(t).length;for(var n in t)if(s.call(t,n))return!1;return!0}},function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).replace(/^\[object /,"").replace(/\]$/,"")}},function(t,e){var n=Object.prototype;t.exports=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||n)}},function(t,e){var n=function(){var t={};return function(e){return e=e||"g",t[e]?t[e]+=1:t[e]=1,e+t[e]}}();t.exports=n},function(t,e,n){var i=n(23);t.exports=function(t){var e=i(t);return e.charAt(0).toUpperCase()+e.substring(1)}},function(t,e,n){var i=n(11),r=n(8);t.exports=function(t,e,n,a){i(e)||(n=e,e=t,t=function(){});var o=Object.create?function(t,e){return Object.create(t,{constructor:{value:e}})}:function(t,e){function n(){}n.prototype=t;var i=new n;return i.constructor=e,i},s=o(e.prototype,t);return t.prototype=r(s,t.prototype),t.superclass=o(e.prototype,e),r(s,n),r(t,a),t}},function(t,e,n){var i=n(11),r=n(34),a=n(8);t.exports=function(t){for(var e=r(arguments),n=1;n-1;)i.call(t,s,1);return t}},function(t,e){var n=Math.PI/180;t.exports=function(t){return n*t}},function(t,e){var n=180/Math.PI;t.exports=function(t){return n*t}},function(t,e){t.exports=function(t,e){return(t%e+e)%e}},function(t,e){var n=document.createElement("table"),i=document.createElement("tr"),r=/^\s*<(\w+|!)[^>]*>/,a={tr:document.createElement("tbody"),tbody:n,thead:n,tfoot:n,td:i,th:i,"*":document.createElement("div")};t.exports=function(t){var e=r.test(t)&&RegExp.$1;e in a||(e="*");var n=a[e];t=t.replace(/(^\s*)|(\s*$)/g,""),n.innerHTML=""+t;var i=n.childNodes[0];return n.removeChild(i),i}},function(t,e){t.exports=function(t,e){if(t)for(var n in e)e.hasOwnProperty(n)&&(t.style[n]=e[n]);return t}},function(t,e){t.exports=function(t){return(window.requestAnimationFrame||window.webkitRequestAnimationFrame||function(t){return setTimeout(t,16)})(t)}},function(t,e,n){var i=n(183),r=n(50);i.angle=function(t,e){var n=i.dot(t,e)/(i.length(t)*i.length(e));return Math.acos(r(n,-1,1))},i.direction=function(t,e){return t[0]*e[1]-e[0]*t[1]},i.angleTo=function(t,e,n){var r=i.angle(t,e),a=i.direction(t,e)>=0;return n?a?2*Math.PI-r:r:a?r:2*Math.PI-r},i.vertical=function(t,e,n){return n?(t[0]=e[1],t[1]=-1*e[0]):(t[0]=-1*e[1],t[1]=e[0]),t},t.exports=i},function(t,e,n){var i=n(184);t.exports=i},function(t,e,n){var i=n(46),r=n(2),a=n(51);t.exports=function(t,e){return t=i(t),r(e,function(e){switch(e[0]){case"t":a.translate(t,t,[e[1],e[2]]);break;case"s":a.scale(t,t,[e[1],e[2]]);break;case"r":a.rotate(t,t,e[1]);break;case"m":a.multiply(t,t,e[1]);break;default:return!1}}),t}},function(t,e,n){var i=n(1),r=function(t,e,n,i){this.type=t,this.target=null,this.currentTarget=null,this.bubbles=n,this.cancelable=i,this.timeStamp=(new Date).getTime(),this.defaultPrevented=!1,this.propagationStopped=!1,this.removed=!1,this.event=e};i.augment(r,{preventDefault:function(){this.defaultPrevented=this.cancelable&&!0},stopPropagation:function(){this.propagationStopped=!0},remove:function(){this.remove=!0},clone:function(){return i.clone(this)},toString:function(){return"[Event (type="+this.type+")]"}}),t.exports=r},function(t,e,n){function i(t,e,n){for(var i,r=t.length-1;r>=0;r--){var a=t[r];if(a._cfg.visible&&a._cfg.capture&&(a.isGroup?i=a.getShape(e,n):a.isHit(e,n)&&(i=a)),i)break}return i}function r(t){if(!t._cfg&&t!==c){var e=t.superclass.constructor;e&&!e._cfg&&r(e),t._cfg={},a.merge(t._cfg,e._cfg),a.merge(t._cfg,t.CFG)}}var a=n(1),o=n(102),s=n(188),l={},u="_INDEX",c=function t(e){t.superclass.constructor.call(this,e),this.set("children",[]),this.set("tobeRemoved",[]),this._beforeRenderUI(),this._renderUI(),this._bindUI()};a.extend(c,o),a.augment(c,{isGroup:!0,type:"group",canFill:!0,canStroke:!0,getDefaultCfg:function(){return r(this.constructor),a.merge({},this.constructor._cfg)},_beforeRenderUI:function(){},_renderUI:function(){},_bindUI:function(){},addShape:function(t,e){var n=this.get("canvas");e=e||{};var i=l[t];if(i||(i=a.upperFirst(t),l[t]=i),e.attrs&&n){var r=e.attrs;if("text"===t){var o=n.get("fontFamily");o&&(r.fontFamily=r.fontFamily?r.fontFamily:o)}}e.canvas=n,e.type=t;var u=new s[i](e);return this.add(u),u},addGroup:function(t,e){var n,i=this.get("canvas");if(e=a.merge({},e),a.isFunction(t))e?(e.canvas=i,e.parent=this,n=new t(e)):n=new t({canvas:i,parent:this}),this.add(n);else if(a.isObject(t))t.canvas=i,n=new c(t),this.add(n);else{if(void 0!==t)return!1;n=new c,this.add(n)}return n},renderBack:function(t,e){var n=this.get("backShape"),i=this.getBBox();return a.merge(e,{x:i.minX-t[3],y:i.minY-t[0],width:i.width+t[1]+t[3],height:i.height+t[0]+t[2]}),n?n.attr(e):n=this.addShape("rect",{zIndex:-1,attrs:e}),this.set("backShape",n),this.sort(),n},removeChild:function(t,e){if(arguments.length>=2)this.contain(t)&&t.remove(e);else{if(1===arguments.length){if(!a.isBoolean(t))return this.contain(t)&&t.remove(!0),this;e=t}0===arguments.length&&(e=!0),c.superclass.remove.call(this,e)}return this},add:function(t){var e=this,n=e.get("children");if(a.isArray(t))a.each(t,function(t){var n=t.get("parent");n&&n.removeChild(t,!1),e._setCfgProperty(t)}),e._cfg.children=n.concat(t);else{var i=t,r=i.get("parent");r&&r.removeChild(i,!1),e._setCfgProperty(i),n.push(i)}return e},_setCfgProperty:function(t){var e=this._cfg;t.set("parent",this),t.set("canvas",e.canvas),e.timeline&&t.set("timeline",e.timeline)},contain:function(t){return this.get("children").indexOf(t)>-1},getChildByIndex:function(t){return this.get("children")[t]},getFirst:function(){return this.getChildByIndex(0)},getLast:function(){var t=this.get("children").length-1;return this.getChildByIndex(t)},getBBox:function(){var t=1/0,e=-1/0,n=1/0,i=-1/0,r=this.get("children");r.length>0?a.each(r,function(r){if(r.get("visible")){if(r.isGroup&&0===r.get("children").length)return;var a=r.getBBox();if(!a)return!0;var o=[a.minX,a.minY,1],s=[a.minX,a.maxY,1],l=[a.maxX,a.minY,1],u=[a.maxX,a.maxY,1];r.apply(o),r.apply(s),r.apply(l),r.apply(u);var c=Math.min(o[0],s[0],l[0],u[0]),h=Math.max(o[0],s[0],l[0],u[0]),f=Math.min(o[1],s[1],l[1],u[1]),p=Math.max(o[1],s[1],l[1],u[1]);ce&&(e=h),fi&&(i=p)}}):(t=0,e=0,n=0,i=0);var o={minX:t,minY:n,maxX:e,maxY:i};return o.x=o.minX,o.y=o.minY,o.width=o.maxX-o.minX,o.height=o.maxY-o.minY,o},getCount:function(){return this.get("children").length},sort:function(){var t=this.get("children");return a.each(t,function(t,e){return t[u]=e,t}),t.sort(function(t){return function(e,n){var i=t(e,n);return 0===i?e[u]-n[u]:i}}(function(t,e){return t.get("zIndex")-e.get("zIndex")})),this},findById:function(t){return this.find(function(e){return e.get("id")===t})},find:function(t){if(a.isString(t))return this.findById(t);var e=this.get("children"),n=null;return a.each(e,function(e){if(t(e)?n=e:e.find&&(n=e.find(t)),n)return!1}),n},findAll:function(t){var e=this.get("children"),n=[],i=[];return a.each(e,function(e){t(e)&&n.push(e),e.findAllBy&&(i=e.findAllBy(t),n=n.concat(i))}),n},findBy:function(t){var e=this.get("children"),n=null;return a.each(e,function(e){if(t(e)?n=e:e.findBy&&(n=e.findBy(t)),n)return!1}),n},findAllBy:function(t){var e=this.get("children"),n=[],i=[];return a.each(e,function(e){t(e)&&n.push(e),e.findAllBy&&(i=e.findAllBy(t),n=n.concat(i))}),n},getShape:function(t,e){var n,r=this._attrs.clip,a=this._cfg.children;if(r){var o=[t,e,1];r.invert(o,this.get("canvas")),r.isPointInPath(o[0],o[1])&&(n=i(a,t,e))}else n=i(a,t,e);return n},clearTotalMatrix:function(){if(this.get("totalMatrix")){this.setSilent("totalMatrix",null);for(var t=this._cfg.children,e=0;e=0;n--)e[n].remove(!0,t);return this._cfg.children=[],this},destroy:function(){this.get("destroyed")||(this.clear(),c.superclass.destroy.call(this))},clone:function(){var t=this._cfg.children,e=new c;return a.each(t,function(t){e.add(t.clone())}),e}}),t.exports=c},function(t,e,n){var i=n(1),r=n(185),a=n(186),o=n(187),s=n(53),l=function(t){this._cfg={zIndex:0,capture:!0,visible:!0,destroyed:!1},i.assign(this._cfg,this.getDefaultCfg(),t),this.initAttrs(this._cfg.attrs),this._cfg.attrs={},this.initTransform(),this.init()};l.CFG={id:null,zIndex:0,canvas:null,parent:null,capture:!0,context:null,visible:!0,destroyed:!1},i.augment(l,r,a,s,o,{init:function(){this.setSilent("animable",!0),this.setSilent("animating",!1)},getParent:function(){return this._cfg.parent},getDefaultCfg:function(){return{}},set:function(t,e){return"zIndex"===t&&this._beforeSetZIndex&&this._beforeSetZIndex(e),"loading"===t&&this._beforeSetLoading&&this._beforeSetLoading(e),this._cfg[t]=e,this},setSilent:function(t,e){this._cfg[t]=e},get:function(t){return this._cfg[t]},show:function(){return this._cfg.visible=!0,this},hide:function(){return this._cfg.visible=!1,this},remove:function(t,e){var n=this._cfg,r=n.parent,a=n.el;return r&&i.remove(r.get("children"),this),a&&(e?r&&r._cfg.tobeRemoved.push(a):a.parentNode.removeChild(a)),(t||void 0===t)&&this.destroy(),this},destroy:function(){this.get("destroyed")||(this._attrs=null,this.removeEvent(),this._cfg={destroyed:!0})},toFront:function(){var t=this._cfg,e=t.parent;if(e){var n=e._cfg.children,i=t.el,r=n.indexOf(this);n.splice(r,1),n.push(this),i&&(i.parentNode.removeChild(i),t.el=null)}},toBack:function(){var t=this._cfg,e=t.parent;if(e){var n=e._cfg.children,i=t.el,r=n.indexOf(this);if(n.splice(r,1),n.unshift(this),i){var a=i.parentNode;a.removeChild(i),a.insertBefore(i,a.firstChild)}}},_beforeSetZIndex:function(t){var e=this._cfg.parent;this._cfg.zIndex=t,i.isNil(e)||e.sort();var n=this._cfg.el;if(n){var r=e._cfg.children,a=r.indexOf(this),o=n.parentNode;o.removeChild(n),a===r.length-1?o.appendChild(n):o.insertBefore(n,o.childNodes[a])}return t},_setAttrs:function(t){return this.attr(t),t},setZIndex:function(t){return this._cfg.zIndex=t,this._beforeSetZIndex(t)},clone:function(){return i.clone(this)},getBBox:function(){}}),t.exports=l},function(t,e,n){function i(t,e,n,i){var r=1-i;return r*(r*t+2*i*e)+i*i*n}function r(t,e,n,r,a,s,l,u,c){var h,f,p,g,d,v,y,x=.005,m=1/0,_=[l,u];for(d=0;d<1;d+=.05)p=[i(t,n,a,d),i(e,r,s,d)],(f=o.squaredDistance(_,p))=0&&f=0?[r]:[]}}},function(t,e){t.exports={xAt:function(t,e,n,i,r){return e*Math.cos(t)*Math.cos(r)-n*Math.sin(t)*Math.sin(r)+i},yAt:function(t,e,n,i,r){return e*Math.sin(t)*Math.cos(r)+n*Math.cos(t)*Math.sin(r)+i},xExtrema:function(t,e,n){return Math.atan(-n/e*Math.tan(t))},yExtrema:function(t,e,n){return Math.atan(n/(e*Math.tan(t)))}}},function(t,e,n){function i(t,e,n){return t+e*Math.cos(n)}function r(t,e,n){return t+e*Math.sin(n)}var a=n(1),o=n(6),s=n(37),l=n(38),u=function t(e){t.superclass.constructor.call(this,e)};u.ATTRS={x:0,y:0,r:0,startAngle:0,endAngle:0,clockwise:!1,lineWidth:1,startArrow:!1,endArrow:!1},a.extend(u,o),a.augment(u,{canStroke:!0,type:"arc",getDefaultAttrs:function(){return{x:0,y:0,r:0,startAngle:0,endAngle:0,clockwise:!1,lineWidth:1,startArrow:!1,endArrow:!1}},calculateBox:function(){var t=this._attrs,e=t.x,n=t.y,i=t.r,r=t.startAngle,a=t.endAngle,o=t.clockwise,l=this.getHitLineWidth()/2,u=s.box(e,n,i,r,a,o);return u.minX-=l,u.minY-=l,u.maxX+=l,u.maxY+=l,u},getStartTangent:function(){var t=this._attrs,e=t.x,n=t.y,a=t.startAngle,o=t.r,s=t.clockwise,l=Math.PI/180;s&&(l*=-1);var u=[],c=i(e,o,a+l),h=r(n,o,a+l),f=i(e,o,a),p=r(n,o,a);return u.push([c,h]),u.push([f,p]),u},getEndTangent:function(){var t=this._attrs,e=t.x,n=t.y,a=t.endAngle,o=t.r,s=t.clockwise,l=Math.PI/180,u=[];s&&(l*=-1);var c=i(e,o,a+l),h=r(n,o,a+l),f=i(e,o,a),p=r(n,o,a);return u.push([f,p]),u.push([c,h]),u},createPath:function(t){var e=this._attrs,n=e.x,i=e.y,r=e.r,a=e.startAngle,o=e.endAngle,s=e.clockwise;(t=t||self.get("context")).beginPath(),t.arc(n,i,r,a,o,s)},afterPath:function(t){var e=this._attrs;if(t=t||this.get("context"),e.startArrow){var n=this.getStartTangent();l.addStartArrow(t,e,n[0][0],n[0][1],n[1][0],n[1][1])}if(e.endArrow){var i=this.getEndTangent();l.addEndArrow(t,e,i[0][0],i[0][1],i[1][0],i[1][1])}}}),t.exports=u},function(t,e,n){var i=n(1),r=n(6),a=function t(e){t.superclass.constructor.call(this,e)};a.ATTRS={x:0,y:0,r:0,lineWidth:1},i.extend(a,r),i.augment(a,{canFill:!0,canStroke:!0,type:"circle",getDefaultAttrs:function(){return{lineWidth:1}},calculateBox:function(){var t=this._attrs,e=t.x,n=t.y,i=t.r,r=this.getHitLineWidth()/2+i;return{minX:e-r,minY:n-r,maxX:e+r,maxY:n+r}},createPath:function(t){var e=this._attrs,n=e.x,i=e.y,r=e.r;t.beginPath(),t.arc(n,i,r,0,2*Math.PI,!1),t.closePath()}}),t.exports=a},function(t,e,n){var i=n(1),r=n(6),a=function t(e){t.superclass.constructor.call(this,e)};i.extend(a,r),i.augment(a,{canFill:!0,canStroke:!0,type:"dom",calculateBox:function(){var t=this._attrs,e=t.x,n=t.y,i=t.width,r=t.height,a=this.getHitLineWidth()/2;return{minX:e-a,minY:n-a,maxX:e+i+a,maxY:n+r+a}}}),t.exports=a},function(t,e,n){var i=n(1),r=n(6),a=function t(e){t.superclass.constructor.call(this,e)};a.ATTRS={x:0,y:0,rx:1,ry:1,lineWidth:1},i.extend(a,r),i.augment(a,{canFill:!0,canStroke:!0,type:"ellipse",getDefaultAttrs:function(){return{lineWidth:1}},calculateBox:function(){var t=this._attrs,e=t.x,n=t.y,i=t.rx,r=t.ry,a=this.getHitLineWidth(),o=i+a/2,s=r+a/2;return{minX:e-o,minY:n-s,maxX:e+o,maxY:n+s}},createPath:function(t){var e=this._attrs,n=e.x,r=e.y,a=e.rx,o=e.ry;t=t||self.get("context");var s=a>o?a:o,l=a>o?1:a/o,u=a>o?o/a:1,c=[1,0,0,0,1,0,0,0,1];i.mat3.scale(c,c,[l,u]),i.mat3.translate(c,c,[n,r]),t.beginPath(),t.save(),t.transform(c[0],c[1],c[3],c[4],c[6],c[7]),t.arc(0,0,s,0,2*Math.PI),t.restore(),t.closePath()}}),t.exports=a},function(t,e,n){var i=n(1),r=n(6),a=n(37),o=function t(e){t.superclass.constructor.call(this,e)};o.ATTRS={x:0,y:0,rs:0,re:0,startAngle:0,endAngle:0,clockwise:!1,lineWidth:1},i.extend(o,r),i.augment(o,{canFill:!0,canStroke:!0,type:"fan",getDefaultAttrs:function(){return{clockwise:!1,lineWidth:1,rs:0,re:0}},calculateBox:function(){var t=this._attrs,e=t.x,n=t.y,i=t.rs,r=t.re,o=t.startAngle,s=t.endAngle,l=t.clockwise,u=this.getHitLineWidth(),c=a.box(e,n,i,o,s,l),h=a.box(e,n,r,o,s,l),f=u/2;return{minX:Math.min(c.minX,h.minX)-f,minY:Math.min(c.minY,h.minY)-f,maxX:Math.max(c.maxX,h.maxX)+f,maxY:Math.max(c.maxY,h.maxY)+f}},createPath:function(t){var e=this._attrs,n=e.x,i=e.y,r=e.rs,a=e.re,o=e.startAngle,s=e.endAngle,l=e.clockwise,u={x:Math.cos(o)*r+n,y:Math.sin(o)*r+i},c={x:Math.cos(o)*a+n,y:Math.sin(o)*a+i},h={x:Math.cos(s)*r+n,y:Math.sin(s)*r+i};(t=t||self.get("context")).beginPath(),t.moveTo(u.x,u.y),t.lineTo(c.x,c.y),t.arc(n,i,a,o,s,l),t.lineTo(h.x,h.y),t.arc(n,i,r,s,o,!l),t.closePath()}}),t.exports=o},function(t,e,n){var i=n(1),r=n(6),a=function t(e){t.superclass.constructor.call(this,e)};a.ATTRS={x:0,y:0,img:void 0,width:0,height:0,sx:null,sy:null,swidth:null,sheight:null},i.extend(a,r),i.augment(a,{type:"image",isHitBox:function(){return!1},calculateBox:function(){var t=this._attrs;this._cfg.attrs&&this._cfg.attrs.img===t.img||this._setAttrImg();var e=t.x,n=t.y;return{minX:e,minY:n,maxX:e+t.width,maxY:n+t.height}},_beforeSetLoading:function(t){var e=this.get("canvas");return!1===t&&!0===this.get("toDraw")&&(this._cfg.loading=!1,e.draw()),t},_setAttrImg:function(){var t=this,e=t._attrs,n=e.img;if(!i.isString(n))return n instanceof Image?(e.width||t.attr("width",n.width),e.height||t.attr("height",n.height),n):n instanceof HTMLElement&&i.isString(n.nodeName)&&"CANVAS"===n.nodeName.toUpperCase()?(e.width||t.attr("width",Number(n.getAttribute("width"))),e.height||t.attr("height",Number(n.getAttribute("height"))),n):n instanceof ImageData?(e.width||t.attr("width",n.width),e.height||t.attr("height",n.height),n):null;var r=new Image;r.onload=function(){if(t.get("destroyed"))return!1;t.attr("imgSrc",n),t.attr("img",r);var e=t.get("callback");e&&e.call(t),t.set("loading",!1)},r.src=n,r.crossOrigin="Anonymous",t.set("loading",!0)},drawInner:function(t){this._cfg.hasUpdate&&this._setAttrImg(),this.get("loading")?this.set("toDraw",!0):(this._drawImage(t),this._cfg.hasUpdate=!1)},_drawImage:function(t){var e=this._attrs,n=e.x,r=e.y,a=e.img,o=e.width,s=e.height,l=e.sx,u=e.sy,c=e.swidth,h=e.sheight;this.set("toDraw",!1);var f=a;if(f instanceof ImageData&&((f=new Image).src=a),f instanceof Image||f instanceof HTMLElement&&i.isString(f.nodeName)&&"CANVAS"===f.nodeName.toUpperCase()){if(i.isNil(l)||i.isNil(u)||i.isNil(c)||i.isNil(h))return void t.drawImage(f,n,r,o,s);if(!(i.isNil(l)||i.isNil(u)||i.isNil(c)||i.isNil(h)))return void t.drawImage(f,l,u,c,h,n,r,o,s)}}}),t.exports=a},function(t,e,n){var i=n(1),r=n(6),a=n(38),o=n(36),s=function t(e){t.superclass.constructor.call(this,e)};s.ATTRS={x1:0,y1:0,x2:0,y2:0,lineWidth:1,startArrow:!1,endArrow:!1},i.extend(s,r),i.augment(s,{canStroke:!0,type:"line",getDefaultAttrs:function(){return{lineWidth:1,startArrow:!1,endArrow:!1}},calculateBox:function(){var t=this._attrs,e=t.x1,n=t.y1,i=t.x2,r=t.y2,a=this.getHitLineWidth();return o.box(e,n,i,r,a)},createPath:function(t){var e=this._attrs,n=e.x1,i=e.y1,r=e.x2,a=e.y2;(t=t||self.get("context")).beginPath(),t.moveTo(n,i),t.lineTo(r,a)},afterPath:function(t){var e=this._attrs,n=e.x1,i=e.y1,r=e.x2,o=e.y2;t=t||this.get("context"),e.startArrow&&a.addStartArrow(t,e,r,o,n,i),e.endArrow&&a.addEndArrow(t,e,n,i,r,o)},getPoint:function(t){var e=this._attrs;return{x:o.at(e.x1,e.x2,t),y:o.at(e.y1,e.y2,t)}}}),t.exports=s},function(t,e,n){var i=n(1),r=n(6),a=n(39),o=n(27),s=n(38),l=n(57),u=n(55),c=function t(e){t.superclass.constructor.call(this,e)};c.ATTRS={path:null,lineWidth:1,startArrow:!1,endArrow:!1},i.extend(c,r),i.augment(c,{canFill:!0,canStroke:!0,type:"path",getDefaultAttrs:function(){return{lineWidth:1,startArrow:!1,endArrow:!1}},_afterSetAttrPath:function(t){if(i.isNil(t))return this.setSilent("segments",null),void this.setSilent("box",void 0);var e,n=o.parsePath(t),r=[];if(i.isArray(n)&&0!==n.length&&("M"===n[0][0]||"m"===n[0][0])){for(var s=n.length,l=0;lr&&(r=i.maxX),i.minYo&&(o=i.maxY))}),n===1/0||a===1/0?{minX:0,minY:0,maxX:0,maxY:0}:{minX:n,minY:a,maxX:r,maxY:o}},_setTcache:function(){var t,e,n,r,a=0,o=0,s=[],l=this._cfg.curve;l&&(i.each(l,function(t,e){n=l[e+1],r=t.length,n&&(a+=u.len(t[r-2],t[r-1],n[1],n[2],n[3],n[4],n[5],n[6]))}),i.each(l,function(i,c){n=l[c+1],r=i.length,n&&((t=[])[0]=o/a,e=u.len(i[r-2],i[r-1],n[1],n[2],n[3],n[4],n[5],n[6]),o+=e,t[1]=o/a,s.push(t))}),this._cfg.tCache=s)},_calculateCurve:function(){var t=this._attrs.path;this._cfg.curve=l.pathTocurve(t)},getStartTangent:function(){var t,e,n,r,a=this.get("segments");if(a.length>1)if(t=a[0].endPoint,e=a[1].endPoint,n=a[1].startTangent,r=[],i.isFunction(n)){var o=n();r.push([t.x-o[0],t.y-o[1]]),r.push([t.x,t.y])}else r.push([e.x,e.y]),r.push([t.x,t.y]);return r},getEndTangent:function(){var t,e,n,r,a=this.get("segments"),o=a.length;if(o>1)if(t=a[o-2].endPoint,e=a[o-1].endPoint,n=a[o-1].endTangent,r=[],i.isFunction(n)){var s=n();r.push([e.x-s[0],e.y-s[1]]),r.push([e.x,e.y])}else r.push([t.x,t.y]),r.push([e.x,e.y]);return r},getPoint:function(t){var e,n,r=this._cfg.tCache;r||(this._calculateCurve(),this._setTcache(),r=this._cfg.tCache);var a=this._cfg.curve;if(!r)return a?{x:a[0][1],y:a[0][2]}:null;i.each(r,function(i,r){t>=i[0]&&t<=i[1]&&(e=(t-i[0])/(i[1]-i[0]),n=r)});var o=a[n];if(i.isNil(o)||i.isNil(n))return null;var s=o.length,l=a[n+1];return{x:u.at(o[s-2],l[1],l[3],l[5],1-e),y:u.at(o[s-1],l[2],l[4],l[6],1-e)}},createPath:function(t){var e=this.get("segments");if(i.isArray(e)){(t=t||this.get("context")).beginPath();for(var n=e.length,r=0;ra&&(a=e),io&&(o=i)});var s=e/2;return{minX:n-s,minY:r-s,maxX:a+s,maxY:o+s}},createPath:function(t){var e=this._attrs.points;e.length<2||((t=t||this.get("context")).beginPath(),i.each(e,function(e,n){0===n?t.moveTo(e[0],e[1]):t.lineTo(e[0],e[1])}),t.closePath())}}),t.exports=a},function(t,e,n){var i=n(1),r=n(6),a=n(38),o=n(36),s=function t(e){t.superclass.constructor.call(this,e)};s.ATTRS={points:null,lineWidth:1,startArrow:!1,endArrow:!1,tCache:null},i.extend(s,r),i.augment(s,{canStroke:!0,type:"polyline",tCache:null,getDefaultAttrs:function(){return{lineWidth:1,startArrow:!1,endArrow:!1}},calculateBox:function(){var t=this._attrs,e=this.getHitLineWidth(),n=t.points;if(!n||0===n.length)return null;var r=1/0,a=1/0,o=-1/0,s=-1/0;i.each(n,function(t){var e=t[0],n=t[1];eo&&(o=e),ns&&(s=n)});var l=e/2;return{minX:r-l,minY:a-l,maxX:o+l,maxY:s+l}},_setTcache:function(){var t,e,n=this._attrs.points,r=0,a=0,s=[];n&&0!==n.length&&(i.each(n,function(t,e){n[e+1]&&(r+=o.len(t[0],t[1],n[e+1][0],n[e+1][1]))}),r<=0||(i.each(n,function(i,l){n[l+1]&&((t=[])[0]=a/r,e=o.len(i[0],i[1],n[l+1][0],n[l+1][1]),a+=e,t[1]=a/r,s.push(t))}),this.tCache=s))},createPath:function(t){var e,n,i=this._attrs.points;if(!(i.length<2)){for((t=t||this.get("context")).beginPath(),t.moveTo(i[0][0],i[0][1]),n=1,e=i.length-1;n=i[0]&&t<=i[1]&&(e=(t-i[0])/(i[1]-i[0]),n=r)}),{x:o.at(r[n][0],r[n+1][0],e),y:o.at(r[n][1],r[n+1][1],e)}}}),t.exports=s},function(t,e,n){var i=n(1),r=n(27).parseRadius,a=n(6),o=function t(e){t.superclass.constructor.call(this,e)};o.ATTRS={x:0,y:0,width:0,height:0,radius:0,lineWidth:1},i.extend(o,a),i.augment(o,{canFill:!0,canStroke:!0,type:"rect",getDefaultAttrs:function(){return{lineWidth:1,radius:0}},calculateBox:function(){var t=this._attrs,e=t.x,n=t.y,i=t.width,r=t.height,a=this.getHitLineWidth()/2;return{minX:e-a,minY:n-a,maxX:e+i+a,maxY:n+r+a}},createPath:function(t){var e=this._attrs,n=e.x,i=e.y,a=e.width,o=e.height,s=e.radius;if((t=t||this.get("context")).beginPath(),0===s)t.rect(n,i,a,o);else{var l=r(s);t.moveTo(n+l.r1,i),t.lineTo(n+a-l.r2,i),0!==l.r2&&t.arc(n+a-l.r2,i+l.r2,l.r2,-Math.PI/2,0),t.lineTo(n+a,i+o-l.r3),0!==l.r3&&t.arc(n+a-l.r3,i+o-l.r3,l.r3,0,Math.PI/2),t.lineTo(n+l.r4,i+o),0!==l.r4&&t.arc(n+l.r4,i+o-l.r4,l.r4,Math.PI/2,Math.PI),t.lineTo(n,i+l.r1),0!==l.r1&&t.arc(n+l.r1,i+l.r1,l.r1,Math.PI,1.5*Math.PI),t.closePath()}}}),t.exports=o},function(t,e,n){var i=n(1),r=n(6),a=function t(e){t.superclass.constructor.call(this,e)};a.ATTRS={x:0,y:0,text:null,fontSize:12,fontFamily:"sans-serif",fontStyle:"normal",fontWeight:"normal",fontVariant:"normal",textAlign:"start",textBaseline:"bottom",lineHeight:null,textArr:null},i.extend(a,r),i.augment(a,{canFill:!0,canStroke:!0,type:"text",getDefaultAttrs:function(){return{lineWidth:1,lineCount:1,fontSize:12,fontFamily:"sans-serif",fontStyle:"normal",fontWeight:"normal",fontVariant:"normal",textAlign:"start",textBaseline:"bottom"}},initTransform:function(){var t=this._attrs.fontSize;t&&+t<12&&this.transform([["t",-1*this._attrs.x,-1*this._attrs.y],["s",+t/12,+t/12],["t",this._attrs.x,this._attrs.y]])},_assembleFont:function(){var t=this._attrs,e=t.fontSize,n=t.fontFamily,i=t.fontWeight,r=t.fontStyle,a=t.fontVariant;t.font=[r,a,i,e+"px",n].join(" ")},_setAttrText:function(){var t=this._attrs,e=t.text,n=null;if(i.isString(e)&&-1!==e.indexOf("\n")){var r=(n=e.split("\n")).length;t.lineCount=r}t.textArr=n},_getTextHeight:function(){var t=this._attrs,e=t.lineCount,n=1*t.fontSize;if(e>1){return n*e+this._getSpaceingY()*(e-1)}return n},isHitBox:function(){return!1},calculateBox:function(){var t=this._attrs,e=this._cfg;e.attrs&&!e.hasUpdate||(this._assembleFont(),this._setAttrText()),t.textArr||this._setAttrText();var n=t.x,i=t.y,r=this.measureText();if(!r)return{minX:n,minY:i,maxX:n,maxY:i};var a=this._getTextHeight(),o=t.textAlign,s=t.textBaseline,l=this.getHitLineWidth(),u={x:n,y:i-a};o&&("end"===o||"right"===o?u.x-=r:"center"===o&&(u.x-=r/2)),s&&("top"===s?u.y+=a:"middle"===s&&(u.y+=a/2)),this.set("startPoint",u);var c=l/2;return{minX:u.x-c,minY:u.y-c,maxX:u.x+r+c,maxY:u.y+a+c}},_getSpaceingY:function(){var t=this._attrs,e=t.lineHeight,n=1*t.fontSize;return e?e-n:.14*n},drawInner:function(t){var e=this._attrs,n=this._cfg;n.attrs&&!n.hasUpdate||(this._assembleFont(),this._setAttrText()),t.font=e.font;var r=e.text;if(r){var a=e.textArr,o=e.x,s=e.y;if(t.beginPath(),this.hasStroke()){var l=e.strokeOpacity;i.isNil(l)||1===l||(t.globalAlpha=l),a?this._drawTextArr(t,!1):t.strokeText(r,o,s),t.globalAlpha=1}if(this.hasFill()){var u=e.fillOpacity;i.isNil(u)||1===u||(t.globalAlpha=u),a?this._drawTextArr(t,!0):t.fillText(r,o,s)}n.hasUpdate=!1}},_drawTextArr:function(t,e){var n,r=this._attrs.textArr,a=this._attrs.textBaseline,o=1*this._attrs.fontSize,s=this._getSpaceingY(),l=this._attrs.x,u=this._attrs.y,c=this.getBBox(),h=c.maxY-c.minY;i.each(r,function(i,r){n=u+r*(s+o)-h+o,"middle"===a&&(n+=h-o-(h-o)/2),"top"===a&&(n+=h-o),e?t.fillText(i,l,n):t.strokeText(i,l,n)})},measureText:function(){var t,e=this._attrs,n=e.text,r=e.font,a=e.textArr,o=0;if(!i.isNil(n)){var s=document.createElement("canvas").getContext("2d");return s.save(),s.font=r,a?i.each(a,function(e){t=s.measureText(e).width,ol&&(s=e.slice(l,s),c[u]?c[u]+=s:c[++u]=s),(n=n[0])===(o=o[0])?c[u]?c[u]+=o:c[++u]=o:(c[++u]=null,h.push({i:u,x:Object(i.a)(n,o)})),l=a.lastIndex;return lo&&(n=t,o=s)}),n}}},function(t,e){t.exports=parseInt},function(t,e){t.exports=function(t,e){return t.hasOwnProperty(e)}},function(t,e,n){var i=n(2),r=n(11),a=Object.values?function(t){return Object.values(t)}:function(t){var e=[];return i(t,function(n,i){r(t)&&"prototype"===i||e.push(n)}),e};t.exports=a},function(t,e,n){var i=n(137);t.exports=function(t,e,n,r,a){if(a)return[["M",+t+ +a,e],["l",n-2*a,0],["a",a,a,0,0,1,a,a],["l",0,r-2*a],["a",a,a,0,0,1,-a,a],["l",2*a-n,0],["a",a,a,0,0,1,-a,-a],["l",0,2*a-r],["a",a,a,0,0,1,a,-a],["z"]];var o=[["M",t,e],["l",n,0],["l",0,r],["l",-n,0],["z"]];return o.parsePathArray=i,o}},function(t,e){var n=/,?([a-z]),?/gi;t.exports=function(t){return t.join(",").replace(n,"$1")}},function(t,e,n){var i=n(139),r=function(t,e,n,i){return[t,e,n,i,n,i]},a=function(t,e,n,i,r,a){return[1/3*t+2/3*n,1/3*e+2/3*i,1/3*r+2/3*n,1/3*a+2/3*i,r,a]};t.exports=function(t,e){var n=i(t),o=e&&i(e),s={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},l={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},u=[],c=[],h="",f="",p=void 0,g=function(t,e,n){var i=void 0,o=void 0;if(!t)return["C",e.x,e.y,e.x,e.y,e.x,e.y];switch(!(t[0]in{T:1,Q:1})&&(e.qx=e.qy=null),t[0]){case"M":e.X=t[1],e.Y=t[2];break;case"A":t=["C"].concat(function t(e,n,i,r,a,o,s,l,u,c){i===r&&(i+=1);var h=120*Math.PI/180,f=Math.PI/180*(+a||0),p=[],g=void 0,d=void 0,v=void 0,y=void 0,x=void 0,m=function(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}};if(c)d=c[0],v=c[1],y=c[2],x=c[3];else{e=(g=m(e,n,-f)).x,n=g.y,l=(g=m(l,u,-f)).x,u=g.y,e===l&&n===u&&(l+=1,u+=1);var _=(e-l)/2,b=(n-u)/2,w=_*_/(i*i)+b*b/(r*r);w>1&&(i*=w=Math.sqrt(w),r*=w);var S=i*i,M=r*r,C=(o===s?-1:1)*Math.sqrt(Math.abs((S*M-S*b*b-M*_*_)/(S*b*b+M*_*_)));y=C*i*b/r+(e+l)/2,x=C*-r*_/i+(n+u)/2,d=Math.asin(((n-x)/r).toFixed(9)),v=Math.asin(((u-x)/r).toFixed(9)),d=ev&&(d-=2*Math.PI),!s&&v>d&&(v-=2*Math.PI)}var A=v-d;if(Math.abs(A)>h){var k=v,P=l,T=u;v=d+h*(s&&v>d?1:-1),p=t(l=y+i*Math.cos(v),u=x+r*Math.sin(v),i,r,a,0,s,P,T,[v,k,y,x])}A=v-d;var I=Math.cos(d),O=Math.sin(d),L=Math.cos(v),E=Math.sin(v),D=Math.tan(A/4),F=4/3*i*D,B=4/3*r*D,R=[e,n],j=[e+F*O,n-B*I],N=[l+F*E,u-B*L],z=[l,u];if(j[0]=2*R[0]-j[0],j[1]=2*R[1]-j[1],c)return[j,N,z].concat(p);for(var Y=[],V=0,X=(p=[j,N,z].concat(p).join().split(",")).length;V7){t[e].shift();for(var i=t[e];i.length;)u[e]="A",o&&(c[e]="A"),t.splice(e++,0,["C"].concat(i.splice(0,6)));t.splice(e,1),p=Math.max(n.length,o&&o.length||0)}},v=function(t,e,i,r,a){t&&e&&"M"===t[a][0]&&"M"!==e[a][0]&&(e.splice(a,0,["M",r.x,r.y]),i.bx=0,i.by=0,i.x=t[a][1],i.y=t[a][2],p=Math.max(n.length,o&&o.length||0))};p=Math.max(n.length,o&&o.length||0);for(var y=0;y180),0,l,e+n*Math.sin(-r*o)]]}else a=[["M",t,e],["m",0,-i],["a",n,i,0,1,1,0,2*i],["a",n,i,0,1,1,0,-2*i],["z"]];return a}var r=n(140),a=n(141);t.exports=function(t){if(!(t=r(t))||!t.length)return[["M",0,0]];var e=[],n=0,o=0,s=0,l=0,u=0,c=void 0,h=void 0;"M"===t[0][0]&&(s=n=+t[0][1],l=o=+t[0][2],u++,e[0]=["M",n,o]);for(var f,p,g=3===t.length&&"M"===t[0][0]&&"R"===t[1][0].toUpperCase()&&"Z"===t[2][0].toUpperCase(),d=u,v=t.length;d2&&(i.push([n].concat(o.splice(0,2))),s="l",n="m"===n?"l":"L"),"o"===s&&1===o.length&&i.push([n,o[0]]),"r"===s)i.push([n].concat(o));else for(;o.length>=e[s]&&(i.push([n].concat(o.splice(0,e[s]))),e[s]););}),i}},function(t,e){t.exports=function(t,e){for(var n=[],i=0,r=t.length;r-2*!e>i;i+=2){var a=[{x:+t[i-2],y:+t[i-1]},{x:+t[i],y:+t[i+1]},{x:+t[i+2],y:+t[i+3]},{x:+t[i+4],y:+t[i+5]}];e?i?r-4===i?a[3]={x:+t[0],y:+t[1]}:r-2===i&&(a[2]={x:+t[0],y:+t[1]},a[3]={x:+t[2],y:+t[3]}):a[0]={x:+t[r-2],y:+t[r-1]}:r-4===i?a[3]=a[2]:i||(a[0]={x:+t[i],y:+t[i+1]}),n.push(["C",(-a[0].x+6*a[1].x+a[2].x)/6,(-a[0].y+6*a[1].y+a[2].y)/6,(a[1].x+6*a[2].x-a[3].x)/6,(a[1].y+6*a[2].y-a[3].y)/6,a[2].x,a[2].y])}return n}},function(t,e,n){var i=n(23);t.exports=function(t){return i(t).toLowerCase()}},function(t,e,n){var i=n(23);t.exports=function(t){return i(t).toUpperCase()}},function(t,e,n){var i=n(145);t.exports=function(t,e){if(!e)return[t];var n=i(t,e),r=[];for(var a in n)r.push(n[a]);return r}},function(t,e,n){var i=n(11),r=n(4),a=n(146);t.exports=function(t,e){if(!e)return{0:t};if(!i(e)){var n=r(e)?e:e.replace(/\s+/g,"").split("*");e=function(t){for(var e="_",i=0,r=n.length;i
    ');t.appendChild(a),this.set("wrapperEl",a),this.get("forceFit")&&(n=s.getWidth(t,n),this.set("width",n));var l=this.get("renderer"),u=new o({containerDOM:a,width:n,height:i,pixelRatio:"svg"===l?1:this.get("pixelRatio"),renderer:l});this.set("canvas",u)},n._initPlot=function(){this._initPlotBack();var t=this.get("canvas"),e=t.addGroup({zIndex:1}),n=t.addGroup({zIndex:0}),i=t.addGroup({zIndex:3});this.set("backPlot",e),this.set("middlePlot",n),this.set("frontPlot",i)},n._initPlotBack=function(){var t=this.get("canvas"),e=this.get("viewTheme"),n=t.addGroup(u,{padding:this.get("padding"),plotBackground:r.mix({},e.plotBackground,this.get("plotBackground")),background:r.mix({},e.background,this.get("background"))});this.set("plot",n),this.set("plotRange",n.get("plotRange"))},n._initEvents=function(){this.get("forceFit")&&window.addEventListener("resize",r.wrapBehavior(this,"_initForceFitEvent"))},n._initForceFitEvent=function(){var t=setTimeout(r.wrapBehavior(this,"forceFit"),200);clearTimeout(this.get("resizeTimer")),this.set("resizeTimer",t)},n._renderLegends=function(){var t=this.get("options").legends;if(r.isNil(t)||!1!==t){var e=this.get("legendController");if(e.options=t||{},e.plotRange=this.get("plotRange"),t&&t.custom)e.addCustomLegend();else{var n=this.getAllGeoms(),i=[];r.each(n,function(t){var n=t.get("view"),a=t.getAttrsForLegend();r.each(a,function(a){var o=a.type,s=a.getScale(o);if(s.field&&"identity"!==s.type&&!function(t,e){var n=!1;return r.each(t,function(t){var i=[].concat(t.values),r=[].concat(e.values);t.type!==e.type||t.field!==e.field||i.sort().toString()!==r.sort().toString()||(n=!0)}),n}(i,s)){i.push(s);var l=n.getFilteredOutValues(s.field);e.addLegend(s,a,t,l)}})});var a=this.getYScales();0===i.length&&a.length>1&&e.addMixedLegend(a,n)}e.alignLegends()}},n._renderTooltips=function(){var t=this.get("options");if(r.isNil(t.tooltip)||!1!==t.tooltip){var e=this.get("tooltipController");e.options=t.tooltip||{},e.renderTooltip()}},n.getAllGeoms=function(){var t=[];t=t.concat(this.get("geoms"));var e=this.get("views");return r.each(e,function(e){t=t.concat(e.get("geoms"))}),t},n.forceFit=function(){if(this&&!this.destroyed){var t=this.get("container"),e=this.get("width"),n=s.getWidth(t,e);if(0!==n&&n!==e){var i=this.get("height");this.changeSize(n,i)}return this}},n.resetPlot=function(){var t=this.get("plot"),e=this.get("padding");i(e,t.get("padding"))||(t.set("padding",e),t.repaint())},n.changeSize=function(t,e){this.get("canvas").changeSize(t,e);var n=this.get("plot");return this.set("width",t),this.set("height",e),n.repaint(),this.set("keepPadding",!0),this.repaint(),this.set("keepPadding",!1),this.emit("afterchangesize"),this},n.changeWidth=function(t){return this.changeSize(t,this.get("height"))},n.changeHeight=function(t){return this.changeSize(this.get("width"),t)},n.view=function(t){(t=t||{}).theme=this.get("theme"),t.parent=this,t.backPlot=this.get("backPlot"),t.middlePlot=this.get("middlePlot"),t.frontPlot=this.get("frontPlot"),t.canvas=this.get("canvas"),r.isNil(t.animate)&&(t.animate=this.get("animate")),t.options=r.mix({},this._getSharedOptions(),t.options);var e=new a(t);return e.set("_id","view"+this.get("views").length),this.get("views").push(e),this.emit("addview",{view:e}),e},n.removeView=function(t){var e=this.get("views");r.Array.remove(e,t),t.destroy()},n._getSharedOptions=function(){var t=this.get("options"),e={};return r.each(["scales","coord","axes"],function(n){e[n]=r.cloneDeep(t[n])}),e},n.getViewRegion=function(){var t=this.get("plotRange");return{start:t.bl,end:t.tr}},n.legend=function(t,e){var n=this.get("options");n.legends||(n.legends={});var i={};return!1===t?n.legends=!1:r.isObject(t)?i=t:r.isString(t)?i[t]=e:i=e,r.mix(n.legends,i),this},n.tooltip=function(t,e){var n=this.get("options");return n.tooltip||(n.tooltip={}),!1===t?n.tooltip=!1:r.isObject(t)?r.mix(n.tooltip,t):r.mix(n.tooltip,e),this},n.clear=function(){this.emit("beforeclear");for(var e=this.get("views");e.length>0;){e.shift().destroy()}t.prototype.clear.call(this);var n=this.get("canvas");return this.resetPlot(),n.draw(),this.emit("afterclear"),this},n.clearInner=function(){var e=this.get("views");r.each(e,function(t){t.clearInner()});var n=this.get("tooltipController");if(n&&n.clear(),!this.get("keepLegend")){var i=this.get("legendController");i&&i.clear()}t.prototype.clearInner.call(this)},n.drawComponents=function(){t.prototype.drawComponents.call(this),this.get("keepLegend")||this._renderLegends()},n.render=function(){if(!this.get("keepPadding")&&this._isAutoPadding()){this.beforeRender(),this.drawComponents();var e=this._getAutoPadding(),n=this.get("plot");i(n.get("padding"),e)||(n.set("padding",e),n.repaint())}var a=this.get("middlePlot");if(this.get("limitInPlot")&&!a.attr("clip")){var o=r.getClipByRange(this.get("plotRange"));a.attr("clip",o)}t.prototype.render.call(this),this._renderTooltips()},n.repaint=function(){this.get("keepPadding")||this.resetPlot(),t.prototype.repaint.call(this)},n.changeVisible=function(t){var e=this.get("wrapperEl"),n=t?"":"none";e.style.display=n},n.toDataURL=function(){var t=this.get("canvas"),e=this.get("renderer"),n=t.get("el"),i="";if("svg"===e){var r=n.cloneNode(!0),a=document.implementation.createDocumentType("svg","-//W3C//DTD SVG 1.1//EN","http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"),o=document.implementation.createDocument("http://www.w3.org/2000/svg","svg",a);o.replaceChild(r,o.documentElement);var s=(new XMLSerializer).serializeToString(o);i="data:image/svg+xml;charset=utf8,"+encodeURIComponent(s)}else"canvas"===e&&(i=n.toDataURL("image/png"));return i},n.downloadImage=function(t){var e=this,n=document.createElement("a"),i=e.get("renderer"),r=(t||"chart")+("svg"===i?".svg":".png");e.get("canvas").get("timeline").stopAllAnimations(),setTimeout(function(){var t=e.toDataURL();if(window.Blob&&window.URL&&"svg"!==i){for(var a=t.split(","),o=a[0].match(/:(.*?);/)[1],s=atob(a[1]),l=s.length,u=new Uint8Array(l);l--;)u[l]=s.charCodeAt(l);var c=new Blob([u],{type:o});window.navigator.msSaveBlob?window.navigator.msSaveBlob(c,r):n.addEventListener("click",function(){n.download=r,n.href=window.URL.createObjectURL(c)})}else n.addEventListener("click",function(){n.download=r,n.href=t});var h=document.createEvent("MouseEvents");h.initEvent("click",!1,!1),n.dispatchEvent(h)},16)},n.showTooltip=function(t){var e=this.getViewsByPoint(t);if(e.length){this.get("tooltipController").showTooltip(t,e)}return this},n.hideTooltip=function(){return this.get("tooltipController").hideTooltip(),this},n.getTooltipItems=function(t){var e=this.getViewsByPoint(t),n=[];return r.each(e,function(e){var i=e.get("geoms");r.each(i,function(e){var i=e.get("dataArray"),a=[];r.each(i,function(n){var i=e.findPoint(t,n);if(i){var r=e.getTipItems(i);a=a.concat(r)}}),n=n.concat(a)})}),n},n.destroy=function(){this.emit("beforedestroy"),clearTimeout(this.get("resizeTimer"));var e=this.get("canvas"),n=this.get("wrapperEl");n.parentNode.removeChild(n),t.prototype.destroy.call(this),e.destroy(),window.removeEventListener("resize",r.getWrapBehavior(this,"_initForceFitEvent")),this.emit("afterdestroy")},e}(a);t.exports=g},function(t,e,n){var i=n(53),r=n(0),a=function(t){function e(e){var n,i={visible:!0},a=(n=t.call(this)||this).getDefaultCfg();return n._attrs=i,r.assign(i,a,e),n}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){return{}},n.get=function(t){return this._attrs[t]},n.set=function(t,e){this._attrs[t]=e},n.show=function(){this.get("visible")||(this.set("visible",!0),this.changeVisible(!0))},n.hide=function(){this.get("visible")&&(this.set("visible",!1),this.changeVisible(!1))},n.changeVisible=function(){},n.destroy=function(){this._attrs={},this.removeAllListeners(),this.destroyed=!0},e}(i);t.exports=a},function(t,e,n){function i(t,e,n,i){return t[i]+(e[i]-t[i])*n}function r(t){return"#"+a(t[0])+a(t[1])+a(t[2])}function a(t){return t=Math.round(t),1===(t=t.toString(16)).length&&(t="0"+t),t}function o(t){var e=[];return e.push(parseInt(t.substr(1,2),16)),e.push(parseInt(t.substr(3,2),16)),e.push(parseInt(t.substr(5,2),16)),e}var s=n(9),l=n(10),u=n(2),c=/rgba?\(([\s.,0-9]+)\)/,h={},f=null,p={toRGB:function(t){if("#"===t[0]&&7===t.length)return t;f||(f=function(){var t=document.createElement("i");return t.title="Web Colour Picker",t.style.display="none",document.body.appendChild(t),t}());var e;if(h[t])e=h[t];else{f.style.color=t,e=document.defaultView.getComputedStyle(f,"").getPropertyValue("color");e=r(c.exec(e)[1].split(/\s*,\s*/)),h[t]=e}return e},rgb2arr:o,gradient:function(t){var e=[];return l(t)&&(t=t.split("-")),u(t,function(t){-1===t.indexOf("#")&&(t=p.toRGB(t)),e.push(o(t))}),function(t){return function(t,e){(isNaN(e)||!s(e)||e<0)&&(e=0),e>1&&(e=1);var n=t.length-1,a=Math.floor(n*e),o=n*e-a,l=t[a],u=a===n?l:t[a+1];return r([i(l,u,o,0),i(l,u,o,1),i(l,u,o,2)])}(e,t)}}};t.exports=p},function(t,e,n){var i=n(2),r={values:n(64)};t.exports={isAdjust:function(t){return this.adjustNames.indexOf(t)>=0},_getDimValues:function(t){var e={},n=[];if(this.xField&&this.isAdjust("x")&&n.push(this.xField),this.yField&&this.isAdjust("y")&&n.push(this.yField),i(n,function(n){var i=r.values(t,n);i.sort(function(t,e){return t-e}),e[n]=i}),!this.yField&&this.isAdjust("y")){var a=[0,1];e.y=a}return e},adjustData:function(t,e){var n=this,r=n._getDimValues(e);i(t,function(e,a){i(r,function(i,r){n.adjustDim(r,i,e,t.length,a)})})},getAdjustRange:function(t,e,n){var i,r,a=n.indexOf(e),o=n.length;return!this.yField&&this.isAdjust("y")?(i=0,r=1):o>1?(i=0===a?n[0]:n[a-1],r=a===o-1?n[o-1]:n[a+1],0!==a?i+=(e-i)/2:i-=(r-e)/2,a!==o-1?r-=(r-e)/2:r+=(e-n[o-2])/2):(i=0===e?0:e-.5,r=0===e?1:e+.5),{pre:i,next:r}},groupData:function(t,e){var n={};return i(t,function(t){var i=t[e];void 0===i&&(i=t[e]=0),n[i]||(n[i]=[]),n[i].push(t)}),n}}},function(t,e,n){var i={default:n(152),dark:n(304)};t.exports=i},function(t,e){var n,i,r='"-apple-system", BlinkMacSystemFont, "Segoe UI", Roboto,"Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",SimSun, "sans-serif"',a={defaultColor:"#1890FF",plotCfg:{padding:[20,20,95,80]},fontFamily:r,defaultLegendPosition:"bottom",colors:["#1890FF","#2FC25B","#FACC14","#223273","#8543E0","#13C2C2","#3436C7","#F04864"],colors_16:["#1890FF","#41D9C7","#2FC25B","#FACC14","#E6965C","#223273","#7564CC","#8543E0","#5C8EE6","#13C2C2","#5CA3E6","#3436C7","#B381E6","#F04864","#D598D9"],colors_24:["#1890FF","#66B5FF","#41D9C7","#2FC25B","#6EDB8F","#9AE65C","#FACC14","#E6965C","#57AD71","#223273","#738AE6","#7564CC","#8543E0","#A877ED","#5C8EE6","#13C2C2","#70E0E0","#5CA3E6","#3436C7","#8082FF","#DD81E6","#F04864","#FA7D92","#D598D9"],colors_pie:["#1890FF","#13C2C2","#2FC25B","#FACC14","#F04864","#8543E0","#3436C7","#223273"],colors_pie_16:["#1890FF","#73C9E6","#13C2C2","#6CD9B3","#2FC25B","#9DD96C","#FACC14","#E6965C","#F04864","#D66BCA","#8543E0","#8E77ED","#3436C7","#737EE6","#223273","#7EA2E6"],shapes:{point:["hollowCircle","hollowSquare","hollowDiamond","hollowBowtie","hollowTriangle","hollowHexagon","cross","tick","plus","hyphen","line"],line:["line","dash","dot"],area:["area"]},sizes:[1,10],opacities:[.1,.9],axis:{top:{position:"top",title:null,label:{offset:16,textStyle:{fill:"#545454",fontSize:12,lineHeight:16,textBaseline:"middle",fontFamily:r},autoRotate:!0},line:{lineWidth:1,stroke:"#BFBFBF"},tickLine:{lineWidth:1,stroke:"#BFBFBF",length:4,alignWithLabel:!0}},bottom:{position:"bottom",title:null,label:{offset:16,autoRotate:!0,textStyle:{fill:"#545454",fontSize:12,lineHeight:16,textBaseline:"middle",fontFamily:r}},line:{lineWidth:1,stroke:"#BFBFBF"},tickLine:{lineWidth:1,stroke:"#BFBFBF",length:4,alignWithLabel:!0}},left:{position:"left",title:null,label:{offset:8,autoRotate:!0,textStyle:{fill:"#545454",fontSize:12,lineHeight:16,textBaseline:"middle",fontFamily:r}},line:null,tickLine:null,grid:{zIndex:-1,lineStyle:{stroke:"#E9E9E9",lineWidth:1,lineDash:[3,3]},hideFirstLine:!0}},right:{position:"right",title:null,label:{offset:8,autoRotate:!0,textStyle:{fill:"#545454",fontSize:12,lineHeight:16,textBaseline:"middle",fontFamily:r}},line:null,tickLine:null,grid:{lineStyle:{stroke:"#E9E9E9",lineWidth:1,lineDash:[3,3]},hideFirstLine:!0}},circle:{zIndex:1,title:null,label:{offset:8,textStyle:{fill:"#545454",fontSize:12,lineHeight:16,fontFamily:r}},line:{lineWidth:1,stroke:"#BFBFBF"},tickLine:{lineWidth:1,stroke:"#BFBFBF",length:4,alignWithLabel:!0},grid:{lineStyle:{stroke:"#E9E9E9",lineWidth:1,lineDash:[3,3]},hideFirstLine:!0}},radius:{zIndex:0,label:{offset:12,textStyle:{fill:"#545454",fontSize:12,textBaseline:"middle",lineHeight:16,fontFamily:r}},line:{lineWidth:1,stroke:"#BFBFBF"},tickLine:{lineWidth:1,stroke:"#BFBFBF",length:4,alignWithLabel:!0},grid:{lineStyle:{stroke:"#E9E9E9",lineWidth:1,lineDash:[3,3]},type:"circle"}},helix:{grid:null,label:null,title:null,line:{lineWidth:1,stroke:"#BFBFBF"},tickLine:{lineWidth:1,length:4,stroke:"#BFBFBF",alignWithLabel:!0}}},label:{offset:20,textStyle:{fill:"#545454",fontSize:12,textBaseline:"middle",fontFamily:r}},treemapLabels:{offset:10,textStyle:{fill:"#fff",fontSize:12,textBaseline:"top",fontStyle:"bold",fontFamily:r}},innerLabels:{textStyle:{fill:"#fff",fontSize:12,textBaseline:"middle",fontFamily:r}},thetaLabels:{labelHeight:14,offset:30},legend:{right:{position:"right",layout:"vertical",itemMarginBottom:8,width:16,height:156,title:null,legendStyle:{LIST_CLASS:{textAlign:"left"}},textStyle:{fill:"#8C8C8C",fontSize:12,textAlign:"start",textBaseline:"middle",lineHeight:0,fontFamily:r},unCheckColor:"#bfbfbf"},left:{position:"left",layout:"vertical",itemMarginBottom:8,width:16,height:156,title:null,textStyle:{fill:"#8C8C8C",fontSize:12,textAlign:"start",textBaseline:"middle",lineHeight:20,fontFamily:r},unCheckColor:"#bfbfbf"},top:{position:"top",offset:[0,6],layout:"horizontal",title:null,itemGap:10,width:156,height:16,textStyle:{fill:"#8C8C8C",fontSize:12,textAlign:"start",textBaseline:"middle",lineHeight:20,fontFamily:r},unCheckColor:"#bfbfbf"},bottom:{position:"bottom",offset:[0,6],layout:"horizontal",title:null,itemGap:10,width:156,height:16,textStyle:{fill:"#8C8C8C",fontSize:12,textAlign:"start",textBaseline:"middle",lineHeight:20,fontFamily:r},unCheckColor:"#bfbfbf"},html:(n={},n["g2-legend"]={height:"auto",width:"auto",position:"absolute",overflow:"auto",fontSize:"12px",fontFamily:r,lineHeight:"20px",color:"#8C8C8C"},n["g2-legend-title"]={marginBottom:"4px"},n["g2-legend-list"]={listStyleType:"none",margin:0,padding:0},n["g2-legend-list-item"]={cursor:"pointer",marginBottom:"5px",marginRight:"24px"},n["g2-legend-marker"]={width:"9px",height:"9px",borderRadius:"50%",display:"inline-block",marginRight:"8px",verticalAlign:"middle"},n),gradient:{textStyle:{fill:"#8C8C8C",fontSize:12,textAlign:"center",textBaseline:"middle",lineHeight:20,fontFamily:r},lineStyle:{lineWidth:1,stroke:"#fff"},unCheckColor:"#bfbfbf"},margin:[0,5,24,5],legendMargin:24},tooltip:(i={useHtml:!0,crosshairs:!1,offset:15},i["g2-tooltip"]={position:"absolute",visibility:"hidden",zIndex:8,transition:"visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), left 0.4s cubic-bezier(0.23, 1, 0.32, 1), top 0.4s cubic-bezier(0.23, 1, 0.32, 1)",backgroundColor:"rgba(255, 255, 255, 0.9)",boxShadow:"0px 0px 10px #aeaeae",borderRadius:"3px",color:"rgb(87, 87, 87)",fontSize:"12px",fontFamily:r,lineHeight:"20px",padding:"10px 10px 6px 10px"},i["g2-tooltip-title"]={marginBottom:"4px"},i["g2-tooltip-list"]={margin:0,listStyleType:"none",padding:0},i["g2-tooltip-list-item"]={marginBottom:"4px"},i["g2-tooltip-marker"]={width:"5px",height:"5px",borderRadius:"50%",display:"inline-block",marginRight:"8px"},i["g2-tooltip-value"]={display:"inline-block",float:"right",marginLeft:"30px"},i),tooltipMarker:{symbol:function(t,e,n){return[["M",t,e],["m",-n,0],["a",n,n,0,1,0,2*n,0],["a",n,n,0,1,0,2*-n,0]]},stroke:"#fff",shadowBlur:10,shadowOffsetX:0,shadowOffSetY:0,shadowColor:"rgba(0,0,0,0.09)",lineWidth:2,radius:4},tooltipCrosshairsRect:{type:"rect",rectStyle:{fill:"#CCD6EC",opacity:.3}},tooltipCrosshairsLine:{lineStyle:{stroke:"rgba(0, 0, 0, 0.25)",lineWidth:1}},shape:{point:{lineWidth:1,fill:"#1890FF",radius:4},hollowPoint:{fill:"#fff",lineWidth:1,stroke:"#1890FF",radius:3},interval:{lineWidth:0,fill:"#1890FF",fillOpacity:.85},hollowInterval:{fill:"#fff",stroke:"#1890FF",fillOpacity:0,lineWidth:2},area:{lineWidth:0,fill:"#1890FF",fillOpacity:.6},polygon:{lineWidth:0,fill:"#1890FF",fillOpacity:1},hollowPolygon:{fill:"#fff",stroke:"#1890FF",fillOpacity:0,lineWidth:2},hollowArea:{fill:"#fff",stroke:"#1890FF",fillOpacity:0,lineWidth:2},line:{stroke:"#1890FF",lineWidth:2,fill:null},edge:{stroke:"#1890FF",lineWidth:1,fill:null},schema:{stroke:"#1890FF",lineWidth:1,fill:null}},guide:{line:{lineStyle:{stroke:"rgba(0, 0, 0, .65)",lineDash:[2,2],lineWidth:1},text:{position:"start",autoRotate:!0,style:{fill:"rgba(0, 0, 0, .45)",fontSize:12,textAlign:"start",fontFamily:r,textBaseline:"bottom"}}},text:{style:{fill:"rgba(0,0,0,.5)",fontSize:12,textBaseline:"middle",textAlign:"start",fontFamily:r}},region:{style:{lineWidth:0,fill:"#000",fillOpacity:.04}},html:{alignX:"middle",alignY:"middle"},dataRegion:{style:{region:{lineWidth:0,fill:"#000000",opacity:.04},text:{textAlign:"center",textBaseline:"bottom",fontSize:12,fill:"rgba(0, 0, 0, .65)"}}},dataMarker:{top:!0,style:{point:{r:3,fill:"#FFFFFF",stroke:"#1890FF",lineWidth:2},line:{stroke:"#A3B1BF",lineWidth:1},text:{fill:"rgba(0, 0, 0, .65)",opacity:1,fontSize:12,textAlign:"start"}},display:{point:!0,line:!0,text:!0},lineLength:20,direction:"upward",autoAdjust:!0}},pixelRatio:null};t.exports=a},function(t,e,n){var i=n(25).Group,r=n(3),a=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){return{zIndex:1,type:"line",lineStyle:null,items:null,alternateColor:null,matrix:null,hideFirstLine:!1,hideLastLine:!1,hightLightZero:!1,zeroLineStyle:{stroke:"#595959",lineDash:[0,0]}}},n._renderUI=function(){t.prototype._renderUI.call(this),this._drawLines()},n._drawLines=function(){var t=this.get("lineStyle"),e=this.get("items");e&&e.length&&(this._precessItems(e),this._drawGridLines(e,t))},n._precessItems=function(t){var e,n=this;r.each(t,function(t,i){e&&n.get("alternateColor")&&n._drawAlternativeBg(t,e,i),e=t})},n._drawGridLines=function(t,e){var n,i,a,o,s=this,l=this.get("type"),u=t.length;"line"===l||"polygon"===l?r.each(t,function(t,c){s.get("hideFirstLine")&&0===c||s.get("hideLastLine")&&c===u-1||(o=t.points,i=[],"line"===l?(i.push(["M",o[0].x,o[0].y]),i.push(["L",o[o.length-1].x,o[o.length-1].y])):r.each(o,function(t,e){0===e?i.push(["M",t.x,t.y]):i.push(["L",t.x,t.y])}),a=s._drawZeroLine(l,c)?r.mix({},s.get("zeroLineStyle"),{path:i}):r.mix({},e,{path:i}),(n=s.addShape("path",{attrs:a})).name="axis-grid",n._id=t._id,n.set("coord",s.get("coord")),s.get("appendInfo")&&n.setSilent("appendInfo",s.get("appendInfo")))}):r.each(t,function(t,l){s.get("hideFirstLine")&&0===l||s.get("hideLastLine")&&l===u-1||(o=t.points,i=[],r.each(o,function(t,e){var n=t.radius;0===e?i.push(["M",t.x,t.y]):i.push(["A",n,n,0,0,t.flag,t.x,t.y])}),a=r.mix({},e,{path:i}),(n=s.addShape("path",{attrs:a})).name="axis-grid",n._id=t._id,n.set("coord",s.get("coord")),s.get("appendInfo")&&n.setSilent("appendInfo",s.get("appendInfo")))})},n._drawZeroLine=function(t,e){var n=this.get("tickValues");return!("line"!==t||!n||0!==n[e]||!this.get("hightLightZero"))},n._drawAlternativeBg=function(t,e,n){var i,a,o,s=this.get("alternateColor");r.isString(s)?a=s:r.isArray(s)&&(a=s[0],o=s[1]),n%2==0?o&&(i=this._getBackItem(e.points,t.points,o)):a&&(i=this._getBackItem(e.points,t.points,a));var l=this.addShape("Path",{attrs:i});l.name="axis-grid-rect",l._id=t._id&&t._id.replace("grid","grid-rect"),l.set("coord",this.get("coord")),this.get("appendInfo")&&l.setSilent("appendInfo",this.get("appendInfo"))},n._getBackItem=function(t,e,n){var i=[],a=this.get("type");if("line"===a)i.push(["M",t[0].x,t[0].y]),i.push(["L",t[t.length-1].x,t[t.length-1].y]),i.push(["L",e[e.length-1].x,e[e.length-1].y]),i.push(["L",e[0].x,e[0].y]),i.push(["Z"]);else if("polygon"===a){r.each(t,function(t,e){0===e?i.push(["M",t.x,t.y]):i.push(["L",t.x,t.y])});for(var o=e.length-1;o>=0;o--)i.push(["L",e[o].x,e[o].y]);i.push(["Z"])}else{var s=t[0].flag;r.each(t,function(t,e){var n=t.radius;0===e?i.push(["M",t.x,t.y]):i.push(["A",n,n,0,0,t.flag,t.x,t.y])});for(var l=e.length-1;l>=0;l--){var u=e[l],c=u.radius;l===e.length-1?i.push(["M",u.x,u.y]):i.push(["A",c,c,0,0,1===s?0:1,u.x,u.y])}}return{fill:n,path:i}},e}(i);t.exports=a},function(t,e,n){var i=n(3),r=i.DomUtil,a=n(32),o={scatter:n(307),map:n(308),treemap:n(309)},s=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return i.mix({},e,{name:"label",type:"default",textStyle:null,formatter:null,items:null,useHtml:!1,containerTpl:'
    ',itemTpl:'
    {text}
    ',labelLine:!1,lineGroup:null,shapes:null,config:!0,capture:!0})},n.clear=function(){var e=this.get("group"),n=this.get("container");e&&!e.get("destroyed")&&e.clear(),n&&(n.innerHTML=""),t.prototype.clear.call(this)},n.destroy=function(){var t=this.get("group"),e=this.get("container");t.destroy||t.destroy(),e&&(e.innerHTML="")},n.render=function(){this.clear(),this._init(),this.beforeDraw(),this.draw(),this.afterDraw()},n._dryDraw=function(){var t=this,e=t.get("items"),n=t.getLabels(),r=n.length;i.each(e,function(e,i){if(i=e.length;a--)n[a].remove();t._adjustLabels(),!t.get("labelLine")&&t.get("config")||t.drawLines()},n.draw=function(){this._dryDraw(),this.get("canvas").draw()},n.changeLabel=function(t,e){if(t)if(t.tagName){var n=this._createDom(e);t.innerHTML=n.innerHTML,this._setCustomPosition(e,t)}else t._id=e._id,t.attr("text",e.text),t.attr("x")===e.x&&t.attr("y")===e.y||(t.resetMatrix(),e.textStyle.rotate&&(t.rotateAtStart(e.textStyle.rotate),delete e.textStyle.rotate),t.attr(e))},n.show=function(){var t=this.get("group"),e=this.get("container");t&&t.show(),e&&(e.style.opacity=1)},n.hide=function(){var t=this.get("group"),e=this.get("container");t&&t.hide(),e&&(e.style.opacity=0)},n.drawLines=function(){var t=this;"boolean"==typeof t.get("labelLine")&&t.set("labelLine",{});var e=t.get("lineGroup");!e||e.get("destroyed")?(e=t.get("group").addGroup({elCls:"x-line-group"}),t.set("lineGroup",e)):e.clear(),i.each(t.get("items"),function(n){t.lineToLabel(n,e)})},n.lineToLabel=function(t,e){if(this.get("config")||t.labelLine){var n=t.labelLine||this.get("labelLine"),r=void 0===t.capture?this.get("capture"):t.capture,a=n.path;if(a&&i.isFunction(n.path)&&(a=n.path(t)),!a){var o=t.start||{x:t.x-t._offset.x,y:t.y-t._offset.y};a=[["M",o.x,o.y],["L",t.x,t.y]]}var s=t.color;s||(s=t.textStyle&&t.textStyle.fill?t.textStyle.fill:"#000");var l=e.addShape("path",{attrs:i.mix({path:a,fill:null,stroke:s},n),capture:r});l.name=this.get("name"),l._id=t._id&&t._id.replace("glabel","glabelline"),l.set("coord",this.get("coord"))}},n._adjustLabels=function(){var t=this.get("type"),e=this.getLabels(),n=this.get("shapes"),i=o[t];"default"!==t&&i&&i(e,n)},n.getLabels=function(){var t=this.get("container");return t?i.toArray(t.childNodes):this.get("group").get("children")},n._addLabel=function(t,e){var n=t;return this.get("config")&&(n=this._getLabelCfg(t,e)),this._createText(n)},n._getLabelCfg=function(t,e){var n=this.get("textStyle")||{},r=this.get("formatter"),a=this.get("htmlTemplate");if(!i.isObject(t)){var o=t;(t={}).text=o}i.isFunction(n)&&(n=n(t.text,t,e)),r&&(t.text=r(t.text,t,e)),a&&(t.useHtml=!0,i.isFunction(a)&&(t.text=a(t.text,t,e))),i.isNil(t.text)&&(t.text=""),t.text=t.text+"";return i.mix({},t,{textStyle:n},{x:t.x||0,y:t.y||0})},n._init=function(){if(!this.get("group")){var t=this.get("canvas").addGroup({id:"label-group"});this.set("group",t)}},n.initHtmlContainer=function(){var t=this.get("container");if(t)i.isString(t)&&(t=document.getElementById(t))&&this.set("container",t);else{var e=this.get("containerTpl"),n=this.get("canvas").get("el").parentNode;t=r.createDom(e),n.style.position="relative",n.appendChild(t),this.set("container",t)}return t},n._createText=function(t){var e,n=this.get("container"),r=void 0===t.capture?this.get("capture"):t.capture;if(!t.useHtml&&!t.htmlTemplate){var a=this.get("name"),o=t.point,s=this.get("group");delete t.point;var l=t.rotate;return t.textStyle&&(t.textStyle.rotate&&(l=t.textStyle.rotate,delete t.textStyle.rotate),t=i.mix({x:t.x,y:t.y,textAlign:t.textAlign,text:t.text},t.textStyle)),e=s.addShape("text",{attrs:t,capture:r}),l&&(Math.abs(l)>2*Math.PI&&(l=l/180*Math.PI),e.transform([["t",-t.x,-t.y],["r",l],["t",t.x,t.y]])),e.setSilent("origin",o||t),e.name=a,this.get("appendInfo")&&e.setSilent("appendInfo",this.get("appendInfo")),e}n||(n=this.initHtmlContainer());var u=this._createDom(t);n.appendChild(u),this._setCustomPosition(t,u)},n._createDom=function(t){var e=this.get("itemTpl"),n=i.substitute(e,{text:t.text});return r.createDom(n)},n._setCustomPosition=function(t,e){var n=t.textAlign||"left",i=t.y,a=t.x,o=r.getOuterWidth(e);i-=r.getOuterHeight(e)/2,"center"===n?a-=o/2:"right"===n&&(a-=o),e.style.top=parseInt(i,10)+"px",e.style.left=parseInt(a,10)+"px"},e}(a);t.exports=s},function(t,e){var n=function(){function t(){this.bitmap=[]}var e=t.prototype;return e.hasGap=function(t){for(var e=!0,n=this.bitmap,i=Math.floor(t.minX),r=Math.ceil(t.maxX),a=Math.floor(t.minY),o=Math.ceil(t.maxY)-1,s=i;sn&&a.each(e,function(t){h=t.getBBox(),u=f||h.width,c=h.height+r,n-li&&a.each(n,function(t){p=t.getBBox(),h=p.width,f=p.height,u?g=u+r:h>g&&(g=h+r),i-c-1?t:t.parentNode?t.parentNode.className===h?t.parentNode:r(t.parentNode,e):null}function a(t,e){var n=null,i=e instanceof c?e.get("value"):e;return o.each(t,function(t){if(t.value===i)return n=t,!1}),n}var o=n(3),s=n(157),l=n(14).FONT_FAMILY,u=o.DomUtil,c=o.Group,h="g2-legend",f="g2-legend-list",p="g2-legend-list-item",g="g2-legend-marker",d=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return o.mix({},e,{type:"category-legend",container:null,containerTpl:'

      ',itemTpl:'
    • {value}
    • ',legendStyle:{},textStyle:{fill:"#333",fontSize:12,textAlign:"middle",textBaseline:"top",fontFamily:l},abridgeText:!1,tipTpl:'
      ',tipStyle:{display:"none",fontSize:"12px",backgroundColor:"#fff",position:"absolute",width:"auto",height:"auto",padding:"3px",boxShadow:"2px 2px 5px #888"},autoPosition:!0})},n._init=function(){},n.beforeRender=function(){},n.render=function(){this._renderHTML()},n._bindEvents=function(){var t=this,e=i(this.get("legendWrapper"),f);this.get("hoverable")&&(e.onmousemove=function(e){return t._onMousemove(e)},e.onmouseout=function(e){return t._onMouseleave(e)}),this.get("clickable")&&(e.onclick=function(e){return t._onClick(e)})},n._onMousemove=function(t){var e=this.get("items"),n=t.target,i=n.className;if(!((i=i.split(" ")).indexOf(h)>-1||i.indexOf(f)>-1)){var o=r(n,p),s=a(e,o.getAttribute("data-value"));s?(this.deactivate(),this.activate(o.getAttribute("data-value")),this.emit("itemhover",{item:s,currentTarget:o,checked:s.checked})):s||(this.deactivate(),this.emit("itemunhover",t))}},n._onMouseleave=function(t){this.deactivate(),this.emit("itemunhover",t)},n._onClick=function(t){var e=this,n=i(this.get("legendWrapper"),f),s=this.get("unCheckColor"),l=this.get("items"),u=this.get("selectedMode"),c=n.childNodes,d=t.target,v=d.className;if(!((v=v.split(" ")).indexOf(h)>-1||v.indexOf(f)>-1)){var y=r(d,p),x=i(y,"g2-legend-text"),m=i(y,g),_=a(l,y.getAttribute("data-value"));if(_){var b=y.className,w=y.getAttribute("data-color");if("single"===u)_.checked=!0,o.each(c,function(t){if(t!==y){i(t,g).style.backgroundColor=s,t.className=t.className.replace("checked","unChecked"),t.style.color=s;a(l,t.getAttribute("data-value")).checked=!1}else x&&(x.style.color=e.get("textStyle").fill),m&&(m.style.backgroundColor=w),y.className=b.replace("unChecked","checked")});else{var S=-1!==b.indexOf("checked"),M=0;if(o.each(c,function(t){-1!==t.className.indexOf("checked")&&M++}),!this.get("allowAllCanceled")&&S&&1===M)return void this.emit("clicklastitem",{item:_,currentTarget:y,checked:"single"===u||_.checked});_.checked=!_.checked,S?(m&&(m.style.backgroundColor=s),y.className=b.replace("checked","unChecked"),y.style.color=s):(m&&(m.style.backgroundColor=w),y.className=b.replace("unChecked","checked"),y.style.color=this.get("textStyle").fill)}this.emit("itemclick",{item:_,currentTarget:y,checked:"single"===u||_.checked})}}},n.activate=function(t){var e=this,n=this,r=n.get("items"),o=a(r,t);i(n.get("legendWrapper"),f).childNodes.forEach(function(t){var s=i(t,g),l=a(r,t.getAttribute("data-value"));if(e.get("highlight")){if(l===o&&l.checked)return void(s.style.border="1px solid #333")}else l===o?s.style.opacity=n.get("activeOpacity"):l.checked&&(s.style.opacity=n.get("inactiveOpacity"))})},n.deactivate=function(){var t=this,e=this;i(e.get("legendWrapper"),f).childNodes.forEach(function(n){var r=i(n,g);t.get("highlight")?r.style.border="1px solid #fff":r.style.opacity=e.get("inactiveOpacity")})},n._renderHTML=function(){var t=this,e=this.get("container"),n=this.get("title"),r=this.get("containerTpl"),a=u.createDom(r),s=i(a,"g2-legend-title"),c=i(a,f),d=this.get("unCheckColor"),v=o.deepMix({},{CONTAINER_CLASS:{height:"auto",width:"auto",position:"absolute",overflowY:"auto",fontSize:"12px",fontFamily:l,lineHeight:"20px",color:"#8C8C8C"},TITLE_CLASS:{marginBottom:this.get("titleGap")+"px",fontSize:"12px",color:"#333",textBaseline:"middle",fontFamily:l},LIST_CLASS:{listStyleType:"none",margin:0,padding:0,textAlign:"center"},LIST_ITEM_CLASS:{cursor:"pointer",marginBottom:"5px",marginRight:"24px"},MARKER_CLASS:{width:"9px",height:"9px",borderRadius:"50%",display:"inline-block",marginRight:"4px",verticalAlign:"middle"}},this.get("legendStyle"));if(/^\#/.test(e)||"string"==typeof e&&e.constructor===String){var y=e.replace("#","");(e=document.getElementById(y)).appendChild(a)}else{var x=this.get("position"),m={};m="left"===x||"right"===x?{maxHeight:(this.get("maxLength")||e.offsetHeight)+"px"}:{maxWidth:(this.get("maxLength")||e.offsetWidth)+"px"},u.modifyCSS(a,o.mix({},v.CONTAINER_CLASS,m,this.get(h))),e.appendChild(a)}u.modifyCSS(c,o.mix({},v.LIST_CLASS,this.get(f))),s&&(n&&n.text?(s.innerHTML=n.text,u.modifyCSS(s,o.mix({},v.TITLE_CLASS,this.get("g2-legend-title"),n))):a.removeChild(s));var _=this.get("items"),b=this.get("itemTpl"),w=this.get("position"),S=this.get("layout"),M="right"===w||"left"===w||"vertical"===S?"block":"inline-block",C=o.mix({},v.LIST_ITEM_CLASS,{display:M},this.get(p)),A=o.mix({},v.MARKER_CLASS,this.get(g));if(o.each(_,function(e,n){var r,s=e.checked,l=t._formatItemValue(e.value),h=e.marker.fill||e.marker.stroke,f=s?h:d;r=o.isFunction(b)?b(l,f,s,n):b;var p=o.substitute(r,o.mix({},e,{index:n,checked:s?"checked":"unChecked",value:l,color:f,originColor:h,originValue:e.value.replace(/\"/g,""")})),v=u.createDom(p);v.style.color=t.get("textStyle").fill;var y=i(v,g),x=i(v,"g2-legend-text");if(u.modifyCSS(v,C),y&&u.modifyCSS(y,A),s||(v.style.color=d,y&&(y.style.backgroundColor=d)),c.appendChild(v),t.get("abridgeText")){var m=l,_=v.offsetWidth,w=t.get("textStyle").fontSize;isNaN(w)&&(-1!==w.indexOf("pt")?w=1*parseFloat(w.substr(0,w.length-2))/72*96:-1!==w.indexOf("px")&&(w=parseFloat(w.substr(0,w.length-2))));var S=w*m.length,M=Math.floor(_/w);_<2*w?m="":_1&&(m=m.substr(0,M-1)+"..."),x.innerText=m,v.addEventListener("mouseover",function(){var t=i(a.parentNode,"textTip");t.style.display="block",t.style.left=v.offsetLeft+v.offsetWidth+"px",t.style.top=v.offsetTop+15+"px",t.innerText=l}),v.addEventListener("mouseout",function(){i(a.parentNode,"textTip").style.display="none"})}}),this.get("abridgeText")){var k=this.get("tipTpl"),P=u.createDom(k),T=this.get("tipStyle");u.modifyCSS(P,T),a.parentNode.appendChild(P),P.addEventListener("mouseover",function(){P.style.display="none"})}this.set("legendWrapper",a)},n._adjustPositionOffset=function(){var t=this.get("position"),e=this.get("offset"),n=this.get("offsetX"),i=this.get("offsetY");n&&(e[0]=n),i&&(e[1]=i);var r=this.get("legendWrapper");r.style.left=t[0]+"px",r.style.top=t[1]+"px",r.style.marginLeft=e[0]+"px",r.style.marginTop=e[1]+"px"},n.getWidth=function(){return u.getOuterWidth(this.get("legendWrapper"))},n.getHeight=function(){return u.getOuterHeight(this.get("legendWrapper"))},n.move=function(e,n){/^\#/.test(this.get("container"))?t.prototype.move.call(this,e,n):(u.modifyCSS(this.get("legendWrapper"),{left:e+"px",top:n+"px"}),this.set("x",e),this.set("y",n))},n.destroy=function(){var t=this.get("legendWrapper");t&&t.parentNode&&t.parentNode.removeChild(t)},e}(s);t.exports=d},function(t,e,n){var i=n(32),r=n(3),a=function(t){function e(e){var n;return(n=t.call(this,e)||this)._init_(),n.render(),n}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return r.mix({},e,{type:null,plot:null,plotRange:null,rectStyle:{fill:"#CCD6EC",opacity:.3},lineStyle:{stroke:"rgba(0, 0, 0, 0.25)",lineWidth:1},isTransposed:!1})},n._init_=function(){var t,e=this.get("plot");t="rect"===this.type?e.addGroup({zIndex:0}):e.addGroup(),this.set("container",t)},n._addLineShape=function(t,e){var n=this.get("container").addShape("line",{capture:!1,attrs:t});return this.set("crossLineShape"+e,n),n},n._renderHorizontalLine=function(t,e){var n=r.mix(this.get("lineStyle"),this.get("style")),i=r.mix({x1:e?e.bl.x:t.get("width"),y1:0,x2:e?e.br.x:0,y2:0},n);this._addLineShape(i,"X")},n._renderVerticalLine=function(t,e){var n=r.mix(this.get("lineStyle"),this.get("style")),i=r.mix({x1:0,y1:e?e.bl.y:t.get("height"),x2:0,y2:e?e.tl.y:0},n);this._addLineShape(i,"Y")},n._renderBackground=function(t,e){var n=r.mix(this.get("rectStyle"),this.get("style")),i=this.get("container"),a=r.mix({x:e?e.tl.x:0,y:e?e.tl.y:t.get("height"),width:e?e.br.x-e.bl.x:t.get("width"),height:e?Math.abs(e.tl.y-e.bl.y):t.get("height")},n),o=i.addShape("rect",{attrs:a,capture:!1});return this.set("crosshairsRectShape",o),o},n._updateRectShape=function(t){var e,n=this.get("crosshairsRectShape"),i=this.get("isTransposed"),a=t[0],o=t[t.length-1],s=i?"y":"x",l=i?"height":"width",u=a[s];if(t.length>1&&a[s]>o[s]&&(u=o[s]),this.get("width"))n.attr(s,u-this.get("crosshairs").width/2),n.attr(l,this.get("width"));else if(r.isArray(a.point[s])&&!a.size){var c=a.point[s][1]-a.point[s][0];n.attr(s,a.point[s][0]),n.attr(l,c)}else e=3*a.size/4,n.attr(s,u-e),1===t.length?n.attr(l,3*a.size/2):n.attr(l,Math.abs(o[s]-a[s])+2*e)},n.render=function(){var t=this.get("canvas"),e=this.get("plotRange"),n=this.get("isTransposed");switch(this.clear(),this.get("type")){case"x":this._renderHorizontalLine(t,e);break;case"y":this._renderVerticalLine(t,e);break;case"cross":this._renderHorizontalLine(t,e),this._renderVerticalLine(t,e);break;case"rect":this._renderBackground(t,e);break;default:n?this._renderHorizontalLine(t,e):this._renderVerticalLine(t,e)}},n.show=function(){var e=this.get("container");t.prototype.show.call(this),e.show()},n.hide=function(){var e=this.get("container");t.prototype.hide.call(this),e.hide()},n.clear=function(){var e=this.get("container");this.set("crossLineShapeX",null),this.set("crossLineShapeY",null),this.set("crosshairsRectShape",null),t.prototype.clear.call(this),e.clear()},n.destroy=function(){var e=this.get("container");t.prototype.destroy.call(this),e.remove()},n.setPosition=function(t,e,n){var i=this.get("crossLineShapeX"),r=this.get("crossLineShapeY"),a=this.get("crosshairsRectShape");r&&!r.get("destroyed")&&r.move(t,0),i&&!i.get("destroyed")&&i.move(0,e),a&&!a.get("destroyed")&&this._updateRectShape(n)},e}(i);t.exports=a},function(t,e){var n={_calcTooltipPosition:function(t,e,n,i,r,a){var o=0,s=0,l=20;if(a){var u=a.getBBox();o=u.width,s=u.height,t=u.x,e=u.y,l=5}switch(n){case"inside":t=t+o/2-i/2,e=e+s/2-r/2;break;case"top":t=t+o/2-i/2,e=e-r-l;break;case"left":t=t-i-l,e=e+s/2-r/2;break;case"right":t=t+o+l,e=e+s/2-r/2;break;case"bottom":default:t=t+o/2-i/2,e=e+s+l}return[t,e]},_constraintPositionInBoundary:function(t,e,n,i,r,a){return t+n+20>r?t=(t-=n+20)<0?0:t:t+20<0?t=20:t+=20,e+i+20>a?e=(e-=i+20)<0?0:e:e+20<0?e=20:e+=20,[t,e]},_constraintPositionInPlot:function(t,e,n,i,r,a){return t+n>r.tr.x&&(t-=n+40),tr.bl.y&&(e-=i+40),ee&&!a){t+=2*Math.asin(e/(2*o))}else o+=e;return{x:r.x+o*Math.cos(t),y:r.y+o*Math.sin(t),angle:t,r:o}},n.getArcPoint=function(t,e){var n;return e=e||0,n=a.isArray(t.x)||a.isArray(t.y)?{x:a.isArray(t.x)?t.x[e]:t.x,y:a.isArray(t.y)?t.y[e]:t.y}:t,this.transLabelPoint(n),n},n.getPointAngle=function(t){var e=this.get("coord");return r.getPointAngle(e,t)},n.getMiddlePoint=function(t){var e=this.get("coord"),n=t.length,i={x:0,y:0};return a.each(t,function(t){i.x+=t.x,i.y+=t.y}),i.x/=n,i.y/=n,i=e.convert(i)},n._isToMiddle=function(t){return t.x.length>2},n.getLabelPoint=function(t,e,n){var i,r=t.text[n],a=1;this._isToMiddle(e)?i=this.getMiddlePoint(e.points):(1===t.text.length&&0===n?n=1:0===n&&(a=-1),i=this.getArcPoint(e,n));var o=this.getDefaultOffset(t);o*=a;var s=this.getPointAngle(i),l=this.getCirclePoint(s,o,i);if(l?(l.text=r,l.angle=s,l.color=e.color):l={text:""},t.autoRotate||void 0===t.autoRotate){var u=l.textStyle?l.textStyle.rotate:null;u||(u=l.rotate||this.getLabelRotate(s,o,e)),l.rotate=u}return l.start={x:i.x,y:i.y},l},n._isEmitLabels=function(){return this.get("label").labelEmit},n.getLabelRotate=function(t){var e;return e=180*t/Math.PI,e+=90,this._isEmitLabels()&&(e-=90),e&&(e>90?e-=180:e<-90&&(e+=180)),e/180*Math.PI},n.getLabelAlign=function(t){var e,n=this.get("coord");if(this._isEmitLabels())e=t.angle<=Math.PI/2&&t.angle>-Math.PI/2?"left":"right";else if(n.isTransposed){var i=n.getCenter(),r=this.getDefaultOffset(t);e=Math.abs(t.x-i.x)<1?"center":t.angle>Math.PI||t.angle<=0?r>0?"left":"right":r>0?"right":"left"}else e="center";return e},e}(i);t.exports=o},function(t,e,n){t.exports={Scale:n(341),Coord:n(342),Axis:n(347),Guide:n(348),Legend:n(351),Tooltip:n(353),Event:n(354)}},function(t,e,n){function i(t,e,n){void 0===n&&(n=1);var i=[t.x,t.y,n];return a.vec3.transformMat3(i,i,e),{x:i[0],y:i[1]}}var r=n(16),a=n(0),o=n(167);t.exports=function(t,e){var n=e;return a.each(t.get("children"),function(t){if(t instanceof r.Group||t instanceof r.Path)n=o(n,t.getBBox());else if(t instanceof r.Text){var e=function(t){var e=t.getBBox(),n={x:e.minX,y:e.minY},r={x:e.maxX,y:e.maxY},a=t.attr("matrix");return n=i(n,a),r=i(r,a),{minX:n.x,minY:n.y,maxX:r.x,maxY:r.y}}(t),s=Math.abs(e.maxX-e.minX),l=Math.abs(e.maxY-e.minY);n=s0?e=0:n=0,n-e<5&&!l&&n-e>=1&&(l=1)),i(l)){var m=(n-e)/(v-1);l=a.snapFactorTo(m,x,"ceil"),f!==h&&((y=parseInt((n-e)/l,10))>f&&(y=f),ye&&(_-=l),n=a.fixedBase(M,l),e=a.fixedBase(_,l)}n=Math.min(n,d),e=Math.max(e,g),c.push(e);for(var C=1;Cn?(s=o,o=n):s>n&&(s=n),l1&&(e.minTickInterval=s-o),(a(e.min)||e._toTimeStamp(e.min)>o)&&(e.min=o),(a(e.max)||e._toTimeStamp(e.max)d&&(d=n);var m=d/x,_=i(p);if(m>.51){for(var b=Math.ceil(m),w=i(g),S=_;S<=w+b;S+=b)f.push(r(S));d=null}else if(m>.0834){for(var M=Math.ceil(m/.0834),C=a(p),A=function(t,e){var n=i(t),r=i(e),o=a(t);return 12*(r-n)+(a(e)-o)%12}(p,g),k=0;k<=A+M;k+=M)f.push(o(_,k+C));d=null}else if(d>.5*y){var P=new Date(p),T=P.getFullYear(),I=P.getMonth(p),O=P.getDate(),L=Math.ceil(d/y),E=function(t,e){return Math.ceil((e-t)/h)}(p,g);d=L*y;for(var D=0;Dc){var F=new Date(p),B=F.getFullYear(),R=F.getMonth(p),j=F.getDate(),N=F.getHours(),z=s.snapTo(u,Math.ceil(d/c)),Y=function(t,e){return Math.ceil((e-t)/c)}(p,g);d=z*c;for(var V=0;V<=Y+z;V+=z)f.push(new Date(B,R,j,N+V).getTime())}else if(d>6e4){var X=function(t,e){return Math.ceil((e-t)/6e4)}(p,g),H=Math.ceil(d/6e4);d=6e4*H;for(var W=0;W<=X+H;W+=H)f.push(p+6e4*W)}else{d<1e3&&(d=1e3),p=1e3*Math.floor(p/1e3);var G=Math.ceil((g-p)/1e3),q=Math.ceil(d/1e3);d=1e3*q;for(var U=0;U-1?r/(this.values.length-1):0,n+e*(i-n)},n.getText=function(t){var e="",n=this.translate(t);e=n>-1?this.values[n]:t;var i=this.formatter;return e=parseInt(e,10),e=i?i(e):a.format(e,this.mask)},n.getTicks=function(){var t=this,e=this.ticks,n=[];return l(e,function(e){var i;i=c(e)?e:{text:h(e)?e:t.getText(e),value:t.scale(e),tickValue:e},n.push(i)}),n},n._toTimeStamp=function(t){return s.toTimeStamp(t)},e}(r);i.TimeCat=f,t.exports=f},function(t,e,n){function i(t,e){return 1===t?1:Math.log(e)/Math.log(t)}var r=n(2),a=n(17),o=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n._initDefaultCfg=function(){t.prototype._initDefaultCfg.call(this),this.type="log",this.tickCount=10,this.base=2,this._minTick=null},n.calculateTicks=function(){var t,e=this.base;if(this.min<0)throw new Error("The minimum value must be greater than zero!");var n=i(e,this.max);if(this.min>0)t=Math.floor(i(e,this.min));else{var a=this.values,o=this.max;r(a,function(t){t>0&&t1&&(o=1),t=Math.floor(i(e,o)),this._minTick=t,this.positiveMin=o}for(var s=n-t,l=this.tickCount,u=Math.ceil(s/l),c=[],h=t;h=0?Math.floor(i(e,this.min)):0)>n){var r=n;n=t,t=r}for(var a=n-t,o=this.tickCount,s=Math.ceil(a/o),l=[],u=t;u0&&(r=1/Math.sqrt(r),t[0]=e[0]*r,t[1]=e[1]*r),t},e.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},e.cross=function(t,e,n){var i=e[0]*n[1]-e[1]*n[0];return t[0]=t[1]=0,t[2]=i,t},e.lerp=function(t,e,n,i){var r=e[0],a=e[1];return t[0]=r+i*(n[0]-r),t[1]=a+i*(n[1]-a),t},e.random=function(t,e){e=e||1;var n=2*h.RANDOM()*Math.PI;return t[0]=Math.cos(n)*e,t[1]=Math.sin(n)*e,t},e.transformMat2=function(t,e,n){var i=e[0],r=e[1];return t[0]=n[0]*i+n[2]*r,t[1]=n[1]*i+n[3]*r,t},e.transformMat2d=function(t,e,n){var i=e[0],r=e[1];return t[0]=n[0]*i+n[2]*r+n[4],t[1]=n[1]*i+n[3]*r+n[5],t},e.transformMat3=function(t,e,n){var i=e[0],r=e[1];return t[0]=n[0]*i+n[3]*r+n[6],t[1]=n[1]*i+n[4]*r+n[7],t},e.transformMat4=function(t,e,n){var i=e[0],r=e[1];return t[0]=n[0]*i+n[4]*r+n[12],t[1]=n[1]*i+n[5]*r+n[13],t},e.rotate=function(t,e,n,i){var r=e[0]-n[0],a=e[1]-n[1],o=Math.sin(i),s=Math.cos(i);return t[0]=r*s-a*o+n[0],t[1]=r*o+a*s+n[1],t},e.angle=function(t,e){var n=t[0],i=t[1],r=e[0],a=e[1],o=n*n+i*i;o>0&&(o=1/Math.sqrt(o));var s=r*r+a*a;s>0&&(s=1/Math.sqrt(s));var l=(n*r+i*a)*o*s;return l>1?0:l<-1?Math.PI:Math.acos(l)},e.str=function(t){return"vec2("+t[0]+", "+t[1]+")"},e.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]},e.equals=function(t,e){var n=t[0],i=t[1],r=e[0],a=e[1];return Math.abs(n-r)<=h.EPSILON*Math.max(1,Math.abs(n),Math.abs(r))&&Math.abs(i-a)<=h.EPSILON*Math.max(1,Math.abs(i),Math.abs(a))};var h=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(n(52));e.len=u,e.sub=r,e.mul=a,e.div=o,e.dist=s,e.sqrDist=l,e.sqrLen=c,e.forEach=function(){var t=i();return function(e,n,i,r,a,o){var s=void 0,l=void 0;for(n||(n=2),i||(i=0),l=r?Math.min(r*n+i,e.length):e.length,s=i;s0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t}function p(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}Object.defineProperty(e,"__esModule",{value:!0}),e.forEach=e.sqrLen=e.len=e.sqrDist=e.dist=e.div=e.mul=e.sub=void 0,e.create=i,e.clone=function(t){var e=new g.ARRAY_TYPE(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},e.length=r,e.fromValues=a,e.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},e.set=function(t,e,n,i){return t[0]=e,t[1]=n,t[2]=i,t},e.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t},e.subtract=o,e.multiply=s,e.divide=l,e.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t},e.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t},e.min=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t},e.max=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t},e.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t},e.scale=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t},e.scaleAndAdd=function(t,e,n,i){return t[0]=e[0]+n[0]*i,t[1]=e[1]+n[1]*i,t[2]=e[2]+n[2]*i,t},e.distance=u,e.squaredDistance=c,e.squaredLength=h,e.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},e.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t},e.normalize=f,e.dot=p,e.cross=function(t,e,n){var i=e[0],r=e[1],a=e[2],o=n[0],s=n[1],l=n[2];return t[0]=r*l-a*s,t[1]=a*o-i*l,t[2]=i*s-r*o,t},e.lerp=function(t,e,n,i){var r=e[0],a=e[1],o=e[2];return t[0]=r+i*(n[0]-r),t[1]=a+i*(n[1]-a),t[2]=o+i*(n[2]-o),t},e.hermite=function(t,e,n,i,r,a){var o=a*a,s=o*(2*a-3)+1,l=o*(a-2)+a,u=o*(a-1),c=o*(3-2*a);return t[0]=e[0]*s+n[0]*l+i[0]*u+r[0]*c,t[1]=e[1]*s+n[1]*l+i[1]*u+r[1]*c,t[2]=e[2]*s+n[2]*l+i[2]*u+r[2]*c,t},e.bezier=function(t,e,n,i,r,a){var o=1-a,s=o*o,l=a*a,u=s*o,c=3*a*s,h=3*l*o,f=l*a;return t[0]=e[0]*u+n[0]*c+i[0]*h+r[0]*f,t[1]=e[1]*u+n[1]*c+i[1]*h+r[1]*f,t[2]=e[2]*u+n[2]*c+i[2]*h+r[2]*f,t},e.random=function(t,e){e=e||1;var n=2*g.RANDOM()*Math.PI,i=2*g.RANDOM()-1,r=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(n)*r,t[1]=Math.sin(n)*r,t[2]=i*e,t},e.transformMat4=function(t,e,n){var i=e[0],r=e[1],a=e[2],o=n[3]*i+n[7]*r+n[11]*a+n[15];return o=o||1,t[0]=(n[0]*i+n[4]*r+n[8]*a+n[12])/o,t[1]=(n[1]*i+n[5]*r+n[9]*a+n[13])/o,t[2]=(n[2]*i+n[6]*r+n[10]*a+n[14])/o,t},e.transformMat3=function(t,e,n){var i=e[0],r=e[1],a=e[2];return t[0]=i*n[0]+r*n[3]+a*n[6],t[1]=i*n[1]+r*n[4]+a*n[7],t[2]=i*n[2]+r*n[5]+a*n[8],t},e.transformQuat=function(t,e,n){var i=n[0],r=n[1],a=n[2],o=n[3],s=e[0],l=e[1],u=e[2],c=r*u-a*l,h=a*s-i*u,f=i*l-r*s,p=r*f-a*h,g=a*c-i*f,d=i*h-r*c,v=2*o;return c*=v,h*=v,f*=v,p*=2,g*=2,d*=2,t[0]=s+c+p,t[1]=l+h+g,t[2]=u+f+d,t},e.rotateX=function(t,e,n,i){var r=[],a=[];return r[0]=e[0]-n[0],r[1]=e[1]-n[1],r[2]=e[2]-n[2],a[0]=r[0],a[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),a[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),t[0]=a[0]+n[0],t[1]=a[1]+n[1],t[2]=a[2]+n[2],t},e.rotateY=function(t,e,n,i){var r=[],a=[];return r[0]=e[0]-n[0],r[1]=e[1]-n[1],r[2]=e[2]-n[2],a[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),a[1]=r[1],a[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),t[0]=a[0]+n[0],t[1]=a[1]+n[1],t[2]=a[2]+n[2],t},e.rotateZ=function(t,e,n,i){var r=[],a=[];return r[0]=e[0]-n[0],r[1]=e[1]-n[1],r[2]=e[2]-n[2],a[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),a[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),a[2]=r[2],t[0]=a[0]+n[0],t[1]=a[1]+n[1],t[2]=a[2]+n[2],t},e.angle=function(t,e){var n=a(t[0],t[1],t[2]),i=a(e[0],e[1],e[2]);f(n,n),f(i,i);var r=p(n,i);return r>1?0:r<-1?Math.PI:Math.acos(r)},e.str=function(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"},e.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},e.equals=function(t,e){var n=t[0],i=t[1],r=t[2],a=e[0],o=e[1],s=e[2];return Math.abs(n-a)<=g.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(i-o)<=g.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-s)<=g.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))};var g=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(n(52));e.sub=o,e.mul=s,e.div=l,e.dist=u,e.sqrDist=c,e.len=r,e.sqrLen=h,e.forEach=function(){var t=i();return function(e,n,i,r,a,o){var s=void 0,l=void 0;for(n||(n=3),i||(i=0),l=r?Math.min(r*n+i,e.length):e.length,s=i;s2*Math.PI&&(t=t/180*Math.PI),this.transform([["t",-e,-n],["r",t],["t",e,n]])},move:function(t,e){var n=this.get("x")||0,i=this.get("y")||0;return this.translate(t-n,e-i),this.set("x",t),this.set("y",e),this},transform:function(t){var e=this,n=this._attrs.matrix;return o.each(t,function(t){switch(t[0]){case"t":e.translate(t[1],t[2]);break;case"s":e.scale(t[1],t[2]);break;case"r":e.rotate(t[1]);break;case"m":e.attr("matrix",o.mat3.multiply([],n,t[1])),e.clearTotalMatrix()}}),e},setTransform:function(t){return this.attr("matrix",[1,0,0,0,1,0,0,0,1]),this.transform(t)},getMatrix:function(){return this.attr("matrix")},setMatrix:function(t){return this.attr("matrix",t),this.clearTotalMatrix(),this},apply:function(t,e){var n;return n=e?this._getMatrixByRoot(e):this.attr("matrix"),o.vec3.transformMat3(t,t,n),this},_getMatrixByRoot:function(t){t=t||this;for(var e=this,n=[];e!==t;)n.unshift(e),e=e.get("parent");n.unshift(e);var i=[1,0,0,0,1,0,0,0,1];return o.each(n,function(t){o.mat3.multiply(i,t.attr("matrix"),i)}),i},getTotalMatrix:function(){var t=this._cfg.totalMatrix;if(!t){t=[1,0,0,0,1,0,0,0,1];var e=this._cfg.parent;if(e){a(t,e.getTotalMatrix())}a(t,this.attr("matrix")),this._cfg.totalMatrix=t}return t},clearTotalMatrix:function(){},invert:function(t){var e=this.getTotalMatrix();if(r(e))t[0]/=e[0],t[1]/=e[4];else{var n=o.mat3.invert([],e);n&&o.vec3.transformMat3(t,t,n)}return this},resetTransform:function(t){var e=this.attr("matrix");i(e)||t.transform(e[0],e[1],e[3],e[4],e[6],e[7])}}},function(t,e,n){var i=n(1),r={delay:"delay",rotate:"rotate"},a={fill:"fill",stroke:"stroke",fillStyle:"fillStyle",strokeStyle:"strokeStyle"};t.exports={animate:function(t,e,n,o,s){void 0===s&&(s=0);this.set("animating",!0);var l=this.get("timeline");l||(l=this.get("canvas").get("timeline"),this.setSilent("timeline",l));var u=this.get("animators")||[];l._timer||l.initTimer(),i.isNumber(o)&&(s=o,o=null),i.isFunction(n)?(o=n,n="easeLinear"):n=n||"easeLinear";var c=function(t,e){var n={matrix:null,attrs:{}},o=e._attrs;for(var s in t)if("transform"===s)n.matrix=i.transform(e.getMatrix(),t[s]);else if("rotate"===s)n.matrix=i.transform(e.getMatrix(),[["r",t[s]]]);else if("matrix"===s)n.matrix=t[s];else{if(a[s]&&/^[r,R,L,l]{1}[\s]*\(/.test(t[s]))continue;r[s]||o[s]===t[s]||(n.attrs[s]=t[s])}return n}(t,this),h={fromAttrs:function(t,e){var n={},i=e._attrs;for(var r in t.attrs)n[r]=i[r];return n}(c,this),toAttrs:c.attrs,fromMatrix:i.clone(this.getMatrix()),toMatrix:c.matrix,duration:e,easing:n,callback:o,delay:s,startTime:l.getTime(),id:i.uniqueId()};u.length>0?u=function(t,e){var n=e.delay,r=Object.prototype.hasOwnProperty;return i.each(e.toAttrs,function(e,a){i.each(t,function(t){n').getContext("2d"),l={arc:function(t,e){var n=this._attrs,i=n.x,r=n.y,o=n.r,s=n.startAngle,l=n.endAngle,u=n.clockwise,c=this.getHitLineWidth();return!!this.hasStroke()&&a.arcline(i,r,o,s,l,u,c,t,e)},circle:function(t,e){var n=this._attrs,i=n.x,r=n.y,o=n.r,s=this.getHitLineWidth(),l=this.hasFill(),u=this.hasStroke();return l&&u?a.circle(i,r,o,t,e)||a.arcline(i,r,o,0,2*Math.PI,!1,s,t,e):l?a.circle(i,r,o,t,e):!!u&&a.arcline(i,r,o,0,2*Math.PI,!1,s,t,e)},dom:function(t,e){if(!this._cfg.el)return!1;var n=this._cfg.el.getBBox();return a.box(n.x,n.x+n.width,n.y,n.y+n.height,t,e)},ellipse:function(t,e){var n=this._attrs,i=this.hasFill(),o=this.hasStroke(),s=n.x,l=n.y,u=n.rx,c=n.ry,h=this.getHitLineWidth(),f=u>c?u:c,p=u>c?1:u/c,g=u>c?c/u:1,d=[t,e,1],v=[1,0,0,0,1,0,0,0,1];r.mat3.scale(v,v,[p,g]),r.mat3.translate(v,v,[s,l]);var y=r.mat3.invert([],v);return r.vec3.transformMat3(d,d,y),i&&o?a.circle(0,0,f,d[0],d[1])||a.arcline(0,0,f,0,2*Math.PI,!1,h,d[0],d[1]):i?a.circle(0,0,f,d[0],d[1]):!!o&&a.arcline(0,0,f,0,2*Math.PI,!1,h,d[0],d[1])},fan:function(t,e){function n(){var t=o.arc.nearAngle(m,d,v,y);if(r.isNumberEqual(m,t)){var e=r.vec2.squaredLength(x);if(p*p<=e&&e<=g*g)return!0}return!1}function i(){var n=s.getHitLineWidth(),i={x:Math.cos(d)*p+h,y:Math.sin(d)*p+f},r={x:Math.cos(d)*g+h,y:Math.sin(d)*g+f},o={x:Math.cos(v)*p+h,y:Math.sin(v)*p+f},l={x:Math.cos(v)*g+h,y:Math.sin(v)*g+f};return!!(a.line(i.x,i.y,r.x,r.y,n,t,e)||a.line(o.x,o.y,l.x,l.y,n,t,e)||a.arcline(h,f,p,d,v,y,n,t,e)||a.arcline(h,f,g,d,v,y,n,t,e))}var s=this,l=s.hasFill(),u=s.hasStroke(),c=s._attrs,h=c.x,f=c.y,p=c.rs,g=c.re,d=c.startAngle,v=c.endAngle,y=c.clockwise,x=[t-h,e-f],m=r.vec2.angleTo([1,0],x);return l&&u?n()||i():l?n():!!u&&i()},image:function(t,e){var n=this._attrs;if(this.get("toDraw")||!n.img)return!1;this._cfg.attrs&&this._cfg.attrs.img===n.img||this._setAttrImg();var i=n.x,r=n.y,o=n.width,s=n.height;return a.rect(i,r,o,s,t,e)},line:function(t,e){var n=this._attrs,i=n.x1,r=n.y1,o=n.x2,s=n.y2,l=this.getHitLineWidth();return!!this.hasStroke()&&a.line(i,r,o,s,l,t,e)},path:function(t,e){function n(){if(!r.isEmpty(o)){for(var n=a.getHitLineWidth(),i=0,s=o.length;i=3&&o.push(n[0]),a.polyline(o,i,t,e)}var r=this,o=r.hasFill(),s=r.hasStroke();return o&&s?i(t,e,r)||n():o?i(t,e,r):!!s&&n()},polyline:function(t,e){var n=this._attrs;if(this.hasStroke()){var i=n.points;if(i.length<2)return!1;var r=n.lineWidth;return a.polyline(i,r,t,e)}return!1},rect:function(t,e){function n(){var n=r._attrs,i=n.x,o=n.y,s=n.width,l=n.height,u=n.radius,c=r.getHitLineWidth();if(0===u){var h=c/2;return a.line(i-h,o,i+s+h,o,c,t,e)||a.line(i+s,o-h,i+s,o+l+h,c,t,e)||a.line(i+s+h,o+l,i-h,o+l,c,t,e)||a.line(i,o+l+h,i,o-h,c,t,e)}return a.line(i+u,o,i+s-u,o,c,t,e)||a.line(i+s,o+u,i+s,o+l-u,c,t,e)||a.line(i+s-u,o+l,i+u,o+l,c,t,e)||a.line(i,o+l-u,i,o+u,c,t,e)||a.arcline(i+s-u,o+u,u,1.5*Math.PI,2*Math.PI,!1,c,t,e)||a.arcline(i+s-u,o+l-u,u,0,.5*Math.PI,!1,c,t,e)||a.arcline(i+u,o+l-u,u,.5*Math.PI,Math.PI,!1,c,t,e)||a.arcline(i+u,o+u,u,Math.PI,1.5*Math.PI,!1,c,t,e)}var r=this,o=r.hasFill(),s=r.hasStroke();return o&&s?i(t,e,r)||n():o?i(t,e,r):!!s&&n()},text:function(t,e){var n=this.getBBox();if(this.hasFill()||this.hasStroke())return a.box(n.minX,n.maxX,n.minY,n.maxY,t,e)}};t.exports={isPointInPath:function(t,e){var n=l[this.type];return!!n&&n.call(this,t,e)}}},function(t,e,n){function i(t,e,n){var i=e.startTime;if(ng.length?(p=a.parsePathString(o[f]),g=a.parsePathString(s[f]),g=a.fillPathByDiff(g,p),g=a.formatPath(g,p),e.fromAttrs.path=g,e.toAttrs.path=p):e.pathFormatted||(p=a.parsePathString(o[f]),g=a.parsePathString(s[f]),g=a.formatPath(g,p),e.fromAttrs.path=g,e.toAttrs.path=p,e.pathFormatted=!0),i[f]=[];for(var d=0;d0){for(var l=r._animators.length-1;l>=0;l--)if((t=r._animators[l]).get("destroyed"))a.removeAnimator(l);else{if(!t.get("pause").isPaused)for(var u=(e=t.get("animators")).length-1;u>=0;u--)n=e[u],(s=i(t,n,o))&&(e.splice(u,1),s=!1,n.callback&&n.callback());0===e.length&&a.removeAnimator(l)}r.canvas.draw()}})},addAnimator:function(t){this._animators.push(t)},removeAnimator:function(t){this._animators.splice(t,1)},isAnimating:function(){return!!this._animators.length},stop:function(){this._timer&&this._timer.stop()},stopAllAnimations:function(){this._animators.forEach(function(t){t.stopAnimate()}),this._animators=[],this.canvas.draw()},getTime:function(){return this._current}}),t.exports=h},function(t,e,n){"use strict";var i=n(58);e.a=function(t,e,n){var r=new i.a;return e=null==e?0:+e,r.restart(function(n){r.stop(),t(n+e)},e,n),r}},function(t,e,n){"use strict";var i=n(58);e.a=function(t,e,n){var r=new i.a,a=e;return null==e?(r.restart(t,e,n),r):(e=+e,n=null==n?Object(i.b)():+n,r.restart(function i(o){o+=a,r.restart(i,a+=e,n),t(o)},e,n),r)}},function(t,e,n){"use strict";e.a=function(t){return+t}},function(t,e,n){"use strict";e.a=function(t){return t*t},e.c=function(t){return t*(2-t)},e.b=function(t){return((t*=2)<=1?t*t:--t*(2-t)+1)/2}},function(t,e,n){"use strict";e.a=function(t){return t*t*t},e.c=function(t){return--t*t*t+1},e.b=function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}},function(t,e,n){"use strict";n.d(e,"a",function(){return i}),n.d(e,"c",function(){return r}),n.d(e,"b",function(){return a});var i=function t(e){function n(t){return Math.pow(t,e)}return e=+e,n.exponent=t,n}(3),r=function t(e){function n(t){return 1-Math.pow(1-t,e)}return e=+e,n.exponent=t,n}(3),a=function t(e){function n(t){return((t*=2)<=1?Math.pow(t,e):2-Math.pow(2-t,e))/2}return e=+e,n.exponent=t,n}(3)},function(t,e,n){"use strict";e.a=function(t){return 1-Math.cos(t*r)},e.c=function(t){return Math.sin(t*r)},e.b=function(t){return(1-Math.cos(i*t))/2};var i=Math.PI,r=i/2},function(t,e,n){"use strict";e.a=function(t){return Math.pow(2,10*t-10)},e.c=function(t){return 1-Math.pow(2,-10*t)},e.b=function(t){return((t*=2)<=1?Math.pow(2,10*t-10):2-Math.pow(2,10-10*t))/2}},function(t,e,n){"use strict";e.a=function(t){return 1-Math.sqrt(1-t*t)},e.c=function(t){return Math.sqrt(1- --t*t)},e.b=function(t){return((t*=2)<=1?1-Math.sqrt(1-t*t):Math.sqrt(1-(t-=2)*t)+1)/2}},function(t,e,n){"use strict";function i(t){return(t=+t)b?Math.pow(t,1/3):t/_+x}function s(t){return t>m?t*t*t:_*(t-x)}function l(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function u(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function c(t,e,n,r){return 1===arguments.length?function(t){if(t instanceof h)return new h(t.h,t.c,t.l,t.opacity);t instanceof a||(t=i(t));var e=Math.atan2(t.b,t.a)*g.b;return new h(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}(t):new h(t,e,n,null==r?1:r)}function h(t,e,n,i){this.h=+t,this.c=+e,this.l=+n,this.opacity=+i}e.a=r,e.b=c;var f=n(61),p=n(60),g=n(118),d=.95047,v=1,y=1.08883,x=4/29,m=6/29,_=3*m*m,b=m*m*m;Object(f.a)(a,r,Object(f.b)(p.a,{brighter:function(t){return new a(this.l+18*(null==t?1:t),this.a,this.b,this.opacity)},darker:function(t){return new a(this.l-18*(null==t?1:t),this.a,this.b,this.opacity)},rgb:function(){var t=(this.l+16)/116,e=isNaN(this.a)?t:t+this.a/500,n=isNaN(this.b)?t:t-this.b/200;return t=v*s(t),e=d*s(e),n=y*s(n),new p.b(l(3.2404542*e-1.5371385*t-.4985314*n),l(-.969266*e+1.8760108*t+.041556*n),l(.0556434*e-.2040259*t+1.0572252*n),this.opacity)}})),Object(f.a)(h,c,Object(f.b)(p.a,{brighter:function(t){return new h(this.h,this.c,this.l+18*(null==t?1:t),this.opacity)},darker:function(t){return new h(this.h,this.c,this.l-18*(null==t?1:t),this.opacity)},rgb:function(){return i(this).rgb()}}))},function(t,e,n){"use strict";function i(t,e,n,i){return 1===arguments.length?function(t){if(t instanceof r)return new r(t.h,t.s,t.l,t.opacity);t instanceof o.b||(t=Object(o.h)(t));var e=t.r/255,n=t.g/255,i=t.b/255,a=(d*i+p*e-g*n)/(d+p-g),l=i-a,u=(f*(n-a)-c*l)/h,v=Math.sqrt(u*u+l*l)/(f*a*(1-a)),y=v?Math.atan2(u,l)*s.b-120:NaN;return new r(y<0?y+360:y,v,a,t.opacity)}(t):new r(t,e,n,null==i?1:i)}function r(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}e.a=i;var a=n(61),o=n(60),s=n(118),l=-.14861,u=1.78277,c=-.29227,h=-.90649,f=1.97294,p=f*h,g=f*u,d=u*c-h*l;Object(a.a)(r,i,Object(a.b)(o.a,{brighter:function(t){return t=null==t?o.c:Math.pow(o.c,t),new r(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?o.d:Math.pow(o.d,t),new r(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*s.a,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),i=Math.cos(t),r=Math.sin(t);return new o.b(255*(e+n*(l*i+u*r)),255*(e+n*(c*i+h*r)),255*(e+n*(f*i)),this.opacity)}}))},function(t,e,n){"use strict";e.a=function(t,e){return t=+t,e-=t,function(n){return Math.round(t+e*n)}}},function(t,e,n){"use strict";function i(t,e,n,i){function a(t){return t.length?t.pop()+" ":""}return function(o,s){var l=[],u=[];return o=t(o),s=t(s),function(t,i,a,o,s,l){if(t!==a||i!==o){var u=s.push("translate(",null,e,null,n);l.push({i:u-4,x:Object(r.a)(t,a)},{i:u-2,x:Object(r.a)(i,o)})}else(a||o)&&s.push("translate("+a+e+o+n)}(o.translateX,o.translateY,s.translateX,s.translateY,l,u),function(t,e,n,o){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(a(n)+"rotate(",null,i)-2,x:Object(r.a)(t,e)})):e&&n.push(a(n)+"rotate("+e+i)}(o.rotate,s.rotate,l,u),function(t,e,n,o){t!==e?o.push({i:n.push(a(n)+"skewX(",null,i)-2,x:Object(r.a)(t,e)}):e&&n.push(a(n)+"skewX("+e+i)}(o.skewX,s.skewX,l,u),function(t,e,n,i,o,s){if(t!==n||e!==i){var l=o.push(a(o)+"scale(",null,",",null,")");s.push({i:l-4,x:Object(r.a)(t,n)},{i:l-2,x:Object(r.a)(e,i)})}else 1===n&&1===i||o.push(a(o)+"scale("+n+","+i+")")}(o.scaleX,o.scaleY,s.scaleX,s.scaleY,l,u),o=s=null,function(t){for(var e,n=-1,i=u.length;++n');return t.appendChild(n),this.type="canvas",this.canvas=n,this.context=n.getContext("2d"),this.toDraw=!1,this}var e=t.prototype;return e.beforeDraw=function(){var t=this.canvas;this.context&&this.context.clearRect(0,0,t.width,t.height)},e.draw=function(t){function e(){n.animateHandler=i.requestAnimationFrame(function(){n.animateHandler=void 0,n.toDraw&&e()}),n.beforeDraw();try{n._drawGroup(t)}catch(t){console.warn("error in draw canvas, detail as:"),console.warn(t),n.toDraw=!1}n.toDraw=!1}var n=this;n.animateHandler?n.toDraw=!0:e()},e.drawSync=function(t){this.beforeDraw(),this._drawGroup(t)},e._drawGroup=function(t){if(!t._cfg.removed&&!t._cfg.destroyed&&t._cfg.visible){var e=t._cfg.children,n=null;this.setContext(t);for(var i=0;i-1){var s=n[o];"fillStyle"===o&&(s=r.parseStyle(s,t,e)),"strokeStyle"===o&&(s=r.parseStyle(s,t,e)),"lineDash"===o&&e.setLineDash?i.isArray(s)?e.setLineDash(s):i.isString(s)&&e.setLineDash(s.split(" ")):e[o]=s}},t}();t.exports=o},function(t,e,n){function i(t,e){var n=t.match(c);r.each(n,function(t){t=t.split(":"),e.addColorStop(t[0],t[1])})}var r=n(1),a=/[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/gi,o=/[^\s\,]+/gi,s=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i,l=/^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i,u=/^p\s*\(\s*([axyn])\s*\)\s*(.*)/i,c=/[\d.]+:(#[^\s]+|[^\)]+\))/gi;t.exports={parsePath:function(t){return t=t||[],r.isArray(t)?t:r.isString(t)?(t=t.match(a),r.each(t,function(e,n){if((e=e.match(o))[0].length>1){var i=e[0].charAt(0);e.splice(1,0,e[0].substr(1)),e[0]=i}r.each(e,function(t,n){isNaN(t)||(e[n]=+t)}),t[n]=e}),t):void 0},parseStyle:function(t,e,n){if(r.isString(t)){if("("===t[1]||"("===t[2]){if("l"===t[0])return function(t,e,n){var a,o,l=s.exec(t),u=r.mod(r.toRadian(parseFloat(l[1])),2*Math.PI),c=l[2],h=e.getBBox();u>=0&&u<.5*Math.PI?(a={x:h.minX,y:h.minY},o={x:h.maxX,y:h.maxY}):.5*Math.PI<=u&&u');return t.appendChild(n),this.type="svg",this.canvas=n,this.context=new o(n),this.toDraw=!1,this}var e=t.prototype;return e.draw=function(t){function e(){n.animateHandler=i.requestAnimationFrame(function(){n.animateHandler=void 0,n.toDraw&&e()});try{n._drawChildren(t)}catch(t){console.warn("error in draw canvas, detail as:"),console.warn(t),n.toDraw=!1}n.toDraw=!1}var n=this;n.animateHandler?n.toDraw=!0:e()},e.drawSync=function(t){this._drawChildren(t)},e._drawGroup=function(t,e){var n=t._cfg;n.removed||n.destroyed||(n.tobeRemoved&&(i.each(n.tobeRemoved,function(t){t.parentNode&&t.parentNode.removeChild(t)}),n.tobeRemoved=[]),this._drawShape(t,e),n.children&&n.children.length>0&&this._drawChildren(t))},e._drawChildren=function(t){var e,n=t._cfg.children;if(n)for(var i=0;is?1:0,f=Math.abs(l-s)>Math.PI?1:0,p=n.rs,g=n.re,d=e(s,n.rs,a),v=e(l,n.rs,a);n.rs>0?(o.push("M "+c.x+","+c.y),o.push("L "+v.x+","+v.y),o.push("A "+p+","+p+",0,"+f+","+(1===h?0:1)+","+d.x+","+d.y),o.push("L "+u.x+" "+u.y)):(o.push("M "+a.x+","+a.y),o.push("L "+u.x+","+u.y)),o.push("A "+g+","+g+",0,"+f+","+h+","+c.x+","+c.y),n.rs>0?o.push("L "+v.x+","+v.y):o.push("Z"),r.el.setAttribute("d",o.join(" "))},e._updateText=function(t){var e=t._attrs,n=t._cfg.attrs,i=t._cfg.el;this._setFont(t);for(var r in e)if(e[r]!==n[r]){if("text"===r){this._setText(t,""+e[r]);continue}if("fillStyle"===r||"strokeStyle"===r){this._setColor(t,r,e[r]);continue}if("matrix"===r){this._setTransform(t);continue}l[r]&&i.setAttribute(l[r],e[r])}t._cfg.attrs=Object.assign({},t._attrs),t._cfg.hasUpdate=!1},e._setFont=function(t){var e=t.get("el"),n=t._attrs,i=n.fontSize;e.setAttribute("alignment-baseline",u[n.textBaseline]||"baseline"),e.setAttribute("text-anchor",c[n.textAlign]||"left"),i&&+i<12&&(n.matrix=[1,0,0,0,1,0,0,0,1],t.transform([["t",-n.x,-n.y],["s",+i/12,+i/12],["t",n.x,n.y]]))},e._setText=function(t,e){var n=t._cfg.el,r=t._attrs.textBaseline||"bottom";if(e)if(~e.indexOf("\n")){var a=t._attrs.x,o=e.split("\n"),s=o.length-1,l="";i.each(o,function(t,e){0===e?"alphabetic"===r?l+=''+t+"":"top"===r?l+=''+t+"":"middle"===r?l+=''+t+"":"bottom"===r?l+=''+t+"":"hanging"===r&&(l+=''+t+""):l+=''+t+""}),n.innerHTML=l}else n.innerHTML=e;else n.innerHTML=""},e._setClip=function(t,e){var n=t._cfg.el;if(e)if(n.hasAttribute("clip-path"))e._cfg.hasUpdate&&this._updateShape(e);else{this._createDom(e),this._updateShape(e);var i=this.context.addClip(e);n.setAttribute("clip-path","url(#"+i+")")}else n.removeAttribute("clip-path")},e._setColor=function(t,e,n){var i=t._cfg.el,r=this.context;if(n)if(n=n.trim(),/^[r,R,L,l]{1}[\s]*\(/.test(n)){var a=r.find("gradient",n);a||(a=r.addGradient(n)),i.setAttribute(l[e],"url(#"+a+")")}else if(/^[p,P]{1}[\s]*\(/.test(n)){var o=r.find("pattern",n);o||(o=r.addPattern(n)),i.setAttribute(l[e],"url(#"+o+")")}else i.setAttribute(l[e],n);else i.setAttribute(l[e],"none")},e._setShadow=function(t){var e=t._cfg.el,n=t._attrs,i={dx:n.shadowOffsetX,dy:n.shadowOffsetY,blur:n.shadowBlur,color:n.shadowColor};if(i.dx||i.dy||i.blur||i.color){var r=this.context.find("filter",i);r||(r=this.context.addShadow(i,this)),e.setAttribute("filter","url(#"+r+")")}else e.removeAttribute("filter")},t}();t.exports=h},function(t,e,n){var i=n(1),r=n(222),a=n(223),o=n(224),s=n(225),l=n(226),u=function(){function t(t){var e=document.createElementNS("http://www.w3.org/2000/svg","defs"),n=i.uniqueId("defs_");e.id=n,t.appendChild(e),this.children=[],this.defaultArrow={},this.el=e,this.canvas=t}var e=t.prototype;return e.find=function(t,e){for(var n=this.children,i=null,r=0;r'}),n}var r=n(1),a=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i,o=/^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i,s=/[\d.]+:(#[^\s]+|[^\)]+\))/gi,l=function(){function t(t){var e=null,n=r.uniqueId("gradient_");return"l"===t.toLowerCase()[0]?function(t,e){var n,o,s=a.exec(t),l=r.mod(r.toRadian(parseFloat(s[1])),2*Math.PI),u=s[2];l>=0&&l<.5*Math.PI?(n={x:0,y:0},o={x:1,y:1}):.5*Math.PI<=l&&l';e.innerHTML=n},t}();t.exports=o},function(t,e,n){var i=n(1),r=function(){function t(t,e){var n=document.createElementNS("http://www.w3.org/2000/svg","marker"),r=i.uniqueId("marker_");n.setAttribute("id",r);var a=document.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("stroke","none"),a.setAttribute("fill",t.stroke||"#000"),n.appendChild(a),n.setAttribute("overflow","visible"),n.setAttribute("orient","auto-start-reverse"),this.el=n,this.child=a,this.id=r,this.cfg=t["marker-start"===e?"startArrow":"endArrow"],this.stroke=t.stroke||"#000",!0===this.cfg?this._setDefaultPath(e,a):this._setMarker(t.lineWidth,a),this}var e=t.prototype;return e.match=function(){return!1},e._setDefaultPath=function(t,e){var n=this.el;e.setAttribute("d","M0,0 L6,3 L0,6 L3,3Z"),n.setAttribute("refX",3),n.setAttribute("refY",3)},e._setMarker=function(t,e){var n=this.el,r=this.cfg.path,a=this.cfg.d;i.isArray(r)&&(r=r.map(function(t){return t.join(" ")}).join("")),e.setAttribute("d",r),n.appendChild(e),a&&n.setAttribute("refX",a/t)},e.update=function(t){var e=this.child;e.attr?e.attr("fill",t):e.setAttribute("fill",t)},t}();t.exports=r},function(t,e,n){var i=n(1),r=function(){function t(t){this.type="clip";var e=document.createElementNS("http://www.w3.org/2000/svg","clipPath");this.el=e,this.id=i.uniqueId("clip_"),e.id=this.id;var n=t._cfg.el;return e.appendChild(n.cloneNode(!0)),this.cfg=t,this}var e=t.prototype;return e.match=function(){return!1},e.remove=function(){var t=this.el;t.parentNode.removeChild(t)},t}();t.exports=r},function(t,e,n){var i=n(1),r=/^p\s*\(\s*([axyn])\s*\)\s*(.*)/i,a=function(){function t(t){function e(){console.log(l.width,l.height),n.setAttribute("width",l.width),n.setAttribute("height",l.height)}var n=document.createElementNS("http://www.w3.org/2000/svg","pattern");n.setAttribute("patternUnits","userSpaceOnUse");var a=document.createElementNS("http://www.w3.org/2000/svg","image");n.appendChild(a);var o=i.uniqueId("pattern_");n.id=o,this.el=n,this.id=o,this.cfg=t;var s=r.exec(t)[2];a.setAttribute("href",s);var l=new Image;return s.match(/^data:/i)||(l.crossOrigin="Anonymous"),l.src=s,l.complete?e():(l.onload=e,l.src=l.src),this}return t.prototype.match=function(t,e){return this.cfg===e},t}();t.exports=a},function(t,e){var n={svg:"svg",circle:"circle",rect:"rect",text:"text",path:"path",foreignObject:"foreignObject",polygon:"polygon",ellipse:"ellipse",image:"image"};t.exports=function(t,e,i){var r=i.target||i.srcElement;if(!n[r.tagName]){for(var a=r.parentNode;a&&!n[a.tagName];)a=a.parentNode;r=a}return this._cfg.el===r?this:this.find(function(t){return t._cfg&&t._cfg.el===r})}},function(t,e,n){t.exports={addEventListener:n(229),createDom:n(94),getBoundingClientRect:n(230),getHeight:n(231),getOuterHeight:n(232),getOuterWidth:n(233),getRatio:n(234),getStyle:n(235),getWidth:n(236),modifyCSS:n(95),requestAnimationFrame:n(96)}},function(t,e){t.exports=function(t,e,n){if(t){if(t.addEventListener)return t.addEventListener(e,n,!1),{remove:function(){t.removeEventListener(e,n,!1)}};if(t.attachEvent)return t.attachEvent("on"+e,n),{remove:function(){t.detachEvent("on"+e,n)}}}}},function(t,e){t.exports=function(t,e){if(t&&t.getBoundingClientRect){var n=t.getBoundingClientRect(),i=document.documentElement.clientTop,r=document.documentElement.clientLeft;return{top:n.top-i,bottom:n.bottom-i,left:n.left-r,right:n.right-r}}return e||null}},function(t,e){t.exports=function(t,e){var n=this.getStyle(t,"height",e);return"auto"===n&&(n=t.offsetHeight),parseFloat(n)}},function(t,e){t.exports=function(t,e){var n=this.getHeight(t,e),i=parseFloat(this.getStyle(t,"borderTopWidth"))||0,r=parseFloat(this.getStyle(t,"paddingTop"))||0,a=parseFloat(this.getStyle(t,"paddingBottom"))||0;return n+i+(parseFloat(this.getStyle(t,"borderBottomWidth"))||0)+r+a}},function(t,e){t.exports=function(t,e){var n=this.getWidth(t,e),i=parseFloat(this.getStyle(t,"borderLeftWidth"))||0,r=parseFloat(this.getStyle(t,"paddingLeft"))||0,a=parseFloat(this.getStyle(t,"paddingRight"))||0;return n+i+(parseFloat(this.getStyle(t,"borderRightWidth"))||0)+r+a}},function(t,e){t.exports=function(){return window.devicePixelRatio?window.devicePixelRatio:2}},function(t,e,n){var i=n(5);t.exports=function(t,e,n){try{return window.getComputedStyle?window.getComputedStyle(t,null)[e]:t.currentStyle[e]}catch(t){return i(n)?null:n}}},function(t,e){t.exports=function(t,e){var n=this.getStyle(t,"width",e);return"auto"===n&&(n=t.offsetWidth),parseFloat(n)}},function(t,e,n){t.exports={contains:n(41),difference:n(238),find:n(239),firstValue:n(240),flatten:n(241),flattenDeep:n(242),getRange:n(243),merge:n(42),pull:n(90),pullAt:n(130),reduce:n(244),remove:n(245),sortBy:n(246),union:n(247),uniq:n(131),valuesOfKey:n(64)}},function(t,e,n){var i=n(63),r=n(41);t.exports=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return i(t,function(t){return!r(e,t)})}},function(t,e,n){var i=n(11),r=n(26),a=n(128);t.exports=function(t,e){var n=void 0;if(i(e)&&(n=e),r(e)&&(n=function(t){return a(t,e)}),n)for(var o=0;o1&&void 0!==arguments[1]?arguments[1]:[];if(i(e))for(var r=0;re[i])return 1;if(t[i]1){var i=e[0].charAt(0);e.splice(1,0,e[0].substr(1)),e[0]=i}a(e,function(t,n){isNaN(t)||(e[n]=+t)}),t[n]=e}),t):void 0}},function(t,e,n){var i=n(4);t.exports=function(t){var e=0,n=0,r=0,a=0;return i(t)?1===t.length?e=n=r=a=t[0]:2===t.length?(e=r=t[0],n=a=t[1]):3===t.length?(e=t[0],n=a=t[1],r=t[2]):(e=t[0],n=t[1],r=t[2],a=t[3]):e=n=r=a=t,{r1:e,r2:n,r3:r,r4:a}}},function(t,e,n){var i=n(35);t.exports={clamp:n(50),fixedBase:n(256),isDecimal:n(257),isEven:n(258),isInteger:n(259),isNegative:n(260),isNumberEqual:i,isOdd:n(261),isPositive:n(262),maxBy:n(132),minBy:n(263),mod:n(93),snapEqual:i,toDegree:n(92),toInt:n(133),toInteger:n(133),toRadian:n(91)}},function(t,e){t.exports=function(t,e){var n=e.toString(),i=n.indexOf(".");if(-1===i)return Math.round(t);var r=n.substr(i+1).length;return r>20&&(r=20),parseFloat(t.toFixed(r))}},function(t,e,n){var i=n(9);t.exports=function(t){return i(t)&&t%1!=0}},function(t,e,n){var i=n(9);t.exports=function(t){return i(t)&&t%2==0}},function(t,e,n){var i=n(9),r=Number.isInteger?Number.isInteger:function(t){return i(t)&&t%1==0};t.exports=r},function(t,e,n){var i=n(9);t.exports=function(t){return i(t)&&t<0}},function(t,e,n){var i=n(9);t.exports=function(t){return i(t)&&t%2!=0}},function(t,e,n){var i=n(9);t.exports=function(t){return i(t)&&t>0}},function(t,e,n){var i=n(4),r=n(11),a=n(2);t.exports=function(t,e){if(i(t)){var n=t[0],o=void 0;o=r(e)?e(t[0]):t[0][e];var s=void 0;return a(t,function(t){(s=r(e)?e(t):t[e])1?1:u<0?0:u)/2,h=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],f=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],p=0,g=0;g<12;g++){var d=c*h[g]+c,v=o(d,t,n,r,s),y=o(d,e,i,a,l),x=v*v+y*y;p+=f[g]*Math.sqrt(x)}return c*p},l=function(t,e,n,i,r,a,o,s){if(!(Math.max(t,n)Math.max(r,o)||Math.max(e,i)Math.max(a,s))){var l=(t-n)*(a-s)-(e-i)*(r-o);if(l){var u=((t*i-e*n)*(r-o)-(t-n)*(r*s-a*o))/l,c=((t*i-e*n)*(a-s)-(e-i)*(r*s-a*o))/l,h=+u.toFixed(2),f=+c.toFixed(2);if(!(h<+Math.min(t,n).toFixed(2)||h>+Math.max(t,n).toFixed(2)||h<+Math.min(r,o).toFixed(2)||h>+Math.max(r,o).toFixed(2)||f<+Math.min(e,i).toFixed(2)||f>+Math.max(e,i).toFixed(2)||f<+Math.min(a,s).toFixed(2)||f>+Math.max(a,s).toFixed(2)))return{x:u,y:c}}}},u=function(t,e,n){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height},c=function(t,e,n,i){return null===t&&(t=e=n=i=0),null===e&&(e=t.y,n=t.width,i=t.height,t=t.x),{x:t,y:e,width:n,w:n,height:i,h:i,x2:t+n,y2:e+i,cx:t+n/2,cy:e+i/2,r1:Math.min(n,i)/2,r2:Math.max(n,i)/2,r0:Math.sqrt(n*n+i*i)/2,path:r(t,e,n,i),vb:[t,e,n,i].join(" ")}},h=function(t,e,n,r,a,o,s,l){i(t)||(t=[t,e,n,r,a,o,s,l]);var u=function(t,e,n,i,r,a,o,s){for(var l=[],u=[[],[]],c=void 0,h=void 0,f=void 0,p=void 0,g=0;g<2;++g)if(0===g?(h=6*t-12*n+6*r,c=-3*t+9*n-9*r+3*o,f=3*n-3*t):(h=6*e-12*i+6*a,c=-3*e+9*i-9*a+3*s,f=3*i-3*e),Math.abs(c)<1e-12){if(Math.abs(h)<1e-12)continue;(p=-f/h)>0&&p<1&&l.push(p)}else{var d=h*h-4*f*c,v=Math.sqrt(d);if(!(d<0)){var y=(-h+v)/(2*c);y>0&&y<1&&l.push(y);var x=(-h-v)/(2*c);x>0&&x<1&&l.push(x)}}for(var m=l.length,_=m,b=void 0;m--;)b=1-(p=l[m]),u[0][m]=b*b*b*t+3*b*b*p*n+3*b*p*p*r+p*p*p*o,u[1][m]=b*b*b*e+3*b*b*p*i+3*b*p*p*a+p*p*p*s;return u[0][_]=t,u[1][_]=e,u[0][_+1]=o,u[1][_+1]=s,u[0].length=u[1].length=_+2,{min:{x:Math.min.apply(0,u[0]),y:Math.min.apply(0,u[1])},max:{x:Math.max.apply(0,u[0]),y:Math.max.apply(0,u[1])}}}.apply(null,t);return c(u.min.x,u.min.y,u.max.x-u.min.x,u.max.y-u.min.y)},f=function(t,e,n,i,r,a,o,s,l){var u=1-l,c=Math.pow(u,3),h=Math.pow(u,2),f=l*l,p=f*l,g=t+2*l*(n-t)+f*(r-2*n+t),d=e+2*l*(i-e)+f*(a-2*i+e),v=n+2*l*(r-n)+f*(o-2*r+n),y=i+2*l*(a-i)+f*(s-2*a+i);return{x:c*t+3*h*l*n+3*u*l*l*r+p*o,y:c*e+3*h*l*i+3*u*l*l*a+p*s,m:{x:g,y:d},n:{x:v,y:y},start:{x:u*t+l*n,y:u*e+l*i},end:{x:u*r+l*o,y:u*a+l*s},alpha:90-180*Math.atan2(g-v,d-y)/Math.PI}},p=function(t,e,n){if(!function(t,e){return t=c(t),e=c(e),u(e,t.x,t.y)||u(e,t.x2,t.y)||u(e,t.x,t.y2)||u(e,t.x2,t.y2)||u(t,e.x,e.y)||u(t,e.x2,e.y)||u(t,e.x,e.y2)||u(t,e.x2,e.y2)||(t.xe.x||e.xt.x)&&(t.ye.y||e.yt.y)}(h(t),h(e)))return n?0:[];for(var i=~~(s.apply(0,t)/8),r=~~(s.apply(0,e)/8),a=[],o=[],p={},g=n?0:[],d=0;d=0&&P<=1&&T>=0&&T<=1&&(n?g++:g.push({x:k.x,y:k.y,t1:P,t2:T}))}}return g};t.exports=function(t,e){return function(t,e,n){t=a(t),e=a(e);for(var i=void 0,r=void 0,o=void 0,s=void 0,l=void 0,u=void 0,c=void 0,h=void 0,f=void 0,g=void 0,d=n?0:[],v=0,y=t.length;v=3&&(3===t.length&&e.push("Q"),e=e.concat(t[1])),2===t.length&&e.push("L"),e=e.concat(t[t.length-1])})}(t,e,i));else{var a=[].concat(t);"M"===a[0]&&(a[0]="L");for(var o=0;o<=i-1;o++)r.push(a)}return r}t.exports=function(t,e){if(1===t.length)return t;var n=t.length-1,r=e.length-1,a=n/r,o=[];if(1===t.length&&"M"===t[0][0]){for(var s=0;s=0;p--)l=s[p].index,"add"===s[p].type?t.splice(l,0,[].concat(t[l])):t.splice(l,1)}if((a=t.length)0)){t[a]=e[a];break}r=i(r,t[a-1],1)}t[a]=["Q"].concat(r.reduce(function(t,e){return t.concat(e)},[]));break;case"T":t[a]=["T"].concat(r[0]);break;case"C":if(r.length<3){if(!(a>0)){t[a]=e[a];break}r=i(r,t[a-1],2)}t[a]=["C"].concat(r.reduce(function(t,e){return t.concat(e)},[]));break;case"S":if(r.length<2){if(!(a>0)){t[a]=e[a];break}r=i(r,t[a-1],1)}t[a]=["S"].concat(r.reduce(function(t,e){return t.concat(e)},[]));break;default:t[a]=e[a]}return t}},function(t,e,n){var i={lc:n(275),lowerCase:n(142),lowerFirst:n(75),substitute:n(276),uc:n(277),upperCase:n(143),upperFirst:n(87)};t.exports=i},function(t,e,n){t.exports=n(142)},function(t,e){t.exports=function(t,e){return t&&e?t.replace(/\\?\{([^{}]+)\}/g,function(t,n){return"\\"===t.charAt(0)?t.slice(1):void 0===e[n]?"":e[n]}):t}},function(t,e,n){t.exports=n(143)},function(t,e,n){var i=n(12),r={getType:n(84),isArray:n(4),isArrayLike:n(13),isBoolean:n(82),isFunction:n(11),isNil:n(5),isNull:n(279),isNumber:n(9),isObject:n(24),isObjectLike:n(48),isPlainObject:n(26),isPrototype:n(85),isType:i,isUndefined:n(280),isString:n(10),isRegExp:n(281),isDate:n(80),isArguments:n(282),isError:n(283)};t.exports=r},function(t,e){t.exports=function(t){return null===t}},function(t,e){t.exports=function(t){return void 0===t}},function(t,e,n){var i=n(12);t.exports=function(t){return i(t,"RegExp")}},function(t,e,n){var i=n(12);t.exports=function(t){return i(t,"Arguments")}},function(t,e,n){var i=n(12);t.exports=function(t){return i(t,"Error")}},function(t,e){t.exports=function(t,e,n){var i=void 0;return function(){var r=this,a=arguments,o=n&&!i;clearTimeout(i),i=setTimeout(function(){i=null,n||t.apply(r,a)},e),o&&t.apply(r,a)}}},function(t,e,n){var i=n(13);t.exports=function(t,e){if(!i(t))return-1;var n=Array.prototype.indexOf;if(n)return n.call(t,e);for(var r=-1,a=0;ae?(i&&(clearTimeout(i),i=null),s=u,o=t.apply(r,a),i||(r=a=null)):i||!1===n.trailing||(i=setTimeout(l,c)),o};return u.cancel=function(){clearTimeout(i),s=0,i=r=a=null},u}},function(t,e,n){function i(t,e){var n,i,r=function(t){if(f.isEmpty(t))return null;var e=t[0].x,n=t[0].x,i=t[0].y,r=t[0].y;return f.each(t,function(t){e=e>t.x?t.x:e,n=nt.y?t.y:i,r=r0?o.maxX:o.minX,l,1];t.apply(u),t.attr({transform:[["t",-n,-l],["s",.01,1],["t",n,l]]});var c={transform:[["t",-n,-l],["s",100,1],["t",n,l]]},h=r(e,a,i);t.animate(c,h.duration,h.easing,h.callback,h.delay)}function s(t,e,n){var i,a,o=t._id,s=t.get("index");if(n.isPolar&&"point"!==t.name)i=n.getCenter().x,a=n.getCenter().y;else{var l=t.getBBox();i=(l.minX+l.maxX)/2,a=(l.minY+l.maxY)/2}var u=[i,a,1];t.apply(u),t.attr({transform:[["t",-i,-a],["s",.01,.01],["t",i,a]]});var c={transform:[["t",-i,-a],["s",100,100],["t",i,a]]},h=r(e,s,o);t.animate(c,h.duration,h.easing,h.callback,h.delay)}function l(t,e){if("path"===t.get("type")){var n=t._id,i=t.get("index"),a=g.pathToAbsolute(t.attr("path"));t.attr("path",[a[0]]);var o={path:a},s=r(e,i,n);t.animate(o,s.duration,s.easing,s.callback,s.delay)}}function u(t,e,n,i,a){var o,s=function(t){var e,n,i,r,a,o=t.start,s=t.end,l=t.getWidth(),u=t.getHeight();return t.isPolar?(r=t.getRadius(),i=t.getCenter(),e=t.startAngle,n=t.endAngle,(a=new p.Fan({attrs:{x:i.x,y:i.y,rs:0,re:r+200,startAngle:e,endAngle:e}})).endState={endAngle:n}):(a=new p.Rect({attrs:{x:o.x-200,y:s.y-200,width:t.isTransposed?l+400:0,height:t.isTransposed?0:u+400}}),t.isTransposed?a.endState={height:u+400}:a.endState={width:l+400}),a.isClip=!0,a}(n),l=t.get("canvas"),u=t._id,c=t.get("index");i?(s.attr("startAngle",i),s.attr("endAngle",i),o={endAngle:a}):o=s.endState,s.set("canvas",l),t.attr("clip",s),t.setSilent("animating",!0);var h=r(e,c,u);s.animate(o,h.duration,h.easing,function(){t&&!t.get("destroyed")&&(t.attr("clip",null),t.setSilent("cacheShape",null),t.setSilent("animating",!1),s.remove())},h.delay)}function c(t,e){var n=t._id,i=t.get("index"),a=f.isNil(t.attr("fillOpacity"))?1:t.attr("fillOpacity"),o=f.isNil(t.attr("strokeOpacity"))?1:t.attr("strokeOpacity");t.attr("fillOpacity",0),t.attr("strokeOpacity",0);var s={fillOpacity:a,strokeOpacity:o},l=r(e,i,n);t.animate(s,l.duration,l.easing,l.callback,l.delay)}function h(t,e,n){var r=i(t,n),a=r.endAngle;u(t,e,n,r.startAngle,a)}var f=n(0),p=n(16),g=f.PathUtil;t.exports={enter:{clipIn:u,zoomIn:s,pathIn:l,scaleInY:a,scaleInX:o,fanIn:h,fadeIn:c},leave:{lineWidthOut:function(t,e){var n={lineWidth:0,opacity:0},i=t._id,a=r(e,t.get("index"),i);t.animate(n,a.duration,a.easing,function(){t.remove()},a.delay)},zoomOut:function(t,e,n){var i,a,o=t._id,s=t.get("index");if(n.isPolar&&"point"!==t.name)i=n.getCenter().x,a=n.getCenter().y;else{var l=t.getBBox();i=(l.minX+l.maxX)/2,a=(l.minY+l.maxY)/2}var u=[i,a,1];t.apply(u);var c={transform:[["t",-i,-a],["s",.01,.01],["t",i,a]]},h=r(e,s,o);t.animate(c,h.duration,h.easing,function(){t.remove()},h.delay)},pathOut:function(t,e){if("path"===t.get("type")){var n=t._id,i=t.get("index"),a={path:[g.pathToAbsolute(t.attr("path"))[0]]},o=r(e,i,n);t.animate(a,o.duration,o.easing,function(){t.remove()},o.delay)}},fadeOut:function(t,e){var n=t._id,i={fillOpacity:0,strokeOpacity:0},a=r(e,t.get("index"),n);t.animate(i,a.duration,a.easing,function(){t.remove()},a.delay)}},appear:{clipIn:u,zoomIn:s,pathIn:l,scaleInY:a,scaleInX:o,fanIn:h,fadeIn:c},update:{fadeIn:c,fanIn:h}}},function(t,e,n){function i(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function r(t,e,n){var i=(t-e)/(n-e);return i>=0&&i<=1}function a(t,e){var n=!1;if(t){if("theta"===t.type){var i=t.start,a=t.end;n=r(e.x,i.x,a.x)&&r(e.y,i.y,a.y)}else{var o=t.invert(e);n=o.x>=0&&o.y>=0&&o.x<=1&&o.y<=1}}return n}var o=n(148),s=n(20),l=n(0),u=n(165),c=n(7),h=n(151),f=n(355),p={};l.each(s,function(t,e){var n=l.lowerFirst(e);p[n]=function(e){var n=new t(e);return this.addGeom(n),n}});var g=function(t){function e(e){var n,r=i(i(n=t.call(this,e)||this));return r._setTheme(),l.each(s,function(t,e){var n=l.lowerFirst(e);r[n]=function(e){void 0===e&&(e={}),e.viewTheme=r.get("viewTheme");var n=new t(e);return r.addGeom(n),n}}),r.init(),n}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){return{viewContainer:null,coord:null,start:{x:0,y:0},end:{x:1,y:1},geoms:[],scales:{},options:{},scaleController:null,padding:0,theme:null,parent:null,tooltipEnable:!0,animate:c.animate,visible:!0}},n._setTheme=function(){var t=this.get("theme"),e={},n={};l.isObject(t)?n=t:-1!==l.indexOf(Object.keys(h),t)&&(n=h[t]),l.deepMix(e,c,n),this.set("viewTheme",e)},n.init=function(){this._initViewPlot(),this.get("data")&&this._initData(this.get("data")),this._initOptions(),this._initControllers(),this._bindEvents()},n._initOptions=function(){var t=this,e=l.mix({},t.get("options"));e.scales||(e.scales={}),e.coord||(e.coord={}),!1===e.animate&&this.set("animate",!1),(!1===e.tooltip||l.isNull(e.tooltip))&&this.set("tooltipEnable",!1),e.geoms&&e.geoms.length&&l.each(e.geoms,function(e){t._createGeom(e)});var n=t.get("scaleController");n&&(n.defs=e.scales);var i=t.get("coordController");i&&i.reset(e.coord),this.set("options",e)},n._createGeom=function(t){var e,n=t.type;this[n]&&(e=this[n](),l.each(t,function(t,n){if(e[n])if(l.isObject(t)&&t.field)if("label"===t)e[n](t.field,t.callback,t.cfg);else{var i;l.each(t,function(t,e){"field"!==e&&(i=t)}),e[n](t.field,i)}else e[n](t)}))},n._initControllers=function(){var t=this.get("options"),e=this.get("viewTheme"),n=this.get("canvas"),i=new u.Scale({viewTheme:e,defs:t.scales}),r=new u.Coord(t.coord);this.set("scaleController",i),this.set("coordController",r);var a=new u.Axis({canvas:n,viewTheme:e});this.set("axisController",a);var o=new u.Guide({viewTheme:e,options:t.guides||[]});this.set("guideController",o)},n._initViewPlot=function(){this.get("viewContainer")||this.set("viewContainer",this.get("middlePlot"))},n._initGeoms=function(){for(var t=this.get("geoms"),e=this.get("filteredData"),n=this.get("coord"),i=this.get("_id"),r=0;r0;){t.shift().destroy()}},n._drawGeoms=function(){this.emit("beforedrawgeoms");for(var t=this.get("geoms"),e=this.get("coord"),n=0;n0?r.change({min:0}):s<=0&&r.change({max:0}))}}},n._setCatScalesRange=function(){var t=this.get("coord"),e=this.get("viewTheme"),n=this.getXScale(),i=this.getYScales(),r=[];n&&r.push(n),r=r.concat(i);var a=t.isPolar&&function(t){var e=t.startAngle,n=t.endAngle;return!(!l.isNil(e)&&!l.isNil(n)&&n-e<2*Math.PI)}(t),o=this.get("scaleController").defs;l.each(r,function(n){if((n.isCategory||n.isIdentity)&&n.values&&(!o[n.field]||!o[n.field].range)){var i,r=n.values.length;if(1===r)i=[.5,1];else{var s=0;i=a?t.isTransposed?[(s=1/r*e.widthRatio.multiplePie)/2,1-s/2]:[0,1-1/r]:[s=1/r*1/2,1-s]}n.range=i}})},n.getXScale=function(){var t=this.get("geoms"),e=null;return l.isEmpty(t)||(e=t[0].getXScale()),e},n.getYScales=function(){for(var t=this.get("geoms"),e=[],n=0;n=0?"positive":"negative";o[d][g]||(o[d][g]=0),h[n]=[o[d][g],p+o[d][g]],o[d][g]+=p}}},e}(a);a.Stack=o,t.exports=o},function(t,e,n){var i={merge:n(42),values:n(64)},r=n(144),a=n(2);t.exports={processAdjust:function(t){var e=i.merge(t),n=this.dodgeBy,a=t;n&&(a=r(e,n)),this.cacheMap={},this.adjDataArray=a,this.mergeData=e,this.adjustData(a,e),this.adjDataArray=null,this.mergeData=null},getDistribution:function(t){var e=this.adjDataArray,n=this.cacheMap,r=n[t];return r||(r={},a(e,function(e,n){var o=i.values(e,t);o.length||o.push(0),a(o,function(t){r[t]||(r[t]=[]),r[t].push(n)})}),n[t]=r),r},adjustDim:function(t,e,n,i,r){var o=this,s=o.getDistribution(t),l=o.groupData(n,t);a(l,function(n,i){i=parseFloat(i);var l;l=1===e.length?{pre:e[0]-1,next:e[0]+1}:o.getAdjustRange(t,i,e),a(n,function(e){var n=e[t],i=s[n],a=i.indexOf(r);e[t]=o.getDodgeOffset(l,a,i.length)})})}}},function(t,e){t.exports={_initDefaultCfg:function(){this.xField=null,this.yField=null,this.height=null,this.size=10,this.reverseOrder=!1,this.adjustNames=["y"]},processOneDimStack:function(t){var e=this.xField,n=this.yField||"y",i=this.height,r={};this.reverseOrder&&(t=t.slice(0).reverse());for(var a=0,o=t.length;ai.width||n.height>i.height?r.push(t[a]):n.width*n.height>i.width*i.height&&r.push(t[a]);for(var o=0;o0?e="left":t[0]<0&&(e="right"),e},n.getLinePath=function(){var t=this.get("center"),e=t.x,n=t.y,i=this.get("radius"),r=i,a=this.get("startAngle"),o=this.get("endAngle"),s=this.get("inner"),l=[];if(Math.abs(o-a)===2*Math.PI)l=[["M",e,n],["m",0,-r],["a",i,r,0,1,1,0,2*r],["a",i,r,0,1,1,0,-2*r],["z"]];else{var u=this._getCirclePoint(a),c=this._getCirclePoint(o),h=Math.abs(o-a)>Math.PI?1:0,f=a>o?0:1;if(s){var p=this.getSideVector(s*i,u),g=this.getSideVector(s*i,c),d={x:p[0]+e,y:p[1]+n},v={x:g[0]+e,y:g[1]+n};l=[["M",d.x,d.y],["L",u.x,u.y],["A",i,r,0,h,f,c.x,c.y],["L",v.x,v.y],["A",i*s,r*s,0,h,Math.abs(f-1),d.x,d.y]]}else l=[["M",e,n],["L",u.x,u.y],["A",i,r,0,h,f,c.x,c.y],["L",e,n]]}return l},n.addLabel=function(e,n,i){var r=this.get("label").offset||this.get("_labelOffset")||.001;n=this.getSidePoint(n,r),t.prototype.addLabel.call(this,e,n,i)},n.autoRotateLabels=function(){var t=this.get("ticks"),e=this.get("labelRenderer");if(e&&t.length>12){var n=this.get("radius"),r=this.get("startAngle"),a=this.get("endAngle")-r,o=a/(t.length-1),s=Math.sin(o/2)*n*2,l=this.getMaxLabelWidth(e);i.each(e.get("group").get("children"),function(e,n){var i=t[n].value*a+r,o=i%(2*Math.PI);lMath.PI&&(i-=Math.PI),i-=Math.PI/2,e.attr("textAlign","center")):o>Math.PI/2?i-=Math.PI:oo.x)&&(u=!0);var c=a.vertical([],l,u);return a.scale([],c,t*n)},n.getAxisVector=function(){var t=this.get("start"),e=this.get("end");return[e.x-t.x,e.y-t.y]},n.getLinePath=function(){var t=this.get("start"),e=this.get("end"),n=[];return n.push(["M",t.x,t.y]),n.push(["L",e.x,e.y]),n},n.getTickEnd=function(t,e){var n=this.getSideVector(e);return{x:t.x+n[0],y:t.y+n[1]}},n.getTickPoint=function(t){var e=this.get("start"),n=this.get("end"),i=n.x-e.x,r=n.y-e.y;return{x:e.x+i*t,y:e.y+r*t}},n.renderTitle=function(){var t=this.get("title"),e=this.getTickPoint(.5),n=t.offset;if(r.isNil(n)){n=20;var i=this.get("labelsGroup");if(i){n+=this.getMaxLabelWidth(i)+(this.get("label").offset||this.get("_labelOffset"))}}var o=t.textStyle,s=r.mix({},o);if(t.text){var l=this.getAxisVector();if(t.autoRotate&&r.isNil(o.rotate)){var u=0;if(!r.snapEqual(l[1],0)){var c=[l[0],l[1]];u=a.angleTo(c,[1,0],!0)}s.rotate=u*(180/Math.PI)}else r.isNil(o.rotate)||(s.rotate=o.rotate/180*Math.PI);var h,f=this.getSideVector(n),p=t.position;h="start"===p?{x:this.get("start").x+f[0],y:this.get("start").y+f[1]}:"end"===p?{x:this.get("end").x+f[0],y:this.get("end").y+f[1]}:{x:e.x+f[0],y:e.y+f[1]},s.x=h.x,s.y=h.y,s.text=t.text;var g=this.get("group").addShape("Text",{zIndex:2,attrs:s});g.name="axis-title",this.get("appendInfo")&&g.setSilent("appendInfo",this.get("appendInfo"))}},n.autoRotateLabels=function(){var t=this.get("labelRenderer"),e=this.get("title");if(t){var n=t.get("group").get("children"),i=this.get("label").offset,a=e?e.offset:48;if(a<0)return;var o,s,l=this.getAxisVector();if(r.snapEqual(l[0],0)&&e&&e.text)(s=this.getMaxLabelWidth(t))>a-i-12&&(o=-1*Math.acos((a-i-12)/s));else if(r.snapEqual(l[1],0)&&n.length>1){var u=Math.abs(this._getAvgLabelLength(t));(s=this.getMaxLabelWidth(t))>u&&(o=Math.asin(1.25*(a-i-12)/s))}if(o){var c=this.get("factor");r.each(n,function(t){t.rotateAtStart(o),r.snapEqual(l[1],0)&&(c>0?t.attr("textAlign","left"):t.attr("textAlign","right"))})}}},n.autoHideLabels=function(){var t,e,n=this.get("labelRenderer");if(n){var i=n.get("group").get("children"),a=this.getAxisVector();if(i.length<2)return;if(r.snapEqual(a[0],0)){var o=this.getMaxLabelHeight(n)+8,s=Math.abs(this._getAvgLabelHeightSpace(n));o>s&&(t=o,e=s)}else if(r.snapEqual(a[1],0)&&i.length>1){var l=this.getMaxLabelWidth(n)+8,u=Math.abs(this._getAvgLabelLength(n));l>u&&(t=l,e=u)}if(t&&e){var c=Math.ceil(t/e);r.each(i,function(t,e){e%c!=0&&t.attr("text","")})}}},e}(i);t.exports=o},function(t,e,n){var i=n(3),r=n(31),a=i.MatrixUtil,o=i.PathUtil,s=a.vec2,l=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return i.mix({},e,{type:"polyline"})},n.getLinePath=function(){var t=this.get("tickPoints"),e=this.get("start"),n=this.get("end"),r=[];r.push(e.x),r.push(e.y),i.each(t,function(t){r.push(t.x),r.push(t.y)}),r.push(n.x),r.push(n.y);var a=o.catmullRomToBezier(r);return a.unshift(["M",e.x,e.y]),a},n.getTickPoint=function(t,e){return this.get("tickPoints")[e]},n.getTickEnd=function(t,e,n){var i=this.get("tickLine"),r=e||i.length,a=this.getSideVector(r,t,n);return{x:t.x+a[0],y:t.y+a[1]}},n.getSideVector=function(t,e,n){var i;if(0===n){if((i=this.get("start")).x===e.x&&i.y===e.y)return[0,0]}else{i=this.get("tickPoints")[n-1]}var r=[e.x-i.x,e.y-i.y],a=s.normalize([],r),o=s.vertical([],a,!1);return s.scale([],o,t)},e}(r);t.exports=l},function(t,e,n){t.exports={Guide:n(15),Arc:n(315),DataMarker:n(316),DataRegion:n(317),Html:n(318),Image:n(319),Line:n(320),Region:n(321),Text:n(322)}},function(t,e,n){function i(t,e){var n,i=t.x-e.x,r=t.y-e.y;return 0===r?n=i<0?o/2:270*o/180:i>=0&&r>0?n=2*o-s(i/r):i<=0&&r<0?n=o-s(i/r):i>0&&r<0?n=o+s(-i/r):i<0&&r>0&&(n=s(i/-r)),n}var r=n(3),a=n(15),o=Math.PI,s=Math.atan,l=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return r.mix({},e,{name:"arc",start:null,end:null,style:{stroke:"#999",lineWidth:1}})},n.render=function(t,e){var n,a=this.parsePoint(t,this.get("start")),s=this.parsePoint(t,this.get("end")),l=t.getCenter(),u=Math.sqrt((a.x-l.x)*(a.x-l.x)+(a.y-l.y)*(a.y-l.y)),c=i(a,l),h=i(s,l);if(ho?1:0;n=[["M",a.x,a.y],["A",u,u,0,f,1,s.x,s.y]]}var p=e.addShape("path",{zIndex:this.get("zIndex"),attrs:r.mix({path:n},this.get("style"))});p.name="guide-arc",this.get("appendInfo")&&p.setSilent("appendInfo",this.get("appendInfo")),this.set("el",p)},e}(a);t.exports=l},function(t,e,n){var i=n(3),r=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return i.mix({},e,{name:"dataMarker",zIndex:1,top:!0,position:null,style:{point:{r:3,fill:"#FFFFFF",stroke:"#1890FF",lineWidth:2},line:{stroke:"#A3B1BF",lineWidth:1},text:{fill:"#000000",opacity:.65,fontSize:12,textAlign:"start"}},display:{point:!0,line:!0,text:!0},lineLength:20,direction:"upward",autoAdjust:!0})},n.render=function(t,e){var n=this.parsePoint(t,this.get("position")),i=e.addGroup();i.name="guide-data-marker";var r,a,o=this._getElementPosition(n),s=this.get("display");if(s.line){var l=o.line;r=this._drawLine(l,i)}if(s.text&&this.get("content")){var u=o.text;a=this._drawText(u,i)}if(s.point){var c=o.point;this._drawPoint(c,i)}if(this.get("autoAdjust")){var h=i.getBBox(),f=h.minX,p=h.minY,g=h.maxX,d=h.maxY,v=t.start,y=t.end;if(a){f<=v.x&&a.attr("textAlign","start"),g>=y.x&&a.attr("textAlign","end");var x=this.get("direction");if("upward"===x&&p<=y.y||"upward"!==x&&d>=v.y){var m,_;"upward"===x&&p<=y.y?(m="top",_=1):(m="bottom",_=-1),a.attr("textBaseline",m);var b=0;if(this.get("display").line){b=this.get("lineLength");var w=[["M",n.x,n.y],["L",n.x,n.y+b*_]];r.attr("path",w)}var S=n.y+(b+2)*_;a.attr("y",S)}}}this.get("appendInfo")&&i.setSilent("appendInfo",this.get("appendInfo")),this.set("el",i)},n._getElementPosition=function(t){var e=t.x,n=t.y,i=this.get("display").line?this.get("lineLength"):0,r=this.get("direction");this.get("style").text.textBaseline="upward"===r?"bottom":"top";var a="upward"===r?-1:1;return{point:{x:e,y:n},line:[{x:e,y:n},{x:e,y:i*a+n}],text:{x:e,y:(i+2)*a+n}}},n._drawLine=function(t,e){var n=this.get("style").line,r=[["M",t[0].x,t[0].y],["L",t[1].x,t[1].y]];return e.addShape("path",{attrs:i.mix({path:r},n)})},n._drawText=function(t,e){var n=this.get("style").text;return e.addShape("text",{attrs:i.mix({text:this.get("content")},n,t)})},n._drawPoint=function(t,e){var n=this.get("style").point;return e.addShape("circle",{attrs:i.mix({},n,t)})},e}(n(15));t.exports=r},function(t,e,n){var i=n(3),r=n(156),a=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return i.mix({},e,{name:"dataRegion",start:null,end:null,content:"",style:{region:{lineWidth:0,fill:"#000000",opacity:.04},text:{textAlign:"center",textBaseline:"bottom",fontSize:12,fill:"rgba(0, 0, 0, .65)"}}})},n.render=function(t,e,n){var r=this.get("lineLength")||0,a=this._getRegionData(t,n);if(a.length){var o=this._getBBox(a),s=[];s.push(["M",a[0].x,o.yMin-r]);for(var l=0,u=a.length;l=n&&h.push(this.parsePoint(t,[g[s],g[l]])),g[s]===c)break}return h},n._getBBox=function(t){for(var e=[],n=[],r=0;r');a.appendChild(o);var s=this.get("htmlContent")||this.get("html");if(i.isFunction(s)){s=s(this.get("xScales"),this.get("yScales"))}var l=r.createDom(s);o.appendChild(l),r.modifyCSS(o,{position:"absolute"}),this._setDomPosition(o,l,n),this.set("el",o)},n._setDomPosition=function(t,e,n){var i=this.get("alignX"),a=this.get("alignY"),o=r.getOuterWidth(e),s=r.getOuterHeight(e),l={x:n.x,y:n.y};"middle"===i&&"top"===a?l.x-=Math.round(o/2):"middle"===i&&"bottom"===a?(l.x-=Math.round(o/2),l.y-=Math.round(s)):"left"===i&&"bottom"===a?l.y-=Math.round(s):"left"===i&&"middle"===a?l.y-=Math.round(s/2):"left"===i&&"top"===a?(l.x=n.x,l.y=n.y):"right"===i&&"bottom"===a?(l.x-=Math.round(o),l.y-=Math.round(s)):"right"===i&&"middle"===a?(l.x-=Math.round(o),l.y-=Math.round(s/2)):"right"===i&&"top"===a?l.x-=Math.round(o):(l.x-=Math.round(o/2),l.y-=Math.round(s/2));var u=this.get("offsetX");u&&(l.x+=u);var c=this.get("offsetY");c&&(l.y+=c),r.modifyCSS(t,{top:Math.round(l.y)+"px",left:Math.round(l.x)+"px",visibility:"visible",zIndex:this.get("zIndex")})},n.clear=function(){var t=this.get("el");t&&t.parentNode&&t.parentNode.removeChild(t)},e}(n(15));t.exports=a},function(t,e,n){var i=n(3),r=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return i.mix({},e,{type:"image",start:null,end:null,src:null,offsetX:null,offsetY:null})},n.render=function(t,e){var n=this.parsePoint(t,this.get("start")),i={x:n.x,y:n.y};if(i.img=this.get("src"),this.get("end")){var r=this.parsePoint(t,this.get("end"));i.width=r.x-n.x,i.height=r.y-n.y}else i.width=this.get("width")||32,i.height=this.get("height")||32;this.get("offsetX")&&(i.x+=this.get("offsetX")),this.get("offsetY")&&(i.y+=this.get("offsetY"));var a=e.addShape("Image",{zIndex:1,attrs:i});a.name="guide-image",this.get("appendInfo")&&a.setSilent("appendInfo",this.get("appendInfo")),this.set("el",a)},e}(n(15));t.exports=r},function(t,e,n){var i=n(3),r=n(15),a=i.MatrixUtil.vec2,o=n(14).FONT_FAMILY,s=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return i.mix({},e,{name:"line",start:null,end:null,lineStyle:{stroke:"#000",lineWidth:1},text:{position:"end",autoRotate:!0,style:{fill:"#999",fontSize:12,fontWeight:500,fontFamily:o},content:null}})},n.render=function(t,e){var n=this.parsePoint(t,this.get("start")),i=this.parsePoint(t,this.get("end")),r=e.addGroup({viewId:e.get("viewId")});this._drawLines(n,i,r);var a=this.get("text");a&&a.content&&this._drawText(n,i,r),this.set("el",r)},n._drawLines=function(t,e,n){var r=[["M",t.x,t.y],["L",e.x,e.y]],a=n.addShape("Path",{attrs:i.mix({path:r},this.get("lineStyle"))});a.name="guide-line",this.get("appendInfo")&&a.setSilent("appendInfo",this.get("appendInfo"))},n._drawText=function(t,e,n){var r,o=this.get("text"),s=o.position,l=o.style||{};((r="start"===s?0:"center"===s?.5:i.isString(s)&&-1!==s.indexOf("%")?parseInt(s,10)/100:i.isNumber(s)?s:1)>1||r<0)&&(r=1);var u={x:t.x+(e.x-t.x)*r,y:t.y+(e.y-t.y)*r};if(o.offsetX&&(u.x+=o.offsetX),o.offsetY&&(u.y+=o.offsetY),u.text=o.content,u=i.mix({},u,l),o.autoRotate&&i.isNil(l.rotate)){var c=a.angleTo([e.x-t.x,e.y-t.y],[1,0],1);u.rotate=c}else i.isNil(l.rotate)||(u.rotate=l.rotate*Math.PI/180);var h=n.addShape("Text",{attrs:u});h.name="guide-line-text",this.get("appendInfo")&&h.setSilent("appendInfo",this.get("appendInfo"))},e}(r);t.exports=s},function(t,e,n){var i=n(3),r=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return i.mix({},e,{name:"region",zIndex:1,start:null,end:null,style:{lineWidth:0,fill:"#CCD7EB",opacity:.4}})},n.render=function(t,e){var n=this.get("style"),r=this._getPath(t),a=e.addShape("path",{zIndex:this.get("zIndex"),attrs:i.mix({path:r},n)});a.name="guide-region",this.get("appendInfo")&&a.setSilent("appendInfo",this.get("appendInfo")),this.set("el",a)},n._getPath=function(t){var e=this.parsePoint(t,this.get("start")),n=this.parsePoint(t,this.get("end"));return[["M",e.x,e.y],["L",n.x,e.y],["L",n.x,n.y],["L",e.x,n.y],["z"]]},e}(n(15));t.exports=r},function(t,e,n){var i=n(3),r=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return i.mix({},e,{name:"text",position:null,content:null,style:{fill:"#999",fontSize:12,fontWeight:500,textAlign:"center"},offsetX:null,offsetY:null,top:!0})},n.render=function(t,e){var n=this.parsePoint(t,this.get("position")),r=i.mix({},this.get("style")),a=this.get("offsetX"),o=this.get("offsetY");a&&(n.x+=a),o&&(n.y+=o),r.rotate&&(r.rotate=r.rotate*Math.PI/180);var s=e.addShape("Text",{zIndex:this.get("zIndex"),attrs:i.mix({text:this.get("content")},r,n)});s.name="guide-text",this.get("appendInfo")&&s.setSilent("appendInfo",this.get("appendInfo")),this.set("el",s)},e}(n(15));t.exports=r},function(t,e,n){var i=n(154);t.exports=i},function(t,e,n){t.exports={Category:n(157),CatHtml:n(159),CatPageHtml:n(325),Color:n(326),Size:n(328),CircleSize:n(329)}},function(t,e,n){function i(t,e){return t.getElementsByClassName(e)[0]}var r=n(3),a=n(159),o=n(14).FONT_FAMILY,s=r.DomUtil,l=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return r.mix({},e,{type:"category-page-legend",container:null,caretStyle:{fill:"rgba(0,0,0,0.65)"},pageNumStyle:{display:"inline-block",fontSize:"12px",fontFamily:o,cursor:"default"},slipDomStyle:{width:"auto",height:"auto",position:"absolute"},slipTpl:'

      1

      /2

      ',slipWidth:65,legendOverflow:"unset"})},n.render=function(){t.prototype._renderHTML.call(this),this._renderFlipPage()},n._renderFlipPage=function(){var t=document.getElementsByClassName("g2-legend")[0],e=i(t,"g2-legend-list"),n=this.get("position"),a=this.get("layout"),o="right"===n||"left"===n||"vertical"===a?"block":"inline-block";if(t.scrollHeight>t.offsetHeight){var l=this.get("slipTpl"),u=s.createDom(l),c=i(u,"g2-caret-up"),h=i(u,"g2-caret-down");s.modifyCSS(c,this.get("caretStyle")),s.modifyCSS(c,{fill:"rgba(0,0,0,0.25)"}),s.modifyCSS(h,this.get("caretStyle"));var f=i(u,"cur-pagenum"),p=i(u,"next-pagenum"),g=this.get("pageNumStyle");s.modifyCSS(f,r.mix({},g,{paddingLeft:"10px"})),s.modifyCSS(p,r.mix({},g,{opacity:.3,paddingRight:"10px"})),s.modifyCSS(u,r.mix({},this.get("slipDomStyle"),{top:t.offsetHeight+"px"})),t.style.overflow=this.get("legendOverflow"),t.appendChild(u);for(var d=e.childNodes,v=0,y=1,x=[],m=0;m=t.offsetHeight&&(y++,x.forEach(function(t){t.style.display="none"}),x=[]),x.push(d[m]);p.innerText="/"+y,d.forEach(function(e){e.style.display=o,(v=e.offsetTop+e.offsetHeight)>t.offsetHeight&&(e.style.display="none")}),c.addEventListener("click",function(){if(d[0].style.display!==o){var e=-1;d.forEach(function(t,n){t.style.display===o&&(e=-1===e?n:e,t.style.display="none")});for(var n=e-1;n>=0&&(d[n].style.display=o,v=d[e-1].offsetTop+d[e-1].offsetHeight,d[n].style.display="none",v0){var g=i.toRGB(l[p-1].color);u+=1-l[p].percentage+":"+g+" "}h.addShape("text",{attrs:r.mix({},{x:a+this.get("textOffset")/2,y:o-l[p].percentage*o,text:this._formatItemValue(l[p].value)+""},this.get("textStyle"),{textAlign:"start"})})}}else{u+="l (0) ";for(var d=0;d0){var v=i.toRGB(l[d-1].color);u+=l[d].percentage+":"+v+" "}u+=l[d].percentage+":"+n+" ",h.addShape("text",{attrs:r.mix({},{x:l[d].percentage*a,y:o+5+this.get("textOffset"),text:this._formatItemValue(l[d].value)+""},this.get("textStyle"))})}}h.addShape("rect",{attrs:{x:0,y:0,width:a,height:o,fill:u,strokeOpacity:0}}),h.addShape("path",{attrs:r.mix({path:c},this.get("lineStyle"))}),h.move(0,e)},e}(n(67));t.exports=a},function(t,e,n){var i=n(3),r=i.DomUtil,a=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){return{range:null,middleAttr:{fill:"#fff",fillOpacity:0},backgroundElement:null,minHandleElement:null,maxHandleElement:null,middleHandleElement:null,currentTarget:null,layout:"vertical",width:null,height:null,pageX:null,pageY:null}},n._beforeRenderUI=function(){var t=this.get("layout"),e=this.get("backgroundElement"),n=this.get("minHandleElement"),i=this.get("maxHandleElement"),r=this.addShape("rect",{attrs:this.get("middleAttr")}),a="vertical"===t?"ns-resize":"ew-resize";this.add([e,n,i]),this.set("middleHandleElement",r),e.set("zIndex",0),r.set("zIndex",1),n.set("zIndex",2),i.set("zIndex",2),r.attr("cursor","move"),n.attr("cursor",a),i.attr("cursor",a),this.sort()},n._renderUI=function(){"horizontal"===this.get("layout")?this._renderHorizontal():this._renderVertical()},n._transform=function(t){var e=this.get("range"),n=e[0]/100,i=e[1]/100,r=this.get("width"),a=this.get("height"),o=this.get("minHandleElement"),s=this.get("maxHandleElement"),l=this.get("middleHandleElement");o.resetMatrix(),s.resetMatrix(),"horizontal"===t?(l.attr({x:r*n,y:0,width:(i-n)*r,height:a}),o.translate(n*r,a),s.translate(i*r,a)):(l.attr({x:0,y:a*(1-i),width:r,height:(i-n)*a}),o.translate(1,(1-n)*a),s.translate(1,(1-i)*a))},n._renderHorizontal=function(){this._transform("horizontal")},n._renderVertical=function(){this._transform("vertical")},n._bindUI=function(){this.on("mousedown",i.wrapBehavior(this,"_onMouseDown"))},n._isElement=function(t,e){var n=this.get(e);if(t===n)return!0;if(n.isGroup){return n.get("children").indexOf(t)>-1}return!1},n._getRange=function(t,e){var n=t+e;return n=n>100?100:n,n=n<0?0:n},n._updateStatus=function(t,e){var n="x"===t?this.get("width"):this.get("height");t=i.upperFirst(t);var r,a=this.get("range"),o=this.get("page"+t),s=this.get("currentTarget"),l=this.get("rangeStash"),u="vertical"===this.get("layout")?-1:1,c=e["page"+t],h=(c-o)/n*100*u;a[1]<=a[0]?(this._isElement(s,"minHandleElement")||this._isElement(s,"maxHandleElement"))&&(a[0]=this._getRange(h,a[0]),a[1]=this._getRange(h,a[0])):(this._isElement(s,"minHandleElement")&&(a[0]=this._getRange(h,a[0])),this._isElement(s,"maxHandleElement")&&(a[1]=this._getRange(h,a[1]))),this._isElement(s,"middleHandleElement")&&(r=l[1]-l[0],a[0]=this._getRange(h,a[0]),a[1]=a[0]+r,a[1]>100&&(a[1]=100,a[0]=a[1]-r)),this.emit("sliderchange",{range:a}),this.set("page"+t,c),this._renderUI(),this.get("canvas").draw()},n._onMouseDown=function(t){var e=t.currentTarget,n=t.event,i=this.get("range");n.stopPropagation(),n.preventDefault(),this.set("pageX",n.pageX),this.set("pageY",n.pageY),this.set("currentTarget",e),this.set("rangeStash",[i[0],i[1]]),this._bindCanvasEvents()},n._bindCanvasEvents=function(){var t=this.get("canvas").get("containerDOM");this.onMouseMoveListener=r.addEventListener(t,"mousemove",i.wrapBehavior(this,"_onCanvasMouseMove")),this.onMouseUpListener=r.addEventListener(t,"mouseup",i.wrapBehavior(this,"_onCanvasMouseUp")),this.onMouseLeaveListener=r.addEventListener(t,"mouseleave",i.wrapBehavior(this,"_onCanvasMouseUp"))},n._onCanvasMouseMove=function(t){if(!this._mouseOutArea(t)){"horizontal"===this.get("layout")?this._updateStatus("x",t):this._updateStatus("y",t)}},n._onCanvasMouseUp=function(){this._removeDocumentEvents()},n._removeDocumentEvents=function(){this.onMouseMoveListener.remove(),this.onMouseUpListener.remove()},n._mouseOutArea=function(t){var e=this.get("canvas").get("el").getBoundingClientRect(),n=this.get("parent"),i=n.getBBox(),r=n.attr("matrix")[6],a=n.attr("matrix")[7],o=r+i.width,s=a+i.height,l=t.clientX-e.x,u=t.clientY-e.y;return lo||us},e}(i.Group);t.exports=a},function(t,e,n){var i=n(3),r=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return i.mix({},e,{type:"size-legend",width:100,height:200,_unslidableElementStyle:{fill:"#4E7CCC",fillOpacity:1},frontMiddleBarStyle:{fill:"rgb(64, 141, 251)"}})},n._renderSliderShape=function(){var t=this.get("slider").get("backgroundElement"),e=this.get("layout"),n=this.get("width"),r=this.get("height"),a=this.get("height")/2,o=this.get("frontMiddleBarStyle"),s="vertical"===e?[[0,0],[n,0],[n,r],[n-4,r]]:[[0,a+r/2],[0,a+r/2-4],[n,a-r/2],[n,a+r/2]];return this._addMiddleBar(t,"Polygon",i.mix({points:s},o))},n._renderUnslidable=function(){var t=this.get("layout"),e=this.get("width"),n=this.get("height"),r=this.get("frontMiddleBarStyle"),a="vertical"===t?[[0,0],[e,0],[e,n],[e-4,n]]:[[0,n],[0,n-4],[e,0],[e,n]];this.get("group").addGroup().addShape("Polygon",{attrs:i.mix({points:a},r)});var o=this._formatItemValue(this.get("firstItem").value),s=this._formatItemValue(this.get("lastItem").value);"vertical"===this.get("layout")?(this._addText(e+10,n-3,o),this._addText(e+10,3,s)):(this._addText(0,n,o),this._addText(e,n,s))},n._addText=function(t,e,n){var r=this.get("group").addGroup(),a=this.get("textStyle"),o=this.get("titleShape"),s=this.get("titleGap");o&&(s+=o.getBBox().height),"vertical"===this.get("layout")?r.addShape("text",{attrs:i.mix({x:t+this.get("textOffset"),y:e,text:0===n?"0":n},a)}):(e+=s+this.get("textOffset")-20,o||(e+=10),r.addShape("text",{attrs:i.mix({x:t,y:e,text:0===n?"0":n},a)}))},e}(n(67));t.exports=r},function(t,e,n){var i=n(3),r=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return i.mix({},e,{type:"size-circle-legend",width:100,height:200,_unslidableCircleStyle:{stroke:"rgb(99, 161, 248)",fill:"rgb(99, 161, 248)",fillOpacity:.3,lineWidth:1.5},triggerAttr:{fill:"white",shadowOffsetX:-2,shadowOffsetY:2,shadowBlur:10,shadowColor:"#ccc"},frontMiddleBarStyle:{fill:"rgb(64, 141, 251)"}})},n._renderSliderShape=function(){var t=this.get("slider").get("backgroundElement"),e=this.get("layout"),n="vertical"===e?2:this.get("width"),r="vertical"===e?this.get("height"):2,a=this.get("height")/2,o=this.get("frontMiddleBarStyle"),s="vertical"===e?[[0,0],[n,0],[n,r],[0,r]]:[[0,a+r],[0,a-r],[5+n-4,a-r],[5+n-4,a+r]];return this._addMiddleBar(t,"Polygon",i.mix({points:s},o))},n._addHorizontalTrigger=function(t,e,n,r){var a=this.get("slider").get(t+"HandleElement"),o=-this.get("height")/2,s=a.addShape("circle",{attrs:i.mix({x:0,y:o,r:r},e)}),l=a.addShape("text",{attrs:i.mix(n,{x:0,y:o+r+10,textAlign:"center",textBaseline:"middle"})}),u="vertical"===this.get("layout")?"ns-resize":"ew-resize";s.attr("cursor",u),l.attr("cursor",u),this.set(t+"ButtonElement",s),this.set(t+"TextElement",l)},n._addVerticalTrigger=function(t,e,n,r){var a=this.get("slider").get(t+"HandleElement"),o=a.addShape("circle",{attrs:i.mix({x:0,y:0,r:r},e)}),s=a.addShape("text",{attrs:i.mix(n,{x:r+10,y:0,textAlign:"start",textBaseline:"middle"})}),l="vertical"===this.get("layout")?"ns-resize":"ew-resize";o.attr("cursor",l),s.attr("cursor",l),this.set(t+"ButtonElement",o),this.set(t+"TextElement",s)},n._renderTrigger=function(){var t=this.get("firstItem"),e=this.get("lastItem"),n=this.get("layout"),r=this.get("textStyle"),a=this.get("triggerAttr"),o=i.mix({},a),s=i.mix({},a),l=i.mix({text:this._formatItemValue(t.value)+""},r),u=i.mix({text:this._formatItemValue(e.value)+""},r);"vertical"===n?(this._addVerticalTrigger("min",o,l,5),this._addVerticalTrigger("max",s,u,16)):(this._addHorizontalTrigger("min",o,l,5),this._addHorizontalTrigger("max",s,u,16))},n._bindEvents=function(){var t=this;if(this.get("slidable")){this.get("slider").on("sliderchange",function(e){var n=e.range,i=t.get("firstItem").value,r=t.get("lastItem").value,a=i+n[0]/100*(r-i),o=i+n[1]/100*(r-i),s=5+n[0]/100*11,l=5+n[1]/100*11;t._updateElement(a,o,s,l);var u=new Event("itemfilter",e,!0,!0);u.range=[a,o],t.emit("itemfilter",u)})}},n._updateElement=function(e,n,i,r){t.prototype._updateElement.call(this,e,n);var a=this.get("minTextElement"),o=this.get("maxTextElement"),s=this.get("minButtonElement"),l=this.get("maxButtonElement");s.attr("r",i),l.attr("r",r);if("vertical"===this.get("layout"))a.attr("x",i+10),o.attr("x",r+10);else{var u=-this.get("height")/2;a.attr("y",u+i+10),o.attr("y",u+r+10)}},n._addCircle=function(t,e,n,r,a){var o=this.get("group").addGroup(),s=this.get("_unslidableCircleStyle"),l=this.get("textStyle"),u=this.get("titleShape"),c=this.get("titleGap");u&&(c+=u.getBBox().height),o.addShape("circle",{attrs:i.mix({x:t,y:e+c,r:0===n?1:n},s)}),"vertical"===this.get("layout")?o.addShape("text",{attrs:i.mix({x:a+20+this.get("textOffset"),y:e+c,text:0===r?"0":r},l)}):o.addShape("text",{attrs:i.mix({x:t,y:e+c+a+13+this.get("textOffset"),text:0===r?"0":r},l)})},n._renderUnslidable=function(){var t=this.get("firstItem").value,e=this.get("lastItem").value;if(t>e){var n=e;e=t,t=n}var i=this._formatItemValue(t),r=this._formatItemValue(e),a=t<5?5:t,o=e>16?16:e;a>o&&(a=5,o=16),"vertical"===this.get("layout")?(this._addCircle(o,o,a,i,2*o),this._addCircle(o,2*o+16+a,o,r,2*o)):(this._addCircle(o,o,a,i,2*o),this._addCircle(2*o+16+a,o,o,r,2*o))},n.activate=function(e){this.get("slidable")&&t.prototype.activate.call(this,e)},e}(n(67));t.exports=r},function(t,e,n){var i=n(68);i.Html=n(331),i.Canvas=n(163),i.Mini=n(333),t.exports=i},function(t,e,n){function i(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function r(t,e){return t.getElementsByClassName(e)[0]}var a=n(68),o=n(3),s=o.DomUtil,l=n(332),u=n(160),c=n(161),h=n(162),f=function(t){function e(e){var n;n=t.call(this,e)||this,o.assign(i(i(n)),c),o.assign(i(i(n)),h);var r=l;n.style=function(t,e){return Object.keys(t).forEach(function(n){e[n]&&(t[n]=o.mix(t[n],e[n]))}),t}(r,e),n._init_(),n.get("items")&&n.render();var a=n.get("crosshairs");if(a){var s="rect"===a.type?n.get("backPlot"):n.get("frontPlot"),f=new u(o.mix({plot:s,plotRange:n.get("plotRange"),canvas:n.get("canvas")},n.get("crosshairs")));f.hide(),n.set("crosshairGroup",f)}return n}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return o.mix({},e,{containerTpl:'
        ',itemTpl:'
      • {name}{value}
      • ',htmlContent:null,follow:!0,enterable:!1})},n._init_=function(){var t,e=this.get("containerTpl"),n=this.get("canvas").get("el").parentNode;if(!this.get("htmlContent")){if(/^\#/.test(e)){var i=e.replace("#","");t=document.getElementById(i)}else t=s.createDom(e),s.modifyCSS(t,this.style["g2-tooltip"]),n.appendChild(t),n.style.position="relative";this.set("container",t)}},n.render=function(){if(this.clear(),this.get("htmlContent")){var t=this.get("canvas").get("el").parentNode,e=this._getHtmlContent();t.appendChild(e),this.set("container",e)}else this._renderTpl()},n._renderTpl=function(){var t=this,e=t.get("showTitle"),n=t.get("titleContent"),i=t.get("container"),a=r(i,"g2-tooltip-title"),l=r(i,"g2-tooltip-list"),u=t.get("items");a&&e&&(s.modifyCSS(a,t.style["g2-tooltip-title"]),a.innerHTML=n),l&&(s.modifyCSS(l,t.style["g2-tooltip-list"]),o.each(u,function(e,n){l.appendChild(t._addItem(e,n))}))},n.clear=function(){var t=this.get("container");if(this.get("htmlContent"))t&&t.remove();else{var e=r(t,"g2-tooltip-title"),n=r(t,"g2-tooltip-list");e&&(e.innerHTML=""),n&&(n.innerHTML="")}},n.show=function(){var e=this.get("container");e.style.visibility="visible",e.style.display="block";var n=this.get("crosshairGroup");n&&n.show();var i=this.get("markerGroup");i&&i.show(),t.prototype.show.call(this),this.get("canvas").draw()},n.hide=function(){var e=this.get("container");e.style.visibility="hidden",e.style.display="none";var n=this.get("crosshairGroup");n&&n.hide();var i=this.get("markerGroup");i&&i.hide(),t.prototype.hide.call(this),this.get("canvas").draw()},n.destroy=function(){var e=this.get("container"),n=this.get("containerTpl");e&&!/^\#/.test(n)&&e.parentNode.removeChild(e);var i=this.get("crosshairGroup");i&&i.destroy();var r=this.get("markerGroup");r&&r.remove(),t.prototype.destroy.call(this)},n._addItem=function(t,e){var n=this.get("itemTpl"),i=o.substitute(n,o.mix({index:e},t)),a=s.createDom(i);s.modifyCSS(a,this.style["g2-tooltip-list-item"]);var l=r(a,"g2-tooltip-marker");l&&s.modifyCSS(l,this.style["g2-tooltip-marker"]);var u=r(a,"g2-tooltip-value");return u&&s.modifyCSS(u,this.style["g2-tooltip-value"]),a},n._getHtmlContent=function(){var t=this.get("htmlContent")(this.get("titleContent"),this.get("items"));return s.createDom(t)},n.setPosition=function(e,n,i){var r,a=this.get("container"),l=this.get("canvas").get("el"),u=s.getWidth(l),c=s.getHeight(l),h=a.clientWidth,f=a.clientHeight,p=e,g=n,d=this.get("prePosition")||{x:0,y:0};if(this.get("enterable"))r=[e,n-=a.clientHeight/2],d&&e-d.x>0?e-=a.clientWidth+1:e+=1;else if(this.get("position")){var v=a.clientWidth,y=a.clientHeight;e=(r=this._calcTooltipPosition(e,n,this.get("position"),v,y,i))[0],n=r[1]}else e=(r=this._constraintPositionInBoundary(e,n,h,f,u,c))[0],n=r[1];if(this.get("inPlot")){var x=this.get("plotRange");e=(r=this._constraintPositionInPlot(e,n,h,f,x,this.get("enterable")))[0],n=r[1]}var m=this.get("markerItems");o.isEmpty(m)||(p=m[0].x,g=m[0].y),this.set("prePosition",r);this.get("follow")&&(a.style.left=e+"px",a.style.top=n+"px");var _=this.get("crosshairGroup");if(_){var b=this.get("items");_.setPosition(p,g,b)}t.prototype.setPosition.call(this,e,n)},e}(a);t.exports=f},function(t,e,n){var i,r=n(14).FONT_FAMILY,a=(i={crosshairs:!1,offset:15},i["g2-tooltip"]={position:"absolute",visibility:"hidden",zIndex:8,transition:"visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), left 0.4s cubic-bezier(0.23, 1, 0.32, 1), top 0.4s cubic-bezier(0.23, 1, 0.32, 1)",backgroundColor:"rgba(255, 255, 255, 0.9)",boxShadow:"0px 0px 10px #aeaeae",borderRadius:"3px",color:"rgb(87, 87, 87)",fontSize:"12px",fontFamily:r,lineHeight:"20px",padding:"10px 10px 6px 10px"},i["g2-tooltip-title"]={marginBottom:"4px"},i["g2-tooltip-list"]={margin:0,listStyleType:"none",padding:0},i["g2-tooltip-list-item"]={marginBottom:"4px"},i["g2-tooltip-marker"]={width:"5px",height:"5px",borderRadius:"50%",display:"inline-block",marginRight:"8px"},i["g2-tooltip-value"]={display:"inline-block",float:"right",marginLeft:"30px"},i);t.exports=a},function(t,e,n){var i=n(3),r=n(163),a=n(14).FONT_FAMILY,o=i.DomUtil,s=i.MatrixUtil,l=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return i.mix({},e,{boardStyle:{x:0,y:0,width:0,height:0,radius:3},valueStyle:{x:0,y:0,text:"",fontFamily:a,fontSize:12,stroke:"#fff",lineWidth:2,fill:"black",textBaseline:"top",textAlign:"start"},padding:{top:5,right:5,bottom:0,left:5},triangleWidth:10,triangleHeight:4})},n._init_=function(){var t=this.get("padding"),e=this.get("frontPlot").addGroup();this.set("container",e);var n=e.addShape("rect",{attrs:i.mix({},this.get("boardStyle"))});this.set("board",n);var r=e.addShape("path",{attrs:{fill:this.get("boardStyle").fill}});this.set("triangleShape",r);var a=e.addGroup();a.move(t.left,t.top);var o=a.addShape("text",{attrs:i.mix({},this.get("valueStyle"))});this.set("valueShape",o)},n.render=function(){this.clear();var t=this.get("board"),e=this.get("valueShape"),n=this.get("padding"),i=this.get("items")[0];e&&e.attr("text",i.value);var r=e?e.getBBox():{width:80,height:30},a=n.left+r.width+n.right,o=n.top+r.height+n.bottom;t.attr("width",a),t.attr("height",o),this._centerTriangleShape()},n.clear=function(){this.get("valueShape").attr("text","")},n.setPosition=function(t,e,n){var i=this.get("container"),r=this.get("plotRange"),a=i.getBBox(),l=a.width,u=a.height;if(t-=l/2,n&&("point"===n.name||"interval"===n.name)){e=n.getBBox().y}if(e-=u,this.get("inPlot"))tr.tr.x?(t=r.tr.x-l,this._rightTriangleShape()):this._centerTriangleShape(),er.bl.y&&(e=r.bl.y-u);else{var c=this.get("canvas").get("el"),h=o.getWidth(c),f=o.getHeight(c);t<0?(t=0,this._leftTriangleShape()):t+l/2>h?(t=h-l,this._rightTriangleShape()):this._centerTriangleShape(),e<0?e=0:e+u>f&&(e=f-u)}var p=s.transform([1,0,0,0,1,0,0,0,1],[["t",t,e]]);i.stopAnimate(),i.animate({matrix:p},this.get("animationDuration"))},n._centerTriangleShape=function(){var t=this.get("triangleShape"),e=this.get("triangleWidth"),n=this.get("triangleHeight"),i=this.get("board").getBBox(),r=i.width,a=i.height,o=[["M",0,0],["L",e,0],["L",e/2,n],["L",0,0],["Z"]];t.attr("path",o),t.move(r/2-e/2,a-1)},n._leftTriangleShape=function(){var t=this.get("triangleShape"),e=this.get("triangleWidth"),n=this.get("triangleHeight"),i=this.get("board").getBBox().height,r=[["M",0,0],["L",e,0],["L",0,n+3],["L",0,0],["Z"]];t.attr("path",r),t.move(0,i-3)},n._rightTriangleShape=function(){var t=this.get("triangleShape"),e=this.get("triangleWidth"),n=this.get("triangleHeight"),i=this.get("board").getBBox(),r=i.width,a=i.height,o=[["M",0,0],["L",e,0],["L",e,n+4],["L",0,0],["Z"]];t.attr("path",o),t.move(r-e-1,a-4)},e}(r);t.exports=l},function(t,e,n){var i=n(0).MatrixUtil.vec2;t.exports={catmullRom2bezier:function(t,e,n){for(var r=!!e,a=[],o=0,s=t.length;o0&&(e=this._distribute(e,n)),t.prototype.adjustItems.call(this,e)},n._distribute=function(t,e){var n=this.get("coord"),i=n.getRadius(),r=this.get("label").labelHeight,a=n.getCenter(),o=2*(i+e)+2*r,s={start:n.start,end:n.end},l=this.get("geom");if(l){var u=l.get("view");s=u.getViewRegion()}var c=[[],[]];return t.forEach(function(t){t&&("right"===t.textAlign?c[0].push(t):c[1].push(t))}),c.forEach(function(t,e){var n=parseInt(o/r,10);t.length>n&&(t.sort(function(t,e){return e["..percent"]-t["..percent"]}),t.splice(n,t.length-n)),t.sort(function(t,e){return t.y-e.y}),function(t,e,n,i,r){var a,o=!0,s=n.start,l=n.end,u=Math.min(s.y,l.y),c=Math.abs(s.y-l.y),h=0,f=Number.MIN_VALUE,p=t.map(function(t){return t.y>h&&(h=t.y),t.yc&&(c=h-u);o;)for(p.forEach(function(t){var e=(Math.min.apply(f,t.targets)+Math.max.apply(f,t.targets))/2;t.pos=Math.min(Math.max(f,e-t.size/2),c-t.size)}),o=!1,a=p.length;a--;)if(a>0){var g=p[a-1],d=p[a];g.pos+g.size>d.pos&&(g.size+=d.size,g.targets=g.targets.concat(d.targets),g.pos+g.size>c&&(g.pos=c-g.size),p.splice(a,1),o=!0)}a=0,p.forEach(function(n){var i=u+e/2;n.targets.forEach(function(){t[a].y=n.pos+i,i+=e,a++})}),t.forEach(function(t){var e=t.r*t.r,n=Math.pow(Math.abs(t.y-i.y),2);if(e90&&(n-=180),n<-90&&(n+=180)),n/180*Math.PI},n.getLabelAlign=function(t){var e,n=this.get("coord").getCenter();e=t.angle<=Math.PI/2&&t.x>=n.x?"left":"right";return this.getDefaultOffset(t)<=0&&(e="right"===e?"left":"right"),e},n.getArcPoint=function(t){return t},n.getPointAngle=function(t){var e=this.get("coord"),n={x:r.isArray(t.x)?t.x[0]:t.x,y:t.y[0]};this.transLabelPoint(n);var i={x:r.isArray(t.x)?t.x[1]:t.x,y:t.y[1]};this.transLabelPoint(i);var a,s=o.getPointAngle(e,n);if(t.points&&t.points[0].y===t.points[1].y)a=s;else{var l=o.getPointAngle(e,i);s>=l&&(l+=2*Math.PI),a=s+(l-s)/2}return a},n.getCirclePoint=function(t,e){var n=this.get("coord"),r=n.getCenter(),a=n.getRadius()+e,o=i(r,t,a);return o.angle=t,o.r=a,o},e}(a);t.exports=l},function(t,e,n){var i=n(0),r=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);return e.prototype.setLabelPosition=function(t,e,n,r){i.isFunction(r)&&(r=r(t.text,e._origin,n));var a=this.get("coord"),o=a.isTransposed,s=a.convertPoint(e.points[0]),l=a.convertPoint(e.points[2]),u=(s.x-l.x)/2*(o?-1:1),c=(s.y-l.y)/2*(o?-1:1);switch(r){case"right":o?(t.x-=u,t.y+=c,t.textAlign=t.textAlign||"center"):(t.x-=u,t.y+=c,t.textAlign=t.textAlign||"left");break;case"left":o?(t.x-=u,t.y-=c,t.textAlign=t.textAlign||"center"):(t.x+=u,t.y+=c,t.textAlign=t.textAlign||"right");break;case"bottom":o?(t.x-=2*u,t.textAlign=t.textAlign||"left"):(t.y+=2*c,t.textAlign=t.textAlign||"center");break;case"middle":o?t.x-=u:t.y+=c,t.textAlign=t.textAlign||"center";break;case"top":t.textAlign=o?t.textAlign||"left":t.textAlign||"center"}},e}(n(65));t.exports=r},function(t,e,n){function i(t){return t.alias||t.field}var r=n(0),a=n(7).defaultColor,o={_getIntervalSize:function(t){var e=null,n=this.get("type"),i=this.get("coord");if(i.isRect&&("interval"===n||"schema"===n)){e=this.getSize(t._origin);var a=i.isTransposed?"y":"x";if(r.isArray(t[a])){e=e(1+i.rangeMax())/2&&(r=i.rangeMin()),e=i.invert(r),i.isCategory&&(e=i.translate(e)),e},_getOriginByPoint:function(t){var e=this.getXScale(),n=this.getYScale(),i=e.field,r=n.field,a=this.get("coord").invert(t),o=e.invert(a.x),s=n.invert(a.y),l={};return l[i]=o,l[r]=s,l},_getScale:function(t){var e=this.get("scales"),n=null;return r.each(e,function(e){if(e.field===t)return n=e,!1}),n},_getTipValueScale:function(){var t,e=this.getAttrsForLegend();r.each(e,function(e){var n=e.getScale(e.type);if(n.isLinear)return t=n,!1});var n=this.getXScale(),i=this.getYScale();return!t&&i&&"..y"===i.field?n:t||i||n},_getTipTitleScale:function(t){if(t)return this._getScale(t);var e,n=this.getAttr("position").getFields();return r.each(n,function(t){if(-1===t.indexOf(".."))return e=t,!1}),this._getScale(e)},_filterValue:function(t,e){var n=this.get("coord"),i=this.getYScale(),a=i.field,o=n.invert(e).y;o=i.invert(o);var s=t[t.length-1];return r.each(t,function(t){var e=t._origin;if(e[a][0]<=o&&e[a][1]>=o)return s=t,!1}),s},getXDistance:function(){var t=this.get("xDistance");if(!t){var e=this.getXScale();if(e.isCategory)t=1;else{var n=e.values,i=e.translate(n[0]),a=i;r.each(n,function(t){(t=e.translate(t))a&&(a=t)});var o=n.length;t=(a-i)/(o-1)}this.set("xDistance",t)}return t},findPoint:function(t,e){var n=this,i=n.get("type"),a=n.getXScale(),o=n.getYScale(),s=a.field,l=o.field,u=null;if(r.indexOf(["heatmap","point"],i)>-1){var c=n.get("coord").invert(t),h=a.invert(c.x),f=o.invert(c.y),p=1/0;return r.each(e,function(t){var e=Math.pow(t._origin[s]-h,2)+Math.pow(t._origin[l]-f,2);e=v){if(!_)return u=t,!1;r.isArray(u)||(u=[]),u.push(t)}}),r.isArray(u)&&(u=this._filterValue(u,t));else{var b;if(a.isLinear||"timeCat"===a.type){if((v>a.translate(m)||va.max||vMath.abs(a.translate(b._origin[s])-v)&&(d=b)}var A=n.getXDistance();return!u&&Math.abs(a.translate(d._origin[s])-v)<=A/2&&(u=d),u},getTipTitle:function(t,e){var n="",i=this._getTipTitleScale(e);if(i){var r=t[i.field];n=i.getText(r)}else if("heatmap"===this.get("type")){var a=this.getXScale(),o=this.getYScale();n="( "+a.getText(t[a.field])+", "+o.getText(t[o.field])+" )"}return n},getTipValue:function(t,e){var n,i=e.field,a=t.key;if(n=t[i],r.isArray(n)){var o=[];r.each(n,function(t){o.push(e.getText(t))}),n=o.join("-")}else n=e.getText(n,a);return n},getTipName:function(t){var e,n,a=this._getGroupScales();if(a.length&&r.each(a,function(t){return n=t,!1}),n){var o=n.field;e=n.getText(t[o])}else{e=i(this._getTipValueScale())}return e},getTipItems:function(t,e){function n(e,n,i){if(!r.isNil(n)&&""!==n){var o={title:c,point:t,name:e||c,value:n,color:t.color||a,marker:!0};o.size=l._getIntervalSize(t),f.push(r.mix({},o,i))}}var o,s,l=this,u=t._origin,c=l.getTipTitle(u,e),h=l.get("tooltipCfg"),f=[];if(h){var p=h.fields,g=h.cfg,d=[];if(r.each(p,function(t){d.push(u[t])}),g){r.isFunction(g)&&(g=g.apply(null,d));var v=r.mix({},{point:t,title:c,color:t.color||a,marker:!0},g);v.size=l._getIntervalSize(t),f.push(v)}else r.each(p,function(t){if(!r.isNil(u[t])){var e=l._getScale(t);o=i(e),s=e.getText(u[t]),n(o,s)}})}else{var y=l._getTipValueScale();r.isNil(u[y.field])||(s=l.getTipValue(u,y),n(o=l.getTipName(u),s))}return f},isShareTooltip:function(){var t,e=this.get("shareTooltip"),n=this.get("type"),i=this.get("view");if(t=i.get("parent")?i.get("parent").get("options"):i.get("options"),"interval"===n){var a=this.get("coord"),o=a.type;("theta"===o||"polar"===o&&a.isTransposed)&&(e=!1)}else this.getYScale()&&!r.inArray(["contour","point","polygon","edge"],n)||(e=!1);return t.tooltip&&r.isBoolean(t.tooltip.shared)&&(e=t.tooltip.shared),e}};t.exports=o},function(t,e,n){function i(t,e){if(!t)return!0;if(t.length!==e.length)return!0;var n=!1;return a.each(e,function(e,i){if(!function(t,e){if(a.isNil(t)||a.isNil(e))return!1;var n=t.get("origin"),i=e.get("origin");return a.isEqual(n,i)}(e,t[i]))return n=!0,!1}),n}function r(t,e){var n={};return a.each(t,function(t,i){var r=e.attr(i);a.isArray(r)&&(r=a.cloneDeep(r)),n[i]=r}),n}var a=n(0),o={_isAllowActive:function(){var t=this.get("allowActive");if(!a.isNil(t))return t;var e=this.get("view"),n=this.isShareTooltip();return!1===e.get("options").tooltip||!n},_onMouseenter:function(t){var e=t.shape,n=this.get("shapeContainer");e&&n.contain(e)&&this._isAllowActive()&&this.setShapesActived(e)},_onMouseleave:function(){var t=this.get("view").get("canvas");this.get("activeShapes")&&(this.clearActivedShapes(),t.draw())},_bindActiveAction:function(){var t=this.get("view"),e=this.get("type");t.on(e+":mouseenter",a.wrapBehavior(this,"_onMouseenter")),t.on(e+":mouseleave",a.wrapBehavior(this,"_onMouseleave"))},_offActiveAction:function(){var t=this.get("view"),e=this.get("type");t.off(e+":mouseenter",a.getWrapBehavior(this,"_onMouseenter")),t.off(e+":mouseleave",a.getWrapBehavior(this,"_onMouseleave"))},_setActiveShape:function(t){var e=this.get("activedOptions")||{},n=t.get("origin"),i=n.shape||this.getDefaultValue("shape");a.isArray(i)&&(i=i[0]);var o=this.get("shapeFactory"),s=a.mix({},t.attr(),{origin:n}),l=o.getActiveCfg(i,s);e.style&&a.mix(l,e.style);var u=r(l,t);t.setSilent("_originAttrs",u),e.animate?t.animate(l,300):t.attr(l),t.set("zIndex",1)},setShapesActived:function(t){var e=this;a.isArray(t)||(t=[t]);var n=e.get("activeShapes");if(i(n,t)){var r=e.get("view").get("canvas"),o=e.get("shapeContainer"),s=e.get("activedOptions");s&&s.highlight?(a.each(t,function(t){t.get("animating")&&t.stopAnimate()}),e.highlightShapes(t)):(n&&e.clearActivedShapes(),a.each(t,function(t){t.get("animating")&&t.stopAnimate(),t.get("visible")&&!t.get("selected")&&e._setActiveShape(t)})),e.set("activeShapes",t),o.sort(),r.draw()}},clearActivedShapes:function(){var t=this.get("shapeContainer"),e=this.get("activedOptions"),n=e&&e.animate;if(t&&!t.get("destroyed")){var i=this.get("activeShapes");a.each(i,function(t){if(!t.get("selected")){var e=t.get("_originAttrs");n?(t.stopAnimate(),t.animate(e,300)):t.attr(e),t.setZIndex(0),t.set("_originAttrs",null)}});if(this.get("preHighlightShapes")){var r=t.get("children");a.each(r,function(t){if(!t.get("selected")){var e=t.get("_originAttrs");e&&(n?(t.stopAnimate(),t.animate(e,300)):t.attr(e),t.setZIndex(0),t.set("_originAttrs",null))}})}t.get("children").sort(function(t,e){return t._INDEX-e._INDEX}),this.set("activeShapes",null),this.set("preHighlightShapes",null)}},getGroupShapesByPoint:function(t){var e=[];if(this.get("shapeContainer")){var n=this.getXScale().field,i=this.getShapes(),r=this._getOriginByPoint(t);a.each(i,function(t){var i=t.get("origin");if(t.get("visible")&&i){i._origin[n]===r[n]&&e.push(t)}})}return e},getSingleShapeByPoint:function(t){var e,n=this.get("shapeContainer"),i=n.get("canvas").get("pixelRatio");if(n&&(e=n.getShape(t.x*i,t.y*i)),e&&e.get("origin"))return e},highlightShapes:function(t,e){a.isArray(t)||(t=[t]);var n=this.get("activeShapes");if(i(n,t)){n&&this.clearActivedShapes();var o=this.getShapes(),s=this.get("activedOptions"),l=s&&s.animate,u=s&&s.style;a.each(o,function(n){var i={};n.stopAnimate(),-1!==a.indexOf(t,n)?(a.mix(i,u,e),n.setZIndex(1)):(a.mix(i,{fillOpacity:.3,opacity:.3}),n.setZIndex(0));var o=r(i,n);n.setSilent("_originAttrs",o),l?n.animate(i,300):n.attr(i)}),this.set("preHighlightShapes",t),this.set("activeShapes",t)}}};t.exports=o},function(t,e,n){function i(t,e){if(r.isNil(t)||r.isNil(e))return!1;var n=t.get("origin"),i=e.get("origin");return r.isEqual(n,i)}var r=n(0),a={_isAllowSelect:function(){var t=this.get("allowSelect");if(!r.isNil(t))return t;var e=this.get("type"),n=this.get("coord"),i=n&&n.type;return"interval"===e&&"theta"===i},_onClick:function(t){if(this._isAllowSelect()){this.clearActivedShapes();var e=t.shape,n=this.get("shapeContainer");e&&!e.get("animating")&&n.contain(e)&&this.setShapeSelected(e)}},_bindSelectedAction:function(){var t=this.get("view"),e=this.get("type");t.on(e+":click",r.wrapBehavior(this,"_onClick"))},_offSelectedAction:function(){var t=this.get("view"),e=this.get("type");t.off(e+":click",r.getWrapBehavior(this,"_onClick"))},_setShapeStatus:function(t,e){var n=this.get("view"),i=this.get("selectedOptions")||{},a=!1!==i.animate,o=n.get("canvas");t.set("selected",e);var s=t.get("origin");if(e){var l=s.shape||this.getDefaultValue("shape");r.isArray(l)&&(l=l[0]);var u=this.get("shapeFactory"),c=r.mix({geom:this,point:s},i),h=u.getSelectedCfg(l,c);r.mix(h,c.style),t.get("_originAttrs")||(t.get("animating")&&t.stopAnimate(),t.set("_originAttrs",function(t,e){var n={};return r.each(t,function(t,i){"transform"===i&&(i="matrix");var a=e.attr(i);r.isArray(a)&&(a=r.cloneDeep(a)),n[i]=a}),n}(h,t))),a?t.animate(h,300):(t.attr(h),o.draw())}else{var f=t.get("_originAttrs");t.set("_originAttrs",null),a?t.animate(f,300):(t.attr(f),o.draw())}},setShapeSelected:function(t){var e=this._getSelectedShapes(),n=this.get("selectedOptions")||{},a=!1!==n.cancelable;if("multiple"===n.mode)-1===r.indexOf(e,t)?(e.push(t),this._setShapeStatus(t,!0)):a&&(r.Array.remove(e,t),this._setShapeStatus(t,!1));else{var o=e[0];a&&(t=i(o,t)?null:t),i(o,t)||(o&&this._setShapeStatus(o,!1),t&&this._setShapeStatus(t,!0))}},clearSelected:function(){var t=this,e=t.get("shapeContainer");if(e&&!e.get("destroyed")){var n=t._getSelectedShapes();r.each(n,function(e){t._setShapeStatus(e,!1),e.set("_originAttrs",null)})}},setSelected:function(t){var e=this,n=e.getShapes();return r.each(n,function(n){var i=n.get("origin");i&&i._origin===t&&e.setShapeSelected(n)}),this},_getSelectedShapes:function(){var t=this.getShapes(),e=[];return r.each(t,function(t){t.get("selected")&&e.push(t)}),this.set("selectedShapes",e),e}};t.exports=a},function(t,e,n){var i=n(0);t.exports=function(t){return i.isArray(t)?t:i.isString(t)?t.split("*"):[t]}},function(t,e,n){var i=n(74),r=n(0),a=/^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/,o={LINEAR:"linear",CAT:"cat",TIME:"time"},s=function(){function t(t){this.defs={},this.viewTheme={scales:{}},this.filters={},r.assign(this,t)}var e=t.prototype;return e._getDef=function(t){var e=this.defs,n=this.viewTheme,i=null;return(n.scales[t]||e[t])&&(i=r.mix({},n.scales[t]),r.each(e[t],function(t,e){r.isNil(t)?delete i[e]:i[e]=t}),this.filters[t]&&(delete i.min,delete i.max)),i},e._getDefaultType=function(t,e){var n=o.LINEAR,i=r.Array.firstValue(e,t);return r.isArray(i)&&(i=i[0]),a.test(i)?n=o.TIME:r.isString(i)&&(n=o.CAT),n},e._getScaleCfg=function(t,e,n){var a={field:e},o=r.Array.values(n,e);if(a.values=o,!i.isCategory(t)&&"time"!==t){var s=r.Array.getRange(o);a.min=s.min,a.max=s.max,a.nice=!0}return"time"===t&&(a.nice=!1),a},e.createScale=function(t,e){var n,a=this._getDef(t);if(!e||!e.length)return n=a&&a.type?i[a.type](a):i.identity({value:t,field:t.toString(),values:[t]});var o=r.Array.firstValue(e,t);if(r.isNumber(t)||r.isNil(o)&&!a)n=i.identity({value:t,field:t.toString(),values:[t]});else{var s;a&&(s=a.type),s=s||this._getDefaultType(t,e);var l=this._getScaleCfg(s,t,e);a&&r.mix(l,a),n=i[s](l)}return n},t}();t.exports=s},function(t,e,n){var i=n(0),r=n(343),a=function(){function t(t){this.type="rect",this.actions=[],this.cfg={},i.mix(this,t),this.option=t||{}}var e=t.prototype;return e.reset=function(t){return this.actions=t.actions||[],this.type=t.type,this.cfg=t.cfg,this.option.actions=this.actions,this.option.type=this.type,this.option.cfg=this.cfg,this},e._execActions=function(t){var e=this.actions;i.each(e,function(e){var n=e[0];t[n](e[1],e[2])})},e.hasAction=function(t){var e=this.actions,n=!1;return i.each(e,function(e){if(t===e[0])return n=!0,!1}),n},e.createCoord=function(t,e){var n,a,o=this.type,s=this.cfg,l=i.mix({start:t,end:e},s);return"theta"===o?(n=r.Polar,this.hasAction("transpose")||this.transpose(),(a=new n(l)).type=o):a=new(n=r[i.upperFirst(o||"")]||r.Rect)(l),this._execActions(a),a},e.rotate=function(t){return t=t*Math.PI/180,this.actions.push(["rotate",t]),this},e.reflect=function(t){return this.actions.push(["reflect",t]),this},e.scale=function(t,e){return this.actions.push(["scale",t,e]),this},e.transpose=function(){return this.actions.push(["transpose"]),this},t}();t.exports=a},function(t,e,n){"use strict";var i=n(44);i.Cartesian=n(344),i.Rect=i.Cartesian,i.Polar=n(345),i.Helix=n(346),t.exports=i},function(t,e,n){"use strict";function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){return!e||"object"!==i(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function a(t,e){for(var n=0;nf/l?(a=f/l,o={x:n.x-(.5-c)*f,y:n.y-(.5-h)*a*u}):(a=p/u,o={x:n.x-(.5-c)*a*l,y:n.y-(.5-h)*p}),t?t>0&&t<=1?t*=a:(t<=0||t>a)&&(t=a):t=a;var g={start:i,end:r},d={start:e*t,end:t};this.x=g,this.y=d,this.radius=t,this.circleCentre=o,this.center=o}},{key:"getCenter",value:function(){return this.circleCentre}},{key:"getOneBox",value:function(){var t=this.startAngle,e=this.endAngle;if(Math.abs(e-t)>=2*Math.PI)return{minX:-1,maxX:1,minY:-1,maxY:1};for(var n=[0,Math.cos(t),Math.cos(e)],i=[0,Math.sin(t),Math.sin(e)],r=Math.min(t,e);r0?l:-l;var u=this.invertDim(s,"y"),c={};return c.x=this.isTransposed?u:l,c.y=this.isTransposed?l:u,c}}]),e}();t.exports=y},function(t,e,n){"use strict";function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){return!e||"object"!==i(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function a(t,e){for(var n=0;n=0&&n<=1&&(s*=n);var l=Math.floor(s*(1-i)/o),u=l/(2*Math.PI),c={start:r,end:a},h={start:i*s,end:i*s+.99*l};this.a=u,this.d=l,this.x=c,this.y=h}},{key:"getCenter",value:function(){return this.center}},{key:"convertPoint",value:function(t){var e,n,i=this.a,r=this.center;this.isTransposed?(e=t.y,n=t.x):(e=t.x,n=t.y);var a=this.convertDim(e,"x"),o=i*a,s=this.convertDim(n,"y");return{x:r.x+Math.cos(a)*(o+s),y:r.y+Math.sin(a)*(o+s)}}},{key:"invertPoint",value:function(t){var e=this.center,n=this.a,i=this.d+this.y.start,r=g.subtract([],[t.x,t.y],[e.x,e.y]),a=g.angleTo(r,[1,0],!0),o=a*n;g.length(r)u.x||!o&&s.y>u.y?1:-1,{isVertical:o,factor:r,start:s,end:l}},e._getCircleCfg=function(t){var e,n={},i=t.x,r=t.y,a=r.start>r.end;e=t.isTransposed?{x:a?0:1,y:0}:{x:0,y:a?0:1},e=t.convert(e);var s,l=t.circleCentre,u=[e.x-l.x,e.y-l.y],c=[1,0],h=(s=e.y>l.y?o.angle(u,c):-1*o.angle(u,c))+(i.end-i.start);return n.startAngle=s,n.endAngle=h,n.center=l,n.radius=Math.sqrt(Math.pow(e.x-l.x,2)+Math.pow(e.y-l.y,2)),n.inner=t.innerRadius||0,n},e._getRadiusCfg=function(t){var e,n,i=t.x.start<0?-1:1;return t.isTransposed?(e={x:0,y:0},n={x:1,y:0}):(e={x:0,y:0},n={x:0,y:1}),{factor:i,start:t.convert(e),end:t.convert(n)}},e._getAxisPosition=function(t,e,n,i){var r="",a=this.options;if(a[i]&&a[i].position)r=a[i].position;else{var o=t.type;t.isRect?"x"===e?r="bottom":"y"===e&&(r=n?"right":"left"):r="helix"===o?"helix":"x"===e?t.isTransposed?"radius":"circle":t.isTransposed?"circle":"radius"}return r},e._getAxisDefaultCfg=function(t,e,n,i){var a=this.viewTheme,o={},s=this.options,l=e.field;if(o=r.deepMix({},a.axis[i],o,s[l]),o.viewTheme=a,o.title){var u=r.isPlainObject(o.title)?o.title:{};u.text=u.text||e.alias||l,r.deepMix(o,{title:u})}return o.ticks=e.getTicks(),t.isPolar&&!e.isCategory&&"x"===n&&Math.abs(t.endAngle-t.startAngle)===2*Math.PI&&o.ticks.pop(),o.coord=t,o.label&&r.isNil(o.label.autoRotate)&&(o.label.autoRotate=!0),s.hasOwnProperty("xField")&&s.xField.hasOwnProperty("grid")&&"left"===o.position&&r.deepMix(o,s.xField),o},e._getAxisCfg=function(t,e,n,i,a,o){void 0===a&&(a="");var s=this,l=s._getAxisPosition(t,i,a,e.field),u=s._getAxisDefaultCfg(t,e,i,l);if(!r.isEmpty(u.grid)&&n){var c=[],h=[],f=function(t){var e=[];if(t.length>0){var n=(e=t.slice(0))[0],i=e[e.length-1];0!==n.value&&e.unshift({value:0}),1!==i.value&&e.push({value:1})}return e}(n.getTicks());if(f.length){var p=function(t,e,n){var i=[];return t.length<1?i:(t.length>=2&&e&&n&&i.push({text:"",tickValue:"",value:0}),0!==t[0].value&&i.push({text:"",tickValue:"",value:0}),1!==(i=i.concat(t))[i.length-1].value&&i.push({text:"",tickValue:"",value:1}),i)}(u.ticks,e.isLinear,"center"===u.grid.align);r.each(p,function(n,l){h.push(n.tickValue);var g=[],d=n.value;if("center"===u.grid.align&&(d=s._getMiddleValue(d,p,l,e.isLinear)),!r.isNil(d)){var v=t.x,y=t.y;r.each(f,function(e){var n="x"===i?d:e.value,r="x"===i?e.value:d,a=t.convert({x:n,y:r});if(t.isPolar){var o=t.circleCentre;y.start>y.end&&(r=1-r),a.flag=v.start>v.end?0:1,a.radius=Math.sqrt(Math.pow(a.x-o.x,2)+Math.pow(a.y-o.y,2))}g.push(a)}),c.push({_id:o+"-"+i+a+"-grid-"+n.tickValue,points:g})}})}u.grid.items=c,u.grid.tickValues=h}return u.type=e.type,u},e._getHelixCfg=function(t){for(var e={},n=t.a,i=t.startAngle,r=t.endAngle,a=[],o=0;o<=100;o++){var s=t.convert({x:o/100,y:0});a.push(s.x),a.push(s.y)}var l=t.convert({x:0,y:0});return e.a=n,e.startAngle=i,e.endAngle=r,e.crp=a,e.axisStart=l,e.center=t.center,e.inner=t.y.start,e},e._drawAxis=function(t,e,n,i,o,s,l){var u,c,h=this.container,f=this.canvas;"cartesian"===t.type?(u=a.Line,c=this._getLineCfg(t,e,i,l)):"helix"===t.type&&"x"===i?(u=a.Helix,c=this._getHelixCfg(t)):"x"===i?(u=a.Circle,c=this._getCircleCfg(t)):(u=a.Line,c=this._getRadiusCfg(t));var p=this._getAxisCfg(t,e,n,i,l,o);p=r.mix({},p,c),"y"===i&&s&&"circle"===s.get("type")&&(p.circle=s),p._id=o+"-"+i,r.isNil(l)||(p._id=o+"-"+i+l),r.mix(p,{canvas:f,group:h});var g=new u(p);return g.render(),this.axes.push(g),g},e.createAxis=function(t,e,n){var i=this,a=this.coord,o=a.type;if("theta"!==o&&("polar"!==o||!a.isTransposed)){var s;t&&!i._isHide(t.field)&&(s=i._drawAxis(a,t,e[0],"x",n)),r.isEmpty(e)||"helix"===o||r.each(e,function(e,r){i._isHide(e.field)||i._drawAxis(a,e,t,"y",n,s,r)})}},e.changeVisible=function(t){var e=this.axes;r.each(e,function(e){e.set("visible",t)})},e.clear=function(){var t=this.axes;r.each(t,function(t){t.clear()}),this.axes=[]},t}();t.exports=s},function(t,e,n){var i=n(0),r=n(349),a=function(){function t(t){this.guides=[],this.options=[],this.xScales=null,this.yScales=null,this.view=null,this.viewTheme=null,this.frontGroup=null,this.backGroup=null,i.mix(this,t)}var e=t.prototype;return e._creatGuides=function(){var t=this,e=this.options,n=this.xScales,a=this.yScales,o=this.view,s=this.viewTheme;return this.backContainer&&o&&(this.backGroup=this.backContainer.addGroup({viewId:o.get("_id")})),this.frontContainer&&o&&(this.frontGroup=this.frontContainer.addGroup({viewId:o.get("_id")})),e.forEach(function(e){var o=e.type,l=i.deepMix({xScales:n,yScales:a,viewTheme:s},s?s.guide[o]:{},e);o=i.upperFirst(o);var u=new r[o](l);t.guides.push(u)}),t.guides},e.line=function(t){return void 0===t&&(t={}),this.options.push(i.mix({type:"line"},t)),this},e.arc=function(t){return void 0===t&&(t={}),this.options.push(i.mix({type:"arc"},t)),this},e.text=function(t){return void 0===t&&(t={}),this.options.push(i.mix({type:"text"},t)),this},e.image=function(t){return void 0===t&&(t={}),this.options.push(i.mix({type:"image"},t)),this},e.region=function(t){return void 0===t&&(t={}),this.options.push(i.mix({type:"region"},t)),this},e.regionFilter=function(t){return void 0===t&&(t={}),this.options.push(i.mix({type:"regionFilter"},t)),this},e.dataMarker=function(t){return void 0===t&&(t={}),this.options.push(i.mix({type:"dataMarker"},t)),this},e.dataRegion=function(t){return void 0===t&&(t={}),this.options.push(i.mix({type:"dataRegion"},t)),this},e.html=function(t){return void 0===t&&(t={}),this.options.push(i.mix({type:"html"},t)),this},e.render=function(t){var e=this,n=e.view,r=n&&n.get("data"),a=e._creatGuides();i.each(a,function(i){var a;a=i.get("top")?e.frontGroup||e.frontContainer:e.backGroup||e.backContainer,i.render(t,a,r,n)})},e.clear=function(){this.options=[],this.reset()},e.changeVisible=function(t){var e=this.guides;i.each(e,function(e){e.changeVisible(t)})},e.reset=function(){var t=this.guides;i.each(t,function(t){t.clear()}),this.guides=[],this.backGroup&&this.backGroup.remove(),this.frontGroup&&this.frontGroup.remove()},t}();t.exports=a},function(t,e,n){var i=n(21).Guide,r=n(350);i.RegionFilter=r,t.exports=i},function(t,e,n){var i=n(0),r=n(15),a=n(25).Path,o=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return i.mix({},e,{name:"regionFilter",zIndex:1,top:!0,start:null,end:null,color:null,apply:null,style:{opacity:1}})},n.render=function(t,e,n,i){var r=this,a=e.addGroup();a.name="guide-region-filter",i.once("afterpaint",function(){if(!a.get("destroyed")){r._drawShapes(i,a);var e=r._drawClip(t);a.attr({clip:e}),r.set("clip",e),r.get("appendInfo")&&a.setSilent("appendInfo",r.get("appendInfo")),r.set("el",a)}})},n._drawShapes=function(t,e){var n=this,r=[];return t.getAllGeoms().map(function(t){var a=t.getShapes(),o=t.get("type");return n._geomFilter(o)&&a.map(function(t){var a=t.type,o=i.cloneDeep(t.attr());n._adjustDisplay(o);var s=e.addShape(a,{attrs:o});return r.push(s),t}),t}),r},n._drawClip=function(t){var e=this.parsePoint(t,this.get("start")),n=this.parsePoint(t,this.get("end")),i=[["M",e.x,e.y],["L",n.x,e.y],["L",n.x,n.y],["L",e.x,n.y],["z"]];return new a({attrs:{path:i,opacity:1}})},n._adjustDisplay=function(t){var e=this.get("color");t.fill&&(t.fill=t.fillStyle=e),t.stroke=t.strokeStyle=e},n._geomFilter=function(t){var e=this.get("apply");return!e||i.contains(e,t)},n.clear=function(){t.prototype.clear.call(this);var e=this.get("clip");e&&e.remove()},e}(r);t.exports=o},function(t,e,n){var i=n(0),r=n(21).Legend,a=n(352),o=n(18),s=n(166),l=n(168),u=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,c=function(){function t(t){this.options={},i.mix(this,t),this.clear();var e=this.chart;this.container=e.get("frontPlot"),this.plotRange=e.get("plotRange")}var e=t.prototype;return e.clear=function(){var t=this.legends;this.backRange=null,i.each(t,function(t){i.each(t,function(t){t.destroy()})}),this.legends={}},e.getBackRange=function(){var t=this.backRange;if(!t){var e=this.chart.get("backPlot");t=s(e,l(this.chart.get("plotRange")));var n=this.plotRange;t.maxX-t.minX0){var a=e.getXScale(),o=e.getYScale(),s=a.field,l=o.field,u=t.get("origin")._origin,c=e.get("labelContainer").get("labelsGroup").get("children");i.each(c,function(e){var i=e.get("origin")||[];i[s]===u[s]&&i[l]===u[l]&&(e.set("visible",n),t.set("gLabel",e))})}}},e._bindFilterEvent=function(t,e){var n=this,r=this.chart,a=e.field;t.on("itemfilter",function(t){var e=t.range;r.filterShape(function(t,r,o){if(!i.isNil(t[a])){var s=t[a]>=e[0]&&t[a]<=e[1];return n._filterLabels(r,o,s),s}return!0});for(var o=r.getAllGeoms()||[],s=function(t){var n=o[t];"heatmap"===n.get("type")&&u(function(){n.drawWithRange(e)})},l=0;l1?l:n;if("left"===x[0]||"right"===x[0])s=u.br.y,m=this._getXAlign(x[0],o,n,c,g,d),_=e?e.get("group").get("y")+e.getHeight()+v:this._getYAlignVertical(x[1],s,b,c,0,d,a.get("height"));else if("top"===x[0]||"bottom"===x[0])if(_=this._getYAlignHorizontal(x[0],s,n,c,p,d),e){var w=e.getWidth();m=e.get("group").get("x")+w+v}else m=this._getXAlign(x[1],o,b,c,0,d),"right"===x[1]&&(m=u.br.x-b.totalWidth);t.move(m+h,_+f)},e._getXAlign=function(t,e,n,i,r,a){var o="left"===t?i.minX-r-a[3]:i.maxX+a[1];return"center"===t&&(o=(e-n.totalWidth)/2),o},e._getYAlignHorizontal=function(t,e,n,i,r,a){return"top"===t?i.minY-r-a[0]:i.maxY+a[2]},e._getYAlignVertical=function(t,e,n,i,r,a,o){var s="top"===t?i.minY-r-a[0]:e-n.totalHeight;return"center"===t&&(s=(o-n.totalHeight)/2),s},e._getSubRegion=function(t){var e=0,n=0,r=0,a=0;return i.each(t,function(t){var i=t.getWidth(),o=t.getHeight();e1){var g=Array(f.callback.length-1).fill("");c.color=f.mapping.apply(f,[l].concat(g)).join("")||b.defaultColor}else c.color=f.mapping(l).join("")||b.defaultColor;if(y&&p)if(p.callback&&p.callback.length>1){var v=Array(p.callback.length-1).fill("");m=p.mapping.apply(p,[l].concat(v)).join("")}else m=p.mapping(l).join("");var _=o.getShapeFactory(x).getMarkerCfg(m,c);i.isFunction(m)&&(_.symbol=m),d.push({value:r,dataValue:l,checked:h,marker:_})});var A=i.deepMix({},b.legend[M[0]],h[c]||h,{viewId:_.get("_id"),maxLength:C,items:d,container:g,position:[0,0]});A.title&&i.deepMix(A,{title:{text:t.alias||t.field}});var k;if(u._isTailLegend(h,n))A.chart=u.chart,A.geom=n,k=new a(A);else if(h.useHtml){var P=g.get("canvas").get("el");if(g=h.container,i.isString(g)&&/^\#/.test(g)){var T=g.replace("#","");g=document.getElementById(T)}g||(g=P.parentNode),A.container=g,void 0===A.legendStyle&&(A.legendStyle={}),A.legendStyle.CONTAINER_CLASS={position:"absolute",overflow:"auto","z-index":""===P.style.zIndex?1:parseInt(P.style.zIndex,10)+1},h.flipPage?(A.legendStyle.CONTAINER_CLASS.height="right"===M[0]||"left"===M[0]?C+"px":"auto",A.legendStyle.CONTAINER_CLASS.width="right"!==M[0]&&"left"!==M[0]?C+"px":"auto",k=new r.CatPageHtml(A)):k=new r.CatHtml(A)}else k=new r.Category(A);return u._bindClickEvent(k,t,s),p[l].push(k),k},e._bindChartMove=function(t){var e=this.chart,n=this.legends;e.on("plotmove",function(e){var r=!1;if(e.target){var a=e.target.get("origin");if(a){var o=a._origin||a[0]._origin,s=t.field;if(o){var l=o[s];i.each(n,function(t){i.each(t,function(t){r=!0,!t.destroyed&&t.activate(l)})})}}}r||i.each(n,function(t){i.each(t,function(t){!t.destroyed&&t.deactivate()})})})},e._addContinuousLegend=function(t,e,n){var a=this.legends;a[n]=a[n]||[];var o,s,l,u=this.container,c=t.field,h=t.getTicks(),f=[],p=this.viewTheme;i.each(h,function(n){var i=n.value,r=t.invert(i),a=e.mapping(r).join("");f.push({value:n.tickValue,attrValue:a,color:a,scaleValue:i}),0===i&&(s=!0),1===i&&(l=!0)}),s||f.push({value:t.min,attrValue:e.mapping(0).join(""),color:e.mapping(0).join(""),scaleValue:0}),l||f.push({value:t.max,attrValue:e.mapping(1).join(""),color:e.mapping(1).join(""),scaleValue:1});var g=this.options,d=n.split("-"),v=p.legend[d[0]];(g&&!1===g.slidable||g[c]&&!1===g[c].slidable)&&(v=i.mix({},v,p.legend.gradient));var y=i.deepMix({},v,g[c]||g,{items:f,attr:e,formatter:t.formatter,container:u,position:[0,0]});if(y.title&&i.deepMix(y,{title:{text:t.alias||t.field}}),"color"===e.type)o=new r.Color(y);else{if("size"!==e.type)return;o=g&&"circle"===g.sizeType?new r.CircleSize(y):new r.Size(y)}return this._bindFilterEvent(o,t),a[n].push(o),o},e._isTailLegend=function(t,e){if(t.hasOwnProperty("attachLast")&&t.attachLast){var n=e.get("type");if("line"===n||"lineStack"===n||"area"===n||"areaStack"===n)return!0}return!1},e._adjustPosition=function(t,e){var n;if(e)n="right-top";else if(i.isArray(t))n=String(t[0])+"-"+String(t[1]);else{var r=t.split("-");1===r.length?("left"===r[0]&&(n="left-bottom"),"right"===r[0]&&(n="right-bottom"),"top"===r[0]&&(n="top-center"),"bottom"===r[0]&&(n="bottom-center")):n=t}return n},e.addLegend=function(t,e,n,i){var r=this.options,a=t.field,o=r[a],s=this.viewTheme;if(!1===o)return null;if(o&&o.custom)this.addCustomLegend(a);else{var l=r.position||s.defaultLegendPosition;l=this._adjustPosition(l,this._isTailLegend(r,n)),o&&o.position&&(l=this._adjustPosition(o.position,this._isTailLegend(o,n)));var u;(u=t.isLinear?this._addContinuousLegend(t,e,l):this._addCategoryLegend(t,e,n,i,l))&&(this._bindHoverEvent(u,a),r.reactive&&this._bindChartMove(t))}},e.addCustomLegend=function(t){var e=this.chart,n=this.viewTheme,a=this.container,o=this.options;t&&(o=o[t]);var s=o.position||n.defaultLegendPosition;s=this._adjustPosition(s);var l=this.legends;l[s]=l[s]||[];var u=o.items;if(u){var c=e.getAllGeoms();i.each(u,function(t){var e=function(t,e){var n;return i.each(t,function(t){t.get("visible")&&t.getYScale().field===e&&(n=t)}),n}(c,t.value);i.isObject(t.marker)?t.marker.radius=t.marker.radius||4.5:t.marker={symbol:t.marker?t.marker:"circle",fill:t.fill,radius:4.5},t.checked=!!i.isNil(t.checked)||t.checked,t.geom=e});var h,f=e.get("canvas"),p=this.plotRange,g=s.split("-"),d="right"===g[0]||"left"===g[0]?p.bl.y-p.tr.y:f.get("width"),v=i.deepMix({},n.legend[g[0]],o,{maxLength:d,items:u,container:a,position:[0,0]});if(o.useHtml){var y=o.container;if(/^\#/.test(a)){var x=y.replace("#","");y=document.getElementById(x)}else y||(y=a.get("canvas").get("el").parentNode);v.container=y,void 0===v.legendStyle&&(v.legendStyle={}),v.legendStyle.CONTAINER_CLASS||(v.legendStyle.CONTAINER_CLASS={height:"right"===g[0]||"left"===g[0]?d+"px":"auto",width:"right"!==g[0]&&"left"!==g[0]?d+"px":"auto",position:"absolute",overflow:"auto"}),h=o.flipPage?new r.CatPageHtml(v):new r.CatHtml(v)}else h=new r.Category(v);return l[s].push(h),h.on("itemclick",function(t){o.onClick&&o.onClick(t)}),this._bindHoverEvent(h),h}},e.addMixedLegend=function(t,e){var n=[];i.each(t,function(t){var r=t.field;i.each(e,function(e){if(e.getYScale()===t&&t.values&&t.values.length>0){var i=e.get("shapeType")||"point",a=e.getDefaultValue("shape")||"circle",s=o.getShapeFactory(i),l={color:e.getDefaultValue("color")},u=s.getMarkerCfg(a,l),c={value:r,marker:u};n.push(c)}})});var r={custom:!0,items:n};this.options=i.deepMix({},r,this.options);var a=this.addCustomLegend();this._bindClickEventForMix(a)},e.alignLegends=function(){var t=this,e=t.legends,n=t._getRegion(e);t.totalRegion=n;var r=0;return i.each(e,function(e,a){var o=n.subs[r];i.each(e,function(n,i){var r=e[i-1];n.get("useHtml")&&!n.get("autoPosition")||t._alignLegend(n,r,o,a)}),r++}),this},t}();t.exports=c},function(t,e,n){var i=n(0),r=n(21),a=n(7),o=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return i.mix({},e,{type:"tail-legend",layout:"vertical",autoLayout:!0})},n._addItem=function(t){var e=this.get("itemsGroup"),n=this._getNextX(),r=this.get("unCheckColor"),a=e.addGroup({x:0,y:0,value:t.value,scaleValue:t.scaleValue,checked:t.checked});a.translate(n,0),a.set("viewId",e.get("viewId"));var o=this.get("textStyle"),s=this.get("_wordSpaceing"),l=0;if(t.marker){var u=i.mix({},t.marker,{x:t.marker.radius,y:0});t.checked||(u.fill&&(u.fill=r),u.stroke&&(u.stroke=r));var c=a.addShape("marker",{type:"marker",attrs:u});c.attr("cursor","pointer"),c.name="legend-marker",l+=c.getBBox().width+s}var h=i.mix({},o,{x:l,y:0,text:this._formatItemValue(t.value)});t.checked||i.mix(h,{fill:r});var f=a.addShape("text",{attrs:h});f.attr("cursor","pointer"),f.name="legend-text",this.get("appendInfo")&&f.setSilent("appendInfo",this.get("appendInfo"));var p=a.getBBox(),g=this.get("itemWidth"),d=a.addShape("rect",{attrs:{x:n,y:0-p.height/2,fill:"#fff",fillOpacity:0,width:g||p.width,height:p.height}});return d.attr("cursor","pointer"),d.setSilent("origin",t),d.name="legend-item",this.get("appendInfo")&&d.setSilent("appendInfo",this.get("appendInfo")),a.name="legendGroup",a},n._adjust=function(){if(this.get("geom")){this.get("group").attr("matrix")[7]=0;var t=this.get("geom").get("dataArray"),e=this.get("itemsGroup").get("children"),n=0;i.each(e,function(e){var r=t[n],a=r[r.length-1].y;i.isArray(a)&&(a=a[1]);var o=e.getBBox().height,s=e.get("x"),l=a-o/2;e.translate(s,l),n++}),this.get("autoLayout")&&this._antiCollision(e)}},n.render=function(){var e=this;t.prototype.render.call(this);this.get("chart").once("afterpaint",function(){e._adjust()})},n._getPreviousY=function(t){return t.attr("matrix")[7]+t.getBBox().height},n._adjustDenote=function(t,e,n){var i=2*-a.legend.legendMargin;t.addShape("path",{attrs:{path:"M-2,"+e+"L"+i+","+(n+3),lineWidth:1,lineDash:[2,2],stroke:"#999999"}})},n._antiCollision=function(t){var e=this;t.sort(function(t,e){return t.attr("matrix")[7]-e.attr("matrix")[7]});var n=!0,i=e.get("chart").get("plotRange"),r=i.tl.y,a=Math.abs(r-i.bl.y),o=t[0].getBBox().height,s=Number.MIN_VALUE,l=0,u=t.map(function(t){var e=t.attr("matrix")[7];return e>l&&(l=e),e0){var g=u[c-1],d=u[c];g.pos+g.size>d.pos&&(g.size+=d.size,g.targets=g.targets.concat(d.targets),u.splice(c,1),n=!0)}}c=0;var v=this.get("itemsGroup").addGroup();u.forEach(function(n){var i=r+o;n.targets.forEach(function(){var r=t[c].attr("matrix")[7],a=n.pos+i-o/2;Math.abs(r-a)>o/2&&e._adjustDenote(v,a,r-e.get("group").attr("matrix")[7]/2),t[c].translate(0,-r),t[c].translate(0,a),i+=o,c++})})},e}(r.Legend.Category);t.exports=o},function(t,e,n){function i(t,e){if(!t)return!1;return!!t.className&&-1!==(a.isNil(t.className.baseVal)?t.className:t.className.baseVal).indexOf(e)}function r(t){var e=[];return a.each(t,function(t){var n=function(t,e){var n=-1;return a.each(t,function(t,i){var r=!0;for(var o in e)if(e.hasOwnProperty(o)&&-1===h.indexOf(o)&&!a.isObject(e[o])&&e[o]!==t[o]){r=!1;break}if(r)return n=i,!1}),n}(e,t);-1===n?e.push(t):e[n]=t}),e}var a=n(0),o=n(18),s=n(21).Tooltip,l=a.MatrixUtil.vec2,u=["line","area","path","areaStack"],c=["line","area"],h=["marker","showMarker"],f=function(){function t(t){a.assign(this,t),this.timeStamp=0}var e=t.prototype;return e._normalizeEvent=function(t){var e=this.chart,n=this._getCanvas(),i=n.getPointByClient(t.clientX,t.clientY),r=n.get("pixelRatio");i.x=i.x/r,i.y=i.y/r;var a=e.getViewsByPoint(i);return i.views=a,i},e._getCanvas=function(){return this.chart.get("canvas")},e._getTriggerEvent=function(){var t,e=this.options.triggerOn;return e&&"mousemove"!==e?"click"===e?t="plotclick":"none"===e&&(t=null):t="plotmove",t},e._getDefaultTooltipCfg=function(){var t=this.chart,e=this.viewTheme,n=this.options,i=a.mix({},e.tooltip),r=t.getAllGeoms().filter(function(t){return t.get("visible")}),o=[];a.each(r,function(t){var e=t.get("type"),n=t.get("adjusts"),i=!1;n&&a.each(n,function(t){if("symmetric"===t.type||"Symmetric"===t.type)return i=!0,!1}),-1!==a.indexOf(o,e)||i||o.push(e)});var s,l=!(!r.length||!r[0].get("coord"))&&r[0].get("coord").isTransposed;if(r.length&&r[0].get("coord")&&"cartesian"===r[0].get("coord").type)if("interval"===o[0]&&!1!==n.shared){var u=a.mix({},e.tooltipCrosshairsRect);u.isTransposed=l,s={zIndex:0,crosshairs:u}}else if(a.indexOf(c,o[0])>-1){var h=a.mix({},e.tooltipCrosshairsLine);h.isTransposed=l,s={crosshairs:h}}return a.mix(i,s,{})},e._bindEvent=function(){var t=this.chart,e=this._getTriggerEvent();e&&(t.on(e,a.wrapBehavior(this,"onMouseMove")),t.on("plotleave",a.wrapBehavior(this,"onMouseOut")))},e._offEvent=function(){var t=this.chart,e=this._getTriggerEvent();e&&(t.off(e,a.getWrapBehavior(this,"onMouseMove")),t.off("plotleave",a.getWrapBehavior(this,"onMouseOut")))},e._setTooltip=function(t,e,n,i){var o=this.tooltip,s=this.prePoint;if(!s||s.x!==t.x||s.y!==t.y){e=r(e),this.prePoint=t;var l=this.chart,u=this.viewTheme,c=a.isArray(t.x)?t.x[t.x.length-1]:t.x,h=a.isArray(t.y)?t.y[t.y.length-1]:t.y;o.get("visible")||l.emit("tooltip:show",{x:c,y:h,tooltip:o});var f=e[0],p=f.title||f.name;o.isContentChange(p,e)&&(l.emit("tooltip:change",{tooltip:o,x:c,y:h,items:e}),p=e[0].title||e[0].name,o.setContent(p,e),a.isEmpty(n)?(o.clearMarkers(),o.set("markerItems",[])):!0===this.options.hideMarkers?o.set("markerItems",n):o.setMarkers(n,u.tooltipMarker));i===this._getCanvas()&&"mini"===o.get("type")?o.hide():(o.setPosition(c,h,i),o.show())}},e.hideTooltip=function(){var t=this.tooltip,e=this.chart,n=this._getCanvas();this.prePoint=null,t.hide(),e.emit("tooltip:hide",{tooltip:t}),n.draw()},e.onMouseMove=function(t){if(!a.isEmpty(t.views)){var e=this.timeStamp,n=+new Date,i={x:t.x,y:t.y};n-e>16&&!this.chart.get("stopTooltip")&&(this.showTooltip(i,t.views,t.shape),this.timeStamp=n)}},e.onMouseOut=function(t){var e=this.tooltip;e.get("visible")&&e.get("follow")&&(t&&t.toElement&&(i(t.toElement,"g2-tooltip")||function(t,e){for(var n=t.parentNode,r=!1;n&&n!==document.body;){if(i(n,e)){r=!0;break}n=n.parentNode}return r}(t.toElement,"g2-tooltip"))||this.hideTooltip())},e.renderTooltip=function(){var t=this;if(!t.tooltip){var e=t.chart,n=t.viewTheme,i=t._getCanvas(),r=t._getDefaultTooltipCfg(),o=t.options;(o=a.deepMix({plotRange:e.get("plotRange"),capture:!1,canvas:i,frontPlot:e.get("frontPlot"),viewTheme:n.tooltip,backPlot:e.get("backPlot")},r,o)).crosshairs&&"rect"===o.crosshairs.type&&(o.zIndex=0),o.visible=!1;var l;"mini"===o.type?(o.crosshairs=!1,o.position="top",l=new s.Mini(o)):l=o.useHtml?new s.Html(o):new s.Canvas(o),t.tooltip=l;var u=t._getTriggerEvent();if(!l.get("enterable")&&"plotmove"===u){var c=l.get("container");c&&(c.onmousemove=function(n){var i=t._normalizeEvent(n);e.emit(u,i)})}t._bindEvent()}},e.showTooltip=function(t,e,n){var i=this;if(!a.isEmpty(e)&&t){this.tooltip||this.renderTooltip();var r=i.options,o=[],s=[];if(a.each(e,function(e){if(!e.get("tooltipEnable"))return!0;var n=e.get("geoms"),l=e.get("coord");a.each(n,function(e){var n=e.get("type");if(e.get("visible")&&!1!==e.get("tooltipCfg")){var c=e.get("dataArray");if(e.isShareTooltip()||!1===r.shared&&a.inArray(["area","line","path","polygon"],n))a.each(c,function(c){var h=e.findPoint(t,c);if(h){var f=e.getTipItems(h,r.title);a.each(f,function(t){var r=t.point;if(r&&r.x&&r.y){var s=a.isArray(r.x)?r.x[r.x.length-1]:r.x,c=a.isArray(r.y)?r.y[r.y.length-1]:r.y;r=l.applyMatrix(s,c,1),t.x=r[0],t.y=r[1],t.showMarker=!0;var h=i._getItemMarker(e,t.color);t.marker=h,-1!==a.indexOf(u,n)&&o.push(t)}}),s=s.concat(f)}});else{var h=e.get("shapeContainer"),f=h.get("canvas").get("pixelRatio"),p=h.getShape(t.x*f,t.y*f);p&&p.get("visible")&&p.get("origin")&&(s=e.getTipItems(p.get("origin"),r.title))}}}),a.each(s,function(t){var e=t.point,n=a.isArray(e.x)?e.x[e.x.length-1]:e.x,i=a.isArray(e.y)?e.y[e.y.length-1]:e.y;e=l.applyMatrix(n,i,1),t.x=e[0],t.y=e[1]})}),s.length){var c=s[0];if(!s.every(function(t){return t.title===c.title})){var h=c,f=1/0;s.forEach(function(e){var n=l.distance([t.x,t.y],[e.x,e.y]);n1){var p=s[0],g=Math.abs(t.y-p.y);a.each(s,function(e){Math.abs(t.y-e.y)<=g&&(p=e,g=Math.abs(t.y-e.y))}),p&&p.x&&p.y&&(o=[p]),s=[p]}i._setTooltip(t,s,o,n)}else i.hideTooltip()}},e.clear=function(){var t=this.tooltip;t&&t.destroy(),this.tooltip=null,this.prePoint=null,this._offEvent()},e._getItemMarker=function(t,e){var n=t.get("shapeType")||"point",i=t.getDefaultValue("shape")||"circle",r={color:e};return o.getShapeFactory(n).getMarkerCfg(i,r)},t}();t.exports=f},function(t,e,n){function i(t,e){if(a.isNil(t)||a.isNil(e))return!1;var n=t.get("origin"),i=e.get("origin");return a.isNil(n)&&a.isNil(i)?a.isEqual(t,e):a.isEqual(n,i)}function r(t){t.shape&&t.shape.get("origin")&&(t.data=t.shape.get("origin"))}var a=n(0),o=function(){function t(t){this.view=null,this.canvas=null,a.assign(this,t),this._init()}var e=t.prototype;return e._init=function(){this.pixelRatio=this.canvas.get("pixelRatio")},e._getShapeEventObj=function(t){return{x:t.x/this.pixelRatio,y:t.y/this.pixelRatio,target:t.target,toElement:t.event.toElement||t.event.relatedTarget}},e._getShape=function(t,e){return this.view.get("canvas").getShape(t,e)},e._getPointInfo=function(t){var e=this.view,n={x:t.x/this.pixelRatio,y:t.y/this.pixelRatio},i=e.getViewsByPoint(n);return n.views=i,n},e._getEventObj=function(t,e,n){return{x:e.x,y:e.y,target:t.target,toElement:t.event.toElement||t.event.relatedTarget,views:n}},e.bindEvents=function(){var t=this.canvas;t.on("mousedown",a.wrapBehavior(this,"onDown")),t.on("mousemove",a.wrapBehavior(this,"onMove")),t.on("mouseleave",a.wrapBehavior(this,"onOut")),t.on("mouseup",a.wrapBehavior(this,"onUp")),t.on("click",a.wrapBehavior(this,"onClick")),t.on("dblclick",a.wrapBehavior(this,"onClick")),t.on("touchstart",a.wrapBehavior(this,"onTouchstart")),t.on("touchmove",a.wrapBehavior(this,"onTouchmove")),t.on("touchend",a.wrapBehavior(this,"onTouchend"))},e._triggerShapeEvent=function(t,e,n){if(t&&t.name&&!t.get("destroyed")){var i=this.view;if(i.isShapeInView(t)){var r=t.name+":"+e;n.view=i,n.appendInfo=t.get("appendInfo"),i.emit(r,n);var a=i.get("parent");a&&a.emit(r,n)}}},e.onDown=function(t){var e=this.view,n=this._getShapeEventObj(t);n.shape=this.currentShape,r(n),e.emit("mousedown",n),this._triggerShapeEvent(this.currentShape,"mousedown",n)},e.onMove=function(t){var e=this.view,n=this.currentShape;n&&n.get("destroyed")&&(n=null,this.currentShape=null);var a=this._getShape(t.x,t.y)||t.currentTarget,o=this._getShapeEventObj(t);if(o.shape=a,r(o),e.emit("mousemove",o),this._triggerShapeEvent(a,"mousemove",o),n&&!i(n,a)){var s=this._getShapeEventObj(t);s.shape=n,s.toShape=a,r(s),this._triggerShapeEvent(n,"mouseleave",s)}if(a&&!i(n,a)){var l=this._getShapeEventObj(t);l.shape=a,l.fromShape=n,r(l),this._triggerShapeEvent(a,"mouseenter",l)}this.currentShape=a;var u=this._getPointInfo(t),c=this.curViews||[];0===c.length&&u.views.length&&e.emit("plotenter",this._getEventObj(t,u,u.views)),c.length&&0===u.views.length&&e.emit("plotleave",this._getEventObj(t,u,c)),u.views.length&&((o=this._getEventObj(t,u,u.views)).shape=a,r(o),e.emit("plotmove",o)),this.curViews=u.views},e.onOut=function(t){var e=this.view,n=this._getPointInfo(t),i=this.curViews||[],r=this._getEventObj(t,n,i);!this.curViews||0===this.curViews.length||r.toElement&&"CANVAS"===r.toElement.tagName||(e.emit("plotleave",r),this.curViews=[])},e.onUp=function(t){var e=this.view,n=this._getShapeEventObj(t);n.shape=this.currentShape,e.emit("mouseup",n),this._triggerShapeEvent(this.currentShape,"mouseup",n)},e.onClick=function(t){var e=this.view,n=this._getShape(t.x,t.y)||t.currentTarget,i=this._getShapeEventObj(t);i.shape=n,r(i),e.emit("click",i),this._triggerShapeEvent(n,t.type,i),this.currentShape=n;var o=this._getPointInfo(t),s=o.views;if(!a.isEmpty(s)){var l=this._getEventObj(t,o,s);if(this.currentShape){var u=this.currentShape;l.shape=u,r(l)}e.emit("plotclick",l),"dblclick"===t.type&&(e.emit("plotdblclick",l),e.emit("dblclick",i))}},e.onTouchstart=function(t){var e=this.view,n=this._getShape(t.x,t.y)||t.currentTarget,i=this._getShapeEventObj(t);i.shape=n,r(i),e.emit("touchstart",i),this._triggerShapeEvent(n,"touchstart",i),this.currentShape=n},e.onTouchmove=function(t){var e=this.view,n=this._getShape(t.x,t.y)||t.currentTarget,i=this._getShapeEventObj(t);i.shape=n,r(i),e.emit("touchmove",i),this._triggerShapeEvent(n,"touchmove",i),this.currentShape=n},e.onTouchend=function(t){var e=this.view,n=this._getShapeEventObj(t);n.shape=this.currentShape,r(n),e.emit("touchend",n),this._triggerShapeEvent(this.currentShape,"touchend",n)},e.clearEvents=function(){var t=this.canvas;t.off("mousemove",a.getWrapBehavior(this,"onMove")),t.off("mouseleave",a.getWrapBehavior(this,"onOut")),t.off("mousedown",a.getWrapBehavior(this,"onDown")),t.off("mouseup",a.getWrapBehavior(this,"onUp")),t.off("click",a.getWrapBehavior(this,"onClick")),t.off("dblclick",a.getWrapBehavior(this,"onClick")),t.off("touchstart",a.getWrapBehavior(this,"onTouchstart")),t.off("touchmove",a.getWrapBehavior(this,"onTouchmove")),t.off("touchend",a.getWrapBehavior(this,"onTouchend"))},t}();t.exports=o},function(t,e,n){function i(t,e){var n=[];if(!1===t.get("animate"))return[];var r=t.get("children");return s.each(r,function(t){if(t.isGroup)n=n.concat(i(t,e));else if(t.isShape&&t._id){var r=t._id;(r=r.split("-")[0])===e&&n.push(t)}}),n}function r(t,e,n,i){return i?l.Action[n][i]:l.getAnimation(t,e,n)}function a(t,e,n){var i=l.getAnimateCfg(t,e);return n&&n[e]?s.deepMix({},i,n[e]):i}function o(t,e,n,i){var o,l,c=!1;if(i){var h=[],f=[];s.each(e,function(e){var n=t[e._id];n?(e.setSilent("cacheShape",n),h.push(e),delete t[e._id]):f.push(e)}),s.each(t,function(t){var e=t.name,i=t.coord,h=t._id,f=t.attrs,p=t.index,g=t.type;if(l=a(e,"leave",t.animateCfg),o=r(e,i,"leave",l.animation),s.isFunction(o)){var d=n.addShape(g,{attrs:f,index:p});if(d._id=h,d.name=e,i&&"label"!==e){var v=d.getMatrix(),y=u.multiply([],v,i.matrix);d.setMatrix(y)}c=!0,o(d,l,i)}}),s.each(h,function(t){var e=t.name,n=t.get("coord"),i=t.get("cacheShape").attrs;if(!s.isEqual(i,t.attr())){if(l=a(e,"update",t.get("animateCfg")),o=r(e,n,"update",l.animation),s.isFunction(o))o(t,l,n);else{var u=s.cloneDeep(t.attr());t.attr(i),t.animate(u,l.duration,l.easing,function(){t.setSilent("cacheShape",null)})}c=!0}}),s.each(f,function(t){var e=t.name,n=t.get("coord");l=a(e,"enter",t.get("animateCfg")),o=r(e,n,"enter",l.animation),s.isFunction(o)&&(o(t,l,n),c=!0)})}else s.each(e,function(t){var e=t.name,n=t.get("coord");l=a(e,"appear",t.get("animateCfg")),o=r(e,n,"appear",l.animation),s.isFunction(o)&&(o(t,l,n),c=!0)});return c}var s=n(0),l=n(126),u=s.MatrixUtil.mat3;t.exports={execAnimation:function(t,e){var n=t.get("middlePlot"),r=t.get("backPlot"),a=t.get("_id"),l=t.get("canvas"),u=l.get(a+"caches")||[];0===u.length&&(e=!1);var c=i(n,a),h=i(r,a),f=c.concat(h);l.setSilent(a+"caches",function(t){var e={};return s.each(t,function(t){if(t._id&&!t.isClip){var n=t._id;e[n]={_id:n,type:t.get("type"),attrs:s.cloneDeep(t.attr()),name:t.name,index:t.get("index"),animateCfg:t.get("animateCfg"),coord:t.get("coord")}}}),e}(f));(e?o(u,f,l,e):o(u,c,l,e))||l.draw()}}},function(t,e,n){var i=n(0),r=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){return{type:"plotBack",padding:null,background:null,plotRange:null,plotBackground:null}},n._beforeRenderUI=function(){this._calculateRange()},n._renderUI=function(){this._renderBackground(),this._renderPlotBackground()},n._renderBackground=function(){var t=this.get("background");if(t){var e=this.get("canvas"),n={x:0,y:0,width:this.get("width")||e.get("width"),height:this.get("height")||e.get("height")},r=this.get("backgroundShape");r?r.attr(n):(r=this.addShape("rect",{attrs:i.mix(n,t)}),this.set("backgroundShape",r))}},n._renderPlotBackground=function(){var t=this.get("plotBackground");if(t){var e=this.get("plotRange"),n=e.br.x-e.bl.x,r=e.br.y-e.tr.y,a=e.tl,o={x:a.x,y:a.y,width:n,height:r},s=this.get("plotBackShape");s?s.attr(o):(t.image?(o.img=t.image,s=this.addShape("image",{attrs:o})):(i.mix(o,t),s=this.addShape("rect",{attrs:o})),this.set("plotBackShape",s))}},n._convert=function(t,e){if(i.isString(t))if("auto"===t)t=0;else if(-1!==t.indexOf("%")){var n=this.get("canvas"),r=this.get("width")||n.get("width"),a=this.get("height")||n.get("height");t=parseInt(t,10)/100,t=e?t*r:t*a}return t},n._calculateRange=function(){var t=this.get("plotRange");i.isNil(t)&&(t={});var e=this.get("padding"),n=this.get("canvas"),r=this.get("width")||n.get("width"),a=this.get("height")||n.get("height"),o=i.toAllPadding(e),s=this._convert(o[0],!1),l=this._convert(o[1],!0),u=this._convert(o[2],!1),c=this._convert(o[3],!0),h=Math.min(c,r-l),f=Math.max(c,r-l),p=Math.min(a-u,s),g=Math.max(a-u,s);t.tl={x:h,y:p},t.tr={x:f,y:p},t.bl={x:h,y:g},t.br={x:f,y:g},t.cc={x:(f+h)/2,y:(g+p)/2},this.set("plotRange",t)},n.repaint=function(){return this._calculateRange(),this._renderBackground(),this._renderPlotBackground(),this},e}(n(16).Group);t.exports=r},function(t,e,n){var i=n(7),r=n(0),a={getDefaultSize:function(){var t=this.get("defaultSize"),e=this.get("viewTheme")||i;if(!t){var n,a=this.get("coord"),o=this.getXScale(),s=o.values,l=this.get("dataArray");if(o.isLinear&&s.length>1){s.sort();var u=function(t,e){var n=t.length;r.isString(t[0])&&(t=t.map(function(t){return e.translate(t)}));for(var i=t[1]-t[0],a=2;ao&&(i=o)}return i}(s,o);n=(o.max-o.min)/u,s.length>n&&(n=s.length)}else n=s.length;var c=o.range,h=1/n,f=1;if(this.isInCircle()?f=a.isTransposed&&n>1?e.widthRatio.multiplePie:e.widthRatio.rose:(o.isLinear&&(h*=c[1]-c[0]),f=e.widthRatio.column),h*=f,this.hasAdjust("dodge")){h/=this._getDodgeCount(l)}t=h,this.set("defaultSize",t)}return t},_getDodgeCount:function(t){var e,n=this.get("adjusts"),i=t.length;if(r.each(n,function(t){"dodge"===t.type&&(e=t.dodgeBy)}),e){var a=r.Array.merge(t);i=r.Array.values(a,e).length}return i},getDimWidth:function(t){var e=this.get("coord"),n=e.convertPoint({x:0,y:0}),i=e.convertPoint({x:"x"===t?1:0,y:"x"===t?0:1}),r=0;return n&&i&&(r=Math.sqrt(Math.pow(i.x-n.x,2)+Math.pow(i.y-n.y,2))),r},_getWidth:function(){var t=this.get("coord");return this.isInCircle()&&!t.isTransposed?(t.endAngle-t.startAngle)*t.radius:this.getDimWidth("x")},_toNormalizedSize:function(t){return t/this._getWidth()},_toCoordSize:function(t){return this._getWidth()*t},getNormalizedSize:function(t){var e=this.getAttrValue("size",t);return e=r.isNil(e)?this.getDefaultSize():this._toNormalizedSize(e)},getSize:function(t){var e=this.getAttrValue("size",t);if(r.isNil(e)){var n=this.getDefaultSize();e=this._toCoordSize(n)}return e}};t.exports=a},function(t,e,n){var i=n(0),r=n(7);t.exports={splitData:function(t){var e=this.get("viewTheme")||r;if(!t.length)return[];var n,a=[],o=[],s=this.getYScale().field;return i.each(t,function(t){n=t._origin?t._origin[s]:t[s],e.connectNulls?i.isNil(n)||o.push(t):i.isArray(n)&&i.isNil(n[0])||i.isNil(n)?o.length&&(a.push(o),o=[]):o.push(t)}),o.length&&a.push(o),a}}},function(t,e,n){function i(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var r=n(20),a=n(358),o=n(0),s=function(t){function e(e){var n;return n=t.call(this,e)||this,o.assign(i(i(n)),a),n}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return e.type="path",e.shapeType="line",e},n.getDrawCfg=function(e){var n=t.prototype.getDrawCfg.call(this,e);return n.isStack=this.hasStack(),n},n.draw=function(t,e,n,i){var r=this,a=this.splitData(t),s=this.getDrawCfg(t[0]);r._applyViewThemeShapeStyle(s,s.shape,n),s.origin=t,o.each(a,function(t,a){if(!o.isEmpty(t)){s.splitedIndex=a,s.points=t;var l=n.drawShape(s.shape,s,e);r.appendShapeInfo(l,i+a)}})},e}(r);r.Path=s,t.exports=s},function(t,e,n){"use strict";var i=n(370),r=n(371);e.a=function(t){var e=Object(i.a)(t);return(e.local?function(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}:function(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===r.b&&e.documentElement.namespaceURI===r.b?e.createElement(t):e.createElementNS(n,t)}})(e)}},function(t,e,n){"use strict";e.a=function(t,e){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}},function(t,e,n){"use strict";e.b=function(t,e,n){var r=t._id;return t.each(function(){var t=Object(i.h)(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)}),function(t){return Object(i.f)(t,r).value[e]}};var i=n(70);e.a=function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,a=Object(i.f)(this.node(),n).tween,o=0,s=a.length;o0;)i-=2*Math.PI;var c=a-t+(i=i/Math.PI/2*n)-2*t;l.push(["M",c,e]);for(var h=0,f=0;f=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),i.a.hasOwnProperty(e)?{space:i.a[e],local:t}:t}},function(t,e,n){"use strict";n.d(e,"b",function(){return i});var i="http://www.w3.org/1999/xhtml";e.a={svg:"http://www.w3.org/2000/svg",xhtml:i,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"}},function(t,e,n){"use strict";e.a=function(t){return null==t?function(){}:function(){return this.querySelector(t)}}},function(t,e,n){"use strict";e.a=function(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}},function(t,e,n){"use strict";function i(t,e,n){return function(i){var r=o;o=i;try{t.call(this,this.__data__,e,n)}finally{o=r}}}function r(t,e,n){var r=a.hasOwnProperty(t.type)?function(t,e,n){return t=i(t,e,n),function(e){var n=e.relatedTarget;n&&(n===this||8&n.compareDocumentPosition(this))||t.call(this,e)}}:i;return function(i,a,o){var s,l=this.__on,u=r(e,a,o);if(l)for(var c=0,h=l.length;c=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}})}(t+""),s=o.length;{if(!(arguments.length<2)){for(l=e?r:function(t){return function(){var e=this.__on;if(e){for(var n,i=0,r=-1,a=e.length;in.max&&(n.max=e.max)):"timeCat"===o?(i.each(s,function(t,e){s[e]=r.toTimeStamp(t)}),s.sort(function(t,e){return t-e}),n=s):n=s,n}},function(t,e,n){"use strict";var i=n(69);e.a=function(t){return"string"==typeof t?new i.a([[document.querySelector(t)]],[document.documentElement]):new i.a([[t]],i.c)}},function(t,e,n){"use strict";e.a=function(t){return null==t?function(){return[]}:function(){return this.querySelectorAll(t)}}},function(t,e,n){"use strict";var i=function(t){return function(){return this.matches(t)}};if("undefined"!=typeof document){var r=document.documentElement;if(!r.matches){var a=r.webkitMatchesSelector||r.msMatchesSelector||r.mozMatchesSelector||r.oMatchesSelector;i=function(t){return function(){return a.call(this,t)}}}}e.a=i},function(t,e,n){"use strict";function i(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}e.a=i;var r=n(383),a=n(69);e.b=function(){return new a.a(this._enter||this._groups.map(r.a),this._parents)},i.prototype={constructor:i,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}}},function(t,e,n){"use strict";e.a=function(t){return new Array(t.length)}},function(t,e,n){"use strict";function i(t,e){return t.style.getPropertyValue(e)||Object(r.a)(t).getComputedStyle(t,null).getPropertyValue(e)}e.b=i;var r=n(373);e.a=function(t,e,n){return arguments.length>1?this.each((null==e?function(t){return function(){this.style.removeProperty(t)}}:"function"==typeof e?function(t,e,n){return function(){var i=e.apply(this,arguments);null==i?this.style.removeProperty(t):this.style.setProperty(t,i,n)}}:function(t,e,n){return function(){this.style.setProperty(t,e,n)}})(t,e,null==n?"":n)):i(this.node(),t)}},function(t,e,n){"use strict";var i=n(70);e.a=function(t,e){var n,r,a,o=t.__transition,s=!0;if(o){e=null==e?null:e+"";for(a in o)(n=o[a]).name===e?(r=n.state>i.d&&n.state0&&(o[0][0]="L"),i=i.concat(o)}),i.push(["Z"]),i}function o(t){return{symbol:function(t,e){return[["M",t-5.5,e-4],["L",t+5.5,e-4],["L",t+5.5,e+4],["L",t-5.5,e+4],["Z"]]},radius:5,fill:t.color,fillOpacity:.6}}var s=n(0),l=n(18),u=n(22),c=n(45),h=n(7),f=l.registerFactory("area",{defaultShapeType:"area",getDefaultPoints:function(t){var e=[],n=t.x,i=t.y,r=t.y0;return i=s.isArray(i)?i:[r,i],s.each(i,function(t){e.push({x:n,y:t})}),e},getActiveCfg:function(t,e){return function(t,e){if("line"===t||"smoothLine"===t)return{lineWidth:(e.lineWidth||0)+1};var n=e.fillOpacity||e.opacity||1;return{fillOpacity:n-.15,strokeOpacity:n-.15}}(t,e)},drawShape:function(t,e,n){var i,r=this.getShape(t);return(i=1===e.points.length&&h.showSinglePoint?function(t,e,n){var i=t._coord.convertPoint(e.points[0][1]);return n.addShape("circle",{attrs:s.mix({x:i.x,y:i.y,r:2,fill:e.color},e.style)})}(this,e,n):r.draw(e,n))&&(i.set("origin",e.origin),i._id=e.splitedIndex?e._id+e.splitedIndex:e._id,i.name=this.name),i},getSelectedCfg:function(t,e){return e&&e.style?e.style:this.getActiveCfg(t,e)}});l.registerShape("area","area",{draw:function(t,e){var n=r(t),i=a(t,!1,this);return e.addShape("path",{attrs:s.mix(n,{path:i})})},getMarkerCfg:function(t){return o(t)}}),l.registerShape("area","smooth",{draw:function(t,e){var n=r(t),i=this._coord;t.constraint=[[i.start.x,i.end.y],[i.end.x,i.start.y]];var o=a(t,!0,this);return e.addShape("path",{attrs:s.mix(n,{path:o})})},getMarkerCfg:function(t){return o(t)}}),l.registerShape("area","line",{draw:function(t,e){var n=i(t),r=a(t,!1,this);return e.addShape("path",{attrs:s.mix(n,{path:r})})},getMarkerCfg:function(t){return o(t)}}),l.registerShape("area","smoothLine",{draw:function(t,e){var n=i(t),r=a(t,!0,this);return e.addShape("path",{attrs:s.mix(n,{path:r})})},getMarkerCfg:function(t){return o(t)}}),f.spline=f.smooth,t.exports=f},function(t,e,n){var i=n(20);n(393);var r=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);return e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return e.type="edge",e.shapeType="edge",e.generatePoints=!0,e},e}(i);i.Edge=r,t.exports=r},function(t,e,n){function i(t){var e=u.shape.edge,n=o.mix({},e,t.style);return l.addStrokeAttrs(n,t),n}function r(t,e){var n=[];n.push({x:t.x,y:.5*t.y+1*e.y/2}),n.push({y:.5*t.y+1*e.y/2,x:e.x}),n.push(e);var i=["C"];return o.each(n,function(t){i.push(t.x,t.y)}),i}function a(t,e){var n=[];n.push({x:e.x,y:e.y}),n.push(t);var i=["Q"];return o.each(n,function(t){i.push(t.x,t.y)}),i}var o=n(0),s=n(18),l=n(45),u=n(7),c=n(22),h=1/3,f=s.registerFactory("edge",{defaultShapeType:"line",getDefaultPoints:function(t){return l.splitPoints(t)},getActiveCfg:function(t,e){return{lineWidth:(e.lineWidth||0)+1}}});s.registerShape("edge","line",{draw:function(t,e){var n=this.parsePoints(t.points),r=i(t),a=c.getLinePath(n);return e.addShape("path",{attrs:o.mix(r,{path:a})})},getMarkerCfg:function(t){return o.mix({symbol:"circle",radius:4.5},i(t))}}),s.registerShape("edge","vhv",{draw:function(t,e){var n=t.points,r=i(t),a=function(t,e){var n=[];n.push({y:t.y*(1-h)+e.y*h,x:t.x}),n.push({y:t.y*(1-h)+e.y*h,x:e.x}),n.push(e);var i=[["M",t.x,t.y]];return o.each(n,function(t){i.push(["L",t.x,t.y])}),i}(n[0],n[1]);a=this.parsePath(a);return e.addShape("path",{attrs:o.mix(r,{path:a})})},getMarkerCfg:function(t){return o.mix({symbol:"circle",radius:4.5},i(t))}}),s.registerShape("edge","smooth",{draw:function(t,e){var n=t.points,a=i(t),s=function(t,e){var n=r(t,e),i=[["M",t.x,t.y]];return i.push(n),i}(n[0],n[1]);s=this.parsePath(s);return e.addShape("path",{attrs:o.mix(a,{path:s})})},getMarkerCfg:function(t){return o.mix({symbol:"circle",radius:4.5},i(t))}}),s.registerShape("edge","arc",{draw:function(t,e){var n,s,l=t.points,u=l.length>2?"weight":"normal",c=i(t);if(t.isInCircle){var h={x:0,y:1};"normal"===u?s=function(t,e,n){var i=a(e,n),r=[["M",t.x,t.y]];return r.push(i),r}(l[0],l[1],h):(c.fill=c.stroke,s=function(t,e){var n=a(t[1],e),i=a(t[3],e),r=[["M",t[0].x,t[0].y]];return r.push(i),r.push(["L",t[3].x,t[3].y]),r.push(["L",t[2].x,t[2].y]),r.push(n),r.push(["L",t[1].x,t[1].y]),r.push(["L",t[0].x,t[0].y]),r.push(["Z"]),r}(l,h)),s=this.parsePath(s),n=e.addShape("path",{attrs:o.mix(c,{path:s})})}else if("normal"===u)l=this.parsePoints(l),n=e.addShape("arc",{attrs:o.mix(c,{x:(l[1].x+l[0].x)/2,y:l[0].y,r:Math.abs(l[1].x-l[0].x)/2,startAngle:Math.PI,endAngle:2*Math.PI})});else{s=[["M",l[0].x,l[0].y],["L",l[1].x,l[1].y]];var f=r(l[1],l[3]),p=r(l[2],l[0]);s.push(f),s.push(["L",l[3].x,l[3].y]),s.push(["L",l[2].x,l[2].y]),s.push(p),s.push(["Z"]),s=this.parsePath(s),c.fill=c.stroke,n=e.addShape("path",{attrs:o.mix(c,{path:s})})}return n},getMarkerCfg:function(t){return o.mix({symbol:"circle",radius:4.5},i(t))}}),t.exports=f},function(t,e,n){var i=n(73).ColorUtil,r=n(20),a=n(0),o=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return e.type="heatmap",e.paletteCache={},e},n._prepareRange=function(){var t=this.get("mappedData"),e=this.getAttr("color").field,n=1/0,i=-1/0;t.forEach(function(t){var r=t._origin[e];r>i&&(i=r),r=t[0]}));for(var c=this._getScale(o),h=0;h1?t[1]:e;return{min:e,max:n,min1:i,max1:t.length>3?t[3]:n,median:t.length>2?t[2]:i}}function r(t,e,n){var r,a,s=[];return o.isArray(e)?r=[[t-n/2,(a=i(e)).max],[t+n/2,a.max],[t,a.max],[t,a.max1],[t-n/2,a.min1],[t-n/2,a.max1],[t+n/2,a.max1],[t+n/2,a.min1],[t,a.min1],[t,a.min],[t-n/2,a.min],[t+n/2,a.min],[t-n/2,a.median],[t+n/2,a.median]]:(e=e||.5,r=[[(a=i(t)).min,e-n/2],[a.min,e+n/2],[a.min,e],[a.min1,e],[a.min1,e-n/2],[a.min1,e+n/2],[a.max1,e+n/2],[a.max1,e-n/2],[a.max1,e],[a.max,e],[a.max,e-n/2],[a.max,e+n/2],[a.median,e-n/2],[a.median,e+n/2]]),function(t,e){o.each(t,function(t){e.push({x:t[0],y:t[1]})})}(r,s),s}function a(t,e,n){var i=function(t){o.isArray(t)||(t=[t]);var e=t.sort(function(t,e){return te[n].radius+B)return!1;return!0}(e,t)}),u=0,c=0,h=[];if(o.length>1){var f=l(o);for(n=0;n-1){var m=t[d.parentIndex[x]],_=Math.atan2(d.x-m.x,d.y-m.y),b=Math.atan2(g.x-m.x,g.y-m.y),w=b-_;w<0&&(w+=2*Math.PI);var S=b-w/2,M=a(v,{x:m.x+m.radius*Math.sin(S),y:m.y+m.radius*Math.cos(S)});M>2*m.radius&&(M=2*m.radius),(null===y||y.width>M)&&(y={circle:m,width:M,p1:d,p2:g})}null!==y&&(h.push(y),u+=r(y.circle.radius,y.width),g=d)}}else{var C=t[0];for(n=1;nMath.abs(C.radius-t[n].radius)){A=!0;break}A?u=c=0:(u=C.radius*C.radius*Math.PI,h.push({circle:C,p1:{x:C.x,y:C.y+C.radius},p2:{x:C.x-B,y:C.y+C.radius},width:2*C.radius}))}return c/=2,e&&(e.area=u+c,e.arcArea=u,e.polygonArea=c,e.arcs=h,e.innerPoints=o,e.intersectionPoints=i),u+c}function r(t,e){return t*t*Math.acos(1-e/t)-(t-e)*Math.sqrt(e*(2*t-e))}function a(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function o(t,e,n){if(n>=t+e)return 0;if(n<=Math.abs(t-e))return Math.PI*Math.min(t,e)*Math.min(t,e);var i=e-(n*n-t*t+e*e)/(2*n);return r(t,t-(n*n-e*e+t*t)/(2*n))+r(e,i)}function s(t,e){var n=a(t,e),i=t.radius,r=e.radius;if(n>=i+r||n<=Math.abs(i-r))return[];var o=(i*i-r*r+n*n)/(2*n),s=Math.sqrt(i*i-o*o),l=t.x+o*(e.x-t.x)/n,u=t.y+o*(e.y-t.y)/n,c=-(e.y-t.y)*(s/n),h=-(e.x-t.x)*(s/n);return[{x:l+c,y:u-h},{x:l-c,y:u+h}]}function l(t){for(var e={x:0,y:0},n=0;n=v[d-1].fx){var P=!1;if(b.fx>k.fx?(g(w,1+f,_,-f,k),w.fx=t(w),w.fx=1)break;for(y=1;yl+a*r*u||c>=d)f=r;else{if(Math.abs(p)<=-o*u)return r;p*(f-s)>=0&&(f=s),s=r,d=c}return 0}var l=n.fx,u=h(n.fxprime,e),c=l,f=l,p=u,d=0;r=r||1,a=a||1e-6,o=o||.1;for(var v=0;v<10;++v){if(g(i.x,1,n.x,r,e),c=i.fx=t(i.x,i.fxprime),p=h(i.fxprime,e),c>l+a*r*u||v&&c>=f)return s(d,r,f);if(Math.abs(p)<=-o*u)return r;if(p>=0)return s(r,d,c);f=c,d=r,r*=2}return r}function y(t,e,n){var i,r,a,o={x:e.slice(),fx:0,fxprime:e.slice()},s={x:e.slice(),fx:0,fxprime:e.slice()},l=e.slice(),u=1;a=(n=n||{}).maxIterations||20*e.length,o.fx=t(o.x,o.fxprime),p(i=o.fxprime.slice(),o.fxprime,-1);for(var c=0;ce}),e=0;e0)throw"Initial bisect points must have opposite signs";if(0===o)return e;if(0===s)return n;for(var u=0;u=0&&(e=c),Math.abs(l)=8){var r=function(t,e){var n,i=(e=e||{}).restarts||10,r=[],a={};for(n=0;n=Math.min(e[a].size,e[o].size)?l=1:t.size<=1e-10&&(l=-1),r[a][o]=r[o][a]=l}),{distances:i,constraints:r}}(t,r,a),l=s.distances,h=s.constraints,g=f(l.map(f))/l.length;l=l.map(function(t){return t.map(function(t){return t/g})});var d,v,x=function(t,e){return function(t,e,n,i){var r,a=0;for(r=0;r0&&g<=h||f<0&&g>=h||(a+=2*d*d,e[2*r]+=4*d*(o-u),e[2*r+1]+=4*d*(s-c),e[2*l]+=4*d*(u-o),e[2*l+1]+=4*d*(c-s))}return a}(t,e,l,h)};for(n=0;n=Math.min(l[g].size,l[d].size)&&(p=0),u[g].push({set:d,size:f.size,weight:p}),u[d].push({set:g,size:f.size,weight:p})}var v=[];for(a in u)if(u.hasOwnProperty(a)){var y=0;for(c=0;c0){var r=t[0].x,o=t[0].y;for(i=0;i1){var s,l,u=Math.atan2(t[1].x,t[1].y)-e,c=Math.cos(u),h=Math.sin(u);for(i=0;i2){for(var f=Math.atan2(t[2].x,t[2].y)-e;f<0;)f+=2*Math.PI;for(;f>2*Math.PI;)f-=2*Math.PI;if(f>Math.PI){var p=t[1].y/(1e-10+t[1].x);for(i=0;iu&&p.node().getComputedTextLength()>o&&(h.pop(),p.text(h.join(" ")),h=[c],p=r.append("tspan").text(c),f++)}var g=.35-1.1*f/2,d=r.attr("x"),v=r.attr("y");r.selectAll("tspan").attr("x",d).attr("y",v).attr("dy",function(t,e){return g+1.1*e+"em"})}}function T(t,e,n){var i,r,o=e[0].radius-a(e[0],t);for(i=1;i=u&&(s=r[n],u=c)}var h=d(function(n){return-1*T({x:n[0],y:n[1]},t,e)},[s.x,s.y],{maxIterations:500,minErrorDelta:1e-10}).x,f={x:h[0],y:h[1]},p=!0;for(n=0;nt[n].radius){p=!1;break}for(n=0;n0&&console.log("WARNING: area "+a+" not represented on screen")}return n}function E(t,e,n){var i=[];return i.push("\nM",t,e),i.push("\nm",-n,0),i.push("\na",n,n,0,1,0,2*n,0),i.push("\na",n,n,0,1,0,2*-n,0),i.join(" ")}function D(t){var e=t.split(" ");return{x:parseFloat(e[1]),y:parseFloat(e[2]),radius:-parseFloat(e[4])}}function F(t){var e={};i(t,e);var n=e.arcs;if(0===n.length)return"M 0 0";if(1==n.length){var r=n[0].circle;return E(r.x,r.y,r.radius)}for(var a=["\nM",n[0].p2.x,n[0].p2.y],o=0;ol;a.push("\nA",l,l,0,u?1:0,1,s.p1.x,s.p1.y)}return a.join(" ")}var B=1e-10,R=1e-10;t.intersectionArea=i,t.circleCircleIntersection=s,t.circleOverlap=o,t.circleArea=r,t.distance=a,t.venn=x,t.greedyLayout=b,t.scaleSolution=k,t.normalizeSolution=A,t.bestInitialLayout=_,t.lossFunction=w,t.disjointCluster=M,t.distanceFromIntersectArea=m,t.VennDiagram=function(){function t(t){function f(t){return t.sets in b?b[t.sets]:1==t.sets.length?""+t.sets[0]:void 0}var p=t.datum(),g={};p.forEach(function(t){0==t.size&&1==t.sets.length&&(g[t.sets[0]]=1)});var x={},m={};if((p=p.filter(function(t){return!t.sets.some(function(t){return t in g})})).length>0){var _=v(p,{lossFunction:y});s&&(_=A(_,o,h)),x=k(_,n,i,r),m=L(x,p)}var b={};p.forEach(function(t){t.label&&(b[t.sets]=t.label)}),t.selectAll("svg").data([x]).enter().append("svg");var w=t.select("svg").attr("width",n).attr("height",i),S={},M=!1;w.selectAll(".venn-area path").each(function(t){var n=e.select(this).attr("d");1==t.sets.length&&n&&(M=!0,S[t.sets[0]]=D(n))});var C=function(t){return function(e){return F(t.sets.map(function(t){var r=S[t],a=x[t];return r||(r={x:n/2,y:i/2,radius:1}),a||(a={x:n/2,y:i/2,radius:1}),{x:r.x*(1-e)+a.x*e,y:r.y*(1-e)+a.y*e,radius:r.radius*(1-e)+a.radius*e}}))}},T=w.selectAll(".venn-area").data(p,function(t){return t.sets}),I=T.enter().append("g").attr("class",function(t){return"venn-area venn-"+(1==t.sets.length?"circle":"intersection")}).attr("data-venn-sets",function(t){return t.sets.join("_")}),O=I.append("path"),E=I.append("text").attr("class","label").text(function(t){return f(t)}).attr("text-anchor","middle").attr("dy",".35em").attr("x",n/2).attr("y",i/2);u&&(O.style("fill-opacity","0").filter(function(t){return 1==t.sets.length}).style("fill",function(t){return d(t.sets)}).style("fill-opacity",".25"),E.style("fill",function(t){return 1==t.sets.length?d(t.sets):"#444"}));var B=t;M?(B=t.transition("venn").duration(a)).selectAll("path").attrTween("d",C):B.selectAll("path").attr("d",function(t){return F(t.sets.map(function(t){return x[t]}))});var R=B.selectAll("text").filter(function(t){return t.sets in m}).text(function(t){return f(t)}).attr("x",function(t){return Math.floor(m[t.sets].x)}).attr("y",function(t){return Math.floor(m[t.sets].y)});l&&(M?"on"in R?R.on("end",P(x,f)):R.each("end",P(x,f)):R.each(P(x,f)));var j=T.exit().transition("venn").duration(a).remove();j.selectAll("path").attrTween("d",C);var N=j.selectAll("text").attr("x",n/2).attr("y",i/2);return null!==c&&(E.style("font-size","0px"),R.style("font-size",c),N.style("font-size","0px")),{circles:x,textCentres:m,nodes:T,enter:I,update:B,exit:j}}var n=600,i=350,r=15,a=1e3,o=Math.PI/2,s=!0,l=!0,u=!0,c=null,h=null,f={},p=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],g=0,d=function(t){if(t in f)return f[t];var e=f[t]=p[g];return(g+=1)>=p.length&&(g=0),e},v=x,y=w;return t.wrap=function(e){return arguments.length?(l=e,t):l},t.width=function(e){return arguments.length?(n=e,t):n},t.height=function(e){return arguments.length?(i=e,t):i},t.padding=function(e){return arguments.length?(r=e,t):r},t.colours=function(e){return arguments.length?(d=e,t):d},t.fontSize=function(e){return arguments.length?(c=e,t):c},t.duration=function(e){return arguments.length?(a=e,t):a},t.layoutFunction=function(e){return arguments.length?(v=e,t):v},t.normalize=function(e){return arguments.length?(s=e,t):s},t.styled=function(e){return arguments.length?(u=e,t):u},t.orientation=function(e){return arguments.length?(o=e,t):o},t.orientationOrder=function(e){return arguments.length?(h=e,t):h},t.lossFunction=function(e){return arguments.length?(y=e,t):y},t},t.wrapText=P,t.computeTextCentres=L,t.computeTextCentre=I,t.sortAreas=function(t,e){function n(t){for(var e=0;e=M&&(M=S+1);!(w=_[M])&&++M=0;)(i=r[a])&&(o&&o!==i.nextSibling&&o.parentNode.insertBefore(i,o),o=i);return this}},function(t,e,n){"use strict";function i(t,e){return te?1:t>=e?0:NaN}var r=n(69);e.a=function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=i);for(var n=this._groups,a=n.length,o=new Array(a),s=0;s1?this.each((null==e?function(t){return function(){delete this[t]}}:"function"==typeof e?function(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}:function(t,e){return function(){this[t]=e}})(t,e)):this.node()[t]}},function(t,e,n){"use strict";function i(t){return t.trim().split(/^|\s+/)}function r(t){return t.classList||new a(t)}function a(t){this._node=t,this._names=i(t.getAttribute("class")||"")}function o(t,e){for(var n=r(t),i=-1,a=e.length;++i=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}},e.a=function(t,e){var n=i(t+"");if(arguments.length<2){for(var a=r(this.node()),l=-1,u=n.length;++l=0&&(n=t.slice(i+1),t=t.slice(0,i)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}(t+"",i),o=-1,s=r.length;{if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++o0)for(var n,i,r=new Array(n),a=0;a=0&&(t=t.slice(0,e)),!t||"start"===t})}(e)?i.g:i.h;return function(){var i=o(this,t),s=i.on;s!==r&&(a=(r=s).copy()).on(e,n),i.on=a}}(n,t,e))}},function(t,e,n){"use strict";e.a=function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))}},function(t,e,n){"use strict";var i=n(72),r=n(169),a=n(70);e.a=function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=Object(i.selector)(t));for(var o=this._groups,s=o.length,l=new Array(s),u=0;ur.c&&n.name===e)return new i.a([[t]],a,e,+o)}return null}},function(t,e,n){function i(t){var e=s.shape.venn,n=r.mix({},e,t.style);return o.addFillAttrs(n,t),n}var r=n(0),a=n(18),o=n(45),s=n(7),l=r.PathUtil,u=a.registerFactory("venn",{defaultShapeType:"venn",getDefaultPoints:function(t){var e=[];return r.each(t.x,function(n,i){var r=t.y[i];e.push({x:n,y:r})}),e},getActiveCfg:function(t,e){var n=e.lineWidth||1;if("hollow"===t)return{lineWidth:n+1};return{fillOpacity:(e.fillOpacity||e.opacity||1)-.08}},getSelectedCfg:function(t,e){return e&&e.style?e.style:this.getActiveCfg(t,e)}});a.registerShape("venn","venn",{draw:function(t,e){var n=t.origin._origin.path,a=i(t),o=l.parsePathString(n);return e.addShape("path",{attrs:r.mix(a,{path:o})})},getMarkerCfg:function(t){return r.mix({symbol:"circle",radius:4},i(t))}}),a.registerShape("venn","hollow",{draw:function(t,e){var n=t.origin._origin.path,i=function(t){var e=s.shape.hollowVenn,n=r.mix({},e,t.style);return o.addStrokeAttrs(n,t),n}(t),a=l.parsePathString(n);return e.addShape("path",{attrs:r.mix(i,{path:a})})},getMarkerCfg:function(t){return r.mix({symbol:"circle",radius:4},i(t))}}),t.exports=u},function(t,e,n){function i(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function r(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var a=n(20),o=n(0),s=n(357);n(460);var l=function(t){function e(e){var n;return n=t.call(this,e)||this,o.assign(r(r(n)),s),n}i(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return e.type="violin",e.shapeType="violin",e.generatePoints=!0,e},n.createShapePointsCfg=function(e){var n=t.prototype.createShapePointsCfg.call(this,e);n.size=this.getNormalizedSize(e);var i=this.get("_sizeField");return n._size=e._origin[i],n},n.clearInner=function(){t.prototype.clearInner.call(this),this.set("defaultSize",null)},n._initAttrs=function(){var e=this.get("attrOptions"),n=e.size?e.size.field:this.get("_sizeField")?this.get("_sizeField"):"size";this.set("_sizeField",n),delete e.size,t.prototype._initAttrs.call(this)},e}(a),u=function(t){function e(){return t.apply(this,arguments)||this}i(e,t);return e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return e.hasDefaultAdjust=!0,e.adjusts=[{type:"dodge"}],e},e}(l);l.Dodge=u,a.Violin=l,a.ViolinDodge=u,t.exports=l},function(t,e,n){function i(t){var e=c.shape.venn,n=s.mix({},e,t.style);return u.addFillAttrs(n,t),t.color&&(n.stroke=n.stroke||t.color),n}function r(t){var e=c.shape.hollowVenn,n=s.mix({},e,t.style);return u.addStrokeAttrs(n,t),n}function a(t){for(var e=[],n=0;n=0;r--)for(var a=e.getFacetsByLevel(t,r),o=0;op.x||a.yf.y)return}s.style.cursor="crosshair",e.startPoint=a,e.brushShape=null,e.brushing=!0,c?c.clear():(c=n.addGroup({zIndex:5})).initTransform(),e.container=c,"POLYGON"===i&&(e.polygonPath="M "+a.x+" "+a.y)}}}},n.process=function(t){var e=this,n=e.brushing,i=e.dragging,a=e.type,o=e.plot,s=e.startPoint,l=e.xScale,u=e.yScale,c=e.canvas;if(n||i){var h={x:t.offsetX,y:t.offsetY},f=c.get("canvasDOM");if(n){f.style.cursor="crosshair";var p=o.start,g=o.end,d=e.polygonPath,v=e.brushShape,y=e.container;e.plot&&e.inPlot&&(h=e._limitCoordScope(h));var x,m,_,b;"Y"===a?(x=p.x,m=h.y>=s.y?s.y:h.y,_=Math.abs(p.x-g.x),b=Math.abs(s.y-h.y)):"X"===a?(x=h.x>=s.x?s.x:h.x,m=g.y,_=Math.abs(s.x-h.x),b=Math.abs(g.y-p.y)):"XY"===a?(h.x>=s.x?(x=s.x,m=h.y>=s.y?s.y:h.y):(x=h.x,m=h.y>=s.y?s.y:h.y),_=Math.abs(s.x-h.x),b=Math.abs(s.y-h.y)):"POLYGON"===a&&(d+="L "+h.x+" "+h.y,e.polygonPath=d,v?!v.get("destroyed")&&v.attr(r.mix({},v._attrs,{path:d})):v=y.addShape("path",{attrs:r.mix(e.style,{path:d})})),"POLYGON"!==a&&(v?!v.get("destroyed")&&v.attr(r.mix({},v._attrs,{x:x,y:m,width:_,height:b})):v=y.addShape("rect",{attrs:r.mix(e.style,{x:x,y:m,width:_,height:b})})),e.brushShape=v}else if(i){f.style.cursor="move";var w=e.selection;if(w&&!w.get("destroyed"))if("POLYGON"===a){var S=e.prePoint;e.selection.translate(h.x-S.x,h.y-S.y)}else e.dragoffX&&w.attr("x",h.x-e.dragoffX),e.dragoffY&&w.attr("y",h.y-e.dragoffY)}e.prePoint=h,c.draw();var M=e._getSelected(),C=M.data,A=M.shapes,k=M.xValues,P=M.yValues,T={data:C,shapes:A,x:h.x,y:h.y};l&&(T[l.field]=k),u&&(T[u.field]=P),e.onDragmove&&e.onDragmove(T),e.onBrushmove&&e.onBrushmove(T)}},n.end=function(t){var e=this,n=e.data,i=e.shapes,a=e.xValues,o=e.yValues,s=e.canvas,l=e.type,u=e.startPoint,c=e.chart,h=e.container,f=e.xScale,p=e.yScale,g=t.offsetX,d=t.offsetY;if(s.get("canvasDOM").style.cursor="default",Math.abs(u.x-g)<=1&&Math.abs(u.y-d)<=1)return e.brushing=!1,void(e.dragging=!1);var v={data:n,shapes:i,x:g,y:d};if(f&&(v[f.field]=a),p&&(v[p.field]=o),e.dragging)e.dragging=!1,e.onDragend&&e.onDragend(v);else if(e.brushing){e.brushing=!1;var y=e.brushShape,x=e.polygonPath;"POLYGON"===l&&(x+="z",y&&!y.get("destroyed")&&y.attr(r.mix({},y._attrs,{path:x})),e.polygonPath=x,s.draw()),e.onBrushend?e.onBrushend(v):c&&e.filter&&(h.clear(),"X"===l?f&&c.filter(f.field,function(t){return a.indexOf(t)>-1}):"Y"===l?p&&c.filter(p.field,function(t){return o.indexOf(t)>-1}):(f&&c.filter(f.field,function(t){return a.indexOf(t)>-1}),p&&c.filter(p.field,function(t){return o.indexOf(t)>-1})),c.repaint())}},n.reset=function(){var t=this.chart,e=this.filter,n=this.brushShape,i=this.canvas;t&&e&&(t.get("options").filters={},t.repaint()),n&&(n.destroy(),i.draw())},n._limitCoordScope=function(t){var e=this.plot,n=e.start,i=e.end;return t.xi.x&&(t.x=i.x),t.yn.y&&(t.y=n.y),t},n._getSelected=function(){var t=this,e=t.chart,n=t.xScale,i=t.yScale,r=t.brushShape,a=t.canvas,o=a.get("pixelRatio"),s=[],l=[],u=[],c=[];if(e){e.get("geoms").map(function(t){return t.getShapes().map(function(t){var e=t.get("origin");return Array.isArray(e)||(e=[e]),e.map(function(e){if(r.isHit(e.x*o,e.y*o)){s.push(t);var a=e._origin;c.push(a),n&&l.push(a[n.field]),i&&u.push(a[i.field])}return e}),t}),t})}return t.shapes=s,t.xValues=l,t.yValues=u,t.data=c,a.draw(),{data:c,xValues:l,yValues:u,shapes:s}},e}(n(171));t.exports=s},function(t,e,n){function i(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var r=n(0),a=n(171),o=n(469),s=n(377),l=n(378),u=["X","Y","XY"],c="X",h=function(t){function e(e,n){var a,s=i(i(a=t.call(this,e,n)||this));s.type=s.type.toUpperCase(),s.chart=n,s.coord=n.get("coord");var h=s.data=n.get("data");o(n);var f=n.getYScales(),p=n.getXScale();f.push(p);var g=n.get("scaleController");return f.forEach(function(t){var e=t.field;s.limitRange[e]=l(h,t);var n=g.defs[e]||{};s.originScaleDefsByField[e]=r.mix(n,{nice:!!n.nice}),t.isLinear&&(s.stepByField[e]=(t.max-t.min)*s.stepRatio)}),-1===u.indexOf(s.type)&&(s.type=c),s._disableTooltip(),a}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return r.mix({},e,{type:c,stepRatio:.05,limitRange:{},stepByField:{},threshold:20,originScaleDefsByField:{},previousPoint:null,isDragging:!1})},n._disableTooltip=function(){var t=this.chart;t.get("tooltipController")&&(this._showTooltip=!0,t.tooltip(!1))},n._enableTooltip=function(t){var e=this.chart;this._showTooltip&&(e.tooltip(!0),e.showTooltip(t))},n._applyTranslate=function(t,e,n){void 0===e&&(e=0);t.isLinear?this._translateLinearScale(t,e,n):this._translateCatScale(t,e,n)},n._translateCatScale=function(t,e,n){var i=this.chart,a=t.type,o=t.field,l=t.values,u=t.ticks,c=s(i,o),h=this.limitRange[o],f=e/n,p=l.length,g=Math.max(1,Math.abs(parseInt(f*p))),d=h.indexOf(l[0]),v=h.indexOf(l[p-1]);if(e>0&&d>=0){for(var y=0;y0;y++)d-=1,v-=1;var x=h.slice(d,v+1),m=null;if("timeCat"===a){for(var _=u.length>2?u[1]-u[0]:864e5,b=u[0]-_;b>=x[0];b-=_)u.unshift(b);m=u}i.scale(o,r.mix({},c,{values:x,ticks:m}))}else if(e<0&&v<=h.length-1){for(var w=0;w2?u[1]-u[0]:864e5,A=u[u.length-1]+C;A<=S[S.length-1];A+=C)u.push(A);M=u}i.scale(o,r.mix({},c,{values:S,ticks:M}))}},n._translateLinearScale=function(t,e,n){var i=this.chart,a=this.limitRange,o=t.min,l=t.max,u=t.field;if(o!==a[u].min||l!==a[u].max){var c=e/n,h=l-o,f=s(i,u);i.scale(u,r.mix({},f,{nice:!1,min:o+c*h,max:l+c*h}))}},n.start=function(t){this.canvas.get("canvasDOM").style.cursor="pointer",this.isDragging=!0,this.previousPoint={x:t.x,y:t.y},this._disableTooltip()},n.process=function(t){var e=this;if(e.isDragging){var n=e.chart,i=e.type,r=e.canvas,a=e.coord,o=e.threshold;r.get("canvasDOM").style.cursor="move";var s=e.previousPoint,l=t,u=l.x-s.x,c=l.y-s.y,h=!1;if(Math.abs(u)>o&&i.indexOf("X")>-1){h=!0;var f=n.getXScale();e._applyTranslate(f,f.isLinear?-u:u,a.width)}if(Math.abs(c)>o&&i.indexOf("Y")>-1){h=!0;n.getYScales().forEach(function(t){e._applyTranslate(t,l.y-s.y,a.height)})}h&&(e.previousPoint=l,n.repaint())}},n.end=function(t){this.isDragging=!1;this.canvas.get("canvasDOM").style.cursor="default",this._enableTooltip(t)},n.reset=function(){var t=this.view,e=this.originScaleDefsByField,n=t.getYScales(),i=t.getXScale();n.push(i),n.forEach(function(n){if(n.isLinear){var i=n.field;t.scale(i,e[i])}}),t.repaint(),this._disableTooltip()},e}(a);t.exports=h},function(t,e,n){var i=n(0),r=n(71),a=n(376);t.exports=function(t){t.on("beforeinitgeoms",function(){t.set("limitInPlot",!0);var e=t.get("data"),n=a(t);if(!n)return e;var o=t.get("geoms"),s=!1;i.each(o,function(t){if(-1!==["area","line","path"].indexOf(t.get("type")))return s=!0,!1});var l=[];if(i.each(n,function(t,e){!s&&t&&(t.values||t.min||t.max)&&l.push(e)}),0===l.length)return e;var u=[];i.each(e,function(t){var e=!0;i.each(l,function(a){var o=t[a];if(o){var s=n[a];if("timeCat"===s.type){var l=s.values;i.isNumber(l[0])&&(o=r.toTimeStamp(o))}(s.values&&-1===s.values.indexOf(o)||s.min&&os.max)&&(e=!1)}}),e&&u.push(t)}),t.set("filteredData",u)})}},function(t,e,n){var i=n(0),r=n(171),a=n(471),o=n(378),s=function(t){function e(e,n){var r,a=(r=t.call(this,e,n)||this).getDefaultCfg();return n.set("_scrollBarCfg",i.deepMix({},a,e)),n.set("_limitRange",{}),n.get("_horizontalBar")||n.get("_verticalBar")||r._renderScrollBars(),r}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return i.mix({},e,{startEvent:null,processEvent:null,endEvent:null,resetEvent:null,type:"X",xStyle:{backgroundColor:"rgba(202, 215, 239, .2)",fillerColor:"rgba(202, 215, 239, .75)",size:4,lineCap:"round",offsetX:0,offsetY:-10},yStyle:{backgroundColor:"rgba(202, 215, 239, .2)",fillerColor:"rgba(202, 215, 239, .75)",size:4,lineCap:"round",offsetX:8,offsetY:0}})},n._renderScrollBars=function(){var t=this.chart,e=t.get("_scrollBarCfg");if(e){var n=t.get("data"),i=t.get("plotRange");i.width=Math.abs(i.br.x-i.bl.x),i.height=Math.abs(i.tl.y-i.bl.y);var r=t.get("backPlot"),s=t.get("canvas").get("height"),l=t.get("_limitRange"),u=e.type;if(u.indexOf("X")>-1){var c=e.xStyle,h=c.offsetX,f=c.offsetY,p=c.lineCap,g=c.backgroundColor,d=c.fillerColor,v=c.size,y=t.getXScale(),x=l[y.field];x||(x=o(n,y),l[y.field]=x);var m=a(y,x,y.type),_=t.get("_horizontalBar"),b=s-v/2+f;if(_){_.get("children")[1].attr({x1:Math.max(i.bl.x+i.width*m[0]+h,i.bl.x),x2:Math.min(i.bl.x+i.width*m[1]+h,i.br.x)})}else(_=r.addGroup({className:"horizontalBar"})).addShape("line",{attrs:{x1:i.bl.x+h,y1:b,x2:i.br.x+h,y2:b,lineWidth:v,stroke:g,lineCap:p}}),_.addShape("line",{attrs:{x1:Math.max(i.bl.x+i.width*m[0]+h,i.bl.x),y1:b,x2:Math.min(i.bl.x+i.width*m[1]+h,i.br.x),y2:b,lineWidth:v,stroke:d,lineCap:p}}),t.set("_horizontalBar",_)}if(u.indexOf("Y")>-1){var w=e.yStyle,S=w.offsetX,M=w.offsetY,C=w.lineCap,A=w.backgroundColor,k=w.fillerColor,P=w.size,T=t.getYScales()[0],I=l[T.field];I||(I=o(n,T),l[T.field]=I);var O=a(T,I,T.type),L=t.get("_verticalBar"),E=P/2+S;if(L){L.get("children")[1].attr({y1:Math.max(i.tl.y+i.height*O[0]+M,i.tl.y),y2:Math.min(i.tl.y+i.height*O[1]+M,i.bl.y)})}else(L=r.addGroup({className:"verticalBar"})).addShape("line",{attrs:{x1:E,y1:i.tl.y+M,x2:E,y2:i.bl.y+M,lineWidth:P,stroke:A,lineCap:C}}),L.addShape("line",{attrs:{x1:E,y1:Math.max(i.tl.y+i.height*O[0]+M,i.tl.y),x2:E,y2:Math.min(i.tl.y+i.height*O[1]+M,i.bl.y),lineWidth:P,stroke:k,lineCap:C}}),t.set("_verticalBar",L)}}},n._clear=function(){var t=this.chart;if(t){var e=t.get("_horizontalBar"),n=t.get("_verticalBar");e&&e.remove(!0),n&&n.remove(!0),t.set("_horizontalBar",null),t.set("_verticalBar",null)}},n._bindEvents=function(){this._onAfterclearOrBeforechangedata=this._onAfterclearOrBeforechangedata.bind(this),this._onAfterclearinner=this._onAfterclearinner.bind(this),this._onAfterdrawgeoms=this._onAfterdrawgeoms.bind(this);var t=this.chart;t.on("afterclear",this._onAfterclearOrBeforechangedata),t.on("beforechangedata",this._onAfterclearOrBeforechangedata),t.on("afterclearinner",this._onAfterclearinner),t.on("afterdrawgeoms",this._onAfterdrawgeoms)},n._onAfterclearOrBeforechangedata=function(){this.chart&&this.chart.set("_limitRange",{})},n._onAfterclearinner=function(){this._clear()},n._onAfterdrawgeoms=function(){this._renderScrollBars()},n._clearEvents=function(){var t=this.chart;t&&(t.off("afterclear",this._onAfterclearOrBeforechangedata),t.off("beforechangedata",this._onAfterclearOrBeforechangedata),t.off("afterclearinner",this._onAfterclearinner),t.off("afterdrawgeoms",this._onAfterdrawgeoms))},n.destroy=function(){this._clearEvents(),this._clear(),this.canvas.draw()},e}(r);t.exports=s},function(t,e){t.exports=function(t,e,n){if(!t)return[0,1];var i=0,r=0;if("linear"===n){var a=e.min,o=e.max-a;i=(t.min-a)/o,r=(t.max-a)/o}else{var s=e,l=t.values,u=s.indexOf(l[0]),c=s.indexOf(l[l.length-1]);i=u/(s.length-1),r=c/(s.length-1)}return[i,r]}},function(t,e,n){function i(t,e){var n={};for(var i in e)n[i]=t[i];return n}var r=n(0),a=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return r.mix({},e,{startEvent:"mouseup",processEvent:null,selectStyle:{fillOpacity:1},unSelectStyle:{fillOpacity:.1},cancelable:!0})},n.start=function(t){var e,n=[];if(this.view.eachShape(function(i,r){r.isPointInPath(t.x,t.y)?e=r:n.push(r)}),e)if(e.get("_selected")){if(!this.cancelable)return;this.reset()}else{var a=this.selectStyle,o=this.unSelectStyle,s=i(e.attr(),e);e.set("_originAttrs",s),e.attr(a),r.each(n,function(t){var e=t.get("_originAttrs");e&&t.attr(e),t.set("_selected",!1),o&&(e=i(t.attr(),o),t.set("_originAttrs",e),t.attr(o))}),e.set("_selected",!0),this.selectedShape=e,this.canvas.draw()}else this.reset()},n.end=function(t){var e=this.selectedShape;e&&!e.get("destroyed")&&e.get("origin")&&(t.data=e.get("origin")._origin,t.shapeInfo=e.get("origin"),t.shape=e,t.selected=!!e.get("_selected"))},n.reset=function(){if(this.selectedShape){var t=this.view.get("geoms")[0].get("container").get("children")[0].get("children");r.each(t,function(t){var e=t.get("_originAttrs");e&&(t._attrs=e,t.set("_originAttrs",null)),t.set("_selected",!1)}),this.canvas.draw()}},e}(n(171));t.exports=a},function(t,e,n){function i(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var r=n(474),a=n(147),o=n(0),s=n(16),l=n(7),u=n(171),c=n(377),h=n(376),f=s.Canvas,p=o.DomUtil,g=o.isNumber,d=function(t){function e(e,n){var r,a=i(i(r=t.call(this,e,n)||this));return a._initContainer(),a._initStyle(),a.render(),r}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return o.mix({},e,{startEvent:null,processEvent:null,endEvent:null,resetEvent:null,height:26,width:"auto",padding:l.plotCfg.padding,container:null,xAxis:null,yAxis:null,fillerStyle:{fill:"#BDCCED",fillOpacity:.3},backgroundStyle:{stroke:"#CCD6EC",fill:"#CCD6EC",fillOpacity:.3,lineWidth:1},range:[0,100],layout:"horizontal",textStyle:{fill:"#545454"},handleStyle:{img:"https://gw.alipayobjects.com/zos/rmsportal/QXtfhORGlDuRvLXFzpsQ.png",width:5},backgroundChart:{type:["area"],color:"#CCD6EC"}})},n._initContainer=function(){var t=this.container;if(!t)throw new Error("Please specify the container for the Slider!");o.isString(t)?this.domContainer=document.getElementById(t):this.domContainer=t},n.forceFit=function(){var t=this;if(t&&!t.destroyed){var e=p.getWidth(t.domContainer),n=t.height;if(e!==t.domWidth){var i=t.canvas;i.changeSize(e,n),t.bgChart&&t.bgChart.changeWidth(e),i.clear(),t._initWidth(),t._initSlider(),t._bindEvent(),i.draw()}}},n._initForceFitEvent=function(){var t=setTimeout(o.wrapBehavior(this,"forceFit"),200);clearTimeout(this.resizeTimer),this.resizeTimer=t},n._initStyle=function(){var t=this;t.handleStyle=o.mix({width:t.height,height:t.height},t.handleStyle),"auto"===t.width&&window.addEventListener("resize",o.wrapBehavior(t,"_initForceFitEvent"))},n._initWidth=function(){var t,e=this;t="auto"===e.width?p.getWidth(e.domContainer):e.width,e.domWidth=t;var n=o.toAllPadding(e.padding);"horizontal"===e.layout?(e.plotWidth=t-n[1]-n[3],e.plotPadding=n[3],e.plotHeight=e.height):"vertical"===e.layout&&(e.plotWidth=e.width,e.plotHeight=e.height-n[0]-n[2],e.plotPadding=n[0])},n._initCanvas=function(){var t=this.domWidth,e=this.height,n=new f({width:t,height:e,containerDOM:this.domContainer,capture:!1}),i=n.get("el");i.style.position="absolute",i.style.top=0,i.style.left=0,i.style.zIndex=3,this.canvas=n},n._initBackground=function(){var t,e=this,n=this.chart,i=n.getAllGeoms[0],r=e.data=e.data||n.get("data"),s=n.getXScale(),l=e.xAxis||s.field,u=e.yAxis||n.getYScales()[0].field,c=o.deepMix((t={},t[""+l]={range:[0,1]},t),h(n),e.scales);if(delete c[l].min,delete c[l].max,!r)throw new Error("Please specify the data!");if(!l)throw new Error("Please specify the xAxis!");if(!u)throw new Error("Please specify the yAxis!");var f=e.backgroundChart,p=f.type||i.get("type"),g=f.color||"grey";o.isArray(p)||(p=[p]);var d=o.toAllPadding(e.padding),v=new a({container:e.container,width:e.domWidth,height:e.height,padding:[0,d[1],0,d[3]],animate:!1});v.source(r),v.scale(c),v.axis(!1),v.tooltip(!1),v.legend(!1),o.each(p,function(t){v[t]().position(l+"*"+u).color(g).opacity(1)}),v.render(),e.bgChart=v,e.scale="horizontal"===e.layout?v.getXScale():v.getYScales()[0],"vertical"===e.layout&&v.destroy()},n._initRange=function(){var t=this,e=t.startRadio,n=t.endRadio,i=t._startValue,r=t._endValue,a=t.scale,o=0,s=1;g(e)?o=e:i&&(o=a.scale(a.translate(i))),g(n)?s=n:r&&(s=a.scale(a.translate(r)));var l=t.minSpan,u=t.maxSpan,c=0;if("time"===a.type||"timeCat"===a.type){var h=a.values,f=h[0];c=h[h.length-1]-f}else a.isLinear&&(c=a.max-a.min);c&&l&&(t.minRange=l/c*100),c&&u&&(t.maxRange=u/c*100);var p=[100*o,100*s];return t.range=p,p},n._getHandleValue=function(t){var e=this,n=e.range,i=n[0]/100,r=n[1]/100,a=e.scale;return"min"===t?e._startValue?e._startValue:a.invert(i):e._endValue?e._endValue:a.invert(r)},n._initSlider=function(){var t=this,e=t.canvas,n=t._initRange(),i=t.scale,a=e.addGroup(r,{middleAttr:t.fillerStyle,range:n,minRange:t.minRange,maxRange:t.maxRange,layout:t.layout,width:t.plotWidth,height:t.plotHeight,backgroundStyle:t.backgroundStyle,textStyle:t.textStyle,handleStyle:t.handleStyle,minText:i.getText(t._getHandleValue("min")),maxText:i.getText(t._getHandleValue("max"))});"horizontal"===t.layout?a.translate(t.plotPadding,0):"vertical"===t.layout&&a.translate(0,t.plotPadding),t.rangeElement=a},n._updateElement=function(t,e){var n=this,i=n.chart,r=n.scale,a=n.rangeElement,s=r.field,l=a.get("minTextElement"),u=a.get("maxTextElement"),h=r.invert(t),f=r.invert(e),p=r.getText(h),g=r.getText(f);l.attr("text",p),u.attr("text",g),n._startValue=p,n._endValue=g,n.onChange&&n.onChange({startText:p,endText:g,startValue:h,endValue:f,startRadio:t,endRadio:e}),i.scale(s,o.mix({},c(i,s),{nice:!1,min:h,max:f})),i.repaint()},n._bindEvent=function(){var t=this;t.rangeElement.on("sliderchange",function(e){var n=e.range,i=n[0]/100,r=n[1]/100;t._updateElement(i,r)})},n.clear=function(){var t=this;t.canvas.clear(),t.bgChart&&t.bgChart.destroy(),t.bgChart=null,t.scale=null,t.canvas.draw()},n.repaint=function(){this.clear(),this.render()},n.render=function(){var t=this;t._initWidth(),t._initCanvas(),t._initBackground(),t._initSlider(),t._bindEvent(),t.canvas.draw()},n.destroy=function(){var t=this;clearTimeout(t.resizeTimer);t.rangeElement.off("sliderchange"),t.bgChart&&t.bgChart.destroy(),t.canvas.destroy();for(var e=t.domContainer;e.hasChildNodes();)e.removeChild(e.firstChild);window.removeEventListener("resize",o.getWrapBehavior(t,"_initForceFitEvent")),t.destroyed=!0},e}(u);t.exports=d},function(t,e,n){var i=n(0),r=n(16).Group,a=i.DomUtil,o=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){return{range:null,middleAttr:null,backgroundElement:null,minHandleElement:null,maxHandleElement:null,middleHandleElement:null,currentTarget:null,layout:"vertical",width:null,height:null,pageX:null,pageY:null}},n._initHandle=function(t){var e,n,r,a=this.addGroup(),o=this.get("layout"),s=this.get("handleStyle"),l=s.img,u=s.width,c=s.height;if("horizontal"===o){var h=s.width;r="ew-resize",n=a.addShape("Image",{attrs:{x:-h/2,y:0,width:h,height:c,img:l,cursor:r}}),e=a.addShape("Text",{attrs:i.mix({x:"min"===t?-(h/2+5):h/2+5,y:c/2,textAlign:"min"===t?"end":"start",textBaseline:"middle",text:"min"===t?this.get("minText"):this.get("maxText"),cursor:r},this.get("textStyle"))})}else r="ns-resize",n=a.addShape("Image",{attrs:{x:0,y:-c/2,width:u,height:c,img:l,cursor:r}}),e=a.addShape("Text",{attrs:i.mix({x:u/2,y:"min"===t?c/2+5:-(c/2+5),textAlign:"center",textBaseline:"middle",text:"min"===t?this.get("minText"):this.get("maxText"),cursor:r},this.get("textStyle"))});return this.set(t+"TextElement",e),this.set(t+"IconElement",n),a},n._initSliderBackground=function(){var t=this.addGroup();return t.initTransform(),t.translate(0,0),t.addShape("Rect",{attrs:i.mix({x:0,y:0,width:this.get("width"),height:this.get("height")},this.get("backgroundStyle"))}),t},n._beforeRenderUI=function(){var t=this._initSliderBackground(),e=this._initHandle("min"),n=this._initHandle("max"),i=this.addShape("rect",{attrs:this.get("middleAttr")});this.set("middleHandleElement",i),this.set("minHandleElement",e),this.set("maxHandleElement",n),this.set("backgroundElement",t),t.set("zIndex",0),i.set("zIndex",1),e.set("zIndex",2),n.set("zIndex",2),i.attr("cursor","move"),this.sort()},n._renderUI=function(){"horizontal"===this.get("layout")?this._renderHorizontal():this._renderVertical()},n._transform=function(t){var e=this.get("range"),n=e[0]/100,i=e[1]/100,r=this.get("width"),a=this.get("height"),o=this.get("minHandleElement"),s=this.get("maxHandleElement"),l=this.get("middleHandleElement");o.resetMatrix?(o.resetMatrix(),s.resetMatrix()):(o.initTransform(),s.initTransform()),"horizontal"===t?(l.attr({x:r*n,y:0,width:(i-n)*r,height:a}),o.translate(n*r,0),s.translate(i*r,0)):(l.attr({x:0,y:a*(1-i),width:r,height:(i-n)*a}),o.translate(0,(1-n)*a),s.translate(0,(1-i)*a))},n._renderHorizontal=function(){this._transform("horizontal")},n._renderVertical=function(){this._transform("vertical")},n._bindUI=function(){this.on("mousedown",i.wrapBehavior(this,"_onMouseDown"))},n._isElement=function(t,e){var n=this.get(e);if(t===n)return!0;if(n.isGroup){return n.get("children").indexOf(t)>-1}return!1},n._getRange=function(t,e){var n=t+e;return n=n>100?100:n,n=n<0?0:n},n._limitRange=function(t,e,n){n[0]=this._getRange(t,n[0]),n[1]=n[0]+e,n[1]>100&&(n[1]=100,n[0]=n[1]-e)},n._updateStatus=function(t,e){var n="x"===t?this.get("width"):this.get("height");t=i.upperFirst(t);var r,a=this.get("range"),o=this.get("page"+t),s=this.get("currentTarget"),l=this.get("rangeStash"),u="vertical"===this.get("layout")?-1:1,c=e["page"+t],h=(c-o)/n*100*u,f=this.get("minRange"),p=this.get("maxRange");a[1]<=a[0]?(this._isElement(s,"minHandleElement")||this._isElement(s,"maxHandleElement"))&&(a[0]=this._getRange(h,a[0]),a[1]=this._getRange(h,a[0])):(this._isElement(s,"minHandleElement")&&(a[0]=this._getRange(h,a[0]),f&&a[1]-a[0]<=f&&this._limitRange(h,f,a),p&&a[1]-a[0]>=p&&this._limitRange(h,p,a)),this._isElement(s,"maxHandleElement")&&(a[1]=this._getRange(h,a[1]),f&&a[1]-a[0]<=f&&this._limitRange(h,f,a),p&&a[1]-a[0]>=p&&this._limitRange(h,p,a))),this._isElement(s,"middleHandleElement")&&(r=l[1]-l[0],this._limitRange(h,r,a)),this.emit("sliderchange",{range:a}),this.set("page"+t,c),this._renderUI(),this.get("canvas").draw()},n._onMouseDown=function(t){var e=t.currentTarget,n=t.event,i=this.get("range");n.stopPropagation(),n.preventDefault(),this.set("pageX",n.pageX),this.set("pageY",n.pageY),this.set("currentTarget",e),this.set("rangeStash",[i[0],i[1]]),this._bindCanvasEvents()},n._bindCanvasEvents=function(){var t=this.get("canvas").get("containerDOM");this.onMouseMoveListener=a.addEventListener(t,"mousemove",i.wrapBehavior(this,"_onCanvasMouseMove")),this.onMouseUpListener=a.addEventListener(t,"mouseup",i.wrapBehavior(this,"_onCanvasMouseUp")),this.onMouseLeaveListener=a.addEventListener(t,"mouseleave",i.wrapBehavior(this,"_onCanvasMouseUp"))},n._onCanvasMouseMove=function(t){"horizontal"===this.get("layout")?this._updateStatus("x",t):this._updateStatus("y",t)},n._onCanvasMouseUp=function(){this._removeDocumentEvents()},n._removeDocumentEvents=function(){this.onMouseMoveListener.remove(),this.onMouseUpListener.remove(),this.onMouseLeaveListener.remove()},e}(r);t.exports=o},function(t,e,n){function i(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var r=n(0),a=n(171),o=n(377),s=n(378),l=["X","Y","XY"],u="X",c=function(t){function e(e,n){var a,o=i(i(a=t.call(this,e,n)||this));o.chart=n,o.type=o.type.toUpperCase();var c=o.data=n.get("data"),h=n.getYScales(),f=n.getXScale();h.push(f);var p=n.get("scaleController");return h.forEach(function(t){var e=t.field,n=p.defs[e]||{};o.limitRange[e]=s(c,t),o.originScaleDefsByField[e]=r.mix(n,{nice:!!n.nice}),t.isLinear?o.stepByField[e]=(t.max-t.min)*o.stepRatio:o.stepByField[e]=o.catStep}),-1===l.indexOf(o.type)&&(o.type=u),a}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return r.mix({},e,{processEvent:"mousewheel",type:u,stepRatio:.05,stepByField:{},minScale:1,maxScale:4,catStep:2,limitRange:{},originScaleDefsByField:{}})},n._applyScale=function(t,e,n,i){void 0===n&&(n=0);var a=this,s=a.chart,l=a.stepByField;if(t.isLinear){var u=t.min,c=t.max,h=t.field,f=1-n,p=l[h]*e,g=u+p*n,d=c-p*f;d>g&&s.scale(h,{nice:!1,min:g,max:d})}else{var v=t.field,y=t.values,x=a.chart,m=x.get("coord"),_=o(x,v),b=a.limitRange[v],w=b.length,S=w/a.maxScale,M=w/a.minScale,C=y.length,A=m.invertPoint(i).x,k=C-e*this.catStep,P=parseInt(k*A),T=k+P;if(e>0&&C>=S){var I=P,O=T;T>C&&(O=C-1,I=C-k);var L=y.slice(I,O);x.scale(v,r.mix({},_,{values:L}))}else if(e<0&&C<=M){var E=b.indexOf(y[0]),D=b.indexOf(y[C-1]),F=Math.max(0,E-P),B=Math.min(D+T,w),R=b.slice(F,B);x.scale(v,r.mix({},_,{values:R}))}}},n.process=function(t){var e=this,n=e.chart,i=e.type,r=n.get("coord"),a=t.deltaY,o=r.invertPoint(t);if(a){e.onZoom&&e.onZoom(a,o,e),a>0?e.onZoomin&&e.onZoomin(a,o,e):e.onZoomout&&e.onZoomout(a,o,e);var s=a/Math.abs(a);if(i.indexOf("X")>-1&&e._applyScale(n.getXScale(),s,o.x,t),i.indexOf("Y")>-1){n.getYScales().forEach(function(n){e._applyScale(n,s,o.y,t)})}}n.repaint()},n.reset=function(){var t=this.view,e=this.originScaleDefsByField,n=t.getYScales(),i=t.getXScale();n.push(i),n.forEach(function(n){if(n.isLinear){var i=n.field;t.scale(i,e[i])}}),t.repaint()},e}(a);t.exports=c}])}); \ No newline at end of file diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/js/jquery.min.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/js/jquery.min.js new file mode 100755 index 00000000..fad9ab12 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/lib/js/jquery.min.js @@ -0,0 +1,5 @@ +/*! jQuery v2.1.4 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */ +!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.4",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)+1>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b="length"in a&&a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),T=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),U=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),V=new RegExp(P),W=new RegExp("^"+N+"$"),X={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+O),PSEUDO:new RegExp("^"+P),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,aa=/[+~]/,ba=/'|\\/g,ca=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),da=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ea=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(fa){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],k=b.nodeType,"string"!=typeof a||!a||1!==k&&9!==k&&11!==k)return d;if(!e&&p){if(11!==k&&(f=_.exec(a)))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return H.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName)return H.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=1!==k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(ba,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+ra(o[l]);w=aa.test(a)&&pa(b.parentNode)||b,x=o.join(",")}if(x)try{return H.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=g.documentElement,e=g.defaultView,e&&e!==e.top&&(e.addEventListener?e.addEventListener("unload",ea,!1):e.attachEvent&&e.attachEvent("onunload",ea)),p=!f(g),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(g.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(g.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!g.getElementsByName||!g.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(g.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){var b=g.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",P)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===g||a.ownerDocument===v&&t(v,a)?-1:b===g||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,h=[a],i=[b];if(!e||!f)return a===g?-1:b===g?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?la(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},g):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ca,da),a[3]=(a[3]||a[4]||a[5]||"").replace(ca,da),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ca,da).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(Q," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(ca,da),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return W.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(ca,da).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:oa(function(){return[0]}),last:oa(function(a,b){return[b-1]}),eq:oa(function(a,b,c){return[0>c?c+b:c]}),even:oa(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:oa(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:oa(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:oa(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function sa(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function ta(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ua(a,b,c){for(var d=0,e=b.length;e>d;d++)ga(a,b[d],c);return c}function va(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function wa(a,b,c,d,e,f){return d&&!d[u]&&(d=wa(d)),e&&!e[u]&&(e=wa(e,f)),ia(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ua(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:va(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=va(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=va(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function xa(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sa(function(a){return a===b},h,!0),l=sa(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[sa(ta(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return wa(i>1&&ta(m),i>1&&ra(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&xa(a.slice(i,e)),f>e&&xa(a=a.slice(e)),f>e&&ra(a))}m.push(c)}return ta(m)}function ya(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=F.call(i));s=va(s)}H.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&ga.uniqueSort(i)}return k&&(w=v,j=t),r};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=xa(b[c]),f[u]?d.push(f):e.push(f);f=A(a,ya(e,d)),f.selector=a}return f},i=ga.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(ca,da),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(ca,da),aa.test(j[0].type)&&pa(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&ra(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,aa.test(a)&&pa(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ja(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+K.uid++}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){ +return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthx",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,ba=/<([\w:]+)/,ca=/<|&#?\w+;/,da=/<(?:script|style|link)/i,ea=/checked\s*(?:[^=]|=\s*.checked.)/i,fa=/^$|\/(?:java|ecma)script/i,ga=/^true\/(.*)/,ha=/^\s*\s*$/g,ia={option:[1,""],thead:[1,"","
        "],col:[2,"","
        "],tr:[2,"","
        "],td:[3,"","
        "],_default:[0,"",""]};ia.optgroup=ia.option,ia.tbody=ia.tfoot=ia.colgroup=ia.caption=ia.thead,ia.th=ia.td;function ja(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function ka(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function la(a){var b=ga.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function ma(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function na(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function oa(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pa(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=oa(h),f=oa(a),d=0,e=f.length;e>d;d++)pa(f[d],g[d]);if(b)if(c)for(f=f||oa(a),g=g||oa(h),d=0,e=f.length;e>d;d++)na(f[d],g[d]);else na(a,h);return g=oa(h,"script"),g.length>0&&ma(g,!i&&oa(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(ca.test(e)){f=f||k.appendChild(b.createElement("div")),g=(ba.exec(e)||["",""])[1].toLowerCase(),h=ia[g]||ia._default,f.innerHTML=h[1]+e.replace(aa,"<$1>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=oa(k.appendChild(e),"script"),i&&ma(f),c)){j=0;while(e=f[j++])fa.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=ja(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=ja(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(oa(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&ma(oa(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(oa(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!da.test(a)&&!ia[(ba.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(aa,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(oa(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(oa(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&ea.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(oa(c,"script"),ka),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,oa(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,la),j=0;g>j;j++)h=f[j],fa.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(ha,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qa,ra={};function sa(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function ta(a){var b=l,c=ra[a];return c||(c=sa(a,b),"none"!==c&&c||(qa=(qa||n("