weiro/assets/js/controllers/show_upload.js
Leon Mika 199ff9feb9 More changes to uploads:
- Have got upload images appearing in the post list
- Allowed for deleting uploads
- Allowed for seeing the upload progress
- Fixed the setting of upload properties like the MIME type
- Removed the stripe exif logic with just re-encoding PNGs and JPEGs by loading them and saving them
2026-03-04 22:33:39 +11:00

41 lines
1 KiB
JavaScript

import { Controller } from "@hotwired/stimulus"
import {showToast} from "../services/toast";
export default class ShowUploadController extends Controller {
static values = {
copySnippet: String,
siteId: Number,
uploadId: Number,
};
async copy(ev) {
ev.preventDefault();
await navigator.clipboard.writeText(this.copySnippetValue);
showToast({
title: "️📋 HTML Snippet",
body: "Copied to clipboard.",
});
}
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'
}
})
}
}