Managed to figure out how to use javascript on the plugin page by utilizing data-controller as found in other repos. Unsure how this is used, but appears to be how you can attach a js file to a div. Also implemented a basic state api to build off of in future.

This commit is contained in:
2026-01-20 20:32:37 -07:00
parent 8d85194df5
commit d024035d07
7 changed files with 111 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
<div data-role="page" class="page type-interior pluginConfigurationPage withTabs">
<div data-role="page" class="page type-interior pluginConfigurationPage withTabs"
data-controller="__plugin/media_cleaner_table.js">
<div data-role="content">
<div class="content-primary">
<div>
@@ -6,6 +7,15 @@
<a href="#configurationpage?name=Settings">Settings</a>
</div>
<h2>Media Cleaner</h2>
<table id="seriesTable">
<thead>
<tr>
<th>ID</th>
<th>Series Name</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>

View File

@@ -0,0 +1,27 @@
var table = document.getElementById("seriesTable");
const getMediaCleanerState = async () => {
const response = await fetch('/mediacleaner/state');
if(!response.ok){
throw new Error(`Response status: ${response.status}`)
}
return response.json();
}
var state = await getMediaCleanerState();
console.log("State: ", state);
for(let i = 0; i < state.length; i++){
var row = table.insertRow(-1);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
cell1.innerHTML = state[i].Id;
cell2.innerHTML = state[i].SeriesName;
cell3.innerHTML = state[i].Seasons.length;
}