urls & files: set page size to 25, add page nav and sort by create desc
This commit is contained in:
parent
0dfae21005
commit
0de960a168
@ -26,7 +26,7 @@ export default class FileController extends Controller {
|
||||
max_upload_size: config.get<string>('max_upload_size'),
|
||||
allowed_domains: allowedDomains,
|
||||
default_domain: allowedDomains[config.get<number>('default_url_domain_for_files')],
|
||||
files: await FileModel.paginateForUser(req, 100, user.getOrFail('id')),
|
||||
files: await FileModel.paginateForUser(req, 25, user.getOrFail('id')),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ export default class URLRedirectController extends Controller {
|
||||
res.render('url-shrinker', {
|
||||
allowed_domains: allowedDomains,
|
||||
default_domain: allowedDomains[config.get<number>('default_url_domain_for_urls')],
|
||||
urls: await URLRedirect.paginateForUser(req, 2, user.getOrFail('id')),
|
||||
urls: await URLRedirect.paginateForUser(req, 25, user.getOrFail('id')),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@ export default class FileModel extends Model {
|
||||
}
|
||||
|
||||
public static async paginateForUser(req: Request, perPage: number, user_id: number): Promise<FileModel[]> {
|
||||
req.params.sortBy = 'created_at';
|
||||
req.params.sortDirection = 'DESC';
|
||||
return await this.paginate(req, perPage, this.select().where('user_id', user_id));
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@ export default class URLRedirect extends Model {
|
||||
}
|
||||
|
||||
public static async paginateForUser(req: Request, perPage: number, user_id: number): Promise<URLRedirect[]> {
|
||||
req.params.sortBy = 'created_at';
|
||||
req.params.sortDirection = 'DESC';
|
||||
return await this.paginate(req, perPage, this.select().where('user_id', user_id));
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,9 @@
|
||||
|
||||
<section class="panel">
|
||||
<h2><i data-feather="folder"></i> File list</h2>
|
||||
|
||||
{{ macros.paginate(files.pagination, 'file-uploader', 3) }}
|
||||
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -94,6 +97,8 @@
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{{ macros.paginate(files.pagination, 'file-uploader', 3) }}
|
||||
</section>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -38,6 +38,9 @@
|
||||
|
||||
<section class="panel">
|
||||
<h2><i data-feather="link"></i> URL list</h2>
|
||||
|
||||
{{ macros.paginate(urls.pagination, 'url-shrinker', 3) }}
|
||||
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -62,6 +65,8 @@
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{{ macros.paginate(urls.pagination, 'url-shrinker', 3) }}
|
||||
</section>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user