Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Vladislav Rykov
THSO.server
Commits
27f49a1f
Commit
27f49a1f
authored
May 11, 2020
by
Vladislav Rykov
Browse files
autoloaded table on scroll added
parent
65d79ff9
Changes
4
Show whitespace changes
Inline
Side-by-side
app/app/__pycache__/views.cpython-37.pyc
View file @
27f49a1f
No preview for this file type
app/app/templates/public/dev-data-t.html
View file @
27f49a1f
...
@@ -36,6 +36,12 @@
...
@@ -36,6 +36,12 @@
<div
id=
"curve_chart_{{ k }}"
></div>
<div
id=
"curve_chart_{{ k }}"
></div>
<table
class=
"table"
id=
"table_{{ k }}"
>
<table
class=
"table"
id=
"table_{{ k }}"
>
<thead>
<th>
Time
</th>
<th>
{{ k }}
</th>
</thead>
<tbody
id=
"table_{{ k }}_body"
>
</tbody>
</table>
</table>
</div>
</div>
{% endfor %}
{% endfor %}
...
@@ -92,6 +98,16 @@
...
@@ -92,6 +98,16 @@
{% if data %}
{% if data %}
<script
type=
"text/javascript"
src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"
></script>
<script
type=
"text/javascript"
src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"
></script>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
function
init_scroll
()
{
var
ts
=
{
{
%
for
k
in
data
[
0
][
2
]
%
}
{{
k
}}
:
1
,
{
%
endfor
%
}
};
return
ts
;
}
var
tscroll
=
init_scroll
();
google
.
charts
.
load
(
'
current
'
,
{
'
packages
'
:[
'
corechart
'
]});
google
.
charts
.
load
(
'
current
'
,
{
'
packages
'
:[
'
corechart
'
]});
function
drawChart
(
dname
,
ddata
)
{
function
drawChart
(
dname
,
ddata
)
{
...
@@ -140,8 +156,17 @@
...
@@ -140,8 +156,17 @@
document
.
getElementById
(
dname
).
style
.
display
=
"
block
"
;
document
.
getElementById
(
dname
).
style
.
display
=
"
block
"
;
evt
.
currentTarget
.
className
+=
"
active
"
;
evt
.
currentTarget
.
className
+=
"
active
"
;
fetch
(
window
.
origin
+
'
/dev-data/
'
+
dname
+
'
/graph/1
'
).
then
(
res
=>
res
.
text
()).
then
(
data
=>
drawChart
(
dname
,
eval
(
data
)));
fetch
(
window
.
origin
+
'
/dev-data/
'
+
dname
+
'
/graph/
'
+
tscroll
[
dname
]).
then
(
res
=>
res
.
text
()).
then
(
data
=>
drawChart
(
dname
,
eval
(
data
)));
fetch
(
window
.
origin
+
'
/dev-data/
'
+
dname
+
'
/table/1
'
).
then
(
res
=>
res
.
text
()).
then
(
data
=>
$
(
'
#table_
'
+
dname
).
html
(
data
));
fetch
(
window
.
origin
+
'
/dev-data/
'
+
dname
+
'
/table/
'
+
tscroll
[
dname
]).
then
(
res
=>
res
.
text
()).
then
(
data
=>
$
(
'
#table_
'
+
dname
+
'
_body
'
).
html
(
data
));
window
.
onscroll
=
function
(
ev
)
{
if
((
window
.
innerHeight
+
window
.
scrollY
)
>=
document
.
body
.
offsetHeight
)
{
tscroll
[
dname
]
+=
1
;
fetch
(
window
.
origin
+
'
/dev-data/
'
+
dname
+
'
/table/
'
+
tscroll
[
dname
]).
then
(
res
=>
res
.
text
()).
then
(
data
=>
$
(
'
#table_
'
+
dname
+
'
_body
'
).
append
(
data
));
console
.
log
(
tscroll
[
dname
]);
}
};
}
}
document
.
getElementById
(
"
tab_{{ data[0][2] | first }}
"
).
click
();
document
.
getElementById
(
"
tab_{{ data[0][2] | first }}
"
).
click
();
...
...
app/app/templates/public/index.html
View file @
27f49a1f
{% extends 'layout.html' %}
{% extends 'layout.html' %}
{% block title %} H
ome
{% endblock %}
{% block title %} H
PC
&
A IoT Server
{% endblock %}
{% block content %}
{% block content %}
...
...
app/app/views.py
View file @
27f49a1f
...
@@ -484,16 +484,17 @@ def dev_data(var, dest, page):
...
@@ -484,16 +484,17 @@ def dev_data(var, dest, page):
elif
dest
==
'table'
:
elif
dest
==
'table'
:
# for table <cnt> is in items
# for table <cnt> is in items
last
=
data
.
get_last_range
(
session
[
'appkey'
],
session
[
'devid'
],
[
MAX_PG_ENTRIES_DATA
,
(
int
(
page
)
-
1
)
*
MAX_PG_ENTRIES_DATA
])
last
=
data
.
get_last_range
(
session
[
'appkey'
],
session
[
'devid'
],
[
MAX_PG_ENTRIES_DATA
,
(
int
(
page
)
-
1
)
*
MAX_PG_ENTRIES_DATA
])
t
=
""" <thead>
#t = """ <thead>
<th>Time</th>
# <th>Time</th>
<th>{}</th>
# <th>{}</th>
</thead>
# </thead>
<tbody>
# <tbody>
"""
.
format
(
var
)
#""".format(var)
t
=
''
if
last
[
0
]:
if
last
[
0
]:
for
d
in
last
[
1
]:
for
d
in
last
[
1
]:
t
+=
'<tr><th>'
+
d
[
1
]
+
'</th><th>'
+
str
(
d
[
2
][
var
])
+
'</th></tr>'
t
+=
'<tr><th>'
+
d
[
1
]
+
'</th><th>'
+
str
(
d
[
2
][
var
])
+
'</th></tr>'
t
+=
'</tbody>'
#
t += '</tbody>'
return
t
return
t
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment