Fix landing, api urls
This commit is contained in:
parent
67e0d5559b
commit
630ad3a94f
@ -7,6 +7,8 @@ import axios from 'axios';
|
|||||||
import jwt_decode from 'jwt-decode';
|
import jwt_decode from 'jwt-decode';
|
||||||
import auth from '../utils/Auth';
|
import auth from '../utils/Auth';
|
||||||
|
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
const api = (url.port == "5173") ? "http://localhost:3001" : "/api";
|
||||||
const { onMenuToggle } = useLayout();
|
const { onMenuToggle } = useLayout();
|
||||||
const outsideClickListener = ref(null);
|
const outsideClickListener = ref(null);
|
||||||
const topbarMenuActive = ref(false);
|
const topbarMenuActive = ref(false);
|
||||||
@ -69,7 +71,7 @@ async function savePassword(pass) {
|
|||||||
var token = localStorage.getItem("token");
|
var token = localStorage.getItem("token");
|
||||||
var decoded = jwt_decode(token);
|
var decoded = jwt_decode(token);
|
||||||
try {
|
try {
|
||||||
const response = await axios.patch(`http://localhost:3001/user/` + decoded.id, pass, auth.getTokenHeader());
|
const response = await axios.patch(api + `/user/` + decoded.id, pass, auth.getTokenHeader());
|
||||||
if (response.status !== 204) {
|
if (response.status !== 204) {
|
||||||
console.error(response);
|
console.error(response);
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,13 @@ const setColorOptions = () => {
|
|||||||
textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary');
|
textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary');
|
||||||
surfaceBorder = documentStyle.getPropertyValue('--surface-border');
|
surfaceBorder = documentStyle.getPropertyValue('--surface-border');
|
||||||
};
|
};
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
const api = (url.port == "5173") ? "http://localhost:3001" : "/api";
|
||||||
|
|
||||||
|
|
||||||
async function getGames() {
|
async function getGames() {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`http://localhost:3001/game?limit=5000`);
|
const response = await axios.get(api + `/game?limit=5000`);
|
||||||
games.value = response.data.map(game_id => {
|
games.value = response.data.map(game_id => {
|
||||||
return game_id.ID;
|
return game_id.ID;
|
||||||
});
|
});
|
||||||
@ -42,7 +45,7 @@ async function getFrames() {
|
|||||||
if (selectedGame.value === undefined) {
|
if (selectedGame.value === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const response = await axios.get(`http://localhost:3001/frame?limit=5000&game_id=` + selectedGame.value);
|
const response = await axios.get(api + `/frame?limit=5000&game_id=` + selectedGame.value);
|
||||||
if (response.data[response.data.length - 1].elapsed_time >= 10000) {
|
if (response.data[response.data.length - 1].elapsed_time >= 10000) {
|
||||||
ms.value = false;
|
ms.value = false;
|
||||||
}
|
}
|
||||||
|
@ -41,12 +41,6 @@ const onClickLinux = () => {
|
|||||||
<span>Features</span>
|
<span>Features</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<a @click="smoothScroll('#moreinfo')"
|
|
||||||
class="flex m-0 md:ml-5 px-0 py-3 text-900 font-medium line-height-3 p-ripple" v-ripple>
|
|
||||||
<span>More info</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<a @click="smoothScroll('#downloads')"
|
<a @click="smoothScroll('#downloads')"
|
||||||
class="flex m-0 md:ml-5 px-0 py-3 text-900 font-medium line-height-3 p-ripple" v-ripple>
|
class="flex m-0 md:ml-5 px-0 py-3 text-900 font-medium line-height-3 p-ripple" v-ripple>
|
||||||
|
@ -7,6 +7,8 @@ const username = ref('');
|
|||||||
const password = ref('');
|
const password = ref('');
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
const api = (url.port == "5173") ? "http://localhost:3001" : "/api";
|
||||||
|
|
||||||
async function onLoginClick() {
|
async function onLoginClick() {
|
||||||
var login =
|
var login =
|
||||||
@ -15,7 +17,7 @@ async function onLoginClick() {
|
|||||||
password: password.value
|
password: password.value
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(`http://localhost:3001/login`, login);
|
const response = await axios.post(api + `/login`, login);
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
localStorage.setItem('token', response.data.token);
|
localStorage.setItem('token', response.data.token);
|
||||||
router.push('/home');
|
router.push('/home');
|
||||||
|
@ -19,10 +19,12 @@ const submitted = ref(false);
|
|||||||
const checkAuth = () => {
|
const checkAuth = () => {
|
||||||
auth.checkToken(true);
|
auth.checkToken(true);
|
||||||
};
|
};
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
const api = (url.port == "5173") ? "http://localhost:3001" : "/api";
|
||||||
|
|
||||||
async function showTable() {
|
async function showTable() {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`http://localhost:3001/os`);
|
const response = await axios.get(api + `/os`);
|
||||||
console.log(response.data);
|
console.log(response.data);
|
||||||
users.value = response.data;
|
users.value = response.data;
|
||||||
}
|
}
|
||||||
@ -41,7 +43,7 @@ async function onCreateClick() {
|
|||||||
name: os.value.name
|
name: os.value.name
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(`http://localhost:3001/os`, newOS, auth.getTokenHeader());
|
const response = await axios.post(api + `/os`, newOS, auth.getTokenHeader());
|
||||||
|
|
||||||
if (response.status === 204) {
|
if (response.status === 204) {
|
||||||
toast.add({ severity: 'success', summary: 'Successful', detail: 'OS Created', life: 3000 });
|
toast.add({ severity: 'success', summary: 'Successful', detail: 'OS Created', life: 3000 });
|
||||||
@ -94,7 +96,7 @@ async function onChangeOS() {
|
|||||||
};
|
};
|
||||||
console.log(os.value.ID);
|
console.log(os.value.ID);
|
||||||
try {
|
try {
|
||||||
const response = await axios.patch(`http://localhost:3001/os/` + os.value.ID, changeOS, auth.getTokenHeader());
|
const response = await axios.patch(api + `/os/` + os.value.ID, changeOS, auth.getTokenHeader());
|
||||||
|
|
||||||
if (response.status === 204) {
|
if (response.status === 204) {
|
||||||
toast.add({ severity: 'success', summary: 'Successful', detail: 'OS Modified', life: 3000 });
|
toast.add({ severity: 'success', summary: 'Successful', detail: 'OS Modified', life: 3000 });
|
||||||
@ -117,7 +119,7 @@ const confirmDeleteUser = (editUser) => {
|
|||||||
|
|
||||||
async function deleteUser() {
|
async function deleteUser() {
|
||||||
try {
|
try {
|
||||||
const response = await axios.delete(`http://localhost:3001/os/` + os.value.ID, auth.getTokenHeader());
|
const response = await axios.delete(api + `/os/` + os.value.ID, auth.getTokenHeader());
|
||||||
if (response.status !== 204) {
|
if (response.status !== 204) {
|
||||||
console.error(response);
|
console.error(response);
|
||||||
}
|
}
|
||||||
@ -139,7 +141,7 @@ const confirmDeleteSelected = () => {
|
|||||||
const deleteSelectedUsers = () => {
|
const deleteSelectedUsers = () => {
|
||||||
selectedUsers.value.forEach(element => {
|
selectedUsers.value.forEach(element => {
|
||||||
try {
|
try {
|
||||||
const response = axios.delete(`http://localhost:3001/os/` + element.ID, auth.getTokenHeader());
|
const response = axios.delete(api + `/os/` + element.ID, auth.getTokenHeader());
|
||||||
if (response.status !== 204) {
|
if (response.status !== 204) {
|
||||||
console.error(response);
|
console.error(response);
|
||||||
}
|
}
|
||||||
@ -173,8 +175,8 @@ const initFilters = () => {
|
|||||||
<template v-slot:start>
|
<template v-slot:start>
|
||||||
<div class="my-2">
|
<div class="my-2">
|
||||||
<Button label="New" icon="pi pi-plus" class="p-button-success mr-2" @click="openNew" />
|
<Button label="New" icon="pi pi-plus" class="p-button-success mr-2" @click="openNew" />
|
||||||
<Button label="Delete" icon="pi pi-trash" class="p-button-danger"
|
<Button label="Delete" icon="pi pi-trash" class="p-button-danger" @click="confirmDeleteSelected"
|
||||||
@click="confirmDeleteSelected" :disabled="!selectedUsers || !selectedUsers.length" />
|
:disabled="!selectedUsers || !selectedUsers.length" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -185,8 +187,7 @@ const initFilters = () => {
|
|||||||
:rows="10" :filters="filters"
|
:rows="10" :filters="filters"
|
||||||
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
|
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
|
||||||
:rowsPerPageOptions="[5, 10, 25]"
|
:rowsPerPageOptions="[5, 10, 25]"
|
||||||
currentPageReportTemplate="Showing {first} to {last} of {totalRecords} users"
|
currentPageReportTemplate="Showing {first} to {last} of {totalRecords} users" responsiveLayout="scroll">
|
||||||
responsiveLayout="scroll">
|
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
|
<div class="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
|
||||||
<h5 class="m-0">Manage Users</h5>
|
<h5 class="m-0">Manage Users</h5>
|
||||||
@ -258,8 +259,7 @@ const initFilters = () => {
|
|||||||
<span v-if="os">Are you sure you want to delete the selected users?</span>
|
<span v-if="os">Are you sure you want to delete the selected users?</span>
|
||||||
</div>
|
</div>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<Button label="No" icon="pi pi-times" class="p-button-text"
|
<Button label="No" icon="pi pi-times" class="p-button-text" @click="deleteUsersDialog = false" />
|
||||||
@click="deleteUsersDialog = false" />
|
|
||||||
<Button label="Yes" icon="pi pi-check" class="p-button-text" @click="deleteSelectedUsers" />
|
<Button label="Yes" icon="pi pi-check" class="p-button-text" @click="deleteSelectedUsers" />
|
||||||
</template>
|
</template>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
@ -19,10 +19,12 @@ const userDialogChange = ref(false);
|
|||||||
const checkAuth = () => {
|
const checkAuth = () => {
|
||||||
auth.checkToken(true);
|
auth.checkToken(true);
|
||||||
};
|
};
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
const api = (url.port == "5173") ? "http://localhost:3001" : "/api";
|
||||||
|
|
||||||
async function showTable() {
|
async function showTable() {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`http://localhost:3001/user`, auth.getTokenHeader());
|
const response = await axios.get(api + `/user`, auth.getTokenHeader());
|
||||||
users.value = response.data;
|
users.value = response.data;
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
@ -48,7 +50,7 @@ async function onCreateClick() {
|
|||||||
email: user.value.email
|
email: user.value.email
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(`http://localhost:3001/user`, newUser, auth.getTokenHeader());
|
const response = await axios.post(api + `/user`, newUser, auth.getTokenHeader());
|
||||||
|
|
||||||
if (response.status === 204) {
|
if (response.status === 204) {
|
||||||
toast.add({ severity: 'success', summary: 'Successful', detail: 'User Created', life: 3000 });
|
toast.add({ severity: 'success', summary: 'Successful', detail: 'User Created', life: 3000 });
|
||||||
@ -104,7 +106,7 @@ async function onChangeUser() {
|
|||||||
email: user.value.email
|
email: user.value.email
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const response = await axios.patch(`http://localhost:3001/user/` + user.value.ID, changeUser, auth.getTokenHeader());
|
const response = await axios.patch(api + `/user/` + user.value.ID, changeUser, auth.getTokenHeader());
|
||||||
|
|
||||||
if (response.status === 204) {
|
if (response.status === 204) {
|
||||||
toast.add({ severity: 'success', summary: 'Successful', detail: 'User Modified', life: 3000 });
|
toast.add({ severity: 'success', summary: 'Successful', detail: 'User Modified', life: 3000 });
|
||||||
@ -127,7 +129,7 @@ const confirmDeleteUser = (editUser) => {
|
|||||||
|
|
||||||
async function deleteUser() {
|
async function deleteUser() {
|
||||||
try {
|
try {
|
||||||
const response = await axios.delete(`http://localhost:3001/user/` + user.value.ID, auth.getTokenHeader());
|
const response = await axios.delete(api + `/user/` + user.value.ID, auth.getTokenHeader());
|
||||||
if (response.status !== 204) {
|
if (response.status !== 204) {
|
||||||
console.error(response);
|
console.error(response);
|
||||||
}
|
}
|
||||||
@ -149,7 +151,7 @@ const confirmDeleteSelected = () => {
|
|||||||
const deleteSelectedUsers = () => {
|
const deleteSelectedUsers = () => {
|
||||||
selectedUsers.value.forEach(element => {
|
selectedUsers.value.forEach(element => {
|
||||||
try {
|
try {
|
||||||
const response = axios.delete(`http://localhost:3001/user/` + element.ID, auth.getTokenHeader());
|
const response = axios.delete(api + `/user/` + element.ID, auth.getTokenHeader());
|
||||||
if (response.status !== 204) {
|
if (response.status !== 204) {
|
||||||
console.error(response);
|
console.error(response);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user