Merge branch 'feature/spa' of git.yoho.cn:OPENTECH/yoho-node-ci into feature/spa
Showing
7 changed files
with
115 additions
and
10 deletions
@@ -4,33 +4,50 @@ | @@ -4,33 +4,50 @@ | ||
4 | // SecretKey: 'Mhuw11qY5KPK5fBYxDHAsQnzzpU4Xqzx', | 4 | // SecretKey: 'Mhuw11qY5KPK5fBYxDHAsQnzzpU4Xqzx', |
5 | // serviceType: 'logset' | 5 | // serviceType: 'logset' |
6 | // }); | 6 | // }); |
7 | +const _ = require('lodash'); | ||
7 | const moment = require('moment'); | 8 | const moment = require('moment'); |
8 | const rp = require('request-promise'); | 9 | const rp = require('request-promise'); |
9 | const Model = require('./model'); | 10 | const Model = require('./model'); |
10 | const qcloud = require('../../lib/qcloud'); | 11 | const qcloud = require('../../lib/qcloud'); |
11 | 12 | ||
13 | + | ||
14 | +let _convert = res => { | ||
15 | + res = JSON.parse(res); | ||
16 | + | ||
17 | + let message; | ||
18 | + _.each(res.results, (item, idx) => { | ||
19 | + message = JSON.parse(JSON.parse(item.content)['__CONTENT__'].message); | ||
20 | + res.results[idx].message = message.message; | ||
21 | + res.results[idx].level = message.level; | ||
22 | + // res.results[idx].t = moment(message.timestamp).format('YYYY-MM-DD HH:mm:ss'); | ||
23 | + delete res.results[idx].content; | ||
24 | + | ||
25 | + }); | ||
26 | + return res; | ||
27 | +}; | ||
28 | + | ||
12 | class Logs extends Model { | 29 | class Logs extends Model { |
13 | constructor() { | 30 | constructor() { |
14 | super('logs'); | 31 | super('logs'); |
15 | } | 32 | } |
16 | 33 | ||
17 | - async init(query = 'yoho') { | ||
18 | - const result = await rp(qcloud.sign({ | 34 | + async init({query = '', limit = 10}) { |
35 | + const res = await rp(qcloud.sign({ | ||
19 | method: 'get', | 36 | method: 'get', |
20 | baseUrl: 'http://ap-beijing.cls.myqcloud.com', | 37 | baseUrl: 'http://ap-beijing.cls.myqcloud.com', |
21 | uri: '/searchlog', | 38 | uri: '/searchlog', |
22 | qs: { | 39 | qs: { |
23 | logset_id: '3a292186-9241-4d2c-98de-a13896ed7b25', | 40 | logset_id: '3a292186-9241-4d2c-98de-a13896ed7b25', |
24 | topic_ids: '3cb90ed6-0f92-40cb-b064-42f36d13b11a', | 41 | topic_ids: '3cb90ed6-0f92-40cb-b064-42f36d13b11a', |
25 | - start_time: moment(Date.now() - 3600 * 1000).format('YYYY-MM-DD HH:mm:ss'), | 42 | + start_time: moment(Date.now() - 3600 * 1000 * 48).format('YYYY-MM-DD HH:mm:ss'), |
26 | end_time: moment().format('YYYY-MM-DD HH:mm:ss'), | 43 | end_time: moment().format('YYYY-MM-DD HH:mm:ss'), |
27 | query, | 44 | query, |
28 | - limit: '10' | 45 | + limit |
29 | }, | 46 | }, |
30 | headers: {} | 47 | headers: {} |
31 | - })) | ||
32 | - | ||
33 | - return result | 48 | + }, {query, limit})); |
49 | + | ||
50 | + return _convert(res) | ||
34 | } | 51 | } |
35 | } | 52 | } |
36 | 53 |
public/src/js/services/logs/index.js
0 → 100644
public/src/js/services/logs/log-service.js
0 → 100644
public/src/js/services/service.js
0 → 100644
1 | +import axios from 'axios'; | ||
2 | + | ||
3 | +class Service { | ||
4 | + get(url, options) { | ||
5 | + return axios.get(url, options).then(res => { | ||
6 | + if (res.status === 200) { | ||
7 | + return res.data; | ||
8 | + } | ||
9 | + return {}; | ||
10 | + }); | ||
11 | + } | ||
12 | + post(url, data) { | ||
13 | + return axios.post(url, data).then(res => { | ||
14 | + if (res.status === 200) { | ||
15 | + return res.data; | ||
16 | + } | ||
17 | + return {}; | ||
18 | + }); | ||
19 | + } | ||
20 | +} | ||
21 | +export default Service; | ||
22 | + |
1 | <template> | 1 | <template> |
2 | <div> | 2 | <div> |
3 | - Node logs | 3 | + <div class="filter"> |
4 | + <Input v-model="value" placeholder="日志集" style="width: 300px"></Input> | ||
5 | + <Input v-model="value" placeholder="日志主题" style="width: 300px"></Input> | ||
6 | + <Input v-model="value" placeholder="检索关键词多个以空格分隔" style="width: 300px"></Input> | ||
7 | + <Select v-model="model1" style="width:200px"> | ||
8 | + <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> | ||
9 | + </Select> | ||
10 | + </div> | ||
11 | + <Table highlight-row ref="currentRowTable" :columns="columns" :data="logs"></Table> | ||
4 | </div> | 12 | </div> |
5 | </template> | 13 | </template> |
6 | 14 | ||
7 | <script> | 15 | <script> |
16 | + import {LogService} from '../../js/services/logs'; | ||
17 | + | ||
8 | export default { | 18 | export default { |
19 | + data() { | ||
20 | + return { | ||
21 | + columns: [ | ||
22 | + { | ||
23 | + title: 'topic_name', | ||
24 | + key: 'topic_name' | ||
25 | + }, | ||
26 | + { | ||
27 | + title: 'topic_id', | ||
28 | + key: 'topic_id' | ||
29 | + }, | ||
30 | + { | ||
31 | + title: '级别', | ||
32 | + key: 'level' | ||
33 | + }, | ||
34 | + { | ||
35 | + title: '内容', | ||
36 | + key: 'message' | ||
37 | + }, | ||
38 | + { | ||
39 | + title: '时间', | ||
40 | + key: 'timestamp' | ||
41 | + } | ||
42 | + ], | ||
43 | + logs: [] | ||
44 | + } | ||
45 | + }, | ||
46 | + methods: { | ||
47 | + searchLog() { | ||
48 | + this.logService.getLogs({limit: 20}).then(res => { | ||
49 | + this.logs = res.results; | ||
50 | + }); | ||
51 | + } | ||
52 | + }, | ||
53 | + created() { | ||
54 | + this.logService = new LogService(); | ||
55 | + this.searchLog(); | ||
56 | + } | ||
9 | } | 57 | } |
10 | -</script> | ||
58 | +</script> |
-
Please register or login to post a comment