|
@@ -351,6 +351,9 @@
|
|
|
<div>
|
|
<div>
|
|
|
<span x-text="p.key" class="font-bold text-slate-300"></span>
|
|
<span x-text="p.key" class="font-bold text-slate-300"></span>
|
|
|
<span class="text-brand-500 text-xs ml-2" x-text="'[' + p.actions.join(',') + ']'"></span>
|
|
<span class="text-brand-500 text-xs ml-2" x-text="'[' + p.actions.join(',') + ']'"></span>
|
|
|
|
|
+ <template x-if="p.constraint">
|
|
|
|
|
+ <span class="text-yellow-500 text-xs ml-2" x-text="'Range: ' + (p.constraint.min !== null ? p.constraint.min : '-∞') + ' ~ ' + (p.constraint.max !== null ? p.constraint.max : '+∞')"></span>
|
|
|
|
|
+ </template>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="flex gap-2 opacity-0 group-hover/perm:opacity-100 transition-opacity">
|
|
<div class="flex gap-2 opacity-0 group-hover/perm:opacity-100 transition-opacity">
|
|
|
<button @click="openAddPermModal(r.name, p)" class="text-blue-400 hover:text-blue-300" title="Edit">
|
|
<button @click="openAddPermModal(r.name, p)" class="text-blue-400 hover:text-blue-300" title="Edit">
|
|
@@ -430,6 +433,18 @@
|
|
|
</label>
|
|
</label>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+
|
|
|
|
|
+ <div x-show="newPerm.actions.includes('write')" x-transition class="grid grid-cols-2 gap-4">
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <label class="block text-sm font-medium mb-2 text-slate-400">Min Value (Optional)</label>
|
|
|
|
|
+ <input x-model="newPerm.min" type="number" step="any" placeholder="No Limit" class="w-full bg-dark-900 border border-dark-700 rounded-lg p-3 text-white outline-none focus:border-brand-500">
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <label class="block text-sm font-medium mb-2 text-slate-400">Max Value (Optional)</label>
|
|
|
|
|
+ <input x-model="newPerm.max" type="number" step="any" placeholder="No Limit" class="w-full bg-dark-900 border border-dark-700 rounded-lg p-3 text-white outline-none focus:border-brand-500">
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
<div class="flex gap-3 pt-2">
|
|
<div class="flex gap-3 pt-2">
|
|
|
<button @click="addPermission" class="flex-1 bg-brand-600 text-white py-2 rounded-lg font-bold hover:bg-brand-500" x-text="isEditing ? 'Save' : 'Add'"></button>
|
|
<button @click="addPermission" class="flex-1 bg-brand-600 text-white py-2 rounded-lg font-bold hover:bg-brand-500" x-text="isEditing ? 'Save' : 'Add'"></button>
|
|
|
<button @click="showAddPermModal = false" class="flex-1 bg-dark-700 text-white py-2 rounded-lg font-bold hover:bg-dark-600">Cancel</button>
|
|
<button @click="showAddPermModal = false" class="flex-1 bg-dark-700 text-white py-2 rounded-lg font-bold hover:bg-dark-600">Cancel</button>
|
|
@@ -478,7 +493,7 @@
|
|
|
showAddPermModal: false,
|
|
showAddPermModal: false,
|
|
|
isEditing: false,
|
|
isEditing: false,
|
|
|
selectedRole: '',
|
|
selectedRole: '',
|
|
|
- newPerm: { pattern: '', actions: [] },
|
|
|
|
|
|
|
+ newPerm: { pattern: '', actions: [], min: '', max: '' },
|
|
|
|
|
|
|
|
init() {
|
|
init() {
|
|
|
if (this.token) {
|
|
if (this.token) {
|
|
@@ -647,10 +662,15 @@
|
|
|
this.selectedRole = roleName;
|
|
this.selectedRole = roleName;
|
|
|
if (perm) {
|
|
if (perm) {
|
|
|
this.isEditing = true;
|
|
this.isEditing = true;
|
|
|
- this.newPerm = { pattern: perm.key, actions: [...perm.actions] };
|
|
|
|
|
|
|
+ this.newPerm = {
|
|
|
|
|
+ pattern: perm.key,
|
|
|
|
|
+ actions: [...perm.actions],
|
|
|
|
|
+ min: perm.constraint && perm.constraint.min !== undefined ? perm.constraint.min : '',
|
|
|
|
|
+ max: perm.constraint && perm.constraint.max !== undefined ? perm.constraint.max : ''
|
|
|
|
|
+ };
|
|
|
} else {
|
|
} else {
|
|
|
this.isEditing = false;
|
|
this.isEditing = false;
|
|
|
- this.newPerm = { pattern: '', actions: [] };
|
|
|
|
|
|
|
+ this.newPerm = { pattern: '', actions: [], min: '', max: '' };
|
|
|
}
|
|
}
|
|
|
this.showAddPermModal = true;
|
|
this.showAddPermModal = true;
|
|
|
},
|
|
},
|
|
@@ -671,9 +691,21 @@
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
try {
|
|
try {
|
|
|
- // Command: ROLE_PERMISSION_ADD <role> <pattern> <actions>
|
|
|
|
|
|
|
+ // Command: ROLE_PERMISSION_ADD <role> <pattern> <actions> [min] [max]
|
|
|
const actionsStr = this.newPerm.actions.join(',');
|
|
const actionsStr = this.newPerm.actions.join(',');
|
|
|
- await this.api('ROLE_PERMISSION_ADD', [this.selectedRole, this.newPerm.pattern, actionsStr]);
|
|
|
|
|
|
|
+ const args = [this.selectedRole, this.newPerm.pattern, actionsStr];
|
|
|
|
|
+
|
|
|
|
|
+ if (this.newPerm.actions.includes('write')) {
|
|
|
|
|
+ const minVal = (this.newPerm.min !== '' && this.newPerm.min !== null) ? this.newPerm.min : '-';
|
|
|
|
|
+ const maxVal = (this.newPerm.max !== '' && this.newPerm.max !== null) ? this.newPerm.max : '-';
|
|
|
|
|
+
|
|
|
|
|
+ if (minVal !== '-' || maxVal !== '-') {
|
|
|
|
|
+ args.push(String(minVal));
|
|
|
|
|
+ args.push(String(maxVal));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ await this.api('ROLE_PERMISSION_ADD', args);
|
|
|
this.showAddPermModal = false;
|
|
this.showAddPermModal = false;
|
|
|
this.fetchRoles();
|
|
this.fetchRoles();
|
|
|
} catch (e) {
|
|
} catch (e) {
|