add new block dialog to scheduler

This commit is contained in:
Sundog Jones 2024-09-22 11:13:01 -04:00
parent b0c35eaa6d
commit 285180957a

View File

@ -400,40 +400,40 @@
// show dialog to get media metadata for new upload
console.log("Upload response: ");
console.dir(json);
const metadata_dialog = document.getElementById("media_details_dialog");
const metadata_header = document.getElementById("media_details_dialog_header");
metadata_header.innerHTML = "Metadata for " + json.source_path;
const metadata_title = document.getElementById("media_details_dialog_title");
metadata_title.value = json.title === "unknown" ? json.source_path : json.title;
const dur_span = document.getElementById("media_details_dialog_duration_secs");
dur_span.innerHTML = new Date(json.duration_secs * 1000).toISOString().substring(11, 19);
const id_input = document.getElementById("media_details_dialog_id");
id_input.value = json.id;
const metadata_close_button = document.getElementById("media_details_dialog_close_button");
metadata_close_button.addEventListener("click", (event) => {
event.preventDefault();
metadata_dialog.close();
});
const metadata_save_button = document.getElementById("media_details_dialog_save_button");
metadata_save_button.addEventListener("click", (event) => {
event.preventDefault();
const updateURL = "update.php?id=" + json.id;
let data = new FormData(document.getElementById("media_details_dialog_form"));
console.dir(data);
fetch(updateURL, {
method: "POST",
body: data
})
.then((response) => {
if (response.ok) {
response.json().then((json) => {
metadata_dialog.close();
fetch_media_items();
});
}
});
});
metadata_dialog.showModal();
const metadata_dialog = document.getElementById("media_details_dialog");
const metadata_header = document.getElementById("media_details_dialog_header");
metadata_header.innerHTML = "Metadata for " + json.source_path;
const metadata_title = document.getElementById("media_details_dialog_title");
metadata_title.value = json.title === "unknown" ? json.source_path : json.title;
const dur_span = document.getElementById("media_details_dialog_duration_secs");
dur_span.innerHTML = new Date(json.duration_secs * 1000).toISOString().substring(11, 19);
const id_input = document.getElementById("media_details_dialog_id");
id_input.value = json.id;
const metadata_close_button = document.getElementById("media_details_dialog_close_button");
metadata_close_button.addEventListener("click", (event) => {
event.preventDefault();
metadata_dialog.close();
});
const metadata_save_button = document.getElementById("media_details_dialog_save_button");
metadata_save_button.addEventListener("click", (event) => {
event.preventDefault();
const updateURL = "update.php?id=" + json.id;
let data = new FormData(document.getElementById("media_details_dialog_form"));
console.dir(data);
fetch(updateURL, {
method: "POST",
body: data
})
.then((response) => {
if (response.ok) {
response.json().then((json) => {
metadata_dialog.close();
fetch_media_items();
});
}
});
});
metadata_dialog.showModal();
});
}
})
@ -816,7 +816,36 @@
const schedule_grid_click_handler = (e) => {
e.preventDefault();
// TODO: open dialog for add block
const new_block_dialog = document.getElementById("new_block_dialog");
const new_block_header = document.getElementById("new_block_dialog_header");
const block_start_time = e.target.parentNode.firstElementChild.innerHTML;
new_block_header.innerHTML = "New program block for " + block_start_time;
const new_block_close_button = document.getElementById("new_block_dialog_close_button");
new_block_close_button.addEventListener("click", (event) => {
event.preventDefault();
new_block_dialog.close();
});
const new_block_save_button = document.getElementById("new_block_dialog_save_button");
new_block_save_button.addEventListener("click", (event) => {
event.preventDefault();
const updateURL = "block.php";
let data = new FormData(document.getElementById("new_block_dialog_form"));
console.dir(data);
fetch(updateURL, {
method: "POST",
body: data
})
.then((response) => {
if (response.ok) {
response.json().then((json) => {
new_block_dialog.close();
load_schedule(); // TODO: need to pass day here to keep working on the same schedule!
});
}
});
});
new_block_dialog.showModal();
}
const schedule_block_click_handler = (e) => {