forked from jumpserver/lina
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2360da5
commit a14bd2c
Showing
13 changed files
with
330 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<template> | ||
<div> | ||
<el-tag v-if="isOk" type="success">{{ $t('common.Yes') }}</el-tag> | ||
<el-tag v-else type="danger">{{ $t('common.No') }}</el-tag> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import BaseFormatter from './base' | ||
export default { | ||
name: 'BoolTagFormatter', | ||
extends: BaseFormatter, | ||
props: { | ||
formatterArgsDefault: { | ||
type: Object, | ||
default() { | ||
return { | ||
typeChange(val) { | ||
return !!val | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
data() { | ||
return { | ||
formatterArgs: Object.assign(this.formatterArgsDefault, this.col.formatterArgs) | ||
} | ||
}, | ||
computed: { | ||
isOk() { | ||
return this.formatterArgs.typeChange(this.cellValue) | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<template> | ||
<el-tooltip effect="light" placement="top-start"> | ||
<div slot="content"><span v-html="display" /></div> | ||
<span style="overflow: auto" v-html="title" /> | ||
</el-tooltip> | ||
</template> | ||
|
||
<script> | ||
import BaseFormatter from './base' | ||
export default { | ||
name: 'HtmlDisplayFormatter', | ||
extends: BaseFormatter, | ||
data() { | ||
return { | ||
title: this.col.formatterArgs.getTitle(this.row), | ||
display: this.col.formatterArgs.getDisplay(this.row) | ||
} | ||
}, | ||
computed: { | ||
}, | ||
methods: { | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<template> | ||
<div> | ||
<GenericListTable :table-config="tableConfig" :header-actions="headerActions" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import GenericListTable from '@/layout/components/GenericListTable' | ||
import getConfig from './tableConfig' | ||
export default { | ||
name: 'AllMessageList', | ||
components: { | ||
GenericListTable | ||
}, | ||
data() { | ||
const config = getConfig.bind(this)() | ||
return { | ||
tableConfig: { | ||
url: '/api/v1/notifications/site-messages/', | ||
columns: config.tableConfigColumns, | ||
columnsShow: config.tableConfigColumnsShow, | ||
columnsMeta: config.tableConfigColumnsMeta | ||
}, | ||
headerActions: config.headerActions | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<template> | ||
<div> | ||
<GenericListTable :table-config="tableConfig" :header-actions="headerActions" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import GenericListTable from '@/layout/components/GenericListTable' | ||
import getConfig from '@/views/messages/tableConfig' | ||
export default { | ||
name: 'ReadMessageList', | ||
components: { | ||
GenericListTable | ||
}, | ||
data() { | ||
const config = getConfig.bind(this)() | ||
return { | ||
tableConfig: { | ||
url: '/api/v1/notifications/site-messages/?has_read=true', | ||
columns: config.tableConfigColumns, | ||
columnsShow: config.tableConfigColumnsShow, | ||
columnsMeta: config.tableConfigColumnsMeta | ||
}, | ||
headerActions: config.headerActions | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<template> | ||
<div> | ||
<GenericListTable :table-config="tableConfig" :header-actions="headerActions" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import GenericListTable from '@/layout/components/GenericListTable' | ||
import getConfig from '@/views/messages/tableConfig' | ||
export default { | ||
name: 'UnreadMessageList', | ||
components: { | ||
GenericListTable | ||
}, | ||
data() { | ||
const config = getConfig.bind(this)() | ||
return { | ||
tableConfig: { | ||
url: '/api/v1/notifications/site-messages/?has_read=false', | ||
columns: config.tableConfigColumns, | ||
columnsShow: config.tableConfigColumnsShow, | ||
columnsMeta: config.tableConfigColumnsMeta | ||
}, | ||
headerActions: Object.assign(config.headerActions, { | ||
extraActions: [ | ||
{ | ||
name: 'MarkRead', | ||
title: this.$t('notifications.MarkAsRead'), | ||
type: 'info', | ||
can: (cellValue) => { | ||
return cellValue.selectedRows.length > 0 | ||
}, | ||
callback: (cellValue) => { | ||
const url = `/api/v1/notifications/site-messages/mark-as-read/` | ||
const msgIds = cellValue.selectedRows.map((item) => { | ||
return item.id | ||
}) | ||
this.$axios.patch(url, { ids: msgIds }).then(res => { | ||
this.$children[0].$refs.ListTable.reloadTable() | ||
}).catch(err => { | ||
this.$message(err.detail) | ||
}) | ||
} | ||
} | ||
] | ||
}) | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<template> | ||
<TabPage :active-menu.sync="config.activeMenu" :submenu="config.submenu"> | ||
<div slot="title"> | ||
{{ Title }} | ||
</div> | ||
<keep-alive> | ||
<component :is="config.activeMenu" /> | ||
</keep-alive> | ||
</TabPage> | ||
</template> | ||
|
||
<script> | ||
import { TabPage } from '@/layout/components' | ||
import AllMessageList from './AllMessageList' | ||
import ReadMessageList from './ReadMessageList' | ||
import UnreadMessageList from './UnreadMessageList' | ||
export default { | ||
name: 'Index', | ||
components: { | ||
TabPage, | ||
AllMessageList, | ||
ReadMessageList, | ||
UnreadMessageList | ||
}, | ||
data() { | ||
return { | ||
config: { | ||
activeMenu: 'UnreadMessageList', | ||
submenu: [ | ||
{ | ||
title: this.$t('notifications.AllMessages'), | ||
name: 'AllMessageList' | ||
}, | ||
{ | ||
title: this.$t('notifications.ReadMessages'), | ||
name: 'ReadMessageList' | ||
}, | ||
{ | ||
title: this.$t('notifications.UnreadMessages'), | ||
name: 'UnreadMessageList' | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
computed: { | ||
Title() { | ||
return this.$t('route.MessageCenter') | ||
} | ||
}, | ||
mounted() { | ||
const params = this.$route.params | ||
switch (params.activeMenu) { | ||
case 'AllMessageList': | ||
this.config.activeMenu = 'AllMessageList' | ||
break | ||
case 'ReadMessageList': | ||
this.config.activeMenu = 'ReadMessageList' | ||
break | ||
case 'UnreadMessageList': | ||
this.config.activeMenu = 'UnreadMessageList' | ||
break | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import i18n from '@/i18n/i18n' | ||
import { DateFormatter, BooleanTagFormatter, HtmlDisplayFormatter } from '@/components/TableFormatters' | ||
|
||
function getConfig() { | ||
const tableConfigColumns = [ | ||
'message', 'date_created', 'has_read' | ||
] | ||
|
||
const tableConfigColumnsShow = { | ||
default: ['content.message', 'date_created', 'has_read'], | ||
min: ['message', 'has_read'] | ||
} | ||
|
||
const tableConfigColumnsMeta = { | ||
message: { | ||
label: i18n.t('notifications.Message'), | ||
formatter: HtmlDisplayFormatter, | ||
formatterArgs: { | ||
getTitle: (row) => { | ||
return row.content.subject | ||
}, | ||
getDisplay: (row) => { | ||
return row.content.message | ||
} | ||
} | ||
}, | ||
date_created: { | ||
showOverflowTooltip: true, | ||
formatter: DateFormatter | ||
}, | ||
has_read: { | ||
label: i18n.t('notifications.OneClickRead'), | ||
width: '100px', | ||
align: 'center', | ||
formatter: BooleanTagFormatter | ||
} | ||
} | ||
|
||
const headerActions = { | ||
hasCreate: false, | ||
hasExport: false, | ||
hasImport: false, | ||
canBulkDelete: true | ||
} | ||
return { | ||
tableConfigColumns: tableConfigColumns, | ||
tableConfigColumnsShow: tableConfigColumnsShow, | ||
headerActions: headerActions, | ||
tableConfigColumnsMeta: tableConfigColumnsMeta | ||
} | ||
} | ||
|
||
export default getConfig |