Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eduGAIN Connectivity Check
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
edugain
eduGAIN Connectivity Check
Commits
47759bb4
Commit
47759bb4
authored
5 years ago
by
Marco Malavolti
Browse files
Options
Downloads
Patches
Plain Diff
Fixed API and added Calendar for the input date value
parent
b2f7a796
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api.py
+79
-39
79 additions, 39 deletions
api.py
web/index.php
+5
-3
5 additions, 3 deletions
web/index.php
web/script.js
+10
-2
10 additions, 2 deletions
web/script.js
with
94 additions
and
44 deletions
api.py
+
79
−
39
View file @
47759bb4
...
...
@@ -5,6 +5,7 @@ import logging
import
re
from
eccs2properties
import
DAY
,
ECCS2LOGSDIR
,
ECCS2OUTPUTDIR
from
flask.logging
import
default_handler
from
flask
import
Flask
,
request
,
jsonify
from
flask_restful
import
Resource
,
Api
from
utils
import
getLogger
...
...
@@ -13,11 +14,7 @@ app = Flask(__name__)
api
=
Api
(
app
)
# /eccs2/test
class
Test
(
Resource
):
def
get
(
self
):
app
.
logger
.
info
(
"
Test Passed!
"
)
return
{
'
test
'
:
'
It Works!
'
}
### Functions
# Build Email Addresses Link for ECCS2 Web Gui
def
buildEmailAddress
(
listContacts
):
...
...
@@ -29,72 +26,115 @@ def buildEmailAddress(listContacts):
return
hrefList
### Classes
# Test
class
Test
(
Resource
):
def
get
(
self
):
return
{
'
test
'
:
'
It Works!
'
}
# /eccs2/api/eccsresults
class
EccsResults
(
Resource
):
def
get
(
self
):
app
.
logger
.
info
(
"
Request
'
EccsResults
'"
)
file_path
=
"
%s/eccs2_%s.log
"
%
(
ECCS2OUTPUTDIR
,
DAY
)
date
=
DAY
pretty
=
0
status
=
None
idp
=
None
reg_auth
=
None
eccsDataTable
=
False
if
'
eccsdt
'
in
request
.
args
:
eccsDataTable
=
True
if
'
date
'
in
request
.
args
:
app
.
logger
.
info
(
"'
date
'
parameter inserted
"
)
date
=
request
.
args
[
'
date
'
]
file_path
=
"
%s/eccs2_%s.log
"
%
(
ECCS2OUTPUTDIR
,
date
)
if
'
pretty
'
in
request
.
args
:
app
.
logger
.
info
(
"'
pretty
'
parameter inserted
"
)
pretty
=
request
.
args
[
'
pretty
'
]
if
'
status
'
in
request
.
args
:
app
.
logger
.
info
(
"'
status
'
parameter inserted
"
)
status
=
request
.
args
[
'
status
'
]
status
=
request
.
args
[
'
status
'
].
upper
()
if
(
status
not
in
[
'
OK
'
,
'
DISABLED
'
,
'
ERROR
'
]):
return
"
Incorrect status format, should be
'
ok
'
,
'
disabled
'
,
'
error
'"
if
'
idp
'
in
request
.
args
:
app
.
logger
.
info
(
"'
idp
'
parameter inserted
"
)
idp
=
request
.
args
[
'
idp
'
]
app
.
logger
.
info
(
idp
)
fo
=
open
(
file_path
,
"
r
"
,
encoding
=
"
utf-8
"
)
result
=
[]
lines
=
fo
.
readlines
()
with
open
(
file_path
,
"
r
"
,
encoding
=
"
utf-8
"
)
as
fo
:
lines
=
fo
.
readlines
()
found
=
False
for
line
in
lines
:
aux
=
json
.
loads
(
line
)
if
(
idp
==
aux
[
'
entityID
'
]):
found
=
True
if
(
found
==
False
):
return
"
Identity Provider not found with the entityID: %s
"
%
idp
if
'
reg_auth
'
in
request
.
args
:
reg_auth
=
request
.
args
[
'
reg_auth
'
]
with
open
(
file_path
,
"
r
"
,
encoding
=
"
utf-8
"
)
as
fo
:
lines
=
fo
.
readlines
()
found
=
False
for
line
in
lines
:
aux
=
json
.
loads
(
line
)
if
(
reg_auth
==
aux
[
'
registrationAuthority
'
]):
found
=
True
if
(
found
==
False
):
return
"
Identity Providers not found with the Registration Authority: %s
"
%
reg_auth
lines
=
[]
results
=
[]
with
open
(
file_path
,
"
r
"
,
encoding
=
"
utf-8
"
)
as
fo
:
lines
=
fo
.
readlines
()
for
line
in
lines
:
# Strip the line feed and carriage return characters
line
=
line
.
rstrip
(
"
\n\r
"
)
print
(
line
)
# Loads the json line into aux
aux
=
json
.
loads
(
line
)
aux
[
'
date
'
]
=
date
aux
[
'
contacts
'
][
'
technical
'
]
=
buildEmailAddress
(
aux
[
'
contacts
'
][
'
technical
'
])
aux
[
'
contacts
'
][
'
support
'
]
=
buildEmailAddress
(
aux
[
'
contacts
'
][
'
support
'
])
# If the results are for ECCS2 DataTable, otherwise... remove only "mailto:" prefix
if
(
eccsDataTable
):
aux
[
'
contacts
'
][
'
technical
'
]
=
buildEmailAddress
(
aux
[
'
contacts
'
][
'
technical
'
])
aux
[
'
contacts
'
][
'
support
'
]
=
buildEmailAddress
(
aux
[
'
contacts
'
][
'
support
'
])
else
:
aux
[
'
contacts
'
][
'
technical
'
]
=
aux
[
'
contacts
'
][
'
technical
'
].
replace
(
"
mailto:
"
,
""
)
aux
[
'
contacts
'
][
'
support
'
]
=
aux
[
'
contacts
'
][
'
support
'
].
replace
(
"
mailto:
"
,
""
)
if
(
idp
and
status
):
app
.
logger
.
info
(
"
eccsresults: check for
'
idp
'
:
'
%s
'
with
'
status
'
:
'
%s
'"
%
(
idp
,
status
))
if
(
idp
==
aux
[
'
entityID
'
]
and
status
==
aux
[
'
status
'
]):
result
.
append
(
aux
)
results
.
append
(
aux
)
elif
(
reg_auth
and
status
):
if
(
reg_auth
==
aux
[
'
registrationAuthority
'
]
and
status
==
aux
[
'
status
'
]):
results
.
append
(
aux
)
elif
(
idp
):
app
.
logger
.
info
(
"
eccsresults: results for IdP:
'
%s
'
.
"
%
idp
)
if
(
re
.
search
(
"
.*.
"
+
idp
+
"
.*.
"
,
aux
[
'
entityID
'
],
re
.
IGNORECASE
)):
result
.
append
(
aux
)
if
(
idp
==
aux
[
'
entityID
'
]):
results
.
append
(
aux
)
elif
(
reg_auth
):
if
(
reg_auth
==
aux
[
'
registrationAuthority
'
]):
results
.
append
(
aux
)
elif
(
status
):
if
(
status
==
aux
[
'
status
'
]):
result
.
append
(
aux
)
result
s
.
append
(
aux
)
else
:
result
.
append
(
aux
)
results
.
append
(
aux
)
return
jsonify
(
results
)
if
(
pretty
):
pp_json
=
json
.
dumps
(
result
,
indent
=
4
,
sort_keys
=
True
)
return
jsonify
(
pp_json
)
else
:
return
jsonify
(
result
)
api
.
add_resource
(
Test
,
'
/eccs/test
'
)
# Route_1
api
.
add_resource
(
EccsResults
,
'
/eccs/eccsresults
'
)
# Route_2
# /eccs2/api/fedstats
class
FedStats
(
Resource
):
def
get
(
self
):
return
{
'
fedstats
'
:
'
It Works!
'
}
# Routes
api
.
add_resource
(
Test
,
'
/test
'
)
# Route_1
api
.
add_resource
(
EccsResults
,
'
/eccsresults
'
)
# Route_2
api
.
add_resource
(
FedStats
,
'
/fedstats
'
)
# Route_3
if
__name__
==
'
__main__
'
:
app
.
config
[
'
JSON_AS_ASCII
'
]
=
False
app
.
logger
=
getLogger
(
"
eccs2api.log
"
,
ECCS2LOGSDIR
,
"
w
"
,
"
INFO
"
)
#app.config['JSON_AS_ASCII'] = True
#app.logger.removeHandler(default_handler)
#app.logger = getLogger("eccs2api.log", ECCS2LOGSDIR, "w", "INFO")
app
.
run
(
port
=
'
5002
'
)
This diff is collapsed.
Click to expand it.
web/index.php
+
5
−
3
View file @
47759bb4
...
...
@@ -15,9 +15,11 @@
<body>
<hr>
<div
id=
"status"
>
<input
type=
"checkbox"
name=
"status"
value=
"ERROR"
>
ERROR
<input
type=
"checkbox"
name=
"status"
value=
"OK"
>
OK
<input
type=
"checkbox"
name=
"status"
value=
"DISABLE"
>
DISABLE
<input
type=
"checkbox"
name=
"status"
value=
"ERROR"
>
ERROR
</input>
<input
type=
"checkbox"
name=
"status"
value=
"OK"
>
OK
</input>
<input
type=
"checkbox"
name=
"status"
value=
"DISABLE"
>
DISABLE
</input>
<button
style=
"float:right;"
onclick=
"getPastResults()"
>
Go
</button>
<input
style=
"float:right;"
type=
"date"
id=
"myDate"
min=
"2020-07-03"
max=
"
<?php
echo
date
(
"Y-m-d"
)
?>
"
value=
"
<?php
echo
date
(
"Y-m-d"
)
?>
"
/>
</div>
<hr>
<button
id=
"btn-show-all-children"
type=
"button"
>
Expand All
</button>
...
...
This diff is collapsed.
Click to expand it.
web/script.js
+
10
−
2
View file @
47759bb4
// Global URL
var
url
=
"
/eccs2/api/eccsresults?eccdt=1
"
;
var
table
;
// use URL constructor and return hostname
function
getHostname
(
url
)
{
const
urlNew
=
new
URL
(
url
);
...
...
@@ -51,11 +55,15 @@ function format ( d ) {
'
</table>
'
;
}
function
getPastResults
()
{
url
=
"
/eccs2/api/eccsresults?eccsdt=1&date=
"
+
document
.
getElementById
(
"
myDate
"
).
value
;
table
.
ajax
.
url
(
url
).
load
();
}
$
(
document
).
ready
(
function
()
{
var
table
=
$
(
'
#eccstable
'
).
DataTable
(
{
table
=
$
(
'
#eccstable
'
).
DataTable
(
{
"
ajax
"
:
{
"
url
"
:
"
data.json
"
,
"
url
"
:
url
,
"
dataSrc
"
:
""
},
"
lengthMenu
"
:
[[
10
,
20
,
30
,
40
,
50
,
100
,
-
1
],
[
10
,
20
,
30
,
40
,
50
,
100
,
"
All
"
]],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment