init project

This commit is contained in:
2023-06-27 14:47:56 +07:00
commit b78685db0b
25 changed files with 828 additions and 0 deletions

59
web/app.py Normal file
View File

@@ -0,0 +1,59 @@
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)
if __name__ == "__main__":
app.debug = True
app.run(host="0.0.0.0", port=5001)

16
web/dockerfile Normal file
View 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/requirements.txt Normal file
View 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/static/main.css Normal file
View 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;
}

View File

@@ -0,0 +1,22 @@
<!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">
<textarea name="reason"></textarea>
<input type="hidden" name="id" value="{{id}}">
<button type="submit">Удалить</button>
</form>
</body>
</html>

View 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>

View File

@@ -0,0 +1,47 @@
<!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> -->
{% 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></td>
{% else %}
<td >{{ "%s %s %s %s"|format(entry.client[0:1], entry.client[1:4], entry.client[4:7], entry.client[7:11]) }}</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 %}
</td>
</tr>
{% endfor %}
</body>
</table>
</html>