Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -103,7 +103,10 @@
|
||||
:rows="store.rows"
|
||||
:columns="columns"
|
||||
:loading="store.loading"
|
||||
v-model:pagination="store.pagination"
|
||||
:rows-per-page-options="[250, 500, 1000]"
|
||||
binary-state-sort
|
||||
@request="store.onTableRequest"
|
||||
>
|
||||
|
||||
|
||||
|
||||
@@ -4,18 +4,15 @@ import { get } from 'src/services/api'
|
||||
export const useActivityLogStore = defineStore('activityLogStore', {
|
||||
state: () => ({
|
||||
loading: false,
|
||||
|
||||
rows: [],
|
||||
total: 0,
|
||||
|
||||
pagination: {
|
||||
page: 1,
|
||||
rowsPerPage: 0, // ✅ SINIRSIZ
|
||||
rowsPerPage: 1000,
|
||||
rowsNumber: 0,
|
||||
sortBy: 'created_at',
|
||||
descending: true
|
||||
}
|
||||
,
|
||||
|
||||
},
|
||||
filters: {
|
||||
username: '',
|
||||
actionCategory: null,
|
||||
@@ -30,50 +27,34 @@ export const useActivityLogStore = defineStore('activityLogStore', {
|
||||
async fetchLogs () {
|
||||
this.loading = true
|
||||
try {
|
||||
const params = {}
|
||||
|
||||
if (this.pagination.rowsPerPage > 0) {
|
||||
params.page = this.pagination.page
|
||||
params.limit = this.pagination.rowsPerPage
|
||||
const params = {
|
||||
page: Math.max(1, Number(this.pagination.page || 1)),
|
||||
limit: Math.min(1000, Math.max(1, Number(this.pagination.rowsPerPage || 1000)))
|
||||
}
|
||||
|
||||
|
||||
if (this.filters.username)
|
||||
params.username = this.filters.username
|
||||
|
||||
if (this.filters.actionCategory)
|
||||
params.action_category = this.filters.actionCategory
|
||||
|
||||
if (this.filters.actionType)
|
||||
params.action_type = this.filters.actionType
|
||||
|
||||
if (this.filters.success !== null)
|
||||
params.success = this.filters.success
|
||||
|
||||
if (this.filters.dateFrom)
|
||||
params.date_from = this.filters.dateFrom
|
||||
|
||||
if (this.filters.dateTo)
|
||||
params.date_to = this.filters.dateTo
|
||||
if (this.filters.username) params.username = this.filters.username
|
||||
if (this.filters.actionCategory) params.action_category = this.filters.actionCategory
|
||||
if (this.filters.actionType) params.action_type = this.filters.actionType
|
||||
if (this.filters.success !== null) params.success = this.filters.success
|
||||
if (this.filters.dateFrom) params.date_from = this.filters.dateFrom
|
||||
if (this.filters.dateTo) params.date_to = this.filters.dateTo
|
||||
|
||||
const data = await get('/activity-logs', params)
|
||||
|
||||
this.rows = data.items || []
|
||||
this.total = data.total || 0
|
||||
this.pagination.rowsNumber = this.total
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
quickRoleChange () {
|
||||
|
||||
quickRoleChange () {
|
||||
this.filters.actionCategory = 'role_permission'
|
||||
this.filters.actionType = 'role_department_permission_change'
|
||||
|
||||
this.pagination.page = 1
|
||||
|
||||
this.fetchLogs()
|
||||
}
|
||||
,
|
||||
},
|
||||
|
||||
onTableRequest (props) {
|
||||
const { page, rowsPerPage, sortBy, descending } = props.pagination
|
||||
@@ -84,8 +65,8 @@ export const useActivityLogStore = defineStore('activityLogStore', {
|
||||
this.pagination.descending = descending
|
||||
|
||||
this.fetchLogs()
|
||||
}
|
||||
,
|
||||
},
|
||||
|
||||
resetFilters () {
|
||||
this.filters = {
|
||||
username: '',
|
||||
|
||||
Reference in New Issue
Block a user