Skip to content

Commit

Permalink
Merge pull request #358 from TencentBlueKing/develop
Browse files Browse the repository at this point in the history
v1.5.11
  • Loading branch information
zhu327 authored Nov 8, 2021
2 parents 434c049 + 60489c0 commit ecc5de7
Show file tree
Hide file tree
Showing 18 changed files with 1,858 additions and 104 deletions.
4 changes: 3 additions & 1 deletion frontend/src/language/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,9 @@ export const m = {
'耗时': 'time consuming',
'操作人': 'Operator',
'触发类型': 'Trigger type',
'日志详情': 'Log details'
'日志详情': 'Log details',
'成功': 'Succeed',
'失败': 'Failed'
},
grading: {
'分级管理员': 'Grading Manager',
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/language/lang/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,9 @@ export const m = {
'耗时': '耗时',
'操作人': '操作人',
'触发类型': '触发类型',
'日志详情': '日志详情'
'日志详情': '日志详情',
'成功': '成功',
'失败': '失败'
},
grading: {
'分级管理员': '分级管理员',
Expand Down
25 changes: 25 additions & 0 deletions frontend/src/store/modules/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,31 @@ export default {
*/
verifyManualUser ({ commit, state, dispatch }, params, config) {
return http.post(`${AJAX_URL_PREFIX}/organizations/users/query/`, params, config)
},

/**
* 获取同步记录
*
* @param {Function} commit store commit mutation handler
* @param {Object} state store state
* @param {Function} dispatch store dispatch action handler
* @param {Object} params 请求参数
* @return {Promise} promise 对象
*/
getRecordsList ({ commit, state, dispatch }, params, config = {}) {
return http.get(`${AJAX_URL_PREFIX}/organizations/sync_records/?${json2Query(params)}`, {}, config)
},
/**
* 获取日志详情
*
* @param {Function} commit store commit mutation handler
* @param {Object} state store state
* @param {Function} dispatch store dispatch action handler
* @param {Object} params 请求参数
* @return {Promise} promise 对象
*/
getRecordsLog ({ commit, state, dispatch }, id, config) {
return http.get(`${AJAX_URL_PREFIX}/organizations/sync_records/${id}/logs/`, config)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,11 @@
const inOriginalList = !!this.originalList.filter(
original => String(original.id) === String(item.id)
).length
item.expired_at = item.expired_at - this.user.timestamp
if ((item.tag === 'add' || item.tag === 'update' || item.isExpired) && item.expired_at !== PERMANENT_TIMESTAMP) {
if (!item.isShowRenewal) {
item.expired_at = item.expired_at - this.user.timestamp
}
}
this.tableList.splice(
curIndex,
1,
Expand Down
216 changes: 137 additions & 79 deletions frontend/src/views/user/components/record-list.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
<template>
<div class="iam-system-access-wrapper">
<render-search>
<!-- <bk-button theme="primary" @click="goCreate">{{ $t(`m.common['新增']`) }}</bk-button> -->
<span class="display-name">同步记录</span>
<div slot="right">
<bk-date-picker
v-model="initDateTimeRange"
:placeholder="'选择日期范围'"
:type="'daterange'"
placement="bottom-end"
:shortcuts="shortcuts"
:shortcut-close="true"
@change="handleDateChange">
</bk-date-picker>
</div>
</render-search>
<bk-table
:data="tableList"
Expand All @@ -12,35 +22,33 @@
:pagination="pagination"
@page-change="handlePageChange"
@page-limit-change="handleLimitChange"
@select="handlerChange"
@select-all="handlerAllChange"
v-bkloading="{ isLoading: tableLoading, opacity: 1 }">
<!-- <bk-table-column type="selection" align="center"></bk-table-column> -->
<bk-table-column :label="$t(`m.user['开始时间']`)" :min-width="220">
<template slot-scope="{ row }">
<span class="system-access-name" :title="row.system.name" @click="goDetail(row)">
{{ row.system.name }}
</span>
{{ timestampToTime(row.created_time) }}
</template>
</bk-table-column>
<bk-table-column :label="$t(`m.user['耗时']`)">
<template slot-scope="{ row }">
<span :title="row.system.id">{{ row.system.id }}</span>
<span :title="row.cost_time">{{ row.cost_time | getDuration }}</span>
</template>
</bk-table-column>
<bk-table-column :label="$t(`m.user['操作人']`)">
<template slot-scope="{ row }">
<span :title="row.owner">{{ row.owner }}</span>
<span :title="row.executor">
{{ row.trigger_type === 'periodic_task' ? '定时同步' : row.executor }}
</span>
</template>
</bk-table-column>
<bk-table-column :label="$t(`m.user['触发类型']`)" :sortable="true" sort-by="created_time">
<bk-table-column :label="$t(`m.user['触发类型']`)">
<template slot-scope="{ row }">
<span :title="row.created_time">{{ row.created_time }}</span>
<span :title="row.trigger_type">{{ triggerType[row.trigger_type] }}</span>
</template>
</bk-table-column>
<bk-table-column :label="$t(`m.audit['状态']`)" :sortable="true" sort-by="updated_time">
<bk-table-column :label="$t(`m.audit['状态']`)">
<template slot-scope="{ row }">
<span :title="row.updated_time">{{ row.updated_time }}</span>
<render-status :status="row.status" />
</template>
</bk-table-column>
<bk-table-column :label="$t(`m.common['操作']`)" width="270">
Expand All @@ -61,20 +69,47 @@
:width="725"
:quick-close="true"
@animation-end="handleAnimationEnd">
<div slot="content">
<log-details v-model="detailData" :value="detailData"></log-details>
<div slot="content" v-bkloading="{ isLoading: logDetailLoading, opacity: 1 }">
<section v-show="!logDetailLoading">
<div class="link-btn">
<bk-link class="link" theme="primary" href="https://bk.tencent.com/docs/document/6.0/160/8402" target="_blank">同步失败排查指引</bk-link>
</div>
<div class="msg-content">
<div v-if="exceptionMsg || tracebackMsg">
<div>{{exceptionMsg}}</div>
<div>{{tracebackMsg}}</div>
</div>
<div v-else>暂无日志详情</div>
</div>
</section>
</div>
</bk-sideslider>
</div>
</template>
<script>
import { buildURLParams } from '@/common/url'
import LogDetails from './log-details'
import { timestampToTime } from '@/common/util'
import RenderStatus from './render-status'
import moment from 'moment'
export default {
name: 'system-access-index',
filters: {
getDuration (val) {
const d = moment.duration(val, 'seconds')
if (val >= 86400) {
return `${Math.floor(d.asDays())}d${d.hours()}h${d.minutes()}min${d.seconds()}s`
}
if (val >= 3600) {
return `${d.hours()}h${d.minutes()}min${d.seconds()}s`
}
if (val > 60) {
return `${d.minutes()}min${d.seconds()}s`
}
return `${Math.floor(val)}s`
}
},
components: {
LogDetails
RenderStatus
},
data () {
return {
Expand All @@ -86,9 +121,42 @@
limit: 10
},
currentBackup: 1,
currentSelectList: [],
isShowLogDetails: false,
detailData: '测试'
logDetailLoading: false,
exceptionMsg: '',
tracebackMsg: '',
timestampToTime: timestampToTime,
initDateTimeRange: [],
triggerType: { 'periodic_task': '定时同步', 'manual_sync': '手动同步' },
shortcuts: [
{
text: '今天',
value () {
const end = new Date()
const start = new Date()
return [start, end]
}
},
{
text: '最近7天',
value () {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
return [start, end]
}
},
{
text: '最近30天',
value () {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
return [start, end]
}
}
],
dateRange: { startTime: '', endTime: '' }
}
},
watch: {
Expand All @@ -97,57 +165,23 @@
}
},
created () {
console.log(123455)
this.fetchPageData()
const currentQueryCache = this.getCurrentQueryCache()
if (currentQueryCache && Object.keys(currentQueryCache).length) {
if (currentQueryCache.limit) {
this.pagination.limit = currentQueryCache.limit
this.pagination.current = currentQueryCache.current
}
}
},
methods: {
async fetchPageData () {
await this.fetchModelingList(true)
},
handleOpenMoreLink () {
window.open(`${window.PRODUCT_DOC_URL_PREFIX}/权限中心/产品白皮书/场景案例/GradingManager.md`)
},
refreshCurrentQuery () {
const { limit, current } = this.pagination
const queryParams = { limit, current }
window.history.replaceState({}, '', `?${buildURLParams(queryParams)}`)
return queryParams
},
setCurrentQueryCache (payload) {
window.localStorage.setItem('templateList', JSON.stringify(payload))
},
getCurrentQueryCache () {
return JSON.parse(window.localStorage.getItem('templateList'))
},
resetPagination () {
this.pagination = Object.assign({}, {
limit: 10,
current: 1,
count: 0
})
},
async fetchModelingList (isLoading = false) {
this.tableLoading = isLoading
this.setCurrentQueryCache(this.refreshCurrentQuery())
const params = {
limit: this.pagination.limit,
offset: this.pagination.limit * (this.pagination.current - 1)
offset: this.pagination.limit * (this.pagination.current - 1),
start_time: this.dateRange.startTime,
end_time: this.dateRange.endTime
}
try {
const res = await this.$store.dispatch('access/getModelingList', params)
const res = await this.$store.dispatch('organization/getRecordsList', params)
this.pagination.count = res.data.count
res.data.results = res.data.results.length && res.data.results.sort(
(a, b) => new Date(b.updated_time) - new Date(a.updated_time))
Expand All @@ -167,21 +201,6 @@
}
},
goDetail (payload) {
this.$router.push({
name: 'systemAccessAccess',
params: {
id: payload.id
}
})
},
goCreate () {
this.$router.push({
name: 'systemAccessCreate'
})
},
handlePageChange (page) {
if (this.currentBackup === page) {
return
Expand All @@ -196,18 +215,46 @@
this.fetchModelingList(true)
},
handlerAllChange (selection) {
this.currentSelectList = [...selection]
handleAnimationEnd () {
this.isShowLogDetails = false
},
handlerChange (selection, row) {
this.currentSelectList = [...selection]
async showLogDetails (data) {
this.isShowLogDetails = true
this.logDetailLoading = true
try {
const res = await this.$store.dispatch('organization/getRecordsLog', data.id)
this.exceptionMsg = res.data.exception_msg
this.tracebackMsg = res.data.traceback_msg
} catch (e) {
console.error(e)
this.bkMessageInstance = this.$bkMessage({
limit: 1,
theme: 'error',
message: e.message || e.data.msg || e.statusText,
ellipsisLine: 2,
ellipsisCopy: true
})
} finally {
this.logDetailLoading = false
}
},
handleAnimationEnd () {},
resetPagination () {
this.pagination = Object.assign({}, {
limit: 10,
current: 1,
count: 0
})
},
showLogDetails () {
this.isShowLogDetails = true
handleDateChange (date) {
this.resetPagination()
this.dateRange = {
startTime: `${date[0]}` ? `${date[0]} 00:00:00` : '',
endTime: `${date[1]}` ? `${date[1]} 23:59:59` : ''
}
this.fetchModelingList(true)
}
}
Expand Down Expand Up @@ -243,5 +290,16 @@
color: #fe9c00;
}
}
.link-btn{
margin: 10px 0 10px 600px;
}
.msg-content{
background: #555555;
color: #fff;
margin: 0 0px 0 30px;
padding: 10px;
max-height: 1200px;
overflow-y: scroll;
}
}
</style>
Loading

0 comments on commit ecc5de7

Please sign in to comment.