witching to UIKit 3
This commit is contained in:
parent
8b6c71247f
commit
595f2be1fb
@ -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",
|
||||
"client_id": "cf699b12-2014-4a61-bb7d-a7e38b197350",
|
||||
"permission": "5c1ed399dc361731340a49d4",
|
||||
"callback_url": "http://localhost:8080"
|
||||
"callback_url": "https://notes.dev.hibas123.de"
|
||||
}
|
666
package-lock.json
generated
666
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
25
package.json
25
package.json
@ -13,41 +13,40 @@
|
||||
"author": "Fabian Stamm <dev@fabianstamm.de>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@hibas123/secure-file-wrapper": "^2.4.0",
|
||||
"@hibas123/utils": "^2.0.0",
|
||||
"@hibas123/secure-file-wrapper": "^2.5.0",
|
||||
"@hibas123/utils": "^2.0.5",
|
||||
"aes-js": "^3.1.2",
|
||||
"crypto-js": "^3.1.9-1",
|
||||
"feather-icons": "^4.19.0",
|
||||
"idb": "^3.0.2",
|
||||
"feather-icons": "^4.21.0",
|
||||
"idb": "3.0.2",
|
||||
"js-sha256": "^0.9.0",
|
||||
"js-sha512": "^0.8.0",
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
"mini.css": "^3.0.1",
|
||||
"secure-file-wrapper": "git+https://git.stamm.me/OpenServer/OSSecureFileWrapper.git",
|
||||
"uikit": "^3.0.3",
|
||||
"uuid": "^3.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash.clonedeep": "^4.5.6",
|
||||
"@types/uikit": "^2.27.7",
|
||||
"@types/uuid": "^3.4.4",
|
||||
"copy-webpack-plugin": "^5.0.2",
|
||||
"css-loader": "^2.1.1",
|
||||
"file-loader": "^3.0.1",
|
||||
"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",
|
||||
"preact": "^8.3.1",
|
||||
"preact-svg-loader": "^0.2.1",
|
||||
"sass-loader": "^7.1.0",
|
||||
"style-loader": "^0.23.1",
|
||||
"ts-loader": "^5.3.0",
|
||||
"typescript": "^3.3.4000",
|
||||
"webpack": "^4.29.6",
|
||||
"webpack-bundle-analyzer": "^3.1.0",
|
||||
"typescript": "^3.4.3",
|
||||
"webpack": "^4.30.0",
|
||||
"webpack-bundle-analyzer": "^3.3.2",
|
||||
"webpack-cli": "^3.3.0",
|
||||
"webpack-dev-server": "^3.2.1",
|
||||
"webpack-dev-server": "^3.3.1",
|
||||
"webpack-visualizer-plugin": "^0.1.11",
|
||||
"workbox-webpack-plugin": "^4.1.1",
|
||||
"workbox-webpack-plugin": "^4.3.0",
|
||||
"worker-loader": "^2.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,5 +2,11 @@ import { h } from "preact";
|
||||
import "./add_button.scss";
|
||||
import Plus from "feather-icons/dist/icons/plus.svg";
|
||||
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>
|
||||
}
|
@ -56,7 +56,7 @@ export class Footer extends Component<{}, { synced: boolean, syncing: boolean }>
|
||||
text = "not synced";
|
||||
}
|
||||
}
|
||||
return <footer>
|
||||
return <footer class="uk-background-default def-shadow">
|
||||
<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>
|
||||
|
@ -26,7 +26,7 @@ export class Router extends Component<{}, { next?: JSX.Element, current: JSX.Ele
|
||||
render() {
|
||||
let overlay;
|
||||
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 = () => {
|
||||
if (this.state.next)
|
||||
this.setState({ current: this.state.next, next: undefined }, () => {
|
||||
@ -43,7 +43,7 @@ export class Router extends Component<{}, { next?: JSX.Element, current: JSX.Ele
|
||||
</div>
|
||||
}
|
||||
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}
|
||||
</div>
|
||||
{overlay}
|
||||
|
@ -1,15 +1,14 @@
|
||||
// .add_button_container {}
|
||||
.add_button_button {
|
||||
.add-button-button {
|
||||
position: fixed;
|
||||
bottom: 2rem;
|
||||
right: 2rem;
|
||||
bottom: 2.5rem;
|
||||
right: 1rem;
|
||||
width: 4rem;
|
||||
height: 4rem;
|
||||
padding: 0.75rem;
|
||||
z-index: 16;
|
||||
}
|
||||
|
||||
.add_button_button>svg {
|
||||
height: 2.5rem;
|
||||
width: 2.5rem;
|
||||
>svg {
|
||||
height: 2.5rem;
|
||||
width: 2.5rem;
|
||||
}
|
||||
}
|
18
src/components/context.scss
Normal file
18
src/components/context.scss
Normal 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;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ import { h } from "preact";
|
||||
import "./context.scss";
|
||||
|
||||
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}
|
||||
</div>
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
@import "../vars.scss";
|
||||
|
||||
.reloading { animation: turner 1s infinite linear }
|
||||
|
||||
@keyframes turner{
|
||||
@ -14,6 +16,8 @@ footer {
|
||||
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
// border-top: 1px solid $border-color;
|
||||
|
||||
padding: calc(0.9 * var(--universal-padding)) !important;
|
||||
padding: 0.15em !important;
|
||||
}
|
@ -16,6 +16,10 @@ export class InputModal extends Modal<string> {
|
||||
this.rand = Math.random().toString();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.input.focus();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this.input)
|
||||
this.input.value = "";
|
||||
@ -23,23 +27,36 @@ export class InputModal extends Modal<string> {
|
||||
|
||||
render() {
|
||||
return <Modal.BaseModal modal={this.props.modal}>
|
||||
<fieldset style="border:none; min-inline-size:0;">
|
||||
<label for={this.rand}>{this.props.modal.fieldname}</label>
|
||||
<input style="min-width: 85%" autofocus ref={elm => {
|
||||
this.input = elm
|
||||
if (this.input)
|
||||
setTimeout(() => this.input.focus(), 0)
|
||||
}} type={this.props.modal.type} id={this.rand} placeholder={this.props.modal.fieldname} onKeyDown={evt => {
|
||||
if (evt.keyCode === 13) {
|
||||
this.props.modal.result(this.input.value)
|
||||
}
|
||||
}} />
|
||||
<div style="text-align: right;">
|
||||
<button class="primary" style="display: inline-block;" onClick={() => {
|
||||
<div class="uk-form-horizontal uk-margin-large">
|
||||
<div class="uk-margin">
|
||||
<label class="uk-form-label" for={this.rand}>{this.props.modal.fieldname}</label>
|
||||
<div class="uk-form-controls">
|
||||
<input
|
||||
class="uk-input"
|
||||
id={this.rand}
|
||||
type={this.props.modal.type}
|
||||
placeholder={this.props.modal.fieldname}
|
||||
autofocus
|
||||
ref={elm => { this.input = elm; }}
|
||||
onKeyDown={evt => {
|
||||
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);
|
||||
}}>Enter</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
{/*
|
||||
<fieldset style="border:none; min-inline-size:0;">
|
||||
|
||||
</fieldset> */}
|
||||
</Modal.BaseModal>
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,11 @@ export default class LoadingModal extends Modal<undefined> {
|
||||
|
||||
getComponent() {
|
||||
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>
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ export default abstract class Modal<T> {
|
||||
// Private
|
||||
private onResult: (result: T | null) => void;
|
||||
private closeOnResult: boolean;
|
||||
private noClose: boolean = false;
|
||||
|
||||
// Protected
|
||||
protected result(value: T | null) {
|
||||
@ -25,9 +26,10 @@ export default abstract class Modal<T> {
|
||||
//Public
|
||||
/**
|
||||
* 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 });
|
||||
}
|
||||
|
||||
@ -38,7 +40,7 @@ export default abstract class Modal<T> {
|
||||
*/
|
||||
public async getResult(close = true) {
|
||||
this.closeOnResult = close;
|
||||
this.show();
|
||||
this.show(false);
|
||||
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> }, {}> {
|
||||
render() {
|
||||
return <div class="modal_container" onClick={(evt) => {
|
||||
return <div class="modal-container" onClick={(evt) => {
|
||||
let path = evt.composedPath();
|
||||
if (!path.find(e => {
|
||||
let res = false;
|
||||
let s = (e as Element);
|
||||
if (s) {
|
||||
if (s.classList) {
|
||||
res = s.classList.contains("card")
|
||||
}
|
||||
}
|
||||
return res;
|
||||
return s.id === "ModalContent";
|
||||
})) {
|
||||
this.props.modal.result(null)
|
||||
}
|
||||
@ -69,12 +65,15 @@ export default abstract class Modal<T> {
|
||||
this.props.modal.result(null)
|
||||
}
|
||||
}}>
|
||||
<div class="card" >
|
||||
<div class="section" style="display:flex;justify-content:space-between;">
|
||||
<div id="ModalContent" class="uk-card uk-card-body uk-card-body" >
|
||||
<div class="modal-title uk-card-title" style="">
|
||||
<h3>{this.props.modal.title}</h3>
|
||||
<h3>
|
||||
<CloseIcon onClick={() => this.props.modal.result(null)} width={undefined} height={undefined} style="height:calc(1rem * var(--heading-ratio) * var(--heading-ratio))" />
|
||||
</h3>
|
||||
{/* <div> */}
|
||||
{!this.props.modal.noClose ?
|
||||
<CloseIcon onClick={() => this.props.modal.result(null)} width={undefined} height={undefined} />
|
||||
: undefined
|
||||
}
|
||||
{/* </div> */}
|
||||
</div>
|
||||
{this.props.children}
|
||||
</div>
|
||||
|
@ -28,16 +28,16 @@ export class YesNoModal extends Modal<boolean> {
|
||||
|
||||
render() {
|
||||
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;">
|
||||
<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);
|
||||
}}>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);
|
||||
}}>Yes</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</Modal.BaseModal>
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +0,0 @@
|
||||
.context_menu {
|
||||
button {
|
||||
margin: 0;
|
||||
display: block;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
.modal_container {
|
||||
.modal-container {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
@ -8,7 +8,7 @@
|
||||
z-index: 32;
|
||||
}
|
||||
|
||||
.modal_container>.card {
|
||||
.modal-container>.uk-card {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
@ -16,4 +16,13 @@
|
||||
width: 80%;
|
||||
max-width: 800px;
|
||||
margin: auto;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
display:flex;
|
||||
justify-content:space-between;
|
||||
>svg {
|
||||
height: 1em;
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
||||
|
||||
skip_save: boolean = false;
|
||||
|
||||
loading?: LoadingModal;
|
||||
// loading?: LoadingModal;
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@ -38,8 +38,8 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
||||
async componentWillMount() {
|
||||
try {
|
||||
this.skip_save = false;
|
||||
this.loading = new LoadingModal();
|
||||
this.loading.show();
|
||||
// this.loading = new LoadingModal();
|
||||
// this.loading.show();
|
||||
|
||||
this.vault = await this.props.vault;
|
||||
let note: ViewNote;
|
||||
@ -66,8 +66,8 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
||||
}
|
||||
let [title] = this.text.split("\n", 1);
|
||||
this.setState({ title, changed })
|
||||
if (this.loading)
|
||||
this.loading.close();
|
||||
// if (this.loading)
|
||||
// this.loading.close();
|
||||
}
|
||||
} catch (err) {
|
||||
Notifications.sendError(err);
|
||||
@ -164,23 +164,28 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
||||
}
|
||||
|
||||
return <div>
|
||||
<header>
|
||||
<div>
|
||||
<a class="button 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}
|
||||
</div>
|
||||
<h1 style="display:inline" class="button header_title">{this.state.title}</h1>
|
||||
<a class="button header_icon_button" onClick={() => delete_handler()}><Trash height={undefined} width={undefined} /></a>
|
||||
<header class="uk-background-primary">
|
||||
{/* <div> */}
|
||||
<a class="header-icon-button" onClick={() => this.exitHandler()}><X height={undefined} width={undefined} /></a>
|
||||
{this.state.changed ? <a class="header-icon-button" style="margin-left: 0.5em;" onClick={() => save_handler()}><Save height={undefined} width={undefined} /></a> : undefined}
|
||||
{/* </div> */}
|
||||
<h3 style="display:inline" class="button header-title">{this.state.title}</h3>
|
||||
<a class="header-icon-button" onClick={() => delete_handler()}><Trash height={undefined} width={undefined} /></a>
|
||||
</header>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-8 col-lg-6 col-md-offset-2 col-lg-offset-3">
|
||||
<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 => {
|
||||
if (elm)
|
||||
setTimeout(() => elm.focus(), 0)
|
||||
}} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-container">
|
||||
<textarea
|
||||
autofocus
|
||||
value={this.text}
|
||||
rows={this.rows}
|
||||
class="doc uk-textarea"
|
||||
style="width:100%;"
|
||||
onKeyDown={evt => this.textAreaKeyPress(evt)}
|
||||
onKeyUp={evt => this.textAreaChange(evt)}
|
||||
ref={elm => {
|
||||
if (elm)
|
||||
setTimeout(() => elm.focus(), 500)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
@ -3,23 +3,34 @@ import Notes, { IVault, BaseNote } from "../../../notes";
|
||||
import AddButton from "../../AddButton";
|
||||
import Navigation from "../../../navigation";
|
||||
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 { Observable, Lock } from "@hibas123/utils";
|
||||
|
||||
|
||||
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) {
|
||||
super(props)
|
||||
console.log("Creating new Instance of EntryList")
|
||||
this.state = { notes: [], context: undefined }
|
||||
this.onDragOver = this.onDragOver.bind(this);
|
||||
this.onDrop = this.onDrop.bind(this);
|
||||
this.reloadNotes = this.reloadNotes.bind(this);
|
||||
this.searchChanged = this.searchChanged.bind(this);
|
||||
}
|
||||
vault: IVault;
|
||||
|
||||
reloadNotes(s?: boolean) {
|
||||
async reloadNotes(s?: boolean) {
|
||||
if (s)
|
||||
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() {
|
||||
@ -28,6 +39,7 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
|
||||
document.body.addEventListener("dragover", this.onDragOver);
|
||||
document.body.addEventListener("drop", this.onDrop);
|
||||
Notes.syncObservable.subscribe(this.reloadNotes);
|
||||
this.searchObservable.subscribeCollect(() => this.applySearch());
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@ -36,6 +48,11 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
|
||||
Notes.syncObservable.unsubscribe(this.reloadNotes);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
console.log("ON Component Did mount", this.search);
|
||||
this.searchInput.value = this.search;
|
||||
}
|
||||
|
||||
onDragOver(evt: DragEvent) {
|
||||
evt.preventDefault();
|
||||
}
|
||||
@ -60,7 +77,7 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
|
||||
|
||||
let share;
|
||||
if ((window.navigator as any).share) {
|
||||
share = <button onClick={() => shareNote()}>
|
||||
share = <button class="uk-button" onClick={() => shareNote()}>
|
||||
share
|
||||
</button>
|
||||
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() {
|
||||
const open_entry = (id: string | null) => {
|
||||
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 [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)
|
||||
}}>
|
||||
<span>{first}</span><br />
|
||||
<span>{second}</span>
|
||||
</div>
|
||||
<div>{first}</div>
|
||||
<div>{second}</div>
|
||||
</li>
|
||||
})
|
||||
|
||||
|
||||
return <div>
|
||||
{this.state.context}
|
||||
<header>
|
||||
<div>
|
||||
<a class="button header_icon_button" onClick={() => history.back()}><ArrowLeft height={undefined} width={undefined} /></a>
|
||||
</div>
|
||||
<h1 style="display:inline" class="button header_title" onClick={() => Navigation.setPage("/")}>{this.vault ? this.vault.name : ""}</h1>
|
||||
<header class="uk-background-primary">
|
||||
{/* <div> */}
|
||||
<a class="header-icon-button" onClick={() => history.back()}><ArrowLeft height={undefined} width={undefined} /></a>
|
||||
{/* </div> */}
|
||||
<h3 style="display:inline" class="header-title" onClick={() => Navigation.setPage("/")}>{this.vault ? this.vault.name : ""}</h3>
|
||||
<span></span>
|
||||
{/* <a class="button header_icon_button"><MoreVertival height={undefined} width={undefined} /></a> */}
|
||||
</header>
|
||||
<AddButton onClick={() => open_entry(null)} />
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-8 col-lg-6 col-md-offset-2 col-lg-offset-3">
|
||||
<div class="card fluid">
|
||||
<div class="section">
|
||||
{elms}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-container">
|
||||
<div style="display:flex;">
|
||||
<input class="uk-input" type="text" onKeyUp={this.searchChanged} ref={elm => this.searchInput = elm} />
|
||||
<button class="uk-button" style="padding: 0 10px;">
|
||||
<Search />
|
||||
</button>
|
||||
</div>
|
||||
<ul class="uk-list uk-list-divider">
|
||||
{elms}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
}
|
@ -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 {
|
||||
font-size: 1rem;
|
||||
margin-left: 1rem;
|
||||
}
|
||||
// .vault_vault {
|
||||
// padding: 0.5rem;
|
||||
// border-bottom: solid 1px var(--card-border-color);
|
||||
// }
|
||||
|
||||
.vault_vault {
|
||||
padding: 0.5rem;
|
||||
border-bottom: solid 1px var(--card-border-color);
|
||||
}
|
||||
// .vault_vault:hover {
|
||||
// background: var(--nav-hover-back-color);
|
||||
// }
|
||||
|
||||
.vault_vault:hover {
|
||||
background: var(--nav-hover-back-color);
|
||||
}
|
||||
// .vault_vault>svg {
|
||||
// height: 2rem;
|
||||
// margin-right: 1rem;
|
||||
// }
|
||||
|
||||
.vault_vault>svg {
|
||||
height: 2rem;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
|
||||
.vault_vault:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
// .vault_vault:last-child {
|
||||
// border-bottom: none;
|
||||
// }
|
@ -8,7 +8,7 @@ import Navigation from "../../../navigation";
|
||||
import { InputModal } from "../../modals/InputModal";
|
||||
import { YesNoModal } from "../../modals/YesNoModal";
|
||||
import AddButton from "../../AddButton";
|
||||
import ContextMenu from "../../modals/context";
|
||||
import ContextMenu from "../../context";
|
||||
import Notifications from "../../../notifications";
|
||||
|
||||
export interface VaultsProps {
|
||||
@ -134,7 +134,7 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
|
||||
}
|
||||
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 result = await delete_modal.getResult();
|
||||
if (result) {
|
||||
@ -151,7 +151,7 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
|
||||
|
||||
let delete_key;
|
||||
if (Notes.getVaultKey(vault.id)) {
|
||||
delete_key = <button onClick={() => {
|
||||
delete_key = <button class="uk-button" onClick={() => {
|
||||
Notes.forgetVaultKey(vault.id);
|
||||
Notifications.sendSuccess("Forgot key!")
|
||||
}}>
|
||||
@ -159,7 +159,7 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
|
||||
</button>;
|
||||
}
|
||||
|
||||
let exportb = <button onClick={async () => {
|
||||
let exportb = <button class="uk-button" onClick={async () => {
|
||||
let key: Uint8Array;
|
||||
if (vault.encrypted) {
|
||||
await this.getKey(vault, false)
|
||||
@ -205,33 +205,27 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
|
||||
|
||||
render() {
|
||||
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} />}
|
||||
<span>
|
||||
{vault.name}
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
})
|
||||
|
||||
return <div style={{ marginTop: "-12px", paddingTop: "12px" }} >
|
||||
{this.state.modal}
|
||||
{/* {this.state.modal} */}
|
||||
{this.state.context}
|
||||
<header>
|
||||
<header class="uk-background-primary">
|
||||
<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>
|
||||
</header>
|
||||
<AddButton onClick={() => this.addButtonClick()} />
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-8 col-lg-6 col-md-offset-2 col-lg-offset-3">
|
||||
<div class="card fluid">
|
||||
<div class="section">
|
||||
{elms}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-container">
|
||||
<ul class="uk-list uk-list-divider">
|
||||
{elms}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
@ -1,21 +1,23 @@
|
||||
.vaults_vault>span {
|
||||
font-size: 2rem !important;
|
||||
}
|
||||
@import "../../../vars.scss";
|
||||
|
||||
.vaults_vault {
|
||||
padding: 0.5rem;
|
||||
border-bottom: solid 1px var(--card-border-color);
|
||||
}
|
||||
margin-top: 0 !important;
|
||||
|
||||
.vaults_vault:hover {
|
||||
background: var(--nav-hover-back-color);
|
||||
}
|
||||
// >span {
|
||||
// font-size: 2rem !important;
|
||||
// }
|
||||
|
||||
.vaults_vault>svg {
|
||||
height: 2rem;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
// &:not(:last-child) {
|
||||
// border-bottom: 1px $border_color solid;
|
||||
// }
|
||||
|
||||
.vaults_vault:last-child {
|
||||
border-bottom: none;
|
||||
>svg {
|
||||
height: 2rem;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: $hover-background;
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
background: var(--back-color);
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
@import url('https://fonts.googleapis.com/css?family=Roboto');
|
||||
@import "./vars.scss";
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
@ -18,27 +18,47 @@ html {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
// .feather {
|
||||
// width: 24px;
|
||||
// height: 24px;
|
||||
// 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-margin: .5em;
|
||||
$header-icon-size: calc(1.5rem * 1);
|
||||
// $header-icon-size: 100%;
|
||||
|
||||
header {
|
||||
display: flex;
|
||||
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);
|
||||
}
|
@ -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 = {};
|
||||
|
||||
|
||||
|
||||
|
||||
import { h, render } from 'preact';
|
||||
import App from './components/App';
|
||||
|
||||
// import "mini.css/src/flavors/mini-dark.scss"
|
||||
import "mini.css/src/flavors/mini-default.scss"
|
||||
import "uikit";
|
||||
// import "mini.css/src/flavors/mini-default.scss"
|
||||
// import "uikit";
|
||||
import "uikit/dist/css/uikit.css"
|
||||
import "./index.scss"
|
||||
import Navigation from './navigation';
|
||||
@ -17,6 +52,7 @@ import DemoPage from './components/demo';
|
||||
import VaultPage from './components/routes/vault/Vault';
|
||||
import SharePage from './components/routes/share/Share';
|
||||
import Notifications from './notifications';
|
||||
|
||||
console.log(Notes);
|
||||
|
||||
(async () => {
|
||||
|
@ -40,7 +40,6 @@ import IDB from "./helper/indexeddb";
|
||||
import { Transaction } from "idb";
|
||||
import Notifications, { MessageType } from "./notifications";
|
||||
|
||||
console.log(aesjs)
|
||||
const Encoder = new TextEncoder();
|
||||
const Decoder = new TextDecoder();
|
||||
|
||||
@ -150,8 +149,12 @@ class NotesProvider {
|
||||
constructor(public readonly baseurl = "") {
|
||||
this._secureFile = new SecureFile(config.secure_file_server);
|
||||
this._secureFile.jwtObservable.subscribe(async (callback) => {
|
||||
let jwt = await this.getJWT();
|
||||
callback(jwt);
|
||||
try {
|
||||
let jwt = await this.getJWT();
|
||||
callback(null, jwt);
|
||||
} catch (err) {
|
||||
callback(err, null);
|
||||
}
|
||||
})
|
||||
|
||||
let key = localStorage.getItem("enc_key");
|
||||
|
@ -1 +1,2 @@
|
||||
$header_icon_width: calc(3.1875rem + var(--universal-padding) / 2);
|
||||
$border-color: #AAAAAA;
|
||||
$hover-background: #DDDDDD;
|
Loading…
Reference in New Issue
Block a user