Interim update
This commit is contained in:
20
Server/app/svelte/src/profile/profile-communes.svelte
Normal file
20
Server/app/svelte/src/profile/profile-communes.svelte
Normal file
@@ -0,0 +1,20 @@
|
||||
<svelte:options tag="profile-communes" />
|
||||
|
||||
<script>
|
||||
|
||||
// Import statements
|
||||
import { onMount } from 'svelte'
|
||||
import * as AuthTools from "/js/libraries/authTools.js"
|
||||
|
||||
// Main code
|
||||
|
||||
onMount(() => {
|
||||
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
265
Server/app/svelte/src/profile/profile-component.svelte
Normal file
265
Server/app/svelte/src/profile/profile-component.svelte
Normal file
@@ -0,0 +1,265 @@
|
||||
<svelte:options tag="profile-component" />
|
||||
|
||||
<script>
|
||||
|
||||
// Import libraries
|
||||
import { onMount, afterUpdate, setContext } from 'svelte'
|
||||
import * as AuthTools from "/js/libraries/authTools.js"
|
||||
import {svgFromObject} from "/js/libraries/miscTools.js"
|
||||
|
||||
//Import components
|
||||
import "/js/components/pane-aligner.js"
|
||||
import "/js/components/profile-general.js"
|
||||
import "/js/components/profile-groups.js"
|
||||
|
||||
// Main code
|
||||
AuthTools.redirectNotLogged()
|
||||
|
||||
let root
|
||||
let general
|
||||
let groups
|
||||
let communes
|
||||
let coops
|
||||
let parties
|
||||
let panes
|
||||
|
||||
let generalButton
|
||||
let groupsButton
|
||||
let communesButton
|
||||
let coopsButton
|
||||
let partiesButton
|
||||
let buttons
|
||||
|
||||
let locationPopup
|
||||
|
||||
let user = {}
|
||||
AuthTools.getUser(user)
|
||||
|
||||
function changePane(pane,button) {
|
||||
for (let p of panes) {
|
||||
p.style.display = "none"
|
||||
}
|
||||
for (let b of buttons) {
|
||||
styleField(b,400,"#636363")
|
||||
}
|
||||
pane.style.display = "initial"
|
||||
|
||||
styleField(button,500,"#c52a28")
|
||||
}
|
||||
|
||||
function styleField(div,weight,color) {
|
||||
div.style.fontWeight = weight
|
||||
let svgObject = div.querySelector("object")
|
||||
let svgItem = svgFromObject(svgObject)
|
||||
svgItem.setAttribute("fill", color)
|
||||
}
|
||||
|
||||
function fillFields() {
|
||||
if (Object.keys(user).length!=0 && root!=undefined) {
|
||||
for (let b of buttons) {
|
||||
styleField(b,400,"#636363")
|
||||
}
|
||||
styleField(generalButton,500,"#c52a28")
|
||||
}
|
||||
else {
|
||||
setTimeout(fillFields, 100)
|
||||
}
|
||||
}
|
||||
|
||||
function showLocationOverlay() {
|
||||
locationPopup.style.display = "block"
|
||||
}
|
||||
|
||||
setContext("profile-component",showLocationOverlay)
|
||||
|
||||
onMount(() => {
|
||||
general.user = user
|
||||
|
||||
panes = [general,groups,communes,coops,parties]
|
||||
buttons = [generalButton,groupsButton,communesButton,coopsButton,partiesButton]
|
||||
|
||||
fillFields()
|
||||
general.style.display = "initial"
|
||||
})
|
||||
</script>
|
||||
|
||||
<div bind:this={locationPopup} class="overlay" style="display: none">
|
||||
<div id="location-overlay-content">
|
||||
<p>wegwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww</p>
|
||||
</div>
|
||||
<button class="overlay-button" on:click={() => locationPopup.style.display = "none"}></button>
|
||||
</div>
|
||||
|
||||
<pane-aligner>
|
||||
<div id="left-column" class="pane" slot="sidebar-left" bind:this={root}>
|
||||
<button bind:this={generalButton} on:click={() => changePane(general,generalButton)}>
|
||||
<object id="general-img" class="icons" type="image/svg+xml" data="/img/profile/icons/general.svg" title="general"></object>
|
||||
<span>general</span>
|
||||
</button>
|
||||
<button bind:this={groupsButton} on:click={() => changePane(groups,groupsButton)}>
|
||||
<object id="groups-img" class="icons" type="image/svg+xml" data="/img/common/groups.svg" title="groups"></object>
|
||||
<span>groups</span>
|
||||
</button>
|
||||
<button bind:this={communesButton} on:click={() => changePane(communes,communesButton)}>
|
||||
<object id="communes-img" class="icons" type="image/svg+xml" data="/img/common/communes.svg" title="communes"></object>
|
||||
<span>communes</span>
|
||||
</button>
|
||||
<button bind:this={coopsButton} on:click={() => changePane(coops,coopsButton)}>
|
||||
<object id="coops-img" class="icons" type="image/svg+xml" data="/img/common/coops.svg" title="coops"></object>
|
||||
<span>cooperatives</span>
|
||||
</button>
|
||||
<button bind:this={partiesButton} on:click={() => changePane(parties,partiesButton)}>
|
||||
<object id="parties-img" class="icons" type="image/svg+xml" data="/img/common/parties.svg" title="parties"></object>
|
||||
<span>parties</span>
|
||||
</button>
|
||||
<button on:click={AuthTools.logout} id="logout-button">
|
||||
<object id="logout-img" class="icons" type="image/svg+xml" data="/img/profile/icons/logout.svg" title=""></object>
|
||||
<span>logout</span>
|
||||
</button>
|
||||
</div>
|
||||
<div id="main-column" slot="main">
|
||||
<profile-general bind:this={general} style="display: none;"></profile-general>
|
||||
<profile-groups bind:this={groups} style="display: none;"></profile-groups>
|
||||
<profile-communes bind:this={communes} style="display: none;"></profile-communes>
|
||||
<profile-coops bind:this={coops} style="display: none;"></profile-coops>
|
||||
<profile-parties bind:this={parties} style="display: none;"></profile-parties>
|
||||
</div>
|
||||
</pane-aligner>
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
@import '/css/common.css';
|
||||
|
||||
#location-overlay-content {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
height: 40rem;
|
||||
width: 40rem;
|
||||
background: white;
|
||||
z-index: 10000;
|
||||
}
|
||||
|
||||
.overlay {
|
||||
top: 0;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 10000;
|
||||
}
|
||||
|
||||
.overlay-button {
|
||||
position: absolute;
|
||||
background: gray;
|
||||
opacity: 0.5;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
#general-img {
|
||||
top: 0rem;
|
||||
}
|
||||
|
||||
#groups-img {
|
||||
top: 0.3rem;
|
||||
}
|
||||
|
||||
#coops-img {
|
||||
top: 0rem;
|
||||
}
|
||||
|
||||
#parties-img {
|
||||
top: 0rem;
|
||||
}
|
||||
|
||||
#logout-img {
|
||||
width: 1.5rem;
|
||||
}
|
||||
|
||||
#logout-button {
|
||||
padding-top: 1rem;
|
||||
padding-left: 0.1rem;
|
||||
}
|
||||
|
||||
#left-column {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 15.2rem;
|
||||
padding: 2rem;
|
||||
border-radius: 0.64rem 0.64rem 0.64rem 0.64rem;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
|
||||
.icons {
|
||||
position: relative;
|
||||
width: 1.8rem;
|
||||
}
|
||||
|
||||
#left-column button span {
|
||||
position: absolute;
|
||||
padding-left: 3.4rem;
|
||||
margin-top: 0rem;
|
||||
font-family: var(--sans-serif,sans-serif);
|
||||
}
|
||||
|
||||
#left-column button {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
#main-column {
|
||||
padding: 1rem 2rem 1rem 2rem;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
border-radius: 0 0.64rem 0.64rem 0;
|
||||
flex-grow: 1;
|
||||
flex-shrink: 1;
|
||||
min-height: 20rem;
|
||||
}
|
||||
|
||||
pane-aligner {
|
||||
--width-main: 800px;
|
||||
--width-left: 10.5rem;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1340px) {
|
||||
|
||||
|
||||
#left-column {
|
||||
position: relative;
|
||||
margin-left: 0rem;
|
||||
width: 100%;
|
||||
border-radius: 0.64rem 0.64rem 0rem 0;
|
||||
}
|
||||
|
||||
#main-column {
|
||||
border-radius: 0.64rem;
|
||||
padding: 3rem 0.5rem;
|
||||
padding-bottom: 1.5rem;
|
||||
border-radius: 0rem 0rem 0.64rem 0.64rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#logout-button {
|
||||
position: relative;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
#left-column button {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
width: 10rem;
|
||||
}
|
||||
|
||||
#logout-button {
|
||||
padding-top: 1rem;
|
||||
margin-bottom: 0rem;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
20
Server/app/svelte/src/profile/profile-coops.svelte
Normal file
20
Server/app/svelte/src/profile/profile-coops.svelte
Normal file
@@ -0,0 +1,20 @@
|
||||
<svelte:options tag="profile-coops" />
|
||||
|
||||
<script>
|
||||
|
||||
// Import statements
|
||||
import { onMount } from 'svelte'
|
||||
import * as AuthTools from "/js/libraries/authTools.js"
|
||||
|
||||
// Main code
|
||||
|
||||
onMount(() => {
|
||||
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
415
Server/app/svelte/src/profile/profile-general.svelte
Normal file
415
Server/app/svelte/src/profile/profile-general.svelte
Normal file
@@ -0,0 +1,415 @@
|
||||
<svelte:options tag="profile-general" />
|
||||
|
||||
<script>
|
||||
|
||||
// Import statements
|
||||
import { onMount, setContext } from 'svelte'
|
||||
import * as AuthTools from "/js/libraries/authTools.js"
|
||||
|
||||
//Import components
|
||||
import "/js/components/select-component.js"
|
||||
import "/js/components/switch-component.js"
|
||||
|
||||
//Export statements
|
||||
export let user = null
|
||||
|
||||
// Main code
|
||||
let emailInput
|
||||
|
||||
let section
|
||||
let saveEmailButton
|
||||
let changePasswordInputDiv
|
||||
let changePasswordMsg
|
||||
let savePasswordButton
|
||||
let passwordInput
|
||||
let changePasswordDiv
|
||||
let passwordVisibilityButton
|
||||
let emailMsg
|
||||
let passwordDiv
|
||||
let emailDiv
|
||||
let emailInputDiv
|
||||
let prevEmail
|
||||
|
||||
function showSaveButton(button) {
|
||||
prevEmail = emailInput.value
|
||||
button.style.display = "initial"
|
||||
emailMsg.style.display = "inline"
|
||||
let windowWidth = window.innerWidth
|
||||
if (windowWidth<1100) {
|
||||
emailInputDiv.style.marginTop = "1rem"
|
||||
emailDiv.style.flexDirection = "column"
|
||||
}
|
||||
else {
|
||||
//emailInput.style.width = "19rem"
|
||||
}
|
||||
}
|
||||
|
||||
function saveEmail() {
|
||||
let email = emailInput.value
|
||||
if (AuthTools.checkEmail(email,emailMsg)) {
|
||||
if (email!=user.email) {
|
||||
AuthTools.changeUser("email",email,user)
|
||||
}
|
||||
resetEmailField()
|
||||
}
|
||||
}
|
||||
|
||||
function resetEmailField() {
|
||||
if (prevEmail!=undefined) {
|
||||
emailInput.value = prevEmail
|
||||
}
|
||||
emailInput.style.width = "100%"
|
||||
emailMsg.style.display = "none"
|
||||
emailDiv.style.flexDirection = "row"
|
||||
emailInputDiv.style.marginTop = "0rem"
|
||||
saveEmailButton.style.display = "none"
|
||||
emailMsg.innerHTML = ""
|
||||
}
|
||||
|
||||
function launchChangePassword() {
|
||||
let windowWidth = window.innerWidth
|
||||
if (windowWidth<1100) {
|
||||
changePasswordInputDiv.style.display = "flex";
|
||||
}
|
||||
else {
|
||||
changePasswordInputDiv.style.display = "initial";
|
||||
}
|
||||
changePasswordDiv.style.display = "none";
|
||||
passwordInput.focus()
|
||||
}
|
||||
|
||||
function savePassword() {
|
||||
let password = passwordInput.value
|
||||
if (AuthTools.checkPassword(password,changePasswordMsg)) {
|
||||
if (password!=user.password) {
|
||||
AuthTools.changeUser("password",password,user)
|
||||
}
|
||||
changePasswordMsg.innerHTML = ""
|
||||
resetPasswordField()
|
||||
}
|
||||
}
|
||||
|
||||
function resetPasswordField() {
|
||||
changePasswordInputDiv.style.display = "none";
|
||||
changePasswordDiv.style.display = "initial";
|
||||
changePasswordMsg.innerHTML = ""
|
||||
}
|
||||
|
||||
function fillFields() {
|
||||
if (user!=null && Object.keys(user).length!=0 && section!=undefined) {
|
||||
emailInput.value = user.email
|
||||
}
|
||||
else {
|
||||
setTimeout(fillFields, 10)
|
||||
}
|
||||
}
|
||||
|
||||
function resizeInput(el) {
|
||||
el.nextElementSibling.innerHTML = el.value
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
|
||||
fillFields()
|
||||
|
||||
document.addEventListener("click", function(event) {
|
||||
if (passwordDiv.focused) {
|
||||
resetEmailField()
|
||||
}
|
||||
else if (emailDiv.focused) {
|
||||
resetPasswordField()
|
||||
}
|
||||
else {
|
||||
resetEmailField()
|
||||
resetPasswordField()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<section bind:this={section} id="general-section">
|
||||
<h2 class="title-highlight">General</h2>
|
||||
<div bind:this={emailDiv} on:mouseenter={emailDiv.focused=true} on:mouseleave={emailDiv.focused=false}>
|
||||
<div class="title-msg">
|
||||
<span>Email:</span>
|
||||
<span bind:this={emailMsg} id="signup-email-msg"></span>
|
||||
</div>
|
||||
<div bind:this={emailInputDiv} id="emailInputDiv">
|
||||
<button bind:this={saveEmailButton} id="save-email" class="save-button" on:click={saveEmail}>save</button>
|
||||
<div class="input-wrapper">
|
||||
<input bind:this={emailInput} id="emailInput" class="text-input" type="text" on:click={() => showSaveButton(saveEmailButton)} on:input={() => resizeInput(emailInput)}>
|
||||
<div class="ghost-input"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div bind:this={passwordDiv} on:mouseenter={passwordDiv.focused=true} on:mouseleave={passwordDiv.focused=false} id="change-password-line-wrapper">
|
||||
<div id="change-password-line">
|
||||
<div class="title-msg">
|
||||
<span>Password:</span>
|
||||
<span bind:this={changePasswordMsg} id="signup-password-msg"></span>
|
||||
</div>
|
||||
|
||||
<div bind:this={changePasswordDiv} id="change-password-div">
|
||||
<button id="change-password" on:click={launchChangePassword}>change
|
||||
<object type="image/svg+xml" data="/img/profile/icons/pencil.svg" title="pencil-icon"></object>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div bind:this={changePasswordInputDiv} id="change-password-input-div">
|
||||
<button bind:this={savePasswordButton} id="save-password" class="save-button" on:click={savePassword}>save</button>
|
||||
<input bind:this={passwordInput} id="passwordInput" class="text-input" type="password">
|
||||
<button bind:this={passwordVisibilityButton} class="eye-icon" on:click="{() => AuthTools.changePasswordVisibility(passwordVisibilityButton)}">
|
||||
<object type="image/svg+xml" data="/img/auth/eye_icon.svg" title="eye icon"></object>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<style>
|
||||
@import '/css/common.css';
|
||||
|
||||
/*---General section-----------------------------------------------------------*/
|
||||
|
||||
.ghost-input {
|
||||
display: block;
|
||||
visibility: hidden;
|
||||
height: 0;
|
||||
|
||||
padding-left: 0.5rem;
|
||||
padding-right: 0.5rem;
|
||||
}
|
||||
|
||||
.input-wrapper {
|
||||
display: inline-block;
|
||||
max-width: calc(100% - 10rem);
|
||||
min-width: 0rem;
|
||||
height: 2.5rem;
|
||||
position: relative;
|
||||
right: 0
|
||||
}
|
||||
|
||||
span {
|
||||
font-family: var(--sans-serif,sans-serif);
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
|
||||
#general-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
#general-section h2 {
|
||||
margin: auto;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#general-section >div {
|
||||
height: 3.5rem;
|
||||
padding-bottom: 0.75rem;
|
||||
padding-top: 0.75rem;
|
||||
border-bottom: 0.14rem solid;
|
||||
border-color: #cdcdcd;
|
||||
}
|
||||
|
||||
#general-section >div >:first-child {
|
||||
font-family: var(--sans-serif,sans-serif);
|
||||
}
|
||||
|
||||
/* add padding to every line to center the diving line*/
|
||||
#general-section >div:last-child {
|
||||
padding-bottom: 0.75rem;
|
||||
padding-top: 0.75rem;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
#general-section >div div,
|
||||
#general-section >div input,
|
||||
#general-section >div :not(:first-child) input {
|
||||
font-weight: 500;
|
||||
font-size: 1.15rem;
|
||||
font-family: var(--sans-serif,sans-serif);
|
||||
color: #292222;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
#general-section >div>:last-child {
|
||||
padding-right: 1.35rem;
|
||||
}
|
||||
|
||||
.text-input {
|
||||
position: relative;
|
||||
width: 20.475rem;
|
||||
direction: rtl;
|
||||
border: 0;
|
||||
outline: none;
|
||||
bottom: 0.341rem;
|
||||
}
|
||||
|
||||
|
||||
/*---Email-------------------------------------------------------------------*/
|
||||
|
||||
#emailInput {
|
||||
position: relative;
|
||||
right: 0;
|
||||
top: 0.1rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#save-email {
|
||||
display: none;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
#signup-email-msg,
|
||||
#signup-password-msg {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
color:red;
|
||||
font-weight: 400;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#signup-email-msg {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#general-section >div:nth-child(2) {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
#emailInputDiv {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: right;
|
||||
align-items: center;
|
||||
height: 2rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.title-msg {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.title-msg * {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/*---Change password-------------------------------------------------------------------*/
|
||||
|
||||
#change-password-line {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
#change-password-div {
|
||||
width: 9.3rem;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
#change-password {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
width: 8rem;
|
||||
height: 2.73rem;
|
||||
font-size: 1.15rem;
|
||||
font-family: var(--sans-serif,sans-serif);
|
||||
font-weight: 500;
|
||||
text-align: right;
|
||||
padding-right: 2rem;
|
||||
margin-top: -0.55rem;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
#change-password > object {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
width: 1.5rem;
|
||||
right: 0.0rem;
|
||||
}
|
||||
|
||||
#change-password-input-div {
|
||||
display: none;
|
||||
float: right;
|
||||
position: relative;
|
||||
margin-top: -1.7rem;
|
||||
}
|
||||
|
||||
#passwordInput {
|
||||
width: 15rem;
|
||||
right: 0.65rem;
|
||||
margin-left: 1.5rem;
|
||||
}
|
||||
|
||||
.save-button {
|
||||
position: relative;
|
||||
bottom: 0.34rem;
|
||||
margin-right: 0.6rem;
|
||||
height: 2.73rem;
|
||||
width: 4.778rem;
|
||||
font-family: var(--sans-serif,sans-serif);
|
||||
font-size: 1.15rem;
|
||||
color: white;
|
||||
background-color: var(--red);
|
||||
border-color: var(--red);
|
||||
border-radius: 0.512rem;
|
||||
}
|
||||
|
||||
#save-password {
|
||||
bottom: 0.6rem
|
||||
}
|
||||
|
||||
.eye-icon {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
opacity: 0.25;
|
||||
height: 2.2rem;
|
||||
width: 1.7rem;
|
||||
}
|
||||
|
||||
.eye-icon * {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
|
||||
@media only screen and (max-width: 1100px) {
|
||||
|
||||
#change-password-line-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: auto;
|
||||
min-height: 4rem;
|
||||
}
|
||||
|
||||
#change-password-input-div {
|
||||
margin-top: 1rem;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
#general-section >div:nth-child(2) {
|
||||
height: auto;
|
||||
min-height: 4rem;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#passwordInput {
|
||||
width: 100%;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
#emailInput {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#save-password {
|
||||
bottom: 0rem
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
300
Server/app/svelte/src/profile/profile-groups.svelte
Normal file
300
Server/app/svelte/src/profile/profile-groups.svelte
Normal file
@@ -0,0 +1,300 @@
|
||||
<svelte:options tag="profile-groups" />
|
||||
|
||||
<script>
|
||||
|
||||
// Import statements
|
||||
import { onMount, getContext } from 'svelte'
|
||||
import { writable } from 'svelte/store'
|
||||
import { getData } from "/js/libraries/serverTools.js"
|
||||
|
||||
//Import components
|
||||
import "/js/components/select-component.js"
|
||||
import "/js/components/switch-component.js"
|
||||
|
||||
//Export statements
|
||||
export let groups = null
|
||||
|
||||
// Main code
|
||||
let section
|
||||
let user_groups
|
||||
let content = writable({})
|
||||
let loaded = writable(0)
|
||||
|
||||
let membersInput
|
||||
let saveMembersButton
|
||||
let membersInputDiv
|
||||
|
||||
let contactInput
|
||||
let saveContactButton
|
||||
let contactInputDiv
|
||||
|
||||
let locale = "en"
|
||||
|
||||
let inputContact
|
||||
let inputMembers
|
||||
|
||||
function groups_callback(response) {
|
||||
user_groups = JSON.parse(response)
|
||||
inputContact = getContact(user_groups[0].contact)
|
||||
inputMembers = user_groups[0].members
|
||||
loaded.update((val) => {
|
||||
return val + 1
|
||||
})
|
||||
}
|
||||
getData("/xx/get_user_groups",groups_callback)
|
||||
|
||||
function getAddress(g) {
|
||||
let location = [g.country,g.state,g.town].filter(x => x!=null)
|
||||
return location.map(x => locale=="en" ? x : translate($content,x)).join(", ")
|
||||
}
|
||||
|
||||
function getContact(c) {
|
||||
if (c==null) {
|
||||
return "https://discord.gg/Qk8KUk787z"
|
||||
}
|
||||
else {
|
||||
return c
|
||||
}
|
||||
}
|
||||
|
||||
function launchChangeLocation() {
|
||||
showLocationOverlay()
|
||||
}
|
||||
|
||||
function launchChangeMembers() {
|
||||
|
||||
}
|
||||
|
||||
function showSaveButton(button) {
|
||||
button.style.display = "initial"
|
||||
}
|
||||
|
||||
function resetMembersField() {
|
||||
saveMembersButton.style.display = "none"
|
||||
}
|
||||
|
||||
function resetContactField() {
|
||||
saveContactButton.style.display = "none"
|
||||
}
|
||||
|
||||
function saveMembers() {
|
||||
let email = emailInput.value
|
||||
if (AuthTools.checkEmail(email,emailMsg)) {
|
||||
if (email!=user.email) {
|
||||
AuthTools.changeUser("email",email,user)
|
||||
}
|
||||
resetMembersField()
|
||||
}
|
||||
}
|
||||
|
||||
function saveContact() {}
|
||||
|
||||
let showLocationOverlay = getContext("profile-component")
|
||||
|
||||
onMount(() => {
|
||||
|
||||
document.addEventListener("click", function(event) {
|
||||
if (membersInputDiv.focused) {
|
||||
resetContactField()
|
||||
}
|
||||
else if (contactInputDiv.focused) {
|
||||
resetMembersField()
|
||||
}
|
||||
else {
|
||||
resetMembersField()
|
||||
resetContactField()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
{#key $loaded}
|
||||
{#if $loaded==1}
|
||||
|
||||
<h2>Groups</h2>
|
||||
<h3>My group</h3>
|
||||
<section bind:this={section} class="entries-section">
|
||||
<div>
|
||||
<div class="change-field-line">
|
||||
<span>Location:</span>
|
||||
<div class="change-field-div">
|
||||
<button class="change-field-button" on:click={launchChangeLocation}>{getAddress(user_groups[0])}
|
||||
<object type="image/svg+xml" data="/img/profile/icons/pencil.svg" title="pencil-icon" class="pencil"></object>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="change-field-line">
|
||||
<span>Members:</span>
|
||||
<div bind:this={membersInputDiv} class="change-field-div input-pencil">
|
||||
<button bind:this={saveMembersButton} class="save-button" on:click={saveMembers}>save</button>
|
||||
<input bind:this={membersInput} id="membersInput" class="text-input" type="text" bind:value={inputMembers} on:click={() => showSaveButton(saveMembersButton)}>
|
||||
<button class="text-input-pencil-button" on:click={() => membersInput.focus()}>
|
||||
<object type="image/svg+xml" data="/img/profile/icons/pencil.svg" title="pencil-icon" class="pencil"></object>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="change-field-line">
|
||||
<span>Contact:</span>
|
||||
<div bind:this={contactInputDiv} class="change-field-div input-pencil">
|
||||
<button bind:this={saveContactButton} class="save-button" on:click={saveContact}>save</button>
|
||||
<input bind:this={contactInput} id="contactInput" class="text-input" type="text" bind:value={inputContact} on:click={() => showSaveButton(saveContactButton)}>
|
||||
<button class="text-input-pencil-button" on:click={() => contactInput.focus()}>
|
||||
<object type="image/svg+xml" data="/img/profile/icons/pencil.svg" title="pencil-icon" class="pencil"></object>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<h3>Requests</h3>
|
||||
<section bind:this={section} class="entries-section">
|
||||
|
||||
</section>
|
||||
{/if}
|
||||
{/key}
|
||||
|
||||
|
||||
<style>
|
||||
@import '/css/common.css';
|
||||
|
||||
.text-input-pencil-button {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
height: 2.3rem;
|
||||
width: 2rem;
|
||||
}
|
||||
|
||||
.text-input-pencil-button object {
|
||||
top: 0rem;
|
||||
}
|
||||
|
||||
.pencil {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
width: 1.5rem;
|
||||
right: 0.0rem;
|
||||
}
|
||||
|
||||
.change-field-div input.text-input {
|
||||
position: relative;
|
||||
width: 20.475rem;
|
||||
direction: rtl;
|
||||
border: 0;
|
||||
outline: none;
|
||||
bottom: 0.341rem;
|
||||
position: relative;
|
||||
top: 0.1rem;
|
||||
font-style: var(--sans-serif,sans-serif)
|
||||
}
|
||||
|
||||
#membersInput {
|
||||
width: 5rem;
|
||||
}
|
||||
|
||||
#contactInput {
|
||||
max-width: 18rem;
|
||||
}
|
||||
|
||||
.save-button {
|
||||
position: relative;
|
||||
bottom: 0.34rem;
|
||||
margin-right: 0.6rem;
|
||||
height: 2.73rem;
|
||||
width: 4.778rem;
|
||||
font-family: var(--sans-serif,sans-serif);
|
||||
font-size: 1.15rem;
|
||||
color: white;
|
||||
background-color: var(--red);
|
||||
border-color: var(--red);
|
||||
border-radius: 0.512rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
text-align: center;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.entries-section {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.entries-section >div {
|
||||
height: 3.5rem;
|
||||
padding-bottom: 0.75rem;
|
||||
padding-top: 0.75rem;
|
||||
border-bottom: 0.14rem solid;
|
||||
border-color: #cdcdcd;
|
||||
}
|
||||
|
||||
/* add padding to every line to center the diving line*/
|
||||
.entries-section >div:last-child {
|
||||
padding-bottom: 0.75rem;
|
||||
padding-top: 0.75rem;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
/*---Change field-------------------------------------------------------------------*/
|
||||
|
||||
.change-field-line {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.change-field-div {
|
||||
width: max-content;
|
||||
}
|
||||
|
||||
.change-field-button {
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
height: 2.73rem;
|
||||
font-size: 1.15rem;
|
||||
font-family: var(--sans-serif,sans-serif);
|
||||
font-weight: 500;
|
||||
text-align: right;
|
||||
padding-right: 1.9rem;
|
||||
margin-top: -0.55rem;
|
||||
background-color: transparent;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
/*---General section-----------------------------------------------------------*/
|
||||
|
||||
h3 {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.entry-container {
|
||||
margin-top: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.entry {
|
||||
font-family: var(--sans-serif,sans-serif);
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
|
||||
span {
|
||||
font-family: var(--sans-serif,sans-serif);
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
|
||||
#groups-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
#groups-section h2 {
|
||||
margin: auto;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
</style>
|
20
Server/app/svelte/src/profile/profile-parties.svelte
Normal file
20
Server/app/svelte/src/profile/profile-parties.svelte
Normal file
@@ -0,0 +1,20 @@
|
||||
<svelte:options tag="profile-parties" />
|
||||
|
||||
<script>
|
||||
|
||||
// Import statements
|
||||
import { onMount } from 'svelte'
|
||||
import * as AuthTools from "/js/libraries/authTools.js"
|
||||
|
||||
// Main code
|
||||
|
||||
onMount(() => {
|
||||
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
Reference in New Issue
Block a user