This commit is contained in:
parent
f828ca4491
commit
cb51a4136f
167 changed files with 21485 additions and 21212 deletions
|
@ -1,10 +1,10 @@
|
|||
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
|
||||
import Person from 'App/Models/Person';
|
||||
import type { HttpContext } from '@adonisjs/core/http';
|
||||
import Person from '#app/Models/Person';
|
||||
// import Dataset from 'App/Models/Dataset';
|
||||
|
||||
// node ace make:controller Author
|
||||
export default class AuthorsController {
|
||||
public async index({}: HttpContextContract) {
|
||||
public async index({}: HttpContext) {
|
||||
// select * from gba.persons
|
||||
// where exists (select * from gba.documents inner join gba.link_documents_persons on "documents"."id" = "link_documents_persons"."document_id"
|
||||
// where ("link_documents_persons"."role" = 'author') and ("persons"."id" = "link_documents_persons"."person_id"));
|
||||
|
@ -19,7 +19,7 @@ export default class AuthorsController {
|
|||
return authors;
|
||||
}
|
||||
|
||||
public async persons({ request }: HttpContextContract) {
|
||||
public async persons({ request }: HttpContext) {
|
||||
const authors = Person.query().where('status', true);
|
||||
|
||||
if (request.input('filter')) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
|
||||
import type { HttpContext } from '@adonisjs/core/http';
|
||||
import { StatusCodes } from 'http-status-codes';
|
||||
// import * as fs from 'fs';
|
||||
// import * as path from 'path';
|
||||
|
@ -7,7 +7,7 @@ const prefixes = ['von', 'van'];
|
|||
|
||||
// node ace make:controller Author
|
||||
export default class AvatarController {
|
||||
public async generateAvatar({ request, response }: HttpContextContract) {
|
||||
public async generateAvatar({ request, response }: HttpContext) {
|
||||
try {
|
||||
const { name, background, textColor, size } = request.only(['name', 'background', 'textColor', 'size']);
|
||||
|
||||
|
@ -40,7 +40,7 @@ export default class AvatarController {
|
|||
}
|
||||
}
|
||||
|
||||
private getInitials(name) {
|
||||
private getInitials(name: string) {
|
||||
const parts = name.split(' ');
|
||||
let initials = '';
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
|
||||
import type { HttpContext } from '@adonisjs/core/http';
|
||||
// import Person from 'App/Models/Person';
|
||||
import Dataset from 'App/Models/Dataset';
|
||||
import Dataset from '#app/Models/Dataset';
|
||||
import { StatusCodes } from 'http-status-codes';
|
||||
|
||||
// node ace make:controller Author
|
||||
export default class DatasetController {
|
||||
public async index({}: HttpContextContract) {
|
||||
public async index({}: HttpContext) {
|
||||
// select * from gba.persons
|
||||
// where exists (select * from gba.documents inner join gba.link_documents_persons on "documents"."id" = "link_documents_persons"."document_id"
|
||||
// where ("link_documents_persons"."role" = 'author') and ("persons"."id" = "link_documents_persons"."person_id"));
|
||||
|
@ -14,7 +14,7 @@ export default class DatasetController {
|
|||
return datasets;
|
||||
}
|
||||
|
||||
public async findAll({ response }: HttpContextContract) {
|
||||
public async findAll({ response }: HttpContext) {
|
||||
try {
|
||||
const datasets = await Dataset.query()
|
||||
.where('server_state', 'published')
|
||||
|
@ -29,7 +29,7 @@ export default class DatasetController {
|
|||
}
|
||||
}
|
||||
|
||||
public async findOne({ params }: HttpContextContract) {
|
||||
public async findOne({ params }: HttpContext) {
|
||||
const datasets = await Dataset.query()
|
||||
.where('publish_id', params.publish_id)
|
||||
.preload('titles')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
|
||||
import File from 'App/Models/File';
|
||||
import type { HttpContext } from '@adonisjs/core/http';
|
||||
import File from '#app/Models/File';
|
||||
import { StatusCodes } from 'http-status-codes';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
@ -7,7 +7,7 @@ import * as path from 'path';
|
|||
// node ace make:controller Author
|
||||
export default class FileController {
|
||||
// @Get("download/:id")
|
||||
public async findOne({ response, params }: HttpContextContract) {
|
||||
public async findOne({ response, params }: HttpContext) {
|
||||
const id = params.id;
|
||||
const file = await File.findOrFail(id);
|
||||
// const file = await File.findOne({
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
|
||||
import Database from '@ioc:Adonis/Lucid/Database';
|
||||
import type { HttpContext } from '@adonisjs/core/http';
|
||||
import db from '@adonisjs/lucid/services/db';
|
||||
import { StatusCodes } from 'http-status-codes';
|
||||
|
||||
export default class HomeController {
|
||||
public async findDocumentsPerYear({ response, params }: HttpContextContract) {
|
||||
public async findDocumentsPerYear({ response, params }: HttpContext) {
|
||||
const year = params.year;
|
||||
const from = parseInt(year);
|
||||
const serverState = 'published';
|
||||
|
@ -17,8 +17,8 @@ export default class HomeController {
|
|||
// .preload('authors')
|
||||
// .orderBy('server_date_published');
|
||||
|
||||
const datasets = await Database.from('documents as doc')
|
||||
.select(['publish_id', 'server_date_published', Database.raw(`date_part('year', server_date_published) as pub_year`)])
|
||||
const datasets = await db.from('documents as doc')
|
||||
.select(['publish_id', 'server_date_published', db.raw(`date_part('year', server_date_published) as pub_year`)])
|
||||
.where('server_state', serverState)
|
||||
.innerJoin('link_documents_persons as ba', 'doc.id', 'ba.document_id')
|
||||
.andWhereRaw(`date_part('year', server_date_published) = ?`, [from])
|
||||
|
@ -32,17 +32,17 @@ export default class HomeController {
|
|||
}
|
||||
}
|
||||
|
||||
public async findYears({ response }: HttpContextContract) {
|
||||
public async findYears({ response }: HttpContext) {
|
||||
const serverState = 'published';
|
||||
// Use raw SQL queries to select all cars which belongs to the user
|
||||
try {
|
||||
const datasets = await Database.rawQuery(
|
||||
const datasets = await db.rawQuery(
|
||||
'SELECT distinct EXTRACT(YEAR FROM server_date_published) as published_date FROM gba.documents WHERE server_state = ?',
|
||||
[serverState],
|
||||
);
|
||||
|
||||
// Pluck the ids of the cars
|
||||
const years = datasets.rows.map((dataset) => dataset.published_date);
|
||||
const years = datasets.rows.map((dataset: any) => dataset.published_date);
|
||||
// check if the cars is returned
|
||||
// if (years.length > 0) {
|
||||
return response.status(StatusCodes.OK).json(years);
|
||||
|
@ -54,7 +54,7 @@ export default class HomeController {
|
|||
}
|
||||
}
|
||||
|
||||
public async findPublicationsPerMonth({ response }: HttpContextContract) {
|
||||
public async findPublicationsPerMonth({ response }: HttpContext) {
|
||||
const serverState = 'published';
|
||||
// const year = params.year;
|
||||
// const from = parseInt(year);
|
||||
|
@ -70,11 +70,11 @@ export default class HomeController {
|
|||
|
||||
const years = [2021, 2022, 2023]; // Add the second year
|
||||
|
||||
const result = await Database.from('documents as doc')
|
||||
const result = await db.from('documents as doc')
|
||||
.select([
|
||||
Database.raw(`date_part('year', server_date_published) as pub_year`),
|
||||
Database.raw(`date_part('month', server_date_published) as pub_month`),
|
||||
Database.raw('COUNT(*) as count'),
|
||||
db.raw(`date_part('year', server_date_published) as pub_year`),
|
||||
db.raw(`date_part('month', server_date_published) as pub_month`),
|
||||
db.raw('COUNT(*) as count'),
|
||||
])
|
||||
.where('server_state', serverState)
|
||||
// .innerJoin('link_documents_persons as ba', 'doc.id', 'ba.document_id')
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
|
||||
import type { HttpContext } from '@adonisjs/core/http';
|
||||
// import TotpSecret from 'App/Models/TotpSecret';
|
||||
import User from 'App/Models/User';
|
||||
import TwoFactorAuthProvider from 'App/Services/TwoFactorAuthProvider';
|
||||
import User from '#app/Models/User';
|
||||
import TwoFactorAuthProvider from '#app/Services/TwoFactorAuthProvider';
|
||||
import { StatusCodes } from 'http-status-codes';
|
||||
import { InvalidArgumentException } from 'node-exceptions';
|
||||
import { TotpState } from 'Contracts/enums';
|
||||
import { TotpState } from '#contracts/enums';
|
||||
|
||||
|
||||
// Here we are generating secret and recovery codes for the user that’s enabling 2FA and storing them to our database.
|
||||
export default class UserController {
|
||||
public async enable({ auth, response, request }: HttpContextContract) {
|
||||
public async enable({ auth, response, request }: HttpContext) {
|
||||
const user = (await User.find(auth.user?.id)) as User;
|
||||
// await user.load('totp_secret');
|
||||
// if (!user.totp_secret) {
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue