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
c18005e8
Commit
c18005e8
authored
May 14, 2020
by
Vladislav Rykov
Browse files
notifiaction creation success
parent
ad155bf6
Changes
7
Hide whitespace changes
Inline
Side-by-side
app/__pycache__/config.cpython-37.pyc
View file @
c18005e8
No preview for this file type
app/app/__pycache__/views.cpython-37.pyc
View file @
c18005e8
No preview for this file type
app/app/templates/public/.new-alert.html.swp
0 → 100644
View file @
c18005e8
File added
app/app/templates/public/alerts.html
View file @
c18005e8
...
...
@@ -12,7 +12,7 @@
</div>
</div>
<div
class=
"col-md-6"
>
{% if al
arm
_list %}
{% if al
ert
_list %}
<div>
<table
class=
"table"
>
<thead>
...
...
app/app/templates/public/new-alert.html
View file @
c18005e8
...
...
@@ -41,7 +41,7 @@
<h4>
THEN
</h4>
<h5>
Send email to
</h5>
<input
form=
"alertform"
class=
"form-control"
type=
"email"
id=
"email"
name=
"email"
placeholder=
"Type email..."
>
<input
form=
"alertform"
class=
"form-control"
type=
"email"
id=
"
alert
email"
name=
"
alert
email"
placeholder=
"Type email..."
>
<br>
<div
class=
"form-group"
>
<button
form=
"alertform"
type=
"submit"
class=
"btn btn-primary"
>
Create Alert
</button>
...
...
@@ -72,7 +72,7 @@
}
function
onvar
()
{
if
(
!
document
.
getElementById
(
"
operation
"
))
{
$
(
"
#alertform
"
).
append
(
"
<select class='form-control notifelem' name='operaton' id='operation' onchange='onop()' required><option default>CHANGES</option><option>></option><option>>=</option><option><</option><option><=</option><option>==</option></select>
"
);
$
(
"
#alertform
"
).
append
(
"
<select class='form-control notifelem' name='operat
i
on' id='operation' onchange='onop()' required><option default>CHANGES</option><option>></option><option>>=</option><option><</option><option><=</option><option>==</option></select>
"
);
}
else
{
var
var_sel
=
document
.
getElementById
(
"
varname
"
);
var
sel_var
=
var_sel
.
options
[
var_sel
.
selectedIndex
].
value
;
...
...
app/app/views.py
View file @
c18005e8
...
...
@@ -130,6 +130,8 @@ def app_():
ap
=
ad
.
get
(
session
[
'appkey'
])
devs
=
dd
.
get_list
(
ap
[
1
][
1
])
session
[
'appname'
]
=
ap
[
1
][
0
]
if
session
[
'role'
]
==
'admin'
or
session
[
'name'
]
==
ap
[
1
][
2
]:
return
render_template
(
'public/app.html'
,
app
=
ap
[
1
],
devs
=
devs
[
1
])
...
...
@@ -535,7 +537,31 @@ def new_alert():
@
app
.
route
(
'/alert'
,
methods
=
[
'POST'
])
def
alert
():
pass
if
'name'
in
session
:
if
request
.
method
==
'POST'
:
# create new notification
nid
=
misc
.
rand_str
(
app
.
config
[
'NID_LENGTH'
]).
decode
(
'utf-8'
)
dev
=
dd
.
get
(
session
[
'appkey'
],
request
.
form
[
'devid'
])
try
:
desc_ext
=
request
.
form
[
'alertdesc'
]
+
' (Application '
+
session
[
'appname'
]
+
' => '
+
dev
[
1
][
0
]
+
'.'
+
request
.
form
[
'varname'
]
+
' '
+
request
.
form
[
'operation'
]
+
' '
+
request
.
form
[
'avalue'
]
+
')'
except
:
desc_ext
=
request
.
form
[
'alertdesc'
]
+
' (Application '
+
session
[
'appname'
]
+
' => '
+
dev
[
1
][
0
]
+
'.'
+
request
.
form
[
'varname'
]
+
' '
+
request
.
form
[
'operation'
]
+
')'
res
=
nfs
.
create
(
nid
,
session
[
'appkey'
],
request
.
form
[
'devid'
],
request
.
form
[
'alertname'
],
desc_ext
,
'alert'
,
request
.
form
[
'alertemail'
])
if
res
[
0
]:
print
(
'notification created'
)
return
redirect
(
url_for
(
'alerts'
))
else
:
flash
(
'Error creating new notification: {}'
.
format
(
res
[
1
]),
'danger'
)
return
redirect
(
url_for
(
'alerts'
))
# create new function and trigger
else
:
return
redirect
(
url_for
(
'index'
))
else
:
return
redirect
(
url_for
(
'index'
))
@
app
.
route
(
'/alert-rm'
)
def
alarm_rm
():
...
...
@@ -543,10 +569,10 @@ def alarm_rm():
res
=
nfs
.
delete
(
session
[
'appkey'
],
request
.
args
.
get
(
'id'
))
if
res
[
0
]:
flash
(
'Al
arm
removed'
,
'success'
)
flash
(
'Al
ert
removed'
,
'success'
)
return
redirect
(
url_for
(
'alerts'
))
else
:
flash
(
'Al
arm
cannot be removed : {}'
.
format
(
res
[
1
]),
'danger'
)
flash
(
'Al
ert
cannot be removed : {}'
.
format
(
res
[
1
]),
'danger'
)
return
redirect
(
url_for
(
'alerts'
))
else
:
return
redirect
(
url_for
(
'index'
))
...
...
app/config.py
View file @
c18005e8
...
...
@@ -14,6 +14,7 @@ class Config(object):
REMEMBER_COOKIE_SECURE
=
True
APPKEY_LENGTH
=
8
NID_LENGTH
=
5
DATA_DOWNLOAD_DIR
=
'data'
DATA_DOWNLOAD_DIR_OS
=
'app/data'
...
...
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