- added LicenseController.ts and MimetypeController for enabling mime_types and licences
Some checks failed
CI Pipeline / japa-tests (push) Failing after 58s
Some checks failed
CI Pipeline / japa-tests (push) Failing after 58s
- add new authors and contributors only by unique email addresses - allow multiple file upload - added validation rule for validating length of uploaded files - modified Dockerfile for starting "bin/server.js" instead of *server.js" - npm updates
This commit is contained in:
parent
770e791613
commit
ac473b1e72
27 changed files with 1720 additions and 914 deletions
|
@ -134,7 +134,7 @@ export default class AdminuserController {
|
|||
// validate update form
|
||||
await request.validateUsing(updateUserValidator, {
|
||||
meta: {
|
||||
userId: user.id,
|
||||
objId: user.id,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -166,8 +166,8 @@ export default class AdminuserController {
|
|||
return response.redirect().toRoute('settings.user.index');
|
||||
}
|
||||
|
||||
// private async syncRoles(userId: number, roleIds: Array<number>) {
|
||||
// const user = await User.findOrFail(userId)
|
||||
// private async syncRoles(objId: number, roleIds: Array<number>) {
|
||||
// const user = await User.findOrFail(objId)
|
||||
// // const roles: Role[] = await Role.query().whereIn('id', roleIds);
|
||||
|
||||
// // await user.roles().sync(roles.rows.map(role => role.id))
|
||||
|
|
51
app/Controllers/Http/Admin/LicenseController.ts
Normal file
51
app/Controllers/Http/Admin/LicenseController.ts
Normal file
|
@ -0,0 +1,51 @@
|
|||
import type { HttpContext } from '@adonisjs/core/http';
|
||||
import License from '#models/license';
|
||||
|
||||
export default class LicenseController {
|
||||
public async index({ auth, inertia }: HttpContext) {
|
||||
const direction = 'asc'; // or 'desc'
|
||||
const licenses = await License.query().orderBy('sort_order', direction).exec();
|
||||
|
||||
return inertia.render('Admin/License/Index', {
|
||||
licenses: licenses,
|
||||
can: {
|
||||
edit: await auth.user?.can(['settings']),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public async down({ request, response }: HttpContext) {
|
||||
const id = request.param('id');
|
||||
const license = await License.findOrFail(id);
|
||||
license.active = false;
|
||||
await license.save();
|
||||
|
||||
// session.flash({ message: 'person has been deactivated!' });
|
||||
return response.flash('person has been deactivated!', 'message').toRoute('settings.license.index')
|
||||
}
|
||||
|
||||
public async up({ request, response }: HttpContext) {
|
||||
const id = request.param('id');
|
||||
const license = await License.findOrFail(id);
|
||||
license.active = true;
|
||||
await license.save();
|
||||
|
||||
// session.flash({ message: 'person has been activated!' });
|
||||
return response.flash('person has been activated!', 'message').toRoute('settings.license.index');
|
||||
}
|
||||
|
||||
// public async edit({ request, inertia }: HttpContext) {
|
||||
// const id = request.param('id');
|
||||
// const license = await License.query().where('id', id).firstOrFail();
|
||||
|
||||
// // const permissions = await Permission.query().pluck('name', 'id');
|
||||
// // // const userHasRoles = user.roles;
|
||||
// // const rolerHasPermissions = await role.related('permissions').query().orderBy('name').pluck('id');
|
||||
|
||||
// return inertia.render('Admin/License/Edit', {
|
||||
// // permissions: permissions,
|
||||
// license: license,
|
||||
// // roleHasPermissions: Object.keys(rolerHasPermissions).map((key) => rolerHasPermissions[key]), //convert object to array with role ids
|
||||
// });
|
||||
// }
|
||||
}
|
51
app/Controllers/Http/Admin/MimetypeController.ts
Normal file
51
app/Controllers/Http/Admin/MimetypeController.ts
Normal file
|
@ -0,0 +1,51 @@
|
|||
import type { HttpContext } from '@adonisjs/core/http';
|
||||
import MimeType from '#models/mime_type';
|
||||
|
||||
export default class MimetypeController {
|
||||
public async index({ auth, inertia }: HttpContext) {
|
||||
const direction = 'asc'; // or 'desc'
|
||||
const mimetypes = await MimeType.query().orderBy('name', direction).exec();
|
||||
|
||||
return inertia.render('Admin/Mimetype/Index', {
|
||||
mimetypes: mimetypes,
|
||||
can: {
|
||||
edit: await auth.user?.can(['settings']),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public async down({ request, response }: HttpContext) {
|
||||
const id = request.param('id');
|
||||
const mimetype = await MimeType.findOrFail(id);
|
||||
mimetype.enabled = false;
|
||||
await mimetype .save();
|
||||
|
||||
// session.flash({ message: 'person has been deactivated!' });
|
||||
return response.flash('mimetype has been deactivated!', 'message').toRoute('settings.mimetype.index')
|
||||
}
|
||||
|
||||
public async up({ request, response }: HttpContext) {
|
||||
const id = request.param('id');
|
||||
const mimetype = await MimeType.findOrFail(id);
|
||||
mimetype.enabled = true;
|
||||
await mimetype .save();
|
||||
|
||||
// session.flash({ message: 'person has been activated!' });
|
||||
return response.flash('mimetype has been activated!', 'message').toRoute('settings.mimetype.index');
|
||||
}
|
||||
|
||||
// public async edit({ request, inertia }: HttpContext) {
|
||||
// const id = request.param('id');
|
||||
// const license = await License.query().where('id', id).firstOrFail();
|
||||
|
||||
// // const permissions = await Permission.query().pluck('name', 'id');
|
||||
// // // const userHasRoles = user.roles;
|
||||
// // const rolerHasPermissions = await role.related('permissions').query().orderBy('name').pluck('id');
|
||||
|
||||
// return inertia.render('Admin/License/Edit', {
|
||||
// // permissions: permissions,
|
||||
// license: license,
|
||||
// // roleHasPermissions: Object.keys(rolerHasPermissions).map((key) => rolerHasPermissions[key]), //convert object to array with role ids
|
||||
// });
|
||||
// }
|
||||
}
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue