Added pagination and total to revisions.
This commit is contained in:
@@ -5,8 +5,10 @@ import { computed, inject, ref } from 'vue';
|
|||||||
import Avatar from '#/components/edit/avatar.vue';
|
import Avatar from '#/components/edit/avatar.vue';
|
||||||
import Socials from '#/components/edit/revision-socials.vue';
|
import Socials from '#/components/edit/revision-socials.vue';
|
||||||
import Checkbox from '#/components/form/checkbox.vue';
|
import Checkbox from '#/components/form/checkbox.vue';
|
||||||
|
import Pagination from '#/components/pagination/pagination.vue';
|
||||||
|
|
||||||
import { get, post } from '#/src/api.js';
|
import { get, post } from '#/src/api.js';
|
||||||
|
import navigate from '#/src/navigate.js';
|
||||||
import { formatDuration } from '#/utils/format.js';
|
import { formatDuration } from '#/utils/format.js';
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
@@ -31,10 +33,14 @@ const moviesById = computed(() => Object.fromEntries(movies.value.map((movie) =>
|
|||||||
const avatarsById = computed(() => Object.fromEntries(avatars.value.map((avatar) => [avatar.id, avatar])));
|
const avatarsById = computed(() => Object.fromEntries(avatars.value.map((avatar) => [avatar.id, avatar])));
|
||||||
|
|
||||||
const feedbacks = ref({});
|
const feedbacks = ref({});
|
||||||
const showReviewed = ref(false);
|
const showReviewed = ref(Object.hasOwn(pageContext.urlParsed.search, 'final'));
|
||||||
const reviewedRevisions = ref(new Set());
|
const reviewedRevisions = ref(new Set());
|
||||||
const expanded = ref(new Set());
|
const expanded = ref(new Set());
|
||||||
|
|
||||||
|
const total = ref(pageContext.pageProps.revisionTotal);
|
||||||
|
const page = Number(pageContext.routeParams.page) || 1;
|
||||||
|
const limit = Number(pageContext.urlParsed.search.limit) || 100;
|
||||||
|
|
||||||
const mappedKeys = {
|
const mappedKeys = {
|
||||||
actors: actorsById,
|
actors: actorsById,
|
||||||
// tags: tagsById,
|
// tags: tagsById,
|
||||||
@@ -163,7 +169,8 @@ const curatedRevisions = computed(() => revisions.value.map((revision) => {
|
|||||||
async function reloadRevisions() {
|
async function reloadRevisions() {
|
||||||
const updatedRevisions = await get(`/revisions/${domain}`, {
|
const updatedRevisions = await get(`/revisions/${domain}`, {
|
||||||
isFinalized: showReviewed.value ? undefined : false,
|
isFinalized: showReviewed.value ? undefined : false,
|
||||||
limit: 50,
|
page,
|
||||||
|
limit,
|
||||||
});
|
});
|
||||||
|
|
||||||
actors.value = updatedRevisions.actors;
|
actors.value = updatedRevisions.actors;
|
||||||
@@ -171,6 +178,14 @@ async function reloadRevisions() {
|
|||||||
movies.value = updatedRevisions.movies;
|
movies.value = updatedRevisions.movies;
|
||||||
avatars.value = updatedRevisions.avatars;
|
avatars.value = updatedRevisions.avatars;
|
||||||
revisions.value = updatedRevisions.revisions;
|
revisions.value = updatedRevisions.revisions;
|
||||||
|
total.value = updatedRevisions.total;
|
||||||
|
|
||||||
|
navigate(pageContext.urlParsed.pathname, {
|
||||||
|
...pageContext.urlParsed.search,
|
||||||
|
final: showReviewed.value || undefined,
|
||||||
|
}, {
|
||||||
|
redirect: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reviewRevision(revision, isApproved) {
|
async function reviewRevision(revision, isApproved) {
|
||||||
@@ -208,10 +223,12 @@ async function banEditor(revision) {
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<div
|
<div
|
||||||
v-if="context === 'admin'"
|
|
||||||
class="revs-header"
|
class="revs-header"
|
||||||
>
|
>
|
||||||
|
<span class="revs-total">{{ total }} revisions</span>
|
||||||
|
|
||||||
<Checkbox
|
<Checkbox
|
||||||
|
v-if="context === 'admin'"
|
||||||
label="Show finalized"
|
label="Show finalized"
|
||||||
:checked="showReviewed"
|
:checked="showReviewed"
|
||||||
@change="(checked) => { showReviewed = checked; reloadRevisions(); }"
|
@change="(checked) => { showReviewed = checked; reloadRevisions(); }"
|
||||||
@@ -388,13 +405,12 @@ async function banEditor(revision) {
|
|||||||
class="rev-compact"
|
class="rev-compact"
|
||||||
@click="expanded.add(rev.id)"
|
@click="expanded.add(rev.id)"
|
||||||
>
|
>
|
||||||
|
|
||||||
<span class="rev-scene nolink noshrink"><template v-if="context !== 'scene' && context !== 'actor'">{{ rev.sceneId || rev.actorId }}</template>@{{ rev.hash.slice(0, 6) }}</span>
|
<span class="rev-scene nolink noshrink"><template v-if="context !== 'scene' && context !== 'actor'">{{ rev.sceneId || rev.actorId }}</template>@{{ rev.hash.slice(0, 6) }}</span>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
v-if="context !== 'scene'"
|
v-if="context !== 'scene'"
|
||||||
class="rev-title nolink ellipsis"
|
class="rev-title nolink ellipsis"
|
||||||
>{{ rev.base.title }}</span>
|
>{{ rev.base.title || rev.base.name }}</span>
|
||||||
|
|
||||||
<span class="rev-summary">
|
<span class="rev-summary">
|
||||||
<span class="summary-deltas ellipsis">{{ rev.deltas.map((delta) => delta.key).join(', ') }}</span>
|
<span class="summary-deltas ellipsis">{{ rev.deltas.map((delta) => delta.key).join(', ') }}</span>
|
||||||
@@ -431,6 +447,13 @@ async function banEditor(revision) {
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<Pagination
|
||||||
|
v-if="total"
|
||||||
|
:total="total"
|
||||||
|
:page="page"
|
||||||
|
:limit="limit"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -443,13 +466,20 @@ async function banEditor(revision) {
|
|||||||
|
|
||||||
.revs-header {
|
.revs-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-bottom: 1rem;
|
justify-content: space-between;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: .5rem .5rem .75rem .5rem;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
.check-container {
|
.check-container {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.revs-total {
|
||||||
|
color: var(--shadow-strong-10);
|
||||||
|
}
|
||||||
|
|
||||||
.revs {
|
.revs {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ const props = defineProps({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
limit: {
|
||||||
|
type: Number,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
redirect: {
|
redirect: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
|
|||||||
@@ -10,10 +10,12 @@ export async function onBeforeRender(pageContext) {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
revisions,
|
revisions,
|
||||||
|
total: revisionTotal,
|
||||||
avatars,
|
avatars,
|
||||||
} = await fetchActorRevisions(null, {
|
} = await fetchActorRevisions(null, {
|
||||||
isFinalized: false,
|
isFinalized: Object.hasOwn(pageContext.urlParsed.search, 'final'),
|
||||||
limit: 50,
|
limit: Number(pageContext.urlParsed.search.limit) || 100,
|
||||||
|
page: Number(pageContext.routeParams.page) || 1,
|
||||||
}, pageContext.user);
|
}, pageContext.user);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -21,6 +23,7 @@ export async function onBeforeRender(pageContext) {
|
|||||||
title: pageContext.routeParams.section,
|
title: pageContext.routeParams.section,
|
||||||
pageProps: {
|
pageProps: {
|
||||||
revisions,
|
revisions,
|
||||||
|
revisionTotal,
|
||||||
avatars,
|
avatars,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { match } from 'path-to-regexp';
|
import { match } from 'path-to-regexp';
|
||||||
|
|
||||||
const path = '/admin/:section/:domain(actors)';
|
const path = '/admin/:section/:domain(actors)/:page?';
|
||||||
const urlMatch = match(path, { decode: decodeURIComponent });
|
const urlMatch = match(path, { decode: decodeURIComponent });
|
||||||
|
|
||||||
export default (pageContext) => {
|
export default (pageContext) => {
|
||||||
@@ -11,6 +11,8 @@ export default (pageContext) => {
|
|||||||
routeParams: {
|
routeParams: {
|
||||||
section: matched.params.section,
|
section: matched.params.section,
|
||||||
domain: matched.params.domain,
|
domain: matched.params.domain,
|
||||||
|
page: matched.params.page || '1',
|
||||||
|
path,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,14 @@ export async function onBeforeRender(pageContext) {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
revisions,
|
revisions,
|
||||||
|
total: revisionTotal,
|
||||||
actors,
|
actors,
|
||||||
tags,
|
tags,
|
||||||
movies,
|
movies,
|
||||||
} = await fetchSceneRevisions(null, {
|
} = await fetchSceneRevisions(null, {
|
||||||
isFinalized: false,
|
isFinalized: Object.hasOwn(pageContext.urlParsed.search, 'final'),
|
||||||
limit: 50,
|
limit: Number(pageContext.urlParsed.search.limit) || 100,
|
||||||
|
page: Number(pageContext.routeParams.page) || 1,
|
||||||
}, pageContext.user);
|
}, pageContext.user);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -23,6 +25,7 @@ export async function onBeforeRender(pageContext) {
|
|||||||
title: pageContext.routeParams.section,
|
title: pageContext.routeParams.section,
|
||||||
pageProps: {
|
pageProps: {
|
||||||
revisions,
|
revisions,
|
||||||
|
revisionTotal,
|
||||||
actors,
|
actors,
|
||||||
tags,
|
tags,
|
||||||
movies,
|
movies,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { match } from 'path-to-regexp';
|
import { match } from 'path-to-regexp';
|
||||||
|
|
||||||
const path = '/admin/:section/:domain(scenes)';
|
const path = '/admin/:section/:domain(scenes)/:page?';
|
||||||
const urlMatch = match(path, { decode: decodeURIComponent });
|
const urlMatch = match(path, { decode: decodeURIComponent });
|
||||||
|
|
||||||
export default (pageContext) => {
|
export default (pageContext) => {
|
||||||
@@ -11,6 +11,8 @@ export default (pageContext) => {
|
|||||||
routeParams: {
|
routeParams: {
|
||||||
section: matched.params.section,
|
section: matched.params.section,
|
||||||
domain: matched.params.domain,
|
domain: matched.params.domain,
|
||||||
|
page: matched.params.page || '1',
|
||||||
|
path,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,14 +15,16 @@ async function fetchRevisions(pageContext) {
|
|||||||
if (pageContext.routeParams.section === 'revisions' && pageContext.routeParams.domain === 'scenes') {
|
if (pageContext.routeParams.section === 'revisions' && pageContext.routeParams.domain === 'scenes') {
|
||||||
return fetchSceneRevisions(null, {
|
return fetchSceneRevisions(null, {
|
||||||
userId: pageContext.user.id,
|
userId: pageContext.user.id,
|
||||||
limit: 100,
|
limit: Number(pageContext.urlParsed.search.limit) || 100,
|
||||||
|
page: Number(pageContext.routeParams.page) || 1,
|
||||||
}, pageContext.user);
|
}, pageContext.user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pageContext.routeParams.section === 'revisions' && pageContext.routeParams.domain === 'actors') {
|
if (pageContext.routeParams.section === 'revisions' && pageContext.routeParams.domain === 'actors') {
|
||||||
return fetchActorRevisions(null, {
|
return fetchActorRevisions(null, {
|
||||||
userId: pageContext.user.id,
|
userId: pageContext.user.id,
|
||||||
limit: 100,
|
limit: Number(pageContext.urlParsed.search.limit) || 100,
|
||||||
|
page: Number(pageContext.routeParams.page) || 1,
|
||||||
}, pageContext.user);
|
}, pageContext.user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,6 +49,7 @@ export async function onBeforeRender(pageContext) {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
revisions,
|
revisions,
|
||||||
|
total: revisionTotal,
|
||||||
actors,
|
actors,
|
||||||
tags,
|
tags,
|
||||||
movies,
|
movies,
|
||||||
@@ -63,6 +66,7 @@ export async function onBeforeRender(pageContext) {
|
|||||||
stashes,
|
stashes,
|
||||||
alerts,
|
alerts,
|
||||||
revisions,
|
revisions,
|
||||||
|
revisionTotal,
|
||||||
keys,
|
keys,
|
||||||
actors,
|
actors,
|
||||||
tags,
|
tags,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { match } from 'path-to-regexp';
|
import { match } from 'path-to-regexp';
|
||||||
import { redirect } from 'vike/abort';
|
import { redirect } from 'vike/abort';
|
||||||
|
|
||||||
const path = '/user/:username/:section?/:domain?';
|
const path = '/user/:username/:section?/:domain?/:page?';
|
||||||
const urlMatch = match(path, { decode: decodeURIComponent });
|
const urlMatch = match(path, { decode: decodeURIComponent });
|
||||||
|
|
||||||
export default (pageContext) => {
|
export default (pageContext) => {
|
||||||
@@ -18,6 +18,8 @@ export default (pageContext) => {
|
|||||||
username: matched.params.username,
|
username: matched.params.username,
|
||||||
section: matched.params.section || '',
|
section: matched.params.section || '',
|
||||||
domain: matched.params.domain || '',
|
domain: matched.params.domain || '',
|
||||||
|
page: matched.params.page || '1',
|
||||||
|
path,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1059,6 +1059,7 @@ export async function fetchActorRevisions(revisionId, filters = {}, reqUser) {
|
|||||||
'actors_revisions.*',
|
'actors_revisions.*',
|
||||||
'users.username as username',
|
'users.username as username',
|
||||||
'reviewers.username as reviewer_username',
|
'reviewers.username as reviewer_username',
|
||||||
|
knex.raw('count(*) over() as total'),
|
||||||
)
|
)
|
||||||
.leftJoin('users', 'users.id', 'actors_revisions.user_id')
|
.leftJoin('users', 'users.id', 'actors_revisions.user_id')
|
||||||
.leftJoin('users as reviewers', 'reviewers.id', 'actors_revisions.reviewed_by')
|
.leftJoin('users as reviewers', 'reviewers.id', 'actors_revisions.reviewed_by')
|
||||||
@@ -1105,6 +1106,7 @@ export async function fetchActorRevisions(revisionId, filters = {}, reqUser) {
|
|||||||
return {
|
return {
|
||||||
revisions: curatedRevisions,
|
revisions: curatedRevisions,
|
||||||
revision: revisionId && curatedRevisions.find((revision) => revision.id === revisionId),
|
revision: revisionId && curatedRevisions.find((revision) => revision.id === revisionId),
|
||||||
|
total: Number(revisions[0]?.total) || 0,
|
||||||
avatars,
|
avatars,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -766,6 +766,7 @@ export async function fetchSceneRevisions(revisionId, filters = {}, reqUser) {
|
|||||||
'scenes_revisions.*',
|
'scenes_revisions.*',
|
||||||
'users.username as username',
|
'users.username as username',
|
||||||
'reviewers.username as reviewer_username',
|
'reviewers.username as reviewer_username',
|
||||||
|
knexOwner.raw('count(*) over() as total'),
|
||||||
)
|
)
|
||||||
.leftJoin('users', 'users.id', 'scenes_revisions.user_id')
|
.leftJoin('users', 'users.id', 'scenes_revisions.user_id')
|
||||||
.leftJoin('users as reviewers', 'reviewers.id', 'scenes_revisions.reviewed_by')
|
.leftJoin('users as reviewers', 'reviewers.id', 'scenes_revisions.reviewed_by')
|
||||||
@@ -824,6 +825,7 @@ export async function fetchSceneRevisions(revisionId, filters = {}, reqUser) {
|
|||||||
return {
|
return {
|
||||||
revisions: curatedRevisions,
|
revisions: curatedRevisions,
|
||||||
revision: revisionId && curatedRevisions.find((revision) => revision.id === revisionId),
|
revision: revisionId && curatedRevisions.find((revision) => revision.id === revisionId),
|
||||||
|
total: Number(revisions[0]?.total) || 0,
|
||||||
actors,
|
actors,
|
||||||
tags,
|
tags,
|
||||||
movies,
|
movies,
|
||||||
|
|||||||
Reference in New Issue
Block a user