Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
merge: from feat/public-projects
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKanera authored Jan 29, 2021
2 parents 49257c1 + 9d225bc commit 78a1a4b
Show file tree
Hide file tree
Showing 13 changed files with 123 additions and 98 deletions.
6 changes: 5 additions & 1 deletion components/login-form/login-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default defineComponent({
components: {
microsoftLogo,
},
setup() {
setup(_, { emit }) {
const mainStore = useMainStore();
const awaitingLogin = ref(false);
Expand Down Expand Up @@ -69,6 +69,8 @@ export default defineComponent({
mainStore.patch(userData);
}
emit('login-complete', true);
} catch (e) {
// TODO Error handling
console.error(e);
Expand Down Expand Up @@ -103,6 +105,8 @@ export default defineComponent({
mainStore.patch(userData);
}
emit('login-complete', true);
} catch (e) {
switch (e.code) {
case 'auth/invalid-email': {
Expand Down
5 changes: 4 additions & 1 deletion components/my-project/my-project.sass
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
@apply text-ps-green text-lg

.row
@apply text-ps-white flex items-center justify-between
@apply text-ps-white flex items-center

.row-items
@apply flex w-full justify-between

.my-project-user
@apply bg-ps-secondary shadow rounded-lg p-2
Expand Down
77 changes: 51 additions & 26 deletions components/my-project/my-project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,38 @@
.my-project-info
.title {{ titleRef }}
ps-text-area.mt-2(v-model='descriptionRef', placeholder='Popis projektu', name='project-description', :readonly='!modificable')
.subtitle.mt-2 Povinné soubory
span.mb-1.text-ps-white.text-sm Dokumentace (docx, PDF), Projekt (zip/rar)
ps-drag-drop(v-model='mandatoryFilesUpload', tile, multiple, accept='.pdf,.docx,.zip,.rar', :disabled='!modificable')
.subtitle(v-if='mandatoryFilesRef.length > 0') Nahrané povinné soubory:
.row(v-for='file in mandatoryFilesRef')
a.flex.items-center(:href='file.url', target='_blank')
word-icon(v-if='file.extension == "docx"')
pdf-icon(v-else-if='file.extension == "pdf"')
zip-icon(v-else-if='file.extension == "zip" || file.extension == "rar"')
file-icon(v-else)
.ml-2.underline {{ file.fileName }}
ps-btn(v-if='modificable', text, @click='removeFile(file.filePath)', :disabled='removing', :loading='removing')
bin-icon(:size='20')
.subtitle.mt-2 Soubory navíc
ps-drag-drop#optionalSelect(v-model='optionalFilesUpload', tile, multiple, :disabled='!modificable')
.subtitle(v-if='optionalFilesRef.length > 0') Nahrané soubory navíc:
.row(v-for='file in optionalFilesRef')
a.flex.items-center(:href='file.url', target='_blank')
word-icon(v-if='file.extension == "docx"')
pdf-icon(v-else-if='file.extension == "pdf"')
zip-icon(v-else-if='file.extension == "zip" || file.extension == "rar"')
image-icon(v-else-if='file.extension == "jpg" || file.extension == "jpeg" || file.extension == "png" || file.extension == "gif"')
file-icon(v-else)
.ml-2.underline {{ file.fileName }}
ps-btn(v-if='modificable', text, @click='removeFile(file.filePath)', :disabled='removing', :loading='removing')
bin-icon(:size='20')
.subtitle.mt-2(v-if='modificable') Povinné soubory
span.mb-1.text-ps-white.text-sm(v-if='modificable') Dokumentace (docx, PDF), Projekt (zip/rar)
ps-drag-drop(v-if='modificable', v-model='mandatoryFilesUpload', tile, multiple, accept='.pdf,.docx,.zip,.rar', :disabled='!modificable')
.subtitle.mt-2(v-if='mandatoryFilesRef.length > 0') Nahrané povinné soubory
draggable.mb-2(v-model='mandatoryFilesRef', handle='.handle')
.row(v-for='file in mandatoryFilesRef')
drag-icon.handle(v-if='modificable')
.row-items
a.flex.items-center(:href='file.url', target='_blank')
word-icon(v-if='file.extension == "docx"')
pdf-icon(v-else-if='file.extension == "pdf"')
zip-icon(v-else-if='file.extension == "zip" || file.extension == "rar"')
file-icon(v-else)
.ml-2.underline {{ file.fileName }}
ps-btn(v-if='modificable', text, @click='removeFile(file.filePath)', :disabled='removing', :loading='removing')
bin-icon(:size='20')
.subtitle.mt-2(v-if='modificable') Soubory navíc
ps-drag-drop#optionalSelect(v-if='modificable', v-model='optionalFilesUpload', tile, multiple, :disabled='!modificable')
.subtitle(v-if='optionalFilesRef.length > 0') Nahrané soubory navíc
draggable.mb-2(v-model='optionalFilesRef', handle='.handle')
.row(v-for='file in optionalFilesRef')
drag-icon.handle(v-if='modificable')
.row-items
a.flex.items-center(:href='file.url', target='_blank')
word-icon(v-if='file.extension == "docx"')
pdf-icon(v-else-if='file.extension == "pdf"')
zip-icon(v-else-if='file.extension == "zip" || file.extension == "rar"')
image-icon(v-else-if='file.extension == "jpg" || file.extension == "jpeg" || file.extension == "png" || file.extension == "gif"')
file-icon(v-else)
.ml-2.underline {{ file.fileName }}
ps-btn(v-if='modificable', text, @click='removeFile(file.filePath)', :disabled='removing', :loading='removing')
bin-icon(:size='20')
ps-chips(v-model='keywordsRef', :edittable='modificable', placeholder='Klíčová slova')
.mt-8.w-full.flex.flex.justify-center
ps-btn.mr-4(@click='saveChanges', :disabled='awaiting || submittedRef || !modificable', :loading='awaiting') Uložit
Expand Down Expand Up @@ -73,16 +79,21 @@ import zipIcon from 'vue-material-design-icons/ZipBox.vue';
import imageIcon from 'vue-material-design-icons/Image.vue';
import fileIcon from 'vue-material-design-icons/File.vue';
import binIcon from 'vue-material-design-icons/Delete.vue';
import dragIcon from 'vue-material-design-icons/DragVertical.vue';
import draggable from 'vuedraggable';
export default defineComponent({
components: {
draggable,
chevronRight,
wordIcon,
zipIcon,
pdfIcon,
imageIcon,
fileIcon,
binIcon,
dragIcon,
},
setup() {
const mainStore = useMainStore();
Expand Down Expand Up @@ -163,6 +174,20 @@ export default defineComponent({
description: descriptionRef.value,
links: linksRef.value,
keywords: keywordsRef.value,
mandatoryOrder: mandatoryFilesRef.value.map((file: any) => {
return {
fileName: file.fileName,
filePath: file.filePath,
uploaded: file.uploaded,
};
}),
optionalOrder: optionalFilesRef.value.map((file: any) => {
return {
fileName: file.fileName,
filePath: file.filePath,
uploaded: file.uploaded,
};
}),
}),
);
Expand Down
56 changes: 7 additions & 49 deletions components/navbar/navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
span.user-role(v-else-if='mainStore.isAdmin && !mainStore.isTeacher') Admin
span.user-role(v-else-if='mainStore.isTeacher && mainStore.isAdmin') Admin/Učitel
.flex.items-center(v-else)
ps-btn(text, @click='loginModal = !loginModal') Přihlášení
ps-btn(text, @click='loginModal = true') Přihlášení
template(#icon-right)
arrow-right/
.flex.justify-center.items-center.relative(v-if='mainStore.isLoggedIn')
Expand All @@ -30,14 +30,12 @@
.burger(:class='{ active: burger }')
ps-modal(v-model='loginModal')
.flex.justify-center
ps-login-form
ps-login-form(@login-complete='toggleLoginModal')
</template>

<script lang="ts">
import { defineComponent, ref, onMounted, computed, watchEffect } from '@nuxtjs/composition-api';
import axios from 'axios';
import { useMainStore } from '@/store';
import dropDown from 'vue-material-design-icons/ChevronDown.vue';
Expand Down Expand Up @@ -115,49 +113,6 @@ export default defineComponent({
const closeNotifications = () => (displayNotifications.value = false);
const awaitingLogin = ref(false);
const loginWithMicrosoft = async () => {
await require('firebase/auth');
try {
awaitingLogin.value = true;
const provider = new firebase.auth.OAuthProvider('microsoft.com');
provider.setCustomParameters({
prompt: 'select_account',
tenant: process.env.TENANT,
});
const authUser = await firebase.auth().signInWithPopup(provider);
const userData = (
await axios.request({
url: '/api/user/create',
method: 'POST',
headers: {
authorization: `Bearer ${await authUser.user?.getIdToken()}`,
},
data: {
// @ts-ignore
accessToken: authUser.credential?.toJSON().oauthAccessToken,
},
})
).data;
if (userData.user) {
userData.user.loggedIn = true;
mainStore.patch(userData);
}
} catch (e) {
console.error(e);
}
awaitingLogin.value = false;
};
const logOut = async () => {
await require('firebase/auth');
Expand All @@ -173,6 +128,10 @@ export default defineComponent({
const loginModal = ref(false);
const toggleLoginModal = (loginComplete: boolean) => {
loginModal.value = !loginComplete;
};
const notificationsLength = ref(0);
const updateNotifications = (length: number) => {
notificationsLength.value = length;
Expand All @@ -188,13 +147,12 @@ export default defineComponent({
toggleNotifications,
closeNotifications,
isDesktop,
loginWithMicrosoft,
logOut,
awaitingLogin,
mainStore,
loginModal,
updateNotifications,
notificationsLength,
toggleLoginModal,
};
},
});
Expand Down
16 changes: 12 additions & 4 deletions components/project-links/project-links.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
ps-btn.rounded-full(v-if='editable', text)
add-icon.text-ps-white(@click='openModal', :size='20')/
.flex.flex-col.ml-2
.flex.justify-between.items-center(v-for='(link, index) in editableValue', :key='index')
a.break-all(:href='link.url', target='_blank') {{ link.placeholder }}
ps-btn.rounded-full(v-if='editable', text)
bin-icon.text-ps-white(@click='removeLink(index)', :size='16')/
draggable
.flex.items-center.text-ps-white(v-for='(link, index) in editableValue', :key='index')
drag-icon.handle(v-if='editable')
.flex.w-full.justify-between.items-center
a.break-all(:href='link.url', target='_blank') {{ link.placeholder }}
ps-btn.rounded-full(v-if='editable', text)
bin-icon.text-ps-white(@click='removeLink(index)', :size='16')/
ps-modal(v-model='linksModal')
.flex.flex-col.flex-wrap
span.text-2xl.text-ps-white Přidat odkaz
Expand All @@ -22,6 +25,9 @@ import { defineComponent, ref, unref, watch } from '@nuxtjs/composition-api';
import addIcon from 'vue-material-design-icons/Plus.vue';
import binIcon from 'vue-material-design-icons/Delete.vue';
import dragIcon from 'vue-material-design-icons/DragVertical.vue';
import draggable from 'vuedraggable';
type Link = {
url: String;
Expand All @@ -32,6 +38,8 @@ export default defineComponent({
components: {
addIcon,
binIcon,
dragIcon,
draggable,
},
props: {
value: {
Expand Down
2 changes: 1 addition & 1 deletion components/teacher-project/teacher-project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
span.text-2xl.text-ps-white {{ projectTitle }}
span.text-lg.text-ps-green {{ displayName }}
span.mt-4.mb-1.text-ps-white Nahraj posudky
ps-drag-drop(v-model='reviewsFiles', tile, multiple, accept='.pdf,.xlsx', :disabled='pastDeadline || !unreviewed')
ps-drag-drop(v-model='reviewsFiles', tile, multiple, accept='.pdf,.xlsx', :disabled='pastDeadline || !unreviewed', :draggable='false')
ps-btn.self-end(v-if='reviewsFiles.length > 0', @click='uploadReviews', :disabled='uploading', :loading='uploading') Odeslat posudek
span.mt-8.text-ps-green Odevzdané posudky:
.text-ps-white.flex.items-center.justify-between(v-for='review in uploadedReviews')
Expand Down
32 changes: 22 additions & 10 deletions components/ui/drag-drop/drag-drop.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<template lang="pug">
.drag-drop(@dragover.prevent, @drop.prevent, @drop='handleFileDrop', :class='{ tile: tile }')
.list-wrap.w-full.mb-4(:class='{ "mt-2": files.length > 0 }')
.text-ps-white.flex.justify-between(v-for='file in files')
.flex.items-center
word-icon(v-if='file.type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document"')
pdf-icon(v-else-if='file.type == "application/pdf"')
zip-icon(v-else-if='file.type == "application/x-zip-compressed"')
image-icon(v-else-if='file.type.split("/")[0] == "image"')
file-icon(v-else)
span.ml-2 {{ file.name }}
ps-btn.justify-self-end(text, @click='removeFile(file.name)')
bin-icon(:size='20')
draggable(v-model='files', handle='.handle')
.text-ps-white.flex.items-center(v-for='file in files')
drag-icon.handle(v-if='draggable')
.flex.justify-between.w-full
.flex.items-center
word-icon(v-if='file.type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document"')
pdf-icon(v-else-if='file.type == "application/pdf"')
zip-icon(v-else-if='file.type == "application/x-zip-compressed"')
image-icon(v-else-if='file.type.split("/")[0] == "image"')
file-icon(v-else)
span.ml-2 {{ file.name }}
ps-btn.justify-self-end(text, @click='removeFile(file.name)')
bin-icon(:size='20')
.input-wrap
ps-btn(@click='btnTrigger', :disabled='disabled') Vyber soubory
span.ml-3.text-ps-white nebo je sem přetáhni
Expand All @@ -26,6 +29,9 @@ import zipIcon from 'vue-material-design-icons/ZipBox.vue';
import imageIcon from 'vue-material-design-icons/Image.vue';
import fileIcon from 'vue-material-design-icons/File.vue';
import binIcon from 'vue-material-design-icons/Delete.vue';
import dragIcon from 'vue-material-design-icons/DragVertical.vue';
import draggable from 'vuedraggable';
export default defineComponent({
components: {
Expand All @@ -35,6 +41,8 @@ export default defineComponent({
imageIcon,
fileIcon,
binIcon,
dragIcon,
draggable,
},
props: {
value: {
Expand All @@ -60,6 +68,10 @@ export default defineComponent({
type: String,
default: 'chooseFiles',
},
draggable: {
type: Boolean,
default: true,
},
},
setup(props, { emit }) {
const files = ref([]);
Expand Down
1 change: 0 additions & 1 deletion functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ exports.newSchoolYear = functions.pubsub.schedule('0 0 25 5 *').timeZone('Europe
currentYear: newSchoolYear,
});

// TODO add properties for reviews and submitted projects
await statisticsRef.set({
currentMaxStudents: 0,
currentProjects: 0,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"short-uuid": "^4.1.0",
"ts-debounce": "^2.1.0",
"vue-clickaway": "2.2.2",
"vue-material-design-icons": "4.11.0"
"vue-material-design-icons": "4.11.0",
"vuedraggable": "^2.24.3"
},
"devDependencies": {
"@babel/core": "7.12.9",
Expand Down
4 changes: 2 additions & 2 deletions pages/project/_id.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
.my-project-info
.title {{ project.title }}
ps-text-area.mt-2(v-model='project.description', placeholder='Popis projektu', name='project-description', :readonly='true')
.subtitle.mt-2 Povinné soubory
.subtitle.mt-2(v-if='!!project.mandatoryFiles.length') Povinné soubory
.row(v-for='file in project.mandatoryFiles')
a.flex.items-center(:href='file.url', target='_blank')
word-icon(v-if='file.extension == "docx"')
pdf-icon(v-else-if='file.extension == "pdf"')
zip-icon(v-else-if='file.extension == "zip" || file.extension == "rar"')
file-icon(v-else)
.ml-2.underline {{ file.fileName }}
.subtitle.mt-2 Soubory navíc
.subtitle.mt-2(v-if='!!project.optionalFiles.length') Soubory navíc
.row(v-for='file in project.optionalFiles')
a.flex.items-center(:href='file.url', target='_blank')
word-icon(v-if='file.extension == "docx"')
Expand Down
Loading

0 comments on commit 78a1a4b

Please sign in to comment.