witching to UIKit 3

This commit is contained in:
Fabian 2019-04-30 12:22:09 -04:00
parent 8b6c71247f
commit 595f2be1fb
26 changed files with 774 additions and 499 deletions

View File

@ -1,7 +1,7 @@
{ {
"secure_file_server": "http://192.168.178.129:3004/", "secure_file_server": "https://sf.dev.hibas123.de",
"auth_server": "https://auth.stamm.me", "auth_server": "https://auth.stamm.me",
"client_id": "cf699b12-2014-4a61-bb7d-a7e38b197350", "client_id": "cf699b12-2014-4a61-bb7d-a7e38b197350",
"permission": "5c1ed399dc361731340a49d4", "permission": "5c1ed399dc361731340a49d4",
"callback_url": "http://localhost:8080" "callback_url": "https://notes.dev.hibas123.de"
} }

666
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,41 +13,40 @@
"author": "Fabian Stamm <dev@fabianstamm.de>", "author": "Fabian Stamm <dev@fabianstamm.de>",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@hibas123/secure-file-wrapper": "^2.4.0", "@hibas123/secure-file-wrapper": "^2.5.0",
"@hibas123/utils": "^2.0.0", "@hibas123/utils": "^2.0.5",
"aes-js": "^3.1.2", "aes-js": "^3.1.2",
"crypto-js": "^3.1.9-1", "feather-icons": "^4.21.0",
"feather-icons": "^4.19.0", "idb": "3.0.2",
"idb": "^3.0.2",
"js-sha256": "^0.9.0", "js-sha256": "^0.9.0",
"js-sha512": "^0.8.0", "js-sha512": "^0.8.0",
"lodash.clonedeep": "^4.5.0", "lodash.clonedeep": "^4.5.0",
"mini.css": "^3.0.1",
"secure-file-wrapper": "git+https://git.stamm.me/OpenServer/OSSecureFileWrapper.git", "secure-file-wrapper": "git+https://git.stamm.me/OpenServer/OSSecureFileWrapper.git",
"uikit": "^3.0.3", "uikit": "^3.0.3",
"uuid": "^3.3.2" "uuid": "^3.3.2"
}, },
"devDependencies": { "devDependencies": {
"@types/lodash.clonedeep": "^4.5.6", "@types/lodash.clonedeep": "^4.5.6",
"@types/uikit": "^2.27.7",
"@types/uuid": "^3.4.4", "@types/uuid": "^3.4.4",
"copy-webpack-plugin": "^5.0.2", "copy-webpack-plugin": "^5.0.2",
"css-loader": "^2.1.1", "css-loader": "^2.1.1",
"file-loader": "^3.0.1", "file-loader": "^3.0.1",
"html-webpack-plugin": "^3.2.0", "html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "^0.5.0", "mini-css-extract-plugin": "^0.6.0",
"node-sass": "^4.10.0", "node-sass": "^4.10.0",
"preact": "^8.3.1", "preact": "^8.3.1",
"preact-svg-loader": "^0.2.1", "preact-svg-loader": "^0.2.1",
"sass-loader": "^7.1.0", "sass-loader": "^7.1.0",
"style-loader": "^0.23.1", "style-loader": "^0.23.1",
"ts-loader": "^5.3.0", "ts-loader": "^5.3.0",
"typescript": "^3.3.4000", "typescript": "^3.4.3",
"webpack": "^4.29.6", "webpack": "^4.30.0",
"webpack-bundle-analyzer": "^3.1.0", "webpack-bundle-analyzer": "^3.3.2",
"webpack-cli": "^3.3.0", "webpack-cli": "^3.3.0",
"webpack-dev-server": "^3.2.1", "webpack-dev-server": "^3.3.1",
"webpack-visualizer-plugin": "^0.1.11", "webpack-visualizer-plugin": "^0.1.11",
"workbox-webpack-plugin": "^4.1.1", "workbox-webpack-plugin": "^4.3.0",
"worker-loader": "^2.0.0" "worker-loader": "^2.0.0"
} }
} }

View File

@ -2,5 +2,11 @@ import { h } from "preact";
import "./add_button.scss"; import "./add_button.scss";
import Plus from "feather-icons/dist/icons/plus.svg"; import Plus from "feather-icons/dist/icons/plus.svg";
export default function AddButton({ onClick }: { onClick: () => void }) { export default function AddButton({ onClick }: { onClick: () => void }) {
return <button title={"add button"} class="add_button_button circular primary shadowed" onClick={() => onClick()}><Plus width={undefined} height={undefined} /></button> return <button
title={"add button"}
class="add-button-button uk-button-primary uk-border-circle def-shadow"
onClick={() => onClick()}
>
<Plus width={undefined} height={undefined} />
</button>
} }

