Hangar/frontend/pages/index.vue

104 lines
3.8 KiB
Vue
Raw Normal View History

2021-01-21 11:36:18 +08:00
<template>
<div>
<v-row>
<v-col cols="12" sm="8" md="5" offset-md="3">
<v-row justify="center" align="center">
<h1>Hangar</h1>
2021-01-23 05:06:44 +08:00
<v-subheader v-text="$t('hangar.subtitle')"></v-subheader>
</v-row>
<v-row justify="center" align="center">
<v-col cols="12">
2021-03-17 01:25:32 +08:00
<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">
<v-col cols="12">
2021-02-11 19:48:52 +08:00
<ProjectList :projects="projects"></ProjectList>
</v-col>
</v-row>
</v-col>
<v-col cols="12" sm="2" md="2">
2021-02-13 19:34:36 +08:00
<HangarSponsor :sponsor="sponsor" />
<v-select></v-select>
2021-01-23 05:06:44 +08:00
<v-checkbox :label="$t('hangar.projectSearch.relevanceSort')"></v-checkbox>
<v-list dense>
<v-subheader>Categories</v-subheader>
<v-list-item-group>
2021-01-23 09:44:41 +08:00
<v-list-item v-for="cat in $store.getters.visibleCategories" :key="cat.apiName">
<v-list-item-icon>
<v-icon v-text="cat.icon" />
</v-list-item-icon>
<v-list-item-content>
2021-01-23 09:44:41 +08:00
<v-list-item-title v-text="$t(`project.category.${cat.apiName}`)"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
<v-list dense>
<v-subheader>Platforms</v-subheader>
<v-list-item-group>
<v-list-item v-for="(platform, i) in platforms" :key="i">
<v-list-item-icon>
<v-icon v-text="`$vuetify.icons.${platform.name.toLowerCase()}`" />
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title v-text="platform.name"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-col>
</v-row>
</div>
2021-01-21 11:36:18 +08:00
</template>
<script lang="ts">
2021-03-21 10:06:09 +08:00
import { Component } from 'nuxt-property-decorator';
2021-02-13 19:34:36 +08:00
import { PaginatedResult, Project, Sponsor } from 'hangar-api';
2021-03-17 01:25:32 +08:00
import { IPlatform } from 'hangar-internal';
2021-02-13 19:34:36 +08:00
import { Context } from '@nuxt/types';
2021-03-20 15:24:17 +08:00
import { ProjectList } from '~/components/projects';
import HangarSponsor from '~/components/layouts/Sponsor.vue';
import { RootState } from '~/store';
2021-03-21 10:06:09 +08:00
import { HangarComponent } from '~/components/mixins';
2021-01-21 11:36:18 +08:00
@Component({
components: {
ProjectList,
HangarSponsor,
},
})
2021-03-21 10:06:09 +08:00
export default class Home extends HangarComponent {
2021-01-31 10:00:11 +08:00
// TODO implement filtering
2021-03-17 01:25:32 +08:00
projects!: PaginatedResult<Project>;
2021-01-22 07:08:06 +08:00
projectFilter: String | null = null;
2021-02-13 19:34:36 +08:00
sponsor!: Sponsor;
get platforms(): IPlatform[] {
return Array.from((this.$store.state as RootState).platforms.values());
}
2021-01-21 11:36:18 +08:00
2021-01-22 04:32:08 +08:00
head() {
return {
title: 'Home',
};
}
2021-02-13 19:34:36 +08:00
async asyncData({ $api, $util }: Context) {
2021-03-17 01:25:32 +08:00
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] };
2021-01-21 11:36:18 +08:00
}
}
</script>