Skip to content

Commit

Permalink
updated document document
Browse files Browse the repository at this point in the history
  • Loading branch information
zen committed Oct 25, 2023
1 parent 34d1724 commit 6750019
Show file tree
Hide file tree
Showing 30 changed files with 384 additions and 36 deletions.
13 changes: 13 additions & 0 deletions change.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 0.6.16
- allow to set session and local storage data though api call in ReturnData and UpdateReturnData

```python
i.ReturnData(type=i.InstanceType.BOX,
box_data=i.BoxData(icon="person", name=name, value=Value),
footer="5% increase compare to last week ",
tooltip_data=i.ToolTipData(label="my label", disable=False),
dialog_data=dialog_data,
ui_data=[i.UIData(type=i.UIType.LOCALSTORAGE,action=i.UIAction.ADD, value="sdasd",key="key1"),
i.UIData(type=i.UIType.SESSION, action=i.UIAction.ADD, value="123213",key="key2")]
)
```
# 0.6.15
- Allow custom url as sidebar
# 0.6.14
Expand Down
9 changes: 9 additions & 0 deletions demo/pages/box_page/row_one/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ async def view(b: BoxInput):
tooltip_data=i.ToolTipData(
label="my label", disable=False),
dialog_data=dialog_data,
ui_data=[i.UIData(
type=i.UIType.LOCALSTORAGE,
action=i.UIAction.ADD,
value="sdasd",
key="my_key"), i.UIData(
type=i.UIType.SESSION,
action=i.UIAction.ADD,
value="123213",
key="my_key")]
)


Expand Down
15 changes: 15 additions & 0 deletions docs/_modules/zen_dash/objects/instances.html
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,20 @@ <h1>Source code for zen_dash.objects.instances</h1><div class="highlight"><pre>
<span class="n">color</span><span class="p">:</span> <span class="n">FABColor</span> <span class="o">=</span> <span class="n">FABColor</span><span class="o">.</span><span class="n">ACCENT</span>
<span class="n">target_attribute</span><span class="p">:</span><span class="n">TargetAttribute</span> <span class="o">=</span> <span class="n">TargetAttribute</span><span class="o">.</span><span class="n">PARENT</span></div>

<div class="viewcode-block" id="UIType"><a class="viewcode-back" href="../../../zen_dash.objects.html#zen_dash.objects.instances.UIType">[docs]</a><span class="k">class</span> <span class="nc">UIType</span><span class="p">(</span><span class="n">Enum</span><span class="p">):</span>
<span class="n">SESSION</span> <span class="o">=</span> <span class="s2">&quot;session&quot;</span>
<span class="n">LOCALSTORAGE</span> <span class="o">=</span> <span class="s2">&quot;local_storage&quot;</span></div>

<div class="viewcode-block" id="UIAction"><a class="viewcode-back" href="../../../zen_dash.objects.html#zen_dash.objects.instances.UIAction">[docs]</a><span class="k">class</span> <span class="nc">UIAction</span><span class="p">(</span><span class="n">Enum</span><span class="p">):</span>
<span class="n">ADD</span> <span class="o">=</span> <span class="s2">&quot;add&quot;</span>
<span class="n">DELETE</span> <span class="o">=</span> <span class="s2">&quot;delete&quot;</span></div>


<div class="viewcode-block" id="UIData"><a class="viewcode-back" href="../../../zen_dash.objects.html#zen_dash.objects.instances.UIData">[docs]</a><span class="k">class</span> <span class="nc">UIData</span><span class="p">(</span><span class="n">BaseUpdate</span><span class="p">):</span>
<span class="nb">type</span><span class="p">:</span> <span class="n">UIType</span>
<span class="n">action</span><span class="p">:</span> <span class="n">UIAction</span>
<span class="n">value</span><span class="p">:</span> <span class="nb">str</span>
<span class="n">key</span><span class="p">:</span> <span class="nb">str</span></div>

<div class="viewcode-block" id="ReturnData"><a class="viewcode-back" href="../../../zen_dash.objects.html#zen_dash.objects.instances.ReturnData">[docs]</a><span class="k">class</span> <span class="nc">ReturnData</span><span class="p">(</span><span class="n">BaseUpdate</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
Expand Down Expand Up @@ -358,6 +371,7 @@ <h1>Source code for zen_dash.objects.instances</h1><div class="highlight"><pre>
<span class="n">button_data</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">ButtonData</span><span class="p">]</span>
<span class="n">form_data</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">FormData</span><span class="p">]</span>
<span class="n">floating_button_data</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">ButtonFloating</span><span class="p">]</span>
<span class="n">ui_data</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="n">UIData</span><span class="p">]]</span>