View File

@ -56,7 +56,7 @@ export class Footer extends Component<{}, { synced: boolean, syncing: boolean }>
text = "not synced"; text = "not synced";
} }
} }
return <footer> return <footer class="uk-background-default def-shadow">
<span> <span>
<span class={extrac} ><a onClick={() => this.onSyncClick()} ><Refresh style="height: 1em; width: 1em;"></Refresh></a></span> <span class={extrac} ><a onClick={() => this.onSyncClick()} ><Refresh style="height: 1em; width: 1em;"></Refresh></a></span>
<span style={"margin-left: 8px; color:" + color}>{text}</span> <span style={"margin-left: 8px; color:" + color}>{text}</span>

View File

@ -26,7 +26,7 @@ export class Router extends Component<{}, { next?: JSX.Element, current: JSX.Ele
render() { render() {
let overlay; let overlay;
if (this.state.next) { if (this.state.next) {
overlay = <div class="transition_container transition_slidein" key={this.state.next.key} ref={(elm: HTMLDivElement) => { overlay = <div class="transition_container transition_slidein uk-background-default" key={this.state.next.key} ref={(elm: HTMLDivElement) => {
let lst = () => { let lst = () => {
if (this.state.next) if (this.state.next)
this.setState({ current: this.state.next, next: undefined }, () => { this.setState({ current: this.state.next, next: undefined }, () => {
@ -43,7 +43,7 @@ export class Router extends Component<{}, { next?: JSX.Element, current: JSX.Ele
</div> </div>
} }
return <div style="position: relative; overflow-x: hidden; width: 100vw; height: 100vh;"> return <div style="position: relative; overflow-x: hidden; width: 100vw; height: 100vh;">
<div class="transition_container" key={this.state.current.key} ref={elm => this.mounted = elm}> <div class="transition_container uk-background-default" key={this.state.current.key} ref={elm => this.mounted = elm}>
{this.state.current} {this.state.current}
</div> </div>
{overlay} {overlay}

View File

@ -1,15 +1,14 @@
// .add_button_container {} .add-button-button {
.add_button_button {
position: fixed; position: fixed;
bottom: 2rem; bottom: 2.5rem;
right: 2rem; right: 1rem;
width: 4rem; width: 4rem;
height: 4rem; height: 4rem;
padding: 0.75rem; padding: 0.75rem;
z-index: 16; z-index: 16;
}
.add_button_button>svg { >svg {
height: 2.5rem; height: 2.5rem;
width: 2.5rem; width: 2.5rem;
}
} }

View File

@ -0,0 +1,18 @@
@import "../vars.scss";
.context-menu {
position: fixed;
z-index: 10;
display: flex;
flex-direction: column;
border: 1px $border_color solid;
> button {
margin: 0;
display: block;
}
> *:not(:last-child) {
border-bottom: 1px $border_color solid;
}
}

View File

@ -2,7 +2,7 @@ import { h } from "preact";
import "./context.scss"; import "./context.scss";
export default function ContextMenu({ children, event }: { children: JSX.Element | JSX.Element[], event: MouseEvent }) { export default function ContextMenu({ children, event }: { children: JSX.Element | JSX.Element[], event: MouseEvent }) {
return <div style={{ position: "fixed", left: event.pageX, top: event.pageY, zIndex: 10 }} class="context_menu"> return <div style={{ left: event.pageX, top: event.pageY }} class="context-menu">
{children} {children}
</div> </div>
} }

View File

@ -1,3 +1,5 @@
@import "../vars.scss";
.reloading { animation: turner 1s infinite linear } .reloading { animation: turner 1s infinite linear }
@keyframes turner{ @keyframes turner{
@ -14,6 +16,8 @@ footer {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
// border-top: 1px solid $border-color;
padding: calc(0.9 * var(--universal-padding)) !important; padding: 0.15em !important;
} }

View File

@ -16,6 +16,10 @@ export class InputModal extends Modal<string> {
this.rand = Math.random().toString(); this.rand = Math.random().toString();
} }
componentDidMount() {
this.input.focus();
}
componentWillUnmount() { componentWillUnmount() {
if (this.input) if (this.input)
this.input.value = ""; this.input.value = "";
@ -23,23 +27,36 @@ export class InputModal extends Modal<string> {
render() { render() {
return <Modal.BaseModal modal={this.props.modal}> return <Modal.BaseModal modal={this.props.modal}>
<fieldset style="border:none; min-inline-size:0;"> <div class="uk-form-horizontal uk-margin-large">
<label for={this.rand}>{this.props.modal.fieldname}</label> <div class="uk-margin">
<input style="min-width: 85%" autofocus ref={elm => { <label class="uk-form-label" for={this.rand}>{this.props.modal.fieldname}</label>
this.input = elm <div class="uk-form-controls">
if (this.input) <input
setTimeout(() => this.input.focus(), 0) class="uk-input"
}} type={this.props.modal.type} id={this.rand} placeholder={this.props.modal.fieldname} onKeyDown={evt => { id={this.rand}
if (evt.keyCode === 13) { type={this.props.modal.type}
this.props.modal.result(this.input.value) placeholder={this.props.modal.fieldname}
} autofocus
}} /> ref={elm => { this.input = elm; }}
<div style="text-align: right;"> onKeyDown={evt => {
<button class="primary" style="display: inline-block;" onClick={() => { if (evt.keyCode === 13) {
this.props.modal.result(this.input.value)
}
}}
/>
</div>
</div>
<div class="uk-margin" style="text-align: right;">
<button class="uk-button uk-button-primary" style="display: inline-block;" onClick={() => {
this.props.modal.result(this.input.value); this.props.modal.result(this.input.value);
}}>Enter</button> }}>Enter</button>
</div> </div>
</fieldset> </div>
{/*
<fieldset style="border:none; min-inline-size:0;">
</fieldset> */}
</Modal.BaseModal> </Modal.BaseModal>
} }
} }

View File

@ -11,7 +11,11 @@ export default class LoadingModal extends Modal<undefined> {
getComponent() { getComponent() {
return <Modal.BaseModal modal={this}> return <Modal.BaseModal modal={this}>
<div class="spinner primary" style="height: 80px; width: 80px; margin: 3rem auto;"></div> <div style="display: flex; justify-content: center;">
<div style="margin: 3rem;" class="uk-spinner uk-icon">
<svg width="90" height="90" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg" data-svg="spinner"><circle fill="none" stroke="#000" cx="15" cy="15" r="14" style="stroke-width: 0.333333px;"></circle></svg>
</div>
</div>
</Modal.BaseModal> </Modal.BaseModal>
} }
} }

View File

@ -13,6 +13,7 @@ export default abstract class Modal<T> {
// Private // Private
private onResult: (result: T | null) => void; private onResult: (result: T | null) => void;
private closeOnResult: boolean; private closeOnResult: boolean;
private noClose: boolean = false;
// Protected // Protected
protected result(value: T | null) { protected result(value: T | null) {
@ -25,9 +26,10 @@ export default abstract class Modal<T> {
//Public //Public
/** /**
* This function shows the modal * This function shows the modal
* Do not cell when using getResult() * Do not call when using getResult()
*/ */
public async show() { public show(noClose = true) {
this.noClose = noClose;
Modal.modalObservableServer.send({ modal: this, close: false }); Modal.modalObservableServer.send({ modal: this, close: false });
} }
@ -38,7 +40,7 @@ export default abstract class Modal<T> {
*/ */
public async getResult(close = true) { public async getResult(close = true) {
this.closeOnResult = close; this.closeOnResult = close;
this.show(); this.show(false);
return new Promise<T | null>((yes) => this.onResult = yes); return new Promise<T | null>((yes) => this.onResult = yes);
} }
@ -50,17 +52,11 @@ export default abstract class Modal<T> {
public static BaseModal = class BaseModal<T> extends Component<{ modal: Modal<T> }, {}> { public static BaseModal = class BaseModal<T> extends Component<{ modal: Modal<T> }, {}> {
render() { render() {
return <div class="modal_container" onClick={(evt) => { return <div class="modal-container" onClick={(evt) => {
let path = evt.composedPath(); let path = evt.composedPath();
if (!path.find(e => { if (!path.find(e => {
let res = false;
let s = (e as Element); let s = (e as Element);
if (s) { return s.id === "ModalContent";
if (s.classList) {
res = s.classList.contains("card")
}
}
return res;
})) { })) {
this.props.modal.result(null) this.props.modal.result(null)
} }
@ -69,12 +65,15 @@ export default abstract class Modal<T> {
this.props.modal.result(null) this.props.modal.result(null)
} }
}}> }}>
<div class="card" > <div id="ModalContent" class="uk-card uk-card-body uk-card-body" >
<div class="section" style="display:flex;justify-content:space-between;"> <div class="modal-title uk-card-title" style="">
<h3>{this.props.modal.title}</h3> <h3>{this.props.modal.title}</h3>
<h3> {/* <div> */}
<CloseIcon onClick={() => this.props.modal.result(null)} width={undefined} height={undefined} style="height:calc(1rem * var(--heading-ratio) * var(--heading-ratio))" /> {!this.props.modal.noClose ?
</h3> <CloseIcon onClick={() => this.props.modal.result(null)} width={undefined} height={undefined} />
: undefined
}
{/* </div> */}
</div> </div>
{this.props.children} {this.props.children}
</div> </div>

View File

@ -28,16 +28,16 @@ export class YesNoModal extends Modal<boolean> {
render() { render() {
return <Modal.BaseModal modal={this.props.modal}> return <Modal.BaseModal modal={this.props.modal}>
<fieldset style="border:none;min-inline-size:0;"> <div class="uk-margin-large">
<div style="text-align: right;"> <div style="text-align: right;">
<button class="primary" style="display: inline-block;" onClick={() => { <button class="uk-button uk-button-primary uk-margin-right" style="display: inline-block;" onClick={() => {
this.props.modal.result(false); this.props.modal.result(false);
}}>No</button> }}>No</button>
<button class="primary" style="display: inline-block;" onClick={() => { <button class="uk-button uk-button-primary" style="display: inline-block;" onClick={() => {
this.props.modal.result(true); this.props.modal.result(true);
}}>Yes</button> }}>Yes</button>
</div> </div>
</fieldset> </div>
</Modal.BaseModal> </Modal.BaseModal>
} }
} }

View File

@ -1,6 +0,0 @@
.context_menu {
button {
margin: 0;
display: block;
}
}

View File

@ -1,4 +1,4 @@
.modal_container { .modal-container {
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
@ -8,7 +8,7 @@
z-index: 32; z-index: 32;
} }
.modal_container>.card { .modal-container>.uk-card {
position: absolute; position: absolute;
left: 0; left: 0;
right: 0; right: 0;
@ -16,4 +16,13 @@
width: 80%; width: 80%;
max-width: 800px; max-width: 800px;
margin: auto; margin: auto;
background: white;
}
.modal-title {
display:flex;
justify-content:space-between;
>svg {
height: 1em;
}
} }

View File

@ -22,7 +22,7 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
skip_save: boolean = false; skip_save: boolean = false;
loading?: LoadingModal; // loading?: LoadingModal;
constructor(props) { constructor(props) {
super(props); super(props);
@ -38,8 +38,8 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
async componentWillMount() { async componentWillMount() {
try { try {
this.skip_save = false; this.skip_save = false;
this.loading = new LoadingModal(); // this.loading = new LoadingModal();
this.loading.show(); // this.loading.show();
this.vault = await this.props.vault; this.vault = await this.props.vault;
let note: ViewNote; let note: ViewNote;
@ -66,8 +66,8 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
} }
let [title] = this.text.split("\n", 1); let [title] = this.text.split("\n", 1);
this.setState({ title, changed }) this.setState({ title, changed })
if (this.loading) // if (this.loading)
this.loading.close(); // this.loading.close();
} }
} catch (err) { } catch (err) {
Notifications.sendError(err); Notifications.sendError(err);
@ -164,23 +164,28 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
} }
return <div> return <div>
<header> <header class="uk-background-primary">
<div> {/* <div> */}
<a class="button header_icon_button" onClick={() => this.exitHandler()}><X height={undefined} width={undefined} /></a> <a class="header-icon-button" onClick={() => this.exitHandler()}><X height={undefined} width={undefined} /></a>
{this.state.changed ? <a class="button header_icon_button" onClick={() => save_handler()}><Save height={undefined} width={undefined} /></a> : undefined} {this.state.changed ? <a class="header-icon-button" style="margin-left: 0.5em;" onClick={() => save_handler()}><Save height={undefined} width={undefined} /></a> : undefined}
</div> {/* </div> */}
<h1 style="display:inline" class="button header_title">{this.state.title}</h1> <h3 style="display:inline" class="button header-title">{this.state.title}</h3>
<a class="button header_icon_button" onClick={() => delete_handler()}><Trash height={undefined} width={undefined} /></a> <a class="header-icon-button" onClick={() => delete_handler()}><Trash height={undefined} width={undefined} /></a>
</header> </header>
<div class="container"> <div class="uk-container">
<div class="row"> <textarea
<div class="col-sm-12 col-md-8 col-lg-6 col-md-offset-2 col-lg-offset-3"> autofocus
<textarea autofocus value={this.text} rows={this.rows} class="doc" style="width:100%;" onKeyDown={evt => this.textAreaKeyPress(evt)} onKeyUp={evt => this.textAreaChange(evt)} ref={elm => { value={this.text}
if (elm) rows={this.rows}
setTimeout(() => elm.focus(), 0) class="doc uk-textarea"
}} /> style="width:100%;"
</div> onKeyDown={evt => this.textAreaKeyPress(evt)}
</div> onKeyUp={evt => this.textAreaChange(evt)}
ref={elm => {
if (elm)
setTimeout(() => elm.focus(), 500)
}}
/>
</div> </div>
</div> </div>
} }

View File

@ -3,23 +3,34 @@ import Notes, { IVault, BaseNote } from "../../../notes";
import AddButton from "../../AddButton"; import AddButton from "../../AddButton";
import Navigation from "../../../navigation"; import Navigation from "../../../navigation";
import ArrowLeft from "feather-icons/dist/icons/arrow-left.svg" import ArrowLeft from "feather-icons/dist/icons/arrow-left.svg"
import ContextMenu from "../../modals/context"; import Search from "feather-icons/dist/icons/search.svg"
import ContextMenu from "../../context";
import Notifications from "../../../notifications"; import Notifications from "../../../notifications";
import { Observable, Lock } from "@hibas123/utils";
export default class EntryList extends Component<{ vault: Promise<IVault> }, { notes: BaseNote[], context: JSX.Element | undefined }> { export default class EntryList extends Component<{ vault: Promise<IVault> }, { notes: BaseNote[], context: JSX.Element | undefined }> {
rawNotes: BaseNote[];
private searchObservableServer = new Observable<void>(1000);
private searchObservable = this.searchObservableServer.getPublicApi();
constructor(props) { constructor(props) {
super(props) super(props)
console.log("Creating new Instance of EntryList")
this.state = { notes: [], context: undefined } this.state = { notes: [], context: undefined }
this.onDragOver = this.onDragOver.bind(this); this.onDragOver = this.onDragOver.bind(this);
this.onDrop = this.onDrop.bind(this); this.onDrop = this.onDrop.bind(this);
this.reloadNotes = this.reloadNotes.bind(this); this.reloadNotes = this.reloadNotes.bind(this);
this.searchChanged = this.searchChanged.bind(this);
} }
vault: IVault; vault: IVault;
reloadNotes(s?: boolean) { async reloadNotes(s?: boolean) {
if (s) if (s)
return; return;
return new Promise(yes => this.vault.getAllNotes().then(entries => this.setState({ notes: entries }, yes))); this.rawNotes = await this.vault.getAllNotes();
await this.applySearch(true);
} }
async componentWillMount() { async componentWillMount() {
@ -28,6 +39,7 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
document.body.addEventListener("dragover", this.onDragOver); document.body.addEventListener("dragover", this.onDragOver);
document.body.addEventListener("drop", this.onDrop); document.body.addEventListener("drop", this.onDrop);
Notes.syncObservable.subscribe(this.reloadNotes); Notes.syncObservable.subscribe(this.reloadNotes);
this.searchObservable.subscribeCollect(() => this.applySearch());
} }
componentWillUnmount() { componentWillUnmount() {
@ -36,6 +48,11 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
Notes.syncObservable.unsubscribe(this.reloadNotes); Notes.syncObservable.unsubscribe(this.reloadNotes);
} }
componentDidMount() {
console.log("ON Component Did mount", this.search);
this.searchInput.value = this.search;
}
onDragOver(evt: DragEvent) { onDragOver(evt: DragEvent) {
evt.preventDefault(); evt.preventDefault();
} }
@ -60,7 +77,7 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
let share; let share;
if ((window.navigator as any).share) { if ((window.navigator as any).share) {
share = <button onClick={() => shareNote()}> share = <button class="uk-button" onClick={() => shareNote()}>
share share
</button> </button>
let context = <ContextMenu event={evt} > let context = <ContextMenu event={evt} >
@ -140,6 +157,74 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
} }
} }
searchLock = new Lock();
oldSearch = "";
async applySearch(force = false) {
const search = this.search.toLowerCase();
if (!force && search === this.oldSearch) {
return;
}
if (this.searchLock.locked)
return;
const lock = await this.searchLock.getLock();
console.time("SearchOP");
let notes: BaseNote[] = [];
if (search === "") {
notes = this.rawNotes;
} else {
const parts = search.split(" ");
const match = (note: BaseNote) => {
return parts.every(function (el) {
return note.preview.toLowerCase().indexOf(el) > -1;
});
}
let elements: BaseNote[];
if (!force && this.oldSearch && search.startsWith(this.oldSearch)) {
elements = [...this.state.notes];
} else {
elements = [...this.rawNotes];
}
await new Promise(yes => {
const idle = () => {
window.requestIdleCallback(deadline => {
let invTR = deadline.timeRemaining() <= 0;
while ((deadline.timeRemaining() > 0 || invTR) && elements.length > 0) {
let element = elements.shift();
if (match(element)) {
notes.push(element);
}
}
if (elements.length > 0)
idle();
else
yes();
}, { timeout: 100 });
}
idle();
})
// notes = elements.filter(note => match(note));
}
await new Promise(yes => this.setState({ notes }, yes));
this.oldSearch = search;
lock.release();
console.timeEnd("SearchOP");
}
search = "";
searchChanged(evt: Event) {
let input = evt.target as HTMLInputElement;
this.search = input.value;
this.searchObservableServer.send();
}
searchInput: HTMLInputElement;
render() { render() {
const open_entry = (id: string | null) => { const open_entry = (id: string | null) => {
Navigation.setPage("/vault", { id: this.vault.id }, { id, entry: "true" }) Navigation.setPage("/vault", { id: this.vault.id }, { id, entry: "true" })
@ -147,36 +232,37 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
let elms = this.state.notes.map(note => { let elms = this.state.notes.map(note => {
let [first, second] = note.preview.split("\n", 2); let [first, second] = note.preview.split("\n", 2);
return <div class="vault_vault" onContextMenu={evt => this.onContext(evt, note)} onClick={() => { return <li class="vault-vault" onContextMenu={evt => this.onContext(evt, note)} onClick={() => {
open_entry(note._id) open_entry(note._id)
}}> }}>
<span>{first}</span><br /> <div>{first}</div>
<span>{second}</span> <div>{second}</div>
</div> </li>
}) })
return <div> return <div>
{this.state.context} {this.state.context}
<header> <header class="uk-background-primary">
<div> {/* <div> */}
<a class="button header_icon_button" onClick={() => history.back()}><ArrowLeft height={undefined} width={undefined} /></a> <a class="header-icon-button" onClick={() => history.back()}><ArrowLeft height={undefined} width={undefined} /></a>
</div> {/* </div> */}
<h1 style="display:inline" class="button header_title" onClick={() => Navigation.setPage("/")}>{this.vault ? this.vault.name : ""}</h1> <h3 style="display:inline" class="header-title" onClick={() => Navigation.setPage("/")}>{this.vault ? this.vault.name : ""}</h3>
<span></span> <span></span>
{/* <a class="button header_icon_button"><MoreVertival height={undefined} width={undefined} /></a> */} {/* <a class="button header_icon_button"><MoreVertival height={undefined} width={undefined} /></a> */}
</header> </header>
<AddButton onClick={() => open_entry(null)} /> <AddButton onClick={() => open_entry(null)} />
<div class="container"> <div class="uk-container">
<div class="row"> <div style="display:flex;">
<div class="col-sm-12 col-md-8 col-lg-6 col-md-offset-2 col-lg-offset-3"> <input class="uk-input" type="text" onKeyUp={this.searchChanged} ref={elm => this.searchInput = elm} />
<div class="card fluid"> <button class="uk-button" style="padding: 0 10px;">
<div class="section"> <Search />
{elms} </button>
</div>
</div>
</div>
</div> </div>
<ul class="uk-list uk-list-divider">
{elms}
</ul>
</div> </div>
</div> </div>;
} }
} }

View File

@ -1,27 +1,43 @@
.vault_vault>span:nth-of-type(1) {
font-size: 1.3rem;
margin-left: 0; .vault-vault {
width: 100%;
>div {
width: 100%;
font-size: 1rem;
margin-left: 1rem;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
>div:nth-of-type(1) {
font-size: 1.3rem;
margin-left: 0;
}
>div:empty {
&::before{
content: " ";
white-space: pre;
}
}
} }
.vault_vault>span { // .vault_vault {
font-size: 1rem; // padding: 0.5rem;
margin-left: 1rem; // border-bottom: solid 1px var(--card-border-color);
} // }
.vault_vault { // .vault_vault:hover {
padding: 0.5rem; // background: var(--nav-hover-back-color);
border-bottom: solid 1px var(--card-border-color); // }
}
.vault_vault:hover { // .vault_vault>svg {
background: var(--nav-hover-back-color); // height: 2rem;
} // margin-right: 1rem;
// }
.vault_vault>svg { // .vault_vault:last-child {
height: 2rem; // border-bottom: none;
margin-right: 1rem; // }
}
.vault_vault:last-child {
border-bottom: none;
}

View File

@ -8,7 +8,7 @@ import Navigation from "../../../navigation";
import { InputModal } from "../../modals/InputModal"; import { InputModal } from "../../modals/InputModal";
import { YesNoModal } from "../../modals/YesNoModal"; import { YesNoModal } from "../../modals/YesNoModal";
import AddButton from "../../AddButton"; import AddButton from "../../AddButton";
import ContextMenu from "../../modals/context"; import ContextMenu from "../../context";
import Notifications from "../../../notifications"; import Notifications from "../../../notifications";
export interface VaultsProps { export interface VaultsProps {
@ -134,7 +134,7 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
} }
window.addEventListener("click", close); window.addEventListener("click", close);
let deleteb = <button onClick={async () => { let deleteb = <button class="uk-button" onClick={async () => {
let delete_modal = new YesNoModal("Delete Vault? Cannot be undone!"); let delete_modal = new YesNoModal("Delete Vault? Cannot be undone!");
let result = await delete_modal.getResult(); let result = await delete_modal.getResult();
if (result) { if (result) {
@ -151,7 +151,7 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
let delete_key; let delete_key;
if (Notes.getVaultKey(vault.id)) { if (Notes.getVaultKey(vault.id)) {
delete_key = <button onClick={() => { delete_key = <button class="uk-button" onClick={() => {
Notes.forgetVaultKey(vault.id); Notes.forgetVaultKey(vault.id);
Notifications.sendSuccess("Forgot key!") Notifications.sendSuccess("Forgot key!")
}}> }}>
@ -159,7 +159,7 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
</button>; </button>;
} }
let exportb = <button onClick={async () => { let exportb = <button class="uk-button" onClick={async () => {
let key: Uint8Array; let key: Uint8Array;
if (vault.encrypted) { if (vault.encrypted) {
await this.getKey(vault, false) await this.getKey(vault, false)
@ -205,33 +205,27 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
render() { render() {
let elms = this.state.vaults.map(vault => { let elms = this.state.vaults.map(vault => {
return <div class="vaults_vault" onClick={() => this.openVault(vault)} onContextMenu={(evt) => this.onContext(evt, vault)}> return <li class="vaults_vault" onClick={() => this.openVault(vault)} onContextMenu={(evt) => this.onContext(evt, vault)}>
{vault.encrypted ? <Lock height={undefined} width={undefined} /> : <Unlock height={undefined} width={undefined} />} {vault.encrypted ? <Lock height={undefined} width={undefined} /> : <Unlock height={undefined} width={undefined} />}
<span> <span>
{vault.name} {vault.name}
</span> </span>
</div> </li>
}) })
return <div style={{ marginTop: "-12px", paddingTop: "12px" }} > return <div style={{ marginTop: "-12px", paddingTop: "12px" }} >
{this.state.modal} {/* {this.state.modal} */}
{this.state.context} {this.state.context}
<header> <header class="uk-background-primary">
<span></span> <span></span>
<h1 style="display:inline" class="button header_title" onClick={() => Navigation.setPage("/")}>Your vaults:</h1> <h3 style="display:inline" class="header_title" onClick={() => Navigation.setPage("/")}>Your vaults:</h3>
<span></span> <span></span>
</header> </header>
<AddButton onClick={() => this.addButtonClick()} /> <AddButton onClick={() => this.addButtonClick()} />
<div class="container"> <div class="uk-container">
<div class="row"> <ul class="uk-list uk-list-divider">
<div class="col-sm-12 col-md-8 col-lg-6 col-md-offset-2 col-lg-offset-3"> {elms}
<div class="card fluid"> </ul>
<div class="section">
{elms}
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
} }

View File

@ -1,21 +1,23 @@
.vaults_vault>span { @import "../../../vars.scss";
font-size: 2rem !important;
}
.vaults_vault { .vaults_vault {
padding: 0.5rem; padding: 0.5rem;
border-bottom: solid 1px var(--card-border-color); margin-top: 0 !important;
}
.vaults_vault:hover { // >span {
background: var(--nav-hover-back-color); // font-size: 2rem !important;
} // }
.vaults_vault>svg { // &:not(:last-child) {
height: 2rem; // border-bottom: 1px $border_color solid;
margin-right: 1rem; // }
}
.vaults_vault:last-child { >svg {
border-bottom: none; height: 2rem;
margin-right: 1rem;
}
&:hover {
background: $hover-background;
}
} }

View File

@ -5,7 +5,6 @@
height: 100%; height: 100%;
width: 100%; width: 100%;
overflow: auto; overflow: auto;
background: var(--back-color);
padding-bottom: 40px; padding-bottom: 40px;
} }

View File

@ -1,5 +1,5 @@
@import url('https://fonts.googleapis.com/css?family=Roboto');
@import "./vars.scss"; @import "./vars.scss";
* { * {
margin: 0; margin: 0;
padding: 0; padding: 0;
@ -18,27 +18,47 @@ html {
display: flex; display: flex;
} }
// .feather { $header-margin: .5em;
// width: 24px; $header-icon-size: calc(1.5rem * 1);
// height: 24px; // $header-icon-size: 100%;
// stroke: currentColor;
// stroke-width: 2;
// stroke-linecap: round;
// stroke-linejoin: round;
// fill: none;
// }
.header_icon_button {
height: $header_icon_width;
width: $header_icon_width;
}
.header_title {
max-width: calc(100% - #{$header_icon_width} - #{$header_icon_width});
overflow: hidden;
}
header { header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
margin-bottom: calc(1.5 * var(--universal-padding)); margin-bottom: $header-margin;
align-content: center;
padding: 0.75em;
border-bottom: solid $border-color 1px;
>* {
margin: 0;
}
>.header-title {
overflow: hidden;
text-overflow: ellipsis;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
flex-grow: 1;
margin: 0 1em;
}
.header-icon-button {
display: block;
margin-top: auto;
margin-bottom: auto;
color: black;
min-width: $header-icon-size;
>svg {
height: $header-icon-size;
width: $header-icon-size;
}
}
}
.def-shadow {
box-shadow: 0px 5px 8px 2px rgba(66, 66, 66, 0.53);
} }

View File

@ -1,11 +1,46 @@
declare global {
interface Window {
requestIdleCallback: (callback: (deadline: { didTimeout: boolean, timeRemaining: () => number }) => void, options?: { timeout: number }) => number | NodeJS.Timeout;
cancelIdleCallback: (id: number | NodeJS.Timeout) => void;
debug: any;
}
}
// declare const window: Window;
window.requestIdleCallback =
window.requestIdleCallback ||
function (cb) {
var start = Date.now();
return setTimeout(function () {
console.log("Idle Timeout reached!");
cb({
didTimeout: false,
timeRemaining: function () {
return Math.max(0, 50 - (Date.now() - start));
}
});
}, 1);
};
window.cancelIdleCallback =
window.cancelIdleCallback ||
function (id) {
clearTimeout(id as any);
};
console.log(window.requestIdleCallback);
window.debug = {}; window.debug = {};
import { h, render } from 'preact'; import { h, render } from 'preact';
import App from './components/App'; import App from './components/App';
// import "mini.css/src/flavors/mini-dark.scss" // import "mini.css/src/flavors/mini-dark.scss"
import "mini.css/src/flavors/mini-default.scss" // import "mini.css/src/flavors/mini-default.scss"
import "uikit"; // import "uikit";
import "uikit/dist/css/uikit.css" import "uikit/dist/css/uikit.css"
import "./index.scss" import "./index.scss"
import Navigation from './navigation'; import Navigation from './navigation';
@ -17,6 +52,7 @@ import DemoPage from './components/demo';
import VaultPage from './components/routes/vault/Vault'; import VaultPage from './components/routes/vault/Vault';
import SharePage from './components/routes/share/Share'; import SharePage from './components/routes/share/Share';
import Notifications from './notifications'; import Notifications from './notifications';
console.log(Notes); console.log(Notes);
(async () => { (async () => {

View File

@ -40,7 +40,6 @@ import IDB from "./helper/indexeddb";
import { Transaction } from "idb"; import { Transaction } from "idb";
import Notifications, { MessageType } from "./notifications"; import Notifications, { MessageType } from "./notifications";
console.log(aesjs)
const Encoder = new TextEncoder(); const Encoder = new TextEncoder();
const Decoder = new TextDecoder(); const Decoder = new TextDecoder();
@ -150,8 +149,12 @@ class NotesProvider {
constructor(public readonly baseurl = "") { constructor(public readonly baseurl = "") {
this._secureFile = new SecureFile(config.secure_file_server); this._secureFile = new SecureFile(config.secure_file_server);
this._secureFile.jwtObservable.subscribe(async (callback) => { this._secureFile.jwtObservable.subscribe(async (callback) => {
let jwt = await this.getJWT(); try {
callback(jwt); let jwt = await this.getJWT();
callback(null, jwt);
} catch (err) {
callback(err, null);
}
}) })
let key = localStorage.getItem("enc_key"); let key = localStorage.getItem("enc_key");

View File

@ -1 +1,2 @@
$header_icon_width: calc(3.1875rem + var(--universal-padding) / 2); $border-color: #AAAAAA;
$hover-background: #DDDDDD;