Skip to content

Commit

Permalink
backend: schema.ts content type as text/plain
Browse files Browse the repository at this point in the history
  • Loading branch information
big213 committed Mar 2, 2021
1 parent 03de781 commit 19aa005
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 51 deletions.
1 change: 1 addition & 0 deletions backend/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ env.pusher && initializePusher(env.pusher);
initializeJomql(app, jomqlOptions);

app.get("/schema.ts", function (req, res, next) {
res.header("Content-Type", "text/plain");
const tsSchemaGenerator = new CustomSchemaGenerator(jomqlOptions);
tsSchemaGenerator.buildSchema();
tsSchemaGenerator.processSchema();
Expand Down
74 changes: 23 additions & 51 deletions frontend/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
</v-list-item>
</v-list>
<v-divider></v-divider>
<v-list dense>
<v-list v-if="isAdmin" dense>
<v-list-group
v-for="item in visibleFeatureGroups"
v-for="item in adminItems"
:key="item.title"
v-model="item.active"
:prepend-icon="item.action"
Expand Down Expand Up @@ -286,7 +286,8 @@ import { mapGetters } from 'vuex'
import Snackbar from '~/components/snackbar/snackbar'
import { goToWcaAuth, handleLogout } from '~/services/auth'
import sharedService from '~/services/shared'
import { copyToClipboard, openLink } from '~/services/common'
import { copyToClipboard, openLink, capitalizeString } from '~/services/common'
import * as models from '~/models'
export default {
components: {
Expand Down Expand Up @@ -324,48 +325,6 @@ export default {
loginRequired: false,
},
],
featureItems: [
{
action: 'mdi-star',
active: true,
roles: ['ADMIN'],
permissions: [],
items: [
{
title: 'Users',
to: '/admin/users',
roles: ['NORMAL', 'ADMIN'],
permissions: [],
},
{
title: 'Events',
to: '/admin/events',
roles: ['NORMAL', 'ADMIN'],
permissions: [],
},
{
title: 'PB Types',
to: '/admin/personalBestClasses',
roles: ['NORMAL', 'ADMIN'],
permissions: [],
},
{
title: 'Products',
to: '/admin/products',
roles: ['NORMAL', 'ADMIN'],
permissions: [],
},
{
title: 'PBs',
to: '/admin/personalBests',
roles: ['NORMAL', 'ADMIN'],
permissions: [],
},
],
title: 'Administration',
},
],
accountItems: [{ title: 'Settings', to: '/settings', exact: false }],
miniVariant: false,
}
Expand All @@ -376,12 +335,6 @@ export default {
user: 'auth/user',
}),
visibleFeatureGroups() {
return this.featureItems.filter((item) =>
this.canSee(item.roles, item.permissions)
)
},
visibleNavItems() {
return this.navItems.filter(
(item) => this.$store.getters['auth/user'] || !item.loginRequired
Expand All @@ -393,6 +346,25 @@ export default {
? '/user?id=' + this.$store.getters['auth/user'].id
: null
},
isAdmin() {
return this.$store.getters['auth/user']?.role === 'ADMIN'
},
adminItems() {
return [
{
action: 'mdi-star',
active: false,
title: 'Administration',
permissions: [],
items: Object.values(models).map((recordInfo) => ({
title: capitalizeString(recordInfo.pluralName),
to: '/admin/' + recordInfo.pluralType,
roles: ['ADMIN'],
permissions: [],
})),
},
]
},
},
methods: {
Expand Down
1 change: 1 addition & 0 deletions frontend/models/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import TimeagoColumn from '~/components/table/common/timeagoColumn.vue'

export const Event = <RecordInfo<'event'>>{
type: 'event',
pluralType: 'events',
name: 'Event',
pluralName: 'Events',
icon: 'mdi-view-grid',
Expand Down
1 change: 1 addition & 0 deletions frontend/models/personalBest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { serializeTime } from '~/services/common'

export const PersonalBest = <RecordInfo<'personalBest'>>{
type: 'personalBest',
pluralType: 'personalBests',
name: 'Personal Best',
pluralName: 'Personal Bests',
// viewRecordRoute: '/pb',
Expand Down
1 change: 1 addition & 0 deletions frontend/models/personalBestClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import TimeagoColumn from '~/components/table/common/timeagoColumn.vue'

export const PersonalBestClass = <RecordInfo<'personalBestClass'>>{
type: 'personalBestClass',
pluralType: 'personalBestClasses',
name: 'Personal Best Type',
pluralName: 'Personal Best Types',
icon: 'mdi-content-copy',
Expand Down
1 change: 1 addition & 0 deletions frontend/models/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import TimeagoColumn from '~/components/table/common/timeagoColumn.vue'

export const Product = <RecordInfo<'product'>>{
type: 'product',
pluralType: 'products',
name: 'Product',
pluralName: 'Products',
icon: 'mdi-dots-grid',
Expand Down
1 change: 1 addition & 0 deletions frontend/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getBooleanOptions, getUserRoles } from '~/services/dropdown'

export const User = <RecordInfo<'user'>>{
type: 'user',
pluralType: 'users',
name: 'User',
pluralName: 'Users',
icon: 'mdi-account',
Expand Down
1 change: 1 addition & 0 deletions frontend/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { InputTypes, MainTypes, FilterByField } from '~/types/schema'
export type RecordInfo<T extends keyof MainTypes> = {
// name of the type
type: T
pluralType: string
name: string
pluralName: string
// route that shareUrl and enterItem should be based off
Expand Down

0 comments on commit 19aa005

Please sign in to comment.