slightly more generic Patch function for API
Some checks failed
gitea/vassago/pipeline/head There was a failure building this commit

untested. you know, since... offline ;)
This commit is contained in:
Adam R Grey 2024-07-06 16:00:18 -04:00
parent ab16600463
commit 5eeec24069
2 changed files with 8 additions and 8 deletions

View File

@ -23,7 +23,7 @@
<tr> <tr>
<th scope="row">Lewdness Filter Level</th> <th scope="row">Lewdness Filter Level</th>
<td> <td>
<select name="LewdnessFilterLevel" id="LewdnessFilterLevel" onchange="patchModel(jsonifyChannel())"> <select name="LewdnessFilterLevel" id="LewdnessFilterLevel" onchange="patchModel(jsonifyChannel(), '/api/Channels/')">
<!option value="" @(ThisChannel.LewdnessFilterLevel == null ? "selected" : "")>⤵ inherited - @Enumerations.GetDescription(IfInheritedLewdnessFilterLevel)</!option> <!option value="" @(ThisChannel.LewdnessFilterLevel == null ? "selected" : "")>⤵ inherited - @Enumerations.GetDescription(IfInheritedLewdnessFilterLevel)</!option>
@foreach (Enumerations.LewdnessFilterLevel enumVal in @foreach (Enumerations.LewdnessFilterLevel enumVal in
Enum.GetValues(typeof(Enumerations.LewdnessFilterLevel))) Enum.GetValues(typeof(Enumerations.LewdnessFilterLevel)))
@ -53,7 +53,7 @@
<tr> <tr>
<th scope="row">Meanness Filter Level</th> <th scope="row">Meanness Filter Level</th>
<td> <td>
<select name="MeannessFilterLevel" id="MeannessFilterLevel" onchange="patchModel(jsonifyChannel())"> <select name="MeannessFilterLevel" id="MeannessFilterLevel" onchange="patchModel(jsonifyChannel(), '/api/Channels/')">
<!option value="" @(ThisChannel.MeannessFilterLevel == null ? "selected" : "")>⤵ inherited - @Enumerations.GetDescription(IfInheritedMeannessFilterLevel)</!option> <!option value="" @(ThisChannel.MeannessFilterLevel == null ? "selected" : "")>⤵ inherited - @Enumerations.GetDescription(IfInheritedMeannessFilterLevel)</!option>
@foreach (Enumerations.MeannessFilterLevel enumVal in @foreach (Enumerations.MeannessFilterLevel enumVal in
Enum.GetValues(typeof(Enumerations.MeannessFilterLevel))) Enum.GetValues(typeof(Enumerations.MeannessFilterLevel)))

View File

@ -7,7 +7,10 @@ function testfunct(caller){
console.log("[gibberish]"); console.log("[gibberish]");
console.log(caller); console.log(caller);
} }
function patchModel(model) //todo: figure out what the URL actually needs to be, rather than assuming you get a whole-ass server to yourself.
//you selfish fuck... What are you, fox?
//as it stands, you want something like /api/Channels/, trailing slash intentional
function patchModel(model, apiUrl)
{ {
//structure the model your (dang) self into a nice object //structure the model your (dang) self into a nice object
console.log(model); console.log(model);
@ -16,15 +19,12 @@ function patchModel(model)
var components = window.location.pathname.split('/'); var components = window.location.pathname.split('/');
if(components[2] !== "Details") if(components[2] !== "Details")
{ {
console.log("wtf are you doing? " + components[2] + " is something other than Details") console.log("wtf are you doing? " + components[2] + " is something other than Details");
//add different endpoings here, if you like
} }
var type=components[1]; var type=components[1];
var id=components[3]; var id=components[3];
//todo: figure out what the URL actually needs to be, rather than assuming you get a whole-ass server to yourself.
//you selfish fuck. What are you, fox?
var apiUrl = "/api/Channels/"
console.log("dexter impression: I am now ready to post the following content:"); console.log("dexter impression: I am now ready to post the following content:");
console.log(JSON.stringify(model)); console.log(JSON.stringify(model));
fetch(apiUrl, { fetch(apiUrl, {