feat: мультироль
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Successful in 9s
🚀 Create and publish a Docker image / Build & publish backend image (push) Successful in 2m6s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Successful in 26s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Successful in 6s

This commit is contained in:
2026-05-11 21:29:16 +03:00
parent 3b0bbfc858
commit 6824d7ce7d
29 changed files with 1350 additions and 95 deletions
+23 -7
View File
@@ -25,14 +25,20 @@ const columns = [
const roleLabels = { Student: 'Студент', Teacher: 'Преподаватель', Admin: 'Администратор' } as const
const roleApi = { Студент: 'Student', Преподаватель: 'Teacher', Администратор: 'Admin' } as const
type ApiUserRole = 'Student' | 'Teacher' | 'Admin'
const roleSetSequence: ApiUserRole[][] = [
['Student'],
['Student', 'Teacher'],
['Student', 'Teacher', 'Admin'],
]
const rows = computed(() =>
users.value.map(user => ({
id: user.id,
name: user.displayName || user.email,
email: user.email,
role: roleLabels[user.role],
apiRole: user.role,
role: user.roles.map(role => roleLabels[role]).join(', '),
apiRoles: user.roles,
institute: 'ЮФУ',
activity: user.isActive ? 'Активен' : 'Заблокирован',
isActive: user.isActive,
@@ -56,14 +62,24 @@ async function fetchUsers() {
}
}
async function toggleActive(row: Record<string, any>) {
await usersApi.setActive(row.id, !row.isActive)
async function toggleActive(row: Record<string, unknown>) {
const id = Number(row.id)
const isActive = Boolean(row.isActive)
await usersApi.setActive(id, !isActive)
await fetchUsers()
}
async function promoteRole(row: Record<string, any>) {
const next = row.apiRole === 'Student' ? 'Teacher' : row.apiRole === 'Teacher' ? 'Admin' : 'Student'
await usersApi.setRole(row.id, next)
async function promoteRole(row: Record<string, unknown>) {
const id = Number(row.id)
const apiRoles = (Array.isArray(row.apiRoles) ? row.apiRoles : []) as ApiUserRole[]
const currentKey = [...new Set(apiRoles)].sort().join(',')
const currentIndex = roleSetSequence.findIndex(set => set.slice().sort().join(',') === currentKey)
const next: ApiUserRole[] = (
currentIndex >= 0
? roleSetSequence[(currentIndex + 1) % roleSetSequence.length]
: roleSetSequence[0]
) ?? ['Student']
await usersApi.setRole(id, next)
await fetchUsers()
}