<div class="viewcode-block" id="ReturnData.validator_type_match"><a class="viewcode-back" href="../../../zen_dash.objects.html#zen_dash.objects.instances.ReturnData.validator_type_match">[docs]</a> <span class="nd">@root_validator</span>
<span class="k">def</span> <span class="nf">validator_type_match</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">field_values</span><span class="p">):</span>
Expand Down Expand Up @@ -457,6 +471,7 @@ <h1>Source code for zen_dash.objects.instances</h1><div class="highlight"><pre>
<span class="n">box_data</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">BoxData</span><span class="p">]</span>
<span class="n">display</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Display</span><span class="p">]</span>
<span class="n">display_dialog</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">DisplayDialog</span><span class="p">]</span>
<span class="n">ui_data</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="n">UIData</span><span class="p">]]</span>

<div class="viewcode-block" id="UpdateReturnData.validator_type_match"><a class="viewcode-back" href="../../../zen_dash.objects.html#zen_dash.objects.instances.UpdateReturnData.validator_type_match">[docs]</a> <span class="nd">@root_validator</span>
<span class="k">def</span> <span class="nf">validator_type_match</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">field_values</span><span class="p">):</span>
Expand Down
39 changes: 37 additions & 2 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ <h1 id="index">Index</h1>
| <a href="#H"><strong>H</strong></a>
| <a href="#I"><strong>I</strong></a>
| <a href="#J"><strong>J</strong></a>
| <a href="#K"><strong>K</strong></a>
| <a href="#L"><strong>L</strong></a>
| <a href="#M"><strong>M</strong></a>
| <a href="#N"><strong>N</strong></a>
Expand All @@ -97,15 +98,19 @@ <h2 id="A">A</h2>
<li><a href="zen_dash.tag.html#zen_dash.tag.A">A (class in zen_dash.tag)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.FABColor.ACCENT">ACCENT (zen_dash.objects.instances.FABColor attribute)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.UIData.action">action (zen_dash.objects.instances.UIData attribute)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.WebSocketConfig.active">active (zen_dash.objects.WebSocketConfig attribute)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.TableData.allow_download">allow_download (zen_dash.objects.instances.TableData attribute)</a>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.UIAction.ADD">ADD (zen_dash.objects.instances.UIAction attribute)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.scripts.Rel.ALTERNATE">ALTERNATE (zen_dash.objects.scripts.Rel attribute)</a>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.TableData.allow_download">allow_download (zen_dash.objects.instances.TableData attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="zen_dash.objects.html#zen_dash.objects.scripts.Rel.ALTERNATE">ALTERNATE (zen_dash.objects.scripts.Rel attribute)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.Auth">Auth (class in zen_dash.objects)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.Configuration.auth">auth (zen_dash.objects.Configuration attribute)</a>
Expand Down Expand Up @@ -257,6 +262,8 @@ <h2 id="D">D</h2>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.DateTimeData">DateTimeData (class in zen_dash.objects.instances)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.scripts.CustomScript.defer">defer (zen_dash.objects.scripts.CustomScript attribute)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.UIAction.DELETE">DELETE (zen_dash.objects.instances.UIAction attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
Expand Down Expand Up @@ -519,6 +526,14 @@ <h2 id="J">J</h2>
</ul></td>
</tr></table>

<h2 id="K">K</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.UIData.key">key (zen_dash.objects.instances.UIData attribute)</a>
</li>
</ul></td>
</tr></table>

<h2 id="L">L</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
Expand All @@ -543,6 +558,8 @@ <h2 id="L">L</h2>
<li><a href="zen_dash.objects.html#zen_dash.objects.scripts.Rel.LICENSE">LICENSE (zen_dash.objects.scripts.Rel attribute)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.scripts.Style.LINK">LINK (zen_dash.objects.scripts.Style attribute)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.UIType.LOCALSTORAGE">LOCALSTORAGE (zen_dash.objects.instances.UIType attribute)</a>
</li>
<li><a href="zen_dash.auth.html#zen_dash.auth.login_support">login_support() (in module zen_dash.auth)</a>
</li>
Expand Down Expand Up @@ -826,6 +843,8 @@ <h2 id="S">S</h2>
<li><a href="zen_dash.objects.html#zen_dash.objects.Zen.server_url">server_url() (zen_dash.objects.Zen static method)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.Zen.server_view">server_view() (zen_dash.objects.Zen static method)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.UIType.SESSION">SESSION (zen_dash.objects.instances.UIType attribute)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.Configuration.show_right_sidebar">show_right_sidebar (zen_dash.objects.Configuration attribute)</a>
</li>
Expand Down Expand Up @@ -961,6 +980,8 @@ <h2 id="T">T</h2>

