2026-03-03 11:36:24 +00:00
|
|
|
import { Controller } from "@hotwired/stimulus"
|
|
|
|
|
import {showToast} from "../services/toast";
|
|
|
|
|
|
|
|
|
|
export default class ShowUploadController extends Controller {
|
|
|
|
|
static values = {
|
|
|
|
|
copySnippet: String,
|
2026-03-04 11:33:39 +00:00
|
|
|
siteId: Number,
|
|
|
|
|
uploadId: Number,
|
2026-03-03 11:36:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
async copy(ev) {
|
|
|
|
|
ev.preventDefault();
|
|
|
|
|
|
|
|
|
|
await navigator.clipboard.writeText(this.copySnippetValue);
|
|
|
|
|
|
|
|
|
|
showToast({
|
|
|
|
|
title: "️📋 HTML Snippet",
|
|
|
|
|
body: "Copied to clipboard.",
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-03-04 11:33:39 +00:00
|
|
|
|
|
|
|
|
async delete(ev) {
|
|
|
|
|
ev.preventDefault();
|
|
|
|
|
if (!confirm("Are you sure you want to delete this upload?")) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
await this._doDelete();
|
|
|
|
|
window.location = `/sites/${this.siteIdValue}/uploads/`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async _doDelete() {
|
|
|
|
|
const url = `/sites/${this.siteIdValue}/uploads/${this.uploadIdValue}`
|
|
|
|
|
|
|
|
|
|
await fetch(url, {
|
|
|
|
|
method: 'DELETE',
|
|
|
|
|
headers: {
|
|
|
|
|
'Accept': 'application/json'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2026-03-03 11:36:24 +00:00
|
|
|
}
|