Skip to content

Commit

Permalink
Create library
Browse files Browse the repository at this point in the history
  • Loading branch information
notmarek committed Jun 28, 2023
1 parent e710241 commit 9121e13
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions static/content/api_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export const library = {
headers: { Authorization: token() },
})
.json(),
create: async (name, path, depth) => await ky.put(`/api/library`, {
headers: { Authorization: token() },
throwHttpErrors: false,
json: { name, path, depth }
}).json(),
};

export const file = {
Expand Down
27 changes: 27 additions & 0 deletions static/content/modules/admin/library/create.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div class="bigaf" module>
<h1 class="primary">
Create library
</h1>
<form>
<input id="name" name="name" type="text" placeholder="Library name"/>
<input id="path" name="path" type="text" placeholder="Library path"/>
<input id="depth" name="depth" type="number" placeholder="Depth" value="3"/>
<input type="submit" class="btn primary" value="Create Library" />
</form>
<p idg="error"></p>
</div>
<script>
import { library } from "/content/api_client.js";
export const run = () => {
document.querySelector("form").onsubmit = async (event) => {
event.preventDefault();
const name = document.querySelector("#name").value;
const path = document.querySelector("#path").value;
const depth = Number(document.querySelector("#depth").value);
let res = await library.create(name, path, depth);
console.log(res);
document.getElementByGID("error").innerText = res.status();
return false;
};
}
</script>
Binary file added test.db-journal
Binary file not shown.

0 comments on commit 9121e13

Please sign in to comment.