release edit page! + a lot of other stuff oml

Signed-off-by: ari melody <ari@arimelody.me>
This commit is contained in:
ari melody 2024-08-05 01:23:17 +01:00
parent f276ef1ff2
commit 10f19d46db
23 changed files with 981 additions and 347 deletions

View file

@ -21,7 +21,7 @@ header {
margin: 1em auto;
display: flex;
flex-direction: row;
justify-content: center;
justify-content: left;
background: #f8f8f8;
border-radius: .5em;
@ -29,13 +29,23 @@ header {
}
header .icon {
height: 100%;
margin-right: 1em;
}
header a {
height: 100%;
header .title {
width: auto;
height: 100%;
margin: 0 1em 0 0;
display: flex;
line-height: 2em;
text-decoration: none;
color: inherit;
}
header a {
width: auto;
height: 100%;
margin: 0px;
padding: 0 1em;
@ -47,9 +57,12 @@ header a {
color: inherit;
}
header a:hover {
background: #00000010;
text-decoration: none;
}
header #logout {
margin-left: auto;
}
main {
@ -67,6 +80,10 @@ a:hover {
text-decoration: underline;
}
.card {
margin-bottom: 2em;
}
.card h2 {
margin: 0 0 .5em 0;
}
@ -77,184 +94,18 @@ a:hover {
}
.card-title {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.create-btn {
background: #c4ff6a;
padding: .5em .8em;
border-radius: .5em;
border: 1px solid #84b141;
text-decoration: none;
}
.create-btn:hover {
background: #fff;
border-color: #d0d0d0;
text-decoration: inherit;
}
.create-btn:active {
background: #d0d0d0;
border-color: #808080;
text-decoration: inherit;
}
.release {
margin-bottom: 1em;
padding: 1em;
display: flex;
flex-direction: row;
gap: 1em;
border-radius: .5em;
background: #f8f8f8f8;
border: 1px solid #808080;
}
.release-artwork {
width: 96px;
display: flex;
justify-content: center;
align-items: center;
}
.release-artwork img {
width: 100%;
aspect-ratio: 1;
}
.latest-release .release-info {
width: 300px;
flex-direction: column;
}
.release-title small {
opacity: .75;
}
.release-links {
margin: .5em 0;
padding: 0;
display: flex;
flex-direction: row;
list-style: none;
flex-wrap: wrap;
gap: .5em;
}
.release-links li {
flex-grow: 1;
}
.release-links a {
padding: .5em;
display: block;
border-radius: .5em;
text-decoration: none;
color: #f0f0f0;
background: #303030;
text-align: center;
transition: color .1s, background .1s;
}
.release-links a:hover {
color: #303030;
background: #f0f0f0;
}
.release-actions {
margin-top: .5em;
}
.release-actions a {
margin-right: .3em;
padding: .3em .5em;
display: inline-block;
border-radius: .3em;
background: #e0e0e0;
transition: color .1s, background .1s;
}
.release-actions a:hover {
color: #303030;
background: #f0f0f0;
text-decoration: none;
}
.artist {
margin-bottom: .5em;
padding: .5em;
display: flex;
flex-direction: row;
align-items: center;
gap: .5em;
border-radius: .5em;
background: #f8f8f8f8;
border: 1px solid #808080;
}
.artist:hover {
text-decoration: hover;
}
.artist-avatar {
width: 32px;
height: 32px;
object-fit: cover;
border-radius: 100%;
}
.track {
margin-bottom: 1em;
padding: 1em;
display: flex;
flex-direction: column;
gap: .5em;
border-radius: .5em;
background: #f8f8f8f8;
border: 1px solid #808080;
}
h2.track-title {
margin: 0;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.track-album {
margin-left: auto;
font-style: italic;
font-size: .75em;
opacity: .5;
}
.track-album.empty {
color: #ff2020;
opacity: 1;
}
.track-description {
font-style: italic;
}
.track-lyrics {
max-height: 10em;
overflow-y: scroll;
}
.track .empty {
opacity: 0.75;
.card-title h1,
.card-title h2,
.card-title h3 {
margin: 0;
}
@media screen and (max-width: 520px) {

View file

@ -0,0 +1,96 @@
import Stateful from "/script/silver.min.js"
const releaseID = document.getElementById("release").dataset.id;
const artwork_input = document.getElementById("artwork");
const type_input = document.getElementById("type");
const desc_input = document.getElementById("description");
const date_input = document.getElementById("release-date");
const buyname_input = document.getElementById("buyname");
const buylink_input = document.getElementById("buylink");
const vis_input = document.getElementById("visibility");
const save_btn = document.getElementById("save");
let token = atob(localStorage.getItem("arime-token"));
let edited = new Stateful(false);
let release_data = update_data(undefined);
function update_data(old) {
let release_data = {
visible: vis_input.value === "true",
title: undefined,
description: desc_input.value,
type: type_input.value,
releaseDate: date_input.value,
artwork: artwork_input.attributes.src.value,
buyname: buyname_input.value,
buylink: buylink_input.value,
};
if (release_data && release_data != old) {
edited.set(true);
}
return release_data;
}
function save_release() {
console.table(release_data);
edited.set(false);
(async () => {
const res = await fetch(
"/api/v1/music/" + releaseID, {
method: "PUT",
body: JSON.stringify(release_data),
headers: {
"Content-Type": "application/json",
"Authorisation": "Bearer " + token,
},
});
if (!res.ok) {
const text = await res.text();
console.error(text);
alert(text);
return;
}
location = location;
})();
}
window.save_release = save_release;
edited.onUpdate(edited => {
save_btn.disabled = !edited;
})
artwork_input.addEventListener("click", () => {
release_data = update_data(release_data);
});
type_input.addEventListener("change", () => {
release_data = update_data(release_data);
});
desc_input.addEventListener("change", () => {
release_data = update_data(release_data);
});
date_input.addEventListener("change", () => {
release_data = update_data(release_data);
});
buyname_input.addEventListener("change", () => {
release_data = update_data(release_data);
});
buylink_input.addEventListener("change", () => {
release_data = update_data(release_data);
});
vis_input.addEventListener("change", () => {
release_data = update_data(release_data);
});
save_btn.addEventListener("click", () => {
if (!edited.get()) return;
save_release();
})

183
admin/static/index.css Normal file
View file

@ -0,0 +1,183 @@
.create-btn {
background: #c4ff6a;
padding: .5em .8em;
border-radius: .5em;
border: 1px solid #84b141;
text-decoration: none;
}
.create-btn:hover {
background: #fff;
border-color: #d0d0d0;
text-decoration: inherit;
}
.create-btn:active {
background: #d0d0d0;
border-color: #808080;
text-decoration: inherit;
}
.release {
margin-bottom: 1em;
padding: 1em;
display: flex;
flex-direction: row;
gap: 1em;
border-radius: .5em;
background: #f8f8f8f8;
border: 1px solid #808080;
}
.release-artwork {
width: 96px;
display: flex;
justify-content: center;
align-items: center;
}
.release-artwork img {
width: 100%;
aspect-ratio: 1;
}
.latest-release .release-info {
width: 300px;
flex-direction: column;
}
.release-title small {
opacity: .75;
}
.release-links {
margin: .5em 0;
padding: 0;
display: flex;
flex-direction: row;
list-style: none;
flex-wrap: wrap;
gap: .5em;
}
.release-links li {
flex-grow: 1;
}
.release-links a {
padding: .5em;
display: block;
border-radius: .5em;
text-decoration: none;
color: #f0f0f0;
background: #303030;
text-align: center;
transition: color .1s, background .1s;
}
.release-links a:hover {
color: #303030;
background: #f0f0f0;
}
.release-actions {
margin-top: .5em;
}
.release-actions a {
margin-right: .3em;
padding: .3em .5em;
display: inline-block;
border-radius: .3em;
background: #e0e0e0;
transition: color .1s, background .1s;
}
.release-actions a:hover {
color: #303030;
background: #f0f0f0;
text-decoration: none;
}
.artist {
margin-bottom: .5em;
padding: .5em;
display: flex;
flex-direction: row;
align-items: center;
gap: .5em;
border-radius: .5em;
background: #f8f8f8f8;
border: 1px solid #808080;
}
.artist:hover {
text-decoration: hover;
}
.artist-avatar {
width: 32px;
height: 32px;
object-fit: cover;
border-radius: 100%;
}
.track {
margin-bottom: 1em;
padding: 1em;
display: flex;
flex-direction: column;
gap: .5em;
border-radius: .5em;
background: #f8f8f8f8;
border: 1px solid #808080;
}
.card h2.track-title {
margin: 0;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.track-id {
width: fit-content;
font-family: "Monaspace Argon", monospace;
font-size: .8em;
font-style: italic;
line-height: 1em;
user-select: all;
}
.track-album {
margin-left: auto;
font-style: italic;
font-size: .75em;
opacity: .5;
}
.track-album.empty {
color: #ff2020;
opacity: 1;
}
.track-description {
font-style: italic;
}
.track-lyrics {
max-height: 10em;
overflow-y: scroll;
}
.track .empty {
opacity: 0.75;
}

219
admin/static/release.css Normal file
View file

@ -0,0 +1,219 @@
#release {
margin-bottom: 1em;
padding: 1em;
display: flex;
flex-direction: row;
gap: 1.2em;
border-radius: .5em;
background: #f8f8f8f8;
border: 1px solid #808080;
}
.release-artwork {
width: 200px;
display: flex;
justify-content: center;
align-items: start;
}
.release-artwork img {
width: 100%;
aspect-ratio: 1;
}
.release-artwork img:hover {
outline: 1px solid #808080;
cursor: pointer;
}
.release-info {
margin: .5em 0;
flex-grow: 1;
display: flex;
flex-direction: column;
}
.release-title {
margin: 0;
}
.release-title small {
opacity: .75;
}
.release-info table {
width: 100%;
margin: .5em 0;
border-collapse: collapse;
}
.release-info table td {
padding: .2em;
border-bottom: 1px solid #d0d0d0;
}
.release-info table tr td:first-child {
vertical-align: top;
opacity: .66;
}
.release-info table tr td:not(:first-child):hover {
background: #e8e8e8;
cursor: pointer;
}
.release-info table td select,
.release-info table td input,
.release-info table td textarea {
padding: .2em;
resize: none;
width: 100%;
font-family: inherit;
font-size: inherit;
color: inherit;
border: none;
background: none;
outline: none;
}
.release-info table td:has(select),
.release-info table td:has(input),
.release-info table td:has(textarea) {
padding: 0;
}
button, .button {
padding: .5em .8em;
font-family: inherit;
font-size: inherit;
border-radius: .5em;
border: 1px solid #a0a0a0;
background: #f0f0f0;
color: inherit;
}
button:hover, .button:hover {
background: #fff;
border-color: #d0d0d0;
}
button:active, .button:active {
background: #d0d0d0;
border-color: #808080;
}
button.edit {
color: inherit;
background: #c4ff6a;
border-color: #84b141;
}
button.edit:hover {
background: #fff;
border-color: #d0d0d0;
}
button.edit:active {
background: #d0d0d0;
border-color: #808080;
}
button.save {
background: #6fd7ff;
border-color: #6f9eb0;
}
button.save:hover {
background: #fff;
border-color: #d0d0d0;
}
button.save:active {
background: #d0d0d0;
border-color: #808080;
}
button[disabled] {
background: #d0d0d0 !important;
border-color: #808080 !important;
opacity: .5;
cursor: not-allowed !important;
}
.release-actions {
margin-top: auto;
display: flex;
gap: .5em;
flex-direction: row;
justify-content: right;
}
.credit {
margin-bottom: .5em;
padding: .5em;
display: flex;
flex-direction: row;
align-items: center;
gap: 1em;
border-radius: .5em;
background: #f8f8f8f8;
border: 1px solid #808080;
}
.credit .artist-avatar {
border-radius: .5em;
}
.credit .artist-name {
font-weight: bold;
}
.credit .artist-role small {
font-size: inherit;
opacity: .66;
}
.track {
margin-bottom: 1em;
padding: 1em;
display: flex;
flex-direction: column;
gap: .5em;
border-radius: .5em;
background: #f8f8f8f8;
border: 1px solid #808080;
}
.card h2.track-title {
margin: 0;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.track-id {
width: fit-content;
font-family: "Monaspace Argon", monospace;
font-size: .8em;
font-style: italic;
line-height: 1em;
user-select: all;
-webkit-user-select: all;
}
.track-album {
margin-left: auto;
font-style: italic;
font-size: .75em;
opacity: .5;
}
.track-album.empty {
color: #ff2020;
opacity: 1;
}
.track-description {
font-style: italic;
}
.track-lyrics {
max-height: 10em;
overflow-y: scroll;
}
.track .empty {
opacity: 0.75;
}