-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from sybila/feat/observations
Feat/observations
- Loading branch information
Showing
33 changed files
with
699 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,9 @@ | |
"close": true, | ||
"setSize": true, | ||
"setFocus": true | ||
}, | ||
"path": { | ||
"all": true | ||
} | ||
}, | ||
"bundle": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/html/component/observations-editor/edit-observation/edit-observation.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<script type="module" src="edit-observation.ts"></script> | ||
<title>Edit observation</title> | ||
</head> | ||
<body> | ||
<edit-observation></edit-observation> | ||
</body> | ||
</html> |
File renamed without changes.
65 changes: 65 additions & 0 deletions
65
src/html/component/observations-editor/edit-observation/edit-observation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { html, css, unsafeCSS, LitElement, type TemplateResult } from 'lit' | ||
import { customElement, query, state } from 'lit/decorators.js' | ||
import style_less from './edit-observation.less?inline' | ||
import { emit, type Event as TauriEvent, once } from '@tauri-apps/api/event' | ||
import { appWindow } from '@tauri-apps/api/window' | ||
import { map } from 'lit/directives/map.js' | ||
import { type IObservation } from '../../../util/data-interfaces' | ||
|
||
@customElement('edit-observation') | ||
export default class EditObservation extends LitElement { | ||
static styles = css`${unsafeCSS(style_less)}` | ||
@query('#node-name') nameField: HTMLInputElement | undefined | ||
@query('#node-id') variableIdField: HTMLInputElement | undefined | ||
@state() data: IObservation | undefined | ||
id = '' | ||
|
||
async firstUpdated (): Promise<void> { | ||
await once('edit_observation_update', (event: TauriEvent<IObservation>) => { | ||
this.id = event.payload.id | ||
this.data = event.payload | ||
}) | ||
await emit('loaded', {}) | ||
this.variableIdField?.focus() | ||
} | ||
|
||
private async handleSubmit (event: Event): Promise<void> { | ||
event.preventDefault() | ||
await emit('edit_observation_dialog', { | ||
id: this.id, | ||
data: this.data | ||
}) | ||
await appWindow.close() | ||
} | ||
|
||
private getValue<T>(data: T, key: string): T[keyof T] { | ||
const newKey = key as keyof typeof data | ||
return data[newKey] | ||
} | ||
|
||
private setValue<T>(data: T, key: string, value: string): void { | ||
const newKey = key as keyof typeof data | ||
data[newKey] = value as T[keyof T] | ||
} | ||
|
||
render (): TemplateResult { | ||
return html` | ||
<form class="uk-form-horizontal uk-flex uk-flex-column uk-flex-between"> | ||
<div class="fields"> | ||
${map(Object.keys(this.data ?? {}), (key) => { | ||
return html` | ||
<div class="uk-margin-small"> | ||
<label class="uk-form-label" for="form-horizontal-text">${key.toUpperCase()}</label> | ||
<div class="uk-form-controls"> | ||
<input class="uk-input" value="${this.getValue(this.data, key)}" @input="${(e: InputEvent) => { this.setValue(this.data, key, (e.target as HTMLInputElement).value) }}" id="node-id" type="text" placeholder="${key}"/> | ||
</div> | ||
</div>` | ||
})} | ||
</div> | ||
<button class="uk-button uk-width-1-1" @click="${this.handleSubmit}">Save</button> | ||
</form> | ||
` | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
src/html/component/observations-editor/observations-editor.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
@import '/src/uikit-theme'; | ||
|
||
.accordion { | ||
.container { | ||
position: relative; | ||
margin: 0.5em 0.5em; | ||
} | ||
|
||
.container.active .content { | ||
height: 100%; | ||
padding-top: 2em; | ||
} | ||
|
||
.container.active .label::before { | ||
content: '-'; | ||
font-size: 2em; | ||
} | ||
|
||
.label { | ||
font-size: 1.5em; | ||
position: relative; | ||
cursor: pointer; | ||
} | ||
|
||
.label::before { | ||
content: '+'; | ||
position: absolute; | ||
top: 50%; | ||
right: -0em; | ||
font-size: 2em; | ||
transform: translateY(-50%); | ||
transition: content 1s; | ||
|
||
} | ||
|
||
.content { | ||
position: relative; | ||
height: 0; | ||
text-align: justify; | ||
overflow: hidden; | ||
} | ||
|
||
hr { | ||
width: 100%; | ||
margin-left: 0; | ||
border: 1px solid grey; | ||
} | ||
} | ||
|
||
.observations { | ||
height: 100%; | ||
width: 100%; | ||
margin: 0; | ||
padding-bottom: 3em; | ||
max-width: inherit; | ||
max-height: inherit; | ||
overflow-y: auto; | ||
overflow-x: hidden; | ||
} | ||
|
||
.header { | ||
width: 100%; | ||
height: 4em; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
|
||
.import-button { | ||
height: 2em; | ||
right: -1em; | ||
} | ||
|
||
.heading { | ||
justify-self: center; | ||
} | ||
|
||
@media (prefers-color-scheme: dark) { | ||
.heading { | ||
color: white; | ||
} | ||
|
||
} | ||
|
||
@media (prefers-color-scheme: light) { | ||
} |
Oops, something went wrong.