Little work on the user page

This commit is contained in:
Fabian Stamm 2020-06-09 14:24:57 +02:00
parent df017833a4
commit e4d08dcbf9
8 changed files with 375 additions and 328 deletions

View File

@ -18,20 +18,27 @@
<h2>About</h2>
<p>
OpenAuth is a Service to provide simple Authentication to a veriaty of Applications.
With a simple to use API and different Strategies, it can be easily integrated
into most Applications.
OpenAuth is a Service to provide simple Authentication to a veriaty of
Applications. With a simple to use API and different Strategies, it can be
easily integrated into most Applications.
</p>
<h2>QickLinks</h2>
<p>
If you want to manage your Account, click <a href="user.html">here</a>
If you want to manage your Account, click
<a href="user.html">here</a>
</p>
<h2>Applications using OpenAuth</h2>
<ul>
<li><a href="https://ebook.stamm.me">EBook Store and Reader</a></li>
<li><a href="https://notes.hibas123.de">Secure and Simple Notes application</a></li>
<li>
<a href="https://ebook.stamm.me">EBook Store and Reader</a>
</li>
<li>
<a href="https://notes.hibas123.de">
Secure and Simple Notes application
</a>
</li>
</ul>
</div>

View File

@ -1,21 +1,21 @@
<script>
import AccountPage from "./Pages/Account.svelte";
import SecurityPage from "./Pages/Security.svelte";
import {
slide,
fade
} from 'svelte/transition';
import { slide, fade } from "svelte/transition";
const pages = [{
const pages = [
{
id: "account",
title: "Account",
icon: "",
icon:
"data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9JzMwMHB4JyB3aWR0aD0nMzAwcHgnICBmaWxsPSIjMDAwMDAwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWxuczpza2V0Y2g9Imh0dHA6Ly93d3cuYm9oZW1pYW5jb2RpbmcuY29tL3NrZXRjaC9ucyIgdmlld0JveD0iMCAwIDUwMCA1MDAiIHZlcnNpb249IjEuMSIgeD0iMHB4IiB5PSIwcHgiPjx0aXRsZT4wMSBAZnVsbHdpZHRoPC90aXRsZT48ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGV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EwNS40YzIyLjEsMCw0MCwxNy45LDQwLDQwTDM0OS4yLDM1MS45ICAgTDM0OS4yLDM1MS45eiI+PC9wYXRoPjwvZz48L3N2Zz4=",
component: SecurityPage
}
];
@ -28,22 +28,19 @@
let page = getPage();
window.addEventListener("hashchange", () => {
page = getPage();
})
});
// $: title = pages.find(e => e.id === page).title;
const mq = window.matchMedia("(min-width: 45rem)");
let sidebar_button = !mq.matches;
mq.addEventListener("change", (ev) => {
mq.addEventListener("change", ev => {
sidebar_button = !ev.matches;
})
});
let sidebar_active = false;
function setPage(pageid) {
let pg = pages.find(e => e.id === pageid)
let pg = pages.find(e => e.id === pageid);
if (!pg) {
throw new Error("Invalid Page " + pageid);
} else {
@ -56,38 +53,10 @@
sidebar_active = false;
}
let loading = true;
import NavigationBar from "./NavigationBar.svelte";
</script>
<div class:loading class="root">
<div class="container">
<div class="header">
{#if sidebar_button}
<button on:click={()=>sidebar_active = !sidebar_active}>
<svg id="Layer_1" style="enable-background:new 0 0 32 32;" version="1.1" viewBox="0 0 32 32" width="32px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M4,10h24c1.104,0,2-0.896,2-2s-0.896-2-2-2H4C2.896,6,2,6.896,2,8S2.896,10,4,10z M28,14H4c-1.104,0-2,0.896-2,2 s0.896,2,2,2h24c1.104,0,2-0.896,2-2S29.104,14,28,14z M28,22H4c-1.104,0-2,0.896-2,2s0.896,2,2,2h24c1.104,0,2-0.896,2-2 S29.104,22,28,22z"/></svg>
</button>
{/if}
<h1>{page.title}</h1>
</div>
<div class="sidebar" class:sidebar-visible={sidebar_active}>
<NavigationBar open={setPage} pages={pages} />
</div>
<div class="content">
<svelte:component this={page.component} bind:loading />
</div>
<div class="footer"></div>
</div>
</div>
{#if loading}
<div class="loader_container">
<div class="loader_box">
<div class="loader"></div>
</div>
</div>
{/if}
<style>
.loading {
@ -111,7 +80,7 @@
grid-template-areas:
"sidebar header"
"sidebar mc"
"sidebar footer"
"sidebar footer";
}
.header {
@ -138,21 +107,21 @@
}
.header > button:hover {
background-color: rgba(255, 255, 255, 0.151)
background-color: rgba(255, 255, 255, 0.151);
}
.sidebar {
width: 0;
overflow: hidden;
grid-area: sidebar;
transition: width .2s;
transition: width 0.2s;
background-color: lightgrey;
height: 100%;
}
.sidebar-visible {
width: var(--sidebar-width);
transition: width .2s;
transition: width 0.2s;
box-shadow: 10px 0px 10px 2px rgba(0, 0, 0, 0.52);
}
@ -172,7 +141,7 @@
.sidebar {
width: var(--sidebar-width);
transition: all .2s;
transition: all 0.2s;
box-shadow: 10px 0px 10px 2px rgba(0, 0, 0, 0.52);
}
@ -193,3 +162,46 @@
z-index: 2;
}
</style>
<div class:loading class="root">
<div class="container">
<div class="header">
{#if sidebar_button}
<button on:click={() => (sidebar_active = !sidebar_active)}>
<svg
id="Layer_1"
style="enable-background:new 0 0 32 32;"
version="1.1"
viewBox="0 0 32 32"
width="32px"
xml:space="preserve"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<path
d="M4,10h24c1.104,0,2-0.896,2-2s-0.896-2-2-2H4C2.896,6,2,6.896,2,8S2.896,10,4,10z
M28,14H4c-1.104,0-2,0.896-2,2
s0.896,2,2,2h24c1.104,0,2-0.896,2-2S29.104,14,28,14z
M28,22H4c-1.104,0-2,0.896-2,2s0.896,2,2,2h24c1.104,0,2-0.896,2-2
S29.104,22,28,22z" />
</svg>
</button>
{/if}
<h1>{page.title}</h1>
</div>
<div class="sidebar" class:sidebar-visible={sidebar_active}>
<NavigationBar open={setPage} {pages} active={page} />
</div>
<div class="content">
<svelte:component this={page.component} bind:loading />
</div>
<div class="footer" />
</div>
</div>
{#if loading}
<div class="loader_container">
<div class="loader_box">
<div class="loader" />
</div>
</div>
{/if}

View File

@ -1,5 +1,6 @@
<script>
export let open;
export let active;
export let pages = [];
</script>
@ -17,6 +18,10 @@
/* justify-content: center; */
}
.active {
background: rgba(0, 0, 0, 0.1);
}
.icon {
/* float: left; */
width: calc(var(--rel-size) * 3);
@ -36,9 +41,11 @@
</style>
{#each pages as page}
<div class="container" on:click={() => open(page.id)}>
<div
class={'container' + (page === active ? ' active' : '')}
on:click={() => open(page.id)}>
<div class="icon">
<img src={page.icon} />
<img alt={page.title} src={page.icon} />
</div>
<h3 class="title">{page.title}</h3>
</div>

View File

@ -6,7 +6,8 @@
import request from "../../request.ts";
export let loading = false;
let error = undefined;
let account_error = undefined;
let contact_error = undefined;
const genderMap = new Map();
genderMap.set(0, "None");
@ -36,6 +37,7 @@
{},
"GET",
undefined,
true,
true
);
@ -47,14 +49,32 @@
: undefined;
} catch (err) {
console.error(err);
error = err.message;
account_error = err.message;
}
}
let email = ["mail@fabianstamm.de", "fabian.stamm.koe@gmail.com"];
let phone = ["+1 1233 123123123", "+21 1233 123 123 1"];
let email = [];
let phone = [];
async function loadContact() {}
async function loadContact() {
try {
let { contact } = await request(
"/api/user/contact",
{},
"GET",
undefined,
true,
true
);
email = contact.mails.map(e => e.mail);
phone = contact.phones.map(e => e.phone);
contact_error = undefined;
} catch (err) {
console.error(err);
contact_error = err.message;
}
}
async function load() {
loading = true;
@ -128,8 +148,8 @@
<Box>
<h1>Profile</h1>
{#if error}
<p class="error">{error}</p>
{#if account_error}
<p class="error">{account_error}</p>
{/if}
<BoxItem name="Name" value={name}>
<div class="input-container">
@ -160,6 +180,9 @@
<Box>
<h1>Contact</h1>
<BoxItem name="E-Mail" value={email} />
<BoxItem name="Phone" value={phone} />
{#if contact_error}
<p class="error">{contact_error}</p>
{/if}
<BoxItem name="E-Mail" value={email} noOpen={true} />
<BoxItem name="Phone" value={phone} noOpen={true} />
</Box>

View File

@ -1,16 +1,13 @@
<script>
import {
slide
} from 'svelte/transition';
import NextIcon from "./NextIcon.svelte"
import { slide } from "svelte/transition";
import NextIcon from "./NextIcon.svelte";
export let name = "";
export let value = "";
export let noOpen = false;
export let open = false;
export let highlight = false;
function toggleOpen(ev) {
}
function toggleOpen(ev) {}
</script>
<style>
@ -49,7 +46,7 @@
.body {
box-sizing: border-box;
padding: .1px;
padding: 0.1px;
margin-top: 2rem;
}
@ -71,7 +68,7 @@
</style>
<div class="root" class:highlight-element={highlight}>
<div class="container" on:click={()=>open=!open}>
<div class="container" on:click={() => (open = !open)}>
<div class="values">
<div>{name}</div>
<div>
@ -82,16 +79,16 @@
<br />
{/if}
{/each}
{:else}
{value}
{/if}
{:else}{value}{/if}
</div>
</div>
{#if !noOpen}
<NextIcon rotation={open ? -90 : 90} />
{/if}
</div>
{#if open}
{#if open && !noOpen}
<div class="body" transition:slide>
<slot></slot>
<slot />
</div>
{/if}
</div>

View File

@ -22,6 +22,7 @@
undefined,
"DELETE",
undefined,
true,
true
);
loadTwoFactor();
@ -33,6 +34,7 @@
undefined,
undefined,
undefined,
true,
true
);
twofactor = res.methods;
@ -46,6 +48,7 @@
undefined,
"DELETE",
undefined,
true,
true
);
loadToken();
@ -58,6 +61,7 @@
undefined,
undefined,
undefined,
true,
true
);
token = res.token;

View File

@ -1,5 +1,5 @@
:root {
--primary: #1E88E5;
--primary: #1e88e5;
--mdc-theme-primary: var(--primary);
--mdc-theme-primary-bg: var(--mdc-theme--primary);
--mdc-theme-on-primary: white;
@ -10,7 +10,7 @@
}
* {
font-family: 'Roboto', 'Helvetica', sans-serif;
font-family: "Roboto", "Helvetica", sans-serif;
}
html,
@ -67,8 +67,8 @@ body {
.floating > input:focus ~ label,
.floating > input.used ~ label {
top: -.75em;
transform: scale(.75);
top: -0.75em;
transform: scale(0.75);
left: -2px;
/* font-size: 14px; */
color: var(--primary);
@ -85,7 +85,7 @@ body {
.bar:before,
.bar:after {
content: '';
content: "";
height: 2px;
width: 0;
bottom: 1px;
@ -140,7 +140,6 @@ body {
}
}
.btn {
position: relative;
@ -153,12 +152,12 @@ body {
border-width: 0;
outline: none;
border-radius: 4px;
box-shadow: 0 1px 4px rgba(0, 0, 0, .6);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
background-color: #cccccc;
color: #ecf0f1;
transition: background-color .3s;
transition: background-color 0.3s;
height: 48px;
@ -194,7 +193,7 @@ body {
border-radius: 100%;
background-color: rgba(236, 240, 241, .3);
background-color: rgba(236, 240, 241, 0.3);
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
@ -207,7 +206,7 @@ body {
width: 120%;
padding-top: 120%;
transition: width .2s ease-out, padding-top .2s ease-out;
transition: width 0.2s ease-out, padding-top 0.2s ease-out;
}
.loader_box {
@ -243,3 +242,7 @@ body {
transform: rotate(360deg);
}
}
#content {
height: 100%;
}

View File

@ -2,12 +2,6 @@
"compilerOptions": {
"module": "commonjs",
"allowSyntheticDefaultImports": true
// "noImplicitAny": true,
// "removeComments": true,
// "preserveConstEnums": true,
// "sourceMap": true
},
"include": [
"build.ts"
]
"include": ["build.ts"]
}