Skip to content

Commit

Permalink
Detects if pod is attached to pico automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
KyerHarris authored Apr 5, 2024
1 parent c246eb8 commit b7f2713
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions samples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ let storageURL;

document.addEventListener("DOMContentLoaded", async function() {

// Set the root path
// Set default photo
storageURL = await getStorage();
setCurrentPath(storageURL);
if (storageURL === null) {
storageURL = '';
toggleDetachAttachButtons();
}
else{
setCurrentPath(storageURL);

// Set the default photo path to a folder called 'myPhotos'
setUpMyPhotosFolder();
// Show all items in the root storage URL
fetchAndDisplayItems(getCurrentPath());
}

// Show primary control panel
toggleControlPanel(true);
Expand Down Expand Up @@ -277,9 +283,9 @@ function addPhotoAction() {
if (url) {
console.log(`Adding file from: ${url}`);
addPhoto(url, filename).then(() => {
alert('File added successfully!');
input.remove(); // Remove the input field
addPhotoBtn.style.display = ''; // Show the button again
fetchAndDisplayItems(getCurrentPath()); // Refresh the contents of the folder
})
}
};
Expand Down Expand Up @@ -318,7 +324,6 @@ function addFolderAction() {
if (folderName) {
console.log(`Adding folder: ${folderName}`);
addFolder(folderName).then(() => {
alert('Folder added successfully!');
input.remove(); // Remove the input field
addFolderBtn.style.display = ''; // Show the button again
})
Expand Down Expand Up @@ -364,7 +369,6 @@ async function deleteFolderAction() {
if (!deleteResponse.ok) {
throw new Error(`Delete folder failed: ${response.status}`);
}
alert('Folder deleted successfully!');
fetchAndDisplayItems(lastURL.pop(), true);
} catch (error) {
console.error('Error deleting the folder:', error);
Expand Down Expand Up @@ -392,10 +396,10 @@ async function handleFileSelect(event) {
if (!response.ok) {
throw new Error('Network response was not ok');
}

// Success feedback
console.log('File uploaded successfully');
alert('File uploaded successfully');
else {
// Success feedback
console.log('File uploaded successfully');
}
} catch (error) {
console.error('Error uploading file:', error);
}
Expand Down Expand Up @@ -467,12 +471,10 @@ async function grantAccessAction() {
grantAccess(getCurrentPath());
document.getElementById('grantAccessToggle').textContent = 'Public';
console.log(`${getCurrentPath()} is now public.`)
alert('The photo is now public!');
} else {
removeAccess(getCurrentPath());
document.getElementById('grantAccessToggle').textContent = 'Private';
console.log(`${getCurrentPath()} is now private.`)
alert('The photo is now private!');
}
}

Expand Down

0 comments on commit b7f2713

Please sign in to comment.