Browse Source

* Merge

master
vvandenb 2 years ago
parent
commit
986bab3d72
  1. 25
      .env_sample
  2. 1
      front/volume/src/App.svelte
  3. 19
      front/volume/src/components/Channels.svelte
  4. 8
      front/volume/src/components/Profile.svelte

25
.env_sample

@ -0,0 +1,25 @@
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_USER=postgres_usr
POSTGRES_PASSWORD=postgres_pw
POSTGRES_DB=transcendence
PGADMIN_DEFAULT_EMAIL=admin@pg.com
PGADMIN_DEFAULT_PASSWORD=admin
MAIL_USER=vaganiwast@gmail.com
MAIL_PASSWORD=
FRONT_FPS=144
HOST=localhost
FRONT_PORT=80
BACK_PORT=3001
HASH_SALT=10
JWT_SECRET=test
JWT_EXPIRATION_TIME=900
FT_OAUTH_CLIENT_ID=
FT_OAUTH_CLIENT_SECRET=
FT_OAUTH_CALLBACK_URL=http://$HOST:$BACK_PORT/log/inReturn

1
front/volume/src/App.svelte

@ -92,6 +92,7 @@
profileUsername = event.detail; profileUsername = event.detail;
setAppState(APPSTATE.PROFILE_ID); setAppState(APPSTATE.PROFILE_ID);
} }
$: console.log(profileUsername)
async function getDMs(username: string): Promise<Response | null> { async function getDMs(username: string): Promise<Response | null> {
const res = await fetch(API_URL + "/channels/dms/" + username, { const res = await fetch(API_URL + "/channels/dms/" + username, {

19
front/volume/src/components/Channels.svelte

@ -95,14 +95,13 @@
export let onSelectChannel: (channel: ChannelsType) => void; export let onSelectChannel: (channel: ChannelsType) => void;
export const selectChat = (id: number) => { export const selectChat = (id: number) => {
console.log("channel: ", id) console.log("channel: ", id)
popup.set(bind(Alert, {message:"Did not find channel", form : false}))
getChannels().then(() => { getChannels().then(() => {
const channel = channels.find((c) => c.id === id); const channel = channels.find((c) => c.id === id);
if (channel) { if (channel) {
joinChannel(id); joinChannel(id);
onSelectChannel(channel); onSelectChannel(channel);
} else { } else {
alert("Did not find channel"); popup.set(bind(Alert, {message:"Did not find channel", form : false}))
} }
}); });
}; };
@ -112,7 +111,7 @@
let password = ""; let password = "";
name = prompt("Enter a name for the new channel:"); name = prompt("Enter a name for the new channel:");
if (name.includes("#")) { if (name.includes("#")) {
alert("Channel name cannot contain #"); popup.set(bind(Alert, {message:"Channel name cannot contain #", form : false}))
return; return;
} }
if (name) { if (name) {
@ -133,7 +132,8 @@
isPrivate: channelMode === "private", isPrivate: channelMode === "private",
}), }),
}); });
if (!response.ok) alert("Error creating channel"); if (!response.ok)
popup.set(bind(Alert, {message:"Error creating channel", form : false}))
getChannels() getChannels()
} }
}; };
@ -149,7 +149,8 @@
mode: "cors", mode: "cors",
}); });
if (response.ok) channels = channels.filter((c) => c.id !== id); if (response.ok) channels = channels.filter((c) => c.id !== id);
else alert("Error deleting channel"); else
popup.set(bind(Alert, {message:"Error deleting channel", form : false}))
} }
}; };
@ -176,12 +177,12 @@
}), }),
}); });
if (response2.ok) { if (response2.ok) {
alert("User invited"); popup.set(bind(Alert, {message:"User invited", form : false}))
} else { } else {
alert("Error inviting user"); popup.set(bind(Alert, {message:"Error inviting user", form : false}))
} }
} else { } else {
alert("Error getting user infos"); popup.set(bind(Alert, {message:"Error getting user infos", form : false}))
} }
}; };
@ -205,7 +206,7 @@
if (response.ok) { if (response.ok) {
channels.push(await response.json()); channels.push(await response.json());
} else { } else {
alert("Error changing password"); popup.set(bind(Alert, {message:"Error changing password", form : false}))
} }
}; };

8
front/volume/src/components/Profile.svelte

@ -17,17 +17,17 @@
export let username: string = $store.username; export let username: string = $store.username;
let edit: boolean = true; let edit: boolean = true;
let user: any = $store; let user: Player = $store;
let avatarForm: HTMLFormElement; let avatarForm: HTMLFormElement;
async function getUser() { async function getUser() {
if (username !== $store.username) { if (username !== $store.username) {
edit = false; edit = false;
const res = await fetch(API_URL + "/users/" + username + "/byname", { let res = await fetch(API_URL + "/users/" + username + "/byname", {
mode: "cors", mode: "cors",
}); });
user = res.json(); user = await res.json();
} }
} }
@ -69,7 +69,7 @@
<h3>===| <mark>{user.username}'s Profile</mark> |===</h3> <h3>===| <mark>{user.username}'s Profile</mark> |===</h3>
<div class="profile-header"> <div class="profile-header">
{#if !edit} {#if !edit}
<img src={API_URL + "/users/avatar"} alt="avatar" class="profile-img" /> <img src={`${API_URL}/users/${user.ftId}/avatar`} alt="avatar" class="profile-img" />
{:else} {:else}
<form <form
action={`${API_URL}/users/avatar`} action={`${API_URL}/users/avatar`}

Loading…
Cancel
Save