Browse Source

moved channel settings from chat to channels, fetch done, need route in controller

master
WalidMoovin 2 years ago
parent
commit
1948f04ca0
  1. 23
      front/volume/src/components/Channels.svelte
  2. 42
      front/volume/src/components/Chat.svelte

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

@ -116,6 +116,28 @@
}; };
//--------------------------------------------------------------------------------/ //--------------------------------------------------------------------------------/
const changePassword = async (id: number) => {
let string = prompt("Enter the new password for this channel (leave empty to remove password) :");
const response = await fetch(API_URL + "/channels/" + id + "/password", {
credentials: "include",
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
password: string,
}),
});
if (response.ok) {
channels.push(await response.json());
} else {
alert("Error changing password");
}
};
//--------------------------------------------------------------------------------/
</script> </script>
<div class="overlay"> <div class="overlay">
@ -132,6 +154,7 @@
on:keydown={() => removeChannel(_channels.id)}>delete</button on:keydown={() => removeChannel(_channels.id)}>delete</button
> >
<button on:click={() => inviteChannel(_channels.id)}>invite</button> <button on:click={() => inviteChannel(_channels.id)}>invite</button>
<button on:click={() => changePassword(_channels.id)}>Set - Change - Remove Password</button>
</li>{/each} </li>{/each}
{:else} {:else}
<p>No channels available</p> <p>No channels available</p>

42
front/volume/src/components/Chat.svelte

@ -34,7 +34,6 @@
messagesDiv.scrollTop = messagesDiv.scrollHeight; messagesDiv.scrollTop = messagesDiv.scrollHeight;
} }
} }
// TODO: save to database
}; };
//--------------------------------------------------------------------------------/ //--------------------------------------------------------------------------------/
@ -46,7 +45,6 @@
showProfileMenu = true; showProfileMenu = true;
selectedUser = username; selectedUser = username;
showChatMembers = false; showChatMembers = false;
showChannelSettings = false;
} }
function closeProfileMenu() { function closeProfileMenu() {
showProfileMenu = false; showProfileMenu = false;
@ -59,7 +57,6 @@
let showChatMembers = false; let showChatMembers = false;
function toggleChatMembers() { function toggleChatMembers() {
showChatMembers = !showChatMembers; showChatMembers = !showChatMembers;
showChannelSettings = false;
} }
let chatMembers: Array<User> = [ let chatMembers: Array<User> = [
{ username: "user1" }, { username: "user1" },
@ -83,14 +80,6 @@
//--------------------------------------------------------------------------------/ //--------------------------------------------------------------------------------/
let showChannelSettings = false;
function toggleChannelSettings() {
showChannelSettings = !showChannelSettings;
showChatMembers = false;
}
//--------------------------------------------------------------------------------/
const blockUser = async (username: string) => {}; const blockUser = async (username: string) => {};
//--------------------------------------------------------------------------------/ //--------------------------------------------------------------------------------/
@ -291,23 +280,6 @@
</div> </div>
</div> </div>
{/if} {/if}
<button
on:click|stopPropagation={toggleChannelSettings}
on:keydown|stopPropagation>Channel Settings</button
>
{#if showChannelSettings}
<div
class="channelSettings"
on:click|stopPropagation
on:keydown|stopPropagation
>
<div>
<button>Change Password</button>
<button>Set Password</button>
<button>Remove Password</button>
</div>
</div>
{/if}
</div> </div>
</div> </div>
@ -356,18 +328,4 @@
.chatMembers button { .chatMembers button {
width: 6rem; width: 6rem;
} }
.channelSettings {
position: absolute;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 5px;
padding: 1rem;
max-height: 100px;
overflow-y: scroll;
}
.channelSettings button {
width: 5rem;
}
</style> </style>

Loading…
Cancel
Save