diff --git a/navigation/index.js b/navigation/index.js index eb0d38c..0538996 100644 --- a/navigation/index.js +++ b/navigation/index.js @@ -64,12 +64,6 @@ export default [ "child": [] } ] - }, - { - "title": "RBAC Management", - "path": "/rbac-permission", - "icon": "ph:matrix-logo", - "child": [] } ], "meta": {} diff --git a/pages/dashboard/index.vue b/pages/dashboard/index.vue index 361238f..c6d7236 100644 --- a/pages/dashboard/index.vue +++ b/pages/dashboard/index.vue @@ -1,338 +1,842 @@ - - - - - - @@ -317,25 +243,25 @@ onMounted(() => {
- + diff --git a/pages/rbac-permission/index.vue b/pages/rbac-permission/index.vue deleted file mode 100644 index c6d7236..0000000 --- a/pages/rbac-permission/index.vue +++ /dev/null @@ -1,842 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/roles/create.vue b/pages/roles/create.vue index d900aa8..6b594d7 100644 --- a/pages/roles/create.vue +++ b/pages/roles/create.vue @@ -12,199 +12,78 @@ definePageMeta({ import { ref, reactive, computed, onMounted } from 'vue' -// Form state +// Form state - SIMPLIFIED const roleForm = reactive({ name: '', description: '', - permissions: { - menus: [], - components: [], - features: [] - } + application: '', + permissions: [], // Simple list of permissions + isActive: true }) -// Simplified templates with clear descriptions -const roleTemplates = ref([ - { - id: 'administrator', - name: '🔴 Administrator', - description: 'Complete system access - all features and permissions', - permissionCount: 45, - icon: 'ph:crown', - color: 'red', - permissions: { - menus: ['1', '2', '3', '4', '5', '6'], - components: ['1', '2', '3', '4', '5'], - features: ['1', '2', '3', '4'] - } - }, - { - id: 'manager', - name: '🟡 Manager', - description: 'Department management, approvals, and team oversight', - permissionCount: 28, - icon: 'ph:briefcase', - color: 'yellow', - permissions: { - menus: ['1', '2', '3', '5'], - components: ['1', '3', '4'], - features: ['2', '4'] - } - }, - { - id: 'editor', - name: '🟢 Editor', - description: 'Content creation, editing, and data management', - permissionCount: 18, - icon: 'ph:pencil', - color: 'green', - permissions: { - menus: ['1', '2', '3'], - components: ['1', '3'], - features: ['1'] - } - }, - { - id: 'viewer', - name: '🔵 Viewer', - description: 'Read-only access to view data and reports', - permissionCount: 8, - icon: 'ph:eye', - color: 'blue', - permissions: { - menus: ['1', '2'], - components: ['1'], - features: [] - } - }, - { - id: 'custom', - name: '⚙️ Custom Role', - description: 'Configure permissions manually for specific needs', - permissionCount: 0, - icon: 'ph:gear', - color: 'gray', - permissions: { - menus: [], - components: [], - features: [] - } - } +// Available applications +const availableApplications = ref([ + { id: '1', name: 'Main Application', description: 'Primary business application' }, + { id: '2', name: 'HR System', description: 'Human Resources Management' }, + { id: '3', name: 'Finance System', description: 'Financial Management' } ]) -// Application options -const applicationOptions = ref([ - { value: '1', label: 'corradAF - Main Application' }, - { value: '2', label: 'HR System - Human Resources' }, - { value: '3', label: 'Finance System - Financial Management' } +// Simplified permissions - focused on actual system functions +const availablePermissions = ref([ + // User Management + { id: 'users_view', name: 'View Users', category: 'User Management', description: 'Can view user listings and profiles' }, + { id: 'users_create', name: 'Create Users', category: 'User Management', description: 'Can create new user accounts' }, + { id: 'users_edit', name: 'Edit Users', category: 'User Management', description: 'Can modify user information' }, + { id: 'users_delete', name: 'Delete Users', category: 'User Management', description: 'Can delete user accounts' }, + + // Group Management + { id: 'groups_view', name: 'View Groups', category: 'Group Management', description: 'Can view group listings' }, + { id: 'groups_create', name: 'Create Groups', category: 'Group Management', description: 'Can create new groups' }, + { id: 'groups_edit', name: 'Edit Groups', category: 'Group Management', description: 'Can modify groups' }, + { id: 'groups_delete', name: 'Delete Groups', category: 'Group Management', description: 'Can delete groups' }, + + // Role Management + { id: 'roles_view', name: 'View Roles', category: 'Role Management', description: 'Can view role listings' }, + { id: 'roles_create', name: 'Create Roles', category: 'Role Management', description: 'Can create new roles' }, + { id: 'roles_edit', name: 'Edit Roles', category: 'Role Management', description: 'Can modify roles' }, + { id: 'roles_delete', name: 'Delete Roles', category: 'Role Management', description: 'Can delete roles' }, + + // System Access + { id: 'dashboard_access', name: 'Dashboard Access', category: 'System Access', description: 'Can access the dashboard' }, + { id: 'reports_view', name: 'View Reports', category: 'System Access', description: 'Can view system reports' }, + { id: 'settings_view', name: 'View Settings', category: 'System Access', description: 'Can view system settings' }, + { id: 'settings_edit', name: 'Edit Settings', category: 'System Access', description: 'Can modify system settings' } ]) -// Simplified resource lists (only shown for custom roles) -const resources = ref({ - menus: [ - { id: '1', name: 'Dashboard', path: '/dashboard' }, - { id: '2', name: 'Users Management', path: '/users' }, - { id: '3', name: 'Groups Management', path: '/groups' }, - { id: '4', name: 'Roles Management', path: '/roles' }, - { id: '5', name: 'Applications', path: '/applications' }, - { id: '6', name: 'RBAC Management', path: '/rbac' } - ], - components: [ - { id: '1', name: 'User Profile Actions', description: 'Edit, delete user profiles' }, - { id: '2', name: 'Data Export', description: 'Export system data' }, - { id: '3', name: 'Bulk Operations', description: 'Mass user/group operations' }, - { id: '4', name: 'System Settings', description: 'Configure system settings' }, - { id: '5', name: 'Audit Logs', description: 'View system audit trails' } - ], - features: [ - { id: '1', name: 'Data Export', description: 'Export data to CSV/Excel' }, - { id: '2', name: 'Approval Workflows', description: 'Approve/reject requests' }, - { id: '3', name: 'System Backup', description: 'Create system backups' }, - { id: '4', name: 'User Impersonation', description: 'Login as other users' } - ] -}) - // Loading state const isLoading = ref(false) // Computed -const selectedTemplateData = computed(() => { - return roleTemplates.value.find(t => t.id === roleForm.selectedTemplate) -}) - const isFormValid = computed(() => { return roleForm.name && roleForm.description && - roleForm.application && - (roleForm.useTemplate ? roleForm.selectedTemplate : true) + roleForm.application }) -const permissionSummary = computed(() => { - if (roleForm.useTemplate && selectedTemplateData.value) { - return selectedTemplateData.value.permissionCount - } - - const manualCount = roleForm.selectedMenus.length + - roleForm.selectedComponents.length + - roleForm.selectedFeatures.length - return manualCount +const applicationOptions = computed(() => + availableApplications.value.map(app => ({ + label: app.name, + value: app.id + })) +) + +const permissionsByCategory = computed(() => { + const grouped = {} + availablePermissions.value.forEach(permission => { + if (!grouped[permission.category]) { + grouped[permission.category] = [] + } + grouped[permission.category].push(permission) + }) + return grouped }) // Methods -const selectTemplate = (templateId) => { - roleForm.selectedTemplate = templateId - roleForm.useTemplate = true - roleForm.showAdvancedPermissions = false - - // Auto-apply template permissions if custom - if (templateId !== 'custom') { - const template = roleTemplates.value.find(t => t.id === templateId) - if (template) { - roleForm.selectedMenus = [...template.permissions.menus] - roleForm.selectedComponents = [...template.permissions.components] - roleForm.selectedFeatures = [...template.permissions.features] - } - } else { - // Clear permissions for custom role - roleForm.selectedMenus = [] - roleForm.selectedComponents = [] - roleForm.selectedFeatures = [] - roleForm.showAdvancedPermissions = true - } -} - -const toggleAdvancedPermissions = () => { - roleForm.showAdvancedPermissions = !roleForm.showAdvancedPermissions - if (roleForm.showAdvancedPermissions) { - roleForm.useTemplate = false - roleForm.selectedTemplate = 'custom' - } -} - -const handleTemplateSubmit = (templateData) => { - console.log('Creating role from template:', templateData) - - // Apply template to form - roleForm.name = templateData.name - roleForm.description = templateData.description - roleForm.permissions = { ...templateData.permissions } -} - -const handleManualSubmit = (data) => { - console.log('Creating custom role:', data) - - // Reset form - Object.assign(roleForm, { - name: '', - description: '', - permissions: { - menus: [], - components: [], - features: [] - } - }) -} - const createRole = async () => { if (!isFormValid.value) return @@ -215,16 +94,8 @@ const createRole = async () => { name: roleForm.name, description: roleForm.description, application: roleForm.application, - isGlobal: roleForm.isGlobal, - isActive: roleForm.isActive, - priority: roleForm.priority, - template: roleForm.useTemplate ? roleForm.selectedTemplate : null, - permissions: { - menus: roleForm.selectedMenus, - components: roleForm.selectedComponents, - features: roleForm.selectedFeatures - }, - syncToAuthentik: roleForm.syncToAuthentik + permissions: roleForm.permissions, + isActive: roleForm.isActive } console.log('Creating role:', roleData) @@ -246,25 +117,15 @@ const resetForm = () => { Object.assign(roleForm, { name: '', description: '', - application: '1', - isGlobal: false, - isActive: true, - priority: 50, - useTemplate: true, - selectedTemplate: '', - showAdvancedPermissions: false, - selectedMenus: [], - selectedComponents: [], - selectedFeatures: [], - selectedActions: {}, - syncToAuthentik: true + application: '', + permissions: [], + isActive: true }) } // Initialize onMounted(() => { - // Set default template - roleForm.selectedTemplate = 'viewer' + // Load additional data if needed }) @@ -277,7 +138,7 @@ onMounted(() => {

Create New Role

-

Choose a template or create a custom role with specific permissions

+

Roles define what users can do in the application

@@ -322,9 +183,14 @@ onMounted(() => { v-model="roleForm.application" type="select" label="Application" + placeholder="Select application" :options="applicationOptions" validation="required" + validation-visibility="dirty" help="Which application this role applies to" + :validation-messages="{ + required: 'Application is required' + }" />
@@ -341,189 +207,45 @@ onMounted(() => { }" /> -
- - - - - -
+
- + - - - - - - @@ -341,6 +364,7 @@ onMounted(() => { validation="required|length:8" validation-visibility="dirty" :validation-messages="{ + required: 'Password is required', length: 'Password must be at least 8 characters' }" /> @@ -353,6 +377,7 @@ onMounted(() => { validation="required|confirm:password" validation-visibility="dirty" :validation-messages="{ + required: 'Confirm password is required', confirm: 'Passwords do not match' }" /> @@ -375,45 +400,6 @@ onMounted(() => { - - - - - - - -
- - -
- - - - - - - - - - - - - - - -
+ + +
+ + + + + + + + + + + + + + + + + +
\ No newline at end of file