diff --git a/crawlab/config/__init__.py b/crawlab/config/__init__.py
index 609b69de..4d2d8d10 100644
--- a/crawlab/config/__init__.py
+++ b/crawlab/config/__init__.py
@@ -1,10 +1,3 @@
# encoding: utf-8
-import os
-
-run_env = os.environ.get("RUNENV", "local")
-
-if run_env == "local": # 加载本地配置
- from config.config_local import *
-else:
- from config.config import *
+from config.config import *
diff --git a/crawlab/config/config_local.py b/crawlab/config/config_local.py
deleted file mode 100644
index 08ab113c..00000000
--- a/crawlab/config/config_local.py
+++ /dev/null
@@ -1,55 +0,0 @@
-import os
-
-BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
-# 爬虫源码路径
-PROJECT_SOURCE_FILE_FOLDER = os.path.join(BASE_DIR, "spiders")
-
-# 配置python虚拟环境的路径
-PYTHON_ENV_PATH = '/Users/yeqing/.pyenv/shims/python'
-
-# 爬虫部署路径
-# PROJECT_DEPLOY_FILE_FOLDER = '../deployfile'
-PROJECT_DEPLOY_FILE_FOLDER = '/var/crawlab'
-
-# 爬虫日志路径
-PROJECT_LOGS_FOLDER = '../deployfile/logs'
-
-# 打包临时文件夹
-PROJECT_TMP_FOLDER = '/tmp'
-
-# Celery中间者URL
-BROKER_URL = 'redis://127.0.0.1:6379/0'
-
-# Celery后台URL
-CELERY_RESULT_BACKEND = 'mongodb://127.0.0.1:27017/'
-
-# Celery MongoDB设置
-CELERY_MONGODB_BACKEND_SETTINGS = {
- 'database': 'crawlab_test',
- 'taskmeta_collection': 'tasks_celery',
-}
-
-# Celery时区
-CELERY_TIMEZONE = 'Asia/Shanghai'
-
-# 是否启用UTC
-CELERY_ENABLE_UTC = True
-
-# Celery Scheduler Redis URL
-CELERY_BEAT_SCHEDULER = 'utils.redisbeat.RedisScheduler'
-CELERY_REDIS_SCHEDULER_URL = 'redis://localhost:6379'
-CELERY_REDIS_SCHEDULER_KEY = 'celery:beat:order_tasks'
-
-# flower variables
-FLOWER_API_ENDPOINT = 'http://localhost:5555/api'
-
-# MongoDB 变量
-MONGO_HOST = '127.0.0.1'
-MONGO_PORT = 27017
-MONGO_DB = 'crawlab_test'
-
-# Flask 变量
-DEBUG = True
-FLASK_HOST = '127.0.0.1'
-FLASK_PORT = 8000
diff --git a/frontend/src/api/login 2.js b/frontend/src/api/login 2.js
deleted file mode 100644
index 4699f07e..00000000
--- a/frontend/src/api/login 2.js
+++ /dev/null
@@ -1,27 +0,0 @@
-import request from '@/utils/request'
-
-export function login (username, password) {
- return request({
- url: '/user/login',
- method: 'post',
- data: {
- username,
- password
- }
- })
-}
-
-export function getInfo (token) {
- return request({
- url: '/user/info',
- method: 'get',
- params: { token }
- })
-}
-
-export function logout () {
- return request({
- url: '/user/logout',
- method: 'post'
- })
-}
diff --git a/frontend/src/api/request 2.js b/frontend/src/api/request 2.js
deleted file mode 100644
index 6ec95917..00000000
--- a/frontend/src/api/request 2.js
+++ /dev/null
@@ -1,46 +0,0 @@
-import axios from 'axios'
-
-let baseUrl = 'http://localhost:8000/api'
-if (process.env.NODE_ENV === 'production') {
- baseUrl = 'http://139.129.230.98:8000/api'
-}
-// const baseUrl = process.env.API_BASE_URL || 'http://localhost:8000/api'
-
-const request = (method, path, params, data) => {
- return new Promise((resolve, reject) => {
- const url = `${baseUrl}${path}`
- axios({
- method,
- url,
- params,
- data
- })
- .then(resolve)
- .catch(reject)
- })
-}
-
-const get = (path, params) => {
- return request('GET', path, params)
-}
-
-const post = (path, data) => {
- return request('POST', path, {}, data)
-}
-
-const put = (path, data) => {
- return request('PUT', path, {}, data)
-}
-
-const del = (path, data) => {
- return request('DELETE', path)
-}
-
-export default {
- baseUrl,
- request,
- get,
- post,
- put,
- delete: del
-}
diff --git a/frontend/src/api/request.js b/frontend/src/api/request.js
index 6ec95917..53603af8 100644
--- a/frontend/src/api/request.js
+++ b/frontend/src/api/request.js
@@ -4,6 +4,7 @@ let baseUrl = 'http://localhost:8000/api'
if (process.env.NODE_ENV === 'production') {
baseUrl = 'http://139.129.230.98:8000/api'
}
+// console.log(process.env)
// const baseUrl = process.env.API_BASE_URL || 'http://localhost:8000/api'
const request = (method, path, params, data) => {
diff --git a/frontend/src/components/Stats/MetricCard.vue b/frontend/src/components/Stats/MetricCard.vue
new file mode 100644
index 00000000..14658dbd
--- /dev/null
+++ b/frontend/src/components/Stats/MetricCard.vue
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+
+
+
+ {{value}}
+
+
+
+
+
+
+
+
diff --git a/frontend/src/components/Stats/SpiderStats.vue b/frontend/src/components/Stats/SpiderStats.vue
new file mode 100644
index 00000000..6abb9527
--- /dev/null
+++ b/frontend/src/components/Stats/SpiderStats.vue
@@ -0,0 +1,175 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{$t('Tasks by Status')}}
+
+
+
+
+
+ {{$t('Daily Tasks')}}
+
+
+
+
+
+
+
+
+ {{$t('Tasks by Status')}}
+
+
+
+
+
+ {{$t('Tasks by Status')}}
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/i18n/zh.js b/frontend/src/i18n/zh.js
index 13baddc7..d56cf69a 100644
--- a/frontend/src/i18n/zh.js
+++ b/frontend/src/i18n/zh.js
@@ -18,6 +18,7 @@ export default {
'Log': '日志',
'Results': '结果',
'Environment': '环境',
+ 'Analytics': '分析',
// 选择
Spider: '爬虫',
diff --git a/frontend/src/store/modules/spider.js b/frontend/src/store/modules/spider.js
index 1e18ecde..bb7d948f 100644
--- a/frontend/src/store/modules/spider.js
+++ b/frontend/src/store/modules/spider.js
@@ -14,7 +14,16 @@ const state = {
importForm: {
url: '',
type: 'github'
- }
+ },
+
+ // spider overview stats
+ overviewStats: {},
+
+ // spider status stats
+ statusStats: [],
+
+ // spider daily stats
+ dailyStats: []
}
const getters = {}
@@ -31,6 +40,15 @@ const mutations = {
},
SET_IMPORT_FORM (state, value) {
state.importForm = value
+ },
+ SET_OVERVIEW_STATS (state, value) {
+ state.overviewStats = value
+ },
+ SET_STATUS_STATS (state, value) {
+ state.statusStats = value
+ },
+ SET_DAILY_STATS (state, value) {
+ state.dailyStats = value
}
}
@@ -138,6 +156,14 @@ const actions = {
.then(response => {
console.log(response)
})
+ },
+ getSpiderStats ({ state, commit }) {
+ return request.get('/stats/get_spider_stats?spider_id=' + state.spiderForm._id)
+ .then(response => {
+ commit('SET_OVERVIEW_STATS', response.data.overview)
+ commit('SET_STATUS_STATS', response.data.task_count_by_status)
+ commit('SET_DAILY_STATS', response.data.daily_stats)
+ })
}
}
diff --git a/frontend/src/views/spider/SpiderDetail.vue b/frontend/src/views/spider/SpiderDetail.vue
index 56cf7982..dac7931e 100644
--- a/frontend/src/views/spider/SpiderDetail.vue
+++ b/frontend/src/views/spider/SpiderDetail.vue
@@ -19,6 +19,9 @@
+
+
+
@@ -30,10 +33,12 @@ import {
import FileList from '../../components/FileList/FileList'
import SpiderOverview from '../../components/Overview/SpiderOverview'
import EnvironmentList from '../../components/Environment/EnvironmentList'
+import SpiderStats from '../../components/Stats/SpiderStats'
export default {
name: 'NodeDetail',
components: {
+ SpiderStats,
EnvironmentList,
FileList,
SpiderOverview
@@ -57,6 +62,11 @@ export default {
},
methods: {
onTabClick () {
+ if (this.activeTabName === 'analytics') {
+ setTimeout(() => {
+ this.$refs['spider-stats'].update()
+ }, 0)
+ }
},
onSpiderChange (id) {
this.$router.push(`/spiders/${id}`)