init project
This commit is contained in:
74
web_admin/app.py
Normal file
74
web_admin/app.py
Normal file
@@ -0,0 +1,74 @@
|
||||
from urllib import request
|
||||
from flask import Flask, jsonify, render_template, url_for, request, redirect
|
||||
import json
|
||||
import datetime
|
||||
from pymongo import MongoClient
|
||||
|
||||
CONNECTION_STRING = "mongodb://mongodb:Cc03Wz5XX3iI3uY3@mongo"
|
||||
|
||||
db_connection = MongoClient(CONNECTION_STRING)
|
||||
db_base = db_connection["phone"]
|
||||
coll_call = db_base["phone"]
|
||||
coll_history = db_base["history"]
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
internal = {}
|
||||
external = {}
|
||||
State = ""
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def root():
|
||||
return "Ok"
|
||||
|
||||
|
||||
IgnoreList = ['83919865589', '83912051046', '83912051045', '84950213944', '84951252791', '83919865589',
|
||||
'84951183750', '89919237009', '89919241441', '89919863883', '89919505445', '89919398228', '89919500798']
|
||||
|
||||
|
||||
@app.route("/web/call/")
|
||||
def WebCall():
|
||||
call = coll_call.find().sort('time', -1)
|
||||
return render_template("WebCall.html", call=call)
|
||||
|
||||
|
||||
@app.route("/web/call/test/")
|
||||
def GetTest():
|
||||
call = coll_call.find({'client': {'$nin': IgnoreList}}).sort('time', -1)
|
||||
return render_template("TestCall.html", call=call)
|
||||
|
||||
|
||||
@app.route("/web/call/test/<id>")
|
||||
def GetTestId(id):
|
||||
call = coll_call.find(
|
||||
{'client': {'$nin': IgnoreList}, 'status': int(id)}).sort('time', -1)
|
||||
return render_template("TestCall.html", call=call)
|
||||
|
||||
|
||||
@app.route("/web/call/status/<id>")
|
||||
def WebCallStatus(id):
|
||||
call = coll_call.find({"status": int(id)}).sort('time', -1)
|
||||
call = coll_call.find(
|
||||
{'client': {'$nin': IgnoreList}, 'status': int(id)}).sort('time', -1)
|
||||
return render_template("WebCall.html", call=call)
|
||||
|
||||
|
||||
@app.route("/web/call/delete/<id>")
|
||||
def WebCallDelete(id):
|
||||
return render_template("DeleteCall.html", id=id)
|
||||
|
||||
|
||||
@app.route("/web/call/delete/confirm", methods=['POST'])
|
||||
def WebCallDeleteConfirm():
|
||||
phone = request.form.get("id")
|
||||
reason = request.form.get('reason')
|
||||
res = phone + " - " + reason
|
||||
coll_call.update_one({'$and': [{'client': phone}, {'status': 1}]}, {
|
||||
'$set': {'status': 9, 'reason': reason}})
|
||||
return redirect("http://192.168.0.20:5001/web/call/status/1")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.debug = True
|
||||
app.run(host="0.0.0.0", port=5002)
|
||||
16
web_admin/dockerfile
Normal file
16
web_admin/dockerfile
Normal file
@@ -0,0 +1,16 @@
|
||||
FROM alpine
|
||||
|
||||
RUN apk update && apk upgrade && apk add python3 && apk add -U tzdata
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt requirements.txt
|
||||
COPY app.py /app
|
||||
COPY static /app/static
|
||||
COPY templates /app/templates
|
||||
RUN python3 -m venv .venv
|
||||
RUN /app/.venv/bin/pip3 install -r /app/requirements.txt
|
||||
|
||||
EXPOSE 5001
|
||||
|
||||
CMD [".venv/bin/python3", "app.py"]
|
||||
10
web_admin/requirements.txt
Normal file
10
web_admin/requirements.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
click==8.1.3
|
||||
dnspython==2.3.0
|
||||
Flask==2.2.3
|
||||
importlib-metadata==6.2.0
|
||||
itsdangerous==2.1.2
|
||||
Jinja2==3.1.2
|
||||
MarkupSafe==2.1.2
|
||||
pymongo==4.3.3
|
||||
Werkzeug==2.2.3
|
||||
zipp==3.15.0
|
||||
47
web_admin/static/main.css
Normal file
47
web_admin/static/main.css
Normal file
@@ -0,0 +1,47 @@
|
||||
table {
|
||||
width: 100%;
|
||||
margin-bottom: 20px;
|
||||
border: 5px solid #fff;
|
||||
border-top: 5px solid #fff;
|
||||
border-bottom: 3px solid #fff;
|
||||
border-collapse: collapse;
|
||||
outline: 3px solid #ffd300;
|
||||
font-size: 15px;
|
||||
background: #fff !important;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
table th {
|
||||
font-weight: bold;
|
||||
padding: 7px;
|
||||
background: #ffd300;
|
||||
border: none;
|
||||
text-align: left;
|
||||
font-size: 15px;
|
||||
border-top: 3px solid #fff;
|
||||
border-bottom: 3px solid #ffd300;
|
||||
}
|
||||
|
||||
table td {
|
||||
padding: 7px;
|
||||
border: none;
|
||||
border-top: 3px solid #fff;
|
||||
border-bottom: 3px solid #fff;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
table tbody tr:nth-child(even) {
|
||||
background: #f8f8f8 !important;
|
||||
}
|
||||
|
||||
a {
|
||||
font-size: large;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
color: chocolate;
|
||||
padding-right: 50px;
|
||||
}
|
||||
|
||||
header {
|
||||
height: 50px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
23
web_admin/templates/DeleteCall.html
Normal file
23
web_admin/templates/DeleteCall.html
Normal file
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Удаление документа</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>Вы действительно хотите удалить номер: {{ id }}?</h2>
|
||||
Причина:
|
||||
<form action="/web/call/delete/confirm" method="post">
|
||||
<input type="hidden" name="id" value="{{id}}">
|
||||
<textarea name="reason" rows="5" cols="60"></textarea>
|
||||
<br>
|
||||
<button type="submit">Удалить</button>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
43
web_admin/templates/TestCall.html
Normal file
43
web_admin/templates/TestCall.html
Normal file
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='main.css') }}">
|
||||
<title>Lost Calls</title>
|
||||
</head>
|
||||
<header>
|
||||
<a href="/web/call/status/0">Входящий вызов принят</a>
|
||||
<a href="/web/call/status/1">Входящий вызов не принят</a>
|
||||
<a href="/web/call/status/2">Перезвонили</a>
|
||||
|
||||
</header>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Номер клиента</td>
|
||||
<!-- <td>Номер оператора</td> -->
|
||||
<td>Дата время</td>
|
||||
<td>Ссылка на запись</td>
|
||||
</tr>
|
||||
|
||||
<body>
|
||||
{% for entry in call %}
|
||||
<tr>
|
||||
<!-- <td>{{ entry.client }}</td> -->
|
||||
<td><a href="tel:{{ entry.client }}">{{ "%s %s %s %s"|format(entry.client[0:1], entry.client[1:4], entry.client[4:7], entry.client[7:11]) }}</a></td>
|
||||
<!-- <td>{{ entry.Operator }}</td> -->
|
||||
<td>{{ entry.time }}</td>
|
||||
<td>
|
||||
{% if entry.recordUrl|length > 1 %}
|
||||
<audio src="{{ entry.recordUrl }}" type="audio/mp3" preload="none" controls>Запись</audio>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</body>
|
||||
</table>
|
||||
|
||||
</html>
|
||||
64
web_admin/templates/WebCall.html
Normal file
64
web_admin/templates/WebCall.html
Normal file
@@ -0,0 +1,64 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='main.css') }}">
|
||||
<title>Lost Calls</title>
|
||||
</head>
|
||||
<header>
|
||||
<a href="/web/call/status/0">Входящий вызов принят</a>
|
||||
<a href="/web/call/status/1">Входящий вызов не принят</a>
|
||||
<a href="/web/call/status/2">Перезвонили</a>
|
||||
<a href="/web/call/status/9">Удаленные</a>
|
||||
|
||||
|
||||
</header>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Номер клиента</td>
|
||||
<!-- <td>Номер оператора</td> -->
|
||||
<td>Дата время</td>
|
||||
<td>Дополнитительная информация</td>
|
||||
</tr>
|
||||
|
||||
<body>
|
||||
{% for entry in call %}
|
||||
<tr>
|
||||
<!-- <td>{{ entry.client }}</td> -->
|
||||
{% if entry.important == True %}
|
||||
<td>
|
||||
<font color="#C30000">{{ "%s %s %s %s"|format(entry.client[0:1], entry.client[1:4], entry.client[4:7],
|
||||
entry.client[7:11]) }}</font>
|
||||
{% if entry.status == 1 %}
|
||||
<a href="/web/call/delete/{{entry.client}}">[удалить]</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% else %}
|
||||
<td>{{ "%s %s %s %s"|format(entry.client[0:1], entry.client[1:4], entry.client[4:7], entry.client[7:11]) }}
|
||||
{% if entry.status == 1 %}
|
||||
<a href="/web/call/delete/{{entry.client}}">[удалить]</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
<!-- <td>{{ entry.Operator }}</td> -->
|
||||
<td>{{ entry.time }}</td>
|
||||
<td>
|
||||
{% if entry.recordUrl|length > 1 %}
|
||||
<audio src="{{ entry.recordUrl }}" type="audio/mp3" preload="none" controls>Запись</audio>
|
||||
{% endif %}
|
||||
|
||||
{% if entry.reason|length > 1 %}
|
||||
{{ entry.reason }}
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</body>
|
||||
</table>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user