<ul>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.ReturnData.type">(zen_dash.objects.instances.ReturnData attribute)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.UIData.type">(zen_dash.objects.instances.UIData attribute)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.UpdateReturnData.type">(zen_dash.objects.instances.UpdateReturnData attribute)</a>
</li>
Expand All @@ -975,7 +996,19 @@ <h2 id="U">U</h2>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="zen_dash.tag.html#zen_dash.tag.U">U (class in zen_dash.tag)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.ReturnData.ui_data">ui_data (zen_dash.objects.instances.ReturnData attribute)</a>

<ul>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.UpdateReturnData.ui_data">(zen_dash.objects.instances.UpdateReturnData attribute)</a>
</li>
</ul></li>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.FormData.ui_schema">ui_schema (zen_dash.objects.instances.FormData attribute)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.UIAction">UIAction (class in zen_dash.objects.instances)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.UIData">UIData (class in zen_dash.objects.instances)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.UIType">UIType (class in zen_dash.objects.instances)</a>
</li>
<li><a href="zen_dash.tag.html#zen_dash.tag.UL">UL (class in zen_dash.tag)</a>
</li>
Expand Down Expand Up @@ -1047,6 +1080,8 @@ <h2 id="V">V</h2>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.InputData.value">(zen_dash.objects.instances.InputData attribute)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.SliderData.value">(zen_dash.objects.instances.SliderData attribute)</a>
</li>
<li><a href="zen_dash.objects.html#zen_dash.objects.instances.UIData.value">(zen_dash.objects.instances.UIData attribute)</a>
</li>
</ul></li>
</ul></td>
Expand Down
Binary file modified docs/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

74 changes: 72 additions & 2 deletions docs/zen_dash.objects.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class AppComponent implements OnInit, OnDestroy {
}

