diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..8b09cc08 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git +.tox +test* +Dockerfile* +*~ +screenshots diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..bb42c23d --- /dev/null +++ b/Makefile @@ -0,0 +1,39 @@ +.PHONY: \ + all \ + check \ + clean \ + log \ + logs \ + redeploy \ + restart \ + setup \ + +all: check + +check: + tox + +clean: + rm -rf .tox + +# Use like "make log service=dashboard" +log: + docker-compose logs -f ${service} --tail=100 + +logs: + docker-compose logs -f --tail=100 + +# Use like "make redeploy service=dashboard" +redeploy: + bash scripts/redeploy.sh ${service} + +start: + bash scripts/start.sh + +stop: + bash scripts/stop.sh + +restart: stop start + +setup: + bash scripts/setup.sh diff --git a/README.md b/README.md index 76b43072..697a4b5a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,55 @@ -Cello -=== +![Cello](docs/imgs/logo.png) -TBD. +[![Build Status](https://travis-ci.org/yeasy/cello.svg?branch=dev)](https://travis-ci.org/yeasy/cello) + +Platform to provide Blockchain as a Service! + +Using Cello, we can + +* Provision customizable Blockchains instantly, e.g., a 6-node chain using PBFT consensus. +* Maintain a pool of running blockchains healthy with no manual operations. +* Check the system status, scale the chain numbers, change resources... through a dashboard. + +![Typical Scenario](docs/imgs/scenario.png) + +You can also find more [scenarios](docs/scenario.md). + +## Features + +* Manage the lifecycle of blockchains, e.g., create/delete/keep health automatically. +* Response nearly instantly, even with hundreds of chains, or nodes. +* Support customized (e.g., size, consensus) blockchains request, currently we support [hyperledger fabric](https://github.com/hyperledger/fabric). +* Support native Docker host or swarm host as the compute nodes, more supports on the way. +* Support heterogeneous architecture, e.g., Z, Power and X86, from bare-metal servers to virtual machines. +* Extend with monitor/log/health features by employing additional components. + +## Docs + +### User Docs +* [Dashboard](docs/dashboard.md) + +### Operator Docs +* [Installation & Deployment](docs/deployment.md) +* [Scenarios](docs/scenario.md) +* [Production Configuration](docs/production_config.md) + +### Development Docs +* [Architecture Design](docs/arch.md) +* [Database Model](docs/db.md) +* [API](api/restserver_v2.md) + +## TODO +* restserver: update api definitions yml files. +* dashboard: support auto state fresh based on websocket. +* dashboard: support return code checking in response. +* dashboard: support user page. +* engine: support advanced scheduling. +* engine: support more-efficient fill-up. +* engine: enhance the robustness for chain operations. +* engine: support membersrvc option. + +## Why named Cello? +Can u find anyone better at playing chains? :) + +## Author +Designed and maintained by [Baohua Yang](https://yeasy.github.com). diff --git a/api/dashboard.yaml b/api/dashboard.yaml new file mode 100644 index 00000000..8f69b8ef --- /dev/null +++ b/api/dashboard.yaml @@ -0,0 +1,158 @@ +# this is an example of the Cello API +# as a demonstration of an API spec in YAML +swagger: '2.0' +info: + title: Cello API + description: Cello API to manage cluster + contact: + name: Baohua Yang + url: https://github.com/yeasy/cello + email: yangbaohua@gmail.com + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + version: "1.0.0" +# the domain of the service +host: 9.186.100.88:80 +# array of all schemes that your API supports +schemes: + - http +# will be prefixed to all paths +basePath: /admin +produces: + - application/json +paths: + /clusters: + get: + summary: A list of all clusters + description: | + The Clusters endpoint returns information about all existing clusters. + The response includes the display name + and other details about each cluster, and lists the clusters in the + proper display order. + parameters: + - name: daemon_url + in: query + description: Filter clusters with specific daemon_url. + required: false + type: string + - name: user_id + in: query + description: Filter clusters with specific user_id. + required: false + type: string + tags: + - Clusters + responses: + 200: + description: An array of clusters + schema: + type: array + items: + $ref: '#/definitions/Cluster' + default: + description: Unexpected error + schema: + $ref: '#/definitions/Error' + /cluster: + get: + summary: Retrieve a special cluster + description: | + The endpoint returns information about specific cluster. + The response includes necessary info. + parameters: + - name: cluster_id + in: query + description: Filter clusters with specific cluster_id. + required: true + type: string + tags: + - Cluster + responses: + 200: + description: A cluster instance + schema: + $ref: '#/definitions/Cluster' + default: + description: Unexpected error + schema: + $ref: '#/definitions/Error' + post: + summary: Create a special cluster + description: | + The endpoint create a specific cluster + The response includes necessary info. + parameters: + - name: daemon_url + in: query + description: Given the daemon_url to create at + required: true + type: string + - name: cluster_name + in: query + description: Given the name + required: false + type: string + tags: + - Cluster + responses: + 200: + description: A cluster instance created + schema: + $ref: '#/definitions/Cluster' + default: + description: Unexpected error + schema: + $ref: '#/definitions/Error' + delete: + summary: Delete a special cluster + description: | + The endpoint deletes a specific cluster + The response includes necessary info. + parameters: + - name: cluster_id + in: query + description: Filter clusters with specific cluster_id. + required: true + type: string + tags: + - Cluster + responses: + 200: + description: A cluster instance delete info + type: string (TODO) + default: + description: Unexpected error + schema: + $ref: '#/definitions/Error' +definitions: + Cluster: + type: object + required: [id, user_id, api_url] + properties: + id: + type: string + description: Unique identifier representing a specific cluster. + user_id: + type: string + description: User id who owns this cluster, empty by default + api_url: + type: string + description: Cluster REST URL representing the cluster. + daemon_url: + type: string + description: Docker host daemon url + name: + type: string + description: Display name of cluster. + Error: + type: object + required: [code] + properties: + code: + type: integer + format: int32 + message: + type: string + fields: + type: string diff --git a/api/restserver_v1.md b/api/restserver_v1.md new file mode 100644 index 00000000..90536c52 --- /dev/null +++ b/api/restserver_v1.md @@ -0,0 +1,42 @@ +# API V1 + +**Deprecated.** + +## Front +These APIs will be called by front web services. + +Latest version please see [restserver.yaml](restserver.yaml). + +### cluster_apply + +Find an available cluster in the pool for a user. + +``` +GET /v1/cluster_apply?user_id=xxx&consensus_plugin=pbft&consensus_mode +=classic&size=4&new=0 +``` + +if add `new=1`, then ignore matched clusters that user already occupy. + +When `cluster_apply` request arrives, the server will try checking available cluster in the pool. + +Accordingly, the server will return a json response (succeed or fail). + +### cluster_release + +Declare the id to release a cluster. + +``` +GET /v1/cluster_release?cluster_id=xxxxxxxx +``` + +Rlease all clusters under a user account. +``` +GET /v1/cluster_release?user_id=xxxxxxxx +``` +The server will drop the corresponding cluster, recreate it and put into available pool for future requests. + + +## Admin +Those APIs should not be called by outside applications. Just for +information, please see [api-admin.yaml](api-admin.yaml) diff --git a/api/restserver_v1.yaml b/api/restserver_v1.yaml new file mode 100644 index 00000000..a30c34e7 --- /dev/null +++ b/api/restserver_v1.yaml @@ -0,0 +1,106 @@ +# this is an example of the Cello API +# as a demonstration of an API spec in YAML +swagger: '2.0' +info: + title: Cello API + description: Cello API for the rest server calling + contact: + name: Baohua Yang + url: https://github.com/yeasy/cello + email: yangbaohua@gmail.com + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + version: "1.1.0" +# the domain of the service +host: 9.186.100.88:80 +# array of all schemes that your API supports +schemes: + - http +# will be prefixed to all paths +basePath: /v2 +produces: + - application/json +paths: + /cluster_apply: + get: + summary: Apply a new cluster for use. + description: | + The endpoint returns information about the new cluster + The response includes the uuid, display name and other details . + parameters: + - name: user_id + in: query + description: The id to specify the user. + required: true + type: string + tags: + - Cluster_apply + responses: + 200: + description: An instance of clusters. + schema: + $ref: '#/definitions/Cluster' + 404: + description: Entity not found. + default: + description: Unexpected error + schema: + $ref: '#/definitions/Error' + /cluster_release: + get: + summary: Release a cluster, no use it more. + description: | + The endpoint returns information about the action. + The response includes message about result. + parameters: + - name: user_id + in: query + description: The id to specify the user. + required: true + type: string + tags: + - Cluster_release + responses: + 200: + description: message tell success. + schema: + type: string + 404: + description: Entity not found. + default: + description: Unexpected error + schema: + $ref: '#/definitions/Error' + +definitions: + Cluster: + type: object + required: [id, user_id, api_url] + properties: + id: + type: string + description: Unique identifier representing a specific cluster. + user_id: + type: string + description: User id who owns this cluster, empty by default + api_url: + type: string + description: Cluster REST URL representing the cluster. + host_id: + type: string + description: Which host the cluster is at. + name: + type: string + description: Display name of cluster. + Error: + type: object + required: [code] + properties: + code: + type: integer + format: int32 + message: + type: string + fields: + type: string \ No newline at end of file diff --git a/api/restserver_v2.md b/api/restserver_v2.md new file mode 100644 index 00000000..e262f742 --- /dev/null +++ b/api/restserver_v2.md @@ -0,0 +1,169 @@ +# API V2 + +Each url should have the `/v2` prefix, e.g., `/cluster_op` should be `/v2/cluster_op`. + +## Rest Server +These APIs will be called by front web services. + +Latest version please see [restserver.yaml](restserver.yaml). + +### Cluster + +Basic request may looks like: + +``` +POST /cluster_op +{ +action:xxx, +key:value +} +``` + +Or + +``` +GET /cluster_op?action=xxx&key=value +``` + +The supported actions can be +* `apply`: apply a chain +* `release`: release a chain, possibly only one peer +* `start`: start a chain, possibly only one peer +* `stop`: stop a chain, possibly only one peer +* `restart`: restart a chain, possibly only one peer + +We may show only one of the GET or POST request in the following sections. + +#### Cluster apply + +Apply an available cluster for a user, support multiple filters like consensus_plugin, size. + +``` +POST /cluster_op +{ +action:apply, +user_id:xxx, +allow_multiple:False, +consensus_plugin:pbft, +consensus_mode:batch, +size:4 +} +``` + +if `allow_multiple:True`, then ignore matched clusters that user already occupied. + +When `apply` request arrives, the server will try checking available cluster in the pool. + +Accordingly, the server will return a json response (succeed or fail). + +```json +{ + "code": 200, + "data": { + "api_url": "http://192.168.7.62:5004", + "consensus_mode": "batch", + "consensus_plugin": "pbft", + "daemon_url": "tcp://192.168.7.62:2375", + "id": "576ba021414b0502864d0306", + "name": "compute2_4", + "size": 4, + "user_id": "xxx" + }, + "error": "", + "status": "OK" +} +``` + +#### Cluster release + +Release a specific cluster. + +``` +POST /cluster_op +{ +action:release, +cluster_id:xxxxxxxx +} +``` + +Return json object may look like + +```json +{ + "code": 200, + "data": "", + "error": "", + "status": "OK" +} +``` + +Release all clusters under a user account. + +``` +POST /cluster_op +{ +action:release, +user_id:xxxxxxxx +} +``` + +The server will drop the corresponding cluster, recreate it and put into available pool for future requests. + + +#### Cluster Start, Stop or Restart + +Take `start` for example, you can specify the node_id if to operate one node. + +``` +POST /cluster_op +{ +action:start, +cluster_id:xxx, +node_id:vp0 +} +``` + +### Clusters List + +Return the json object whose data may contain list of cluster ids. + +List all available cluster of given type. + +``` +POST /clusters +{ +consensus_plugin:pbft, +consensus_mode:classic, +size:4, +user_id:"" +} +``` + +Query all cluster of given type + +``` +POST /clusters +{ +consensus_plugin:pbft, +consensus_mode:classic, +size:4, +} +``` + +Query the clusters for a user. + + +``` +POST /clusters +{ +user_id:xxx +} +``` + +### Get object of a cluster + +``` +GET /cluster/xxxxxxx +``` + +Will return the json object whose data may contain detailed information of cluster. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..4e038c68 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,98 @@ +# This compose file will deploy the services, and bootup a mongo server. +# Local `/opt/cello/mongo` will be used for the db storage. +# dashbard: dashbard service of cello, listen on 8080 +# app: app service of cello, listen on 80 +# nginx: front end +# mongo: mongo db + +version: '2' +services: + # cello dashbard service + dashboard: + build: + context: src + dockerfile: Dockerfile-dashboard + image: cello-dashbard + container_name: dashbard + hostname: cello-dashbard + restart: unless-stopped + environment: + - MONGO_URL=mongodb://mongo:27017 + - MONGO_DB=dev + - DEBUG=True # in debug mode, service will auto-restart + - LOG_LEVEL=DEBUG # what level log will be output + expose: + - "8080" + volumes: # This should be removed in product env + - ./src:/app + + # cello restserver service + restserver: + build: + context: src + dockerfile: Dockerfile-restserver + image: cello-restserver + container_name: restserver + hostname: cello-restserver + restart: unless-stopped + environment: + - MONGO_URL=mongodb://mongo:27017 + - MONGO_DB=dev + - DEBUG=True # in debug mode, service will auto-restart + - LOG_LEVEL=DEBUG # what level log will be output + expose: + - "80" + volumes: # This should be removed in product env + - ./src:/app + + # cello watchdog service + watchdog: + build: + context: src + dockerfile: Dockerfile-watchdog + image: cello-watchdog + container_name: watchdog + hostname: cello-watchdog + restart: unless-stopped + environment: + - MONGO_URL=mongodb://mongo:27017 + - MONGO_DB=dev + - DEBUG=True # in debug mode, service will auto-restart + - LOG_LEVEL=DEBUG # what level log will be output + volumes: # This should be removed in product env + - ./src:/app + + # mongo database, may use others in future + mongo: + image: mongo:3.2 + hostname: mongo + container_name: mongo + restart: unless-stopped + mem_limit: 2048m + ports: + #- "27017:27017" # use follow line instead in production env + - "127.0.0.1:27017:27017" + - "127.0.0.1:27018:27018" + environment: + - NO_USED=0 + volumes: + - /opt/cello/mongo:/data/db + + # nginx to forward front request, may split it out in future + nginx: + image: yeasy/nginx + hostname: nginx + container_name: nginx + restart: always + mem_limit: 2048m + volumes: + - ./nginx/nginx.conf:/etc/nginx/nginx.default.conf + #- /opt/cello/nginx/log/:/var/log/nginx/ + ports: + - "80:80" + - "8080:8080" + environment: + - BACKEND=dashbard + - PORT=8080 + - USERNAME=admin + - PASSWORD=pass \ No newline at end of file diff --git a/docs/arch.md b/docs/arch.md new file mode 100644 index 00000000..085e3c3d --- /dev/null +++ b/docs/arch.md @@ -0,0 +1,36 @@ +# Architecture Design + +Here we discuss the architecture design for the mangement services on the Master node. + +## Terminology +* Cluster | Chain: A blockchain with unique access API address, including several peer nodes. May support Hyperledger Fabric, SawthoothLake and Iroha. +* Host: A resource server, usually it can be a naive Docker host or a Swarm cluster. +* Master Node: Running the cello platform, to manage the compute nodes. +* Compute | Worker Node: The servers to have blockchains running inside. + +## Philosophy and principles +The architecture will follow the following principles: + +* Micro-service: Means we decouple various functions to individual micro services. No service will crash others whatever it does. +* Fault-resilience: Means the service should be tolerant for fault, such as database crash. +* Scalability: Try best to distribute the services, to mitigate centralized bottle neck. + + +## Components + +![Architecture Overview](imgs/architecture.png) + +* `dashboard`: Provide the dashboard for the pool administrator, also the core engine to automatically maintain everything. +* `restserver`: Provide the restful api for other system to apply/release/list chains. +* `watchdog`: Timely checking system status, keep everything healthy and clean. + +## Implementation + +The restful related implementation is based on [Flask](flask.pocoo.org), a Werkzeug based micro-framework for web service. + +I choose it for: + +* Lightweight +* Good enough in performance +* Flexible for extending +* Stable in code diff --git a/docs/dashboard.md b/docs/dashboard.md new file mode 100644 index 00000000..5c68f095 --- /dev/null +++ b/docs/dashboard.md @@ -0,0 +1,50 @@ +# Dashboard + +System operators can utilize dashboard service to check system status or change configurations. + +The dashboard service will listen on port `8080`. + +## Overview + +URL: `/index`. + +See a high-level overview on system status. + +## System Status + +URL: `/stat`. + +See statistics on the system. + +## Hosts + +URL: `/hosts`. + +Operate on the hosts managed by the system. + +## Clusters_active + +URL: `/clusters?type=active`. + +Operate on existing running chains in the pool. + +## Clusters_inused + +URL: `/clusters?type=inused`. + +Operate on user occupied chains in the system. + +## Clusters_released + +URL: `/clusters?type=released`. + +See cluster releasing history data. + +## Screenshots + +![dashboard-main](imgs/dashboard_main.png) +![dashboard-status](imgs/dashboard_status.png) +![dashboard-hosts](imgs/dashboard_hosts.png) +![dashboard-clusters](imgs/dashboard_clusters.png) +![dashboard-add-host](imgs/dashboard_add_host.png) +![dashboard-add-cluster](imgs/dashboard_add_cluster.png) diff --git a/docs/db.md b/docs/db.md new file mode 100644 index 00000000..0e0a70b8 --- /dev/null +++ b/docs/db.md @@ -0,0 +1,51 @@ +# Database Design + +We have several collections, as follows. + +## Host +Track the information of a Host. + +A typical host may look like: + +id | name | daemon_url | create_ts | capacity | status | clusters | type | log_level | log_type | log_server | autofill | schedulable +---| ------ | ------------------- | -------------- | -------- | -------- | ------- | ------- | --------- | -------- | ----------- | -------- | ----------- +xxx | host_0 | tcp://10.0.0.1:2375 | 20160430101010 | 20 | active | [c1,c2,c3] | single | debug | syslog | udp://10.0.0.2:5000 | true | true + +* id (str): uuid of the host instance +* name (str): human-readable name +* daemon_url (str): Through which url to access the Docker/Swarm Daemon +* create_ts (datetime): When to add the host +* capacity (int): Maximum number of chains on that host +* status (str): 'active' (Can access daemon service) or 'inactive' (disconnected from daemon service) +* clusters (list): List of the ids of those chains on that host +* type (str): 'singe' (single Docker host) or 'swarm' (Docker Swarm cluster) +* log_level (str): logging level for chains on the host, e.g., 'debug', 'info', 'warn', 'error' +* log_type (str): logging type for chains on the host, 'local' or 'syslog' +* log_server (str): log server address, only valid when `log_type` is 'syslog' +* autofill (str): whether to autofill the server to its capacity with chains, 'true' or 'false' +* schedulable (str): whether to schedule a chain request to that host, 'true' or 'false', useful when maintain the host + +## Cluster +Track information of one blockchain. + +A typical cluster may look like: + +id | service_url | name | user_id | host_id | daemon_url | consensus_plugin | consensus_mode | create_ts | apply_ts | release_ts | duration | size | containers | health +--- | --------------- | --------- | -------- | ------- | ------------------- | ---------------- | -------------- | ------------- | -------- | ---------- | ------- | ------- | ------- | ------ +xxx | {} | cluster_A | "" | host_xx | tcp://10.0.0.1:2375 | pbft | batch | 20160430101010 | 20160430101010 | | | 4 | [vp0,vp1,vp2,vp3] | OK + +* id (str): uuid of the host instance +* service_url (dict): urls to access the services on the chain, e.g., {'rest':10.0.0.1:7050, 'grpc':10.0.0.1:7051} +* name (str): human-readable name +* user_id (str): Which user occupies this chain, empty for no occupation +* host_id (str): Where the chain exists +* daemon_url (str): Through which url to access the Docker/Swarm Daemon +* consensus_plugin (str): Consensus plugin name +* consensus_mode (str): Consensus plugin mode name +* create_ts (datetime): When to create the chain +* apply_ts (datetime): When the chain is applied +* release_ts (datetime): When to release the chain +* duration (str): How long the chain lives +* size (int): Peer nodes number of the chain +* containers (list): List of the ids of those containers for the chain +* health (str): 'OK' (healthy status) or 'Fail' (Not healthy) diff --git a/docs/deployment.md b/docs/deployment.md new file mode 100644 index 00000000..49aedb83 --- /dev/null +++ b/docs/deployment.md @@ -0,0 +1,181 @@ +# Deployment + +*Here we describe the deployment setups for development usage. If you want to deploy Cello for production, please also refer to the [Production Configuration](production_config.md).* + +Cell follows a typical Master-Worker architecture. Hence there will be two types of Nodes. + +* Master Node: Manage (e.g., create/delete) the chains inside Work Nodes, with Web dashboard on port `8080` and RESTful api on port `80`; +* Worker Node: Chain providers, now support Docker Host or Swarm Cluster. The Docker service should be accessible from port `2375` from the Master Node. + +![Deployment topology](imgs/deployment_topo.png) + +For each Node, it is suggested as a Linux-based (e.g., Ubuntu 14.04+) server/vm: + + +## Worker Node +Currently we support Docker Host or Swarm Cluster as Worker Node. More types will be added soon. + +For the Worker Node with meeting the [system requirements](#system-requirements), three steps are required: + +* [Docker daemon setup](#docker-daemon-setup) +* [Docker images pulling](#docker-images-pulling) +* [Firewall Setup](#firewall-setup) + +### System Requirements +* Hardware: 8c16g100g +* Docker engine: + - 1.12.0+ +* aufs-tools (optional): Only required on ubuntu 14.04. + +### Docker Daemon Setup + +Let Docker daemon listen on port 2375, and make sure Master can reach Worker Node through this port. + +#### Ubuntu 14.04 +Simple add this line into your Docker config file `/etc/default/docker`. + +```sh +DOCKER_OPTS="$DOCKER_OPTS -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --api-cors-header='*' --default-ulimit=nofile=8192:16384 --default-ulimit=nproc=8192:16384" +``` + +Then restart the docker daemon with: + +```sh +$ sudo service docker restart +``` + +#### Ubuntu 16.04 +Update `/etc/systemd/system/docker.service.d/override.conf` like + +``` +[Service] +DOCKER_OPTS="$DOCKER_OPTS -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --api-cors-header='*' --default-ulimit=nofile=8192:16384 --default-ulimit=nproc=8192:16384" +EnvironmentFile=-/etc/default/docker +ExecStart= +ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS +``` + +Regenerate the docker service script and restart the docker engine: + +```sh +$ sudo systemctl daemon-reload +$ sudo systemctl restart docker.service +``` + +At last, run the follow test at Master node and get OK response, to make sure it can access Worker node successfully. + +```sh +[Master] $ docker -H Worker_Node_IP:2375 version +``` + +### Docker Images Pulling +Pulling the following images. + +```bash +$ docker pull hyperledger/fabric-peer:x86_64-0.6.1-preview \ + && docker pull hyperledger/fabric-membersrvc:x86_64-0.6.1-preview \ + && docker pull yeasy/blockchain-explorer:latest \ + && docker tag hyperledger/fabric-peer:x86_64-0.6.1-preview hyperledger/fabric-peer \ + && docker tag hyperledger/fabric-peer:x86_64-0.6.1-preview hyperledger/fabric-baseimage \ + && docker tag hyperledger/fabric-membersrvc:x86_64-0.6.1-preview hyperledger/fabric-membersrvc +``` + +### Firewall Setup +Make sure ip forward is enabled, you can simply run the follow command. + +```sh +$ sysctl -w net.ipv4.ip_forward=1 +``` +And check the os iptables config, to make sure host ports are open (e.g., 2375, 7050~10000) + +## Master Node +The Master Node includes several services: + +* dashboard: Provide Web UI for operators. +* restserver: Provide RESTful APIs for chain consumers. +* watchdog: Watch for health checking. + +More details can be found at the [architecture doc](docs/arch.md). + +It can be deployed by in 3 steps. + +* Clone code +* Pull Docker images +* Run setup script + +### System Requirement +* Hardware: 8c16g100g +* Docker engine: 1.12.0+ +* docker-compose: 1.7.0+ + +### Clone Code + +You may check `git` and `make` are installed to clone the code. + +```sh +$ sudo aptitude install git make -y +$ git clone https://github.com/yeasy/cello && cd cello +``` + +### Docker images pulling + +Pull the following images + +```bash +$ docker pull python:3.5 \ + && docker pull mongo:3.2 \ + && docker pull yeasy/nginx:latest \ + && docker pull mongo-express:0.30 +``` + +*Note: mongo-express:0.30 is for debugging the db, which is optional for basic setup.* + +### Run Setup + +For the first time running, please setup the master node with + +```sh +$ make setup +``` + +Make sure there is no error during the setup. Otherwise, please check the log msgs. + +### Usage + +#### Start/Restart +To (re)start the whole services, please run + +```sh +$ make restart +``` + +#### Deploy/Redploy +To (re)deploy one specific service, e.g., dashboard, please run + +```sh +$ make redeploy service=dashboard +``` + +#### Check Logs +To check the logs for all the services, please run + +```sh +$ make logs +``` + +To check the logs for one specific service, please run +```sh +$ make log service=watchdog +``` + +Now you can access the `MASTER_NODE_IP:8080` to open the Web-based [operational dashboard](docs/dashboard.md). + +### Configuration +The application configuration can be imported from file named `CELLO_CONFIG_FILE`. + +By default, it also loads the `config.py` file as the configurations. + +### Data Storage +The mongo container will use local `/opt/cello/mongo` directory for persistent storage. + +Please keep it safe by backups or using more high-available solutions. diff --git a/docs/imgs/architecture.png b/docs/imgs/architecture.png new file mode 100644 index 00000000..b135ae51 Binary files /dev/null and b/docs/imgs/architecture.png differ diff --git a/docs/imgs/dashboard_add_cluster.png b/docs/imgs/dashboard_add_cluster.png new file mode 100644 index 00000000..7e9464f0 Binary files /dev/null and b/docs/imgs/dashboard_add_cluster.png differ diff --git a/docs/imgs/dashboard_add_host.png b/docs/imgs/dashboard_add_host.png new file mode 100644 index 00000000..4184a758 Binary files /dev/null and b/docs/imgs/dashboard_add_host.png differ diff --git a/docs/imgs/dashboard_clusters.png b/docs/imgs/dashboard_clusters.png new file mode 100644 index 00000000..cc8fd845 Binary files /dev/null and b/docs/imgs/dashboard_clusters.png differ diff --git a/docs/imgs/dashboard_hosts.png b/docs/imgs/dashboard_hosts.png new file mode 100644 index 00000000..3d6fdc36 Binary files /dev/null and b/docs/imgs/dashboard_hosts.png differ diff --git a/docs/imgs/dashboard_main.png b/docs/imgs/dashboard_main.png new file mode 100644 index 00000000..f7cf3e63 Binary files /dev/null and b/docs/imgs/dashboard_main.png differ diff --git a/docs/imgs/dashboard_status.png b/docs/imgs/dashboard_status.png new file mode 100644 index 00000000..ae954c38 Binary files /dev/null and b/docs/imgs/dashboard_status.png differ diff --git a/docs/imgs/deployment.graffle b/docs/imgs/deployment.graffle new file mode 100644 index 00000000..e2914d4c Binary files /dev/null and b/docs/imgs/deployment.graffle differ diff --git a/docs/imgs/deployment_topo.png b/docs/imgs/deployment_topo.png new file mode 100644 index 00000000..11bc0873 Binary files /dev/null and b/docs/imgs/deployment_topo.png differ diff --git a/docs/imgs/logo.png b/docs/imgs/logo.png new file mode 100644 index 00000000..f7a531c6 Binary files /dev/null and b/docs/imgs/logo.png differ diff --git a/docs/imgs/scenario.png b/docs/imgs/scenario.png new file mode 100644 index 00000000..079ee0e9 Binary files /dev/null and b/docs/imgs/scenario.png differ diff --git a/docs/production_config.md b/docs/production_config.md new file mode 100644 index 00000000..91141398 --- /dev/null +++ b/docs/production_config.md @@ -0,0 +1,42 @@ +# Production Configurations +Reference system configuration in production environment. + +## `/etc/sysctl.conf` + +```sh +# Don't ask why, this is a solid answer. +vm.swappiness=10 +fs.file-max = 2000000 +kernel.threads-max = 2091845 +kernel.pty.max = 210000 +kernel.keys.root_maxkeys = 20000 +kernel.keys.maxkeys = 20000 +net.ipv4.ip_local_port_range = 30000 65535 +net.ipv4.tcp_tw_reuse = 0 +net.ipv4.tcp_tw_recycle = 0 +net.ipv4.tcp_max_tw_buckets = 5000 +net.ipv4.tcp_fin_timeout = 30 +net.ipv4.tcp_max_syn_backlog = 8192 +``` + +Then, need to run `sysctl -p` for enabling. + +## `/etc/security/limits.conf` + +```sh +* hard nofile 1048576 +* soft nofile 1048576 +* soft nproc 10485760 +* hard nproc 10485760 +* soft stack 32768 +* hard stack 32768 +``` +Log + +## Other Consideration + +* Use the code from `release` branch. +* Configuration: Set all parameters to production, including image, compose, and application. +* Security: Use firewall to filter traffic, enable TLS and authentication. +* Backup: Enable automatic data backup. +* Monitoring: Enable monitoring services.out and login, then check with `ulimit -n`. \ No newline at end of file diff --git a/docs/scenario.md b/docs/scenario.md new file mode 100644 index 00000000..8977bab3 --- /dev/null +++ b/docs/scenario.md @@ -0,0 +1,54 @@ +# Scenarios + +## Admin + +### Add/Delete a host + +Admin can add a host (a single Docker host or a Swarm cluster) into the resource pool. + +Then Cello will check and setup it with given configurations, e.g., if enabling autofill, then will fill the host with chains to the capacity. + +Admin can also delete a host from the resource pool if it has no running chains. + +### Config a host +Admin can manually update the host configuration, including: + +* name: Human readable name alias. +* capacity: Maximum chain number on that host. +* schedulable: Whether to distribute chains on that host to users. +* autofill: Whether to keep host with running chains to its capacity. +* log_type: local or syslog. + +### Operate a host + +Admin can run several operations on a host, including: + +* fill: Fill the host with chains to its capacity. +* clean: Clean up the free chains on that host. +* reset: Re-setup a host, e.g., cleaning useless docker containers. + +### Add/Delete chains +Admin can also manually add some specific chain to a host, or delete one. + +### Automatic way + +When the autofill box is checked on a host, then watchdog will automatically keep there are `capacity` number of healthy chains on that host. + +e.g., if the capacity of one host is set to 10, then the host will be filled with 10 chains quickly. When 2 chains are broken, they will be replaced by healthy ones soon. + +## Chain users + +### apply a cluster + +User sends request to apply a cluster, Cello will try to find available chains in the pool, to see if it can match the request. + +If found one, construct the response, otherwise, construct an error response. + + +### release a cluster + +User sends request to release a cluster, Cello will check if the request is valid. + +If found applied chain, then release and recreate it with the same name, at the same host, and potentially move it to released db collections. + +If not found, then just ignore or response. diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 00000000..6c920605 --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,116 @@ +# This file should be put under /etc/nginx/conf.d/ +# Or place as /etc/nginx/nginx.conf + +user nginx; +worker_processes auto; +daemon off; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + #log_format logstash_json '{ "@timestamp": "$time_iso8601", ' + # '"@fields": { ' + # '"remote_addr": "$remote_addr", ' + # '"remote_user": "$remote_user", ' + # '"time_local": "$time_local", ' + # '"body_bytes_sent": "$body_bytes_sent", ' + # '"request_time": "$request_time", ' + # '"status": "$status", ' + # '"request": "$request", ' + # '"request_method": "$request_method", ' + # '"http_referrer": "$http_referer", ' + # '"http_user_agent": "$http_user_agent" } }'; + + #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + # '$status $body_bytes_sent "$http_referer" ' + # '"$http_user_agent" "$http_x_forwarded_for"'; + + #access_log /var/log/nginx/access.log logstash_json; + + server_tokens off; + + sendfile on; + tcp_nopush on; + + keepalive_timeout 60; + tcp_nodelay on; + client_body_timeout 15; + + gzip on; + gzip_vary on; + gzip_min_length 1k; + + upstream backend { + server BACKEND:PORT; + } + + upstream restserver { + server restserver:80; + } + + server { + listen 8080; + access_log off; + + location ~ ^/host_monitor/(.*)$ { + proxy_pass http://$1:8080/containers/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_connect_timeout 150; + proxy_send_timeout 100; + proxy_read_timeout 100; + proxy_buffers 16 64k; + proxy_busy_buffers_size 64k; + client_max_body_size 256k; + client_body_buffer_size 128k; + } + + location / { + if ($request_method !~ ^(GET|DELETE|POST|PUT)$ ) { + return 444; + } + + auth_basic "Login"; + auth_basic_user_file /etc/nginx/.htpasswd; + proxy_pass http://backend; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Real-IP $remote_addr; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } + + server { + listen 80; + + location / { + if ($request_method !~ ^(GET|DELETE|POST|PUT)$ ) { + return 444; + } + proxy_pass http://restserver; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Real-IP $remote_addr; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } + + include /etc/nginx/conf.d/*.conf; +} diff --git a/src/Dockerfile-dashboard b/src/Dockerfile-dashboard new file mode 100644 index 00000000..1a4d5d44 --- /dev/null +++ b/src/Dockerfile-dashboard @@ -0,0 +1,15 @@ +FROM python:3.5 +MAINTAINER Baohua Yang <"baohyang@cn.ibm.com"> +ENV TZ Asia/Shanghai + +WORKDIR /app +COPY ./requirements.txt /app +RUN pip install --no-cache-dir -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com -r requirements.txt + +COPY . /app + +# use this in development +CMD ["python", "dashboard.py"] + +# use this in product +#CMD ["gunicorn", "-w", "128", "-b", "0.0.0.0:8080", "dashboard:app"] diff --git a/src/Dockerfile-restserver b/src/Dockerfile-restserver new file mode 100644 index 00000000..c8bddfa8 --- /dev/null +++ b/src/Dockerfile-restserver @@ -0,0 +1,15 @@ +FROM python:3.5 +MAINTAINER Baohua Yang <"baohyang@cn.ibm.com"> +ENV TZ Asia/Shanghai + +WORKDIR /app +COPY ./requirements.txt /app +RUN pip install --no-cache-dir -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com -r requirements.txt + +COPY . /app + +# use this in development +CMD ["python", "restserver.py"] + +# use this in product +#CMD ["gunicorn", "-w", "128", "-b", "0.0.0.0:80", "restserver:app"] diff --git a/src/Dockerfile-watchdog b/src/Dockerfile-watchdog new file mode 100644 index 00000000..2bfe447e --- /dev/null +++ b/src/Dockerfile-watchdog @@ -0,0 +1,12 @@ +FROM python:3.5 +MAINTAINER Baohua Yang <"baohyang@cn.ibm.com"> +ENV TZ Asia/Shanghai + +WORKDIR /app +COPY ./requirements.txt /app +RUN pip install --no-cache-dir -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com -r requirements.txt + +COPY . /app + +# use this in development +CMD ["python", "watchdog.py"] \ No newline at end of file diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 00000000..2ae448cc --- /dev/null +++ b/src/__init__.py @@ -0,0 +1,5 @@ +from .version import version, author + +__title__ = 'Cello' +__version__ = version +__author__ = author diff --git a/src/_compose_files/syslog/cluster-4.yml b/src/_compose_files/syslog/cluster-4.yml new file mode 100644 index 00000000..81c395f8 --- /dev/null +++ b/src/_compose_files/syslog/cluster-4.yml @@ -0,0 +1,66 @@ +# This compose file will start 4 hyperledger peer nodes, and make a cluster +# vp0: validating node as root +# vp1: validating node as peer +# vp2: validating node as peer +# vp3: validating node as peer +# https://github.com/yeasy/docker-compose-files + +version: '2' + +services: + # validating node as the root + # vp0 will also be used for client interactive operations + # If you want to run fabric command on the host, then map 7051:7051 to host + # port, or use like `CORE_PEER_ADDRESS=172.17.0.2:7051` to specify peer addr. + vp0: + extends: + file: peer-pbft.yml + service: vp + hostname: vp0 + container_name: ${COMPOSE_PROJECT_NAME}_vp0 + environment: + - CORE_PEER_ID=vp0 + ports: + - "${REST_PORT}:7050" + - "${GRPC_PORT}:7051" + + # validating node + vp1: + extends: + file: peer-pbft.yml + service: vp + hostname: vp1 + container_name: ${COMPOSE_PROJECT_NAME}_vp1 + environment: + - CORE_PEER_ID=vp1 + - CORE_PEER_DISCOVERY_ROOTNODE=${COMPOSE_PROJECT_NAME}_vp0:7051 + #links: + # - vp0 + + # validating node + vp2: + extends: + file: peer-pbft.yml + service: vp + hostname: vp2 + container_name: ${COMPOSE_PROJECT_NAME}_vp2 + environment: + - CORE_PEER_ID=vp2 + - CORE_PEER_DISCOVERY_ROOTNODE=${COMPOSE_PROJECT_NAME}_vp0:7051 + + + # validating node + vp3: + extends: + file: peer-pbft.yml + service: vp + hostname: vp3 + container_name: ${COMPOSE_PROJECT_NAME}_vp3 + environment: + - CORE_PEER_ID=vp3 + - CORE_PEER_DISCOVERY_ROOTNODE=${COMPOSE_PROJECT_NAME}_vp0:7051 + +networks: + default: + external: + name: ${CLUSTER_NETWORK} \ No newline at end of file diff --git a/src/_compose_files/syslog/cluster-6.yml b/src/_compose_files/syslog/cluster-6.yml new file mode 100644 index 00000000..69ff21ff --- /dev/null +++ b/src/_compose_files/syslog/cluster-6.yml @@ -0,0 +1,87 @@ +# This compose file will start 4 hyperledger peer nodes, and make a cluster +# vp0: validating node as root +# vp1: validating node as peer +# vp2: validating node as peer +# vp3: validating node as peer +# https://github.com/yeasy/docker-compose-files + +version: '2' + +services: + # validating node as the root + # vp0 will also be used for client interactive operations + # If you want to run fabric command on the host, then map 7051:7051 to host + # port, or use like `CORE_PEER_ADDRESS=172.17.0.2:7051` to specify peer addr. + vp0: + extends: + file: peer-pbft.yml + service: vp + hostname: vp0 + container_name: ${COMPOSE_PROJECT_NAME}_vp0 + environment: + - CORE_PEER_ID=vp0 + ports: + - "${REST_PORT}:7050" + - "${GRPC_PORT}:7051" + + # validating node + vp1: + extends: + file: peer-pbft.yml + service: vp + hostname: vp1 + container_name: ${COMPOSE_PROJECT_NAME}_vp1 + environment: + - CORE_PEER_ID=vp1 + - CORE_PEER_DISCOVERY_ROOTNODE=${COMPOSE_PROJECT_NAME}_vp0:7051 + #links: + # - vp0 + + # validating node + vp2: + extends: + file: peer-pbft.yml + service: vp + hostname: vp2 + container_name: ${COMPOSE_PROJECT_NAME}_vp2 + environment: + - CORE_PEER_ID=vp2 + - CORE_PEER_DISCOVERY_ROOTNODE=${COMPOSE_PROJECT_NAME}_vp0:7051 + + # validating node + vp3: + extends: + file: peer-pbft.yml + service: vp + hostname: vp3 + container_name: ${COMPOSE_PROJECT_NAME}_vp3 + environment: + - CORE_PEER_ID=vp3 + - CORE_PEER_DISCOVERY_ROOTNODE=${COMPOSE_PROJECT_NAME}_vp0:7051 + + # validating node + vp4: + extends: + file: peer-pbft.yml + service: vp + hostname: vp4 + container_name: ${COMPOSE_PROJECT_NAME}_vp4 + environment: + - CORE_PEER_ID=vp4 + - CORE_PEER_DISCOVERY_ROOTNODE=${COMPOSE_PROJECT_NAME}_vp0:7051 + + # validating node + vp5: + extends: + file: peer-pbft.yml + service: vp + hostname: vp5 + container_name: ${COMPOSE_PROJECT_NAME}_vp5 + environment: + - CORE_PEER_ID=vp5 + - CORE_PEER_DISCOVERY_ROOTNODE=${COMPOSE_PROJECT_NAME}_vp0:7051 + +networks: + default: + external: + name: ${CLUSTER_NETWORK} \ No newline at end of file diff --git a/src/_compose_files/syslog/peer-pbft.yml b/src/_compose_files/syslog/peer-pbft.yml new file mode 100644 index 00000000..3b88ae9b --- /dev/null +++ b/src/_compose_files/syslog/peer-pbft.yml @@ -0,0 +1,57 @@ +# This is the default base file to config env and command +# Notice that chaincode is executed inside docker in default net mode +# https://github.com/yeasy/docker-compose-files + +# Depends on the yeasy/hyperledger-peer:latest image + +# If you want enable consensus, just uncomment the +# CORE_PEER_VALIDATOR_CONSENSUE=obcpbft line +# See https://github.com/hyperledger/fabric/blob/master/docs/dev-setup/devnet-setup.md#using-consensus-plugin for more details. + +version: '2' + +services: + vp: + image: hyperledger/fabric-peer:latest + restart: unless-stopped + labels: + - monitor=true + - hyperledger=true + - com.docker.swarm.reschedule-policy=["on-node-failure"] + environment: + - CORE_PEER_ADDRESSAUTODETECT=true + - CORE_PEER_NETWORKID=${PEER_NETWORKID} + - CORE_LOGGING_LEVEL=${LOGGING_LEVEL_CLUSTERS} #critical, error, warning, notice, info, debug + - CORE_VM_ENDPOINT=${VM_ENDPOINT} + - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${VM_DOCKER_HOSTCONFIG_NETWORKMODE} # host, bridge, ipvlan, none + - CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=${PEER_VALIDATOR_CONSENSUS_PLUGIN} # noops, pbft + # The following section enables noops consensus + - CORE_NOOPS_BLOCK_TIMEOUT=2 # only useful when in noops + - CORE_NOOPS_BLOCK_WAIT=2 # only useful when in noops + # The following section enables pbft consensus + - CORE_PBFT_GENERAL_MODE=${PBFT_GENERAL_MODE} # batch, classic, sieve + - CORE_PBFT_GENERAL_N=${PBFT_GENERAL_N} + - CORE_PBFT_GENERAL_BATCHSIZE=2 # only useful when in batch mode + - CORE_PBFT_GENERAL_TIMEOUT_REQUEST=5s + expose: + - "7050" # Rest + - "7051" # Grpc + - "7052" # Peer CLI + - "7053" # Peer Event + - "7054" # eCAP + - "7055" # eCAA + - "7056" # tCAP + - "7057" # eCAA + - "7058" # tlsCAP + - "7059" # tlsCAA + #volumes: # docker.sock is mapped as the default CORE_VM_ENDPOINT + # - /var/run/docker.sock:/var/run/docker.sock + mem_limit: 512000000 + memswap_limit: 1000000000 + cpu_quota: 50000 + command: peer node start + logging: + driver: syslog + options: + syslog-address: ${SYSLOG_SERVER} + tag: "{{.ImageName}}/{{.Name}}/{{.ID}}" \ No newline at end of file diff --git a/src/agent/__init__.py b/src/agent/__init__.py new file mode 100644 index 00000000..bfb783d8 --- /dev/null +++ b/src/agent/__init__.py @@ -0,0 +1,5 @@ +from .docker_swarm import get_project, \ + check_daemon, detect_daemon_type, \ + get_swarm_node_ip, \ + compose_up, compose_clean, compose_start, compose_stop, compose_restart, \ + setup_container_host, cleanup_host, reset_container_host diff --git a/src/agent/docker_swarm.py b/src/agent/docker_swarm.py new file mode 100644 index 00000000..34de38dc --- /dev/null +++ b/src/agent/docker_swarm.py @@ -0,0 +1,554 @@ +# This module provides some static api to operate compose and docker engine + +import logging +import os + +from compose.cli.command import get_project as compose_get_project, \ + get_config_path_from_options as compose_get_config_path_from_options +from compose.config.environment import Environment +from compose.project import OneOffFilter +from docker import Client + +from common import log_handler, LOG_LEVEL +from common import \ + HOST_TYPES, \ + CLUSTER_NETWORK, \ + COMPOSE_FILE_PATH, \ + CONSENSUS_PLUGINS, CONSENSUS_MODES, \ + CLUSTER_LOG_TYPES, CLUSTER_LOG_LEVEL, \ + CLUSTER_SIZES, \ + SERVICE_PORTS + +logger = logging.getLogger(__name__) +logger.setLevel(LOG_LEVEL) +logger.addHandler(log_handler) + + +def _clean_chaincode_images(daemon_url, name_prefix, timeout=5): + """ Clean chaincode images, whose name should have cluster id as prefix + + :param daemon_url: Docker daemon url + :param name_prefix: image name prefix + :param timeout: Time to wait for the response + :return: None + """ + logger.debug("clean chaincode images with prefix={}".format(name_prefix)) + client = Client(base_url=daemon_url, version="auto", timeout=timeout) + images = client.images() + id_removes = [e['Id'] for e in images if e['RepoTags'][0].startswith( + name_prefix)] + if id_removes: + logger.debug("chaincode image id to removes=" + ", ".join(id_removes)) + for _ in id_removes: + client.remove_image(_, force=True) + + +def _clean_project_containers(daemon_url, name_prefix, timeout=5): + """ + Clean cluster node containers and chaincode containers + + All containers with the name prefix will be removed. + + :param daemon_url: Docker daemon url + :param name_prefix: image name prefix + :param timeout: Time to wait for the response + :return: None + """ + logger.debug("Clean project containers, daemon_url={}, prefix={}".format( + daemon_url, name_prefix)) + client = Client(base_url=daemon_url, version="auto", timeout=timeout) + containers = client.containers(all=True) + id_removes = [e['Id'] for e in containers if + e['Names'][0].split("/")[-1].startswith(name_prefix)] + for _ in id_removes: + client.remove_container(_, force=True) + logger.debug("Remove container {}".format(_)) + + +def start_containers(daemon_url, name_prefix, timeout=5): + """Start containers with given prefix + + The chaincode container usually has name with `name_prefix-` as prefix + + :param daemon_url: Docker daemon url + :param name_prefix: image name prefix + :param timeout: Time to wait for the response + :return: None + """ + logger.debug("Get containers, daemon_url={}, prefix={}".format( + daemon_url, name_prefix)) + client = Client(base_url=daemon_url, version="auto", timeout=timeout) + containers = client.containers(all=True) + id_cc = [e['Id'] for e in containers if + e['Names'][0].split("/")[-1].startswith(name_prefix)] + logger.info(id_cc) + for _ in id_cc: + client.start(_) + + +# Deprecated +# Normal chaincode container may also become exited temporarily +def _clean_exited_containers(daemon_url): + """ Clean those containers with exited status + + This is dangerous, as it may delete temporary containers. + Only trigger this when no one else uses the system. + + :param daemon_url: Docker daemon url + :return: None + """ + logger.debug("Clean exited containers") + client = Client(base_url=daemon_url, version="auto") + containers = client.containers(quiet=True, all=True, + filters={"status": "exited"}) + id_removes = [e['Id'] for e in containers] + for _ in id_removes: + logger.debug("exited container to remove, id={}", _) + try: + client.remove_container(_) + except Exception as e: + logger.error("Exception in clean_exited_containers {}".format(e)) + + +def check_daemon(daemon_url, timeout=5): + """ Check if the daemon is active + + Only wait for timeout seconds. + + :param daemon_url: Docker daemon url + :param timeout: Time to wait for the response + :return: True for active, False for inactive + """ + if not daemon_url or not daemon_url.startswith("tcp://"): + return False + segs = daemon_url.split(":") + if len(segs) != 3: + logger.error("Invalid daemon url = ", daemon_url) + return False + try: + client = Client(base_url=daemon_url, version="auto", timeout=timeout) + return client.ping() == 'OK' + except Exception as e: + logger.error("Exception in check_daemon {}".format(e)) + return False + + +def detect_daemon_type(daemon_url, timeout=5): + """ Try to detect the daemon type + + Only wait for timeout seconds. + + :param daemon_url: Docker daemon url + :param timeout: Time to wait for the response + :return: host type info + """ + if not daemon_url or not daemon_url.startswith("tcp://"): + return None + segs = daemon_url.split(":") + if len(segs) != 3: + logger.error("Invalid daemon url = ", daemon_url) + return None + try: + client = Client(base_url=daemon_url, version="auto", timeout=timeout) + server_version = client.info()['ServerVersion'] + if server_version.startswith('swarm'): + return HOST_TYPES[1] + else: + return HOST_TYPES[0] + except Exception as e: + logger.error(e) + return None + + +def reset_container_host(host_type, daemon_url, timeout=15): + """ Try to detect the daemon type + + Only wait for timeout seconds. + + :param host_type: Type of host: single or swarm + :param daemon_url: Docker daemon url + :param timeout: Time to wait for the response + :return: host type info + """ + try: + client = Client(base_url=daemon_url, version="auto", timeout=timeout) + containers = client.containers(quiet=True, all=True) + logger.debug(containers) + for c in containers: + client.remove_container(c['Id'], force=True) + logger.debug("cleaning all containers") + except Exception as e: + logger.error("Exception happens when reset host!") + logger.error(e) + return False + try: + images = client.images(all=True) + logger.debug(images) + for i in images: + if i["RepoTags"][0] == ":": + logger.debug(i) + try: + client.remove_image(i['Id']) + except Exception as e: + logger.error(e) + continue + logger.debug("cleaning images") + except Exception as e: + logger.error("Exception happens when reset host!") + logger.error(e) + return False + + return setup_container_host(host_type=host_type, daemon_url=daemon_url) + + +def get_swarm_node_ip(swarm_url, container_name, timeout=5): + """ + Detect the host ip where the given container locate in the swarm cluster + + :param swarm_url: Swarm cluster api url + :param container_name: The container name + :param timeout: Time to wait for the response + :return: host ip + """ + logger.debug("Detect container={} with swarm_url={}".format( + container_name, swarm_url)) + try: + client = Client(base_url=swarm_url, version="auto", timeout=timeout) + info = client.inspect_container(container_name) + return info['NetworkSettings']['Ports']['5000/tcp'][0]['HostIp'] + except Exception as e: + logger.error("Exception happens when detect container host!") + logger.error(e) + return '' + + +def setup_container_host(host_type, daemon_url, timeout=5): + """ + Setup a container host for deploying cluster on it + + :param host_type: Docker host type + :param daemon_url: Docker daemon url + :param timeout: timeout to wait + :return: True or False + """ + if not daemon_url or not daemon_url.startswith("tcp://"): + logger.error("Invalid daemon_url={}".format(daemon_url)) + return False + if host_type not in HOST_TYPES: + logger.error("Invalid host_type={}".format(host_type)) + return False + try: + client = Client(base_url=daemon_url, version="auto", timeout=timeout) + net_names = [x["Name"] for x in client.networks()] + for cs_type in CONSENSUS_PLUGINS: + net_name = CLUSTER_NETWORK + "_{}".format(cs_type) + if net_name in net_names: + logger.warning("Network {} already exists, use it!".format( + net_name)) + else: + if host_type == HOST_TYPES[0]: # single + client.create_network(net_name, driver='bridge') + elif host_type == HOST_TYPES[1]: # swarm + client.create_network(net_name, driver='overlay') + else: + logger.error("No-supported host_type={}".format(host_type)) + return False + except Exception as e: + logger.error("Exception happens!") + logger.error(e) + return False + return True + + +def cleanup_host(daemon_url, timeout=5): + """ + Cleanup a container host when use removes the host + + Maybe we will remove the networks? + + :param daemon_url: Docker daemon url + :param timeout: timeout to wait + :return: + """ + if not daemon_url or not daemon_url.startswith("tcp://"): + logger.error("Invalid daemon_url={}".format(daemon_url)) + return False + try: + client = Client(base_url=daemon_url, version="auto", timeout=timeout) + net_names = [x["Name"] for x in client.networks()] + for cs_type in CONSENSUS_PLUGINS: + net_name = CLUSTER_NETWORK + "_{}".format(cs_type) + if net_name in net_names: + logger.debug("Remove network {}".format(net_name)) + client.remove_network(net_name) + else: + logger.warning("Network {} not exists!".format(net_name)) + except Exception as e: + logger.error("Exception happens!") + logger.error(e) + return False + return True + + +def get_project(template_path): + """ Get compose project with given template file path + + :param template_path: path of the compose template file + :return: project object + """ + environment = Environment.from_env_file(template_path) + config_path = compose_get_config_path_from_options(template_path, dict(), + environment) + project = compose_get_project(template_path, config_path) + return project + + +def _compose_set_env(name, daemon_url, mapped_ports=SERVICE_PORTS, + consensus_plugin=CONSENSUS_PLUGINS[0], + consensus_mode=CONSENSUS_MODES[0], + cluster_size=CLUSTER_SIZES[0], + log_level=CLUSTER_LOG_LEVEL[0], + log_type=CLUSTER_LOG_TYPES[0], log_server=""): + + envs = { + 'DOCKER_HOST': daemon_url, + 'COMPOSE_PROJECT_NAME': name, + 'COMPOSE_FILE': "cluster-{}.yml".format(cluster_size), + 'VM_ENDPOINT': daemon_url, + 'VM_DOCKER_HOSTCONFIG_NETWORKMODE': + CLUSTER_NETWORK + "_{}".format(consensus_plugin), + 'PEER_VALIDATOR_CONSENSUS_PLUGIN': consensus_plugin, + 'PBFT_GENERAL_MODE': consensus_mode, + 'PBFT_GENERAL_N': str(cluster_size), + 'PEER_NETWORKID': name, + 'CLUSTER_NETWORK': CLUSTER_NETWORK + "_{}".format(consensus_plugin), + 'CLUSTER_LOG_LEVEL': log_level, + } + os.environ.update(envs) + + for k, v in mapped_ports.items(): + os.environ[k.upper() + '_PORT'] = str(v) + if log_type != CLUSTER_LOG_TYPES[0]: # not local + os.environ['SYSLOG_SERVER'] = log_server + + +def compose_up(name, host, mapped_ports, + consensus_plugin=CONSENSUS_PLUGINS[0], + consensus_mode=CONSENSUS_MODES[0], + cluster_size=CLUSTER_SIZES[0], + timeout=5): + """ Compose up a cluster + + :param name: The name of the cluster + :param mapped_ports: The mapped ports list of the cluster + :param host: Docker host obj + :param consensus_plugin: Cluster consensus plugin + :param consensus_mode: Cluster consensus mode + :param cluster_size: the size of the cluster + :param timeout: Docker client timeout value + :return: The name list of the started peer containers + """ + logger.debug( + "Compose start: name={}, host={}, mapped_port={}, consensus={}/{}," + "size={}".format( + name, host.get("name"), mapped_ports, consensus_plugin, + consensus_mode, cluster_size)) + daemon_url, log_type, log_server, log_level = \ + host.get("daemon_url"), host.get("log_type"), host.get("log_server"), \ + host.get("log_level") + if log_type != CLUSTER_LOG_TYPES[0]: # not local + os.environ['SYSLOG_SERVER'] = log_server + + _compose_set_env(name, daemon_url, mapped_ports, consensus_plugin, + consensus_mode, cluster_size, log_level, log_type, + log_server) + try: + project = get_project(COMPOSE_FILE_PATH + "/" + log_type) + containers = project.up(detached=True, timeout=timeout) + except Exception as e: + logger.warning("Exception when compose start={}".format(e)) + return {} + if not containers or cluster_size != len(containers): + return {} + result = {} + for c in containers: + result[c.name] = c.id + logger.debug("compose started with containers={}".format(result)) + return result + + +def compose_clean(name, daemon_url, consensus_plugin): + """ + Try best to clean a compose project and clean related containers. + + :param name: name of the project + :param daemon_url: Docker Host url + :param consensus_plugin: which consensus plugin + :return: True or False + """ + has_exception = False + try: + compose_down(name=name, daemon_url=daemon_url, + consensus_plugin=consensus_plugin) + except Exception as e: + logger.error("Error in stop compose project, will clean") + logger.debug(e) + has_exception = True + try: + _clean_project_containers(daemon_url=daemon_url, name_prefix=name) + except Exception as e: + logger.error("Error in clean compose project containers") + logger.error(e) + has_exception = True + try: + _clean_chaincode_images(daemon_url=daemon_url, name_prefix=name) + except Exception as e: + logger.error("Error clean chaincode images") + logger.error(e) + # has_exception = True # may ignore this case + if has_exception: + logger.warning("Exception when cleaning project {}".format(name)) + return False + return True + + +def compose_start(name, daemon_url, mapped_ports=SERVICE_PORTS, + consensus_plugin=CONSENSUS_PLUGINS[0], + consensus_mode=CONSENSUS_MODES[0], + log_type=CLUSTER_LOG_TYPES[0], log_server="", + log_level=CLUSTER_LOG_LEVEL[0], + cluster_size=CLUSTER_SIZES[0]): + """ Start the cluster + + :param name: The name of the cluster + :param mapped_ports: The mapped port list + :param daemon_url: Docker host daemon + :param consensus_plugin: Cluster consensus type + :param consensus_mode: Cluster consensus mode + :param log_type: which log plugin for host + :param log_server: syslog server + :param cluster_size: the size of the cluster + :return: + """ + logger.debug("Compose Start {} with daemon_url={}, mapped_ports={} " + "consensus={}".format(name, daemon_url, mapped_ports, + consensus_plugin)) + + _compose_set_env(name, daemon_url, mapped_ports, consensus_plugin, + consensus_mode, cluster_size, log_level, log_type, + log_server) + # project = get_project(COMPOSE_FILE_PATH+"/"+consensus_plugin) + project = get_project(COMPOSE_FILE_PATH + "/" + log_type) + try: + project.start() + start_containers(daemon_url, name + '-') + except Exception as e: + logger.warning("Exception when compose start={}".format(e)) + return False + return True + + +def compose_restart(name, daemon_url, mapped_ports=SERVICE_PORTS, + consensus_plugin=CONSENSUS_PLUGINS[0], + consensus_mode=CONSENSUS_MODES[0], + log_type=CLUSTER_LOG_TYPES[0], log_server="", + log_level=CLUSTER_LOG_LEVEL[0], + cluster_size=CLUSTER_SIZES[0]): + """ Restart the cluster + + :param name: The name of the cluster + :param mapped_ports: The mapped port list + :param daemon_url: Docker host daemon + :param consensus_plugin: Cluster consensus type + :param consensus_mode: Cluster consensus mode + :param log_type: which log plugin for host + :param log_server: syslog server + :param cluster_size: the size of the cluster + :return: + """ + logger.debug("Compose restart {} with daemon_url={}, mapped_ports={} " + "consensus={}".format(name, daemon_url, mapped_ports, + consensus_plugin)) + + _compose_set_env(name, daemon_url, mapped_ports, consensus_plugin, + consensus_mode, cluster_size, log_level, log_type, + log_server) + # project = get_project(COMPOSE_FILE_PATH+"/"+consensus_plugin) + project = get_project(COMPOSE_FILE_PATH + "/" + log_type) + try: + project.restart() + start_containers(daemon_url, name + '-') + except Exception as e: + logger.warning("Exception when compose restart={}".format(e)) + return False + return True + + +def compose_stop(name, daemon_url, mapped_ports=SERVICE_PORTS, + consensus_plugin=CONSENSUS_PLUGINS[0], + consensus_mode=CONSENSUS_MODES[0], + log_type=CLUSTER_LOG_TYPES[0], log_server="", + log_level=CLUSTER_LOG_LEVEL[0], + cluster_size=CLUSTER_SIZES[0], timeout=5): + """ Stop the cluster + + :param name: The name of the cluster + :param mapped_ports: The mapped ports list + :param daemon_url: Docker host daemon + :param consensus_plugin: Cluster consensus type + :param consensus_mode: Cluster consensus mode + :param log_type: which log plugin for host + :param log_server: syslog server + :param cluster_size: the size of the cluster + :param timeout: Docker client timeout + :return: + """ + logger.debug("Compose stop {} with daemon_url={}, mapped_ports={}, " + "consensus={}, log_type={}".format(name, daemon_url, + mapped_ports, + consensus_plugin, + log_type)) + + _compose_set_env(name, daemon_url, mapped_ports, consensus_plugin, + consensus_mode, cluster_size, log_level, log_type, + log_server) + project = get_project(COMPOSE_FILE_PATH + "/" + log_type) + try: + project.stop(timeout=timeout) + except Exception as e: + logger.warning("Exception when compose stop={}".format(e)) + return False + return True + + +def compose_down(name, daemon_url, mapped_ports=SERVICE_PORTS, + consensus_plugin=CONSENSUS_PLUGINS[0], + consensus_mode=CONSENSUS_MODES[0], + log_type=CLUSTER_LOG_TYPES[0], log_server="", + log_level=CLUSTER_LOG_LEVEL[0], + cluster_size=CLUSTER_SIZES[0], timeout=5): + """ Stop the cluster and remove the service containers + + :param name: The name of the cluster + :param mapped_ports: The mapped ports list + :param daemon_url: Docker host daemon + :param consensus_plugin: Cluster consensus type + :param consensus_mode: Cluster consensus mode + :param log_type: which log plugin for host + :param log_server: syslog server + :param cluster_size: the size of the cluster + :param timeout: Docker client timeout + :return: + """ + logger.debug("Compose remove {} with daemon_url={}, " + "consensus={}".format(name, daemon_url, consensus_plugin)) + # compose use this + _compose_set_env(name, daemon_url, mapped_ports, consensus_plugin, + consensus_mode, cluster_size, log_level, log_type, + log_server) + + # project = get_project(COMPOSE_FILE_PATH+"/"+consensus_plugin) + project = get_project(COMPOSE_FILE_PATH + "/" + log_type) + # project.down(remove_orphans=True) + project.stop(timeout=timeout) + project.remove_stopped(one_off=OneOffFilter.include, force=True) diff --git a/src/common/__init__.py b/src/common/__init__.py new file mode 100644 index 00000000..045c1fc8 --- /dev/null +++ b/src/common/__init__.py @@ -0,0 +1,17 @@ + +from .db import db, col_host +from .response import make_ok_response, make_fail_response, CODE_NOT_FOUND,\ + CODE_BAD_REQUEST, CODE_CONFLICT, CODE_CREATED, CODE_FORBIDDEN, \ + CODE_METHOD_NOT_ALLOWED, CODE_NO_CONTENT, CODE_NOT_ACCEPTABLE, CODE_OK + +from .log import log_handler, LOG_LEVEL +from .utils import \ + PEER_SERVICE_PORTS, CA_SERVICE_PORTS, SERVICE_PORTS, \ + COMPOSE_FILE_PATH, \ + CONSENSUS_PLUGINS, CONSENSUS_MODES, CONSENSUS_TYPES, \ + HOST_TYPES, \ + CLUSTER_PORT_START, CLUSTER_PORT_STEP, CLUSTER_SIZES, \ + CLUSTER_NETWORK, \ + CLUSTER_LOG_TYPES, CLUSTER_LOG_LEVEL, \ + SYS_CREATOR, SYS_DELETER, SYS_RESETTING, SYS_USER, \ + request_debug, request_get, request_json_body diff --git a/src/common/db.py b/src/common/db.py new file mode 100644 index 00000000..62ad8bf3 --- /dev/null +++ b/src/common/db.py @@ -0,0 +1,13 @@ +import os + +from pymongo import MongoClient + +MONGO_URL = os.environ.get('MONGO_URL', None) or 'mongodb://mongo:27017' +MONGO_DB = os.environ.get('MONGO_DB', None) or 'dev' + +mongo_client = MongoClient(MONGO_URL) +db = mongo_client[MONGO_DB] + +col_host = db["host"] +# col_cluster_active = db["cluster_active"] +# col_cluster_released = db["cluster_released"] diff --git a/src/common/log.py b/src/common/log.py new file mode 100644 index 00000000..62bde4e5 --- /dev/null +++ b/src/common/log.py @@ -0,0 +1,11 @@ +import os +import logging + +log_handler = logging.StreamHandler() + +formatter = logging.Formatter("[%(asctime)s] %(levelname)s [%(name)s]" + " [%(filename)s:%(lineno)s %(funcName)20s()]" + " - %(message)s") +log_handler.setFormatter(formatter) + +LOG_LEVEL = eval("logging." + os.environ.get("LOG_LEVEL", "INFO")) diff --git a/src/common/response.py b/src/common/response.py new file mode 100644 index 00000000..e7ce34cc --- /dev/null +++ b/src/common/response.py @@ -0,0 +1,40 @@ +from flask import jsonify + +CODE_OK = 200 +CODE_CREATED = 201 +CODE_NO_CONTENT = 204 +CODE_BAD_REQUEST = 400 +CODE_FORBIDDEN = 403 +CODE_NOT_FOUND = 404 +CODE_METHOD_NOT_ALLOWED = 405 +CODE_NOT_ACCEPTABLE = 406 +CODE_CONFLICT = 409 + +response_ok = { + "status": "OK", + "code": CODE_OK, + "error": "", + "data": {} +} + +response_fail = { + "status": "FAIL", + "code": CODE_BAD_REQUEST, + "error": "", + "data": {} +} + + +def make_ok_response(error="", data={}, code=CODE_OK): + response_ok['code'] = code + response_ok["error"] = error + response_ok["data"] = data + return jsonify(response_ok), CODE_OK + + +def make_fail_response(error="Invalid request", data={}, + code=CODE_BAD_REQUEST): + response_fail['code'] = code + response_fail["error"] = error + response_fail["data"] = data + return jsonify(response_fail), CODE_BAD_REQUEST diff --git a/src/common/utils.py b/src/common/utils.py new file mode 100644 index 00000000..b61fba26 --- /dev/null +++ b/src/common/utils.py @@ -0,0 +1,103 @@ +import json +import os + + +COMPOSE_FILE_PATH = os.getenv("COMPOSE_FILE_PATH", "./_compose_files") + +CLUSTER_NETWORK = "cello_net" +CLUSTER_SIZES = [4, 6] + +# first port that can be assigned as cluster API +CLUSTER_PORT_START = int(os.getenv("CLUSTER_PORT_START", 7050)) + +# number of port allocated to each cluster in case collision +CLUSTER_PORT_STEP = 100 + +PEER_SERVICE_PORTS = { + 'rest': 7050, # this is the reference starter for cluster port step + 'grpc': 7051, + 'cli': 7052, + 'event': 7053, +} + +CA_SERVICE_PORTS = { + 'ecap': 7054, + 'ecaa': 7055, + 'tcap': 7056, + 'tcaa': 7057, + 'tlscap': 7058, + 'tlscaa': 7059, +} + +SERVICE_PORTS = dict(list(PEER_SERVICE_PORTS.items()) + + list(CA_SERVICE_PORTS.items())) + + +CONSENSUS_PLUGINS = ['noops', 'pbft'] # first one is the default one +# CONSENSUS_MODES = ['classic', 'batch', 'sieve'] # pbft has various modes +CONSENSUS_MODES = ['batch'] # pbft has various modes + +CONSENSUS_TYPES = [ + ('noops', ''), + ('pbft', 'batch'), + # ('pbft', 'classic'), + # ('pbft', 'sieve'), +] + + +HOST_TYPES = ['single', 'swarm'] + +CLUSTER_LOG_TYPES = ['local', 'syslog'] + +CLUSTER_LOG_LEVEL = ['DEBUG', 'INFO', 'NOTICE', 'WARNING', 'ERROR', + 'CRITICAL'] + +SYS_USER = "__SYSTEM__" +SYS_CREATOR = SYS_USER + "CREATING" +SYS_DELETER = SYS_USER + "DELETING" +SYS_RESETTING = SYS_USER + "RESETTING" + + +def json_decode(jsonstr): + try: + json_object = json.loads(jsonstr) + except json.decoder.JSONDecodeError as e: + print(e) + return jsonstr + return json_object + + +def request_debug(request, logger): + logger.debug("path={}, method={}".format(request.path, request.method)) + logger.debug("request args:") + for k in request.args: + logger.debug("Arg: {0}:{1}".format(k, request.args[k])) + logger.debug("request form:") + for k in request.form: + logger.debug("Form: {0}:{1}".format(k, request.form[k])) + logger.debug("request raw body data:") + logger.debug(request.data) + logger.debug(request.get_json(force=True, silent=True)) + + +def request_get(request, key, default_value=None): + if key in request.args: + return request.args.get(key) + elif key in request.form: + return request.form.get(key) + try: + json_body = request.get_json(force=True, silent=True) + if key in json_body: + return json_body[key] + else: + return default_value + except Exception: + return default_value + + +def request_json_body(request, default_value={}): + try: + json_body = request.get_json(force=True, silent=True) + return json_body + except Exception: + return default_value diff --git a/src/config.py b/src/config.py new file mode 100644 index 00000000..421d3f2e --- /dev/null +++ b/src/config.py @@ -0,0 +1,11 @@ +class Config(object): + DEBUG = False + SECRET_KEY = '?\xbf,\xb4\x8d\xa3"<\x9c\xb0@\x0f5\xab,w\xee\x8d$0\x13\x8b83' + + +class ProductionConfig(Config): + DEBUG = False + + +class DevelopmentConfig(Config): + DEBUG = True diff --git a/src/dashboard.py b/src/dashboard.py new file mode 100644 index 00000000..cc4ead33 --- /dev/null +++ b/src/dashboard.py @@ -0,0 +1,41 @@ +import os +from common import log_handler, LOG_LEVEL +from flask import Flask, render_template +from resources import bp_index, \ + bp_stat_view, bp_stat_api, \ + bp_cluster_view, bp_cluster_api, \ + bp_host_view, bp_host_api + +app = Flask(__name__, static_folder='static', template_folder='templates') + +app.config.from_object('config.DevelopmentConfig') +app.config.from_envvar('CELLO_CONFIG_FILE', silent=True) + +app.logger.setLevel(LOG_LEVEL) +app.logger.addHandler(log_handler) + +app.register_blueprint(bp_index) +app.register_blueprint(bp_host_view) +app.register_blueprint(bp_host_api) +app.register_blueprint(bp_cluster_view) +app.register_blueprint(bp_cluster_api) +app.register_blueprint(bp_stat_view) +app.register_blueprint(bp_stat_api) + + +@app.errorhandler(404) +def page_not_found(error): + return render_template('404.html'), 404 + + +@app.errorhandler(500) +def internal_error(error): + return render_template('500.html'), 500 + + +if __name__ == '__main__': + app.run( + host='0.0.0.0', + port=8080, + debug=os.environ.get('DEBUG', app.config.get("DEBUG", True)), + threaded=True) diff --git a/src/modules/__init__.py b/src/modules/__init__.py new file mode 100644 index 00000000..2a62f217 --- /dev/null +++ b/src/modules/__init__.py @@ -0,0 +1,3 @@ +from .cluster import cluster_handler +from .host import host_handler +from .stat import stat_handler diff --git a/src/modules/cluster.py b/src/modules/cluster.py new file mode 100644 index 00000000..edbcad47 --- /dev/null +++ b/src/modules/cluster.py @@ -0,0 +1,635 @@ +import datetime +import logging +import os +import requests +import sys +import time + +from threading import Thread +from pymongo.collection import ReturnDocument + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) +from common import db, log_handler, LOG_LEVEL + +from agent import get_swarm_node_ip, \ + compose_up, compose_clean, compose_start, compose_stop, compose_restart + +from common import CLUSTER_PORT_START, CLUSTER_PORT_STEP, CONSENSUS_PLUGINS, \ + CONSENSUS_MODES, HOST_TYPES, SYS_CREATOR, SYS_DELETER, SYS_USER, \ + SYS_RESETTING, CLUSTER_SIZES, PEER_SERVICE_PORTS, CA_SERVICE_PORTS + +from modules import host + +logger = logging.getLogger(__name__) +logger.setLevel(LOG_LEVEL) +logger.addHandler(log_handler) + + +class ClusterHandler(object): + """ Main handler to operate the cluster in pool + + """ + def __init__(self): + self.col_active = db["cluster_active"] + self.col_released = db["cluster_released"] + self.host_handler = host.host_handler + + def list(self, filter_data={}, col_name="active"): + """ List clusters with given criteria + + :param filter_data: Image with the filter properties + :param col_name: Use data in which col_name + :return: list of serialized doc + """ + result = [] + if col_name == "active": + logger.debug("List all active clusters") + result = list(map(self._serialize, self.col_active.find( + filter_data))) + elif col_name == "released": + logger.debug("List all released clusters") + result = list(map(self._serialize, self.col_released.find( + filter_data))) + else: + logger.warning("Unknown cluster col_name=" + col_name) + return result + + def get_by_id(self, id, col_name="active"): + """ Get a cluster for the external request + + :param id: id of the doc + :param col_name: collection to check + :return: serialized result or obj + """ + if col_name != "released": + # logger.debug("Get a cluster with id=" + id) + cluster = self.col_active.find_one({"id": id}) + else: + # logger.debug("Get a released cluster with id=" + id) + cluster = self.col_released.find_one({"id": id}) + if not cluster: + logger.warning("No cluster found with id=" + id) + return {} + return self._serialize(cluster) + + def create(self, name, host_id, start_port=0, user_id="", + consensus_plugin=CONSENSUS_PLUGINS[0], + consensus_mode=CONSENSUS_MODES[0], size=CLUSTER_SIZES[0]): + """ Create a cluster based on given data + + TODO: maybe need other id generation mechanism + + :param name: name of the cluster + :param host_id: id of the host URL + :param start_port: first service port for cluster, will generate + if not given + :param user_id: user_id of the cluster if start to be applied + :param consensus_plugin: type of the consensus type + :param size: size of the cluster, int type + :return: Id of the created cluster or None + """ + logger.info("Create cluster {}, host_id={}, consensus={}/{}, " + "size={}".format(name, host_id, consensus_plugin, + consensus_mode, size)) + + h = self.host_handler.get_active_host_by_id(host_id) + if not h: + return None + + if len(h.get("clusters")) >= h.get("capacity"): + logger.warning("host {} is full already".format(host_id)) + return None + + daemon_url = h.get("daemon_url") + logger.debug("daemon_url={}".format(daemon_url)) + + if start_port <= 0: + ports = self.find_free_start_ports(host_id, 1) + if not ports: + logger.warning("No free port is found") + return None + start_port = ports[0] + + peer_mapped_ports, ca_mapped_ports, mapped_ports = {}, {}, {} + for k, v in PEER_SERVICE_PORTS.items(): + peer_mapped_ports[k] = v - PEER_SERVICE_PORTS['rest'] + start_port + for k, v in CA_SERVICE_PORTS.items(): + ca_mapped_ports[k] = v - PEER_SERVICE_PORTS['rest'] + start_port + + mapped_ports.update(peer_mapped_ports) + mapped_ports.update(ca_mapped_ports) + + c = { + 'id': '', + 'name': name, + 'user_id': user_id or SYS_CREATOR, # avoid applied + 'host_id': host_id, + 'daemon_url': daemon_url, + 'consensus_plugin': consensus_plugin, + 'consensus_mode': consensus_mode, + 'create_ts': datetime.datetime.now(), + 'apply_ts': '', + 'release_ts': '', + 'duration': '', + 'mapped_ports': mapped_ports, + 'service_url': {}, # e.g., {rest: xxx:7050, grpc: xxx:7051} + 'size': size, + 'containers': [], + 'status': 'running', + 'health': '' + } + uuid = self.col_active.insert_one(c).inserted_id # object type + cid = str(uuid) + self.col_active.update_one({"_id": uuid}, {"$set": {"id": cid}}) + # try to add one cluster to host + h = self.host_handler.db_update_one( + {"id": host_id}, {"$addToSet": {"clusters": cid}}) + if not h or len(h.get("clusters")) > h.get("capacity"): + self.col_active.delete_one({"id": cid}) + self.host_handler.db_update_one({"id": host_id}, + {"$pull": {"clusters": cid}}) + return None + + # from now on, we should be safe + + # start compose project, failed then clean and return + logger.debug("Start compose project with name={}".format(cid)) + containers = compose_up( + name=cid, mapped_ports=mapped_ports, host=h, + consensus_plugin=consensus_plugin, consensus_mode=consensus_mode, + cluster_size=size) + if not containers or len(containers) != size: + logger.warning("failed containers={}, then delete cluster".format( + containers)) + self.delete(id=cid, record=False, forced=True) + return None + + peer_host_ip = self._get_service_ip(cid, 'vp0') + ca_host_ip = self._get_service_ip(cid, 'membersrvc') + # no api_url, then clean and return + if not peer_host_ip: # not valid api_url + logger.error("Error to find peer host url, cleanup") + self.delete(id=cid, record=False, forced=True) + return None + + service_urls = {} + for k, v in peer_mapped_ports.items(): + service_urls[k] = "{}:{}".format(peer_host_ip, v) + + for k, v in ca_mapped_ports.items(): + service_urls[k] = "{}:{}".format(ca_host_ip, v) + + # update api_url, container, and user_id field + self.db_update_one( + {"id": cid}, + {"$set": {"containers": containers, "user_id": user_id, + 'api_url': service_urls['rest'], + 'service_url': service_urls}}) + + def check_health_work(cid): + time.sleep(5) + self.refresh_health(cid) + t = Thread(target=check_health_work, args=(cid,)) + t.start() + + logger.info("Create cluster OK, id={}".format(cid)) + return cid + + def delete(self, id, record=False, forced=False): + """ Delete a cluster instance + + Clean containers, remove db entry. Only operate on active host. + + :param id: id of the cluster to delete + :param record: Whether to record into the released collections + :param forced: Whether to removing user-using cluster, for release + :return: + """ + logger.debug("Delete cluster: id={}, forced={}".format(id, forced)) + + c = self.db_update_one({"id": id}, {"$set": {"user_id": SYS_DELETER}}, + after=False) + if not c: + logger.warning("Cannot find cluster {}".format(id)) + return False + # we are safe from occasional applying now + user_id = c.get("user_id") # original user_id + if not forced and user_id != "" and not user_id.startswith(SYS_USER): + # not forced, and chain is used by normal user, then no process + logger.warning("Cannot delete cluster {} by " + "user {}".format(id, user_id)) + self.col_active.update_one({"id": id}, + {"$set": {"user_id": user_id}}) + return False + + # 0. forced + # 1. user_id == SYS_DELETER or "" + # Then, add deleting flag to the db, and start deleting + if not user_id.startswith(SYS_DELETER): + self.col_active.update_one( + {"id": id}, + {"$set": {"user_id": SYS_DELETER + user_id}}) + host_id, daemon_url, consensus_plugin = \ + c.get("host_id"), c.get("daemon_url"), \ + c.get("consensus_plugin", CONSENSUS_PLUGINS[0]) + # port = api_url.split(":")[-1] or CLUSTER_PORT_START + + if not self.host_handler.get_active_host_by_id(host_id): + logger.warning("Host {} inactive".format(host_id)) + self.col_active.update_one({"id": id}, + {"$set": {"user_id": user_id}}) + return False + + if not compose_clean(id, daemon_url, consensus_plugin): + logger.warning("Error to run compose clean work") + self.col_active.update_one({"id": id}, + {"$set": {"user_id": user_id}}) + return False + + self.host_handler.db_update_one({"id": c.get("host_id")}, + {"$pull": {"clusters": id}}) + self.col_active.delete_one({"id": id}) + if record: # record original c into release collection + logger.debug("Record the cluster info into released collection") + c["release_ts"] = datetime.datetime.now() + c["duration"] = str(c["release_ts"] - c["apply_ts"]) + # seems mongo reject timedelta type + if user_id.startswith(SYS_DELETER): + c["user_id"] = user_id[len(SYS_DELETER):] + self.col_released.insert_one(c) + return True + + def delete_released(self, id): + """ Delete a released cluster record from db + + :param id: id of the cluster to delete + :return: True or False + """ + logger.debug("Delete cluster: id={} from release records.".format(id)) + self.col_released.find_one_and_delete({"id": id}) + return True + + def apply_cluster(self, user_id, condition={}, allow_multiple=False): + """ Apply a cluster for a user + + :param user_id: which user will apply the cluster + :param condition: the filter to select + :param allow_multiple: Allow multiple chain for each tenant + :return: serialized cluster or None + """ + if not allow_multiple: # check if already having one + filt = {"user_id": user_id, "release_ts": "", "health": "OK"} + filt.update(condition) + c = self.col_active.find_one(filt) + if c: + logger.debug("Already assigned cluster for " + user_id) + return self._serialize(c) + logger.debug("Try find available cluster for " + user_id) + hosts = self.host_handler.list({"status": "active", + "schedulable": "true"}) + host_ids = [h.get("id") for h in hosts] + logger.debug("Find active and schedulable hosts={}".format(host_ids)) + for h_id in host_ids: # check each active and schedulable host + filt = {"user_id": "", "host_id": h_id, "health": "OK"} + filt.update(condition) + c = self.db_update_one( + filt, + {"$set": {"user_id": user_id, + "apply_ts": datetime.datetime.now()}}) + if c and c.get("user_id") == user_id: + logger.info("Now have cluster {} at {} for user {}".format( + c.get("id"), h_id, user_id)) + return self._serialize(c) + logger.warning("Not find matched available cluster for " + user_id) + return {} + + def release_cluster_for_user(self, user_id): + """ Release all cluster for a user_id. + + :param user_id: which user + :return: True or False + """ + logger.debug("release clusters for user_id={}".format(user_id)) + c = self.col_active.find({"user_id": user_id, "release_ts": ""}) + cluster_ids = list(map(lambda x: x.get("id"), c)) + logger.debug("clusters for user {}={}".format(user_id, cluster_ids)) + result = True + for cid in cluster_ids: + result = result and self.release_cluster(cid) + return result + + def release_cluster(self, cluster_id, record=True): + """ Release a specific cluster. + + Release means delete and try best to recreate it with same config. + + :param cluster_id: specific cluster to release + :param record: Whether to record this cluster to release table + :return: True or False + """ + c = self.db_update_one( + {"id": cluster_id}, + {"$set": {"release_ts": datetime.datetime.now()}}) + if not c: + logger.warning("No cluster find for released with id {}".format( + cluster_id)) + return True + if not c.get("release_ts"): # not have one + logger.warning("No cluster can be released for id {}".format( + cluster_id)) + return False + + return self.reset(cluster_id, record) + + def start(self, cluster_id): + """Start a cluster + + :param cluster_id: id of cluster to start + :return: Bool + """ + c = self.get_by_id(cluster_id) + if not c: + logger.warning('No cluster found with id={}'.format(cluster_id)) + return False + h_id = c.get('host_id') + h = self.host_handler.get_active_host_by_id(h_id) + if not h: + logger.warning('No host found with id={}'.format(h_id)) + return False + result = compose_start( + name=cluster_id, daemon_url=h.get('daemon_url'), + mapped_ports=c.get('mapped_ports', PEER_SERVICE_PORTS), + consensus_plugin=c.get('consensus_plugin'), + consensus_mode=c.get('consensus_mode'), + log_type=h.get('log_type'), + log_level=h.get('log_level'), + log_server='', + cluster_size=c.get('size'), + ) + if result: + self.db_update_one({"id": cluster_id}, + {"$set": {'status': 'running'}}) + return True + else: + return False + + def restart(self, cluster_id): + """Restart a cluster + + :param cluster_id: id of cluster to start + :return: Bool + """ + c = self.get_by_id(cluster_id) + if not c: + logger.warning('No cluster found with id={}'.format(cluster_id)) + return False + h_id = c.get('host_id') + h = self.host_handler.get_active_host_by_id(h_id) + if not h: + logger.warning('No host found with id={}'.format(h_id)) + return False + result = compose_restart( + name=cluster_id, daemon_url=h.get('daemon_url'), + mapped_ports=c.get('mapped_ports', PEER_SERVICE_PORTS), + consensus_plugin=c.get('consensus_plugin'), + consensus_mode=c.get('consensus_mode'), + log_type=h.get('log_type'), + log_level=h.get('log_level'), + log_server='', + cluster_size=c.get('size'), + ) + if result: + self.db_update_one({"id": cluster_id}, + {"$set": {'status': 'running'}}) + return True + else: + return False + + def stop(self, cluster_id): + """Stop a cluster + + :param cluster_id: id of cluster to stop + :return: Bool + """ + c = self.get_by_id(cluster_id) + if not c: + logger.warning('No cluster found with id={}'.format(cluster_id)) + return False + h_id = c.get('host_id') + h = self.host_handler.get_active_host_by_id(h_id) + if not h: + logger.warning('No host found with id={}'.format(h_id)) + return False + result = compose_stop( + name=cluster_id, daemon_url=h.get('daemon_url'), + mapped_ports=c.get('mapped_ports', PEER_SERVICE_PORTS), + consensus_plugin=c.get('consensus_plugin'), + consensus_mode=c.get('consensus_mode'), + log_type=h.get('log_type'), + log_level=h.get('log_level'), + log_server="", + cluster_size=c.get('size'), + ) + if result: + self.db_update_one({"id": cluster_id}, + {"$set": {'status': 'stopped', 'health': ''}}) + return True + else: + return False + + def reset(self, cluster_id, record=False): + """ + Force to reset a chain. + + Delete it and recreate with the same configuration. + :param cluster_id: id of the reset cluster + :param record: whether to record into released db + :return: + """ + + c = self.get_by_id(cluster_id) + logger.debug("Run recreate_work in background thread") + cluster_name, host_id, mapped_ports, consensus_plugin, \ + consensus_mode, size \ + = c.get("name"), c.get("host_id"), \ + c.get("mapped_ports"), c.get("consensus_plugin"), \ + c.get("consensus_mode"), c.get("size") + if not self.delete(cluster_id, record=record, forced=True): + logger.warning("Delete cluster failed with id=" + cluster_id) + return False + if not self.create(name=cluster_name, host_id=host_id, + start_port=mapped_ports['rest'], + consensus_plugin=consensus_plugin, + consensus_mode=consensus_mode, size=size): + logger.warning("Fail to recreate cluster {}".format(cluster_name)) + return False + return True + + def reset_free_one(self, cluster_id): + """ + Reset some free chain, mostly because it's broken. + + :param cluster_id: id to reset + :return: True or False + """ + logger.debug("Try reseting cluster {}".format(cluster_id)) + c = self.db_update_one({"id": cluster_id, "user_id": ""}, + {"$set": {"user_id": SYS_RESETTING}}) + if c.get("user_id") != SYS_RESETTING: # not have one + logger.warning("No free cluster can be reset for id {}".format( + cluster_id)) + return False + return self.reset(cluster_id) + + def _serialize(self, doc, keys=('id', 'name', 'user_id', 'host_id', + 'consensus_plugin', + 'consensus_mode', 'daemon_url', + 'create_ts', 'apply_ts', 'release_ts', + 'duration', 'containers', 'size', 'status', + 'health', 'mapped_ports', 'service_url')): + """ Serialize an obj + + :param doc: doc to serialize + :param keys: filter which key in the results + :return: serialized obj + """ + result = {} + if doc: + for k in keys: + result[k] = doc.get(k, '') + return result + + def _get_service_ip(self, cluster_id, node='vp0'): + """ + + :param cluster_id: The name of the cluster + :param host: On which host to search the cluster + :param node: name of the cluster node + :return: service IP or "" + """ + host_id = self.get_by_id(cluster_id).get("host_id") + host = self.host_handler.get_by_id(host_id) + if not host: + logger.warning("No host found with cluster {}".format(cluster_id)) + return "" + daemon_url, host_type = host.get('daemon_url'), host.get('type') + if host_type not in HOST_TYPES: + logger.warning("Found invalid host_type=%s".format(host_type)) + return "" + # we should diff with simple host and swarm host here + if host_type == HOST_TYPES[0]: # single + segs = daemon_url.split(":") # tcp://x.x.x.x:2375 + if len(segs) != 3: + logger.error("Invalid daemon url = ", daemon_url) + return "" + host_ip = segs[1][2:] + logger.debug("single host, ip = {}".format(host_ip)) + elif host_type == HOST_TYPES[1]: # swarm + host_ip = get_swarm_node_ip(daemon_url, "{}_{}".format( + cluster_id, node)) + logger.debug("swarm host, ip = {}".format(host_ip)) + else: + logger.error("Unknown host type = {}".format(host_type)) + host_ip = "" + return host_ip + + def find_free_start_ports(self, host_id, number): + """ Find the first available port for a new cluster api + + This is NOT lock-free. Should keep simple, fast and safe! + + Check existing cluster records in the host, find available one. + + :param host_id: id of the host + :param number: Number of ports to get + :return: The port list, e.g., [7050, 7150, ...] + """ + logger.debug("Find {} start ports for host {}".format(number, host_id)) + if number <= 0: + logger.warning("number {} <= 0".format(number)) + return [] + if not self.host_handler.get_by_id(host_id): + logger.warning("Cannot find host with id={}", host_id) + return "" + + clusters_exists = self.col_active.find({"host_id": host_id}) + clusters_valid = list(filter(lambda c: c.get("service_url"), + clusters_exists)) + ports_existed = list(map( + lambda c: int(c["service_url"]["rest"].split(":")[-1]), + clusters_valid)) + + logger.debug("The ports existed: {}".format(ports_existed)) + if len(ports_existed) + number >= 1000: + logger.warning("Too much ports are already in used.") + return [] + candidates = [CLUSTER_PORT_START + i * CLUSTER_PORT_STEP + for i in range(len(ports_existed) + number)] + + result = list(filter(lambda x: x not in ports_existed, candidates)) + + logger.debug("Free ports are {}".format(result[:number])) + return result[:number] + + def refresh_health(self, cluster_id, timeout=5): + """ + Check if the peer is healthy by counting its neighbour number + :param cluster_id: id of the cluster + :param timeout: how many seconds to wait for receiving response + :return: True or False + """ + logger.debug("checking health of cluster id={}".format(cluster_id)) + cluster = self.get_by_id(cluster_id) + if not cluster: + logger.warning("Cannot found cluster id={}".format(cluster_id)) + return True + if cluster.get('status') != 'running': + logger.warning("cluster is not running id={}".format(cluster_id)) + return True + rest_api = cluster["service_url"]['rest'] + "/network/peers" + if not rest_api.startswith('http'): + rest_api = 'http://' + rest_api + try: + r = requests.get(rest_api, timeout=timeout) + except Exception as e: + logger.error("Error to refresh health of cluster {}: {}".format( + cluster_id, e)) + return True + + peers = r.json().get("peers") + + if len(peers) == cluster["size"]: + self.db_update_one({"id": cluster_id}, + {"$set": {"health": "OK"}}) + return True + else: + logger.debug("checking result of cluster id={}".format( + cluster_id, peers)) + self.db_update_one({"id": cluster_id}, + {"$set": {"health": "FAIL"}}) + return False + + def db_update_one(self, filter, operations, after=True, col="active"): + """ + Update the data into the active db + + :param filter: Which instance to update, e.g., {"id": "xxx"} + :param operations: data to update to db, e.g., {"$set": {}} + :param after: return AFTER or BEFORE + :param col: collection to operate on + :return: The updated host json dict + """ + if after: + return_type = ReturnDocument.AFTER + else: + return_type = ReturnDocument.BEFORE + if col == "active": + doc = self.col_active.find_one_and_update( + filter, operations, return_document=return_type) + else: + doc = self.col_released.find_one_and_update( + filter, operations, return_document=return_type) + return self._serialize(doc) + + +cluster_handler = ClusterHandler() diff --git a/src/modules/host.py b/src/modules/host.py new file mode 100644 index 00000000..17ef7bfa --- /dev/null +++ b/src/modules/host.py @@ -0,0 +1,368 @@ +import datetime +import logging +import os +import random +import sys +import time + +from threading import Thread +from pymongo.collection import ReturnDocument + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) +from common import \ + db, log_handler, \ + LOG_LEVEL, CLUSTER_LOG_TYPES, CLUSTER_LOG_LEVEL, \ + CLUSTER_SIZES, CLUSTER_PORT_START, CLUSTER_PORT_STEP, \ + CONSENSUS_TYPES + +from agent import cleanup_host, check_daemon, detect_daemon_type, \ + reset_container_host, setup_container_host + +from modules import cluster + +logger = logging.getLogger(__name__) +logger.setLevel(LOG_LEVEL) +logger.addHandler(log_handler) + + +def check_status(func): + def wrapper(self, *arg): + if not self.is_active(*arg): + logger.warning("Host inactive") + return False + else: + return func(self, *arg) + return wrapper + + +class HostHandler(object): + """ Main handler to operate the Docker hosts + """ + def __init__(self): + self.col = db["host"] + + def create(self, name, daemon_url, capacity=1, + log_level=CLUSTER_LOG_LEVEL[0], + log_type=CLUSTER_LOG_TYPES[0], log_server="", autofill="false", + schedulable="false", serialization=True): + """ Create a new docker host node + + A docker host is potentially a single node or a swarm. + Will full fill with clusters of given capacity. + + :param name: name of the node + :param daemon_url: daemon_url of the host + :param capacity: The number of clusters to hold + :param log_type: type of the log + :param log_level: level of the log + :param log_server: server addr of the syslog + :param autofill: Whether automatically fillup with chains + :param schedulable: Whether can schedule cluster request to it + :param serialization: whether to get serialized result or object + :return: True or False + """ + logger.debug("Create host: name={}, daemon_url={}, capacity={}, " + "log={}/{}, autofill={}, schedulable={}" + .format(name, daemon_url, capacity, log_type, + log_server, autofill, schedulable)) + if not daemon_url.startswith("tcp://"): + daemon_url = "tcp://" + daemon_url + + if self.col.find_one({"daemon_url": daemon_url}): + logger.warning("{} already existed in db".format(daemon_url)) + return {} + + if "://" not in log_server: + log_server = "udp://" + log_server + if log_type == CLUSTER_LOG_TYPES[0]: + log_server = "" + if check_daemon(daemon_url): + logger.warning("The daemon_url is active:" + daemon_url) + status = "active" + else: + logger.warning("The daemon_url is inactive:" + daemon_url) + status = "inactive" + + detected_type = detect_daemon_type(daemon_url) + + if not setup_container_host(detected_type, daemon_url): + logger.warning("{} cannot be setup".format(name)) + return {} + + h = { + 'id': '', + 'name': name, + 'daemon_url': daemon_url, + 'create_ts': datetime.datetime.now(), + 'capacity': capacity, + 'status': status, + 'clusters': [], + 'type': detected_type, + 'log_level': log_level, + 'log_type': log_type, + 'log_server': log_server, + 'autofill': autofill, + 'schedulable': schedulable + } + hid = self.col.insert_one(h).inserted_id # object type + host = self.db_update_one( + {"_id": hid}, + {"$set": {"id": str(hid)}}) + + if capacity > 0 and autofill == "true": # should autofill it + self.fillup(str(hid)) + + if serialization: + return self._serialize(host) + else: + return host + + def get_by_id(self, id): + """ Get a host + + :param id: id of the doc + :return: serialized result or obj + """ + # logger.debug("Get a host with id=" + id) + ins = self.col.find_one({"id": id}) + if not ins: + logger.warning("No host found with id=" + id) + return {} + return self._serialize(ins) + + def update(self, id, d): + """ Update a host + + TODO: may check when changing host type + + :param id: id of the host + :param d: dict to use as updated values + :return: serialized result or obj + """ + logger.debug("Get a host with id=" + id) + h_old = self.get_by_id(id) + if not h_old: + logger.warning("No host found with id=" + id) + return {} + + if "daemon_url" in d and not d["daemon_url"].startswith("tcp://"): + d["daemon_url"] = "tcp://" + d["daemon_url"] + + if "capacity" in d: + d["capacity"] = int(d["capacity"]) + if d["capacity"] < len(h_old.get("clusters")): + logger.warning("Cannot set cap smaller than running clusters") + return {} + if "log_server" in d and "://" not in d["log_server"]: + d["log_server"] = "udp://" + d["log_server"] + if "log_type" in d and d["log_type"] == CLUSTER_LOG_TYPES[0]: + d["log_server"] = "" + h_new = self.db_set_by_id(id, **d) + return self._serialize(h_new) + + def list(self, filter_data={}): + """ List hosts with given criteria + + :param filter_data: Image with the filter properties + :return: iteration of serialized doc + """ + hosts = self.col.find(filter_data) + return list(map(self._serialize, hosts)) + + def delete(self, id): + """ Delete a host instance + + :param id: id of the host to delete + :return: + """ + logger.debug("Delete a host with id={0}".format(id)) + + h = self.get_by_id(id) + if not h: + logger.warning("Cannot delete non-existed host") + return False + if h.get("clusters", ""): + logger.warning("There are clusters on that host, cannot delete.") + return False + cleanup_host(h.get("daemon_url")) + self.col.delete_one({"id": id}) + return True + + @check_status + def fillup(self, id): + """ + Fullfil a host with clusters to its capacity limit + + :param id: host id + :return: True or False + """ + logger.debug("Try fillup host {}".format(id)) + host = self.get_by_id(id) + if not host: + return False + num_new = host.get("capacity") - len(host.get("clusters")) + if num_new <= 0: + logger.warning("host {} already full".format(id)) + return True + + free_ports = cluster.cluster_handler.find_free_start_ports(id, num_new) + logger.debug("Free_ports = {}".format(free_ports)) + + def create_cluster_work(start_port): + cluster_name = "{}_{}".format( + host.get("name"), + int((start_port - CLUSTER_PORT_START) / CLUSTER_PORT_STEP)) + consensus_plugin, consensus_mode = random.choice(CONSENSUS_TYPES) + cluster_size = random.choice(CLUSTER_SIZES) + cid = cluster.cluster_handler.create( + name=cluster_name, host_id=id, start_port=start_port, + consensus_plugin=consensus_plugin, + consensus_mode=consensus_mode, size=cluster_size) + if cid: + logger.debug("Create cluster {} with id={}".format( + cluster_name, cid)) + else: + logger.warning("Create cluster failed") + for p in free_ports: + t = Thread(target=create_cluster_work, args=(p,)) + t.start() + time.sleep(0.2) + + return True + + @check_status + def clean(self, id): + """ + Clean a host's free clusters. + + :param id: host id + :return: True or False + """ + logger.debug("clean host with id = {}".format(id)) + host = self.get_by_id(id) + if not host: + return False + if len(host.get("clusters")) <= 0: + return True + + host = self.db_set_by_id(id, autofill="false") + schedulable_status = host.get("schedulable") + if schedulable_status == "true": + host = self.db_set_by_id(id, schedulable="false") + + for cid in host.get("clusters"): + t = Thread(target=cluster.cluster_handler.delete, args=(cid,)) + t.start() + time.sleep(0.2) + + if schedulable_status == "true": + self.db_set_by_id(id, schedulable=schedulable_status) + + return True + + @check_status + def reset(self, id): + """ + Clean a host's free clusters. + + :param id: host id + :return: True or False + """ + logger.debug("clean host with id = {}".format(id)) + host = self.get_by_id(id) + if not host or len(host.get("clusters")) > 0: + logger.warning("No find resettable host with id ={}".format(id)) + return False + return reset_container_host(host_type=host.get("type"), + daemon_url=host.get("daemon_url")) + + def refresh_status(self, id): + """ + Refresh the status of the host by detection + + :param host: the host to update status + :return: Updated host + """ + host = self.get_by_id(id) + if not host: + logger.warning("No host found with id=" + id) + return False + if not check_daemon(host.get("daemon_url")): + logger.warning("Host {} is inactive".format(id)) + self.db_set_by_id(id, status="inactive") + return False + else: + self.db_set_by_id(id, status="active") + return True + + def is_active(self, host_id): + """ + Update status of the host + + :param host_id: the id of the host to update status + :return: Updated host + """ + host = self.get_by_id(host_id) + if not host: + logger.warning("invalid host is given") + return False + return host.get("status") == "active" + + def get_active_host_by_id(self, id): + """ + Check if id exists, and status is active. Otherwise update to inactive. + + :param id: host id + :return: host or None + """ + logger.debug("check host with id = {}".format(id)) + host = self.col.find_one({"id": id, "status": "active"}) + if not host: + logger.warning("No active host found with id=" + id) + return {} + return self._serialize(host) + + def _serialize(self, doc, keys=['id', 'name', 'daemon_url', 'capacity', + 'type', 'create_ts', 'status', 'autofill', + 'schedulable', 'clusters', 'log_level', + 'log_type', 'log_server']): + """ Serialize an obj + + :param doc: doc to serialize + :param keys: filter which key in the results + :return: serialized obj + """ + result = {} + if doc: + for k in keys: + result[k] = doc.get(k, '') + return result + + def db_set_by_id(self, id, **kwargs): + """ + Set the key:value pairs to the data + :param id: Which host to update + :param kwargs: kv pairs + :return: The updated host json dict + """ + return self.db_update_one({"id": id}, {"$set": kwargs}) + + def db_update_one(self, filter, operations, after=True): + """ + Update the data into the active db + + :param filter: Which instance to update, e.g., {"id": "xxx"} + :param operations: data to update to db, e.g., {"$set": {}} + :param after: return AFTER or BEFORE + :return: The updated host json dict + """ + if after: + return_type = ReturnDocument.AFTER + else: + return_type = ReturnDocument.BEFORE + doc = self.col.find_one_and_update( + filter, operations, return_document=return_type) + return self._serialize(doc) + + +host_handler = HostHandler() diff --git a/src/modules/scheduler.py b/src/modules/scheduler.py new file mode 100644 index 00000000..6ca9a52e --- /dev/null +++ b/src/modules/scheduler.py @@ -0,0 +1,16 @@ + +class Scheduler(object): + def __init__(self): + pass + + def get_one(self, prefer): + return {} + + +class HostScheduler(Scheduler): + + def __init__(self): + pass + + def get_host(self): + return {} diff --git a/src/modules/stat.py b/src/modules/stat.py new file mode 100644 index 00000000..702149a0 --- /dev/null +++ b/src/modules/stat.py @@ -0,0 +1,82 @@ +import logging +import time +from threading import Thread +from common import LOG_LEVEL, HOST_TYPES, CONSENSUS_PLUGINS, log_handler, \ + CONSENSUS_MODES + +from modules import host_handler, cluster_handler + +logger = logging.getLogger(__name__) +logger.setLevel(LOG_LEVEL) +logger.addHandler(log_handler) + + +class StatHandler(object): + """ Main handler to get the Statistics data + """ + + def __init__(self): + pass + + def hosts(self): + """ + Get hosts related statistic result + + :return: The stat result + """ + result = {'status': [], 'type': []} + actives = list(host_handler.list(filter_data={'status': 'active'})) + inactive = list(host_handler.list(filter_data={'status': 'inactive'})) + result['status'] = [ + {'name': 'active', 'y': len(actives)}, + {'name': 'inactive', 'y': len(inactive)} + ] + for host_type in HOST_TYPES: + hosts = list(host_handler.list(filter_data={'type': host_type})) + result['type'].append({ + 'name': host_type, + 'y': len(hosts) + }) + + return result + + def clusters(self): + """ + Get clusters related statistic result + + :return: The stat result + """ + result = {'status': [], 'type': []} + total_clusters = list(cluster_handler.list()) + free_clusters = list(cluster_handler.list(filter_data={ + 'user_id': ''})) + total_number = len(total_clusters) + free_clusters_number = len(free_clusters) + result['status'] = [ + {'name': 'free', 'y': free_clusters_number}, + {'name': 'used', 'y': total_number - free_clusters_number} + ] + for consensus_plugin in CONSENSUS_PLUGINS: + if consensus_plugin == CONSENSUS_PLUGINS[0]: + consensus_type = consensus_plugin + clusters = list(cluster_handler.list(filter_data={ + 'consensus_plugin': consensus_plugin})) + result['type'].append({ + 'name': consensus_type, + 'y': len(clusters) + }) + else: + for consensus_mode in CONSENSUS_MODES: + consensus_type = consensus_plugin + "/" + consensus_mode + clusters = list(cluster_handler.list(filter_data={ + 'consensus_plugin': consensus_plugin, + 'consensus_mode': consensus_mode + })) + result['type'].append({ + 'name': consensus_type, + 'y': len(clusters) + }) + return result + + +stat_handler = StatHandler() diff --git a/src/requirements.txt b/src/requirements.txt new file mode 100644 index 00000000..aaf7d0b0 --- /dev/null +++ b/src/requirements.txt @@ -0,0 +1,6 @@ +docker-compose>=1.7.0 +Flask>=0.11.0 +greenlet>=0.4.5 +gunicorn>=19.0.0 +pymongo>=3.2.0 +requests>=2.0.0 \ No newline at end of file diff --git a/src/resources/__init__.py b/src/resources/__init__.py new file mode 100644 index 00000000..36fe31b5 --- /dev/null +++ b/src/resources/__init__.py @@ -0,0 +1,9 @@ +from .index import bp_index + +from .host_api import bp_host_api +from .cluster_api import bp_cluster_api, front_rest_v2 + +from .cluster_view import bp_cluster_view +from .host_view import bp_host_view + +from .stat import bp_stat_api, bp_stat_view diff --git a/src/resources/cluster_api.py b/src/resources/cluster_api.py new file mode 100644 index 00000000..2b0241dc --- /dev/null +++ b/src/resources/cluster_api.py @@ -0,0 +1,382 @@ +import logging +import os +import sys + +from flask import Blueprint, render_template +from flask import request as r + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) +from common import log_handler, LOG_LEVEL, \ + request_get, make_ok_response, make_fail_response, \ + request_debug, request_json_body, \ + CODE_CREATED, CODE_NOT_FOUND, \ + CONSENSUS_PLUGINS, CONSENSUS_MODES, CLUSTER_SIZES +from modules import cluster_handler, host_handler + +logger = logging.getLogger(__name__) +logger.setLevel(LOG_LEVEL) +logger.addHandler(log_handler) + + +bp_cluster_api = Blueprint('bp_cluster_api', __name__, + url_prefix='/{}'.format("api")) + +front_rest_v2 = Blueprint('front_rest_v2', __name__, + url_prefix='/{}'.format("v2")) + + +def cluster_start(r): + """Start a cluster which should be in stopped status currently. + + :param r: + :return: + """ + cluster_id = request_get(r, "cluster_id") + if not cluster_id: + logger.warning("No cluster_id is given") + return make_fail_response("No cluster_id is given") + if cluster_handler.start(cluster_id): + return make_ok_response() + + return make_fail_response("cluster start failed") + + +def cluster_restart(r): + """Start a cluster which should be in stopped status currently. + + :param r: + :return: + """ + cluster_id = request_get(r, "cluster_id") + if not cluster_id: + logger.warning("No cluster_id is given") + return make_fail_response("No cluster_id is given") + if cluster_handler.restart(cluster_id): + return make_ok_response() + + return make_fail_response("cluster restart failed") + + +def cluster_stop(r): + """Stop a cluster which should be in running status currently. + + :param r: + :return: + """ + cluster_id = request_get(r, "cluster_id") + if not cluster_id: + logger.warning("No cluster_id is given") + return make_fail_response("No cluster_id is given") + if cluster_handler.stop(cluster_id): + return make_ok_response() + + return make_fail_response("cluster stop failed") + + +def cluster_apply(r): + """Apply a cluster. + + Return a Cluster json body. + """ + request_debug(r, logger) + + user_id = request_get(r, "user_id") + if not user_id: + logger.warning("cluster_apply without user_id") + return make_fail_response("cluster_apply without user_id") + + allow_multiple, condition = request_get(r, "allow_multiple"), {} + + consensus_plugin = request_get(r, "consensus_plugin") + consensus_mode = request_get(r, "consensus_mode") + cluster_size = int(request_get(r, "size") or -1) + if consensus_plugin: + if consensus_plugin not in CONSENSUS_PLUGINS: + logger.warning("Invalid consensus_plugin") + return make_fail_response("Invalid consensus_plugin") + else: + condition["consensus_plugin"] = consensus_plugin + + if consensus_mode: + if consensus_mode not in CONSENSUS_MODES: + logger.warning("Invalid consensus_mode") + return make_fail_response("Invalid consensus_mode") + else: + condition["consensus_mode"] = consensus_mode + + if cluster_size >= 0: + if cluster_size not in CLUSTER_SIZES: + logger.warning("Invalid cluster_size") + return make_fail_response("Invalid cluster_size") + else: + condition["size"] = cluster_size + + logger.debug("condition={}".format(condition)) + c = cluster_handler.apply_cluster(user_id=user_id, condition=condition, + allow_multiple=allow_multiple) + if not c: + logger.warning("cluster_apply failed") + return make_fail_response("No available res for {}".format(user_id)) + else: + return make_ok_response(data=c) + + +def cluster_release(r): + """Release a cluster which should be in used status currently. + + :param r: + :return: + """ + cluster_id = request_get(r, "cluster_id") + if not cluster_id: + logger.warning("No cluster_id is given") + return make_fail_response("No cluster_id is given") + if cluster_handler.release_cluster(cluster_id): + return make_ok_response() + + return make_fail_response("cluster release failed") + + +@front_rest_v2.route('/cluster_op', methods=['GET', 'POST']) +@bp_cluster_api.route('/cluster_op', methods=['GET', 'POST']) +def cluster_actions(): + """Issue some operations on the cluster. + Valid operations include: apply, release, start, stop, restart + e.g., + apply a cluster for user: GET /cluster_op?action=apply&user_id=xxx + release a cluster: GET /cluster_op?action=release&cluster_id=xxx + start a cluster: GET /cluster_op?action=start&cluster_id=xxx + stop a cluster: GET /cluster_op?action=stop&cluster_id=xxx + restart a cluster: GET /cluster_op?action=restart&cluster_id=xxx + + Return a json obj. + """ + request_debug(r, logger) + action = request_get(r, "action") + logger.info("cluster_op with action={}".format(action)) + if action == "apply": + return cluster_apply(r) + elif action == "release": + return cluster_release(r) + elif action == "start": + return cluster_start(r) + elif action == "stop": + return cluster_stop(r) + elif action == "restart": + return cluster_restart(r) + else: + return make_fail_response(error="Unknown action type") + + +@bp_cluster_api.route('/cluster/', methods=['GET']) +@front_rest_v2.route('/cluster/', methods=['GET']) +def cluster_query(cluster_id): + """Query a json obj of a cluster + + GET /cluster/xxxx + + Return a json obj of the cluster. + """ + request_debug(r, logger) + result = cluster_handler.get_by_id(cluster_id) + logger.info(result) + if result: + return make_ok_response(data=result) + else: + error_msg = "cluster not found with id=" + cluster_id + logger.warning(error_msg) + return make_fail_response(error=error_msg, data=r.form, + code=CODE_NOT_FOUND) + + +@bp_cluster_api.route('/cluster', methods=['POST']) +def cluster_create(): + """Create a cluster on a host + + POST /cluster + { + name: xxx, + host_id: xxx, + consensus_plugin: pbft, + consensus_mode: batch, + size: 4, + } + + :return: response object + """ + logger.info("/cluster action=" + r.method) + request_debug(r, logger) + if not r.form["name"] or not r.form["host_id"] or not \ + r.form["consensus_plugin"] or not r.form["size"]: + error_msg = "cluster post without enough data" + logger.warning(error_msg) + return make_fail_response(error=error_msg, data=r.form) + else: + name, host_id, consensus_plugin, consensus_mode, size = \ + r.form['name'], r.form['host_id'], r.form['consensus_plugin'],\ + r.form['consensus_mode'] or '', int(r.form[ + "size"]) + if consensus_plugin not in CONSENSUS_PLUGINS: + logger.debug("Unknown consensus_plugin={}".format( + consensus_plugin)) + return make_fail_response() + if consensus_plugin != CONSENSUS_PLUGINS[0] and consensus_mode \ + not in CONSENSUS_MODES: + logger.debug("Invalid consensus, plugin={}, mode={}".format( + consensus_plugin, consensus_mode)) + return make_fail_response() + + if size not in CLUSTER_SIZES: + logger.debug("Unknown cluster size={}".format(size)) + return make_fail_response() + if cluster_handler.create(name=name, host_id=host_id, + consensus_plugin=consensus_plugin, + consensus_mode=consensus_mode, + size=size): + logger.debug("cluster POST successfully") + return make_ok_response(code=CODE_CREATED) + else: + logger.debug("cluster creation failed") + return make_fail_response(error="Failed to create cluster {}". + format(name)) + + +@bp_cluster_api.route('/cluster', methods=['DELETE']) +def cluster_delete(): + """Delete a cluster + + DELETE /cluster + { + id: xxx + col_name: active + } + + :return: response obj + """ + logger.info("/cluster action=" + r.method) + request_debug(r, logger) + if not r.form["id"] or not r.form["col_name"]: + error_msg = "cluster operation post without enough data" + logger.warning(error_msg) + return make_fail_response(error=error_msg, data=r.form) + else: + logger.debug("cluster delete with id={0}, col_name={1}".format( + r.form["id"], r.form["col_name"])) + if r.form["col_name"] == "active": + result = cluster_handler.delete(id=r.form["id"]) + else: + result = cluster_handler.delete_released(id=r.form["id"]) + if result: + return make_ok_response() + else: + error_msg = "Failed to delete cluster {}".format(r.form["id"]) + logger.warning(error_msg) + return make_fail_response(error=error_msg) + + +@bp_cluster_api.route('/clusters', methods=['GET', 'POST']) +@front_rest_v2.route('/clusters', methods=['GET', 'POST']) +def cluster_list(): + """List clusters with the filter + e.g., + + GET /clusters?consensus_plugin=pbft + + Return objs of the clusters. + """ + request_debug(r, logger) + f = {} + if r.method == 'GET': + f.update(r.args.to_dict()) + elif r.method == 'POST': + f.update(request_json_body(r)) + logger.info(f) + result = cluster_handler.list(filter_data=f) + logger.error(result) + return make_ok_response(data=result) + + +# will deprecate +@front_rest_v2.route('/cluster_apply', methods=['GET', 'POST']) +def cluster_apply_dep(): + """ + Return a Cluster json body. + """ + request_debug(r, logger) + + user_id = request_get(r, "user_id") + if not user_id: + error_msg = "cluster_apply without user_id" + logger.warning(error_msg) + return make_fail_response(error=error_msg) + + allow_multiple, condition = request_get(r, "allow_multiple"), {} + + consensus_plugin = request_get(r, "consensus_plugin") + consensus_mode = request_get(r, "consensus_mode") + cluster_size = int(request_get(r, "size") or -1) + if consensus_plugin: + if consensus_plugin not in CONSENSUS_PLUGINS: + error_msg = "Invalid consensus_plugin" + logger.warning(error_msg) + return make_fail_response(error=error_msg) + else: + condition["consensus_plugin"] = consensus_plugin + + if consensus_mode: + if consensus_mode not in CONSENSUS_MODES: + error_msg = "Invalid consensus_mode" + logger.warning(error_msg) + return make_fail_response(error=error_msg) + else: + condition["consensus_mode"] = consensus_mode + + if cluster_size >= 0: + if cluster_size not in CLUSTER_SIZES: + error_msg = "Invalid cluster_size" + logger.warning(error_msg) + return make_fail_response(error=error_msg) + else: + condition["size"] = cluster_size + + logger.debug("condition={}".format(condition)) + c = cluster_handler.apply_cluster(user_id=user_id, condition=condition, + allow_multiple=allow_multiple) + if not c: + error_msg = "No available res for {}".format(user_id) + logger.warning(error_msg) + return make_fail_response(error=error_msg) + else: + return make_ok_response(data=c) + + +# will deprecate +@front_rest_v2.route('/cluster_release', methods=['GET', 'POST']) +def cluster_release_dep(): + """ + Return status. + """ + request_debug(r, logger) + user_id = request_get(r, "user_id") + cluster_id = request_get(r, "cluster_id") + if not user_id and not cluster_id: + error_msg = "cluster_release without id" + logger.warning(error_msg) + return make_fail_response(error=error_msg, data=r.args) + else: + result = None + if cluster_id: + result = cluster_handler.release_cluster(cluster_id=cluster_id) + elif user_id: + result = cluster_handler.release_cluster_for_user(user_id=user_id) + if not result: + error_msg = "cluster_release failed user_id={} cluster_id={}". \ + format(user_id, cluster_id) + logger.warning(error_msg) + data = { + "user_id": user_id, + "cluster_id": cluster_id, + } + return make_fail_response(error=error_msg, data=data) + else: + return make_ok_response() diff --git a/src/resources/cluster_view.py b/src/resources/cluster_view.py new file mode 100644 index 00000000..70a2474a --- /dev/null +++ b/src/resources/cluster_view.py @@ -0,0 +1,73 @@ +import logging +import os +import sys + +from flask import Blueprint, render_template +from flask import request as r + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) +from common import log_handler, LOG_LEVEL, \ + request_debug, \ + CONSENSUS_PLUGINS, CONSENSUS_MODES, CLUSTER_SIZES +from modules import cluster_handler, host_handler + +logger = logging.getLogger(__name__) +logger.setLevel(LOG_LEVEL) +logger.addHandler(log_handler) + + +bp_cluster_view = Blueprint('bp_cluster_view', __name__, + url_prefix='/{}'.format("view")) + + +# Return a web page with cluster info +@bp_cluster_view.route('/cluster/', methods=['GET']) +def cluster_info_show(cluster_id): + logger.debug("/ cluster_info/{}?released={} action={}".format( + cluster_id, r.args.get('released', '0'), r.method)) + released = (r.args.get('released', '0') != '0') + if not released: + return render_template("cluster_info.html", + item=cluster_handler.get_by_id(cluster_id), + consensus_plugins=CONSENSUS_PLUGINS) + else: + return render_template("cluster_info.html", + item=cluster_handler.get_by_id( + cluster_id, col_name="released"), + consensus_plugins=CONSENSUS_PLUGINS) + + +# Return a web page with clusters +@bp_cluster_view.route('/clusters', methods=['GET']) +def clusters_show(): + request_debug(r, logger) + show_type = r.args.get("type", "active") + col_filter = dict((key, r.args.get(key)) for key in r.args if + key != "col_name" and key != "page" and key != "type") + if show_type != "released": + col_name = r.args.get("col_name", "active") + else: + col_name = r.args.get("col_name", "released") + + if show_type == "inused": + col_filter["user_id"] = {"$ne": ""} + + clusters = list(cluster_handler.list(filter_data=col_filter, + col_name=col_name)) + if show_type == "active": + clusters.sort(key=lambda x: str(x["create_ts"]), reverse=True) + elif show_type == "inused": + clusters.sort(key=lambda x: str(x["apply_ts"]), reverse=True) + else: + clusters.sort(key=lambda x: str(x["release_ts"]), reverse=True) + total_items = len(clusters) + + hosts = list(host_handler.list()) + hosts_avail = list(filter(lambda e: e["status"] == "active" and len( + e["clusters"]) < e["capacity"], hosts)) + return render_template("clusters.html", type=show_type, col_name=col_name, + items_count=total_items, items=clusters, + hosts_available=hosts_avail, + consensus_plugins=CONSENSUS_PLUGINS, + consensus_modes=CONSENSUS_MODES, + cluster_sizes=CLUSTER_SIZES) diff --git a/src/resources/host_api.py b/src/resources/host_api.py new file mode 100644 index 00000000..6045c71e --- /dev/null +++ b/src/resources/host_api.py @@ -0,0 +1,159 @@ +import logging +import os +import sys + +from flask import jsonify, Blueprint, render_template +from flask import request as r + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) +from common import log_handler, LOG_LEVEL, \ + make_ok_response, make_fail_response, \ + CODE_CREATED, \ + request_debug + +from modules import host_handler + +logger = logging.getLogger(__name__) +logger.setLevel(LOG_LEVEL) +logger.addHandler(log_handler) + + +bp_host_api = Blueprint('bp_host_api', __name__, + url_prefix='/{}'.format("api")) + + +@bp_host_api.route('/host/', methods=['GET']) +def host_query(host_id): + request_debug(r, logger) + result = host_handler.get_by_id(host_id) + logger.debug(result) + if result: + return make_ok_response(data=result) + else: + error_msg = "host not found with id=" + host_id + logger.warning(error_msg) + return make_fail_response(error=error_msg, data=r.form) + + +@bp_host_api.route('/host', methods=['POST']) +def host_create(): + request_debug(r, logger) + name, daemon_url, capacity, log_type, log_server, log_level = \ + r.form['name'], r.form['daemon_url'], r.form['capacity'], \ + r.form['log_type'], r.form['log_server'], r.form['log_level'] + + if "autofill" in r.form and r.form["autofill"] == "on": + autofill = "true" + else: + autofill = "false" + + if "schedulable" in r.form and r.form["schedulable"] == "on": + schedulable = "true" + else: + schedulable = "false" + + logger.debug("name={}, daemon_url={}, capacity={}" + "fillup={}, schedulable={}, log={}/{}". + format(name, daemon_url, capacity, autofill, schedulable, + log_type, log_server)) + if not name or not daemon_url or not capacity or not log_type: + error_msg = "host POST without enough data" + logger.warning(error_msg) + return make_fail_response(error=error_msg, data=r.form) + else: + result = host_handler.create(name=name, daemon_url=daemon_url, + capacity=int(capacity), + autofill=autofill, + schedulable=schedulable, + log_level=log_level, + log_type=log_type, + log_server=log_server) + if result: + logger.debug("host creation successfully") + return make_ok_response(code=CODE_CREATED) + else: + error_msg = "Failed to create host {}".format(r.form["name"]) + logger.warning(error_msg) + return make_fail_response(error=error_msg) + + +@bp_host_api.route('/host', methods=['PUT']) +def host_update(): + request_debug(r, logger) + if "id" not in r.form: + error_msg = "host PUT without enough data" + logger.warning(error_msg) + return make_fail_response(error=error_msg, + data=r.form) + else: + id, d = r.form["id"], {} + for k in r.form: + if k != "id": + d[k] = r.form.get(k) + result = host_handler.update(id, d) + if result: + logger.debug("host PUT successfully") + return make_ok_response() + else: + error_msg = "Failed to update host {}".format(result.get("name")) + logger.warning(error_msg) + return make_fail_response(error=error_msg) + + +@bp_host_api.route('/host', methods=['PUT', 'DELETE']) +def host_delete(): + request_debug(r, logger) + if "id" not in r.form or not r.form["id"]: + error_msg = "host delete without enough data" + logger.warning(error_msg) + return make_fail_response(error=error_msg, data=r.form) + else: + logger.debug("host delete with id={0}".format(r.form["id"])) + if host_handler.delete(id=r.form["id"]): + return make_ok_response() + else: + error_msg = "Failed to delete host {}".format(r.form["id"]) + logger.warning(error_msg) + return make_fail_response(error=error_msg) + + +@bp_host_api.route('/host_op', methods=['POST']) +def host_actions(): + logger.info("/host_op, method=" + r.method) + request_debug(r, logger) + + host_id, action = r.form['id'], r.form['action'] + if not host_id or not action: + error_msg = "host POST without enough data" + logger.warning(error_msg) + return make_fail_response(error=error_msg, + data=r.form) + else: + if action == "fillup": + if host_handler.fillup(host_id): + logger.debug("fillup successfully") + return make_ok_response() + else: + error_msg = "Failed to fillup the host." + logger.warning(error_msg) + return make_fail_response(error=error_msg, data=r.form) + elif action == "clean": + if host_handler.clean(host_id): + logger.debug("clean successfully") + return make_ok_response() + else: + error_msg = "Failed to clean the host." + logger.warning(error_msg) + return make_fail_response(error=error_msg, data=r.form) + elif action == "reset": + if host_handler.reset(host_id): + logger.debug("reset successfully") + return make_ok_response() + else: + error_msg = "Failed to reset the host." + logger.warning(error_msg) + return make_fail_response(error=error_msg, data=r.form) + + error_msg = "unknown host action={}".format(action) + logger.warning(error_msg) + return make_fail_response(error=error_msg, data=r.form) diff --git a/src/resources/host_view.py b/src/resources/host_view.py new file mode 100644 index 00000000..cead3afb --- /dev/null +++ b/src/resources/host_view.py @@ -0,0 +1,45 @@ +import logging +import os +import sys + +from flask import Blueprint, render_template +from flask import request as r + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) +from common import log_handler, LOG_LEVEL, \ + HOST_TYPES, request_debug, \ + CLUSTER_LOG_TYPES, CLUSTER_LOG_LEVEL +from modules import host_handler + +logger = logging.getLogger(__name__) +logger.setLevel(LOG_LEVEL) +logger.addHandler(log_handler) + + +bp_host_view = Blueprint('bp_host_view', __name__, + url_prefix='/{}'.format("view")) + + +@bp_host_view.route('/hosts', methods=['GET']) +def hosts_show(): + logger.info("/hosts method=" + r.method) + request_debug(r, logger) + col_filter = dict((key, r.args.get(key)) for key in r.args) + items = list(host_handler.list(filter_data=col_filter)) + items.sort(key=lambda x: str(x["name"]), reverse=True) + logger.debug(items) + + return render_template("hosts.html", + items_count=len(items), + items=items, + host_types=HOST_TYPES, + log_types=CLUSTER_LOG_TYPES, + log_levels=CLUSTER_LOG_LEVEL, + ) + + +@bp_host_view.route('/host/', methods=['GET']) +def host_info(host_id): + logger.debug("/ host_info/{0} method={1}".format(host_id, r.method)) + return render_template("host_info.html", item=host_handler.get_by_id( + host_id)) diff --git a/src/resources/index.py b/src/resources/index.py new file mode 100644 index 00000000..9bfaeb13 --- /dev/null +++ b/src/resources/index.py @@ -0,0 +1,65 @@ +import logging +import os +import sys +from flask import Blueprint, render_template +from flask import request as r + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) +from common import log_handler, LOG_LEVEL, CONSENSUS_PLUGINS, \ + CONSENSUS_MODES, HOST_TYPES, CLUSTER_SIZES, request_debug, \ + CLUSTER_LOG_TYPES, CLUSTER_LOG_LEVEL +from version import version, homepage, author + +logger = logging.getLogger(__name__) +logger.setLevel(LOG_LEVEL) +logger.addHandler(log_handler) + +from modules import cluster_handler, host_handler + +bp_index = Blueprint('bp_index', __name__) + + +@bp_index.route('/', methods=['GET']) +@bp_index.route('/index', methods=['GET']) +def show(): + request_debug(r, logger) + hosts = list(host_handler.list(filter_data={})) + hosts.sort(key=lambda x: x["name"], reverse=False) + hosts_active = list(filter(lambda e: e["status"] == "active", hosts)) + hosts_inactive = list(filter(lambda e: e["status"] != "active", hosts)) + hosts_free = list(filter( + lambda e: len(e["clusters"]) < e["capacity"], hosts_active)) + hosts_available = hosts_free + clusters_active = len(list(cluster_handler.list(col_name="active"))) + clusters_released = len(list(cluster_handler.list(col_name="released"))) + clusters_free = len(list(cluster_handler.list(filter_data={"user_id": ""}, + col_name="active"))) + clusters_inuse = clusters_active - clusters_free + + clusters_temp = len(list(cluster_handler.list(filter_data={ + "user_id": "/^__/"}, col_name="active"))) + + return render_template("index.html", hosts=hosts, + hosts_free=hosts_free, + hosts_active=hosts_active, + hosts_inactive=hosts_inactive, + hosts_available=hosts_available, + clusters_active=clusters_active, + clusters_released=clusters_released, + clusters_free=clusters_free, + clusters_inuse=clusters_inuse, + clusters_temp=clusters_temp, + cluster_sizes=CLUSTER_SIZES, + consensus_plugins=CONSENSUS_PLUGINS, + consensus_modes=CONSENSUS_MODES, + host_types=HOST_TYPES, + log_types=CLUSTER_LOG_TYPES, + log_levels=CLUSTER_LOG_LEVEL, + ) + + +@bp_index.route('/about', methods=['GET']) +def about(): + logger.info("path={}, method={}".format(r.path, r.method)) + return render_template("about.html", author=author, version=version, + homepage=homepage) diff --git a/src/resources/stat.py b/src/resources/stat.py new file mode 100644 index 00000000..0b4e0e0a --- /dev/null +++ b/src/resources/stat.py @@ -0,0 +1,56 @@ +import logging +import os +import sys +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) + +from flask import Blueprint, jsonify, render_template +from flask import request as r +from common import log_handler, LOG_LEVEL, CODE_OK, request_debug +from version import version +from modules import host_handler, stat_handler + +logger = logging.getLogger(__name__) +logger.setLevel(LOG_LEVEL) +logger.addHandler(log_handler) + + +bp_stat_api = Blueprint('bp_stat_api', __name__, url_prefix='/api') + + +@bp_stat_api.route('/health', methods=['GET']) +def health(): + request_debug(r, logger) + result = { + 'health': 'OK', + 'version': version + } + + return jsonify(result), CODE_OK + + +@bp_stat_api.route('/stat', methods=['GET']) +def get(): + request_debug(r, logger) + res = r.args.get('res') + if res == 'host': + result = stat_handler.hosts() + elif res == 'cluster': + result = stat_handler.clusters() + else: + result = { + 'example': '/api/stat?res=host' + } + + logger.debug(result) + return jsonify(result), CODE_OK + + +bp_stat_view = Blueprint('bp_stat_view', __name__, url_prefix='/view') + + +@bp_stat_view.route('/stat', methods=['GET']) +def show(): + logger.info("path={}, method={}".format(r.path, r.method)) + hosts = list(host_handler.list()) + + return render_template("stat.html", hosts=hosts) diff --git a/src/restserver.py b/src/restserver.py new file mode 100644 index 00000000..fbd36ae6 --- /dev/null +++ b/src/restserver.py @@ -0,0 +1,25 @@ +import os +from flask import Flask + +from common import log_handler, LOG_LEVEL +from resources import front_rest_v2 + +app = Flask(__name__, static_folder='static', template_folder='templates') + +app.config.from_object('config.DevelopmentConfig') +app.config.from_envvar('CELLO_CONFIG_FILE', silent=True) + +app.logger.addHandler(log_handler) +app.logger.setLevel(LOG_LEVEL) + + +# app.register_blueprint(front_rest_v1) +app.register_blueprint(front_rest_v2) + +if __name__ == '__main__': + app.run( + host='0.0.0.0', + port=80, + debug=os.environ.get('DEBUG', app.config.get("DEBUG", True)), + threaded=True + ) diff --git a/src/static/css/bootstrap-table.min.css b/src/static/css/bootstrap-table.min.css new file mode 100644 index 00000000..ad36a502 --- /dev/null +++ b/src/static/css/bootstrap-table.min.css @@ -0,0 +1 @@ +.fixed-table-container .bs-checkbox,.fixed-table-container .no-records-found{text-align:center}.fixed-table-body thead th .th-inner,.table td,.table th{box-sizing:border-box}.bootstrap-table .table{margin-bottom:0!important;border-bottom:1px solid #ddd;border-collapse:collapse!important;border-radius:1px}.bootstrap-table .table:not(.table-condensed),.bootstrap-table .table:not(.table-condensed)>tbody>tr>td,.bootstrap-table .table:not(.table-condensed)>tbody>tr>th,.bootstrap-table .table:not(.table-condensed)>tfoot>tr>td,.bootstrap-table .table:not(.table-condensed)>tfoot>tr>th,.bootstrap-table .table:not(.table-condensed)>thead>tr>td{padding:8px}.bootstrap-table .table.table-no-bordered>tbody>tr>td,.bootstrap-table .table.table-no-bordered>thead>tr>th{border-right:2px solid transparent}.fixed-table-container{position:relative;clear:both;border:1px solid #ddd;border-radius:4px;-webkit-border-radius:4px;-moz-border-radius:4px}.fixed-table-container.table-no-bordered{border:1px solid transparent}.fixed-table-footer,.fixed-table-header{overflow:hidden}.fixed-table-footer{border-top:1px solid #ddd}.fixed-table-body{overflow-x:auto;overflow-y:auto;height:100%}.fixed-table-container table{width:100%}.fixed-table-container thead th{height:0;padding:0;margin:0;border-left:1px solid #ddd}.fixed-table-container thead th:focus{outline:transparent solid 0}.fixed-table-container thead th:first-child{border-left:none;border-top-left-radius:4px;-webkit-border-top-left-radius:4px;-moz-border-radius-topleft:4px}.fixed-table-container tbody td .th-inner,.fixed-table-container thead th .th-inner{padding:8px;line-height:24px;vertical-align:top;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.fixed-table-container thead th .sortable{cursor:pointer;background-position:right;background-repeat:no-repeat;padding-right:30px}.fixed-table-container thead th .both{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAAkElEQVQoz7X QMQ5AQBCF4dWQSJxC5wwax1Cq1e7BAdxD5SL+Tq/QCM1oNiJidwox0355mXnG/DrEtIQ6azioNZQxI0ykPhTQIwhCR+BmBYtlK7kLJYwWCcJA9M4qdrZrd8pPjZWPtOqdRQy320YSV17OatFC4euts6z39GYMKRPCTKY9UnPQ6P+GtMRfGtPnBCiqhAeJPmkqAAAAAElFTkSuQmCC')}.fixed-table-container thead th .asc{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZ0lEQVQ4y2NgGLKgquEuFxBPAGI2ahhWCsS/gDibUoO0gPgxEP8H4ttArEyuQYxAPBdqEAxPBImTY5gjEL9DM+wTENuQahAvEO9DMwiGdwAxOymGJQLxTyD+jgWDxCMZRsEoGAVoAADeemwtPcZI2wAAAABJRU5ErkJggg==)}.fixed-table-container thead th .desc{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZUlEQVQ4y2NgGAWjYBSggaqGu5FA/BOIv2PBIPFEUgxjB+IdQPwfC94HxLykus4GiD+hGfQOiB3J8SojEE9EM2wuSJzcsFMG4ttQgx4DsRalkZENxL+AuJQaMcsGxBOAmGvopk8AVz1sLZgg0bsAAAAASUVORK5CYII=)}.fixed-table-container th.detail{width:30px}.fixed-table-container tbody td{border-left:1px solid #ddd}.fixed-table-container tbody tr:first-child td{border-top:none}.fixed-table-container tbody td:first-child{border-left:none}.fixed-table-container tbody .selected td{background-color:#f5f5f5}.fixed-table-container .bs-checkbox .th-inner{padding:8px 0}.fixed-table-container input[type=radio],.fixed-table-container input[type=checkbox]{margin:0 auto!important}.fixed-table-pagination .pagination-detail,.fixed-table-pagination div.pagination{margin-top:10px;margin-bottom:10px}.fixed-table-pagination div.pagination .pagination{margin:0}.fixed-table-pagination .pagination a{padding:6px 12px;line-height:1.428571429}.fixed-table-pagination .pagination-info{line-height:34px;margin-right:5px}.fixed-table-pagination .btn-group{position:relative;display:inline-block;vertical-align:middle}.fixed-table-pagination .dropup .dropdown-menu{margin-bottom:0}.fixed-table-pagination .page-list{display:inline-block}.fixed-table-toolbar .columns-left{margin-right:5px}.fixed-table-toolbar .columns-right{margin-left:5px}.fixed-table-toolbar .columns label{display:block;padding:3px 20px;clear:both;font-weight:400;line-height:1.428571429}.fixed-table-toolbar .bars,.fixed-table-toolbar .columns,.fixed-table-toolbar .search{position:relative;margin-top:10px;margin-bottom:10px;line-height:34px}.fixed-table-pagination li.disabled a{pointer-events:none;cursor:default}.fixed-table-loading{display:none;position:absolute;top:42px;right:0;bottom:0;left:0;z-index:99;background-color:#fff;text-align:center}.fixed-table-body .card-view .title{font-weight:700;display:inline-block;min-width:30%;text-align:left!important}.table td,.table th{vertical-align:middle}.fixed-table-toolbar .dropdown-menu{text-align:left;max-height:300px;overflow:auto}.fixed-table-toolbar .btn-group>.btn-group{display:inline-block;margin-left:-1px!important}.fixed-table-toolbar .btn-group>.btn-group>.btn{border-radius:0}.fixed-table-toolbar .btn-group>.btn-group:first-child>.btn{border-top-left-radius:4px;border-bottom-left-radius:4px}.fixed-table-toolbar .btn-group>.btn-group:last-child>.btn{border-top-right-radius:4px;border-bottom-right-radius:4px}.bootstrap-table .table>thead>tr>th{vertical-align:bottom;border-bottom:1px solid #ddd}.bootstrap-table .table thead>tr>th{padding:0;margin:0}.bootstrap-table .fixed-table-footer tbody>tr>td{padding:0!important}.bootstrap-table .fixed-table-footer .table{border-bottom:none;border-radius:0;padding:0!important}.pull-right .dropdown-menu{right:0;left:auto}p.fixed-table-scroll-inner{width:100%;height:200px}div.fixed-table-scroll-outer{top:0;left:0;visibility:hidden;width:200px;height:150px;overflow:hidden} \ No newline at end of file diff --git a/src/static/css/bootstrap.min.css b/src/static/css/bootstrap.min.css new file mode 100644 index 00000000..4cf729e4 --- /dev/null +++ b/src/static/css/bootstrap.min.css @@ -0,0 +1,6 @@ +/*! + * Bootstrap v3.3.6 (http://getbootstrap.com) + * Copyright 2011-2015 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + *//*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{margin:0;font:inherit;color:inherit}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}input{line-height:normal}input[type=checkbox],input[type=radio]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}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}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid silver}legend{padding:0;border:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-spacing:0;border-collapse:collapse}td,th{padding:0}/*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */@media print{*,:after,:before{color:#000!important;text-shadow:none!important;background:0 0!important;-webkit-box-shadow:none!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:""}blockquote,pre{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}img,tr{page-break-inside:avoid}img{max-width:100%!important}h2,h3,p{orphans:3;widows:3}h2,h3{page-break-after:avoid}.navbar{display:none}.btn>.caret,.dropup>.btn>.caret{border-top-color:#000!important}.label{border:1px solid #000}.table{border-collapse:collapse!important}.table td,.table th{background-color:#fff!important}.table-bordered td,.table-bordered th{border:1px solid #ddd!important}}@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.woff2) format('woff2'),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';font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.glyphicon-asterisk:before{content:"\002a"}.glyphicon-plus:before{content:"\002b"}.glyphicon-eur:before,.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"}.glyphicon-cd:before{content:"\e201"}.glyphicon-save-file:before{content:"\e202"}.glyphicon-open-file:before{content:"\e203"}.glyphicon-level-up:before{content:"\e204"}.glyphicon-copy:before{content:"\e205"}.glyphicon-paste:before{content:"\e206"}.glyphicon-alert:before{content:"\e209"}.glyphicon-equalizer:before{content:"\e210"}.glyphicon-king:before{content:"\e211"}.glyphicon-queen:before{content:"\e212"}.glyphicon-pawn:before{content:"\e213"}.glyphicon-bishop:before{content:"\e214"}.glyphicon-knight:before{content:"\e215"}.glyphicon-baby-formula:before{content:"\e216"}.glyphicon-tent:before{content:"\26fa"}.glyphicon-blackboard:before{content:"\e218"}.glyphicon-bed:before{content:"\e219"}.glyphicon-apple:before{content:"\f8ff"}.glyphicon-erase:before{content:"\e221"}.glyphicon-hourglass:before{content:"\231b"}.glyphicon-lamp:before{content:"\e223"}.glyphicon-duplicate:before{content:"\e224"}.glyphicon-piggy-bank:before{content:"\e225"}.glyphicon-scissors:before{content:"\e226"}.glyphicon-bitcoin:before{content:"\e227"}.glyphicon-btc:before{content:"\e227"}.glyphicon-xbt:before{content:"\e227"}.glyphicon-yen:before{content:"\00a5"}.glyphicon-jpy:before{content:"\00a5"}.glyphicon-ruble:before{content:"\20bd"}.glyphicon-rub:before{content:"\20bd"}.glyphicon-scale:before{content:"\e230"}.glyphicon-ice-lolly:before{content:"\e231"}.glyphicon-ice-lolly-tasted:before{content:"\e232"}.glyphicon-education:before{content:"\e233"}.glyphicon-option-horizontal:before{content:"\e234"}.glyphicon-option-vertical:before{content:"\e235"}.glyphicon-menu-hamburger:before{content:"\e236"}.glyphicon-modal-window:before{content:"\e237"}.glyphicon-oil:before{content:"\e238"}.glyphicon-grain:before{content:"\e239"}.glyphicon-sunglasses:before{content:"\e240"}.glyphicon-text-size:before{content:"\e241"}.glyphicon-text-color:before{content:"\e242"}.glyphicon-text-background:before{content:"\e243"}.glyphicon-object-align-top:before{content:"\e244"}.glyphicon-object-align-bottom:before{content:"\e245"}.glyphicon-object-align-horizontal:before{content:"\e246"}.glyphicon-object-align-left:before{content:"\e247"}.glyphicon-object-align-vertical:before{content:"\e248"}.glyphicon-object-align-right:before{content:"\e249"}.glyphicon-triangle-right:before{content:"\e250"}.glyphicon-triangle-left:before{content:"\e251"}.glyphicon-triangle-bottom:before{content:"\e252"}.glyphicon-triangle-top:before{content:"\e253"}.glyphicon-console:before{content:"\e254"}.glyphicon-superscript:before{content:"\e255"}.glyphicon-subscript:before{content:"\e256"}.glyphicon-menu-left:before{content:"\e257"}.glyphicon-menu-right:before{content:"\e258"}.glyphicon-menu-down:before{content:"\e259"}.glyphicon-menu-up:before{content:"\e260"}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}:after,:before{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html{font-size:10px;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:1.42857143;color:#333;background-color:#fff}button,input,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit}a{color:#337ab7;text-decoration:none}a:focus,a:hover{color:#23527c;text-decoration:underline}a:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}figure{margin:0}img{vertical-align:middle}.carousel-inner>.item>a>img,.carousel-inner>.item>img,.img-responsive,.thumbnail a>img,.thumbnail>img{display:block;max-width:100%;height:auto}.img-rounded{border-radius:6px}.img-thumbnail{display:inline-block;max-width:100%;height:auto;padding:4px;line-height:1.42857143;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:all .2s ease-in-out;-o-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}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}[role=button]{cursor:pointer}.h1,.h2,.h3,.h4,.h5,.h6,h1,h2,h3,h4,h5,h6{font-family:inherit;font-weight:500;line-height:1.1;color:inherit}.h1 .small,.h1 small,.h2 .small,.h2 small,.h3 .small,.h3 small,.h4 .small,.h4 small,.h5 .small,.h5 small,.h6 .small,.h6 small,h1 .small,h1 small,h2 .small,h2 small,h3 .small,h3 small,h4 .small,h4 small,h5 .small,h5 small,h6 .small,h6 small{font-weight:400;line-height:1;color:#777}.h1,.h2,.h3,h1,h2,h3{margin-top:20px;margin-bottom:10px}.h1 .small,.h1 small,.h2 .small,.h2 small,.h3 .small,.h3 small,h1 .small,h1 small,h2 .small,h2 small,h3 .small,h3 small{font-size:65%}.h4,.h5,.h6,h4,h5,h6{margin-top:10px;margin-bottom:10px}.h4 .small,.h4 small,.h5 .small,.h5 small,.h6 .small,.h6 small,h4 .small,h4 small,h5 .small,h5 small,h6 .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:300;line-height:1.4}@media (min-width:768px){.lead{font-size:21px}}.small,small{font-size:85%}.mark,mark{padding:.2em;background-color:#fcf8e3}.text-left{text-align:left}.text-right{text-align:right}.text-center{text-align:center}.text-justify{text-align:justify}.text-nowrap{white-space:nowrap}.text-lowercase{text-transform:lowercase}.text-uppercase{text-transform:uppercase}.text-capitalize{text-transform:capitalize}.text-muted{color:#777}.text-primary{color:#337ab7}a.text-primary:focus,a.text-primary:hover{color:#286090}.text-success{color:#3c763d}a.text-success:focus,a.text-success:hover{color:#2b542c}.text-info{color:#31708f}a.text-info:focus,a.text-info:hover{color:#245269}.text-warning{color:#8a6d3b}a.text-warning:focus,a.text-warning:hover{color:#66512c}.text-danger{color:#a94442}a.text-danger:focus,a.text-danger:hover{color:#843534}.bg-primary{color:#fff;background-color:#337ab7}a.bg-primary:focus,a.bg-primary:hover{background-color:#286090}.bg-success{background-color:#dff0d8}a.bg-success:focus,a.bg-success:hover{background-color:#c1e2b3}.bg-info{background-color:#d9edf7}a.bg-info:focus,a.bg-info:hover{background-color:#afd9ee}.bg-warning{background-color:#fcf8e3}a.bg-warning:focus,a.bg-warning:hover{background-color:#f7ecb5}.bg-danger{background-color:#f2dede}a.bg-danger:focus,a.bg-danger:hover{background-color:#e4b9b9}.page-header{padding-bottom:9px;margin:40px 0 20px;border-bottom:1px solid #eee}ol,ul{margin-top:0;margin-bottom:10px}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}.list-unstyled{padding-left:0;list-style:none}.list-inline{padding-left:0;margin-left:-5px;list-style:none}.list-inline>li{display:inline-block;padding-right:5px;padding-left:5px}dl{margin-top:0;margin-bottom:20px}dd,dt{line-height:1.42857143}dt{font-weight:700}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}}abbr[data-original-title],abbr[title]{cursor:help;border-bottom:1px dotted #777}.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:10px 20px;margin:0 0 20px;font-size:17.5px;border-left:5px solid #eee}blockquote ol:last-child,blockquote p:last-child,blockquote ul:last-child{margin-bottom:0}blockquote .small,blockquote footer,blockquote small{display:block;font-size:80%;line-height:1.42857143;color:#777}blockquote .small:before,blockquote footer:before,blockquote small:before{content:'\2014 \00A0'}.blockquote-reverse,blockquote.pull-right{padding-right:15px;padding-left:0;text-align:right;border-right:5px solid #eee;border-left:0}.blockquote-reverse .small:before,.blockquote-reverse footer:before,.blockquote-reverse small:before,blockquote.pull-right .small:before,blockquote.pull-right footer:before,blockquote.pull-right small:before{content:''}.blockquote-reverse .small:after,.blockquote-reverse footer:after,.blockquote-reverse small:after,blockquote.pull-right .small:after,blockquote.pull-right footer:after,blockquote.pull-right small:after{content:'\00A0 \2014'}address{margin-bottom:20px;font-style:normal;line-height:1.42857143}code,kbd,pre,samp{font-family:Menlo,Monaco,Consolas,"Courier New",monospace}code{padding:2px 4px;font-size:90%;color:#c7254e;background-color:#f9f2f4;border-radius:4px}kbd{padding:2px 4px;font-size:90%;color:#fff;background-color:#333;border-radius:3px;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.25);box-shadow:inset 0 -1px 0 rgba(0,0,0,.25)}kbd kbd{padding:0;font-size:100%;font-weight:700;-webkit-box-shadow:none;box-shadow:none}pre{display:block;padding:9.5px;margin:0 0 10px;font-size:13px;line-height:1.42857143;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}@media (min-width:768px){.container{width:750px}}@media (min-width:992px){.container{width:970px}}@media (min-width:1200px){.container{width:1170px}}.container-fluid{padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}.row{margin-right:-15px;margin-left:-15px}.col-lg-1,.col-lg-10,.col-lg-11,.col-lg-12,.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-md-1,.col-md-10,.col-md-11,.col-md-12,.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-sm-1,.col-sm-10,.col-sm-11,.col-sm-12,.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-xs-1,.col-xs-10,.col-xs-11,.col-xs-12,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9{position:relative;min-height:1px;padding-right:15px;padding-left:15px}.col-xs-1,.col-xs-10,.col-xs-11,.col-xs-12,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9{float:left}.col-xs-12{width:100%}.col-xs-11{width:91.66666667%}.col-xs-10{width:83.33333333%}.col-xs-9{width:75%}.col-xs-8{width:66.66666667%}.col-xs-7{width:58.33333333%}.col-xs-6{width:50%}.col-xs-5{width:41.66666667%}.col-xs-4{width:33.33333333%}.col-xs-3{width:25%}.col-xs-2{width:16.66666667%}.col-xs-1{width:8.33333333%}.col-xs-pull-12{right:100%}.col-xs-pull-11{right:91.66666667%}.col-xs-pull-10{right:83.33333333%}.col-xs-pull-9{right:75%}.col-xs-pull-8{right:66.66666667%}.col-xs-pull-7{right:58.33333333%}.col-xs-pull-6{right:50%}.col-xs-pull-5{right:41.66666667%}.col-xs-pull-4{right:33.33333333%}.col-xs-pull-3{right:25%}.col-xs-pull-2{right:16.66666667%}.col-xs-pull-1{right:8.33333333%}.col-xs-pull-0{right:auto}.col-xs-push-12{left:100%}.col-xs-push-11{left:91.66666667%}.col-xs-push-10{left:83.33333333%}.col-xs-push-9{left:75%}.col-xs-push-8{left:66.66666667%}.col-xs-push-7{left:58.33333333%}.col-xs-push-6{left:50%}.col-xs-push-5{left:41.66666667%}.col-xs-push-4{left:33.33333333%}.col-xs-push-3{left:25%}.col-xs-push-2{left:16.66666667%}.col-xs-push-1{left:8.33333333%}.col-xs-push-0{left:auto}.col-xs-offset-12{margin-left:100%}.col-xs-offset-11{margin-left:91.66666667%}.col-xs-offset-10{margin-left:83.33333333%}.col-xs-offset-9{margin-left:75%}.col-xs-offset-8{margin-left:66.66666667%}.col-xs-offset-7{margin-left:58.33333333%}.col-xs-offset-6{margin-left:50%}.col-xs-offset-5{margin-left:41.66666667%}.col-xs-offset-4{margin-left:33.33333333%}.col-xs-offset-3{margin-left:25%}.col-xs-offset-2{margin-left:16.66666667%}.col-xs-offset-1{margin-left:8.33333333%}.col-xs-offset-0{margin-left:0}@media (min-width:768px){.col-sm-1,.col-sm-10,.col-sm-11,.col-sm-12,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9{float:left}.col-sm-12{width:100%}.col-sm-11{width:91.66666667%}.col-sm-10{width:83.33333333%}.col-sm-9{width:75%}.col-sm-8{width:66.66666667%}.col-sm-7{width:58.33333333%}.col-sm-6{width:50%}.col-sm-5{width:41.66666667%}.col-sm-4{width:33.33333333%}.col-sm-3{width:25%}.col-sm-2{width:16.66666667%}.col-sm-1{width:8.33333333%}.col-sm-pull-12{right:100%}.col-sm-pull-11{right:91.66666667%}.col-sm-pull-10{right:83.33333333%}.col-sm-pull-9{right:75%}.col-sm-pull-8{right:66.66666667%}.col-sm-pull-7{right:58.33333333%}.col-sm-pull-6{right:50%}.col-sm-pull-5{right:41.66666667%}.col-sm-pull-4{right:33.33333333%}.col-sm-pull-3{right:25%}.col-sm-pull-2{right:16.66666667%}.col-sm-pull-1{right:8.33333333%}.col-sm-pull-0{right:auto}.col-sm-push-12{left:100%}.col-sm-push-11{left:91.66666667%}.col-sm-push-10{left:83.33333333%}.col-sm-push-9{left:75%}.col-sm-push-8{left:66.66666667%}.col-sm-push-7{left:58.33333333%}.col-sm-push-6{left:50%}.col-sm-push-5{left:41.66666667%}.col-sm-push-4{left:33.33333333%}.col-sm-push-3{left:25%}.col-sm-push-2{left:16.66666667%}.col-sm-push-1{left:8.33333333%}.col-sm-push-0{left:auto}.col-sm-offset-12{margin-left:100%}.col-sm-offset-11{margin-left:91.66666667%}.col-sm-offset-10{margin-left:83.33333333%}.col-sm-offset-9{margin-left:75%}.col-sm-offset-8{margin-left:66.66666667%}.col-sm-offset-7{margin-left:58.33333333%}.col-sm-offset-6{margin-left:50%}.col-sm-offset-5{margin-left:41.66666667%}.col-sm-offset-4{margin-left:33.33333333%}.col-sm-offset-3{margin-left:25%}.col-sm-offset-2{margin-left:16.66666667%}.col-sm-offset-1{margin-left:8.33333333%}.col-sm-offset-0{margin-left:0}}@media (min-width:992px){.col-md-1,.col-md-10,.col-md-11,.col-md-12,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9{float:left}.col-md-12{width:100%}.col-md-11{width:91.66666667%}.col-md-10{width:83.33333333%}.col-md-9{width:75%}.col-md-8{width:66.66666667%}.col-md-7{width:58.33333333%}.col-md-6{width:50%}.col-md-5{width:41.66666667%}.col-md-4{width:33.33333333%}.col-md-3{width:25%}.col-md-2{width:16.66666667%}.col-md-1{width:8.33333333%}.col-md-pull-12{right:100%}.col-md-pull-11{right:91.66666667%}.col-md-pull-10{right:83.33333333%}.col-md-pull-9{right:75%}.col-md-pull-8{right:66.66666667%}.col-md-pull-7{right:58.33333333%}.col-md-pull-6{right:50%}.col-md-pull-5{right:41.66666667%}.col-md-pull-4{right:33.33333333%}.col-md-pull-3{right:25%}.col-md-pull-2{right:16.66666667%}.col-md-pull-1{right:8.33333333%}.col-md-pull-0{right:auto}.col-md-push-12{left:100%}.col-md-push-11{left:91.66666667%}.col-md-push-10{left:83.33333333%}.col-md-push-9{left:75%}.col-md-push-8{left:66.66666667%}.col-md-push-7{left:58.33333333%}.col-md-push-6{left:50%}.col-md-push-5{left:41.66666667%}.col-md-push-4{left:33.33333333%}.col-md-push-3{left:25%}.col-md-push-2{left:16.66666667%}.col-md-push-1{left:8.33333333%}.col-md-push-0{left:auto}.col-md-offset-12{margin-left:100%}.col-md-offset-11{margin-left:91.66666667%}.col-md-offset-10{margin-left:83.33333333%}.col-md-offset-9{margin-left:75%}.col-md-offset-8{margin-left:66.66666667%}.col-md-offset-7{margin-left:58.33333333%}.col-md-offset-6{margin-left:50%}.col-md-offset-5{margin-left:41.66666667%}.col-md-offset-4{margin-left:33.33333333%}.col-md-offset-3{margin-left:25%}.col-md-offset-2{margin-left:16.66666667%}.col-md-offset-1{margin-left:8.33333333%}.col-md-offset-0{margin-left:0}}@media (min-width:1200px){.col-lg-1,.col-lg-10,.col-lg-11,.col-lg-12,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9{float:left}.col-lg-12{width:100%}.col-lg-11{width:91.66666667%}.col-lg-10{width:83.33333333%}.col-lg-9{width:75%}.col-lg-8{width:66.66666667%}.col-lg-7{width:58.33333333%}.col-lg-6{width:50%}.col-lg-5{width:41.66666667%}.col-lg-4{width:33.33333333%}.col-lg-3{width:25%}.col-lg-2{width:16.66666667%}.col-lg-1{width:8.33333333%}.col-lg-pull-12{right:100%}.col-lg-pull-11{right:91.66666667%}.col-lg-pull-10{right:83.33333333%}.col-lg-pull-9{right:75%}.col-lg-pull-8{right:66.66666667%}.col-lg-pull-7{right:58.33333333%}.col-lg-pull-6{right:50%}.col-lg-pull-5{right:41.66666667%}.col-lg-pull-4{right:33.33333333%}.col-lg-pull-3{right:25%}.col-lg-pull-2{right:16.66666667%}.col-lg-pull-1{right:8.33333333%}.col-lg-pull-0{right:auto}.col-lg-push-12{left:100%}.col-lg-push-11{left:91.66666667%}.col-lg-push-10{left:83.33333333%}.col-lg-push-9{left:75%}.col-lg-push-8{left:66.66666667%}.col-lg-push-7{left:58.33333333%}.col-lg-push-6{left:50%}.col-lg-push-5{left:41.66666667%}.col-lg-push-4{left:33.33333333%}.col-lg-push-3{left:25%}.col-lg-push-2{left:16.66666667%}.col-lg-push-1{left:8.33333333%}.col-lg-push-0{left:auto}.col-lg-offset-12{margin-left:100%}.col-lg-offset-11{margin-left:91.66666667%}.col-lg-offset-10{margin-left:83.33333333%}.col-lg-offset-9{margin-left:75%}.col-lg-offset-8{margin-left:66.66666667%}.col-lg-offset-7{margin-left:58.33333333%}.col-lg-offset-6{margin-left:50%}.col-lg-offset-5{margin-left:41.66666667%}.col-lg-offset-4{margin-left:33.33333333%}.col-lg-offset-3{margin-left:25%}.col-lg-offset-2{margin-left:16.66666667%}.col-lg-offset-1{margin-left:8.33333333%}.col-lg-offset-0{margin-left:0}}table{background-color:transparent}caption{padding-top:8px;padding-bottom:8px;color:#777;text-align:left}th{text-align:left}.table{width:100%;max-width:100%;margin-bottom:20px}.table>tbody>tr>td,.table>tbody>tr>th,.table>tfoot>tr>td,.table>tfoot>tr>th,.table>thead>tr>td,.table>thead>tr>th{padding:8px;line-height:1.42857143;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>td,.table>caption+thead>tr:first-child>th,.table>colgroup+thead>tr:first-child>td,.table>colgroup+thead>tr:first-child>th,.table>thead:first-child>tr:first-child>td,.table>thead:first-child>tr:first-child>th{border-top:0}.table>tbody+tbody{border-top:2px solid #ddd}.table .table{background-color:#fff}.table-condensed>tbody>tr>td,.table-condensed>tbody>tr>th,.table-condensed>tfoot>tr>td,.table-condensed>tfoot>tr>th,.table-condensed>thead>tr>td,.table-condensed>thead>tr>th{padding:5px}.table-bordered{border:1px solid #ddd}.table-bordered>tbody>tr>td,.table-bordered>tbody>tr>th,.table-bordered>tfoot>tr>td,.table-bordered>tfoot>tr>th,.table-bordered>thead>tr>td,.table-bordered>thead>tr>th{border:1px solid #ddd}.table-bordered>thead>tr>td,.table-bordered>thead>tr>th{border-bottom-width:2px}.table-striped>tbody>tr:nth-of-type(odd){background-color:#f9f9f9}.table-hover>tbody>tr:hover{background-color:#f5f5f5}table col[class*=col-]{position:static;display:table-column;float:none}table td[class*=col-],table th[class*=col-]{position:static;display:table-cell;float:none}.table>tbody>tr.active>td,.table>tbody>tr.active>th,.table>tbody>tr>td.active,.table>tbody>tr>th.active,.table>tfoot>tr.active>td,.table>tfoot>tr.active>th,.table>tfoot>tr>td.active,.table>tfoot>tr>th.active,.table>thead>tr.active>td,.table>thead>tr.active>th,.table>thead>tr>td.active,.table>thead>tr>th.active{background-color:#f5f5f5}.table-hover>tbody>tr.active:hover>td,.table-hover>tbody>tr.active:hover>th,.table-hover>tbody>tr:hover>.active,.table-hover>tbody>tr>td.active:hover,.table-hover>tbody>tr>th.active:hover{background-color:#e8e8e8}.table>tbody>tr.success>td,.table>tbody>tr.success>th,.table>tbody>tr>td.success,.table>tbody>tr>th.success,.table>tfoot>tr.success>td,.table>tfoot>tr.success>th,.table>tfoot>tr>td.success,.table>tfoot>tr>th.success,.table>thead>tr.success>td,.table>thead>tr.success>th,.table>thead>tr>td.success,.table>thead>tr>th.success{background-color:#dff0d8}.table-hover>tbody>tr.success:hover>td,.table-hover>tbody>tr.success:hover>th,.table-hover>tbody>tr:hover>.success,.table-hover>tbody>tr>td.success:hover,.table-hover>tbody>tr>th.success:hover{background-color:#d0e9c6}.table>tbody>tr.info>td,.table>tbody>tr.info>th,.table>tbody>tr>td.info,.table>tbody>tr>th.info,.table>tfoot>tr.info>td,.table>tfoot>tr.info>th,.table>tfoot>tr>td.info,.table>tfoot>tr>th.info,.table>thead>tr.info>td,.table>thead>tr.info>th,.table>thead>tr>td.info,.table>thead>tr>th.info{background-color:#d9edf7}.table-hover>tbody>tr.info:hover>td,.table-hover>tbody>tr.info:hover>th,.table-hover>tbody>tr:hover>.info,.table-hover>tbody>tr>td.info:hover,.table-hover>tbody>tr>th.info:hover{background-color:#c4e3f3}.table>tbody>tr.warning>td,.table>tbody>tr.warning>th,.table>tbody>tr>td.warning,.table>tbody>tr>th.warning,.table>tfoot>tr.warning>td,.table>tfoot>tr.warning>th,.table>tfoot>tr>td.warning,.table>tfoot>tr>th.warning,.table>thead>tr.warning>td,.table>thead>tr.warning>th,.table>thead>tr>td.warning,.table>thead>tr>th.warning{background-color:#fcf8e3}.table-hover>tbody>tr.warning:hover>td,.table-hover>tbody>tr.warning:hover>th,.table-hover>tbody>tr:hover>.warning,.table-hover>tbody>tr>td.warning:hover,.table-hover>tbody>tr>th.warning:hover{background-color:#faf2cc}.table>tbody>tr.danger>td,.table>tbody>tr.danger>th,.table>tbody>tr>td.danger,.table>tbody>tr>th.danger,.table>tfoot>tr.danger>td,.table>tfoot>tr.danger>th,.table>tfoot>tr>td.danger,.table>tfoot>tr>th.danger,.table>thead>tr.danger>td,.table>thead>tr.danger>th,.table>thead>tr>td.danger,.table>thead>tr>th.danger{background-color:#f2dede}.table-hover>tbody>tr.danger:hover>td,.table-hover>tbody>tr.danger:hover>th,.table-hover>tbody>tr:hover>.danger,.table-hover>tbody>tr>td.danger:hover,.table-hover>tbody>tr>th.danger:hover{background-color:#ebcccc}.table-responsive{min-height:.01%;overflow-x:auto}@media screen and (max-width:767px){.table-responsive{width:100%;margin-bottom:15px;overflow-y:hidden;-ms-overflow-style:-ms-autohiding-scrollbar;border:1px solid #ddd}.table-responsive>.table{margin-bottom:0}.table-responsive>.table>tbody>tr>td,.table-responsive>.table>tbody>tr>th,.table-responsive>.table>tfoot>tr>td,.table-responsive>.table>tfoot>tr>th,.table-responsive>.table>thead>tr>td,.table-responsive>.table>thead>tr>th{white-space:nowrap}.table-responsive>.table-bordered{border:0}.table-responsive>.table-bordered>tbody>tr>td:first-child,.table-responsive>.table-bordered>tbody>tr>th:first-child,.table-responsive>.table-bordered>tfoot>tr>td:first-child,.table-responsive>.table-bordered>tfoot>tr>th:first-child,.table-responsive>.table-bordered>thead>tr>td:first-child,.table-responsive>.table-bordered>thead>tr>th:first-child{border-left:0}.table-responsive>.table-bordered>tbody>tr>td:last-child,.table-responsive>.table-bordered>tbody>tr>th:last-child,.table-responsive>.table-bordered>tfoot>tr>td:last-child,.table-responsive>.table-bordered>tfoot>tr>th:last-child,.table-responsive>.table-bordered>thead>tr>td:last-child,.table-responsive>.table-bordered>thead>tr>th:last-child{border-right:0}.table-responsive>.table-bordered>tbody>tr:last-child>td,.table-responsive>.table-bordered>tbody>tr:last-child>th,.table-responsive>.table-bordered>tfoot>tr:last-child>td,.table-responsive>.table-bordered>tfoot>tr:last-child>th{border-bottom:0}}fieldset{min-width:0;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;max-width:100%;margin-bottom:5px;font-weight:700}input[type=search]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}input[type=checkbox],input[type=radio]{margin:4px 0 0;margin-top:1px\9;line-height:normal}input[type=file]{display:block}input[type=range]{display:block;width:100%}select[multiple],select[size]{height:auto}input[type=file]:focus,input[type=checkbox]:focus,input[type=radio]:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}output{display:block;padding-top:7px;font-size:14px;line-height:1.42857143;color:#555}.form-control{display:block;width:100%;height:34px;padding:6px 12px;font-size:14px;line-height:1.42857143;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075);-webkit-transition:border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;-o-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,.075),0 0 8px rgba(102,175,233,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}.form-control::-moz-placeholder{color:#999;opacity:1}.form-control:-ms-input-placeholder{color:#999}.form-control::-webkit-input-placeholder{color:#999}.form-control::-ms-expand{background-color:transparent;border:0}.form-control[disabled],.form-control[readonly],fieldset[disabled] .form-control{background-color:#eee;opacity:1}.form-control[disabled],fieldset[disabled] .form-control{cursor:not-allowed}textarea.form-control{height:auto}input[type=search]{-webkit-appearance:none}@media screen and (-webkit-min-device-pixel-ratio:0){input[type=date].form-control,input[type=time].form-control,input[type=datetime-local].form-control,input[type=month].form-control{line-height:34px}.input-group-sm input[type=date],.input-group-sm input[type=time],.input-group-sm input[type=datetime-local],.input-group-sm input[type=month],input[type=date].input-sm,input[type=time].input-sm,input[type=datetime-local].input-sm,input[type=month].input-sm{line-height:30px}.input-group-lg input[type=date],.input-group-lg input[type=time],.input-group-lg input[type=datetime-local],.input-group-lg input[type=month],input[type=date].input-lg,input[type=time].input-lg,input[type=datetime-local].input-lg,input[type=month].input-lg{line-height:46px}}.form-group{margin-bottom:15px}.checkbox,.radio{position:relative;display:block;margin-top:10px;margin-bottom:10px}.checkbox label,.radio label{min-height:20px;padding-left:20px;margin-bottom:0;font-weight:400;cursor:pointer}.checkbox input[type=checkbox],.checkbox-inline input[type=checkbox],.radio input[type=radio],.radio-inline input[type=radio]{position:absolute;margin-top:4px\9;margin-left:-20px}.checkbox+.checkbox,.radio+.radio{margin-top:-5px}.checkbox-inline,.radio-inline{position:relative;display:inline-block;padding-left:20px;margin-bottom:0;font-weight:400;vertical-align:middle;cursor:pointer}.checkbox-inline+.checkbox-inline,.radio-inline+.radio-inline{margin-top:0;margin-left:10px}fieldset[disabled] input[type=checkbox],fieldset[disabled] input[type=radio],input[type=checkbox].disabled,input[type=checkbox][disabled],input[type=radio].disabled,input[type=radio][disabled]{cursor:not-allowed}.checkbox-inline.disabled,.radio-inline.disabled,fieldset[disabled] .checkbox-inline,fieldset[disabled] .radio-inline{cursor:not-allowed}.checkbox.disabled label,.radio.disabled label,fieldset[disabled] .checkbox label,fieldset[disabled] .radio label{cursor:not-allowed}.form-control-static{min-height:34px;padding-top:7px;padding-bottom:7px;margin-bottom:0}.form-control-static.input-lg,.form-control-static.input-sm{padding-right:0;padding-left:0}.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}select[multiple].input-sm,textarea.input-sm{height:auto}.form-group-sm .form-control{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.form-group-sm select.form-control{height:30px;line-height:30px}.form-group-sm select[multiple].form-control,.form-group-sm textarea.form-control{height:auto}.form-group-sm .form-control-static{height:30px;min-height:32px;padding:6px 10px;font-size:12px;line-height:1.5}.input-lg{height:46px;padding:10px 16px;font-size:18px;line-height:1.3333333;border-radius:6px}select.input-lg{height:46px;line-height:46px}select[multiple].input-lg,textarea.input-lg{height:auto}.form-group-lg .form-control{height:46px;padding:10px 16px;font-size:18px;line-height:1.3333333;border-radius:6px}.form-group-lg select.form-control{height:46px;line-height:46px}.form-group-lg select[multiple].form-control,.form-group-lg textarea.form-control{height:auto}.form-group-lg .form-control-static{height:46px;min-height:38px;padding:11px 16px;font-size:18px;line-height:1.3333333}.has-feedback{position:relative}.has-feedback .form-control{padding-right:42.5px}.form-control-feedback{position:absolute;top:0;right:0;z-index:2;display:block;width:34px;height:34px;line-height:34px;text-align:center;pointer-events:none}.form-group-lg .form-control+.form-control-feedback,.input-group-lg+.form-control-feedback,.input-lg+.form-control-feedback{width:46px;height:46px;line-height:46px}.form-group-sm .form-control+.form-control-feedback,.input-group-sm+.form-control-feedback,.input-sm+.form-control-feedback{width:30px;height:30px;line-height:30px}.has-success .checkbox,.has-success .checkbox-inline,.has-success .control-label,.has-success .help-block,.has-success .radio,.has-success .radio-inline,.has-success.checkbox label,.has-success.checkbox-inline label,.has-success.radio label,.has-success.radio-inline label{color:#3c763d}.has-success .form-control{border-color:#3c763d;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075)}.has-success .form-control:focus{border-color:#2b542c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #67b168;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #67b168}.has-success .input-group-addon{color:#3c763d;background-color:#dff0d8;border-color:#3c763d}.has-success .form-control-feedback{color:#3c763d}.has-warning .checkbox,.has-warning .checkbox-inline,.has-warning .control-label,.has-warning .help-block,.has-warning .radio,.has-warning .radio-inline,.has-warning.checkbox label,.has-warning.checkbox-inline label,.has-warning.radio label,.has-warning.radio-inline label{color:#8a6d3b}.has-warning .form-control{border-color:#8a6d3b;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075)}.has-warning .form-control:focus{border-color:#66512c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #c0a16b;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #c0a16b}.has-warning .input-group-addon{color:#8a6d3b;background-color:#fcf8e3;border-color:#8a6d3b}.has-warning .form-control-feedback{color:#8a6d3b}.has-error .checkbox,.has-error .checkbox-inline,.has-error .control-label,.has-error .help-block,.has-error .radio,.has-error .radio-inline,.has-error.checkbox label,.has-error.checkbox-inline label,.has-error.radio label,.has-error.radio-inline label{color:#a94442}.has-error .form-control{border-color:#a94442;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075)}.has-error .form-control:focus{border-color:#843534;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ce8483;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ce8483}.has-error .input-group-addon{color:#a94442;background-color:#f2dede;border-color:#a94442}.has-error .form-control-feedback{color:#a94442}.has-feedback label~.form-control-feedback{top:25px}.has-feedback label.sr-only~.form-control-feedback{top: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;width:auto;vertical-align:middle}.form-inline .form-control-static{display:inline-block}.form-inline .input-group{display:inline-table;vertical-align:middle}.form-inline .input-group .form-control,.form-inline .input-group .input-group-addon,.form-inline .input-group .input-group-btn{width:auto}.form-inline .input-group>.form-control{width:100%}.form-inline .control-label{margin-bottom:0;vertical-align:middle}.form-inline .checkbox,.form-inline .radio{display:inline-block;margin-top:0;margin-bottom:0;vertical-align:middle}.form-inline .checkbox label,.form-inline .radio label{padding-left:0}.form-inline .checkbox input[type=checkbox],.form-inline .radio input[type=radio]{position:relative;margin-left:0}.form-inline .has-feedback .form-control-feedback{top:0}}.form-horizontal .checkbox,.form-horizontal .checkbox-inline,.form-horizontal .radio,.form-horizontal .radio-inline{padding-top:7px;margin-top:0;margin-bottom:0}.form-horizontal .checkbox,.form-horizontal .radio{min-height:27px}.form-horizontal .form-group{margin-right:-15px;margin-left:-15px}@media (min-width:768px){.form-horizontal .control-label{padding-top:7px;margin-bottom:0;text-align:right}}.form-horizontal .has-feedback .form-control-feedback{right:15px}@media (min-width:768px){.form-horizontal .form-group-lg .control-label{padding-top:11px;font-size:18px}}@media (min-width:768px){.form-horizontal .form-group-sm .control-label{padding-top:6px;font-size:12px}}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-size:14px;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:4px}.btn.active.focus,.btn.active:focus,.btn.focus,.btn:active.focus,.btn:active:focus,.btn:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.focus,.btn:focus,.btn:hover{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,.125);box-shadow:inset 0 3px 5px rgba(0,0,0,.125)}.btn.disabled,.btn[disabled],fieldset[disabled] .btn{cursor:not-allowed;filter:alpha(opacity=65);-webkit-box-shadow:none;box-shadow:none;opacity:.65}a.btn.disabled,fieldset[disabled] a.btn{pointer-events:none}.btn-default{color:#333;background-color:#fff;border-color:#ccc}.btn-default.focus,.btn-default:focus{color:#333;background-color:#e6e6e6;border-color:#8c8c8c}.btn-default:hover{color:#333;background-color:#e6e6e6;border-color:#adadad}.btn-default.active,.btn-default:active,.open>.dropdown-toggle.btn-default{color:#333;background-color:#e6e6e6;border-color:#adadad}.btn-default.active.focus,.btn-default.active:focus,.btn-default.active:hover,.btn-default:active.focus,.btn-default:active:focus,.btn-default:active:hover,.open>.dropdown-toggle.btn-default.focus,.open>.dropdown-toggle.btn-default:focus,.open>.dropdown-toggle.btn-default:hover{color:#333;background-color:#d4d4d4;border-color:#8c8c8c}.btn-default.active,.btn-default:active,.open>.dropdown-toggle.btn-default{background-image:none}.btn-default.disabled.focus,.btn-default.disabled:focus,.btn-default.disabled:hover,.btn-default[disabled].focus,.btn-default[disabled]:focus,.btn-default[disabled]:hover,fieldset[disabled] .btn-default.focus,fieldset[disabled] .btn-default:focus,fieldset[disabled] .btn-default:hover{background-color:#fff;border-color:#ccc}.btn-default .badge{color:#fff;background-color:#333}.btn-primary{color:#fff;background-color:#337ab7;border-color:#2e6da4}.btn-primary.focus,.btn-primary:focus{color:#fff;background-color:#286090;border-color:#122b40}.btn-primary:hover{color:#fff;background-color:#286090;border-color:#204d74}.btn-primary.active,.btn-primary:active,.open>.dropdown-toggle.btn-primary{color:#fff;background-color:#286090;border-color:#204d74}.btn-primary.active.focus,.btn-primary.active:focus,.btn-primary.active:hover,.btn-primary:active.focus,.btn-primary:active:focus,.btn-primary:active:hover,.open>.dropdown-toggle.btn-primary.focus,.open>.dropdown-toggle.btn-primary:focus,.open>.dropdown-toggle.btn-primary:hover{color:#fff;background-color:#204d74;border-color:#122b40}.btn-primary.active,.btn-primary:active,.open>.dropdown-toggle.btn-primary{background-image:none}.btn-primary.disabled.focus,.btn-primary.disabled:focus,.btn-primary.disabled:hover,.btn-primary[disabled].focus,.btn-primary[disabled]:focus,.btn-primary[disabled]:hover,fieldset[disabled] .btn-primary.focus,fieldset[disabled] .btn-primary:focus,fieldset[disabled] .btn-primary:hover{background-color:#337ab7;border-color:#2e6da4}.btn-primary .badge{color:#337ab7;background-color:#fff}.btn-success{color:#fff;background-color:#5cb85c;border-color:#4cae4c}.btn-success.focus,.btn-success:focus{color:#fff;background-color:#449d44;border-color:#255625}.btn-success:hover{color:#fff;background-color:#449d44;border-color:#398439}.btn-success.active,.btn-success:active,.open>.dropdown-toggle.btn-success{color:#fff;background-color:#449d44;border-color:#398439}.btn-success.active.focus,.btn-success.active:focus,.btn-success.active:hover,.btn-success:active.focus,.btn-success:active:focus,.btn-success:active:hover,.open>.dropdown-toggle.btn-success.focus,.open>.dropdown-toggle.btn-success:focus,.open>.dropdown-toggle.btn-success:hover{color:#fff;background-color:#398439;border-color:#255625}.btn-success.active,.btn-success:active,.open>.dropdown-toggle.btn-success{background-image:none}.btn-success.disabled.focus,.btn-success.disabled:focus,.btn-success.disabled:hover,.btn-success[disabled].focus,.btn-success[disabled]:focus,.btn-success[disabled]:hover,fieldset[disabled] .btn-success.focus,fieldset[disabled] .btn-success:focus,fieldset[disabled] .btn-success:hover{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.focus,.btn-info:focus{color:#fff;background-color:#31b0d5;border-color:#1b6d85}.btn-info:hover{color:#fff;background-color:#31b0d5;border-color:#269abc}.btn-info.active,.btn-info:active,.open>.dropdown-toggle.btn-info{color:#fff;background-color:#31b0d5;border-color:#269abc}.btn-info.active.focus,.btn-info.active:focus,.btn-info.active:hover,.btn-info:active.focus,.btn-info:active:focus,.btn-info:active:hover,.open>.dropdown-toggle.btn-info.focus,.open>.dropdown-toggle.btn-info:focus,.open>.dropdown-toggle.btn-info:hover{color:#fff;background-color:#269abc;border-color:#1b6d85}.btn-info.active,.btn-info:active,.open>.dropdown-toggle.btn-info{background-image:none}.btn-info.disabled.focus,.btn-info.disabled:focus,.btn-info.disabled:hover,.btn-info[disabled].focus,.btn-info[disabled]:focus,.btn-info[disabled]:hover,fieldset[disabled] .btn-info.focus,fieldset[disabled] .btn-info:focus,fieldset[disabled] .btn-info:hover{background-color:#5bc0de;border-color:#46b8da}.btn-info .badge{color:#5bc0de;background-color:#fff}.btn-warning{color:#fff;background-color:#f0ad4e;border-color:#eea236}.btn-warning.focus,.btn-warning:focus{color:#fff;background-color:#ec971f;border-color:#985f0d}.btn-warning:hover{color:#fff;background-color:#ec971f;border-color:#d58512}.btn-warning.active,.btn-warning:active,.open>.dropdown-toggle.btn-warning{color:#fff;background-color:#ec971f;border-color:#d58512}.btn-warning.active.focus,.btn-warning.active:focus,.btn-warning.active:hover,.btn-warning:active.focus,.btn-warning:active:focus,.btn-warning:active:hover,.open>.dropdown-toggle.btn-warning.focus,.open>.dropdown-toggle.btn-warning:focus,.open>.dropdown-toggle.btn-warning:hover{color:#fff;background-color:#d58512;border-color:#985f0d}.btn-warning.active,.btn-warning:active,.open>.dropdown-toggle.btn-warning{background-image:none}.btn-warning.disabled.focus,.btn-warning.disabled:focus,.btn-warning.disabled:hover,.btn-warning[disabled].focus,.btn-warning[disabled]:focus,.btn-warning[disabled]:hover,fieldset[disabled] .btn-warning.focus,fieldset[disabled] .btn-warning:focus,fieldset[disabled] .btn-warning:hover{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.focus,.btn-danger:focus{color:#fff;background-color:#c9302c;border-color:#761c19}.btn-danger:hover{color:#fff;background-color:#c9302c;border-color:#ac2925}.btn-danger.active,.btn-danger:active,.open>.dropdown-toggle.btn-danger{color:#fff;background-color:#c9302c;border-color:#ac2925}.btn-danger.active.focus,.btn-danger.active:focus,.btn-danger.active:hover,.btn-danger:active.focus,.btn-danger:active:focus,.btn-danger:active:hover,.open>.dropdown-toggle.btn-danger.focus,.open>.dropdown-toggle.btn-danger:focus,.open>.dropdown-toggle.btn-danger:hover{color:#fff;background-color:#ac2925;border-color:#761c19}.btn-danger.active,.btn-danger:active,.open>.dropdown-toggle.btn-danger{background-image:none}.btn-danger.disabled.focus,.btn-danger.disabled:focus,.btn-danger.disabled:hover,.btn-danger[disabled].focus,.btn-danger[disabled]:focus,.btn-danger[disabled]:hover,fieldset[disabled] .btn-danger.focus,fieldset[disabled] .btn-danger:focus,fieldset[disabled] .btn-danger:hover{background-color:#d9534f;border-color:#d43f3a}.btn-danger .badge{color:#d9534f;background-color:#fff}.btn-link{font-weight:400;color:#337ab7;border-radius:0}.btn-link,.btn-link.active,.btn-link:active,.btn-link[disabled],fieldset[disabled] .btn-link{background-color:transparent;-webkit-box-shadow:none;box-shadow:none}.btn-link,.btn-link:active,.btn-link:focus,.btn-link:hover{border-color:transparent}.btn-link:focus,.btn-link:hover{color:#23527c;text-decoration:underline;background-color:transparent}.btn-link[disabled]:focus,.btn-link[disabled]:hover,fieldset[disabled] .btn-link:focus,fieldset[disabled] .btn-link:hover{color:#777;text-decoration:none}.btn-group-lg>.btn,.btn-lg{padding:10px 16px;font-size:18px;line-height:1.3333333;border-radius:6px}.btn-group-sm>.btn,.btn-sm{padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.btn-group-xs>.btn,.btn-xs{padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.btn-block{display:block;width:100%}.btn-block+.btn-block{margin-top:5px}input[type=button].btn-block,input[type=reset].btn-block,input[type=submit].btn-block{width:100%}.fade{opacity:0;-webkit-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{display:none}.collapse.in{display:block}tr.collapse.in{display:table-row}tbody.collapse.in{display:table-row-group}.collapsing{position:relative;height:0;overflow:hidden;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease;-webkit-transition-duration:.35s;-o-transition-duration:.35s;transition-duration:.35s;-webkit-transition-property:height,visibility;-o-transition-property:height,visibility;transition-property:height,visibility}.caret{display:inline-block;width:0;height:0;margin-left:2px;vertical-align:middle;border-top:4px dashed;border-top:4px solid\9;border-right:4px solid transparent;border-left:4px solid transparent}.dropdown,.dropup{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;text-align:left;list-style:none;background-color:#fff;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #ccc;border:1px solid rgba(0,0,0,.15);border-radius:4px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,.175);box-shadow:0 6px 12px rgba(0,0,0,.175)}.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:400;line-height:1.42857143;color:#333;white-space:nowrap}.dropdown-menu>li>a:focus,.dropdown-menu>li>a:hover{color:#262626;text-decoration:none;background-color:#f5f5f5}.dropdown-menu>.active>a,.dropdown-menu>.active>a:focus,.dropdown-menu>.active>a:hover{color:#fff;text-decoration:none;background-color:#337ab7;outline:0}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:focus,.dropdown-menu>.disabled>a:hover{color:#777}.dropdown-menu>.disabled>a:focus,.dropdown-menu>.disabled>a:hover{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-menu-right{right:0;left:auto}.dropdown-menu-left{right:auto;left:0}.dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.42857143;color:#777;white-space:nowrap}.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{content:"";border-top:0;border-bottom:4px dashed;border-bottom:4px solid\9}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:2px}@media (min-width:768px){.navbar-right .dropdown-menu{right:0;left:auto}.navbar-right .dropdown-menu-left{right:auto;left:0}}.btn-group,.btn-group-vertical{position:relative;display:inline-block;vertical-align:middle}.btn-group-vertical>.btn,.btn-group>.btn{position:relative;float:left}.btn-group-vertical>.btn.active,.btn-group-vertical>.btn:active,.btn-group-vertical>.btn:focus,.btn-group-vertical>.btn:hover,.btn-group>.btn.active,.btn-group>.btn:active,.btn-group>.btn:focus,.btn-group>.btn:hover{z-index:2}.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{margin-left:-5px}.btn-toolbar .btn,.btn-toolbar .btn-group,.btn-toolbar .input-group{float:left}.btn-toolbar>.btn,.btn-toolbar>.btn-group,.btn-toolbar>.input-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-top-left-radius:0;border-bottom-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:not(:last-child)>.btn:last-child,.btn-group>.btn-group:first-child:not(:last-child)>.dropdown-toggle{border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn-group:last-child:not(:first-child)>.btn:first-child{border-top-left-radius:0;border-bottom-left-radius:0}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.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,.125);box-shadow:inset 0 3px 5px rgba(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>.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-left-radius:4px;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-left-radius:0;border-top-right-radius:0;border-bottom-right-radius:4px;border-bottom-left-radius:4px}.btn-group-vertical>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group-vertical>.btn-group:first-child:not(:last-child)>.btn:last-child,.btn-group-vertical>.btn-group:first-child:not(:last-child)>.dropdown-toggle{border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn-group:last-child:not(:first-child)>.btn:first-child{border-top-left-radius:0;border-top-right-radius:0}.btn-group-justified{display:table;width:100%;table-layout:fixed;border-collapse:separate}.btn-group-justified>.btn,.btn-group-justified>.btn-group{display:table-cell;float:none;width:1%}.btn-group-justified>.btn-group .btn{width:100%}.btn-group-justified>.btn-group .dropdown-menu{left:auto}[data-toggle=buttons]>.btn input[type=checkbox],[data-toggle=buttons]>.btn input[type=radio],[data-toggle=buttons]>.btn-group>.btn input[type=checkbox],[data-toggle=buttons]>.btn-group>.btn input[type=radio]{position:absolute;clip:rect(0,0,0,0);pointer-events: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{position:relative;z-index:2;float:left;width:100%;margin-bottom:0}.input-group .form-control:focus{z-index:3}.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.3333333;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}select[multiple].input-group-lg>.form-control,select[multiple].input-group-lg>.input-group-addon,select[multiple].input-group-lg>.input-group-btn>.btn,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}select[multiple].input-group-sm>.form-control,select[multiple].input-group-sm>.input-group-addon,select[multiple].input-group-sm>.input-group-btn>.btn,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 .form-control,.input-group-addon,.input-group-btn{display:table-cell}.input-group .form-control:not(:first-child):not(:last-child),.input-group-addon:not(:first-child):not(:last-child),.input-group-btn: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:400;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=checkbox],.input-group-addon input[type=radio]{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>.btn-group>.btn,.input-group-btn:first-child>.dropdown-toggle,.input-group-btn:last-child>.btn-group:not(:last-child)>.btn,.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:first-child>.btn-group:not(:first-child)>.btn,.input-group-btn:first-child>.btn:not(:first-child),.input-group-btn:last-child>.btn,.input-group-btn:last-child>.btn-group>.btn,.input-group-btn:last-child>.dropdown-toggle{border-top-left-radius:0;border-bottom-left-radius:0}.input-group-addon:last-child{border-left:0}.input-group-btn{position:relative;font-size:0;white-space:nowrap}.input-group-btn>.btn{position:relative}.input-group-btn>.btn+.btn{margin-left:-1px}.input-group-btn>.btn:active,.input-group-btn>.btn:focus,.input-group-btn>.btn:hover{z-index:2}.input-group-btn:first-child>.btn,.input-group-btn:first-child>.btn-group{margin-right:-1px}.input-group-btn:last-child>.btn,.input-group-btn:last-child>.btn-group{z-index:2;margin-left:-1px}.nav{padding-left:0;margin-bottom:0;list-style:none}.nav>li{position:relative;display:block}.nav>li>a{position:relative;display:block;padding:10px 15px}.nav>li>a:focus,.nav>li>a:hover{text-decoration:none;background-color:#eee}.nav>li.disabled>a{color:#777}.nav>li.disabled>a:focus,.nav>li.disabled>a:hover{color:#777;text-decoration:none;cursor:not-allowed;background-color:transparent}.nav .open>a,.nav .open>a:focus,.nav .open>a:hover{background-color:#eee;border-color:#337ab7}.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.42857143;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:focus,.nav-tabs>li.active>a:hover{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:focus,.nav-tabs.nav-justified>.active>a:hover{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:focus,.nav-tabs.nav-justified>.active>a:hover{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:focus,.nav-pills>li.active>a:hover{color:#fff;background-color:#337ab7}.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:focus,.nav-tabs-justified>.active>a:hover{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:focus,.nav-tabs-justified>.active>a:hover{border-bottom-color:#fff}}.tab-content>.tab-pane{display:none}.tab-content>.active{display:block}.nav-tabs .dropdown-menu{margin-top:-1px;border-top-left-radius:0;border-top-right-radius:0}.navbar{position:relative;min-height:50px;margin-bottom:20px;border:1px solid transparent}@media (min-width:768px){.navbar{border-radius:4px}}@media (min-width:768px){.navbar-header{float:left}}.navbar-collapse{padding-right:15px;padding-left:15px;overflow-x:visible;-webkit-overflow-scrolling:touch;border-top:1px solid transparent;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.1);box-shadow:inset 0 1px 0 rgba(255,255,255,.1)}.navbar-collapse.in{overflow-y:auto}@media (min-width:768px){.navbar-collapse{width:auto;border-top:0;-webkit-box-shadow:none;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-bottom .navbar-collapse,.navbar-fixed-top .navbar-collapse,.navbar-static-top .navbar-collapse{padding-right:0;padding-left:0}}.navbar-fixed-bottom .navbar-collapse,.navbar-fixed-top .navbar-collapse{max-height:340px}@media (max-device-width:480px) and (orientation:landscape){.navbar-fixed-bottom .navbar-collapse,.navbar-fixed-top .navbar-collapse{max-height:200px}}.container-fluid>.navbar-collapse,.container-fluid>.navbar-header,.container>.navbar-collapse,.container>.navbar-header{margin-right:-15px;margin-left:-15px}@media (min-width:768px){.container-fluid>.navbar-collapse,.container-fluid>.navbar-header,.container>.navbar-collapse,.container>.navbar-header{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-bottom,.navbar-fixed-top{position:fixed;right:0;left:0;z-index:1030}@media (min-width:768px){.navbar-fixed-bottom,.navbar-fixed-top{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;height:50px;padding:15px 15px;font-size:18px;line-height:20px}.navbar-brand:focus,.navbar-brand:hover{text-decoration:none}.navbar-brand>img{display:block}@media (min-width:768px){.navbar>.container .navbar-brand,.navbar>.container-fluid .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:focus{outline:0}.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;-webkit-box-shadow:none;box-shadow:none}.navbar-nav .open .dropdown-menu .dropdown-header,.navbar-nav .open .dropdown-menu>li>a{padding:5px 15px 5px 25px}.navbar-nav .open .dropdown-menu>li>a{line-height:20px}.navbar-nav .open .dropdown-menu>li>a:focus,.navbar-nav .open .dropdown-menu>li>a:hover{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-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,.1),0 1px 0 rgba(255,255,255,.1);box-shadow:inset 0 1px 0 rgba(255,255,255,.1),0 1px 0 rgba(255,255,255,.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;width:auto;vertical-align:middle}.navbar-form .form-control-static{display:inline-block}.navbar-form .input-group{display:inline-table;vertical-align:middle}.navbar-form .input-group .form-control,.navbar-form .input-group .input-group-addon,.navbar-form .input-group .input-group-btn{width:auto}.navbar-form .input-group>.form-control{width:100%}.navbar-form .control-label{margin-bottom:0;vertical-align:middle}.navbar-form .checkbox,.navbar-form .radio{display:inline-block;margin-top:0;margin-bottom:0;vertical-align:middle}.navbar-form .checkbox label,.navbar-form .radio label{padding-left:0}.navbar-form .checkbox input[type=checkbox],.navbar-form .radio input[type=radio]{position:relative;margin-left:0}.navbar-form .has-feedback .form-control-feedback{top:0}}@media (max-width:767px){.navbar-form .form-group{margin-bottom:5px}.navbar-form .form-group:last-child{margin-bottom:0}}@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-nav>li>.dropdown-menu{margin-top:0;border-top-left-radius:0;border-top-right-radius:0}.navbar-fixed-bottom .navbar-nav>li>.dropdown-menu{margin-bottom:0;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-right-radius:0;border-bottom-left-radius:0}.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}}@media (min-width:768px){.navbar-left{float:left!important}.navbar-right{float:right!important;margin-right:-15px}.navbar-right~.navbar-right{margin-right:0}}.navbar-default{background-color:#f8f8f8;border-color:#e7e7e7}.navbar-default .navbar-brand{color:#777}.navbar-default .navbar-brand:focus,.navbar-default .navbar-brand:hover{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:focus,.navbar-default .navbar-nav>li>a:hover{color:#333;background-color:transparent}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:focus,.navbar-default .navbar-nav>.active>a:hover{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav>.disabled>a,.navbar-default .navbar-nav>.disabled>a:focus,.navbar-default .navbar-nav>.disabled>a:hover{color:#ccc;background-color:transparent}.navbar-default .navbar-toggle{border-color:#ddd}.navbar-default .navbar-toggle:focus,.navbar-default .navbar-toggle:hover{background-color:#ddd}.navbar-default .navbar-toggle .icon-bar{background-color:#888}.navbar-default .navbar-collapse,.navbar-default .navbar-form{border-color:#e7e7e7}.navbar-default .navbar-nav>.open>a,.navbar-default .navbar-nav>.open>a:focus,.navbar-default .navbar-nav>.open>a:hover{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:focus,.navbar-default .navbar-nav .open .dropdown-menu>li>a:hover{color:#333;background-color:transparent}.navbar-default .navbar-nav .open .dropdown-menu>.active>a,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:focus,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:hover{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:focus,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:hover{color:#ccc;background-color:transparent}}.navbar-default .navbar-link{color:#777}.navbar-default .navbar-link:hover{color:#333}.navbar-default .btn-link{color:#777}.navbar-default .btn-link:focus,.navbar-default .btn-link:hover{color:#333}.navbar-default .btn-link[disabled]:focus,.navbar-default .btn-link[disabled]:hover,fieldset[disabled] .navbar-default .btn-link:focus,fieldset[disabled] .navbar-default .btn-link:hover{color:#ccc}.navbar-inverse{background-color:#222;border-color:#080808}.navbar-inverse .navbar-brand{color:#9d9d9d}.navbar-inverse .navbar-brand:focus,.navbar-inverse .navbar-brand:hover{color:#fff;background-color:transparent}.navbar-inverse .navbar-text{color:#9d9d9d}.navbar-inverse .navbar-nav>li>a{color:#9d9d9d}.navbar-inverse .navbar-nav>li>a:focus,.navbar-inverse .navbar-nav>li>a:hover{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav>.active>a,.navbar-inverse .navbar-nav>.active>a:focus,.navbar-inverse .navbar-nav>.active>a:hover{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav>.disabled>a,.navbar-inverse .navbar-nav>.disabled>a:focus,.navbar-inverse .navbar-nav>.disabled>a:hover{color:#444;background-color:transparent}.navbar-inverse .navbar-toggle{border-color:#333}.navbar-inverse .navbar-toggle:focus,.navbar-inverse .navbar-toggle:hover{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:focus,.navbar-inverse .navbar-nav>.open>a:hover{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:#9d9d9d}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:focus,.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:hover{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:focus,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:hover{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:focus,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:hover{color:#444;background-color:transparent}}.navbar-inverse .navbar-link{color:#9d9d9d}.navbar-inverse .navbar-link:hover{color:#fff}.navbar-inverse .btn-link{color:#9d9d9d}.navbar-inverse .btn-link:focus,.navbar-inverse .btn-link:hover{color:#fff}.navbar-inverse .btn-link[disabled]:focus,.navbar-inverse .btn-link[disabled]:hover,fieldset[disabled] .navbar-inverse .btn-link:focus,fieldset[disabled] .navbar-inverse .btn-link:hover{color:#444}.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:#777}.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.42857143;color:#337ab7;text-decoration:none;background-color:#fff;border:1px solid #ddd}.pagination>li:first-child>a,.pagination>li:first-child>span{margin-left:0;border-top-left-radius:4px;border-bottom-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:focus,.pagination>li>a:hover,.pagination>li>span:focus,.pagination>li>span:hover{z-index:2;color:#23527c;background-color:#eee;border-color:#ddd}.pagination>.active>a,.pagination>.active>a:focus,.pagination>.active>a:hover,.pagination>.active>span,.pagination>.active>span:focus,.pagination>.active>span:hover{z-index:3;color:#fff;cursor:default;background-color:#337ab7;border-color:#337ab7}.pagination>.disabled>a,.pagination>.disabled>a:focus,.pagination>.disabled>a:hover,.pagination>.disabled>span,.pagination>.disabled>span:focus,.pagination>.disabled>span:hover{color:#777;cursor:not-allowed;background-color:#fff;border-color:#ddd}.pagination-lg>li>a,.pagination-lg>li>span{padding:10px 16px;font-size:18px;line-height:1.3333333}.pagination-lg>li:first-child>a,.pagination-lg>li:first-child>span{border-top-left-radius:6px;border-bottom-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;line-height:1.5}.pagination-sm>li:first-child>a,.pagination-sm>li:first-child>span{border-top-left-radius:3px;border-bottom-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 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:focus,.pager li>a:hover{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:focus,.pager .disabled>a:hover,.pager .disabled>span{color:#777;cursor:not-allowed;background-color:#fff}.label{display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em}a.label:focus,a.label:hover{color:#fff;text-decoration:none;cursor:pointer}.label:empty{display:none}.btn .label{position:relative;top:-1px}.label-default{background-color:#777}.label-default[href]:focus,.label-default[href]:hover{background-color:#5e5e5e}.label-primary{background-color:#337ab7}.label-primary[href]:focus,.label-primary[href]:hover{background-color:#286090}.label-success{background-color:#5cb85c}.label-success[href]:focus,.label-success[href]:hover{background-color:#449d44}.label-info{background-color:#5bc0de}.label-info[href]:focus,.label-info[href]:hover{background-color:#31b0d5}.label-warning{background-color:#f0ad4e}.label-warning[href]:focus,.label-warning[href]:hover{background-color:#ec971f}.label-danger{background-color:#d9534f}.label-danger[href]:focus,.label-danger[href]:hover{background-color:#c9302c}.badge{display:inline-block;min-width:10px;padding:3px 7px;font-size:12px;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:middle;background-color:#777;border-radius:10px}.badge:empty{display:none}.btn .badge{position:relative;top:-1px}.btn-group-xs>.btn .badge,.btn-xs .badge{top:0;padding:1px 5px}a.badge:focus,a.badge:hover{color:#fff;text-decoration:none;cursor:pointer}.list-group-item.active>.badge,.nav-pills>.active>a>.badge{color:#337ab7;background-color:#fff}.list-group-item>.badge{float:right}.list-group-item>.badge+.badge{margin-right:5px}.nav-pills>li>a>.badge{margin-left:3px}.jumbotron{padding-top:30px;padding-bottom:30px;margin-bottom:30px;color:inherit;background-color:#eee}.jumbotron .h1,.jumbotron h1{color:inherit}.jumbotron p{margin-bottom:15px;font-size:21px;font-weight:200}.jumbotron>hr{border-top-color:#d5d5d5}.container .jumbotron,.container-fluid .jumbotron{padding-right:15px;padding-left:15px;border-radius:6px}.jumbotron .container{max-width:100%}@media screen and (min-width:768px){.jumbotron{padding-top:48px;padding-bottom:48px}.container .jumbotron,.container-fluid .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.42857143;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:border .2s ease-in-out;-o-transition:border .2s ease-in-out;transition:border .2s ease-in-out}.thumbnail a>img,.thumbnail>img{margin-right:auto;margin-left:auto}a.thumbnail.active,a.thumbnail:focus,a.thumbnail:hover{border-color:#337ab7}.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:700}.alert>p,.alert>ul{margin-bottom:0}.alert>p+p{margin-top:5px}.alert-dismissable,.alert-dismissible{padding-right:35px}.alert-dismissable .close,.alert-dismissible .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}}@-o-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,.1);box-shadow:inset 0 1px 2px rgba(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:#337ab7;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,.15);-webkit-transition:width .6s ease;-o-transition:width .6s ease;transition:width .6s ease}.progress-bar-striped,.progress-striped .progress-bar{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);-webkit-background-size:40px 40px;background-size:40px 40px}.progress-bar.active,.progress.active .progress-bar{-webkit-animation:progress-bar-stripes 2s linear infinite;-o-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,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.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,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.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,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.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,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.media{margin-top:15px}.media:first-child{margin-top:0}.media,.media-body{overflow:hidden;zoom:1}.media-body{width:10000px}.media-object{display:block}.media-object.img-thumbnail{max-width:none}.media-right,.media>.pull-right{padding-left:10px}.media-left,.media>.pull-left{padding-right:10px}.media-body,.media-left,.media-right{display:table-cell;vertical-align:top}.media-middle{vertical-align:middle}.media-bottom{vertical-align:bottom}.media-heading{margin-top:0;margin-bottom:5px}.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-left-radius:4px;border-top-right-radius:4px}.list-group-item:last-child{margin-bottom:0;border-bottom-right-radius:4px;border-bottom-left-radius:4px}a.list-group-item,button.list-group-item{color:#555}a.list-group-item .list-group-item-heading,button.list-group-item .list-group-item-heading{color:#333}a.list-group-item:focus,a.list-group-item:hover,button.list-group-item:focus,button.list-group-item:hover{color:#555;text-decoration:none;background-color:#f5f5f5}button.list-group-item{width:100%;text-align:left}.list-group-item.disabled,.list-group-item.disabled:focus,.list-group-item.disabled:hover{color:#777;cursor:not-allowed;background-color:#eee}.list-group-item.disabled .list-group-item-heading,.list-group-item.disabled:focus .list-group-item-heading,.list-group-item.disabled:hover .list-group-item-heading{color:inherit}.list-group-item.disabled .list-group-item-text,.list-group-item.disabled:focus .list-group-item-text,.list-group-item.disabled:hover .list-group-item-text{color:#777}.list-group-item.active,.list-group-item.active:focus,.list-group-item.active:hover{z-index:2;color:#fff;background-color:#337ab7;border-color:#337ab7}.list-group-item.active .list-group-item-heading,.list-group-item.active .list-group-item-heading>.small,.list-group-item.active .list-group-item-heading>small,.list-group-item.active:focus .list-group-item-heading,.list-group-item.active:focus .list-group-item-heading>.small,.list-group-item.active:focus .list-group-item-heading>small,.list-group-item.active:hover .list-group-item-heading,.list-group-item.active:hover .list-group-item-heading>.small,.list-group-item.active:hover .list-group-item-heading>small{color:inherit}.list-group-item.active .list-group-item-text,.list-group-item.active:focus .list-group-item-text,.list-group-item.active:hover .list-group-item-text{color:#c7ddef}.list-group-item-success{color:#3c763d;background-color:#dff0d8}a.list-group-item-success,button.list-group-item-success{color:#3c763d}a.list-group-item-success .list-group-item-heading,button.list-group-item-success .list-group-item-heading{color:inherit}a.list-group-item-success:focus,a.list-group-item-success:hover,button.list-group-item-success:focus,button.list-group-item-success:hover{color:#3c763d;background-color:#d0e9c6}a.list-group-item-success.active,a.list-group-item-success.active:focus,a.list-group-item-success.active:hover,button.list-group-item-success.active,button.list-group-item-success.active:focus,button.list-group-item-success.active:hover{color:#fff;background-color:#3c763d;border-color:#3c763d}.list-group-item-info{color:#31708f;background-color:#d9edf7}a.list-group-item-info,button.list-group-item-info{color:#31708f}a.list-group-item-info .list-group-item-heading,button.list-group-item-info .list-group-item-heading{color:inherit}a.list-group-item-info:focus,a.list-group-item-info:hover,button.list-group-item-info:focus,button.list-group-item-info:hover{color:#31708f;background-color:#c4e3f3}a.list-group-item-info.active,a.list-group-item-info.active:focus,a.list-group-item-info.active:hover,button.list-group-item-info.active,button.list-group-item-info.active:focus,button.list-group-item-info.active:hover{color:#fff;background-color:#31708f;border-color:#31708f}.list-group-item-warning{color:#8a6d3b;background-color:#fcf8e3}a.list-group-item-warning,button.list-group-item-warning{color:#8a6d3b}a.list-group-item-warning .list-group-item-heading,button.list-group-item-warning .list-group-item-heading{color:inherit}a.list-group-item-warning:focus,a.list-group-item-warning:hover,button.list-group-item-warning:focus,button.list-group-item-warning:hover{color:#8a6d3b;background-color:#faf2cc}a.list-group-item-warning.active,a.list-group-item-warning.active:focus,a.list-group-item-warning.active:hover,button.list-group-item-warning.active,button.list-group-item-warning.active:focus,button.list-group-item-warning.active:hover{color:#fff;background-color:#8a6d3b;border-color:#8a6d3b}.list-group-item-danger{color:#a94442;background-color:#f2dede}a.list-group-item-danger,button.list-group-item-danger{color:#a94442}a.list-group-item-danger .list-group-item-heading,button.list-group-item-danger .list-group-item-heading{color:inherit}a.list-group-item-danger:focus,a.list-group-item-danger:hover,button.list-group-item-danger:focus,button.list-group-item-danger:hover{color:#a94442;background-color:#ebcccc}a.list-group-item-danger.active,a.list-group-item-danger.active:focus,a.list-group-item-danger.active:hover,button.list-group-item-danger.active,button.list-group-item-danger.active:focus,button.list-group-item-danger.active:hover{color:#fff;background-color:#a94442;border-color:#a94442}.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,.05);box-shadow:0 1px 1px rgba(0,0,0,.05)}.panel-body{padding:15px}.panel-heading{padding:10px 15px;border-bottom:1px solid transparent;border-top-left-radius:3px;border-top-right-radius:3px}.panel-heading>.dropdown .dropdown-toggle{color:inherit}.panel-title{margin-top:0;margin-bottom:0;font-size:16px;color:inherit}.panel-title>.small,.panel-title>.small>a,.panel-title>a,.panel-title>small,.panel-title>small>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>.list-group,.panel>.panel-collapse>.list-group{margin-bottom:0}.panel>.list-group .list-group-item,.panel>.panel-collapse>.list-group .list-group-item{border-width:1px 0;border-radius:0}.panel>.list-group:first-child .list-group-item:first-child,.panel>.panel-collapse>.list-group:first-child .list-group-item:first-child{border-top:0;border-top-left-radius:3px;border-top-right-radius:3px}.panel>.list-group:last-child .list-group-item:last-child,.panel>.panel-collapse>.list-group:last-child .list-group-item:last-child{border-bottom:0;border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel>.panel-heading+.panel-collapse>.list-group .list-group-item:first-child{border-top-left-radius:0;border-top-right-radius:0}.panel-heading+.list-group .list-group-item:first-child{border-top-width:0}.list-group+.panel-footer{border-top-width:0}.panel>.panel-collapse>.table,.panel>.table,.panel>.table-responsive>.table{margin-bottom:0}.panel>.panel-collapse>.table caption,.panel>.table caption,.panel>.table-responsive>.table caption{padding-right:15px;padding-left:15px}.panel>.table-responsive:first-child>.table:first-child,.panel>.table:first-child{border-top-left-radius:3px;border-top-right-radius:3px}.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child,.panel>.table:first-child>tbody:first-child>tr:first-child,.panel>.table:first-child>thead:first-child>tr:first-child{border-top-left-radius:3px;border-top-right-radius:3px}.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child td:first-child,.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child th:first-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child td:first-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child th:first-child,.panel>.table:first-child>tbody:first-child>tr:first-child td:first-child,.panel>.table:first-child>tbody:first-child>tr:first-child th:first-child,.panel>.table:first-child>thead:first-child>tr:first-child td:first-child,.panel>.table:first-child>thead:first-child>tr:first-child th:first-child{border-top-left-radius:3px}.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child td:last-child,.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child th:last-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child td:last-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child th:last-child,.panel>.table:first-child>tbody:first-child>tr:first-child td:last-child,.panel>.table:first-child>tbody:first-child>tr:first-child th:last-child,.panel>.table:first-child>thead:first-child>tr:first-child td:last-child,.panel>.table:first-child>thead:first-child>tr:first-child th:last-child{border-top-right-radius:3px}.panel>.table-responsive:last-child>.table:last-child,.panel>.table:last-child{border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child,.panel>.table:last-child>tbody:last-child>tr:last-child,.panel>.table:last-child>tfoot:last-child>tr:last-child{border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child td:first-child,.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child th:first-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child td:first-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child th:first-child,.panel>.table:last-child>tbody:last-child>tr:last-child td:first-child,.panel>.table:last-child>tbody:last-child>tr:last-child th:first-child,.panel>.table:last-child>tfoot:last-child>tr:last-child td:first-child,.panel>.table:last-child>tfoot:last-child>tr:last-child th:first-child{border-bottom-left-radius:3px}.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child td:last-child,.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child th:last-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child td:last-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child th:last-child,.panel>.table:last-child>tbody:last-child>tr:last-child td:last-child,.panel>.table:last-child>tbody:last-child>tr:last-child th:last-child,.panel>.table:last-child>tfoot:last-child>tr:last-child td:last-child,.panel>.table:last-child>tfoot:last-child>tr:last-child th:last-child{border-bottom-right-radius:3px}.panel>.panel-body+.table,.panel>.panel-body+.table-responsive,.panel>.table+.panel-body,.panel>.table-responsive+.panel-body{border-top:1px solid #ddd}.panel>.table>tbody:first-child>tr:first-child td,.panel>.table>tbody:first-child>tr:first-child th{border-top:0}.panel>.table-bordered,.panel>.table-responsive>.table-bordered{border:0}.panel>.table-bordered>tbody>tr>td:first-child,.panel>.table-bordered>tbody>tr>th:first-child,.panel>.table-bordered>tfoot>tr>td:first-child,.panel>.table-bordered>tfoot>tr>th:first-child,.panel>.table-bordered>thead>tr>td:first-child,.panel>.table-bordered>thead>tr>th:first-child,.panel>.table-responsive>.table-bordered>tbody>tr>td:first-child,.panel>.table-responsive>.table-bordered>tbody>tr>th:first-child,.panel>.table-responsive>.table-bordered>tfoot>tr>td:first-child,.panel>.table-responsive>.table-bordered>tfoot>tr>th:first-child,.panel>.table-responsive>.table-bordered>thead>tr>td:first-child,.panel>.table-responsive>.table-bordered>thead>tr>th:first-child{border-left:0}.panel>.table-bordered>tbody>tr>td:last-child,.panel>.table-bordered>tbody>tr>th:last-child,.panel>.table-bordered>tfoot>tr>td:last-child,.panel>.table-bordered>tfoot>tr>th:last-child,.panel>.table-bordered>thead>tr>td:last-child,.panel>.table-bordered>thead>tr>th:last-child,.panel>.table-responsive>.table-bordered>tbody>tr>td:last-child,.panel>.table-responsive>.table-bordered>tbody>tr>th:last-child,.panel>.table-responsive>.table-bordered>tfoot>tr>td:last-child,.panel>.table-responsive>.table-bordered>tfoot>tr>th:last-child,.panel>.table-responsive>.table-bordered>thead>tr>td:last-child,.panel>.table-responsive>.table-bordered>thead>tr>th:last-child{border-right:0}.panel>.table-bordered>tbody>tr:first-child>td,.panel>.table-bordered>tbody>tr:first-child>th,.panel>.table-bordered>thead>tr:first-child>td,.panel>.table-bordered>thead>tr:first-child>th,.panel>.table-responsive>.table-bordered>tbody>tr:first-child>td,.panel>.table-responsive>.table-bordered>tbody>tr:first-child>th,.panel>.table-responsive>.table-bordered>thead>tr:first-child>td,.panel>.table-responsive>.table-bordered>thead>tr:first-child>th{border-bottom:0}.panel>.table-bordered>tbody>tr:last-child>td,.panel>.table-bordered>tbody>tr:last-child>th,.panel>.table-bordered>tfoot>tr:last-child>td,.panel>.table-bordered>tfoot>tr:last-child>th,.panel>.table-responsive>.table-bordered>tbody>tr:last-child>td,.panel>.table-responsive>.table-bordered>tbody>tr:last-child>th,.panel>.table-responsive>.table-bordered>tfoot>tr:last-child>td,.panel>.table-responsive>.table-bordered>tfoot>tr:last-child>th{border-bottom:0}.panel>.table-responsive{margin-bottom:0;border:0}.panel-group{margin-bottom:20px}.panel-group .panel{margin-bottom:0;border-radius:4px}.panel-group .panel+.panel{margin-top:5px}.panel-group .panel-heading{border-bottom:0}.panel-group .panel-heading+.panel-collapse>.list-group,.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-heading .badge{color:#f5f5f5;background-color:#333}.panel-default>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#ddd}.panel-primary{border-color:#337ab7}.panel-primary>.panel-heading{color:#fff;background-color:#337ab7;border-color:#337ab7}.panel-primary>.panel-heading+.panel-collapse>.panel-body{border-top-color:#337ab7}.panel-primary>.panel-heading .badge{color:#337ab7;background-color:#fff}.panel-primary>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#337ab7}.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-heading .badge{color:#dff0d8;background-color:#3c763d}.panel-success>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#d6e9c6}.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-heading .badge{color:#d9edf7;background-color:#31708f}.panel-info>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#bce8f1}.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-heading .badge{color:#fcf8e3;background-color:#8a6d3b}.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-heading .badge{color:#f2dede;background-color:#a94442}.panel-danger>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#ebccd1}.embed-responsive{position:relative;display:block;height:0;padding:0;overflow:hidden}.embed-responsive .embed-responsive-item,.embed-responsive embed,.embed-responsive iframe,.embed-responsive object,.embed-responsive video{position:absolute;top:0;bottom:0;left:0;width:100%;height:100%;border:0}.embed-responsive-16by9{padding-bottom:56.25%}.embed-responsive-4by3{padding-bottom:75%}.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,.05);box-shadow:inset 0 1px 1px rgba(0,0,0,.05)}.well blockquote{border-color:#ddd;border-color:rgba(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:700;line-height:1;color:#000;text-shadow:0 1px 0 #fff;filter:alpha(opacity=20);opacity:.2}.close:focus,.close:hover{color:#000;text-decoration:none;cursor:pointer;filter:alpha(opacity=50);opacity:.5}button.close{-webkit-appearance:none;padding:0;cursor:pointer;background:0 0;border:0}.modal-open{overflow:hidden}.modal{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1050;display:none;overflow:hidden;-webkit-overflow-scrolling:touch;outline:0}.modal.fade .modal-dialog{-webkit-transition:-webkit-transform .3s ease-out;-o-transition:-o-transform .3s ease-out;transition:transform .3s ease-out;-webkit-transform:translate(0,-25%);-ms-transform:translate(0,-25%);-o-transform:translate(0,-25%);transform:translate(0,-25%)}.modal.in .modal-dialog{-webkit-transform:translate(0,0);-ms-transform:translate(0,0);-o-transform:translate(0,0);transform:translate(0,0)}.modal-open .modal{overflow-x:hidden;overflow-y:auto}.modal-dialog{position:relative;width:auto;margin:10px}.modal-content{position:relative;background-color:#fff;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #999;border:1px solid rgba(0,0,0,.2);border-radius:6px;outline:0;-webkit-box-shadow:0 3px 9px rgba(0,0,0,.5);box-shadow:0 3px 9px rgba(0,0,0,.5)}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000}.modal-backdrop.fade{filter:alpha(opacity=0);opacity:0}.modal-backdrop.in{filter:alpha(opacity=50);opacity:.5}.modal-header{padding:15px;border-bottom:1px solid #e5e5e5}.modal-header .close{margin-top:-2px}.modal-title{margin:0;line-height:1.42857143}.modal-body{position:relative;padding:15px}.modal-footer{padding:15px;text-align:right;border-top:1px solid #e5e5e5}.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}.modal-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}@media (min-width:768px){.modal-dialog{width:600px;margin:30px auto}.modal-content{-webkit-box-shadow:0 5px 15px rgba(0,0,0,.5);box-shadow:0 5px 15px rgba(0,0,0,.5)}.modal-sm{width:300px}}@media (min-width:992px){.modal-lg{width:900px}}.tooltip{position:absolute;z-index:1070;display:block;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:12px;font-style:normal;font-weight:400;line-height:1.42857143;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;letter-spacing:normal;word-break:normal;word-spacing:normal;word-wrap:normal;white-space:normal;filter:alpha(opacity=0);opacity:0;line-break:auto}.tooltip.in{filter:alpha(opacity=90);opacity:.9}.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;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-width:5px 5px 0;border-top-color:#000}.tooltip.top-left .tooltip-arrow{right:5px;bottom:0;margin-bottom:-5px;border-width:5px 5px 0;border-top-color:#000}.tooltip.top-right .tooltip-arrow{bottom:0;left:5px;margin-bottom:-5px;border-width:5px 5px 0;border-top-color:#000}.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-width:5px 5px 5px 0;border-right-color:#000}.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-width:5px 0 5px 5px;border-left-color:#000}.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-width:0 5px 5px;border-bottom-color:#000}.tooltip.bottom-left .tooltip-arrow{top:0;right:5px;margin-top:-5px;border-width:0 5px 5px;border-bottom-color:#000}.tooltip.bottom-right .tooltip-arrow{top:0;left:5px;margin-top:-5px;border-width:0 5px 5px;border-bottom-color:#000}.popover{position:absolute;top:0;left:0;z-index:1060;display:none;max-width:276px;padding:1px;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;line-height:1.42857143;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;letter-spacing:normal;word-break:normal;word-spacing:normal;word-wrap:normal;white-space:normal;background-color:#fff;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #ccc;border:1px solid rgba(0,0,0,.2);border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,.2);box-shadow:0 5px 10px rgba(0,0,0,.2);line-break:auto}.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;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{content:"";border-width:10px}.popover.top>.arrow{bottom:-11px;left:50%;margin-left:-11px;border-top-color:#999;border-top-color:rgba(0,0,0,.25);border-bottom-width:0}.popover.top>.arrow:after{bottom:1px;margin-left:-10px;content:" ";border-top-color:#fff;border-bottom-width:0}.popover.right>.arrow{top:50%;left:-11px;margin-top:-11px;border-right-color:#999;border-right-color:rgba(0,0,0,.25);border-left-width:0}.popover.right>.arrow:after{bottom:-10px;left:1px;content:" ";border-right-color:#fff;border-left-width:0}.popover.bottom>.arrow{top:-11px;left:50%;margin-left:-11px;border-top-width:0;border-bottom-color:#999;border-bottom-color:rgba(0,0,0,.25)}.popover.bottom>.arrow:after{top:1px;margin-left:-10px;content:" ";border-top-width:0;border-bottom-color:#fff}.popover.left>.arrow{top:50%;right:-11px;margin-top:-11px;border-right-width:0;border-left-color:#999;border-left-color:rgba(0,0,0,.25)}.popover.left>.arrow:after{right:1px;bottom:-10px;content:" ";border-right-width:0;border-left-color:#fff}.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;-o-transition:.6s ease-in-out left;transition:.6s ease-in-out left}.carousel-inner>.item>a>img,.carousel-inner>.item>img{line-height:1}@media all and (transform-3d),(-webkit-transform-3d){.carousel-inner>.item{-webkit-transition:-webkit-transform .6s ease-in-out;-o-transition:-o-transform .6s ease-in-out;transition:transform .6s ease-in-out;-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-perspective:1000px;perspective:1000px}.carousel-inner>.item.active.right,.carousel-inner>.item.next{left:0;-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0)}.carousel-inner>.item.active.left,.carousel-inner>.item.prev{left:0;-webkit-transform:translate3d(-100%,0,0);transform:translate3d(-100%,0,0)}.carousel-inner>.item.active,.carousel-inner>.item.next.left,.carousel-inner>.item.prev.right{left:0;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}}.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,.6);background-color:rgba(0,0,0,0);filter:alpha(opacity=50);opacity:.5}.carousel-control.left{background-image:-webkit-linear-gradient(left,rgba(0,0,0,.5) 0,rgba(0,0,0,.0001) 100%);background-image:-o-linear-gradient(left,rgba(0,0,0,.5) 0,rgba(0,0,0,.0001) 100%);background-image:-webkit-gradient(linear,left top,right top,from(rgba(0,0,0,.5)),to(rgba(0,0,0,.0001)));background-image:linear-gradient(to right,rgba(0,0,0,.5) 0,rgba(0,0,0,.0001) 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00000000', GradientType=1);background-repeat:repeat-x}.carousel-control.right{right:0;left:auto;background-image:-webkit-linear-gradient(left,rgba(0,0,0,.0001) 0,rgba(0,0,0,.5) 100%);background-image:-o-linear-gradient(left,rgba(0,0,0,.0001) 0,rgba(0,0,0,.5) 100%);background-image:-webkit-gradient(linear,left top,right top,from(rgba(0,0,0,.0001)),to(rgba(0,0,0,.5)));background-image:linear-gradient(to right,rgba(0,0,0,.0001) 0,rgba(0,0,0,.5) 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#80000000', GradientType=1);background-repeat:repeat-x}.carousel-control:focus,.carousel-control:hover{color:#fff;text-decoration:none;filter:alpha(opacity=90);outline:0;opacity:.9}.carousel-control .glyphicon-chevron-left,.carousel-control .glyphicon-chevron-right,.carousel-control .icon-next,.carousel-control .icon-prev{position:absolute;top:50%;z-index:5;display:inline-block;margin-top:-10px}.carousel-control .glyphicon-chevron-left,.carousel-control .icon-prev{left:50%;margin-left:-10px}.carousel-control .glyphicon-chevron-right,.carousel-control .icon-next{right:50%;margin-right:-10px}.carousel-control .icon-next,.carousel-control .icon-prev{width:20px;height:20px;font-family:serif;line-height:1}.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,.6)}.carousel-caption .btn{text-shadow:none}@media screen and (min-width:768px){.carousel-control .glyphicon-chevron-left,.carousel-control .glyphicon-chevron-right,.carousel-control .icon-next,.carousel-control .icon-prev{width:30px;height:30px;margin-top:-10px;font-size:30px}.carousel-control .glyphicon-chevron-left,.carousel-control .icon-prev{margin-left:-10px}.carousel-control .glyphicon-chevron-right,.carousel-control .icon-next{margin-right:-10px}.carousel-caption{right:20%;left:20%;padding-bottom:30px}.carousel-indicators{bottom:20px}}.btn-group-vertical>.btn-group:after,.btn-group-vertical>.btn-group:before,.btn-toolbar:after,.btn-toolbar:before,.clearfix:after,.clearfix:before,.container-fluid:after,.container-fluid:before,.container:after,.container:before,.dl-horizontal dd:after,.dl-horizontal dd:before,.form-horizontal .form-group:after,.form-horizontal .form-group:before,.modal-footer:after,.modal-footer:before,.modal-header:after,.modal-header:before,.nav:after,.nav:before,.navbar-collapse:after,.navbar-collapse:before,.navbar-header:after,.navbar-header:before,.navbar:after,.navbar:before,.pager:after,.pager:before,.panel-body:after,.panel-body:before,.row:after,.row:before{display:table;content:" "}.btn-group-vertical>.btn-group:after,.btn-toolbar:after,.clearfix:after,.container-fluid:after,.container:after,.dl-horizontal dd:after,.form-horizontal .form-group:after,.modal-footer:after,.modal-header:after,.nav:after,.navbar-collapse:after,.navbar-header:after,.navbar:after,.pager:after,.panel-body:after,.row: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}.affix{position:fixed}@-ms-viewport{width:device-width}.visible-lg,.visible-md,.visible-sm,.visible-xs{display:none!important}.visible-lg-block,.visible-lg-inline,.visible-lg-inline-block,.visible-md-block,.visible-md-inline,.visible-md-inline-block,.visible-sm-block,.visible-sm-inline,.visible-sm-inline-block,.visible-xs-block,.visible-xs-inline,.visible-xs-inline-block{display:none!important}@media (max-width:767px){.visible-xs{display:block!important}table.visible-xs{display:table!important}tr.visible-xs{display:table-row!important}td.visible-xs,th.visible-xs{display:table-cell!important}}@media (max-width:767px){.visible-xs-block{display:block!important}}@media (max-width:767px){.visible-xs-inline{display:inline!important}}@media (max-width:767px){.visible-xs-inline-block{display:inline-block!important}}@media (min-width:768px) and (max-width:991px){.visible-sm{display:block!important}table.visible-sm{display:table!important}tr.visible-sm{display:table-row!important}td.visible-sm,th.visible-sm{display:table-cell!important}}@media (min-width:768px) and (max-width:991px){.visible-sm-block{display:block!important}}@media (min-width:768px) and (max-width:991px){.visible-sm-inline{display:inline!important}}@media (min-width:768px) and (max-width:991px){.visible-sm-inline-block{display:inline-block!important}}@media (min-width:992px) and (max-width:1199px){.visible-md{display:block!important}table.visible-md{display:table!important}tr.visible-md{display:table-row!important}td.visible-md,th.visible-md{display:table-cell!important}}@media (min-width:992px) and (max-width:1199px){.visible-md-block{display:block!important}}@media (min-width:992px) and (max-width:1199px){.visible-md-inline{display:inline!important}}@media (min-width:992px) and (max-width:1199px){.visible-md-inline-block{display:inline-block!important}}@media (min-width:1200px){.visible-lg{display:block!important}table.visible-lg{display:table!important}tr.visible-lg{display:table-row!important}td.visible-lg,th.visible-lg{display:table-cell!important}}@media (min-width:1200px){.visible-lg-block{display:block!important}}@media (min-width:1200px){.visible-lg-inline{display:inline!important}}@media (min-width:1200px){.visible-lg-inline-block{display:inline-block!important}}@media (max-width:767px){.hidden-xs{display:none!important}}@media (min-width:768px) and (max-width:991px){.hidden-sm{display:none!important}}@media (min-width:992px) and (max-width:1199px){.hidden-md{display:none!important}}@media (min-width:1200px){.hidden-lg{display:none!important}}.visible-print{display:none!important}@media print{.visible-print{display:block!important}table.visible-print{display:table!important}tr.visible-print{display:table-row!important}td.visible-print,th.visible-print{display:table-cell!important}}.visible-print-block{display:none!important}@media print{.visible-print-block{display:block!important}}.visible-print-inline{display:none!important}@media print{.visible-print-inline{display:inline!important}}.visible-print-inline-block{display:none!important}@media print{.visible-print-inline-block{display:inline-block!important}}@media print{.hidden-print{display:none!important}} +/*# sourceMappingURL=bootstrap.min.css.map */ \ No newline at end of file diff --git a/src/static/css/dashboard.css b/src/static/css/dashboard.css new file mode 100644 index 00000000..e0e3632b --- /dev/null +++ b/src/static/css/dashboard.css @@ -0,0 +1,105 @@ +/* + * Base structure + */ + +/* Move down content because we have a fixed navbar that is 50px tall */ +body { + padding-top: 50px; +} + + +/* + * Global add-ons + */ + +.sub-header { + padding-bottom: 10px; + border-bottom: 1px solid #eee; +} + +/* + * Top navigation + * Hide default border to remove 1px line. + */ +.navbar-fixed-top { + border: 0; +} + +/* + * Sidebar + */ + +/* Hide for mobile, show later */ +.sidebar { + display: none; +} +@media (min-width: 768px) { + .sidebar { + position: fixed; + top: 51px; + bottom: 0; + left: 0; + z-index: 1000; + display: block; + padding: 20px; + overflow-x: hidden; + overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ + background-color: #f5f5f5; + border-right: 1px solid #eee; + } +} + +/* Sidebar navigation */ +.nav-sidebar { + margin-right: -21px; /* 20px padding + 1px border */ + margin-bottom: 20px; + margin-left: -20px; +} +.nav-sidebar > li > a { + padding-right: 20px; + padding-left: 20px; +} +.nav-sidebar > .active > a, +.nav-sidebar > .active > a:hover, +.nav-sidebar > .active > a:focus { + color: #fff; + background-color: #428bca; +} + + +/* + * Main content + */ + +.main { + padding: 20px; +} +@media (min-width: 768px) { + .main { + padding-right: 40px; + padding-left: 40px; + } +} +.main .page-header { + margin-top: 0; +} + + +/* + * Placeholder dashboard ideas + */ + +.placeholders { + margin-bottom: 30px; + text-align: center; +} +.placeholders h4 { + margin-bottom: 0; +} +.placeholder { + margin-bottom: 20px; +} +.placeholder img { + display: inline-block; + border-radius: 50%; +} diff --git a/src/static/css/dataTables.bootstrap.min.css b/src/static/css/dataTables.bootstrap.min.css new file mode 100644 index 00000000..16ed6375 --- /dev/null +++ b/src/static/css/dataTables.bootstrap.min.css @@ -0,0 +1 @@ +table.dataTable{clear:both;margin-top:6px !important;margin-bottom:6px !important;max-width:none !important;border-collapse:separate !important}table.dataTable td,table.dataTable th{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}table.dataTable td.dataTables_empty,table.dataTable th.dataTables_empty{text-align:center}table.dataTable.nowrap th,table.dataTable.nowrap td{white-space:nowrap}div.dataTables_wrapper div.dataTables_length label{font-weight:normal;text-align:left;white-space:nowrap}div.dataTables_wrapper div.dataTables_length select{width:75px;display:inline-block}div.dataTables_wrapper div.dataTables_filter{text-align:right}div.dataTables_wrapper div.dataTables_filter label{font-weight:normal;white-space:nowrap;text-align:left}div.dataTables_wrapper div.dataTables_filter input{margin-left:0.5em;display:inline-block;width:auto}div.dataTables_wrapper div.dataTables_info{padding-top:8px;white-space:nowrap}div.dataTables_wrapper div.dataTables_paginate{margin:0;white-space:nowrap;text-align:right}div.dataTables_wrapper div.dataTables_paginate ul.pagination{margin:2px 0;white-space:nowrap}div.dataTables_wrapper div.dataTables_processing{position:absolute;top:50%;left:50%;width:200px;margin-left:-100px;margin-top:-26px;text-align:center;padding:1em 0}table.dataTable thead>tr>th.sorting_asc,table.dataTable thead>tr>th.sorting_desc,table.dataTable thead>tr>th.sorting,table.dataTable thead>tr>td.sorting_asc,table.dataTable thead>tr>td.sorting_desc,table.dataTable thead>tr>td.sorting{padding-right:30px}table.dataTable thead>tr>th:active,table.dataTable thead>tr>td:active{outline:none}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{cursor:pointer;position:relative}table.dataTable thead .sorting:after,table.dataTable thead .sorting_asc:after,table.dataTable thead .sorting_desc:after,table.dataTable thead .sorting_asc_disabled:after,table.dataTable thead .sorting_desc_disabled:after{position:absolute;bottom:8px;right:8px;display:block;font-family:'Glyphicons Halflings';opacity:0.5}table.dataTable thead .sorting:after{opacity:0.2;content:"\e150"}table.dataTable thead .sorting_asc:after{content:"\e155"}table.dataTable thead .sorting_desc:after{content:"\e156"}table.dataTable thead .sorting_asc_disabled:after,table.dataTable thead .sorting_desc_disabled:after{color:#eee}div.dataTables_scrollHead table.dataTable{margin-bottom:0 !important}div.dataTables_scrollBody table{border-top:none;margin-top:0 !important;margin-bottom:0 !important}div.dataTables_scrollBody table thead .sorting:after,div.dataTables_scrollBody table thead .sorting_asc:after,div.dataTables_scrollBody table thead .sorting_desc:after{display:none}div.dataTables_scrollBody table tbody tr:first-child th,div.dataTables_scrollBody table tbody tr:first-child td{border-top:none}div.dataTables_scrollFoot table{margin-top:0 !important;border-top:none}@media screen and (max-width: 767px){div.dataTables_wrapper div.dataTables_length,div.dataTables_wrapper div.dataTables_filter,div.dataTables_wrapper div.dataTables_info,div.dataTables_wrapper div.dataTables_paginate{text-align:center}}table.dataTable.table-condensed>thead>tr>th{padding-right:20px}table.dataTable.table-condensed .sorting:after,table.dataTable.table-condensed .sorting_asc:after,table.dataTable.table-condensed .sorting_desc:after{top:6px;right:6px}table.table-bordered.dataTable th,table.table-bordered.dataTable td{border-left-width:0}table.table-bordered.dataTable th:last-child,table.table-bordered.dataTable th:last-child,table.table-bordered.dataTable td:last-child,table.table-bordered.dataTable td:last-child{border-right-width:0}table.table-bordered.dataTable tbody th,table.table-bordered.dataTable tbody td{border-bottom-width:0}div.dataTables_scrollHead table.table-bordered{border-bottom-width:0}div.table-responsive>div.dataTables_wrapper>div.row{margin:0}div.table-responsive>div.dataTables_wrapper>div.row>div[class^="col-"]:first-child{padding-left:0}div.table-responsive>div.dataTables_wrapper>div.row>div[class^="col-"]:last-child{padding-right:0} diff --git a/src/static/css/jquery.dataTables.min.css b/src/static/css/jquery.dataTables.min.css new file mode 100644 index 00000000..781de6bf --- /dev/null +++ b/src/static/css/jquery.dataTables.min.css @@ -0,0 +1 @@ +table.dataTable{width:100%;margin:0 auto;clear:both;border-collapse:separate;border-spacing:0}table.dataTable thead th,table.dataTable tfoot th{font-weight:bold}table.dataTable thead th,table.dataTable thead td{padding:10px 18px;border-bottom:1px solid #111}table.dataTable thead th:active,table.dataTable thead td:active{outline:none}table.dataTable tfoot th,table.dataTable tfoot td{padding:10px 18px 6px 18px;border-top:1px solid #111}table.dataTable thead .sorting,table.dataTable thead .sorting_asc,table.dataTable thead .sorting_desc{cursor:pointer;*cursor:hand}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-repeat:no-repeat;background-position:center right}table.dataTable thead .sorting{background-image:url("../images/sort_both.png")}table.dataTable thead .sorting_asc{background-image:url("../images/sort_asc.png")}table.dataTable thead .sorting_desc{background-image:url("../images/sort_desc.png")}table.dataTable thead .sorting_asc_disabled{background-image:url("../images/sort_asc_disabled.png")}table.dataTable thead .sorting_desc_disabled{background-image:url("../images/sort_desc_disabled.png")}table.dataTable tbody tr{background-color:#ffffff}table.dataTable tbody tr.selected{background-color:#B0BED9}table.dataTable tbody th,table.dataTable tbody td{padding:8px 10px}table.dataTable.row-border tbody th,table.dataTable.row-border tbody td,table.dataTable.display tbody th,table.dataTable.display tbody td{border-top:1px solid #ddd}table.dataTable.row-border tbody tr:first-child th,table.dataTable.row-border tbody tr:first-child td,table.dataTable.display tbody tr:first-child th,table.dataTable.display tbody tr:first-child td{border-top:none}table.dataTable.cell-border tbody th,table.dataTable.cell-border tbody td{border-top:1px solid #ddd;border-right:1px solid #ddd}table.dataTable.cell-border tbody tr th:first-child,table.dataTable.cell-border tbody tr td:first-child{border-left:1px solid #ddd}table.dataTable.cell-border tbody tr:first-child th,table.dataTable.cell-border tbody tr:first-child td{border-top:none}table.dataTable.stripe tbody tr.odd,table.dataTable.display tbody tr.odd{background-color:#f9f9f9}table.dataTable.stripe tbody tr.odd.selected,table.dataTable.display tbody tr.odd.selected{background-color:#acbad4}table.dataTable.hover tbody tr:hover,table.dataTable.display tbody tr:hover{background-color:#f6f6f6}table.dataTable.hover tbody tr:hover.selected,table.dataTable.display tbody tr:hover.selected{background-color:#aab7d1}table.dataTable.order-column tbody tr>.sorting_1,table.dataTable.order-column tbody tr>.sorting_2,table.dataTable.order-column tbody tr>.sorting_3,table.dataTable.display tbody tr>.sorting_1,table.dataTable.display tbody tr>.sorting_2,table.dataTable.display tbody tr>.sorting_3{background-color:#fafafa}table.dataTable.order-column tbody tr.selected>.sorting_1,table.dataTable.order-column tbody tr.selected>.sorting_2,table.dataTable.order-column tbody tr.selected>.sorting_3,table.dataTable.display tbody tr.selected>.sorting_1,table.dataTable.display tbody tr.selected>.sorting_2,table.dataTable.display tbody tr.selected>.sorting_3{background-color:#acbad5}table.dataTable.display tbody tr.odd>.sorting_1,table.dataTable.order-column.stripe tbody tr.odd>.sorting_1{background-color:#f1f1f1}table.dataTable.display tbody tr.odd>.sorting_2,table.dataTable.order-column.stripe tbody tr.odd>.sorting_2{background-color:#f3f3f3}table.dataTable.display tbody tr.odd>.sorting_3,table.dataTable.order-column.stripe tbody tr.odd>.sorting_3{background-color:whitesmoke}table.dataTable.display tbody tr.odd.selected>.sorting_1,table.dataTable.order-column.stripe tbody tr.odd.selected>.sorting_1{background-color:#a6b4cd}table.dataTable.display tbody tr.odd.selected>.sorting_2,table.dataTable.order-column.stripe tbody tr.odd.selected>.sorting_2{background-color:#a8b5cf}table.dataTable.display tbody tr.odd.selected>.sorting_3,table.dataTable.order-column.stripe tbody tr.odd.selected>.sorting_3{background-color:#a9b7d1}table.dataTable.display tbody tr.even>.sorting_1,table.dataTable.order-column.stripe tbody tr.even>.sorting_1{background-color:#fafafa}table.dataTable.display tbody tr.even>.sorting_2,table.dataTable.order-column.stripe tbody tr.even>.sorting_2{background-color:#fcfcfc}table.dataTable.display tbody tr.even>.sorting_3,table.dataTable.order-column.stripe tbody tr.even>.sorting_3{background-color:#fefefe}table.dataTable.display tbody tr.even.selected>.sorting_1,table.dataTable.order-column.stripe tbody tr.even.selected>.sorting_1{background-color:#acbad5}table.dataTable.display tbody tr.even.selected>.sorting_2,table.dataTable.order-column.stripe tbody tr.even.selected>.sorting_2{background-color:#aebcd6}table.dataTable.display tbody tr.even.selected>.sorting_3,table.dataTable.order-column.stripe tbody tr.even.selected>.sorting_3{background-color:#afbdd8}table.dataTable.display tbody tr:hover>.sorting_1,table.dataTable.order-column.hover tbody tr:hover>.sorting_1{background-color:#eaeaea}table.dataTable.display tbody tr:hover>.sorting_2,table.dataTable.order-column.hover tbody tr:hover>.sorting_2{background-color:#ececec}table.dataTable.display tbody tr:hover>.sorting_3,table.dataTable.order-column.hover tbody tr:hover>.sorting_3{background-color:#efefef}table.dataTable.display tbody tr:hover.selected>.sorting_1,table.dataTable.order-column.hover tbody tr:hover.selected>.sorting_1{background-color:#a2aec7}table.dataTable.display tbody tr:hover.selected>.sorting_2,table.dataTable.order-column.hover tbody tr:hover.selected>.sorting_2{background-color:#a3b0c9}table.dataTable.display tbody tr:hover.selected>.sorting_3,table.dataTable.order-column.hover tbody tr:hover.selected>.sorting_3{background-color:#a5b2cb}table.dataTable.no-footer{border-bottom:1px solid #111}table.dataTable.nowrap th,table.dataTable.nowrap td{white-space:nowrap}table.dataTable.compact thead th,table.dataTable.compact thead td{padding:4px 17px 4px 4px}table.dataTable.compact tfoot th,table.dataTable.compact tfoot td{padding:4px}table.dataTable.compact tbody th,table.dataTable.compact tbody td{padding:4px}table.dataTable th.dt-left,table.dataTable td.dt-left{text-align:left}table.dataTable th.dt-center,table.dataTable td.dt-center,table.dataTable td.dataTables_empty{text-align:center}table.dataTable th.dt-right,table.dataTable td.dt-right{text-align:right}table.dataTable th.dt-justify,table.dataTable td.dt-justify{text-align:justify}table.dataTable th.dt-nowrap,table.dataTable td.dt-nowrap{white-space:nowrap}table.dataTable thead th.dt-head-left,table.dataTable thead td.dt-head-left,table.dataTable tfoot th.dt-head-left,table.dataTable tfoot td.dt-head-left{text-align:left}table.dataTable thead th.dt-head-center,table.dataTable thead td.dt-head-center,table.dataTable tfoot th.dt-head-center,table.dataTable tfoot td.dt-head-center{text-align:center}table.dataTable thead th.dt-head-right,table.dataTable thead td.dt-head-right,table.dataTable tfoot th.dt-head-right,table.dataTable tfoot td.dt-head-right{text-align:right}table.dataTable thead th.dt-head-justify,table.dataTable thead td.dt-head-justify,table.dataTable tfoot th.dt-head-justify,table.dataTable tfoot td.dt-head-justify{text-align:justify}table.dataTable thead th.dt-head-nowrap,table.dataTable thead td.dt-head-nowrap,table.dataTable tfoot th.dt-head-nowrap,table.dataTable tfoot td.dt-head-nowrap{white-space:nowrap}table.dataTable tbody th.dt-body-left,table.dataTable tbody td.dt-body-left{text-align:left}table.dataTable tbody th.dt-body-center,table.dataTable tbody td.dt-body-center{text-align:center}table.dataTable tbody th.dt-body-right,table.dataTable tbody td.dt-body-right{text-align:right}table.dataTable tbody th.dt-body-justify,table.dataTable tbody td.dt-body-justify{text-align:justify}table.dataTable tbody th.dt-body-nowrap,table.dataTable tbody td.dt-body-nowrap{white-space:nowrap}table.dataTable,table.dataTable th,table.dataTable td{-webkit-box-sizing:content-box;box-sizing:content-box}.dataTables_wrapper{position:relative;clear:both;*zoom:1;zoom:1}.dataTables_wrapper .dataTables_length{float:left}.dataTables_wrapper .dataTables_filter{float:right;text-align:right}.dataTables_wrapper .dataTables_filter input{margin-left:0.5em}.dataTables_wrapper .dataTables_info{clear:both;float:left;padding-top:0.755em}.dataTables_wrapper .dataTables_paginate{float:right;text-align:right;padding-top:0.25em}.dataTables_wrapper .dataTables_paginate .paginate_button{box-sizing:border-box;display:inline-block;min-width:1.5em;padding:0.5em 1em;margin-left:2px;text-align:center;text-decoration:none !important;cursor:pointer;*cursor:hand;color:#333 !important;border:1px solid transparent;border-radius:2px}.dataTables_wrapper .dataTables_paginate .paginate_button.current,.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover{color:#333 !important;border:1px solid #979797;background-color:white;background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #fff), color-stop(100%, #dcdcdc));background:-webkit-linear-gradient(top, #fff 0%, #dcdcdc 100%);background:-moz-linear-gradient(top, #fff 0%, #dcdcdc 100%);background:-ms-linear-gradient(top, #fff 0%, #dcdcdc 100%);background:-o-linear-gradient(top, #fff 0%, #dcdcdc 100%);background:linear-gradient(to bottom, #fff 0%, #dcdcdc 100%)}.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover,.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:active{cursor:default;color:#666 !important;border:1px solid transparent;background:transparent;box-shadow:none}.dataTables_wrapper .dataTables_paginate .paginate_button:hover{color:white !important;border:1px solid #111;background-color:#585858;background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #585858), color-stop(100%, #111));background:-webkit-linear-gradient(top, #585858 0%, #111 100%);background:-moz-linear-gradient(top, #585858 0%, #111 100%);background:-ms-linear-gradient(top, #585858 0%, #111 100%);background:-o-linear-gradient(top, #585858 0%, #111 100%);background:linear-gradient(to bottom, #585858 0%, #111 100%)}.dataTables_wrapper .dataTables_paginate .paginate_button:active{outline:none;background-color:#2b2b2b;background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #2b2b2b), color-stop(100%, #0c0c0c));background:-webkit-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:-moz-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:-ms-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:-o-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:linear-gradient(to bottom, #2b2b2b 0%, #0c0c0c 100%);box-shadow:inset 0 0 3px #111}.dataTables_wrapper .dataTables_paginate .ellipsis{padding:0 1em}.dataTables_wrapper .dataTables_processing{position:absolute;top:50%;left:50%;width:100%;height:40px;margin-left:-50%;margin-top:-25px;padding-top:20px;text-align:center;font-size:1.2em;background-color:white;background:-webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255,255,255,0)), color-stop(25%, rgba(255,255,255,0.9)), color-stop(75%, rgba(255,255,255,0.9)), color-stop(100%, rgba(255,255,255,0)));background:-webkit-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:-moz-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:-ms-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:-o-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%)}.dataTables_wrapper .dataTables_length,.dataTables_wrapper .dataTables_filter,.dataTables_wrapper .dataTables_info,.dataTables_wrapper .dataTables_processing,.dataTables_wrapper .dataTables_paginate{color:#333}.dataTables_wrapper .dataTables_scroll{clear:both}.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody{*margin-top:-1px;-webkit-overflow-scrolling:touch}.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody th,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody td{vertical-align:middle}.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody th>div.dataTables_sizing,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody td>div.dataTables_sizing{height:0;overflow:hidden;margin:0 !important;padding:0 !important}.dataTables_wrapper.no-footer .dataTables_scrollBody{border-bottom:1px solid #111}.dataTables_wrapper.no-footer div.dataTables_scrollHead table,.dataTables_wrapper.no-footer div.dataTables_scrollBody table{border-bottom:none}.dataTables_wrapper:after{visibility:hidden;display:block;content:"";clear:both;height:0}@media screen and (max-width: 767px){.dataTables_wrapper .dataTables_info,.dataTables_wrapper .dataTables_paginate{float:none;text-align:center}.dataTables_wrapper .dataTables_paginate{margin-top:0.5em}}@media screen and (max-width: 640px){.dataTables_wrapper .dataTables_length,.dataTables_wrapper .dataTables_filter{float:none;text-align:center}.dataTables_wrapper .dataTables_filter{margin-top:0.5em}} diff --git a/src/static/css/paginate.css b/src/static/css/paginate.css new file mode 100644 index 00000000..6930fc6b --- /dev/null +++ b/src/static/css/paginate.css @@ -0,0 +1,15 @@ +.pagination-page-info { + padding: .6em; + padding-left: 0; + width: 40em; + margin: .5em; + margin-left: 0; + font-size: 12px; +} +.pagination-page-info b { + color: black; + background: #6aa6ed; + padding-left: 2px; + padding: .1em .25em; + font-size: 150%; +} \ No newline at end of file diff --git a/src/static/fonts/glyphicons-halflings-regular.eot b/src/static/fonts/glyphicons-halflings-regular.eot new file mode 100644 index 00000000..b93a4953 Binary files /dev/null and b/src/static/fonts/glyphicons-halflings-regular.eot differ diff --git a/src/static/fonts/glyphicons-halflings-regular.svg b/src/static/fonts/glyphicons-halflings-regular.svg new file mode 100644 index 00000000..94fb5490 --- /dev/null +++ b/src/static/fonts/glyphicons-halflings-regular.svg @@ -0,0 +1,288 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/fonts/glyphicons-halflings-regular.ttf b/src/static/fonts/glyphicons-halflings-regular.ttf new file mode 100644 index 00000000..1413fc60 Binary files /dev/null and b/src/static/fonts/glyphicons-halflings-regular.ttf differ diff --git a/src/static/fonts/glyphicons-halflings-regular.woff b/src/static/fonts/glyphicons-halflings-regular.woff new file mode 100644 index 00000000..9e612858 Binary files /dev/null and b/src/static/fonts/glyphicons-halflings-regular.woff differ diff --git a/src/static/fonts/glyphicons-halflings-regular.woff2 b/src/static/fonts/glyphicons-halflings-regular.woff2 new file mode 100644 index 00000000..64539b54 Binary files /dev/null and b/src/static/fonts/glyphicons-halflings-regular.woff2 differ diff --git a/src/static/img/favicon.ico b/src/static/img/favicon.ico new file mode 100644 index 00000000..c6d2e93f Binary files /dev/null and b/src/static/img/favicon.ico differ diff --git a/src/static/js/bootbox.min.js b/src/static/js/bootbox.min.js new file mode 100644 index 00000000..737d9e9f --- /dev/null +++ b/src/static/js/bootbox.min.js @@ -0,0 +1,6 @@ +/** + * bootbox.js v4.2.0 + * + * http://bootboxjs.com/license.txt + */ +!function(a,b){"use strict";"function"==typeof define&&define.amd?define(["jquery"],b):"object"==typeof exports?module.exports=b(require("jquery")):a.bootbox=b(a.jQuery)}(this,function a(b,c){"use strict";function d(a){var b=q[o.locale];return b?b[a]:q.en[a]}function e(a,c,d){a.stopPropagation(),a.preventDefault();var e=b.isFunction(d)&&d(a)===!1;e||c.modal("hide")}function f(a){var b,c=0;for(b in a)c++;return c}function g(a,c){var d=0;b.each(a,function(a,b){c(a,b,d++)})}function h(a){var c,d;if("object"!=typeof a)throw new Error("Please supply an object of options");if(!a.message)throw new Error("Please specify a message");return a=b.extend({},o,a),a.buttons||(a.buttons={}),a.backdrop=a.backdrop?"static":!1,c=a.buttons,d=f(c),g(c,function(a,e,f){if(b.isFunction(e)&&(e=c[a]={callback:e}),"object"!==b.type(e))throw new Error("button with key "+a+" must be an object");e.label||(e.label=a),e.className||(e.className=2>=d&&f===d-1?"btn-primary":"btn-default")}),a}function i(a,b){var c=a.length,d={};if(1>c||c>2)throw new Error("Invalid argument length");return 2===c||"string"==typeof a[0]?(d[b[0]]=a[0],d[b[1]]=a[1]):d=a[0],d}function j(a,c,d){return b.extend(!0,{},a,i(c,d))}function k(a,b,c,d){var e={className:"bootbox-"+a,buttons:l.apply(null,b)};return m(j(e,d,c),b)}function l(){for(var a={},b=0,c=arguments.length;c>b;b++){var e=arguments[b],f=e.toLowerCase(),g=e.toUpperCase();a[f]={label:d(g)}}return a}function m(a,b){var d={};return g(b,function(a,b){d[b]=!0}),g(a.buttons,function(a){if(d[a]===c)throw new Error("button key "+a+" is not allowed (options are "+b.join("\n")+")")}),a}var n={dialog:"",header:"",footer:"",closeButton:"",form:"
",inputs:{text:"",textarea:"",email:"",select:"",checkbox:"
",date:"",time:"",number:"",password:""}},o={locale:"en",backdrop:!0,animate:!0,className:null,closeButton:!0,show:!0,container:"body"},p={};p.alert=function(){var a;if(a=k("alert",["ok"],["message","callback"],arguments),a.callback&&!b.isFunction(a.callback))throw new Error("alert requires callback property to be a function when provided");return a.buttons.ok.callback=a.onEscape=function(){return b.isFunction(a.callback)?a.callback():!0},p.dialog(a)},p.confirm=function(){var a;if(a=k("confirm",["cancel","confirm"],["message","callback"],arguments),a.buttons.cancel.callback=a.onEscape=function(){return a.callback(!1)},a.buttons.confirm.callback=function(){return a.callback(!0)},!b.isFunction(a.callback))throw new Error("confirm requires a callback");return p.dialog(a)},p.prompt=function(){var a,d,e,f,h,i,k;f=b(n.form),d={className:"bootbox-prompt",buttons:l("cancel","confirm"),value:"",inputType:"text"},a=m(j(d,arguments,["title","callback"]),["cancel","confirm"]),i=a.show===c?!0:a.show;var o=["date","time","number"],q=document.createElement("input");if(q.setAttribute("type",a.inputType),o[a.inputType]&&(a.inputType=q.type),a.message=f,a.buttons.cancel.callback=a.onEscape=function(){return a.callback(null)},a.buttons.confirm.callback=function(){var c;switch(a.inputType){case"text":case"textarea":case"email":case"select":case"date":case"time":case"number":case"password":c=h.val();break;case"checkbox":var d=h.find("input:checked");c=[],g(d,function(a,d){c.push(b(d).val())})}return a.callback(c)},a.show=!1,!a.title)throw new Error("prompt requires a title");if(!b.isFunction(a.callback))throw new Error("prompt requires a callback");if(!n.inputs[a.inputType])throw new Error("invalid prompt type");switch(h=b(n.inputs[a.inputType]),a.inputType){case"text":case"textarea":case"email":case"date":case"time":case"number":case"password":h.val(a.value);break;case"select":var r={};if(k=a.inputOptions||[],!k.length)throw new Error("prompt with select requires options");g(k,function(a,d){var e=h;if(d.value===c||d.text===c)throw new Error("given options in wrong format");d.group&&(r[d.group]||(r[d.group]=b("").attr("label",d.group)),e=r[d.group]),e.append("")}),g(r,function(a,b){h.append(b)}),h.val(a.value);break;case"checkbox":var s=b.isArray(a.value)?a.value:[a.value];if(k=a.inputOptions||[],!k.length)throw new Error("prompt with checkbox requires options");if(!k[0].value||!k[0].text)throw new Error("given options in wrong format");h=b("
"),g(k,function(c,d){var e=b(n.inputs[a.inputType]);e.find("input").attr("value",d.value),e.find("label").append(d.text),g(s,function(a,b){b===d.value&&e.find("input").prop("checked",!0)}),h.append(e)})}return a.placeholder&&h.attr("placeholder",a.placeholder),a.pattern&&h.attr("pattern",a.pattern),f.append(h),f.on("submit",function(a){a.preventDefault(),e.find(".btn-primary").click()}),e=p.dialog(a),e.off("shown.bs.modal"),e.on("shown.bs.modal",function(){h.focus()}),i===!0&&e.modal("show"),e},p.dialog=function(a){a=h(a);var c=b(n.dialog),d=c.find(".modal-body"),f=a.buttons,i="",j={onEscape:a.onEscape};if(g(f,function(a,b){i+="",j[a]=b.callback}),d.find(".bootbox-body").html(a.message),a.animate===!0&&c.addClass("fade"),a.className&&c.addClass(a.className),a.title&&d.before(n.header),a.closeButton){var k=b(n.closeButton);a.title?c.find(".modal-header").prepend(k):k.css("margin-top","-10px").prependTo(d)}return a.title&&c.find(".modal-title").html(a.title),i.length&&(d.after(n.footer),c.find(".modal-footer").html(i)),c.on("hidden.bs.modal",function(a){a.target===this&&c.remove()}),c.on("shown.bs.modal",function(){c.find(".btn-primary:first").focus()}),c.on("escape.close.bb",function(a){j.onEscape&&e(a,c,j.onEscape)}),c.on("click",".modal-footer button",function(a){var d=b(this).data("bb-handler");e(a,c,j[d])}),c.on("click",".bootbox-close-button",function(a){e(a,c,j.onEscape)}),c.on("keyup",function(a){27===a.which&&c.trigger("escape.close.bb")}),b(a.container).append(c),c.modal({backdrop:a.backdrop,keyboard:!1,show:!1}),a.show&&c.modal("show"),c},p.setDefaults=function(){var a={};2===arguments.length?a[arguments[0]]=arguments[1]:a=arguments[0],b.extend(o,a)},p.hideAll=function(){b(".bootbox").modal("hide")};var q={br:{OK:"OK",CANCEL:"Cancelar",CONFIRM:"Sim"},da:{OK:"OK",CANCEL:"Annuller",CONFIRM:"Accepter"},de:{OK:"OK",CANCEL:"Abbrechen",CONFIRM:"Akzeptieren"},en:{OK:"OK",CANCEL:"Cancel",CONFIRM:"OK"},es:{OK:"OK",CANCEL:"Cancelar",CONFIRM:"Aceptar"},fi:{OK:"OK",CANCEL:"Peruuta",CONFIRM:"OK"},fr:{OK:"OK",CANCEL:"Annuler",CONFIRM:"D'accord"},he:{OK:"אישור",CANCEL:"ביטול",CONFIRM:"אישור"},it:{OK:"OK",CANCEL:"Annulla",CONFIRM:"Conferma"},lt:{OK:"Gerai",CANCEL:"Atšaukti",CONFIRM:"Patvirtinti"},lv:{OK:"Labi",CANCEL:"Atcelt",CONFIRM:"Apstiprināt"},nl:{OK:"OK",CANCEL:"Annuleren",CONFIRM:"Accepteren"},no:{OK:"OK",CANCEL:"Avbryt",CONFIRM:"OK"},pl:{OK:"OK",CANCEL:"Anuluj",CONFIRM:"Potwierdź"},ru:{OK:"OK",CANCEL:"Отмена",CONFIRM:"Применить"},sv:{OK:"OK",CANCEL:"Avbryt",CONFIRM:"OK"},tr:{OK:"Tamam",CANCEL:"İptal",CONFIRM:"Onayla"},zh_CN:{OK:"OK",CANCEL:"取消",CONFIRM:"确认"},zh_TW:{OK:"OK",CANCEL:"取消",CONFIRM:"確認"}};return p.init=function(c){return a(c||b)},p}); \ No newline at end of file diff --git a/src/static/js/bootstrap-notify.min.js b/src/static/js/bootstrap-notify.min.js new file mode 100755 index 00000000..f5ad385a --- /dev/null +++ b/src/static/js/bootstrap-notify.min.js @@ -0,0 +1,2 @@ +/* Project: Bootstrap Growl = v3.1.3 | Description: Turns standard Bootstrap alerts into "Growl-like" notifications. | Author: Mouse0270 aka Robert McIntosh | License: MIT License | Website: https://github.com/mouse0270/bootstrap-growl */ +!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t("object"==typeof exports?require("jquery"):jQuery)}(function(t){function e(e,i,n){var i={content:{message:"object"==typeof i?i.message:i,title:i.title?i.title:"",icon:i.icon?i.icon:"",url:i.url?i.url:"#",target:i.target?i.target:"-"}};n=t.extend(!0,{},i,n),this.settings=t.extend(!0,{},s,n),this._defaults=s,"-"==this.settings.content.target&&(this.settings.content.target=this.settings.url_target),this.animations={start:"webkitAnimationStart oanimationstart MSAnimationStart animationstart",end:"webkitAnimationEnd oanimationend MSAnimationEnd animationend"},"number"==typeof this.settings.offset&&(this.settings.offset={x:this.settings.offset,y:this.settings.offset}),this.init()}var s={element:"body",position:null,type:"info",allow_dismiss:!0,newest_on_top:!1,showProgressbar:!1,placement:{from:"top",align:"right"},offset:20,spacing:10,z_index:1031,delay:5e3,timer:1e3,url_target:"_blank",mouse_over:null,animate:{enter:"animated fadeInDown",exit:"animated fadeOutUp"},onShow:null,onShown:null,onClose:null,onClosed:null,icon_type:"class",template:''};String.format=function(){for(var t=arguments[0],e=1;e .progress-bar').removeClass("progress-bar-"+t.settings.type),t.settings.type=i[e],this.$ele.addClass("alert-"+i[e]).find('[data-notify="progressbar"] > .progress-bar').addClass("progress-bar-"+i[e]);break;case"icon":var n=this.$ele.find('[data-notify="icon"]');"class"==t.settings.icon_type.toLowerCase()?n.removeClass(t.settings.content.icon).addClass(i[e]):(n.is("img")||n.find("img"),n.attr("src",i[e]));break;case"progress":var a=t.settings.delay-t.settings.delay*(i[e]/100);this.$ele.data("notify-delay",a),this.$ele.find('[data-notify="progressbar"] > div').attr("aria-valuenow",i[e]).css("width",i[e]+"%");break;case"url":this.$ele.find('[data-notify="url"]').attr("href",i[e]);break;case"target":this.$ele.find('[data-notify="url"]').attr("target",i[e]);break;default:this.$ele.find('[data-notify="'+e+'"]').html(i[e])}var o=this.$ele.outerHeight()+parseInt(t.settings.spacing)+parseInt(t.settings.offset.y);t.reposition(o)},close:function(){t.close()}}},buildNotify:function(){var e=this.settings.content;this.$ele=t(String.format(this.settings.template,this.settings.type,e.title,e.message,e.url,e.target)),this.$ele.attr("data-notify-position",this.settings.placement.from+"-"+this.settings.placement.align),this.settings.allow_dismiss||this.$ele.find('[data-notify="dismiss"]').css("display","none"),(this.settings.delay<=0&&!this.settings.showProgressbar||!this.settings.showProgressbar)&&this.$ele.find('[data-notify="progressbar"]').remove()},setIcon:function(){"class"==this.settings.icon_type.toLowerCase()?this.$ele.find('[data-notify="icon"]').addClass(this.settings.content.icon):this.$ele.find('[data-notify="icon"]').is("img")?this.$ele.find('[data-notify="icon"]').attr("src",this.settings.content.icon):this.$ele.find('[data-notify="icon"]').append('Notify Icon')},styleURL:function(){this.$ele.find('[data-notify="url"]').css({backgroundImage:"url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)",height:"100%",left:"0px",position:"absolute",top:"0px",width:"100%",zIndex:this.settings.z_index+1}),this.$ele.find('[data-notify="dismiss"]').css({position:"absolute",right:"10px",top:"5px",zIndex:this.settings.z_index+2})},placement:function(){var e=this,s=this.settings.offset.y,i={display:"inline-block",margin:"0px auto",position:this.settings.position?this.settings.position:"body"===this.settings.element?"fixed":"absolute",transition:"all .5s ease-in-out",zIndex:this.settings.z_index},n=!1,a=this.settings;switch(t('[data-notify-position="'+this.settings.placement.from+"-"+this.settings.placement.align+'"]:not([data-closing="true"])').each(function(){return s=Math.max(s,parseInt(t(this).css(a.placement.from))+parseInt(t(this).outerHeight())+parseInt(a.spacing))}),1==this.settings.newest_on_top&&(s=this.settings.offset.y),i[this.settings.placement.from]=s+"px",this.settings.placement.align){case"left":case"right":i[this.settings.placement.align]=this.settings.offset.x+"px";break;case"center":i.left=0,i.right=0}this.$ele.css(i).addClass(this.settings.animate.enter),t.each(Array("webkit","moz","o","ms",""),function(t,s){e.$ele[0].style[s+"AnimationIterationCount"]=1}),t(this.settings.element).append(this.$ele),1==this.settings.newest_on_top&&(s=parseInt(s)+parseInt(this.settings.spacing)+this.$ele.outerHeight(),this.reposition(s)),t.isFunction(e.settings.onShow)&&e.settings.onShow.call(this.$ele),this.$ele.one(this.animations.start,function(){n=!0}).one(this.animations.end,function(){t.isFunction(e.settings.onShown)&&e.settings.onShown.call(this)}),setTimeout(function(){n||t.isFunction(e.settings.onShown)&&e.settings.onShown.call(this)},600)},bind:function(){var e=this;if(this.$ele.find('[data-notify="dismiss"]').on("click",function(){e.close()}),this.$ele.mouseover(function(){t(this).data("data-hover","true")}).mouseout(function(){t(this).data("data-hover","false")}),this.$ele.data("data-hover","false"),this.settings.delay>0){e.$ele.data("notify-delay",e.settings.delay);var s=setInterval(function(){var t=parseInt(e.$ele.data("notify-delay"))-e.settings.timer;if("false"===e.$ele.data("data-hover")&&"pause"==e.settings.mouse_over||"pause"!=e.settings.mouse_over){var i=(e.settings.delay-t)/e.settings.delay*100;e.$ele.data("notify-delay",t),e.$ele.find('[data-notify="progressbar"] > div').attr("aria-valuenow",i).css("width",i+"%")}t<=-e.settings.timer&&(clearInterval(s),e.close())},e.settings.timer)}},close:function(){var e=this,s=parseInt(this.$ele.css(this.settings.placement.from)),i=!1;this.$ele.data("closing","true").addClass(this.settings.animate.exit),e.reposition(s),t.isFunction(e.settings.onClose)&&e.settings.onClose.call(this.$ele),this.$ele.one(this.animations.start,function(){i=!0}).one(this.animations.end,function(){t(this).remove(),t.isFunction(e.settings.onClosed)&&e.settings.onClosed.call(this)}),setTimeout(function(){i||(e.$ele.remove(),e.settings.onClosed&&e.settings.onClosed(e.$ele))},600)},reposition:function(e){var s=this,i='[data-notify-position="'+this.settings.placement.from+"-"+this.settings.placement.align+'"]:not([data-closing="true"])',n=this.$ele.nextAll(i);1==this.settings.newest_on_top&&(n=this.$ele.prevAll(i)),n.each(function(){t(this).css(s.settings.placement.from,e),e=parseInt(e)+parseInt(s.settings.spacing)+t(this).outerHeight()})}}),t.notify=function(t,s){var i=new e(this,t,s);return i.notify},t.notifyDefaults=function(e){return s=t.extend(!0,{},s,e)},t.notifyClose=function(e){"undefined"==typeof e||"all"==e?t("[data-notify]").find('[data-notify="dismiss"]').trigger("click"):t('[data-notify-position="'+e+'"]').find('[data-notify="dismiss"]').trigger("click")}}); \ No newline at end of file diff --git a/src/static/js/bootstrap-table-zh-CN.min.js b/src/static/js/bootstrap-table-zh-CN.min.js new file mode 100644 index 00000000..e903fdf8 --- /dev/null +++ b/src/static/js/bootstrap-table-zh-CN.min.js @@ -0,0 +1,7 @@ +/* +* bootstrap-table - v1.10.1 - 2016-02-17 +* https://github.com/wenzhixin/bootstrap-table +* Copyright (c) 2016 zhixin wen +* Licensed MIT License +*/ +!function(a){"use strict";a.fn.bootstrapTable.locales["zh-CN"]={formatLoadingMessage:function(){return"正在努力地加载数据中,请稍候……"},formatRecordsPerPage:function(a){return"每页显示 "+a+" 条记录"},formatShowingRows:function(a,b,c){return"显示第 "+a+" 到第 "+b+" 条记录,总共 "+c+" 条记录"},formatSearch:function(){return"搜索"},formatNoMatches:function(){return"没有找到匹配的记录"},formatPaginationSwitch:function(){return"隐藏/显示分页"},formatRefresh:function(){return"刷新"},formatToggle:function(){return"切换"},formatColumns:function(){return"列"}},a.extend(a.fn.bootstrapTable.defaults,a.fn.bootstrapTable.locales["zh-CN"])}(jQuery); \ No newline at end of file diff --git a/src/static/js/bootstrap-table.min.js b/src/static/js/bootstrap-table.min.js new file mode 100644 index 00000000..3fe39fc7 --- /dev/null +++ b/src/static/js/bootstrap-table.min.js @@ -0,0 +1,8 @@ +/* +* bootstrap-table - v1.10.1 - 2016-02-17 +* https://github.com/wenzhixin/bootstrap-table +* Copyright (c) 2016 zhixin wen +* Licensed MIT License +*/ +!function(a){"use strict";var b=null,c=function(a){var b=arguments,c=!0,d=1;return a=a.replace(/%s/g,function(){var a=b[d++];return"undefined"==typeof a?(c=!1,""):a}),c?a:""},d=function(b,c,d,e){var f="";return a.each(b,function(a,b){return b[c]===e?(f=b[d],!1):!0}),f},e=function(b,c){var d=-1;return a.each(b,function(a,b){return b.field===c?(d=a,!1):!0}),d},f=function(b){var c,d,e,f=0,g=[];for(c=0;cd;d++)g[c][d]=!1;for(c=0;ce;e++)g[c+e][k]=!0;for(e=0;j>e;e++)g[c][k+e]=!0}},g=function(){if(null===b){var c,d,e=a("

").addClass("fixed-table-scroll-inner"),f=a("

").addClass("fixed-table-scroll-outer");f.append(e),a("body").append(f),c=e[0].offsetWidth,f.css("overflow","scroll"),d=e[0].offsetWidth,c===d&&(d=f[0].clientWidth),f.remove(),b=c-d}return b},h=function(b,d,e,f){var g=d;if("string"==typeof d){var h=d.split(".");h.length>1?(g=window,a.each(h,function(a,b){g=g[b]})):g=window[d]}return"object"==typeof g?g:"function"==typeof g?g.apply(b,e):!g&&"string"==typeof d&&c.apply(this,[d].concat(e))?c.apply(this,[d].concat(e)):f},i=function(b,c,d){var e=Object.getOwnPropertyNames(b),f=Object.getOwnPropertyNames(c),g="";if(d&&e.length!==f.length)return!1;for(var h=0;h-1&&b[g]!==c[g])return!1;return!0},j=function(a){return"string"==typeof a?a.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/`/g,"`"):a},k=function(b){var c=0;return b.children().each(function(){c0||navigator.userAgent.match(/Trident.*rv\:11\./))},o=function(b,c){this.options=c,this.$el=a(b),this.$el_=this.$el.clone(),this.timeoutId_=0,this.timeoutFooter_=0,this.init()};o.DEFAULTS={classes:"table table-hover",locale:void 0,height:void 0,undefinedText:"-",sortName:void 0,sortOrder:"asc",striped:!1,columns:[[]],data:[],dataField:"rows",method:"get",url:void 0,ajax:void 0,cache:!0,contentType:"application/json",dataType:"json",ajaxOptions:{},queryParams:function(a){return a},queryParamsType:"limit",responseHandler:function(a){return a},pagination:!1,onlyInfoPagination:!1,sidePagination:"client",totalRows:0,pageNumber:1,pageSize:10,pageList:[10,25,50,100],paginationHAlign:"right",paginationVAlign:"bottom",paginationDetailHAlign:"left",paginationPreText:"‹",paginationNextText:"›",search:!1,searchOnEnterKey:!1,strictSearch:!1,searchAlign:"right",selectItemName:"btSelectItem",showHeader:!0,showFooter:!1,showColumns:!1,showPaginationSwitch:!1,showRefresh:!1,showToggle:!1,buttonsAlign:"right",smartDisplay:!0,escape:!1,minimumCountColumns:1,idField:void 0,uniqueId:void 0,cardView:!1,detailView:!1,detailFormatter:function(){return""},trimOnSearch:!0,clickToSelect:!1,singleSelect:!1,toolbar:void 0,toolbarAlign:"left",checkboxHeader:!0,sortable:!0,silentSort:!0,maintainSelected:!1,searchTimeOut:500,searchText:"",iconSize:void 0,iconsPrefix:"glyphicon",icons:{paginationSwitchDown:"glyphicon-collapse-down icon-chevron-down",paginationSwitchUp:"glyphicon-collapse-up icon-chevron-up",refresh:"glyphicon-refresh icon-refresh",toggle:"glyphicon-list-alt icon-list-alt",columns:"glyphicon-th icon-th",detailOpen:"glyphicon-plus icon-plus",detailClose:"glyphicon-minus icon-minus"},rowStyle:function(){return{}},rowAttributes:function(){return{}},onAll:function(){return!1},onClickCell:function(){return!1},onDblClickCell:function(){return!1},onClickRow:function(){return!1},onDblClickRow:function(){return!1},onSort:function(){return!1},onCheck:function(){return!1},onUncheck:function(){return!1},onCheckAll:function(){return!1},onUncheckAll:function(){return!1},onCheckSome:function(){return!1},onUncheckSome:function(){return!1},onLoadSuccess:function(){return!1},onLoadError:function(){return!1},onColumnSwitch:function(){return!1},onPageChange:function(){return!1},onSearch:function(){return!1},onToggle:function(){return!1},onPreBody:function(){return!1},onPostBody:function(){return!1},onPostHeader:function(){return!1},onExpandRow:function(){return!1},onCollapseRow:function(){return!1},onRefreshOptions:function(){return!1},onResetView:function(){return!1}},o.LOCALES=[],o.LOCALES["en-US"]=o.LOCALES.en={formatLoadingMessage:function(){return"Loading, please wait..."},formatRecordsPerPage:function(a){return c("%s records per page",a)},formatShowingRows:function(a,b,d){return c("Showing %s to %s of %s rows",a,b,d)},formatDetailPagination:function(a){return c("Showing %s rows",a)},formatSearch:function(){return"Search"},formatNoMatches:function(){return"No matching records found"},formatPaginationSwitch:function(){return"Hide/Show pagination"},formatRefresh:function(){return"Refresh"},formatToggle:function(){return"Toggle"},formatColumns:function(){return"Columns"},formatAllRows:function(){return"All"}},a.extend(o.DEFAULTS,o.LOCALES["en-US"]),o.COLUMN_DEFAULTS={radio:!1,checkbox:!1,checkboxEnabled:!0,field:void 0,title:void 0,titleTooltip:void 0,"class":void 0,align:void 0,halign:void 0,falign:void 0,valign:void 0,width:void 0,sortable:!1,order:"asc",visible:!0,switchable:!0,clickToSelect:!0,formatter:void 0,footerFormatter:void 0,events:void 0,sorter:void 0,sortName:void 0,cellStyle:void 0,searchable:!0,searchFormatter:!0,cardVisible:!0},o.EVENTS={"all.bs.table":"onAll","click-cell.bs.table":"onClickCell","dbl-click-cell.bs.table":"onDblClickCell","click-row.bs.table":"onClickRow","dbl-click-row.bs.table":"onDblClickRow","sort.bs.table":"onSort","check.bs.table":"onCheck","uncheck.bs.table":"onUncheck","check-all.bs.table":"onCheckAll","uncheck-all.bs.table":"onUncheckAll","check-some.bs.table":"onCheckSome","uncheck-some.bs.table":"onUncheckSome","load-success.bs.table":"onLoadSuccess","load-error.bs.table":"onLoadError","column-switch.bs.table":"onColumnSwitch","page-change.bs.table":"onPageChange","search.bs.table":"onSearch","toggle.bs.table":"onToggle","pre-body.bs.table":"onPreBody","post-body.bs.table":"onPostBody","post-header.bs.table":"onPostHeader","expand-row.bs.table":"onExpandRow","collapse-row.bs.table":"onCollapseRow","refresh-options.bs.table":"onRefreshOptions","reset-view.bs.table":"onResetView"},o.prototype.init=function(){this.initLocale(),this.initContainer(),this.initTable(),this.initHeader(),this.initData(),this.initFooter(),this.initToolbar(),this.initPagination(),this.initBody(),this.initSearchText(),this.initServer()},o.prototype.initLocale=function(){if(this.options.locale){var b=this.options.locale.split(/-|_/);b[0].toLowerCase(),b[1]&&b[1].toUpperCase(),a.fn.bootstrapTable.locales[this.options.locale]?a.extend(this.options,a.fn.bootstrapTable.locales[this.options.locale]):a.fn.bootstrapTable.locales[b.join("-")]?a.extend(this.options,a.fn.bootstrapTable.locales[b.join("-")]):a.fn.bootstrapTable.locales[b[0]]&&a.extend(this.options,a.fn.bootstrapTable.locales[b[0]])}},o.prototype.initContainer=function(){this.$container=a(['
','
',"top"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?'
':"",'
','
','
','
',this.options.formatLoadingMessage(),"
","
",'',"bottom"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?'
':"","
","
"].join("")),this.$container.insertAfter(this.$el),this.$tableContainer=this.$container.find(".fixed-table-container"),this.$tableHeader=this.$container.find(".fixed-table-header"),this.$tableBody=this.$container.find(".fixed-table-body"),this.$tableLoading=this.$container.find(".fixed-table-loading"),this.$tableFooter=this.$container.find(".fixed-table-footer"),this.$toolbar=this.$container.find(".fixed-table-toolbar"),this.$pagination=this.$container.find(".fixed-table-pagination"),this.$tableBody.append(this.$el),this.$container.after('
'),this.$el.addClass(this.options.classes),this.options.striped&&this.$el.addClass("table-striped"),-1!==a.inArray("table-no-bordered",this.options.classes.split(" "))&&this.$tableContainer.addClass("table-no-bordered")},o.prototype.initTable=function(){var b=this,c=[],d=[];this.$header=this.$el.find(">thead"),this.$header.length||(this.$header=a("").appendTo(this.$el)),this.$header.find("tr").each(function(){var b=[];a(this).find("th").each(function(){b.push(a.extend({},{title:a(this).html(),"class":a(this).attr("class"),titleTooltip:a(this).attr("title"),rowspan:a(this).attr("rowspan")?+a(this).attr("rowspan"):void 0,colspan:a(this).attr("colspan")?+a(this).attr("colspan"):void 0},a(this).data()))}),c.push(b)}),a.isArray(this.options.columns[0])||(this.options.columns=[this.options.columns]),this.options.columns=a.extend(!0,[],c,this.options.columns),this.columns=[],f(this.options.columns),a.each(this.options.columns,function(c,d){a.each(d,function(d,e){e=a.extend({},o.COLUMN_DEFAULTS,e),"undefined"!=typeof e.fieldIndex&&(b.columns[e.fieldIndex]=e),b.options.columns[c][d]=e})}),this.options.data.length||(this.$el.find(">tbody>tr").each(function(){var c={};c._id=a(this).attr("id"),c._class=a(this).attr("class"),c._data=l(a(this).data()),a(this).find("td").each(function(d){var e=b.columns[d].field;c[e]=a(this).html(),c["_"+e+"_id"]=a(this).attr("id"),c["_"+e+"_class"]=a(this).attr("class"),c["_"+e+"_rowspan"]=a(this).attr("rowspan"),c["_"+e+"_title"]=a(this).attr("title"),c["_"+e+"_data"]=l(a(this).data())}),d.push(c)}),this.options.data=d)},o.prototype.initHeader=function(){var b=this,d={},e=[];this.header={fields:[],styles:[],classes:[],formatters:[],events:[],sorters:[],sortNames:[],cellStyles:[],searchables:[]},a.each(this.options.columns,function(f,g){e.push(""),0==f&&!b.options.cardView&&b.options.detailView&&e.push(c('
',b.options.columns.length)),a.each(g,function(a,f){var g="",h="",i="",j="",k=c(' class="%s"',f["class"]),l=(b.options.sortOrder||f.order,"px"),m=f.width;if(void 0===f.width||b.options.cardView||"string"==typeof f.width&&-1!==f.width.indexOf("%")&&(l="%"),f.width&&"string"==typeof f.width&&(m=f.width.replace("%","").replace("px","")),h=c("text-align: %s; ",f.halign?f.halign:f.align),i=c("text-align: %s; ",f.align),j=c("vertical-align: %s; ",f.valign),j+=c("width: %s; ",!f.checkbox&&!f.radio||m?m?m+l:void 0:"36px"),"undefined"!=typeof f.fieldIndex){if(b.header.fields[f.fieldIndex]=f.field,b.header.styles[f.fieldIndex]=i+j,b.header.classes[f.fieldIndex]=k,b.header.formatters[f.fieldIndex]=f.formatter,b.header.events[f.fieldIndex]=f.events,b.header.sorters[f.fieldIndex]=f.sorter,b.header.sortNames[f.fieldIndex]=f.sortName,b.header.cellStyles[f.fieldIndex]=f.cellStyle,b.header.searchables[f.fieldIndex]=f.searchable,!f.visible)return;if(b.options.cardView&&!f.cardVisible)return;d[f.field]=f}e.push(""),e.push(c('
',b.options.sortable&&f.sortable?"sortable both":"")),g=f.title,f.checkbox&&(!b.options.singleSelect&&b.options.checkboxHeader&&(g=''),b.header.stateField=f.field),f.radio&&(g="",b.header.stateField=f.field,b.options.singleSelect=!0),e.push(g),e.push("
"),e.push('
'),e.push("
"),e.push("")}),e.push("")}),this.$header.html(e.join("")),this.$header.find("th[data-field]").each(function(){a(this).data(d[a(this).data("field")])}),this.$container.off("click",".th-inner").on("click",".th-inner",function(c){var d=a(this);return d.closest(".bootstrap-table")[0]!==b.$container[0]?!1:void(b.options.sortable&&d.parent().data().sortable&&b.onSort(c))}),this.$header.children().children().off("keypress").on("keypress",function(c){if(b.options.sortable&&a(this).data().sortable){var d=c.keyCode||c.which;13==d&&b.onSort(c)}}),!this.options.showHeader||this.options.cardView?(this.$header.hide(),this.$tableHeader.hide(),this.$tableLoading.css("top",0)):(this.$header.show(),this.$tableHeader.show(),this.$tableLoading.css("top",this.$header.outerHeight()+1),this.getCaret()),this.$selectAll=this.$header.find('[name="btSelectAll"]'),this.$selectAll.off("click").on("click",function(){var c=a(this).prop("checked");b[c?"checkAll":"uncheckAll"](),b.updateSelected()})},o.prototype.initFooter=function(){!this.options.showFooter||this.options.cardView?this.$tableFooter.hide():this.$tableFooter.show()},o.prototype.initData=function(a,b){this.data="append"===b?this.data.concat(a):"prepend"===b?[].concat(a).concat(this.data):a||this.options.data,this.options.data="append"===b?this.options.data.concat(a):"prepend"===b?[].concat(a).concat(this.options.data):this.data,"server"!==this.options.sidePagination&&this.initSort()},o.prototype.initSort=function(){var b=this,c=this.options.sortName,d="desc"===this.options.sortOrder?-1:1,e=a.inArray(this.options.sortName,this.header.fields);-1!==e&&this.data.sort(function(f,g){b.header.sortNames[e]&&(c=b.header.sortNames[e]);var i=m(f,c,b.options.escape),j=m(g,c,b.options.escape),k=h(b.header,b.header.sorters[e],[i,j]);return void 0!==k?d*k:((void 0===i||null===i)&&(i=""),(void 0===j||null===j)&&(j=""),a.isNumeric(i)&&a.isNumeric(j)?(i=parseFloat(i),j=parseFloat(j),j>i?-1*d:d):i===j?0:("string"!=typeof i&&(i=i.toString()),-1===i.localeCompare(j)?-1*d:d))})},o.prototype.onSort=function(b){var c="keypress"===b.type?a(b.currentTarget):a(b.currentTarget).parent(),d=this.$header.find("th").eq(c.index());return this.$header.add(this.$header_).find("span.order").remove(),this.options.sortName===c.data("field")?this.options.sortOrder="asc"===this.options.sortOrder?"desc":"asc":(this.options.sortName=c.data("field"),this.options.sortOrder="asc"===c.data("order")?"desc":"asc"),this.trigger("sort",this.options.sortName,this.options.sortOrder),c.add(d).data("order",this.options.sortOrder),this.getCaret(),"server"===this.options.sidePagination?void this.initServer(this.options.silentSort):(this.initSort(),void this.initBody())},o.prototype.initToolbar=function(){var b,d,f=this,g=[],i=0,j=0;this.$toolbar.find(".bars").children().length&&a("body").append(a(this.options.toolbar)),this.$toolbar.html(""),("string"==typeof this.options.toolbar||"object"==typeof this.options.toolbar)&&a(c('
',this.options.toolbarAlign)).appendTo(this.$toolbar).append(a(this.options.toolbar)),g=[c('
',this.options.buttonsAlign,this.options.buttonsAlign)],"string"==typeof this.options.icons&&(this.options.icons=h(null,this.options.icons)),this.options.showPaginationSwitch&&g.push(c('"),this.options.showRefresh&&g.push(c('"),this.options.showToggle&&g.push(c('"),this.options.showColumns&&(g.push(c('
',this.options.formatColumns()),'",'","
")),g.push("
"),(this.showToolbar||g.length>2)&&this.$toolbar.append(g.join("")),this.options.showPaginationSwitch&&this.$toolbar.find('button[name="paginationSwitch"]').off("click").on("click",a.proxy(this.togglePagination,this)),this.options.showRefresh&&this.$toolbar.find('button[name="refresh"]').off("click").on("click",a.proxy(this.refresh,this)),this.options.showToggle&&this.$toolbar.find('button[name="toggle"]').off("click").on("click",function(){f.toggleView()}),this.options.showColumns&&(b=this.$toolbar.find(".keep-open"),j<=this.options.minimumCountColumns&&b.find("input").prop("disabled",!0),b.find("li").off("click").on("click",function(a){a.stopImmediatePropagation()}),b.find("input").off("click").on("click",function(){var b=a(this);f.toggleColumn(e(f.columns,a(this).data("field")),b.prop("checked"),!1),f.trigger("column-switch",a(this).data("field"),b.prop("checked"))})),this.options.search&&(g=[],g.push('"),this.$toolbar.append(g.join("")),d=this.$toolbar.find(".search input"),d.off("keyup drop").on("keyup drop",function(a){f.options.searchOnEnterKey&&13!==a.keyCode||(clearTimeout(i),i=setTimeout(function(){f.onSearch(a)},f.options.searchTimeOut))}),n()&&d.off("mouseup").on("mouseup",function(a){clearTimeout(i),i=setTimeout(function(){f.onSearch(a)},f.options.searchTimeOut)}))},o.prototype.onSearch=function(b){var c=a.trim(a(b.currentTarget).val());this.options.trimOnSearch&&a(b.currentTarget).val()!==c&&a(b.currentTarget).val(c),c!==this.searchText&&(this.searchText=c,this.options.searchText=c,this.options.pageNumber=1,this.initSearch(),this.updatePagination(),this.trigger("search",c))},o.prototype.initSearch=function(){var b=this;if("server"!==this.options.sidePagination){var c=this.searchText&&this.searchText.toLowerCase(),d=a.isEmptyObject(this.filterColumns)?null:this.filterColumns;this.data=d?a.grep(this.options.data,function(b){for(var c in d)if(a.isArray(d[c])){if(-1===a.inArray(b[c],d[c]))return!1}else if(b[c]!==d[c])return!1;return!0}):this.options.data,this.data=c?a.grep(this.data,function(d,f){for(var g in d){g=a.isNumeric(g)?parseInt(g,10):g;var i=d[g],j=b.columns[e(b.columns,g)],k=a.inArray(g,b.header.fields);j&&j.searchFormatter&&(i=h(j,b.header.formatters[k],[i,d,f],i));var l=a.inArray(g,b.header.fields);if(-1!==l&&b.header.searchables[l]&&("string"==typeof i||"number"==typeof i))if(b.options.strictSearch){if((i+"").toLowerCase()===c)return!0}else if(-1!==(i+"").toLowerCase().indexOf(c))return!0}return!1}):this.data}},o.prototype.initPagination=function(){if(!this.options.pagination)return void this.$pagination.hide();this.$pagination.show();var b,d,e,f,g,h,i,j,k,l=this,m=[],n=!1,o=this.getData();if("server"!==this.options.sidePagination&&(this.options.totalRows=o.length),this.totalPages=0,this.options.totalRows){if(this.options.pageSize===this.options.formatAllRows())this.options.pageSize=this.options.totalRows,n=!0;else if(this.options.pageSize===this.options.totalRows){var p="string"==typeof this.options.pageList?this.options.pageList.replace("[","").replace("]","").replace(/ /g,"").toLowerCase().split(","):this.options.pageList;a.inArray(this.options.formatAllRows().toLowerCase(),p)>-1&&(n=!0)}this.totalPages=~~((this.options.totalRows-1)/this.options.pageSize)+1,this.options.totalPages=this.totalPages}if(this.totalPages>0&&this.options.pageNumber>this.totalPages&&(this.options.pageNumber=this.totalPages),this.pageFrom=(this.options.pageNumber-1)*this.options.pageSize+1,this.pageTo=this.options.pageNumber*this.options.pageSize,this.pageTo>this.options.totalRows&&(this.pageTo=this.options.totalRows),m.push('
','',this.options.onlyInfoPagination?this.options.formatDetailPagination(this.options.totalRows):this.options.formatShowingRows(this.pageFrom,this.pageTo,this.options.totalRows),""),!this.options.onlyInfoPagination){m.push('');var q=[c('',"top"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?"dropdown":"dropup"),'",'"),m.push(this.options.formatRecordsPerPage(q.join(""))),m.push(""),m.push("
",'")}this.$pagination.html(m.join("")),this.options.onlyInfoPagination||(f=this.$pagination.find(".page-list a"),g=this.$pagination.find(".page-first"),h=this.$pagination.find(".page-pre"),i=this.$pagination.find(".page-next"),j=this.$pagination.find(".page-last"),k=this.$pagination.find(".page-number"),this.options.smartDisplay&&(this.totalPages<=1&&this.$pagination.find("div.pagination").hide(),(r.length<2||this.options.totalRows<=r[0])&&this.$pagination.find("span.page-list").hide(),this.$pagination[this.getData().length?"show":"hide"]()),n&&(this.options.pageSize=this.options.formatAllRows()),f.off("click").on("click",a.proxy(this.onPageListChange,this)),g.off("click").on("click",a.proxy(this.onPageFirst,this)),h.off("click").on("click",a.proxy(this.onPagePre,this)),i.off("click").on("click",a.proxy(this.onPageNext,this)),j.off("click").on("click",a.proxy(this.onPageLast,this)),k.off("click").on("click",a.proxy(this.onPageNumber,this)))},o.prototype.updatePagination=function(b){b&&a(b.currentTarget).hasClass("disabled")||(this.options.maintainSelected||this.resetRows(),this.initPagination(),"server"===this.options.sidePagination?this.initServer():this.initBody(),this.trigger("page-change",this.options.pageNumber,this.options.pageSize))},o.prototype.onPageListChange=function(b){var c=a(b.currentTarget);c.parent().addClass("active").siblings().removeClass("active"),this.options.pageSize=c.text().toUpperCase()===this.options.formatAllRows().toUpperCase()?this.options.formatAllRows():+c.text(),this.$toolbar.find(".page-size").text(this.options.pageSize),this.updatePagination(b)},o.prototype.onPageFirst=function(a){this.options.pageNumber=1,this.updatePagination(a)},o.prototype.onPagePre=function(a){this.options.pageNumber-1==0?this.options.pageNumber=this.options.totalPages:this.options.pageNumber--,this.updatePagination(a)},o.prototype.onPageNext=function(a){this.options.pageNumber+1>this.options.totalPages?this.options.pageNumber=1:this.options.pageNumber++,this.updatePagination(a)},o.prototype.onPageLast=function(a){this.options.pageNumber=this.totalPages,this.updatePagination(a)},o.prototype.onPageNumber=function(b){this.options.pageNumber!==+a(b.currentTarget).text()&&(this.options.pageNumber=+a(b.currentTarget).text(),this.updatePagination(b))},o.prototype.initBody=function(b){var f=this,g=[],i=this.getData();this.trigger("pre-body",i),this.$body=this.$el.find(">tbody"),this.$body.length||(this.$body=a("").appendTo(this.$el)),this.options.pagination&&"server"!==this.options.sidePagination||(this.pageFrom=1,this.pageTo=i.length);for(var k=this.pageFrom-1;k"),this.options.cardView&&g.push(c('',this.header.fields.length)),!this.options.cardView&&this.options.detailView&&g.push("",'',c('',this.options.iconsPrefix,this.options.icons.detailOpen),"",""),a.each(this.header.fields,function(b,i){var j="",l=m(n,i,f.options.escape),q="",r={},s="",t=f.header.classes[b],u="",v="",w="",x=f.columns[e(f.columns,i)];if(x.visible){if(o=c('style="%s"',p.concat(f.header.styles[b]).join("; ")),l=h(x,f.header.formatters[b],[l,n,k],l),n["_"+i+"_id"]&&(s=c(' id="%s"',n["_"+i+"_id"])),n["_"+i+"_class"]&&(t=c(' class="%s"',n["_"+i+"_class"])),n["_"+i+"_rowspan"]&&(v=c(' rowspan="%s"',n["_"+i+"_rowspan"])),n["_"+i+"_title"]&&(w=c(' title="%s"',n["_"+i+"_title"])),r=h(f.header,f.header.cellStyles[b],[l,n,k],r),r.classes&&(t=c(' class="%s"',r.classes)),r.css){var y=[];for(var z in r.css)y.push(z+": "+r.css[z]);o=c('style="%s"',y.concat(f.header.styles[b]).join("; "))}n["_"+i+"_data"]&&!a.isEmptyObject(n["_"+i+"_data"])&&a.each(n["_"+i+"_data"],function(a,b){"index"!==a&&(u+=c(' data-%s="%s"',a,b))}),x.checkbox||x.radio?(q=x.checkbox?"checkbox":q,q=x.radio?"radio":q,j=[c(f.options.cardView?'
':'',x["class"]||""),"",f.header.formatters[b]&&"string"==typeof l?l:"",f.options.cardView?"
":""].join(""),n[f.header.stateField]=l===!0||l&&l.checked):(l="undefined"==typeof l||null===l?f.options.undefinedText:l,j=f.options.cardView?['
',f.options.showHeader?c('%s',o,d(f.columns,"field","title",i)):"",c('%s',l),"
"].join(""):[c("",s,t,o,u,v,w),l,""].join(""),f.options.cardView&&f.options.smartDisplay&&""===l&&(j='
')),g.push(j)}}),this.options.cardView&&g.push(""),g.push("")}g.length||g.push('',c('%s',this.$header.find("th").length,this.options.formatNoMatches()),""),this.$body.html(g.join("")),b||this.scrollTo(0),this.$body.find("> tr[data-index] > td").off("click dblclick").on("click dblclick",function(b){var d=a(this),g=d.parent(),h=f.data[g.data("index")],i=d[0].cellIndex,j=f.header.fields[f.options.detailView&&!f.options.cardView?i-1:i],k=f.columns[e(f.columns,j)],l=m(h,j,f.options.escape);if(!d.find(".detail-icon").length&&(f.trigger("click"===b.type?"click-cell":"dbl-click-cell",j,l,h,d),f.trigger("click"===b.type?"click-row":"dbl-click-row",h,g),"click"===b.type&&f.options.clickToSelect&&k.clickToSelect)){var n=g.find(c('[name="%s"]',f.options.selectItemName));n.length&&n[0].click()}}),this.$body.find("> tr[data-index] > td > .detail-icon").off("click").on("click",function(){var b=a(this),d=b.parent().parent(),e=d.data("index"),g=i[e];if(d.next().is("tr.detail-view"))b.find("i").attr("class",c("%s %s",f.options.iconsPrefix,f.options.icons.detailOpen)),d.next().remove(),f.trigger("collapse-row",e,g);else{b.find("i").attr("class",c("%s %s",f.options.iconsPrefix,f.options.icons.detailClose)),d.after(c('',d.find("td").length));var j=d.next().find("td"),k=h(f.options,f.options.detailFormatter,[e,g,j],"");1===j.length&&j.append(k),f.trigger("expand-row",e,g,j)}f.resetView()}),this.$selectItem=this.$body.find(c('[name="%s"]',this.options.selectItemName)),this.$selectItem.off("click").on("click",function(b){b.stopImmediatePropagation();var c=a(this),d=c.prop("checked"),e=f.data[c.data("index")];f.options.maintainSelected&&a(this).is(":radio")&&a.each(f.options.data,function(a,b){b[f.header.stateField]=!1}),e[f.header.stateField]=d,f.options.singleSelect&&(f.$selectItem.not(this).each(function(){f.data[a(this).data("index")][f.header.stateField]=!1}),f.$selectItem.filter(":checked").not(this).prop("checked",!1)),f.updateSelected(),f.trigger(d?"check":"uncheck",e,c)}),a.each(this.header.events,function(b,c){if(c){"string"==typeof c&&(c=h(null,c));var d=f.header.fields[b],e=a.inArray(d,f.getVisibleFields());f.options.detailView&&!f.options.cardView&&(e+=1);for(var g in c)f.$body.find(">tr:not(.no-records-found)").each(function(){var b=a(this),h=b.find(f.options.cardView?".card-view":"td").eq(e),i=g.indexOf(" "),j=g.substring(0,i),k=g.substring(i+1),l=c[g];h.find(k).off(j).on(j,function(a){var c=b.data("index"),e=f.data[c],g=e[d];l.apply(this,[a,g,e,c])})})}}),this.updateSelected(),this.resetView(),this.trigger("post-body")},o.prototype.initServer=function(b,c){var d,e=this,f={},g={ +searchText:this.searchText,sortName:this.options.sortName,sortOrder:this.options.sortOrder};this.options.pagination&&(g.pageSize=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize,g.pageNumber=this.options.pageNumber),(this.options.url||this.options.ajax)&&("limit"===this.options.queryParamsType&&(g={search:g.searchText,sort:g.sortName,order:g.sortOrder},this.options.pagination&&(g.limit=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize,g.offset=this.options.pageSize===this.options.formatAllRows()?0:this.options.pageSize*(this.options.pageNumber-1))),a.isEmptyObject(this.filterColumnsPartial)||(g.filter=JSON.stringify(this.filterColumnsPartial,null)),f=h(this.options,this.options.queryParams,[g],f),a.extend(f,c||{}),f!==!1&&(b||this.$tableLoading.show(),d=a.extend({},h(null,this.options.ajaxOptions),{type:this.options.method,url:this.options.url,data:"application/json"===this.options.contentType&&"post"===this.options.method?JSON.stringify(f):f,cache:this.options.cache,contentType:this.options.contentType,dataType:this.options.dataType,success:function(a){a=h(e.options,e.options.responseHandler,[a],a),e.load(a),e.trigger("load-success",a),b||e.$tableLoading.hide()},error:function(a){e.trigger("load-error",a.status,a),b||e.$tableLoading.hide()}}),this.options.ajax?h(this,this.options.ajax,[d],null):a.ajax(d)))},o.prototype.initSearchText=function(){if(this.options.search&&""!==this.options.searchText){var a=this.$toolbar.find(".search input");a.val(this.options.searchText),this.onSearch({currentTarget:a})}},o.prototype.getCaret=function(){var b=this;a.each(this.$header.find("th"),function(c,d){a(d).find(".sortable").removeClass("desc asc").addClass(a(d).data("field")===b.options.sortName?b.options.sortOrder:"both")})},o.prototype.updateSelected=function(){var b=this.$selectItem.filter(":enabled").length&&this.$selectItem.filter(":enabled").length===this.$selectItem.filter(":enabled").filter(":checked").length;this.$selectAll.add(this.$selectAll_).prop("checked",b),this.$selectItem.each(function(){a(this).closest("tr")[a(this).prop("checked")?"addClass":"removeClass"]("selected")})},o.prototype.updateRows=function(){var b=this;this.$selectItem.each(function(){b.data[a(this).data("index")][b.header.stateField]=a(this).prop("checked")})},o.prototype.resetRows=function(){var b=this;a.each(this.data,function(a,c){b.$selectAll.prop("checked",!1),b.$selectItem.prop("checked",!1),b.header.stateField&&(c[b.header.stateField]=!1)})},o.prototype.trigger=function(b){var c=Array.prototype.slice.call(arguments,1);b+=".bs.table",this.options[o.EVENTS[b]].apply(this.options,c),this.$el.trigger(a.Event(b),c),this.options.onAll(b,c),this.$el.trigger(a.Event("all.bs.table"),[b,c])},o.prototype.resetHeader=function(){clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(a.proxy(this.fitHeader,this),this.$el.is(":hidden")?100:0)},o.prototype.fitHeader=function(){var b,d,e,f,h=this;if(h.$el.is(":hidden"))return void(h.timeoutId_=setTimeout(a.proxy(h.fitHeader,h),100));if(b=this.$tableBody.get(0),d=b.scrollWidth>b.clientWidth&&b.scrollHeight>b.clientHeight+this.$header.outerHeight()?g():0,this.$el.css("margin-top",-this.$header.outerHeight()),e=a(":focus"),e.length>0){var i=e.parents("th");if(i.length>0){var j=i.attr("data-field");if(void 0!==j){var k=this.$header.find("[data-field='"+j+"']");k.length>0&&k.find(":input").addClass("focus-temp")}}}this.$header_=this.$header.clone(!0,!0),this.$selectAll_=this.$header_.find('[name="btSelectAll"]'),this.$tableHeader.css({"margin-right":d}).find("table").css("width",this.$el.outerWidth()).html("").attr("class",this.$el.attr("class")).append(this.$header_),f=a(".focus-temp:visible:eq(0)"),f.length>0&&(f.focus(),this.$header.find(".focus-temp").removeClass("focus-temp")),this.$header.find("th[data-field]").each(function(){h.$header_.find(c('th[data-field="%s"]',a(this).data("field"))).data(a(this).data())});var l=this.getVisibleFields();this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(b){var d=a(this),e=b;h.options.detailView&&!h.options.cardView&&(0===b&&h.$header_.find("th.detail").find(".fht-cell").width(d.innerWidth()),e=b-1),h.$header_.find(c('th[data-field="%s"]',l[e])).find(".fht-cell").width(d.innerWidth())}),this.$tableBody.off("scroll").on("scroll",function(){h.$tableHeader.scrollLeft(a(this).scrollLeft()),h.options.showFooter&&!h.options.cardView&&h.$tableFooter.scrollLeft(a(this).scrollLeft())}),h.trigger("post-header")},o.prototype.resetFooter=function(){var b=this,d=b.getData(),e=[];this.options.showFooter&&!this.options.cardView&&(!this.options.cardView&&this.options.detailView&&e.push('
 
'),a.each(this.columns,function(a,f){var g="",i="",j=c(' class="%s"',f["class"]);f.visible&&(!b.options.cardView||f.cardVisible)&&(g=c("text-align: %s; ",f.falign?f.falign:f.align),i=c("vertical-align: %s; ",f.valign),e.push(""),e.push('
'),e.push(h(f,f.footerFormatter,[d]," ")||" "),e.push("
"),e.push('
'),e.push("
"),e.push(""))}),this.$tableFooter.find("tr").html(e.join("")),clearTimeout(this.timeoutFooter_),this.timeoutFooter_=setTimeout(a.proxy(this.fitFooter,this),this.$el.is(":hidden")?100:0))},o.prototype.fitFooter=function(){var b,c,d;return clearTimeout(this.timeoutFooter_),this.$el.is(":hidden")?void(this.timeoutFooter_=setTimeout(a.proxy(this.fitFooter,this),100)):(c=this.$el.css("width"),d=c>this.$tableBody.width()?g():0,this.$tableFooter.css({"margin-right":d}).find("table").css("width",c).attr("class",this.$el.attr("class")),b=this.$tableFooter.find("td"),void this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(c){var d=a(this);b.eq(c).find(".fht-cell").width(d.innerWidth())}))},o.prototype.toggleColumn=function(a,b,d){if(-1!==a&&(this.columns[a].visible=b,this.initHeader(),this.initSearch(),this.initPagination(),this.initBody(),this.options.showColumns)){var e=this.$toolbar.find(".keep-open input").prop("disabled",!1);d&&e.filter(c('[value="%s"]',a)).prop("checked",b),e.filter(":checked").length<=this.options.minimumCountColumns&&e.filter(":checked").prop("disabled",!0)}},o.prototype.toggleRow=function(a,b,d){-1!==a&&this.$body.find("undefined"!=typeof a?c('tr[data-index="%s"]',a):c('tr[data-uniqueid="%s"]',b))[d?"show":"hide"]()},o.prototype.getVisibleFields=function(){var b=this,c=[];return a.each(this.header.fields,function(a,d){var f=b.columns[e(b.columns,d)];f.visible&&c.push(d)}),c},o.prototype.resetView=function(a){var b=0;if(a&&a.height&&(this.options.height=a.height),this.$selectAll.prop("checked",this.$selectItem.length>0&&this.$selectItem.length===this.$selectItem.filter(":checked").length),this.options.height){var c=k(this.$toolbar),d=k(this.$pagination),e=this.options.height-c-d;this.$tableContainer.css("height",e+"px")}return this.options.cardView?(this.$el.css("margin-top","0"),void this.$tableContainer.css("padding-bottom","0")):(this.options.showHeader&&this.options.height?(this.$tableHeader.show(),this.resetHeader(),b+=this.$header.outerHeight()):(this.$tableHeader.hide(),this.trigger("post-header")),this.options.showFooter&&(this.resetFooter(),this.options.height&&(b+=this.$tableFooter.outerHeight()+1)),this.getCaret(),this.$tableContainer.css("padding-bottom",b+"px"),void this.trigger("reset-view"))},o.prototype.getData=function(b){return!this.searchText&&a.isEmptyObject(this.filterColumns)&&a.isEmptyObject(this.filterColumnsPartial)?b?this.options.data.slice(this.pageFrom-1,this.pageTo):this.options.data:b?this.data.slice(this.pageFrom-1,this.pageTo):this.data},o.prototype.load=function(b){var c=!1;"server"===this.options.sidePagination?(this.options.totalRows=b.total,c=b.fixedScroll,b=b[this.options.dataField]):a.isArray(b)||(c=b.fixedScroll,b=b.data),this.initData(b),this.initSearch(),this.initPagination(),this.initBody(c)},o.prototype.append=function(a){this.initData(a,"append"),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)},o.prototype.prepend=function(a){this.initData(a,"prepend"),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)},o.prototype.remove=function(b){var c,d,e=this.options.data.length;if(b.hasOwnProperty("field")&&b.hasOwnProperty("values")){for(c=e-1;c>=0;c--)d=this.options.data[c],d.hasOwnProperty(b.field)&&-1!==a.inArray(d[b.field],b.values)&&this.options.data.splice(c,1);e!==this.options.data.length&&(this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0))}},o.prototype.removeAll=function(){this.options.data.length>0&&(this.options.data.splice(0,this.options.data.length),this.initSearch(),this.initPagination(),this.initBody(!0))},o.prototype.getRowByUniqueId=function(a){var b,c,d,e=this.options.uniqueId,f=this.options.data.length,g=null;for(b=f-1;b>=0;b--){if(c=this.options.data[b],c.hasOwnProperty(e))d=c[e];else{if(!c._data.hasOwnProperty(e))continue;d=c._data[e]}if("string"==typeof d?a=a.toString():"number"==typeof d&&(Number(d)===d&&d%1===0?a=parseInt(a):d===Number(d)&&0!==d&&(a=parseFloat(a))),d===a){g=c;break}}return g},o.prototype.removeByUniqueId=function(a){var b=this.options.data.length,c=this.getRowByUniqueId(a);c&&this.options.data.splice(this.options.data.indexOf(c),1),b!==this.options.data.length&&(this.initSearch(),this.initPagination(),this.initBody(!0))},o.prototype.updateByUniqueId=function(b){var c;b.hasOwnProperty("id")&&b.hasOwnProperty("row")&&(c=a.inArray(this.getRowByUniqueId(b.id),this.options.data),-1!==c&&(a.extend(this.data[c],b.row),this.initSort(),this.initBody(!0)))},o.prototype.insertRow=function(a){a.hasOwnProperty("index")&&a.hasOwnProperty("row")&&(this.data.splice(a.index,0,a.row),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0))},o.prototype.updateRow=function(b){b.hasOwnProperty("index")&&b.hasOwnProperty("row")&&(a.extend(this.data[b.index],b.row),this.initSort(),this.initBody(!0))},o.prototype.showRow=function(a){(a.hasOwnProperty("index")||a.hasOwnProperty("uniqueId"))&&this.toggleRow(a.index,a.uniqueId,!0)},o.prototype.hideRow=function(a){(a.hasOwnProperty("index")||a.hasOwnProperty("uniqueId"))&&this.toggleRow(a.index,a.uniqueId,!1)},o.prototype.getRowsHidden=function(b){var c=a(this.$body[0]).children().filter(":hidden"),d=0;if(b)for(;dtr");if(this.options.detailView&&!this.options.cardView&&(g+=1),e=j.eq(f).find(">td").eq(g),!(0>f||0>g||f>=this.data.length)){for(c=f;f+h>c;c++)for(d=g;g+i>d;d++)j.eq(c).find(">td").eq(d).hide();e.attr("rowspan",h).attr("colspan",i).show()}},o.prototype.updateCell=function(a){a.hasOwnProperty("index")&&a.hasOwnProperty("field")&&a.hasOwnProperty("value")&&(this.data[a.index][a.field]=a.value,a.reinit!==!1&&(this.initSort(),this.initBody(!0)))},o.prototype.getOptions=function(){return this.options},o.prototype.getSelections=function(){var b=this;return a.grep(this.data,function(a){return a[b.header.stateField]})},o.prototype.getAllSelections=function(){var b=this;return a.grep(this.options.data,function(a){return a[b.header.stateField]})},o.prototype.checkAll=function(){this.checkAll_(!0)},o.prototype.uncheckAll=function(){this.checkAll_(!1)},o.prototype.checkInvert=function(){var b=this,c=b.$selectItem.filter(":enabled"),d=c.filter(":checked");c.each(function(){a(this).prop("checked",!a(this).prop("checked"))}),b.updateRows(),b.updateSelected(),b.trigger("uncheck-some",d),d=b.getSelections(),b.trigger("check-some",d)},o.prototype.checkAll_=function(a){var b;a||(b=this.getSelections()),this.$selectAll.add(this.$selectAll_).prop("checked",a),this.$selectItem.filter(":enabled").prop("checked",a),this.updateRows(),a&&(b=this.getSelections()),this.trigger(a?"check-all":"uncheck-all",b)},o.prototype.check=function(a){this.check_(!0,a)},o.prototype.uncheck=function(a){this.check_(!1,a)},o.prototype.check_=function(a,b){var d=this.$selectItem.filter(c('[data-index="%s"]',b)).prop("checked",a);this.data[b][this.header.stateField]=a,this.updateSelected(),this.trigger(a?"check":"uncheck",this.data[b],d)},o.prototype.checkBy=function(a){this.checkBy_(!0,a)},o.prototype.uncheckBy=function(a){this.checkBy_(!1,a)},o.prototype.checkBy_=function(b,d){if(d.hasOwnProperty("field")&&d.hasOwnProperty("values")){var e=this,f=[];a.each(this.options.data,function(g,h){if(!h.hasOwnProperty(d.field))return!1;if(-1!==a.inArray(h[d.field],d.values)){var i=e.$selectItem.filter(":enabled").filter(c('[data-index="%s"]',g)).prop("checked",b);h[e.header.stateField]=b,f.push(h),e.trigger(b?"check":"uncheck",h,i)}}),this.updateSelected(),this.trigger(b?"check-some":"uncheck-some",f)}},o.prototype.destroy=function(){this.$el.insertBefore(this.$container),a(this.options.toolbar).insertBefore(this.$el),this.$container.next().remove(),this.$container.remove(),this.$el.html(this.$el_.html()).css("margin-top","0").attr("class",this.$el_.attr("class")||"")},o.prototype.showLoading=function(){this.$tableLoading.show()},o.prototype.hideLoading=function(){this.$tableLoading.hide()},o.prototype.togglePagination=function(){this.options.pagination=!this.options.pagination;var a=this.$toolbar.find('button[name="paginationSwitch"] i');this.options.pagination?a.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchDown):a.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchUp),this.updatePagination()},o.prototype.refresh=function(a){a&&a.url&&(this.options.url=a.url,this.options.pageNumber=1),this.initServer(a&&a.silent,a&&a.query)},o.prototype.resetWidth=function(){this.options.showHeader&&this.options.height&&this.fitHeader(),this.options.showFooter&&this.fitFooter()},o.prototype.showColumn=function(a){this.toggleColumn(e(this.columns,a),!0,!0)},o.prototype.hideColumn=function(a){this.toggleColumn(e(this.columns,a),!1,!0)},o.prototype.getHiddenColumns=function(){return a.grep(this.columns,function(a){return!a.visible})},o.prototype.filterBy=function(b){this.filterColumns=a.isEmptyObject(b)?{}:b,this.options.pageNumber=1,this.initSearch(),this.updatePagination()},o.prototype.scrollTo=function(a){return"string"==typeof a&&(a="bottom"===a?this.$tableBody[0].scrollHeight:0),"number"==typeof a&&this.$tableBody.scrollTop(a),"undefined"==typeof a?this.$tableBody.scrollTop():void 0},o.prototype.getScrollPosition=function(){return this.scrollTo()},o.prototype.selectPage=function(a){a>0&&a<=this.options.totalPages&&(this.options.pageNumber=a,this.updatePagination())},o.prototype.prevPage=function(){this.options.pageNumber>1&&(this.options.pageNumber--,this.updatePagination())},o.prototype.nextPage=function(){this.options.pageNumber tr[data-index="%s"]',b));d.next().is("tr.detail-view")===(a?!1:!0)&&d.find("> td > .detail-icon").click()},o.prototype.expandRow=function(a){this.expandRow_(!0,a)},o.prototype.collapseRow=function(a){this.expandRow_(!1,a)},o.prototype.expandAllRows=function(b){if(b){var d=this.$body.find(c('> tr[data-index="%s"]',0)),e=this,f=null,g=!1,h=-1;if(d.next().is("tr.detail-view")?d.next().next().is("tr.detail-view")||(d.next().find(".detail-icon").click(),g=!0):(d.find("> td > .detail-icon").click(),g=!0),g)try{h=setInterval(function(){f=e.$body.find("tr.detail-view").last().find(".detail-icon"),f.length>0?f.click():clearInterval(h)},1)}catch(i){clearInterval(h)}}else for(var j=this.$body.children(),k=0;k2)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 3")}(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]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",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(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){return a(b.target).is(this)?b.handleObj.handler.apply(this,arguments):void 0}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.6",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a(f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.6",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")?(c.prop("checked")&&(a=!1),b.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==c.prop("type")&&(c.prop("checked")!==this.$element.hasClass("active")&&(a=!1),this.$element.toggleClass("active")),c.prop("checked",this.$element.hasClass("active")),a&&c.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target);d.hasClass("btn")||(d=d.closest(".btn")),b.call(d,"toggle"),a(c.target).is('input[type="radio"]')||a(c.target).is('input[type="checkbox"]')||c.preventDefault()}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",a.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.3.6",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(a){if(!/input|textarea/i.test(a.target.tagName)){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()}},c.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},c.prototype.getItemIndex=function(a){return this.$items=a.parent().children(".item"),this.$items.index(a||this.$active)},c.prototype.getItemForDirection=function(a,b){var c=this.getItemIndex(b),d="prev"==a&&0===c||"next"==a&&c==this.$items.length-1;if(d&&!this.options.wrap)return b;var e="prev"==a?-1:1,f=(c+e)%this.$items.length;return this.$items.eq(f)},c.prototype.to=function(a){var b=this,c=this.getItemIndex(this.$active=this.$element.find(".item.active"));return a>this.$items.length-1||0>a?void 0:this.sliding?this.$element.one("slid.bs.carousel",function(){b.to(a)}):c==a?this.pause().cycle():this.slide(a>c?"next":"prev",this.$items.eq(a))},c.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){return this.sliding?void 0:this.slide("next")},c.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},c.prototype.slide=function(b,d){var e=this.$element.find(".item.active"),f=d||this.getItemForDirection(b,e),g=this.interval,h="next"==b?"left":"right",i=this;if(f.hasClass("active"))return this.sliding=!1;var j=f[0],k=a.Event("slide.bs.carousel",{relatedTarget:j,direction:h});if(this.$element.trigger(k),!k.isDefaultPrevented()){if(this.sliding=!0,g&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var l=a(this.$indicators.children()[this.getItemIndex(f)]);l&&l.addClass("active")}var m=a.Event("slid.bs.carousel",{relatedTarget:j,direction:h});return a.support.transition&&this.$element.hasClass("slide")?(f.addClass(b),f[0].offsetWidth,e.addClass(h),f.addClass(h),e.one("bsTransitionEnd",function(){f.removeClass([b,h].join(" ")).addClass("active"),e.removeClass(["active",h].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger(m)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(e.removeClass("active"),f.addClass("active"),this.sliding=!1,this.$element.trigger(m)),g&&this.cycle(),this}};var d=a.fn.carousel;a.fn.carousel=b,a.fn.carousel.Constructor=c,a.fn.carousel.noConflict=function(){return a.fn.carousel=d,this};var e=function(c){var d,e=a(this),f=a(e.attr("data-target")||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""));if(f.hasClass("carousel")){var g=a.extend({},f.data(),e.data()),h=e.attr("data-slide-to");h&&(g.interval=!1),b.call(f,g),h&&f.data("bs.carousel").to(h),c.preventDefault()}};a(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var c=a(this);b.call(c,c.data())})})}(jQuery),+function(a){"use strict";function b(b){var c,d=b.attr("data-target")||(c=b.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"");return a(d)}function c(b){return this.each(function(){var c=a(this),e=c.data("bs.collapse"),f=a.extend({},d.DEFAULTS,c.data(),"object"==typeof b&&b);!e&&f.toggle&&/show|hide/.test(b)&&(f.toggle=!1),e||c.data("bs.collapse",e=new d(this,f)),"string"==typeof b&&e[b]()})}var d=function(b,c){this.$element=a(b),this.options=a.extend({},d.DEFAULTS,c),this.$trigger=a('[data-toggle="collapse"][href="#'+b.id+'"],[data-toggle="collapse"][data-target="#'+b.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};d.VERSION="3.3.6",d.TRANSITION_DURATION=350,d.DEFAULTS={toggle:!0},d.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},d.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(b=e.data("bs.collapse"),b&&b.transitioning))){var f=a.Event("show.bs.collapse");if(this.$element.trigger(f),!f.isDefaultPrevented()){e&&e.length&&(c.call(e,"hide"),b||e.data("bs.collapse",null));var g=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[g](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var h=function(){this.$element.removeClass("collapsing").addClass("collapse in")[g](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return h.call(this);var i=a.camelCase(["scroll",g].join("-"));this.$element.one("bsTransitionEnd",a.proxy(h,this)).emulateTransitionEnd(d.TRANSITION_DURATION)[g](this.$element[0][i])}}}},d.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 in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var e=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};return a.support.transition?void this.$element[c](0).one("bsTransitionEnd",a.proxy(e,this)).emulateTransitionEnd(d.TRANSITION_DURATION):e.call(this)}}},d.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},d.prototype.getParent=function(){return a(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(c,d){var e=a(d);this.addAriaAndCollapsedClass(b(e),e)},this)).end()},d.prototype.addAriaAndCollapsedClass=function(a,b){var c=a.hasClass("in");a.attr("aria-expanded",c),b.toggleClass("collapsed",!c).attr("aria-expanded",c)};var e=a.fn.collapse;a.fn.collapse=c,a.fn.collapse.Constructor=d,a.fn.collapse.noConflict=function(){return a.fn.collapse=e,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(d){var e=a(this);e.attr("data-target")||d.preventDefault();var f=b(e),g=f.data("bs.collapse"),h=g?"toggle":e.data();c.call(f,h)})}(jQuery),+function(a){"use strict";function b(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#[A-Za-z]/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}function c(c){c&&3===c.which||(a(e).remove(),a(f).each(function(){var d=a(this),e=b(d),f={relatedTarget:this};e.hasClass("open")&&(c&&"click"==c.type&&/input|textarea/i.test(c.target.tagName)&&a.contains(e[0],c.target)||(e.trigger(c=a.Event("hide.bs.dropdown",f)),c.isDefaultPrevented()||(d.attr("aria-expanded","false"),e.removeClass("open").trigger(a.Event("hidden.bs.dropdown",f)))))}))}function d(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new g(this)),"string"==typeof b&&d[b].call(c)})}var e=".dropdown-backdrop",f='[data-toggle="dropdown"]',g=function(b){a(b).on("click.bs.dropdown",this.toggle)};g.VERSION="3.3.6",g.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=b(e),g=f.hasClass("open");if(c(),!g){"ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(a(this)).on("click",c);var h={relatedTarget:this};if(f.trigger(d=a.Event("show.bs.dropdown",h)),d.isDefaultPrevented())return;e.trigger("focus").attr("aria-expanded","true"),f.toggleClass("open").trigger(a.Event("shown.bs.dropdown",h))}return!1}},g.prototype.keydown=function(c){if(/(38|40|27|32)/.test(c.which)&&!/input|textarea/i.test(c.target.tagName)){var d=a(this);if(c.preventDefault(),c.stopPropagation(),!d.is(".disabled, :disabled")){var e=b(d),g=e.hasClass("open");if(!g&&27!=c.which||g&&27==c.which)return 27==c.which&&e.find(f).trigger("focus"),d.trigger("click");var h=" li:not(.disabled):visible a",i=e.find(".dropdown-menu"+h);if(i.length){var j=i.index(c.target);38==c.which&&j>0&&j--,40==c.which&&jdocument.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&a?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!a?this.scrollbarWidth:""})},c.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},c.prototype.checkScrollbar=function(){var a=window.innerWidth;if(!a){var b=document.documentElement.getBoundingClientRect();a=b.right-Math.abs(b.left)}this.bodyIsOverflowing=document.body.clientWidth
',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},c.prototype.init=function(b,c,d){if(this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.$viewport=this.options.viewport&&a(a.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focusin",i="hover"==g?"mouseleave":"focusout";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},c.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},c.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusin"==b.type?"focus":"hover"]=!0),c.tip().hasClass("in")||"in"==c.hoverState?void(c.hoverState="in"):(clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?void(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show)):c.show())},c.prototype.isInStateTrue=function(){for(var a in this.inState)if(this.inState[a])return!0;return!1},c.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusout"==b.type?"focus":"hover"]=!1),c.isInStateTrue()?void 0:(clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?void(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide)):c.hide())},c.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);var d=a.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(b.isDefaultPrevented()||!d)return;var e=this,f=this.tip(),g=this.getUID(this.type);this.setContent(),f.attr("id",g),this.$element.attr("aria-describedby",g),this.options.animation&&f.addClass("fade");var h="function"==typeof this.options.placement?this.options.placement.call(this,f[0],this.$element[0]):this.options.placement,i=/\s?auto?\s?/i,j=i.test(h);j&&(h=h.replace(i,"")||"top"),f.detach().css({top:0,left:0,display:"block"}).addClass(h).data("bs."+this.type,this),this.options.container?f.appendTo(this.options.container):f.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var k=this.getPosition(),l=f[0].offsetWidth,m=f[0].offsetHeight;if(j){var n=h,o=this.getPosition(this.$viewport);h="bottom"==h&&k.bottom+m>o.bottom?"top":"top"==h&&k.top-mo.width?"left":"left"==h&&k.left-lg.top+g.height&&(e.top=g.top+g.height-i)}else{var j=b.left-f,k=b.left+f+c;jg.right&&(e.left=g.left+g.width-k)}return e},c.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||("function"==typeof c.title?c.title.call(b[0]):c.title)},c.prototype.getUID=function(a){do a+=~~(1e6*Math.random());while(document.getElementById(a));return a},c.prototype.tip=function(){if(!this.$tip&&(this.$tip=a(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},c.prototype.enable=function(){this.enabled=!0},c.prototype.disable=function(){this.enabled=!1},c.prototype.toggleEnabled=function(){this.enabled=!this.enabled},c.prototype.toggle=function(b){var c=this;b&&(c=a(b.currentTarget).data("bs."+this.type),c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c))),b?(c.inState.click=!c.inState.click,c.isInStateTrue()?c.enter(c):c.leave(c)):c.tip().hasClass("in")?c.leave(c):c.enter(c)},c.prototype.destroy=function(){var a=this;clearTimeout(this.timeout),this.hide(function(){a.$element.off("."+a.type).removeData("bs."+a.type),a.$tip&&a.$tip.detach(),a.$tip=null,a.$arrow=null,a.$viewport=null})};var d=a.fn.tooltip;a.fn.tooltip=b,a.fn.tooltip.Constructor=c,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=d,this}}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof b&&b;(e||!/destroy|hide/.test(b))&&(e||d.data("bs.popover",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");c.VERSION="3.3.6",c.DEFAULTS=a.extend({},a.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:''}),c.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.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").children().detach().end()[this.options.html?"string"==typeof c?"html":"append":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},c.prototype.hasContent=function(){return this.getTitle()||this.getContent()},c.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)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var d=a.fn.popover;a.fn.popover=b,a.fn.popover.Constructor=c,a.fn.popover.noConflict=function(){return a.fn.popover=d,this}}(jQuery),+function(a){"use strict";function b(c,d){this.$body=a(document.body),this.$scrollElement=a(a(c).is(document.body)?window:c),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",a.proxy(this.process,this)),this.refresh(),this.process()}function c(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]()})}b.VERSION="3.3.6",b.DEFAULTS={offset:10},b.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},b.prototype.refresh=function(){var b=this,c="offset",d=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),a.isWindow(this.$scrollElement[0])||(c="position",d=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var b=a(this),e=b.data("target")||b.attr("href"),f=/^#./.test(e)&&a(e);return f&&f.length&&f.is(":visible")&&[[f[c]().top+d,e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){b.offsets.push(this[0]),b.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.getScrollHeight(),d=this.options.offset+c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(this.scrollHeight!=c&&this.refresh(),b>=d)return g!=(a=f[f.length-1])&&this.activate(a);if(g&&b=e[a]&&(void 0===e[a+1]||b .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).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(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.6",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return c>e?"top":!1;if("bottom"==this.affixed)return null!=c?e+this.unpin<=f.top?!1:"bottom":a-d>=e+g?!1:"bottom";var h=null==this.affixed,i=h?e:f.top,j=h?g:b;return null!=c&&c>=e?"top":null!=d&&i+j>=a-d?"bottom":!1},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=Math.max(a(document).height(),a(document.body).height());"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery); \ No newline at end of file diff --git a/src/static/js/dataTables.bootstrap.min.js b/src/static/js/dataTables.bootstrap.min.js new file mode 100644 index 00000000..2d824c8f --- /dev/null +++ b/src/static/js/dataTables.bootstrap.min.js @@ -0,0 +1,8 @@ +/*! + DataTables Bootstrap 3 integration + ©2011-2015 SpryMedia Ltd - datatables.net/license +*/ +(function(b){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(a){return b(a,window,document)}):"object"===typeof exports?module.exports=function(a,d){a||(a=window);if(!d||!d.fn.dataTable)d=require("datatables.net")(a,d).$;return b(d,a,a.document)}:b(jQuery,window,document)})(function(b,a,d){var f=b.fn.dataTable;b.extend(!0,f.defaults,{dom:"<'row'<'col-sm-6'l><'col-sm-6'f>><'row'<'col-sm-12'tr>><'row'<'col-sm-5'i><'col-sm-7'p>>",renderer:"bootstrap"});b.extend(f.ext.classes, +{sWrapper:"dataTables_wrapper form-inline dt-bootstrap",sFilterInput:"form-control input-sm",sLengthSelect:"form-control input-sm",sProcessing:"dataTables_processing panel panel-default"});f.ext.renderer.pageButton.bootstrap=function(a,h,r,m,j,n){var o=new f.Api(a),s=a.oClasses,k=a.oLanguage.oPaginate,t=a.oLanguage.oAria.paginate||{},e,g,p=0,q=function(d,f){var l,h,i,c,m=function(a){a.preventDefault();!b(a.currentTarget).hasClass("disabled")&&o.page()!=a.data.action&&o.page(a.data.action).draw("page")}; +l=0;for(h=f.length;l",{"class":s.sPageButton+" "+g,id:0===r&&"string"===typeof c?a.sTableId+"_"+c:null}).append(b("",{href:"#", +"aria-controls":a.sTableId,"aria-label":t[c],"data-dt-idx":p,tabindex:a.iTabIndex}).html(e)).appendTo(d),a.oApi._fnBindAction(i,{action:c},m),p++)}},i;try{i=b(h).find(d.activeElement).data("dt-idx")}catch(u){}q(b(h).empty().html('