Skip to content

Commit

Permalink
Merge pull request #21 from ecrum19/EDC_active
Browse files Browse the repository at this point in the history
fixed small issues with adding some data types to pod
  • Loading branch information
ecrum19 authored Jun 5, 2024
2 parents 6ad8dac + c3b5a8b commit 41fc124
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 18 deletions.
31 changes: 23 additions & 8 deletions src/components/PodUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class="mx-auto"
color="indigo-darken-3"
>
<!-- The file input section << Want to make this drag and drop eventually...>> -->
<!-- The file input section << Styling needs a little work >> -->
<form id="writeForm">
<v-file-input
clearable
Expand Down Expand Up @@ -49,6 +49,7 @@
</v-btn>
</form>

<!-- Alert for if session is timed out -->
<div v-if="this.pod === 'Error: probably not logged in'">
<v-alert
class="mx-auto"
Expand All @@ -58,15 +59,29 @@
><b>Try logging out and logging back in!</b></v-alert
>
</div>
<div v-else>
<div id="fileUploaded" v-if="fileUploaded">
<div v-else-if="!initialLoad">
<!-- Shows that file upload was successful -->
<div v-if="!fileUploaded">
<v-alert
class="mx-auto"
title="File(s) successfully uploaded!"
type="success"
icon="$success"
>(File(s) can be found in the <b>{{ this.pod }}uploads/</b> directory
of your pod)</v-alert
>(File(s) can be found in the
<b>{{ this.pod }}uploads/</b> directory of your pod)</v-alert
>
</div>

<!-- Alert for if file upload is not successful -->
<div v-else>
<v-alert
class="mx-auto"
title="There was an error with the file(s) upload!"
type="error"
icon="$error"
>There seems to be an error with the file upload. There are some
file types not supported in the current implementation. We are
working on fixing this currently. Sorry!!</v-alert
>
</div>
</div>
Expand Down Expand Up @@ -97,6 +112,7 @@ export default {
podURLs: [],
pod: "",
fileUploaded: false,
initialLoad: true,
files: FileList,
};
},
Expand All @@ -122,9 +138,8 @@ export default {
'files' variable is a FileList that contains references to all files selected using the upload UI.
*/
submitUpload() {
console.log(this.pod);
handleFiles(this.files, this.pod);
this.fileUploaded = true;
this.fileUploaded = handleFiles(this.files, this.pod);
this.initialLoad = false;
},
},
mounted() {
Expand Down
37 changes: 27 additions & 10 deletions src/components/fileUpload.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
WithResourceInfo,

Check warning on line 2 in src/components/fileUpload.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

'WithResourceInfo' is defined but never used
getPodUrlAll,
overwriteFile,
} from "@inrupt/solid-client";
Expand Down Expand Up @@ -44,16 +45,32 @@ function handleFiles(fileList: FileList, podURL: string) {
* @param fetch A window.fetch that includes the current User's credentials (to allow for Write access).
* @returns A Promise that resolves to a string[] of user Pod URLs, if available, or `undefined` if no pods are found.
*/
async function uploadToPod(targetURL: string, file: File, fetch): Promise<void> {
try {
const savedFile = await overwriteFile(targetURL, file, {
contentType: file.type,
fetch: fetch,
});
console.log(savedFile)
console.log(`File saved at ${targetURL + file.name}`);
} catch (error) {
console.error(error);
async function uploadToPod(targetURL: string, file: File, fetch): Promise<boolean> {
if (file.type != '') {
// for if the file type is captured by the well-known "secret codes"
try {
const savedFile = await overwriteFile(targetURL, file, {
contentType: file.type,
fetch: fetch,
});
console.log(`File saved at ${targetURL}`);

Check warning on line 56 in src/components/fileUpload.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unexpected console statement
console.log(savedFile)

Check warning on line 57 in src/components/fileUpload.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unexpected console statement
return true
} catch (error) {
console.error(error);

Check warning on line 60 in src/components/fileUpload.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unexpected console statement
}
} else {
// for if the file type is not captured by the well-known "secret codes"
try {
const savedFile = await overwriteFile(targetURL, file, {
fetch: fetch,
});
console.log(`File saved at ${targetURL}`);

Check warning on line 68 in src/components/fileUpload.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unexpected console statement
console.log(savedFile)

Check warning on line 69 in src/components/fileUpload.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unexpected console statement
return true
} catch (error) {
console.error(error);

Check warning on line 72 in src/components/fileUpload.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unexpected console statement
}
}
}

Expand Down

0 comments on commit 41fc124

Please sign in to comment.