Apply config function added, synced with django backend

This commit is contained in:
infidel
2022-12-01 13:05:00 +07:00
parent c08c689a14
commit 9746a2914c
3 changed files with 41 additions and 33 deletions

View File

@@ -14,12 +14,16 @@
export let checked_vals;
let submitFilter = "";
$: getCookie("csrftoken") == null?
login_wg() : console.log("Cookie Error");
async function apply_sys_config() {
const rawResponse = await fetch('/api2/wgSysApply');
console.log("Apply system config");
console.log(rawResponse);
}
function login_wg() {
async function login_wg() {
const rawResponse = fetch('/api2/wgLogin', {
const rawResponse = await fetch('/api2/wgLogin', {
method: 'GET',
headers: {
'Authorization': 'Basic ' + btoa('tipadmin:tiplab123'),
@@ -27,8 +31,6 @@
'Content-Type': 'application/json'
}
});
console.log(rawResponse);
}
$: submitFilter != ""?
@@ -75,11 +77,19 @@
}
return cookieValue;
}
async function bulk_disable_req(state) {
login_wg();
// login_wg();
let tmp_filter = filter
filter = "";
filter = tmp_filter;
let csrftoken = getCookie('csrftoken');
console.log("Bulk Disable -->");
console.log(csrftoken);
console.log("-<>-"+checked_vals);
const rawResponse = await fetch('/api2/wgEditState?id=bulk&state='+state, {
method: 'POST',
@@ -93,9 +103,11 @@
body: JSON.stringify(checked_vals)
});
const content = await rawResponse.json();
// const content = await rawResponse.json();
}
login_wg();
</script>
<div
@@ -120,8 +132,9 @@
Filter
</button>
<button
class="mt-3 bg-teal-500 text-white active:bg-red-500 font-bold uppercase text-xs px-4 py-2 rounded shadow hover:shadow-md outline-none focus:outline-none mr-1 ease-linear transition-all duration-150"
class="mt-3 bg-amber-500 text-amber-100 active:bg-red-500 font-bold uppercase text-xs px-4 py-2 rounded shadow hover:shadow-md outline-none focus:outline-none mr-1 ease-linear transition-all duration-150"
type="button"
on:click="{() => apply_sys_config()}"
>
Apply to System
</button>
@@ -170,6 +183,7 @@
<div class="text-center flex justify-between">
<h6 class="text-teal-50 text-xl font-bold">Create Filter</h6>
<div>
<button
class="bg-blueGray-700 text-white active:bg-red-500 font-bold uppercase text-xs px-4 py-2 rounded shadow hover:shadow-md outline-none focus:outline-none mr-1 ease-linear transition-all duration-150"
type="button"
@@ -177,6 +191,7 @@
>
Reset Filter
</button>
<button
class="bg-red-400 text-white active:bg-red-500 font-bold uppercase text-xs px-4 py-2 rounded shadow hover:shadow-md outline-none focus:outline-none mr-1 ease-linear transition-all duration-150"
type="button"
@@ -184,6 +199,7 @@
>
Close Filter
</button>
</div>
</div>
</div>
@@ -212,17 +228,17 @@
<button
class="mt-3 bg-teal-500 text-white active:bg-red-500 font-bold uppercase text-xs px-4 py-2 rounded shadow hover:shadow-md outline-none focus:outline-none mr-1 ease-linear transition-all duration-150"
type="button"
on:click="{bulk_disable_req('false')}"
on:click="{() => bulk_disable_req('true')}"
>
Disable Selected
Enable Selected
</button>
<button
class="mt-3 bg-teal-500 text-white active:bg-red-500 font-bold uppercase text-xs px-4 py-2 rounded shadow hover:shadow-md outline-none focus:outline-none mr-1 ease-linear transition-all duration-150"
type="button"
on:click="{toggleModal}"
on:click="{() => bulk_disable_req('false')}"
>
Edit Profile
Disable Bulk
</button>
<button

View File

@@ -48,6 +48,7 @@
selectedID.clear();
}
selectedID = selectedID;
checked_vals = checkbox_vals;
};
// let promise = getwgResponse();
@@ -56,7 +57,6 @@
checkbox_vals = []
const wg_promise = getwgResponse(filter);
const wg_resp = await wg_promise;
console.log("[+] ID Arrays");