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
e3daac7d
Commit
e3daac7d
authored
May 12, 2020
by
Vladislav Rykov
Browse files
alarms in progress
parent
c6c61238
Changes
7
Hide whitespace changes
Inline
Side-by-side
app/app/dao/notification/__init__.py
0 → 100644
View file @
e3daac7d
app/app/templates/public/alarms.html
0 → 100644
View file @
e3daac7d
{% extends 'layout.html' %}
{% block title %} Application Alarms: {% endblock %}
{% block content %}
<div
class=
"row"
>
<div
class=
"col-md-3"
>
<div
class=
"clickback"
>
<span
class=
"glyphicon glyphicon-arrow-left"
></span>
<p><a
class=
"backlink"
onclick=
"history.back(-1)"
></a></p>
</div>
</div>
<div
class=
"col-md-6"
>
{% if alarm_list %}
<div>
<table
class=
"table"
>
<thead>
<th>
Name
</th>
<th>
Description
</th>
<th>
</th>
</thead>
<tbody>
{% for a in alarm_list %}
<tr>
<th>
{{ a[3] }}
</th>
<th>
{{ a[4] }}
</th>
<th>
<a
href=
"/alarm-rm?id={{ c[0] }}"
>
<span
class=
"glyphicon glyphicon-remove"
</
span
>
</a>
</th>
</tr>
{% endfor %}
</tbody>
</table>
<a
href=
"/new-alarm"
><button
class=
"btn btn-primary"
type=
"submit"
>
Create New Alarm
</button></a>
</div>
{% else %}
<center>
There are no alarms for given application.
</center>
{% endif %}
</div>
</div>
{% endblock %}
app/app/templates/public/app.html
View file @
e3daac7d
...
...
@@ -47,6 +47,7 @@
<center>
<a
href=
"/add-dev"
><button
type=
"submit"
class=
"btn btn-primary"
>
Add Device
</button></a>
<a
href=
"/alarms"
><button
type=
"submit"
class
"
btn
btn-primary
"
>
Alarms
</button></a>
<a
href=
"/delete-app"
><button
type=
"submit"
class=
"btn btn-danger"
onclick=
"return confirm('Are you sure? It will remove all devices and data.');"
>
Delete Application
</button></a>
</center>
<br>
...
...
app/app/views.py
View file @
e3daac7d
...
...
@@ -498,5 +498,13 @@ def dev_data(var, dest, page):
return
t
@
app
.
route
(
'/alarms'
)
def
alarms
():
if
name
in
session
:
return
render_template
(
'public/alarms.html'
)
else
:
return
redirect
(
url_for
(
'index'
))
def
pend_delete_all_ack
():
pend
.
delete_all_ack
()
db-e.sql
0 → 100644
View file @
e3daac7d
CREATE
TABLE
public
.
notifications
(
id
VARCHAR
(
10
)
UNIQUE
NOT
NULL
,
app_key
VARCHAR
(
30
)
UNIQUE
NOT
NULL
,
dev_id
NUMERIC
(
3
)
NOT
NULL
,
name
VARCHAR
(
50
)
NOT
NULL
,
description
VARCHAR
(
300
),
action_type
VARCHAR
(
20
)
NOT
NULL
,
action
VARCHAR
(
200
)
NOT
NULL
);
CREATE
TABLE
public
.
notifications_queue
(
nf_id
VARCHAR
(
10
)
NOT
NULL
,
app_key
VARCHAR
(
30
)
NOT
NULL
,
dev_id
NUMERIC
(
3
)
NOT
NULL
);
ALTER
TABLE
ONLY
public
.
notifications
ADD
CONSTRAINT
notifications_pkey
PRIMARY
KEY
(
id
,
app_key
,
dev_id
);
ALTER
TABLE
ONLY
public
.
notifications_queue
ADD
CONSTRAINT
notifications_queue_pkey
PRIMARY
KEY
(
nf_id
,
app_key
,
dev_id
);
ALTER
TABLE
ONLY
public
.
notifications
ADD
CONSTRAINT
notifications_app_key_fkey
FOREIGN
KEY
(
app_key
)
REFERENCES
public
.
applications
(
app_key
);
ALTER
TABLE
ONLY
public
.
notifications_queue
ADD
CONSTRAINT
notifications_queue_app_key_fkey
FOREIGN
KEY
(
app_key
)
REFERENCES
public
.
notifications
(
app_key
);
ALTER
TABLE
ONLY
public
.
notifications_queue
ADD
CONSTRAINT
notifications_queue_nf_id_fkey
FOREIGN
KEY
(
nf_id
)
REFERENCES
public
.
notifications
(
id
);
db-t.sql
0 → 100644
View file @
e3daac7d
CREATE
OR
REPLACE
FUNCTION
nf_4e662f03_1_aaaaa
()
RETURNS
trigger
AS
$
BODY
$
BEGIN
IF
(
NEW
.
data
->>
'temperature'
)::
int
>
70
THEN
INSERT
INTO
notifications_queue
VALUES
(
'aaaaa'
,
'4e662f03'
,
1
);
END
IF
;
RETURN
NEW
;
END
;
$
BODY
$
LANGUAGE
plpgsql
VOLATILE
COST
100
;
CREATE
TRIGGER
tr_4e662f03_1_aaaaa
AFTER
INSERT
on
dev_4e662f03_1
FOR
EACH
ROW
EXECUTE
PROCEDURE
nf_4e662f03_1_aaaaa
();
db.sql
View file @
e3daac7d
...
...
@@ -41,7 +41,7 @@ SET default_with_oids = false;
CREATE
TABLE
public
.
applications
(
name
character
varying
(
30
)
NOT
NULL
,
app_key
character
varying
(
30
)
NOT
NULL
,
username
character
varying
(
30
),
username
character
varying
(
30
)
NOT
NULL
,
description
character
varying
(
200
)
);
...
...
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