-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #158. Work in progress on the User Dashboard.
- Loading branch information
Showing
13 changed files
with
313 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
teraserver/python/services/VideoRehabService/Views/UserDashboard.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from flask.views import MethodView | ||
from flask import render_template, request | ||
from flask_babel import gettext | ||
from opentera.services.ServiceAccessManager import ServiceAccessManager, current_user_client, current_login_type, \ | ||
LoginType | ||
|
||
|
||
class UserDashboard(MethodView): | ||
|
||
def __init__(self, *args, **kwargs): | ||
self.flaskModule = kwargs.get('flaskModule', None) | ||
|
||
@ServiceAccessManager.token_required(allow_static_tokens=False, allow_dynamic_tokens=True) | ||
def get(self): | ||
# print('get') | ||
|
||
hostname = self.flaskModule.config.service_config['hostname'] | ||
port = self.flaskModule.config.service_config['port'] | ||
backend_hostname = self.flaskModule.config.backend_config['hostname'] | ||
backend_port = self.flaskModule.config.backend_config['port'] | ||
if 'X_EXTERNALSERVER' in request.headers: | ||
backend_hostname = request.headers['X_EXTERNALSERVER'] | ||
|
||
if 'X_EXTERNALPORT' in request.headers: | ||
backend_port = request.headers['X_EXTERNALPORT'] | ||
|
||
if current_login_type != LoginType.USER_LOGIN: | ||
return render_template('user_error.html', backend_hostname=backend_hostname, | ||
backend_port=backend_port, | ||
error_msg=gettext('Only users can access this page. Sorry.')) | ||
|
||
user_name = gettext('Anonymous') | ||
if current_user_client: | ||
user_info = current_user_client.get_user_info() | ||
if user_info and 'user_name' in user_info: | ||
user_name = user_info['user_name'] | ||
|
||
return render_template('user_dashboard.html', hostname=hostname, port=port, | ||
backend_hostname=backend_hostname, backend_port=backend_port, | ||
user_name=user_name, | ||
user_token=current_user_client.user_token, | ||
user_uuid=current_user_client.user_uuid | ||
) |
35 changes: 35 additions & 0 deletions
35
teraserver/python/services/VideoRehabService/Views/UserError.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from flask.views import MethodView | ||
from flask import render_template, request | ||
from opentera.services.ServiceAccessManager import ServiceAccessManager, current_user_client | ||
from flask_babel import gettext | ||
|
||
|
||
class UserError(MethodView): | ||
|
||
def __init__(self, *args, **kwargs): | ||
self.flaskModule = kwargs.get('flaskModule', None) | ||
|
||
@ServiceAccessManager.token_required(allow_static_tokens=False, allow_dynamic_tokens=True) | ||
def get(self): | ||
backend_hostname = self.flaskModule.config.backend_config['hostname'] | ||
backend_port = self.flaskModule.config.backend_config['port'] | ||
|
||
if 'X_EXTERNALSERVER' in request.headers: | ||
backend_hostname = request.headers['X_EXTERNALSERVER'] | ||
|
||
if 'X_EXTERNALPORT' in request.headers: | ||
backend_port = request.headers['X_EXTERNALPORT'] | ||
|
||
if 'error' in request.args: | ||
error_msg = request.args['error'] | ||
else: | ||
error_msg = gettext('Unknown error') | ||
|
||
# Get participant information | ||
if current_user_client: | ||
return render_template('user_error.html', backend_hostname=backend_hostname, | ||
backend_port=backend_port, | ||
user_token=current_user_client.user_token, | ||
error_msg=error_msg) | ||
else: | ||
return 'Unauthorized', 403 |
37 changes: 37 additions & 0 deletions
37
teraserver/python/services/VideoRehabService/static/css/participant_style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.topbar { | ||
position:absolute; | ||
top:0; | ||
left:0; | ||
width:100%; | ||
height:50px; | ||
border:0; | ||
} | ||
|
||
.logo { | ||
display:block; | ||
position:absolute; | ||
} | ||
|
||
.status-zone { | ||
display:block; | ||
position:absolute; | ||
top:10px; | ||
right:0px; | ||
padding-right:12.5px; | ||
} | ||
|
||
.name-zone { | ||
line-height:50px; | ||
display:block; | ||
vertical-align:middle; | ||
height:50px; | ||
margin:auto; | ||
} | ||
|
||
.main-frame { | ||
position:absolute; | ||
top:50px; | ||
left:0; | ||
width:100%; | ||
border:0; | ||
} |
38 changes: 38 additions & 0 deletions
38
teraserver/python/services/VideoRehabService/static/css/user_style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.topbar { | ||
position:absolute; | ||
top:0; | ||
left:0; | ||
width:100%; | ||
height:50px; | ||
border:0; | ||
background-color: #647E85; | ||
} | ||
|
||
.logo { | ||
display:block; | ||
position:absolute; | ||
} | ||
|
||
.status-zone { | ||
display:block; | ||
position:absolute; | ||
top:10px; | ||
right:0px; | ||
padding-right:12.5px; | ||
} | ||
|
||
.name-zone { | ||
line-height:50px; | ||
display:block; | ||
vertical-align:middle; | ||
height:50px; | ||
margin:auto; | ||
} | ||
|
||
.main-frame { | ||
position:absolute; | ||
top:50px; | ||
left:0; | ||
width:100%; | ||
border:0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
teraserver/python/services/VideoRehabService/templates/user_dashboard.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>{{ gettext('OpenTera - User Video Dashboard') }}</title> | ||
|
||
<link href="./static/images/favicon.ico" rel="icon" type="image/x-icon" /> | ||
<link href="./static/images/favicon.ico" rel="shortcut icon" type="image/x-icon" /> | ||
|
||
<script src="./static/js/bowser.js"></script> | ||
<script src="/static/js/jquery-3.5.1.min.js"></script> | ||
|
||
<script src="./static/js/opentera.js"></script> <!-- Always include first --> | ||
<script src="./static/js/opentera_websockets.js"></script> | ||
<script src="./static/js/opentera_login.js"></script> | ||
<script src="./static/js/opentera_dashboard.js"></script> | ||
|
||
<link href="./static/css/fontawesome.min.css" rel="stylesheet" /> | ||
<link rel="stylesheet" href="./static/bootstrap/css/bootstrap.min.css" /> | ||
<link rel="stylesheet" href="./static/css/main_style.css" /> | ||
<link rel="stylesheet" href="./static/css/user_style.css" /> | ||
|
||
<script src="./static/bootstrap/js/bootstrap.min.js"></script> | ||
|
||
<!-- Translations --> | ||
<script> | ||
const str_unsupported_browser_title = "{{ gettext('Unsupported browser detected') }}"; | ||
const str_unsupported_browser = "{{ gettext('Your browser is not supported. Session might or might not work, but it is recommended to user another browser.') }}"; | ||
const str_your_browser = "{{ gettext('Your browser') }}"; | ||
const str_supported_browsers = "{{ gettext('Supported browsers') }}"; | ||
const str_cant_connect = "{{ gettext('Unable to connect') }}"; | ||
const str_cant_connect_reasons = "{{ gettext('Your access might have been disabled or you might be already logged in on another device') }}"; | ||
const str_session_complete = "{{ gettext('Your session is now over. You may now logout or close this page.') }}"; | ||
</script> | ||
|
||
<!-- Server informations --> | ||
<script> | ||
let backend_hostname = "{{ backend_hostname }}"; | ||
let backend_port = {{ backend_port }}; | ||
let user_token = "{{ user_token }}"; | ||
let user_name = "{{ user_name }}"; | ||
let user_uuid = "{{ user_uuid }}"; | ||
|
||
const browser = bowser.getParser(window.navigator.userAgent); | ||
window.onload = function() { | ||
console.log('Page loaded. Ready to start!'); | ||
init_dashboard(backend_hostname, backend_port); | ||
//init_system(); | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<!-- ErrorDialog --> | ||
<div class="modal fade" id="errorDialog" tabindex="-1" role="dialog" aria-labelledby="errorDialogCenterTitle" | ||
aria-hidden="true"> | ||
<div class="modal-dialog modal-dialog-centered" role="document"> | ||
<div class="modal-content"> | ||
<div class="modal-header modal-header-error"> | ||
<h5 class="modal-title" id="errorDialogLongTitle" data-i18n="errorDialog.title">{{ gettext('Error') }}</h5> | ||
<!--<button type="button" class="close" data-dismiss="modal" aria-label="Fermer"> | ||
<span aria-hidden="true" style="color: white;">×</span> | ||
</button>--> | ||
</div> | ||
<div class="modal-body modal-body-error"> | ||
<label id="errorDialogText">Description de l'erreur.</label><br></p> | ||
</div> | ||
<div class="modal-footer modal-footer-error"> | ||
<button type="button" id="errorRefresh" class="btn btn-success" data-dismiss="modal" onclick="location.reload();" data-i18n="errorDialog.retry">{{ gettext('Retry') }}</button> | ||
<!--<button type="button" id="errorIgnore" class="btn btn-warning" data-dismiss="modal" onclick="loginParticipant();" data-i18n="errorDialog.ignore">{{ gettext('Ignore') }}</button>--> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div id="communicator" class="topbar"> | ||
<div align="left" class="logo"> | ||
<img id="imgLogo" src="./static/images/LogoOpenTeraPlus.png" style="height: 50px; width: 100px;"/> | ||
</div> | ||
<div class="status-zone"> | ||
<button id="btnLogout" class="green-button" onclick="doLogout(backend_hostname, backend_port);">{{ gettext('Logout') }}</button> | ||
<img id="imgStatus" src="./static/images/grey_button.png" width="24px"/> | ||
</div> | ||
<div align="center" class="name-zone"> | ||
<label id="displayname">{{ user_name }}</label> | ||
</div> | ||
</div> | ||
<iframe id="mainview" class = "iframe-with-footer main-frame" src="" allow="camera; microphone;">Frames not supported in this browser!</iframe> | ||
{% include "footer.html" %} | ||
</body> | ||
</html> | ||
|
Oops, something went wrong.