call_refresh(call: CallServiceService, ds: DataService, ws: WebsocketService) {
console.log("call refresh")
// console.log("call refresh")
if (call.config.websocket.active){
ws.request_change()
} else {
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/app/component/button/button.component.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ApiCallService } from 'src/app/services/api-call.service';
import { ButtonData, MEData, UpdateReturnData } from './../../shared/application_data';
import { Component, Input, OnInit } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar';
Expand All @@ -21,7 +22,8 @@ export class ButtonComponent implements OnInit {
constructor( private ds: DataService,
private callService: CallServiceService,
private _snackBar: MatSnackBar,
public _dialog: MatDialog
public _dialog: MatDialog,
public api_call_service: ApiCallService
) { }

reactiveity(type: string, value: string = ""){
Expand Down Expand Up @@ -61,7 +63,7 @@ export class ButtonComponent implements OnInit {
this.reactiveity("triggered")

if (this.data.redirect){
console.log(this.data.url)
// console.log(this.data.url)
window.open(this.data.url, this.data.target_attribute)
return
}
Expand Down Expand Up @@ -89,6 +91,10 @@ export class ButtonComponent implements OnInit {
if (tt.display_dialog !== undefined){
this.open_dialog(tt)
}

if (tt.ui_data !== undefined){
this.api_call_service.saveUIData(tt.ui_data)
}
} catch {
this._snackBar.openFromComponent(LoadingComponent, {
duration: 5000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export class FabButtonComponent implements OnInit {
private callService: CallServiceService,
private _snackBar: MatSnackBar,
private api: ApiCallService,
public _dialog: MatDialog
public _dialog: MatDialog,
public api_call_service: ApiCallService

) {}

Expand Down Expand Up @@ -128,6 +129,9 @@ export class FabButtonComponent implements OnInit {
if (tt.display_dialog !== undefined){
this.open_dialog(tt)
}
if (tt.ui_data !== undefined){
this.api_call_service.saveUIData(tt.ui_data)
}
} catch {
this._snackBar.openFromComponent(LoadingComponent, {
duration: 5000,
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/app/component/form/form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { and, createAjv, isControl, optionIs, rankWith, schemaTypeIs, scopeEndsW
import { JsonFormsServerSideComponent } from '../json-forms-server-side/json-forms-server-side.component';
import { MatDialog } from '@angular/material/dialog';
import { SupportDialogComponent } from '../support-dialog/support-dialog.component';
import { ApiCallService } from 'src/app/services/api-call.service';
const serverTester: Tester = and(
schemaTypeIs('string'),
schemaMatches(schema => schema.hasOwnProperty('url'))
Expand Down Expand Up @@ -38,7 +39,8 @@ export class FormComponent implements OnInit {
constructor(private ds: DataService,
private callService: CallServiceService,
private _snackBar: MatSnackBar,
public _dialog: MatDialog
public _dialog: MatDialog,
public api_call_service: ApiCallService
) {}

ngOnInit(): void {
Expand Down Expand Up @@ -85,7 +87,7 @@ export class FormComponent implements OnInit {
undefined);
this.call = p.subscribe(
(res) => {
console.log(res)
// console.log(res)
let r = res as UpdateReturnData
this.reactiveity("success")
let duration = r.display?.duration as number
Expand All @@ -103,6 +105,10 @@ export class FormComponent implements OnInit {
this.open_dialog(r)
}

if (r.ui_data !== undefined){
this.api_call_service.saveUIData(r.ui_data)
}

this.show = false

},
Expand Down
16 changes: 8 additions & 8 deletions frontend/src/app/component/input/input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,22 @@ export class InputComponent implements OnInit {
onPaste(event: ClipboardEvent, inputElement: HTMLInputElement) {
event.preventDefault()
const selectionStart = inputElement.selectionStart
console.log(selectionStart)
// console.log(selectionStart)
const selectionEnd = inputElement.selectionEnd
console.log(selectionEnd)
// console.log(selectionEnd)


if (event.clipboardData){
let pastedText = event.clipboardData.getData("text/plain")
console.log(pastedText)
// console.log(pastedText)
if ((selectionStart !== null) && (selectionEnd !== null)) {
const bST = this.data.substring(0, selectionStart)
const aST = this.data.substring(selectionEnd)
console.log("bst")
console.log(this.data)
console.log(bST)
console.log(aST)
console.log("ast")
// console.log("bst")
// console.log(this.data)
// console.log(bST)
// console.log(aST)
// console.log("ast")
this.data = bST + pastedText + aST
} else {
this.data += pastedText
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Component} from '@angular/core';
import { CallServiceService } from 'src/app/services/call-service.service';
import { JsonFormsAngularService } from '@jsonforms/angular';
import { UpdateReturnData } from 'src/app/shared/application_data';
import { ApiCallService } from 'src/app/services/api-call.service';


@Component({
Expand All @@ -16,7 +17,10 @@ export class JsonFormsServerSideComponent extends AutocompleteControlRenderer {
name: string = ''
current_value: string = ''

constructor(private callService: CallServiceService, jsonformsService: JsonFormsAngularService){
constructor(private callService: CallServiceService,
jsonformsService: JsonFormsAngularService,
public api_call_service: ApiCallService
){
super(jsonformsService);
}
fetchSuggestions = (input: string): Observable<UpdateReturnData> | Observable<unknown> => {
Expand All @@ -40,6 +44,10 @@ export class JsonFormsServerSideComponent extends AutocompleteControlRenderer {
(options) => {
let d = options as UpdateReturnData
this.options = d.simple_fitler_data as string[]

if (d.ui_data !== undefined){
this.api_call_service.saveUIData(d.ui_data)
}
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/component/sidebar/sidebar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class SidebarComponent implements OnInit {
}

getSideData() {
console.log(this.side_data?.tabs as any)
// console.log(this.side_data?.tabs as any)
return this.side_data?.tabs as any
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
map,
takeUntil,
} from 'rxjs/operators';
import { ApiCallService } from 'src/app/services/api-call.service';
import { DataService } from 'src/app/services/data.service';
import { MEData, UpdateReturnData } from 'src/app/shared/application_data';

Expand All @@ -35,7 +36,8 @@ export class SimpleServerFilterComponent implements OnInit {

constructor(
private ds: DataService,
private callService: CallServiceService
private callService: CallServiceService,
private api_call_service: ApiCallService
) {}

ngOnInit() {
Expand Down Expand Up @@ -76,7 +78,9 @@ export class SimpleServerFilterComponent implements OnInit {
final_data = new_data
}


if (data.ui_data !== undefined){
this.api_call_service.saveUIData(data.ui_data)
}

this.filteredServerSideBanks.next(
final_data
Expand Down
Loading

0 comments on commit 6750019

Please sign in to comment.