From a74ac00b5564438a055c92cf2a99e6b30ed6f75e Mon Sep 17 00:00:00 2001 From: Ada Werefox Date: Wed, 30 Apr 2025 14:17:52 -0700 Subject: [PATCH] Updates to match API changes. --- src/ts/authorization.ts | 13 +++++++------ src/ts/function_tags.ts | 9 +++------ src/ts/functions.ts | 20 +++++++------------- src/ts/groups.ts | 7 ++----- src/ts/user_info.ts | 2 +- src/views/UserDashboard.vue | 2 +- vite.config.ts | 2 ++ 7 files changed, 23 insertions(+), 32 deletions(-) diff --git a/src/ts/authorization.ts b/src/ts/authorization.ts index 932a416..3e2e66f 100644 --- a/src/ts/authorization.ts +++ b/src/ts/authorization.ts @@ -1,14 +1,15 @@ +export const authorization = { + message: false, +} + export function isLoggedIn(): Promise { - return fetch('http://localhost:31337/user/authorized', { + return fetch('http://192.168.50.91:31337/user/authorized', { credentials: 'include', }) .then((res) => { return res.json().then((res_json) => { - const is_authorized = res_json.message - return Boolean(is_authorized) + return res_json.message }) }) - .catch(() => { - return false - }) + .catch(() => {}) } diff --git a/src/ts/function_tags.ts b/src/ts/function_tags.ts index 420a63b..d65b3ab 100644 --- a/src/ts/function_tags.ts +++ b/src/ts/function_tags.ts @@ -9,7 +9,7 @@ export const function_tags_store = reactive({ }) export function update_function_tags() { - fetch('http://localhost:31337/all/function-tags', { + fetch('http://192.168.50.91:31337/all/function-tags', { credentials: 'include', }) .then((res) => { @@ -24,9 +24,9 @@ export function update_function_tags() { } export function add_function_tag(function_tag_name: string) { - const post_url = new URL('http://localhost:31337/function-tag') + const post_url = new URL('http://192.168.50.91:31337/function-tag') const search_params = new URLSearchParams() - search_params.append('name', function_tag_name) + search_params.append('id', function_tag_name) post_url.search = search_params.toString() fetch(post_url, { credentials: 'include', @@ -34,9 +34,6 @@ export function add_function_tag(function_tag_name: string) { body: JSON.stringify({ name: function_tag_name, }), - headers: { - 'Content-Type': 'application/json', - }, }) .then((res) => { if (res.status === 400) { diff --git a/src/ts/functions.ts b/src/ts/functions.ts index 5236d5b..79d4747 100644 --- a/src/ts/functions.ts +++ b/src/ts/functions.ts @@ -23,7 +23,7 @@ export const functions_store = reactive({ }) export function get_functions() { - fetch('http://localhost:31337/all/functions', { + fetch('http://192.168.50.91:31337/all/functions', { credentials: 'include', }) .then((res) => { @@ -43,9 +43,9 @@ export function update_function( function_tags: string[], function_requirements: string[], ) { - const post_url = new URL('http://localhost:31337/function') + const post_url = new URL('http://192.168.50.91:31337/function') const search_params = new URLSearchParams() - search_params.append('name', function_name) + search_params.append('id', function_name) function_tags.forEach((tag) => { search_params.append('tags', tag) }) @@ -63,9 +63,6 @@ export function update_function( tags: function_tags, requirements: function_requirements, }), - headers: { - 'Content-Type': 'application/json', - }, }) .then((res) => { if (res.status === 400) { @@ -80,9 +77,9 @@ export function update_function( } export function delete_function(function_name: string) { - const delete_url = new URL('http://localhost:31337/function') + const delete_url = new URL('http://192.168.50.91:31337/function') const search_params = new URLSearchParams() - search_params.append('name', function_name) + search_params.append('id', function_name) delete_url.search = search_params.toString() fetch(delete_url, { credentials: 'include', @@ -108,9 +105,9 @@ export function add_function( function_tags: string[], function_requirements: string[], ) { - const post_url = new URL('http://localhost:31337/function') + const post_url = new URL('http://192.168.50.91:31337/function') const search_params = new URLSearchParams() - search_params.append('name', function_name) + search_params.append('id', function_name) function_tags.forEach((tag) => { search_params.append('tags', tag) }) @@ -128,9 +125,6 @@ export function add_function( tags: function_tags, requirements: function_requirements, }), - headers: { - 'Content-Type': 'application/json', - }, }) .then((res) => { if (res.status === 400) { diff --git a/src/ts/groups.ts b/src/ts/groups.ts index 811424f..51354cf 100644 --- a/src/ts/groups.ts +++ b/src/ts/groups.ts @@ -9,7 +9,7 @@ export const groups_store = reactive({ }) export function update_groups() { - fetch('http://localhost:31337/all/groups', { + fetch('http://192.168.50.91:31337/all/groups', { credentials: 'include', }) .then((res) => { @@ -24,13 +24,10 @@ export function update_groups() { } export function add_group(group: string) { - fetch('http://localhost:31337/group?name=' + group, { + fetch('http://192.168.50.91:31337/group?name=' + group, { credentials: 'include', method: 'POST', body: JSON.stringify({ name: group }), - headers: { - 'Content-Type': 'application/json', - }, }) .then((res) => { if (res.status === 400) { diff --git a/src/ts/user_info.ts b/src/ts/user_info.ts index f218441..a1c57ab 100644 --- a/src/ts/user_info.ts +++ b/src/ts/user_info.ts @@ -9,7 +9,7 @@ export const user_store = reactive({ }) export function update_info() { - fetch('http://localhost:31337/user/info', { + fetch('http://192.168.50.91:31337/user/info', { credentials: 'include', }) .then((res) => { diff --git a/src/views/UserDashboard.vue b/src/views/UserDashboard.vue index c1a9bd2..20548bc 100644 --- a/src/views/UserDashboard.vue +++ b/src/views/UserDashboard.vue @@ -118,7 +118,7 @@ onMounted(update_function_tags)

Logout

diff --git a/vite.config.ts b/vite.config.ts index 2b4202c..0e17034 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,6 +6,8 @@ import vueJsx from '@vitejs/plugin-vue-jsx' import vueDevTools from 'vite-plugin-vue-devtools' import tailwindcss from '@tailwindcss/vite' +export const api_domain = 'http://192.168.50.91:31337' + // https://vite.dev/config/ export default defineConfig({ server: {