generated from moevm/nsql-clean-tempate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from moevm/frontend
#12 - Реализация frontend части интерфейса
- Loading branch information
Showing
10 changed files
with
696 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,13 +17,7 @@ | |
@app.route('/') | ||
@app.route('/index') | ||
def index(): | ||
return "Start page!" | ||
|
||
@app.route('/test') | ||
def test(): | ||
dictToSend = {"full_name": "Шушков Егор", "password": "3214", "email": "[email protected]", | ||
"sex": "male", "birthday": "2004-08-04", "rd": datetime.now().isoformat(), "height": 95, "weight": 180} | ||
res = requests.post('http://localhost:5000/register', json=dictToSend) | ||
return redirect(url_for('db_page', entity_type="Disease")) | ||
|
||
@app.route('/register', methods=['GET', 'POST']) | ||
def register() -> str: | ||
|
@@ -39,14 +33,15 @@ def register() -> str: | |
render_template('register.html', msg = msg) (string) : возвращаем шаблон страницы с комментарием | ||
''' | ||
|
||
msg : str = '' | ||
msg : str = "that's okay" | ||
if request.method == 'POST' and 'full_name' in request.form and \ | ||
'password' in request.form and \ | ||
'email' in request.form and \ | ||
'sex' in request.form and \ | ||
'birthday' in request.form and \ | ||
'height' in request.form and \ | ||
'weight' in request.form: | ||
'weight' in request.form and \ | ||
"admin" in request.form: | ||
|
||
full_name : str = request.form['full_name'] | ||
password : str = request.form['password'] | ||
|
@@ -55,6 +50,7 @@ def register() -> str: | |
birthday : str = request.form['birthday'] | ||
height : float = request.form['height'] | ||
weight : float = request.form['weight'] | ||
admin : bool = request.form['admin'] | ||
|
||
query_string : str = ''' | ||
MATCH(p:Patient {email: $email}) | ||
|
@@ -74,18 +70,18 @@ def register() -> str: | |
|
||
else: | ||
query_string = ''' | ||
MERGE (p:Patient {full_name: $full_name, password: $password, email: $email, sex: $sex, birthday: $birthday, height: $height, weight: $weight, registration_date: $rd}) | ||
MERGE (p:Patient {full_name: $full_name, password: $password, email: $email, sex: $sex, birthday: $birthday, height: $height, weight: $weight, registration_date: $rd, admin: $admin}) | ||
''' | ||
|
||
conn.query(query_string, {"full_name": full_name, "password": password, "email": email, | ||
"sex": sex, "birthday": birthday, "rd": datetime.now().isoformat(), "height": height, "weight": weight}) | ||
"sex": sex, "birthday": birthday, "rd": datetime.now().isoformat(), "height": height, "weight": weight, "admin": admin}) | ||
|
||
msg = "Success" | ||
|
||
elif request.method == 'POST': | ||
msg = "Пожалуйста, заполните форму!" | ||
|
||
return render_template('register.html', msg = msg) | ||
return msg | ||
|
||
@app.route('/login', methods=['GET', 'POST']) | ||
def login() -> str: | ||
|
@@ -100,7 +96,7 @@ def login() -> str: | |
Возвращаемые данные: | ||
render_template('login.html', msg = msg) (string) : возвращаем шаблон страницы с комментарием | ||
''' | ||
msg = '' | ||
msg = None | ||
if request.method == 'POST' and 'email' in request.form and 'password' in request.form: | ||
query_string : str = ''' | ||
MATCH(p:Patient {email: $email, password: $password}) | ||
|
@@ -114,14 +110,18 @@ def login() -> str: | |
session["loggedin"] = True | ||
session["email"] = patient_data["email"] | ||
session["full_name"] = patient_data["full_name"] | ||
|
||
msg = 'Success' | ||
session["admin"] = patient_data["admin"] | ||
else: | ||
msg = 'Неправильный логин или пароль' | ||
elif request.method == 'GET': | ||
return render_template('account.html', session = session, certain_page = False) | ||
|
||
return render_template('login.html', msg = msg) | ||
if msg is None: | ||
return redirect(url_for('db_page', entity_type="Disease")) | ||
else: | ||
return render_template('account.html', session = session, certain_page = False, err = msg) | ||
|
||
@app.route('/logout', methods=['POST']) | ||
@app.route('/logout', methods=['GET']) | ||
def logout() -> Response: | ||
''' | ||
Функция отвечает за выход пользователя из аккаунта. | ||
|
@@ -133,11 +133,12 @@ def logout() -> Response: | |
session.pop('loggedin', None) | ||
session.pop('email', None) | ||
session.pop('full_name', None) | ||
session.pop('admin', None) | ||
|
||
return redirect(url_for('login')) | ||
|
||
@app.route('/entities/<entity_type>', methods=['POST']) | ||
def readEntities(entity_type) -> json: | ||
@app.route('/entities', methods=['POST']) | ||
def readEntities() -> json: | ||
''' | ||
Функция отвечает за чтение любой сущности из базы данных. | ||
|
@@ -149,6 +150,8 @@ def readEntities(entity_type) -> json: | |
параметры всех нодов с меткой "entity_type". | ||
''' | ||
|
||
entity_type : str = request.form['entity_type'] | ||
|
||
query_string : str = f''' | ||
MATCH(p:{entity_type}) | ||
RETURN p | ||
|
@@ -183,6 +186,8 @@ def createEntities(): | |
параметры всех нодов с меткой "entity_type". | ||
''' | ||
|
||
print(request) | ||
|
||
data : json = request.json | ||
entity_type : str = data.get('entity_type') | ||
entity_parametrs : dict = data.get('parametrs', {}) | ||
|
@@ -204,4 +209,47 @@ def createEntities(): | |
return "Success" | ||
|
||
else: | ||
return jsonify({"Error": "Invalid format of form"}), 400 | ||
return jsonify({"Error": "Invalid format of form"}), 400 | ||
|
||
@app.route('/db/<entity_type>', methods=['GET']) | ||
def db_page(entity_type): | ||
''' | ||
Функция отвечает за получение данных, создание таблицы сущностей определённого типа и её визуализацию. | ||
Ключевые переменные: | ||
entity_type (str) : наименование сущности, которую надо добавить в БД | ||
data (dict) : база данных с требуемыми запрошенными по entity_type сущностями | ||
Возвращаемые данные: | ||
render_template('data_bases.html', session = session, certain_page = False, entity_type = entity_type, lst = data) (string) : возвращаем шаблон страницы с таблицей и данными о пользователе | ||
''' | ||
response = requests.post("http://127.0.0.1:5000/entities", data={'entity_type': entity_type}) | ||
data = response.json() | ||
|
||
match(entity_type): | ||
case 'Disease': | ||
data.insert(0, {"name": "Наименование", \ | ||
"description": "Описание", \ | ||
"recommendations": "Рекомендации", \ | ||
"type": "Возбудитель", \ | ||
"course": "Протекание болезни"} ) | ||
case 'Patient': | ||
data.insert(0, {"full_name": "Фамилия и Имя", \ | ||
"email": "Почта", \ | ||
"password": "Пароль", \ | ||
"sex": "Пол", \ | ||
"birthday": "День рождения", \ | ||
"last_update": "Время последнего действия", \ | ||
"registration_date": "Дата регистрации", \ | ||
"height": "Рост", \ | ||
"weight": "Вес", \ | ||
"admin": "Права администратора"}) | ||
case 'Appeal': | ||
data.insert(0, {"date": "Дата", "complaints": "Жалобы"}) | ||
case 'Symptom': | ||
data.insert(0, {"name": "Наименование", "description": "Описание"}) | ||
|
||
return render_template('data_bases.html', session = session, certain_page = False, entity_type = entity_type, lst = data) | ||
|
||
|
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,183 @@ | ||
body{ | ||
margin: 0px; | ||
font-family: "Comfortaa", sans-serif; | ||
} | ||
|
||
|
||
.header{ | ||
width: 100%; | ||
height: 100px; | ||
background-color: #21D9D9; | ||
padding: 0px; | ||
} | ||
|
||
#searching{ | ||
width: 290px; | ||
height: 50px; | ||
border-radius: 25px; | ||
|
||
padding: 0; | ||
border: none; | ||
background: #FFFFFF; | ||
color: #000000; | ||
|
||
font-family: "Comfortaa", sans-serif; | ||
font-size: 18px; | ||
|
||
padding: 8px 8px 8px 8px; | ||
font-weight: 400; | ||
font-size: 18px; | ||
line-height: 1.3; | ||
text-align: right; | ||
|
||
margin-left: 30px; | ||
margin-top: 25px; | ||
} | ||
|
||
h1{ | ||
width: 270px; | ||
height: 70px; | ||
color: #FFFFFF; | ||
font-weight: 400; | ||
font-size: 60px; | ||
text-align: center; | ||
|
||
margin-left: auto; | ||
margin-right: auto; | ||
|
||
position: relative; | ||
top: -110px; | ||
} | ||
|
||
#title { | ||
width: 291px; | ||
height: 50px; | ||
color: #232323; | ||
font-weight: 400; | ||
font-size: 18px; | ||
text-align: center; | ||
|
||
margin-left: auto; | ||
margin-right: auto; | ||
|
||
position: relative; | ||
top: -150px; | ||
} | ||
|
||
#exit{ | ||
width: 60px; | ||
height: 60px; | ||
border-radius: 50px; | ||
|
||
padding: 0; | ||
border: none; | ||
background: #FFFFFF; | ||
color: #000000; | ||
|
||
font-family: "Comfortaa", sans-serif; | ||
font-size: 14px; | ||
|
||
position: relative; | ||
top: -275px; | ||
|
||
float: right; | ||
margin-right: 30px; | ||
|
||
|
||
} | ||
|
||
.menu{ | ||
width: auto; | ||
height: 150px; | ||
color: #21D9D9; | ||
font-weight: 400; | ||
font-size: 40px; | ||
text-align: center; | ||
|
||
margin: 30px; | ||
margin-top: 50px; | ||
|
||
text-decoration: none; | ||
|
||
position: relative; | ||
top: 30px; | ||
} | ||
|
||
.selected{ | ||
text-decoration: underline; | ||
} | ||
|
||
#left_panel { | ||
width: 417px; | ||
height: 103px; | ||
padding: 8px 8px 8px 8px; | ||
background: #21D9D9; | ||
border-radius: 10px 10px 10px 10px; | ||
|
||
margin-left: 30px; | ||
|
||
position: relative; | ||
|
||
} | ||
|
||
#list{ | ||
width: 1337px; | ||
height: 100%; | ||
color: #21D9D9; | ||
border-radius: 10px 10px 0px 0px; | ||
|
||
font-weight: 400; | ||
font-size: 24px; | ||
line-height: 1.3; | ||
text-align: center; | ||
|
||
float: right; | ||
margin-right: 30px; | ||
|
||
position: relative; | ||
bottom: 117px; | ||
|
||
max-width: 100%; | ||
overflow-x: auto; | ||
|
||
} | ||
|
||
table{ | ||
background-color: #FFFFFF; | ||
border: 1px solid #21D9D9; | ||
|
||
} | ||
|
||
th{ | ||
background-color: #21D9D9; | ||
border: 1px solid #21D9D9; | ||
color: #FFFFFF; | ||
|
||
margin: 0px; | ||
border-radius: 10px 10px 0px 0px; | ||
} | ||
|
||
td{ | ||
background-color: #FFFFFF; | ||
border: 1px solid #21D9D9; | ||
} | ||
|
||
.modal { | ||
display: none; | ||
position: fixed; | ||
z-index: 1; | ||
left: 0; | ||
top: 0; | ||
width: 100%; | ||
height: 100%; | ||
overflow: auto; | ||
background-color: rgba(0,0,0,0.4); | ||
} | ||
|
||
.modal-content { | ||
background-color: #fefefe; | ||
margin: 15% auto; | ||
padding: 20px; | ||
border: 1px solid #888; | ||
width: 80%; | ||
} |
Oops, something went wrong.