-
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.
Merge pull request #15 from AIO-Develope/share-uploads
Share uploads
- Loading branch information
Showing
5 changed files
with
368 additions
and
129 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<template> | ||
<div> | ||
<ImageModal | ||
:show-modal="modalId !== null" | ||
:modal-content="modalContent" | ||
@close="modalId = null" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import ImageModal from '@/components/widgets/modals/UploadModal.vue'; | ||
import axiosService from '@/services/axiosService'; | ||
export default { | ||
components: { | ||
ImageModal, | ||
}, | ||
data() { | ||
return { | ||
images: [], | ||
showInfoBox: false, | ||
modalId: null, | ||
page: 1, | ||
loading: false, | ||
hasMore: true, | ||
imageType: 'pfp', | ||
userid: '', | ||
modalContent: {}, | ||
}; | ||
}, | ||
mounted() { | ||
try { | ||
this.imgId = this.$route.params.imgId; | ||
if (this.imgId) { | ||
this.openModal(this.imgId); | ||
} | ||
} catch (error) { | ||
console.log("Error while mounting:", error); | ||
} | ||
}, | ||
methods: { | ||
async openModal(imgId) { | ||
this.modalId = imgId; | ||
try { | ||
const modalupload = await axiosService.getImageDetails(this.modalId); | ||
if (!modalupload) { | ||
console.log("image not found") | ||
return; | ||
} | ||
const newModalContent = modalupload.upload; | ||
let authorInfo = null; | ||
try { | ||
authorInfo = await axiosService.getUser('userId', newModalContent.authorId); | ||
} catch (error) { | ||
console.error("Error fetching author with id:", newModalContent.authorId); | ||
} | ||
this.modalContent = { | ||
id: newModalContent.id, | ||
title: newModalContent.title, | ||
description: newModalContent.description, | ||
type: newModalContent.type, | ||
tags: newModalContent.tags, | ||
imgId: imgId, | ||
authorId: newModalContent.authorId || null, | ||
username: authorInfo?.user?.username || null, | ||
uploadedDate: newModalContent.uploadedDate, | ||
}; | ||
} catch (error) { | ||
console.error("Error fetching image details:", error); | ||
this.$router.push('/'); | ||
} | ||
}, | ||
}, | ||
}; | ||
</script> | ||
Oops, something went wrong.