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
385aadfd
Commit
385aadfd
authored
Jun 02, 2020
by
Vladislav Rykov
Browse files
new front end integrated finished (not purged)
parent
f4558f94
Changes
9
Show whitespace changes
Inline
Side-by-side
app/app/__pycache__/views.cpython-37.pyc
View file @
385aadfd
No preview for this file type
app/app/__pycache__/views_admin.cpython-37.pyc
View file @
385aadfd
No preview for this file type
app/app/dao/misc/__pycache__/misc.cpython-37.pyc
View file @
385aadfd
No preview for this file type
app/app/dao/misc/misc.py
View file @
385aadfd
...
...
@@ -13,7 +13,7 @@ def get_user_data_count(cur, username):
for
a
in
apps
:
devs
.
append
(
dd
.
get_list
(
a
[
1
])[
1
])
if
apps
!=
[]
and
devs
!=
[]:
if
apps
!=
[]
and
devs
!=
[
[]
]:
query
=
'WITH t AS ('
i
=
0
for
a
in
apps
:
...
...
@@ -38,7 +38,7 @@ def get_user_data_count_per_hour(cur, username, hour):
for
a
in
apps
:
devs
.
append
(
dd
.
get_list
(
a
[
1
])[
1
])
if
apps
!=
[]
and
devs
!=
[]:
if
apps
!=
[]
and
devs
!=
[
[]
]:
utc_hour
=
utc_roundhour
(
hour
)
query
=
'WITH t AS ('
...
...
@@ -66,7 +66,7 @@ def get_user_data_count_per_hour_period(cur, username, period):
for
a
in
apps
:
devs
.
append
(
dd
.
get_list
(
a
[
1
])[
1
])
if
apps
!=
[]
and
devs
!=
[]:
if
apps
!=
[]
and
devs
!=
[
[]
]:
utc_hour
=
[
utc_roundhour
(
x
)
for
x
in
range
(
period
,
-
1
,
-
1
)]
query
=
'WITH t AS ('
i
=
0
...
...
@@ -97,7 +97,7 @@ def get_user_data_count_per_day(cur, username, day=0):
for
a
in
apps
:
devs
.
append
(
dd
.
get_list
(
a
[
1
])[
1
])
if
apps
!=
[]
and
devs
!=
[]:
if
apps
!=
[]
and
devs
!=
[
[]
]:
utc_day
=
utc_roundday
(
day
)
query
=
'WITH t AS ('
...
...
@@ -124,7 +124,7 @@ def get_user_data_count_per_day_period(cur, username, period):
for
a
in
apps
:
devs
.
append
(
dd
.
get_list
(
a
[
1
])[
1
])
if
apps
!=
[]
and
devs
!=
[]:
if
apps
!=
[]
and
devs
!=
[
[]
]:
utc_hour
=
[
utc_roundday
(
x
)
for
x
in
range
(
period
,
-
1
,
-
1
)]
query
=
'WITH t AS ('
...
...
@@ -155,7 +155,7 @@ def get_recent_activity(cur, username, n=5):
for
a
in
apps
:
devs
.
append
(
dd
.
get_list
(
a
[
1
])[
1
])
if
apps
!=
[]
and
devs
!=
[]:
if
apps
!=
[]
and
devs
!=
[
[]
]:
query
=
''
for
a
in
apps
:
devs
=
dd
.
get_list
(
a
[
1
])
...
...
app/app/templates/logged_layout.html
View file @
385aadfd
...
...
@@ -117,7 +117,7 @@
<!-- Navigation -->
<ul
class=
"navbar-nav mb-md-3"
>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"/getting-started
/overview.html
"
>
<a
class=
"nav-link"
href=
"/getting-started"
>
<i
class=
"ni ni-spaceship"
></i>
Getting started
</a>
</li>
...
...
@@ -147,10 +147,12 @@
<div
class=
" dropdown-header noti-title"
>
<h6
class=
"text-overflow m-0"
>
Welcome!
</h6>
</div>
<!--
<a href="/profile" class="dropdown-item">
<i class="ni ni-single-02"></i>
<span>My profile</span>
</a>
-->
<a
href=
"/settings"
class=
"dropdown-item"
>
<i
class=
"ni ni-settings-gear-65"
></i>
<span>
Settings
</span>
...
...
app/app/templates/new/admin/user-settings.html
0 → 100644
View file @
385aadfd
{% extends 'logged_layout.html' %}
{% block title %} Administration - {{ user }} - Settings - HPC
&
A IoT {% endblock %}
{% block location %}
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"/administration"
>
Administration
</a>
<p
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
>
-
</p>
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"/administration/users"
>
Users
</a>
<p
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
>
-
</p>
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"/administration/users/{{ user }}"
>
{{ user }}
</a>
<p
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
>
-
</p>
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"/administration/users/{{ user }}/settings"
>
Settings
</a>
{% endblock %}
{% block body %}
<!-- Page content -->
<div
class=
"container-fluid mt--7"
>
<!-- Table -->
<div
class=
"row"
>
<div
class=
"col"
>
<div
class=
"card shadow"
>
<div
class=
"card-header bg-transparent"
>
<h3
class=
"mb-0"
>
User Settings
</h3>
</div>
<div
class=
"card-body"
>
<form
action=
"/administration/users/{{ user }}/settings"
method=
"post"
id=
"settings"
>
<div
class=
"form-group"
>
<label>
Name:
</label><br>
<input
type=
"text"
maxlength=
"30"
class=
"form-control"
id=
"name"
name=
"name"
value=
"{{ user }}"
style=
"pointer-events: none;"
><br>
</div>
<br>
<div
class=
"form-group"
>
<div
class=
"input-group input-group-alternative"
>
<div
class=
"input-group-prepend"
>
<span
class=
"input-group-text"
><i
class=
"ni ni-lock-circle-open"
></i></span>
</div>
<input
class=
"form-control"
placeholder=
"Password"
type=
"password"
minlength=
"8"
id=
"password"
name=
"password"
onkeyup=
"return validate_password();"
>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"input-group input-group-alternative"
>
<div
class=
"input-group-prepend"
>
<span
class=
"input-group-text"
><i
class=
"ni ni-lock-circle-open"
></i></span>
</div>
<input
class=
"form-control"
placeholder=
"Repeat password"
type=
"password"
minlength=
"8"
id=
"rpassword"
name=
"rpassword"
onkeyup=
"return validate_password();"
>
</div>
</div>
<div
class=
"text-muted font-italic"
><small>
Required password strength:
<span
class=
"text-success font-weight-700"
>
At least 8 characters.
</span></small></div>
<div
class=
"text-muted font-italic"
><small
id=
"passvalidation"
></small></div>
<br>
</form>
<div
class=
"row"
style=
"margin-top: 30px;"
>
<div
class=
"col-lg-3"
>
<button
type=
"submit"
form=
"settings"
id=
"submit"
class=
"btn btn-primary btn-block"
>
Save
</button>
</div>
<div
class=
"col-lg-3"
>
</div>
<div
class=
"col-lg-3"
>
</div>
<div
class=
"col-lg-3"
>
<button
type=
"button"
class=
"btn btn-danger btn-block"
data-toggle=
"modal"
data-target=
"#exampleModal"
>
Delete
</button>
<div
class=
"modal fade"
id=
"exampleModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"exampleModalLabel"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
id=
"exampleModalLabel"
>
Are you sure?
</h5>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
</div>
<div
class=
"modal-body"
>
This action will remove permanently the account, applications and all its devices with their corresponding data.
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-secondary"
data-dismiss=
"modal"
>
Close
</button>
<a
href=
"/administration/users/{{ user }}/delete-account"
><button
type=
"button"
class=
"btn btn-danger"
>
Delete Account
</button></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block script %}
<script
type=
"text/javascript"
>
var
password
=
document
.
getElementById
(
"
password
"
);
var
rpassword
=
document
.
getElementById
(
"
rpassword
"
);
function
validate_password
()
{
if
(
password
.
value
!=
rpassword
.
value
)
{
$
(
"
#passvalidation
"
).
html
(
"
<span class='text-danger font-weight-700'>Passwords do not match.</span>
"
);
$
(
"
#submit
"
).
prop
(
"
disabled
"
,
true
);
}
else
{
$
(
"
#passvalidation
"
).
html
(
"
<span class='text-success font-weight-700'>Passwords match.</span>
"
);
$
(
"
#submit
"
).
prop
(
"
disabled
"
,
false
);
}
}
</script>
{% endblock %}
app/app/templates/new/public/settings.html
0 → 100644
View file @
385aadfd
{% extends 'logged_layout.html' %}
{% block title %} Settings - HPC
&
A IoT {% endblock %}
{% block location %}
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"/settings"
>
Settings
</a>
{% endblock %}
{% block body %}
<!-- Page content -->
<div
class=
"container-fluid mt--7"
>
<!-- Table -->
<div
class=
"row"
>
<div
class=
"col"
>
<div
class=
"card shadow"
>
<div
class=
"card-header bg-transparent"
>
<h3
class=
"mb-0"
>
User Settings
</h3>
</div>
<div
class=
"card-body"
>
<form
action=
"/settings"
method=
"post"
id=
"settings"
>
<div
class=
"form-group"
>
<label>
Name:
</label><br>
<input
type=
"text"
maxlength=
"30"
class=
"form-control"
id=
"name"
name=
"name"
value=
"{{ user }}"
style=
"pointer-events: none;"
><br>
</div>
<br>
<div
class=
"form-group"
>
<div
class=
"input-group input-group-alternative"
>
<div
class=
"input-group-prepend"
>
<span
class=
"input-group-text"
><i
class=
"ni ni-lock-circle-open"
></i></span>
</div>
<input
class=
"form-control"
placeholder=
"Password"
type=
"password"
minlength=
"8"
id=
"password"
name=
"password"
onkeyup=
"return validate_password();"
>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"input-group input-group-alternative"
>
<div
class=
"input-group-prepend"
>
<span
class=
"input-group-text"
><i
class=
"ni ni-lock-circle-open"
></i></span>
</div>
<input
class=
"form-control"
placeholder=
"Repeat password"
type=
"password"
minlength=
"8"
id=
"rpassword"
name=
"rpassword"
onkeyup=
"return validate_password();"
>
</div>
</div>
<div
class=
"text-muted font-italic"
><small>
Required password strength:
<span
class=
"text-success font-weight-700"
>
At least 8 characters.
</span></small></div>
<div
class=
"text-muted font-italic"
><small
id=
"passvalidation"
></small></div>
<br>
</form>
<div
class=
"row"
style=
"margin-top: 30px;"
>
<div
class=
"col-lg-3"
>
<button
type=
"submit"
form=
"settings"
id=
"submit"
class=
"btn btn-primary btn-block"
>
Save
</button>
</div>
<div
class=
"col-lg-3"
>
</div>
<div
class=
"col-lg-3"
>
</div>
<div
class=
"col-lg-3"
>
<button
type=
"button"
class=
"btn btn-danger btn-block"
data-toggle=
"modal"
data-target=
"#exampleModal"
>
Delete
</button>
<div
class=
"modal fade"
id=
"exampleModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"exampleModalLabel"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
id=
"exampleModalLabel"
>
Are you sure?
</h5>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
</div>
<div
class=
"modal-body"
>
This action will remove permanently the account, applications and all its devices with their corresponding data.
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-secondary"
data-dismiss=
"modal"
>
Close
</button>
<a
href=
"/delete-account?name={{ user }}"
><button
type=
"button"
class=
"btn btn-danger"
>
Delete Account
</button></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block script %}
<script
type=
"text/javascript"
>
var
password
=
document
.
getElementById
(
"
password
"
);
var
rpassword
=
document
.
getElementById
(
"
rpassword
"
);
function
validate_password
()
{
if
(
password
.
value
!=
rpassword
.
value
)
{
$
(
"
#passvalidation
"
).
html
(
"
<span class='text-danger font-weight-700'>Passwords do not match.</span>
"
);
$
(
"
#submit
"
).
prop
(
"
disabled
"
,
true
);
}
else
{
$
(
"
#passvalidation
"
).
html
(
"
<span class='text-success font-weight-700'>Passwords match.</span>
"
);
$
(
"
#submit
"
).
prop
(
"
disabled
"
,
false
);
}
}
</script>
{% endblock %}
app/app/views.py
View file @
385aadfd
...
...
@@ -647,10 +647,10 @@ def user():
return
render_template
(
'old/public/index.html'
)
@
app
.
route
(
'/
user-
delete'
)
def
user_
delete
():
@
app
.
route
(
'/delete
-account
'
)
def
delete
_account
():
user
=
ud
.
get
(
request
.
args
.
get
(
'name'
))
if
user
[
0
]
and
user
[
1
][
2
]
!=
'admin'
and
session
[
'role'
]
==
'admin'
:
if
user
[
0
]
and
user
[
1
][
2
]
!=
'admin'
:
app_list
=
ad
.
get_list
(
user
[
1
][
0
])
res
=
(
True
,)
...
...
@@ -678,19 +678,17 @@ def user_delete():
flash
(
'Error: {}'
.
format
(
res
[
1
]),
'danger'
)
return
render_template
(
'old/admin/user.html'
,
username
=
user
[
1
][
0
])
else
:
return
redirect
(
url_for
(
'administraion'
))
flash
(
'User {} was successfully deleted'
.
format
(
request
.
args
.
get
(
'name'
)),
'success'
)
return
redirect
(
url_for
(
'login'
))
else
:
flash
(
'Warning: the user is admin or does not exist.'
,
'
warning
'
)
return
redirect
(
url_for
(
'
index
'
))
flash
(
'Warning: the user is admin or does not exist.'
,
'
danger
'
)
return
redirect
(
url_for
(
'
settings
'
))
@
app
.
route
(
'/settings'
,
methods
=
[
'GET'
,
'POST'
])
def
settings
():
if
request
.
method
==
'GET'
:
if
session
[
'role'
]
==
'admin'
:
return
render_template
(
'old/admin/settings.html'
,
username
=
session
[
'name'
])
else
:
return
render_template
(
'old/public/settings.html'
,
username
=
session
[
'name'
])
return
render_template
(
'new/public/settings.html'
,
user
=
session
[
'name'
])
else
:
if
request
.
form
[
'name'
]
!=
session
[
'name'
]:
res
=
ud
.
update_name
(
session
[
'name'
],
request
.
form
[
'name'
])
...
...
@@ -704,13 +702,8 @@ def settings():
if
not
res
[
0
]:
flash
(
'Error: {}'
.
format
(
res
[
1
]),
'danger'
)
return
redirect
(
request
.
url
)
if
session
[
'role'
]
==
'admin'
:
if
request
.
form
.
getlist
(
'users_signup'
)
and
request
.
form
.
getlist
(
'users_signup'
)[
0
]
==
'us'
:
app
.
config
[
'USERS_SIGNUP'
]
=
True
else
:
app
.
config
[
'USERS_SIGNUP'
]
=
False
flash
(
'Settings successfully saved.'
,
'success'
)
return
redirect
(
request
.
url
)
...
...
app/app/views_admin.py
View file @
385aadfd
...
...
@@ -516,3 +516,62 @@ def administration_users_new_user():
else
:
return
redirect
(
url_for
(
'administration/users'
,
name
=
username
))
@
app
.
route
(
'/administration/users/<name>/settings'
,
methods
=
[
'GET'
,
'POST'
])
@
restricted
(
access_level
=
'admin'
)
def
administration_users_user_settings
(
name
):
if
request
.
method
==
'GET'
:
return
render_template
(
'new/admin/user-settings.html'
,
user
=
name
)
else
:
if
request
.
form
[
'name'
]
!=
name
:
res
=
ud
.
update_name
(
name
,
request
.
form
[
'name'
])
if
not
res
[
0
]:
flash
(
'Error: {}'
.
format
(
res
[
1
]),
'danger'
)
return
redirect
(
request
.
url
);
if
request
.
form
[
'password'
]
!=
''
:
res
=
ud
.
update_password
(
name
,
request
.
form
[
'password'
].
encode
(
'utf-8'
))
if
not
res
[
0
]:
flash
(
'Error: {}'
.
format
(
res
[
1
]),
'danger'
)
return
redirect
(
request
.
url
)
flash
(
'Settings successfully saved.'
,
'success'
)
return
redirect
(
request
.
url
)
@
app
.
route
(
'/administration/users/<name>/delete-account'
)
@
restricted
(
access_level
=
'admin'
)
def
administration_users_user_delete_account
(
name
):
user
=
ud
.
get
(
name
)
if
user
[
0
]
and
user
[
1
][
2
]
!=
'admin'
:
app_list
=
ad
.
get_list
(
user
[
1
][
0
])
res
=
(
True
,)
if
app_list
[
0
]:
for
app
in
app_list
[
1
]:
devs
=
dd
.
get_list
(
app
[
1
])
for
dev
in
devs
[
1
]:
res
=
data
.
delete_table
(
app
[
1
],
dev
[
1
])
if
not
res
[
0
]:
break
if
res
[
0
]:
res
=
dd
.
delete_table
(
app
[
1
])
if
res
[
0
]:
res
=
ad
.
delete
(
app
[
1
])
if
not
res
[
0
]:
break
if
res
[
0
]:
res
=
ud
.
delete
(
user
[
1
][
0
])
if
not
res
[
0
]:
flash
(
'Error: {}'
.
format
(
res
[
1
]),
'danger'
)
return
render_template
(
'new/admin/user-settings.html'
,
user
=
name
)
else
:
flash
(
'User {} was successfully deleted'
.
format
(
name
),
'success'
)
return
redirect
(
url_for
(
'administration_users'
))
else
:
flash
(
'Warning: the user is admin or does not exist.'
,
'danger'
)
return
redirect
(
url_for
(
'administration_users_user_settings'
,
name
=
name
))
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