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"> <script lang="ts">
export let message; export let message;
export let form = true; export let form = true;
export let passwordInput = false;
export let onCancel = () => {}; export let onCancel = () => {};
export let onOkay = () => {}; export let onOkay = () => {};
import { content, popup } from "./content"; import { content, popup } from "./content";
@ -31,12 +32,21 @@
<div> <div>
<h2>{message}</h2> <h2>{message}</h2>
{#if form === true} {#if form === true}
<input {#if passwordInput === true}
required <input
type="text" required
bind:value type="password"
on:keydown={(e) => e.which === 13 && _onOkay()} 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} {/if}
<div class="buttons"> <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'; import { bind } from 'svelte-simple-modal';
let val; 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_, { popup.set(bind(Alert__SvelteComponent_, {
message, message,
form form,
passwordInput
})) }))
await waitForCondition() await waitForCondition()
} }

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

@ -114,7 +114,7 @@
} }
if (name) { if (name) {
if (channelMode === 'protected'){ 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 password = $content
if (password == "") { if (password == "") {
await show_popup("Password is required #", false) await show_popup("Password is required #", false)
@ -201,7 +201,7 @@
//--------------------------------------------------------------------------------/ //--------------------------------------------------------------------------------/
const changePassword = async (id: number) => { 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 let string = $content
const response = await fetch(API_URL + "/channels/" + id + "/password", { const response = await fetch(API_URL + "/channels/" + id + "/password", {
credentials: "include", credentials: "include",

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

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

Loading…
Cancel
Save