work on main page

This commit is contained in:
Jake Potrebic 2021-03-16 10:25:32 -07:00
parent defdf66782
commit 4531d7a597
No known key found for this signature in database
GPG Key ID: 7C58557EC9C421F8
3 changed files with 19 additions and 9 deletions

View File

@ -23,6 +23,12 @@
</NuxtLink>
</v-hover>
</template>
<template #no-data>
<div>{{ $t('hangar.projectSearch.noProjects') }}</div>
</template>
<template #no-results>
<div>{{ $t('hangar.projectSearch.noProjectsFound') }}</div>
</template>
</v-data-iterator>
</template>

View File

@ -25,6 +25,8 @@ const msgs: LocaleMessageObject = {
projectSearch: {
query: 'Search in {0} projects, proudly made by the community...',
relevanceSort: 'Sort with relevance',
noProjects: 'There are no projects. :/',
noProjectsFound: 'Found 0 projects. :/',
},
subtitle: 'A Minecraft package repository',
sponsoredBy: 'Sponsored by',

View File

@ -8,7 +8,7 @@
</v-row>
<v-row justify="center" align="center">
<v-col cols="12">
<v-text-field v-model="projectFilter" :label="$t('hangar.projectSearch.query', [totalProjects])" clearable></v-text-field>
<v-text-field v-model="projectFilter" :label="$t('hangar.projectSearch.query', [projects.pagination.count])" clearable></v-text-field>
</v-col>
</v-row>
<v-row justify="center" align="center">
@ -60,7 +60,7 @@
<script lang="ts">
import { Component, Vue } from 'nuxt-property-decorator';
import { PaginatedResult, Project, Sponsor } from 'hangar-api';
import { IPlatform, ProjectPage } from 'hangar-internal';
import { IPlatform } from 'hangar-internal';
import { Context } from '@nuxt/types';
import ProjectList from '~/components/projects/ProjectList.vue';
import HangarSponsor from '~/components/layouts/Sponsor.vue';
@ -74,8 +74,7 @@ import { RootState } from '~/store';
})
export default class Home extends Vue {
// TODO implement filtering
projects?: PaginatedResult<Project>;
totalProjects: Number = 1337;
projects!: PaginatedResult<Project>;
projectFilter: String | null = null;
sponsor!: Sponsor;
@ -90,11 +89,14 @@ export default class Home extends Vue {
}
async asyncData({ $api, $util }: Context) {
const sponsor = await $api.requestInternal<ProjectPage>(`data/sponsor`, false).catch<any>($util.handleRequestError);
const projects = await $api
.request<PaginatedResult<Project>>('projects', false, 'get', { limit: 25, offset: 0 })
.catch<any>($util.handlePageRequestError);
return { projects, sponsor };
const res = await Promise.all<Sponsor, PaginatedResult<Project>>([
$api.requestInternal<Sponsor>(`data/sponsor`, false),
$api.request<PaginatedResult<Project>>('projects', false, 'get', { limit: 25, offset: 0 }),
]).catch($util.handlePageRequestError);
if (typeof res === 'undefined') {
return;
}
return { sponsor: res[0], projects: res[1] };
}
}
</script>