Browse Source

fixed personals profils

master
nicolas-arnaud 2 years ago
parent
commit
297c1ac1b6
  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;
setAppState(APPSTATE.PROFILE_ID);
}
$: console.log(profileUsername)
async function getDMs(username: string): Promise<Response | null> {
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 const selectChat = (id: number) => {
console.log("channel: ", id)
popup.set(bind(Alert, {message:"Did not find channel", form : false}))
getChannels().then(() => {
const channel = channels.find((c) => c.id === id);
if (channel) {
joinChannel(id);
onSelectChannel(channel);
} else {
alert("Did not find channel");
popup.set(bind(Alert, {message:"Did not find channel", form : false}))
}
});
};
@ -112,7 +111,7 @@
let password = "";
name = prompt("Enter a name for the new channel:");
if (name.includes("#")) {
alert("Channel name cannot contain #");
popup.set(bind(Alert, {message:"Channel name cannot contain #", form : false}))
return;
}
if (name) {
@ -133,7 +132,8 @@
isPrivate: channelMode === "private",
}),
});
if (!response.ok) alert("Error creating channel");
if (!response.ok)
popup.set(bind(Alert, {message:"Error creating channel", form : false}))
getChannels()
}
};
@ -149,7 +149,8 @@
mode: "cors",
});
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) {
alert("User invited");
popup.set(bind(Alert, {message:"User invited", form : false}))
} else {
alert("Error inviting user");
popup.set(bind(Alert, {message:"Error inviting user", form : false}))
}
} else {
alert("Error getting user infos");
popup.set(bind(Alert, {message:"Error getting user infos", form : false}))
}
};
@ -205,7 +206,7 @@
if (response.ok) {
channels.push(await response.json());
} 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;
let edit: boolean = true;
let user: any = $store;
let user: Player = $store;
let avatarForm: HTMLFormElement;
async function getUser() {
if (username !== $store.username) {
edit = false;
const res = await fetch(API_URL + "/users/" + username + "/byname", {
let res = await fetch(API_URL + "/users/" + username + "/byname", {
mode: "cors",
});
user = res.json();
user = await res.json();
}
}
@ -69,7 +69,7 @@
<h3>===| <mark>{user.username}'s Profile</mark> |===</h3>
<div class="profile-header">
{#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}
<form
action={`${API_URL}/users/avatar`}

Loading…
Cancel
Save