Browse Source

* Added password option on Alert component

master
vvandenb 2 years ago
parent
commit
118855f19d
  1. 22
      front/volume/src/components/Alert/Alert.svelte
  2. 5
      front/volume/src/components/Alert/content.ts
  3. 4
      front/volume/src/components/Channels.svelte
  4. 2
      front/volume/src/components/Chat.svelte

22
front/volume/src/components/Alert/Alert.svelte

@ -1,6 +1,7 @@
<script lang="ts">
export let message;
export let form = true;
export let passwordInput = false;
export let onCancel = () => {};
export let onOkay = () => {};
import { content, popup } from "./content";
@ -31,12 +32,21 @@
<div>
<h2>{message}</h2>
{#if form === true}
<input
required
type="text"
bind:value
on:keydown={(e) => e.which === 13 && _onOkay()}
/>
{#if passwordInput === true}
<input
required
type="password"
bind:value
on:keydown={(e) => e.which === 13 && _onOkay()}
/>
{:else}
<input
required
type="text"
bind:value
on:keydown={(e) => e.which === 13 && _onOkay()}
/>
{/if}
{/if}
<div class="buttons">

5
front/volume/src/components/Alert/content.ts

@ -5,10 +5,11 @@ export const popup = writable(null)
import { bind } from 'svelte-simple-modal';
let val;
export async function show_popup(message, form = true) {
export async function show_popup(message, form = true, passwordInput = false) {
popup.set(bind(Alert__SvelteComponent_, {
message,
form
form,
passwordInput
}))
await waitForCondition()
}

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

@ -114,7 +114,7 @@
}
if (name) {
if (channelMode === 'protected'){
await show_popup("Enter a password for the new channel:")
await show_popup("Enter a password for the new channel:", true, true)
password = $content
if (password == "") {
await show_popup("Password is required #", false)
@ -201,7 +201,7 @@
//--------------------------------------------------------------------------------/
const changePassword = async (id: number) => {
await show_popup("Enter the new password for this channel (leave empty to remove password) :");
await show_popup("Enter the new password for this channel (leave empty to remove password) :", true, true);
let string = $content
const response = await fetch(API_URL + "/channels/" + id + "/password", {
credentials: "include",

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

@ -53,7 +53,7 @@
ChannelId: channel.id,
});
} else {
await show_popup("Channel is protected, enter password:");
await show_popup("Channel is protected, enter password:", true, true);
socket.emit("joinChannel", {
UserId: $store.ftId,
ChannelId: channel.id,

Loading…
Cancel
Save