This repository has been archived by the owner on Dec 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec555fd
commit cd358c0
Showing
9 changed files
with
225 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
<script> | ||
import { authHeader } from './../../stores.js'; | ||
import {authHeader} from "./../../stores.js"; | ||
import Modal from "../../Modal.svelte"; | ||
import * as modals from "../../modals.js"; | ||
import { chat } from "../../stores"; | ||
import { apiUrl } from "../../urls"; | ||
import {chat} from "../../stores"; | ||
import {apiUrl} from "../../urls"; | ||
export let modalData; | ||
let {username} = modalData; | ||
let reason = ""; | ||
let reason = ""; | ||
</script> | ||
|
||
<Modal on:close={modals.closeLastModal}> | ||
<h2 slot="header">Remove {username}</h2> | ||
|
||
<div slot="default"> | ||
Are you sure you want to ban {username} from this chat? | ||
<form on:submit|preventDefault={() => { | ||
fetch(`${apiUrl}chats/${$chat._id}/bans/${username}`, { | ||
method: "PUT", | ||
headers: { | ||
...$authHeader | ||
}, | ||
body: reason | ||
}) | ||
modals.closeLastModal(); | ||
}}> | ||
|
||
<label for="reason">Reason</label> | ||
<input type="text" id="reason" bind:value={reason}> | ||
|
||
<button type="submit">Ban</button> | ||
|
||
</form> | ||
</div> | ||
</Modal> | ||
<h2 slot="header">Remove {username}</h2> | ||
|
||
<div slot="default"> | ||
Are you sure you want to ban {username} from this chat? | ||
<form | ||
on:submit|preventDefault={() => { | ||
fetch(`${apiUrl}chats/${$chat._id}/bans/${username}`, { | ||
method: "PUT", | ||
headers: { | ||
...$authHeader, | ||
}, | ||
body: reason, | ||
}); | ||
modals.closeLastModal(); | ||
}} | ||
> | ||
<label for="reason">Reason</label> | ||
<input type="text" id="reason" bind:value={reason} /> | ||
|
||
<button type="submit">Ban</button> | ||
</form> | ||
</div> | ||
</Modal> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,81 @@ | ||
<script> | ||
import Member from './../../Member.svelte'; | ||
import { authHeader, chat } from './../../stores.js'; | ||
import { apiUrl } from './../../urls.js'; | ||
import Member from "./../../Member.svelte"; | ||
import {authHeader, chat} from "./../../stores.js"; | ||
import {apiUrl} from "./../../urls.js"; | ||
import Modal from "../../Modal.svelte"; | ||
import * as modals from "../../modals" | ||
import Spinner from '../../Spinner.svelte'; | ||
import Container from '../../Container.svelte'; | ||
async function fetchBannedMembers() { | ||
const resp = await fetch(`${apiUrl}chats/${$chat._id}/bans`, { | ||
headers: $authHeader | ||
}) | ||
if (!resp.ok) { | ||
if (resp.status === 429) { | ||
throw new Error("Too many requests! Try again later.") | ||
} | ||
throw new Error("Response code is not OK; code is " + resp.status) | ||
} | ||
$chat.banned_users = (await resp.json()).bans; | ||
} | ||
import * as modals from "../../modals"; | ||
import Spinner from "../../Spinner.svelte"; | ||
import Container from "../../Container.svelte"; | ||
async function fetchBannedMembers() { | ||
const resp = await fetch(`${apiUrl}chats/${$chat._id}/bans`, { | ||
headers: $authHeader, | ||
}); | ||
if (!resp.ok) { | ||
if (resp.status === 429) { | ||
throw new Error("Too many requests! Try again later."); | ||
} | ||
throw new Error("Response code is not OK; code is " + resp.status); | ||
} | ||
$chat.banned_users = (await resp.json()).bans; | ||
} | ||
</script> | ||
|
||
<Modal on:close={modals.closeLastModal}> | ||
<h2 slot="header">Banned Users</h2> | ||
<div slot="default"> | ||
{#await fetchBannedMembers()} | ||
<Spinner /> | ||
{:then _} | ||
|
||
|
||
{#each $chat.banned_users as member} | ||
|
||
<Container> | ||
<Member member={member.username} owner={false} /> | ||
<div class="inline"> | ||
<p> Reason: {member.message} </p> | ||
<h2 slot="header">Banned Users</h2> | ||
<div slot="default"> | ||
{#await fetchBannedMembers()} | ||
<Spinner /> | ||
{:then _} | ||
{#each $chat.banned_users as member} | ||
<Container> | ||
<Member member={member.username} owner={false} /> | ||
<div class="inline"> | ||
<p>Reason: {member.message}</p> | ||
|
||
<button class="delete" on:click={() => { | ||
fetch(`${apiUrl}chats/${$chat._id}/bans/${member.username}`, { | ||
method: "DELETE", | ||
headers: $authHeader | ||
}) | ||
modals.closeLastModal() | ||
}} >Unban</button> | ||
</div> | ||
</Container> | ||
{/each} | ||
{/await} | ||
</div> | ||
</Modal> | ||
<button | ||
class="delete" | ||
on:click={() => { | ||
fetch( | ||
`${apiUrl}chats/${$chat._id}/bans/${member.username}`, | ||
{ | ||
method: "DELETE", | ||
headers: $authHeader, | ||
} | ||
); | ||
modals.closeLastModal(); | ||
}}>Unban</button | ||
> | ||
</div> | ||
</Container> | ||
{/each} | ||
{/await} | ||
</div> | ||
</Modal> | ||
|
||
<style> | ||
p { | ||
display: flex; | ||
justify-content: center; | ||
text-align: center; | ||
} | ||
p { | ||
display: flex; | ||
justify-content: center; | ||
text-align: center; | ||
} | ||
.delete { | ||
justify-content: right; | ||
flex: right; | ||
height: 100%; | ||
} | ||
.delete { | ||
justify-content: right; | ||
flex: right; | ||
height: 100%; | ||
} | ||
.inline { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: left; | ||
vertical-align: middle; | ||
} | ||
.inline { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: left; | ||
vertical-align: middle; | ||
} | ||
.inline p { | ||
justify-self: center; | ||
align-self: center; | ||
} | ||
</style> | ||
.inline p { | ||
justify-self: center; | ||
align-self: center; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.