68 lines
2.2 KiB
HTML
68 lines
2.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Test OxiCloud</title>
|
|
</head>
|
|
<body>
|
|
<h1>OxiCloud Test Page</h1>
|
|
<div id="result"></div>
|
|
<button id="createBtn">Create new folder</button>
|
|
<button id="listBtn">List folders</button>
|
|
|
|
<script>
|
|
// Function to show results
|
|
function showResult(data) {
|
|
document.getElementById('result').innerHTML =
|
|
'<pre>' + JSON.stringify(data, null, 2) + '</pre>';
|
|
}
|
|
|
|
// Function to create folder
|
|
async function createFolder() {
|
|
try {
|
|
const response = await fetch('/api/folders', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
name: 'test_folder_' + Date.now(),
|
|
parent_id: null
|
|
})
|
|
});
|
|
|
|
const data = await response.json();
|
|
console.log('Folder creation response:', data);
|
|
showResult(data);
|
|
|
|
return data;
|
|
} catch (error) {
|
|
console.error('Error creating folder:', error);
|
|
showResult({error: error.message});
|
|
return null;
|
|
}
|
|
}
|
|
|
|
// Function to list folders
|
|
async function listFolders() {
|
|
try {
|
|
const response = await fetch('/api/folders');
|
|
const data = await response.json();
|
|
console.log('Folder listing:', data);
|
|
showResult(data);
|
|
|
|
return data;
|
|
} catch (error) {
|
|
console.error('Error listing folders:', error);
|
|
showResult({error: error.message});
|
|
return [];
|
|
}
|
|
}
|
|
|
|
// Assign events to buttons
|
|
document.getElementById('createBtn').addEventListener('click', createFolder);
|
|
document.getElementById('listBtn').addEventListener('click', listFolders);
|
|
</script>
|
|
</body>
|
|
</html> |