-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve #28: Add embeddable iframe for sharing PB Cards
- Loading branch information
Showing
3 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<template> | ||
<v-app dark> | ||
<v-main> | ||
<nuxt /> | ||
</v-main> | ||
<Snackbar /> | ||
</v-app> | ||
</template> | ||
|
||
<script> | ||
import { mapGetters } from 'vuex' | ||
import Snackbar from '~/components/snackbar/snackbar.vue' | ||
import VersionCheckText from '~/components/common/versionCheckText.vue' | ||
import { goToWcaAuth, handleLogout } from '~/services/auth' | ||
import { copyToClipboard, openLink, handleError } from '~/services/base' | ||
import AdminNavRoutes from '~/components/navigation/adminNavRoutes.vue' | ||
export default { | ||
components: { | ||
Snackbar, | ||
VersionCheckText, | ||
AdminNavRoutes, | ||
}, | ||
data() { | ||
return { | ||
clipped: true, | ||
drawer: false, | ||
fixed: true, | ||
miniVariant: false, | ||
} | ||
}, | ||
computed: { | ||
...mapGetters({ | ||
user: 'auth/user', | ||
}), | ||
isAdmin() { | ||
return this.$store.getters['auth/user']?.role === 'ADMIN' | ||
}, | ||
}, | ||
mounted() { | ||
this.drawer = this.$vuetify.breakpoint.name !== 'xs' | ||
}, | ||
methods: { | ||
copyToClipboard(content) { | ||
return copyToClipboard(this, content) | ||
}, | ||
goToWcaAuth, | ||
openLink, | ||
toggleTheme() { | ||
this.$vuetify.theme.dark = !this.$vuetify.theme.dark | ||
localStorage.setItem('theme', this.$vuetify.theme.dark ? 'dark' : 'light') | ||
}, | ||
canSee(allowedRoles, allowedPermissions) { | ||
return ( | ||
allowedRoles.includes(this.$store.getters['auth/user']?.role) || | ||
allowedPermissions.some((ele) => | ||
this.$store.getters['auth/user']?.allPermissions.includes(ele) | ||
) | ||
) | ||
}, | ||
logout() { | ||
try { | ||
this.$router.push('/') | ||
handleLogout(this) | ||
} catch (err) { | ||
handleError(this, err) | ||
} | ||
}, | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<template> | ||
<v-container fluid fill-height> | ||
<v-layout align-center justify-center> | ||
<v-row> | ||
<v-col cols="12"> | ||
<div v-if="errorMessage" class="text-center"> | ||
<span class="display-1 pl-2">{{ errorMessage }} </span> | ||
</div> | ||
<div v-else-if="loading.verifyUser"> | ||
<span class="display-1 pl-2" | ||
>Verifying WCA Code... | ||
<v-progress-circular indeterminate></v-progress-circular> | ||
</span> | ||
</div> | ||
<ViewPbCardInterface | ||
v-else-if="userId" | ||
icon="mdi-card-text" | ||
:title="title" | ||
:record-info="recordInfo" | ||
:locked-filters="lockedFilters" | ||
></ViewPbCardInterface> | ||
</v-col> | ||
</v-row> | ||
</v-layout> | ||
</v-container> | ||
</template> | ||
|
||
<script> | ||
import ViewPbCardInterface from '~/components/interface/viewPbCardInterface.vue' | ||
import { PublicPbs } from '~/models/special' | ||
import { executeGiraffeql } from '~/services/giraffeql' | ||
import { handleError } from '~/services/base' | ||
export default { | ||
layout: 'lite', | ||
components: { | ||
ViewPbCardInterface, | ||
}, | ||
data() { | ||
return { | ||
recordInfo: PublicPbs, | ||
title: 'PB Card', | ||
hiddenFilters: ['createdBy.id', 'isCurrent'], | ||
hiddenHeaders: ['createdBy.name+createdBy.avatar'], | ||
errorMessage: null, | ||
loading: { | ||
verifyUser: false, | ||
}, | ||
userId: null, | ||
} | ||
}, | ||
computed: { | ||
lockedFilters() { | ||
return [ | ||
{ | ||
field: 'createdBy.id', | ||
operator: 'eq', | ||
value: this.$route.query.id, | ||
}, | ||
] | ||
}, | ||
}, | ||
mounted() { | ||
this.verifyUserExists() | ||
}, | ||
methods: { | ||
async verifyUserExists() { | ||
this.loading.verifyUser = true | ||
try { | ||
if (!this.$route.query.id) { | ||
throw new Error('Missing user ID') | ||
} | ||
const data = await executeGiraffeql(this, { | ||
getUser: { | ||
id: true, | ||
__args: { | ||
id: this.$route.query.id, | ||
}, | ||
}, | ||
}) | ||
this.userId = data.id | ||
} catch (err) { | ||
handleError(this, err) | ||
this.errorMessage = err.message | ||
} | ||
this.loading.verifyUser = false | ||
}, | ||
}, | ||
head() { | ||
return { | ||
title: this.title, | ||
} | ||
}, | ||
} | ||
</script> |