This commit is contained in:
filimonov
2024-02-20 16:43:56 +07:00
parent f79efa2951
commit a086f94798
28 changed files with 1469 additions and 144 deletions

75
web-dev/app.py Normal file
View File

@@ -0,0 +1,75 @@
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-dev"]
coll = db_base["phone"]
rep = False
# coll_call = db_base["phone"]
# coll_history = db_base["history"]
app = Flask(__name__)
internal = {}
external = {}
State = ""
Findlimit = 100
@app.route("/")
def root():
return redirect("/notanswer")
IgnoreList = ['83919865589', '83912051046', '83912051045', '84950213944', '84951252791', '83919865589',
'84951183750', '89919237009', '89919241441', '89919863883', '89919505445', '89919398228', '89919500798']
ImportantNumber = ['839122051045']
@app.route("/answer")
def answer():
call = coll.find({"status": "ANSWERED"}).sort('time', -1).limit(Findlimit)
return render_template("answer.html", call=call) if rep == False else render_template("repair.html")
@app.route("/notanswer")
def notanswer():
call = coll.find({"status": "NOT_ANSWERED"}).sort(
'time', -1).limit(Findlimit)
return render_template("notanswer.html", call=call) if rep == False else render_template("repair.html")
@app.route("/truerecall")
def recallTrue():
call = coll.find({"status": "RECALL_TRUE"}).sort(
'time', -1).limit(Findlimit)
return render_template("truerecall.html", call=call) if rep == False else render_template("repair.html")
@app.route("/falserecall")
def rcallFalse():
call = coll.find({"status": "RECALL_FALSE"}).sort(
'time', -1).limit(Findlimit)
return render_template("falserecall.html", call=call) if rep == False else render_template("repair.html")
# API
@app.route("/api/v1/call/set/", methods=["POST"])
def call_put():
print(request.form)
if request.form["act"] == "delete":
coll.update_one({"uuid": request.form["uuid"]}, {
"$set": {"status": "DELETED"}})
return redirect("/falserecall")
if __name__ == "__main__":
app.debug = True
app.run(host="0.0.0.0", port=6001)

16
web-dev/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
RUN python3 -m venv .venv
RUN /app/.venv/bin/pip3 install -r /app/requirements.txt
COPY app.py /app
COPY static /app/static
COPY templates /app/templates
EXPOSE 5001
CMD [".venv/bin/python3", "app.py"]

10
web-dev/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

51
web-dev/static/main.css Normal file
View File

@@ -0,0 +1,51 @@
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;
}
form {
height: 40px;
}

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,79 @@
<!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>
<<<<<<< HEAD
<a href="/web/call/status/2">Перезвонили успешно</a>
<a href="/web/call/status/4">Перезвонили безуспешно</a>
<p>
<form name="search" action="/web/call/find/" method="get" class="search">
<label class="search_label">Поиск</label>
<input class="search_text" type="text" name="client">
<input class="search_btn" type="submit" title="Найти">
</form>
</p>
=======
<a href="/web/call/status/2">Перезвонили</a>
>>>>>>> parent of c52dc73 (Добавил поиск)
</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>
<<<<<<< HEAD
{% if entry.status == 0 %}
Вызов принят
{% elif entry.status == 1 %}
Вызов не принят
{% elif entry.status == 2 %}
Перезвонили
{% elif entry.status == 2 %}
Абонент не взял трубку
{% elif entry.status == 9 %}
Абонент заблокирован
{% endif %}
</td>
<td>
=======
>>>>>>> parent of c52dc73 (Добавил поиск)
{% 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,109 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<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> Принятые вызовы</title>
</head>
<style type="text/css" media="screen">
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;
}
form {
height: 40px;
}
</style>
<body>
<div>
<a href="/answer">Входящий вызов принят</a>
<a href="/notanswer">Входящий вызов не принят</a>
<a href="/truerecall">Перезвонили успешно</a>
<a href="/falserecall">Перезвонили безуспешно</a>
</div>
<!-- <div>
<form name="search" action="/web/call/find/" method="get" class="search">
<label class="search_label">Поиск</label>
<input class="search_text" type="text" name="client">
<input class="search_btn" type="submit" title="Найти">
</form>
</div> -->
<table>
<thead>
<tr>
<th>Номер клиента</th>
<th>Дата и время</th>
<th>Запись разговора</th>
</tr>
</thead>
<tbody>
{% for c in call %}
<tr>
<!-- <td>{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}</td> -->
{% if c.mkt_phone == "83912051045": %}
<td>
<font color="#C30000">{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7],
c.client[7:11]) }}</font>
</td>
{% else %}
<td>{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}</td>
{% endif %}
<td>{{ c.time }}</td>
<td><audio src="{{ c.record_url }}" type="audio/mp3" preload="none" controls>Запись</audio></td>
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>

View File

@@ -0,0 +1,128 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<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>Перезвонили безуспешно</title>
</head>
<style type="text/css" media="screen">
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;
}
form {
height: 40px;
}
</style>
<body>
<div>
<a href="/answer">Входящий вызов принят</a>
<a href="/notanswer">Входящий вызов не принят</a>
<a href="/truerecall">Перезвонили успешно</a>
<a href="/falserecall">Перезвонили безуспешно</a>
</div>
<!-- <div>
<form name="search" action="/web/call/find/" method="get" class="search">
<label class="search_label">Поиск</label>
<input class="search_text" type="text" name="client">
<input class="search_btn" type="submit" title="Найти">
</form>
</div> -->
<table>
<thead>
<tr>
<th>Номер клиента</th>
<th>Кол-во попыток</th>
<th>Дата и время</th>
<th>Продолжительность</th>
<th>Оператор</th>
<th>Запись</th>
<th>Действие</th>
</tr>
</thead>
<tbody>
{% for c in call %}
<tr>
{% if c.mkt_phone == "83912051045": %}
<td>
<font color="#C30000">{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7],
c.client[7:11]) }}</font>
</td>
{% else %}
<td>{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}</td>
{% endif %}
<td>{{ c.count_try }}</td>
<td>{{ c.time }}</td>
<td>{{ c.answered_duration // 60 }}:{{ "{:02}".format(c.answered_duration % 60) }}</td>
<td>{{ c.operator }}</td>
<td>
{% if c.has_record == true: %}
<audio src="{{ c.record_url }}" type="audio/mp3" preload="none" controls>Запись</audio>
{% else %}
Отсутствует
{% endif %}
<td style="vertical-align: middle;">
<div>
<form action="/api/v1/call/set/" method="post" style="border: 0;">
<input type="hidden" name="uuid" value="{{ c.uuid }}" />
<input type="hidden" name="act" value="delete" />
<input type="submit" value="Удалить" style="background-color: firebrick; color: #f8f8f8;" />
</form>
</div>
</td>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>

View File

@@ -0,0 +1,126 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='main.css') }}"> -->
<!-- <link rel="stylesheet" type="text/css" href="http://dev-call.mkt.local/static/main.css"> -->
<title>Непринятые</title>
</head>
<style type="text/css" media="screen">
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;
}
form {
height: 40px;
}
</style>
<body>
<div>
<a href="/answer">Входящий вызов принят</a>
<a href="/notanswer">Входящий вызов не принят</a>
<a href="/truerecall">Перезвонили успешно</a>
<a href="/falserecall">Перезвонили безуспешно</a>
</div>
<div>
<!-- <form name="search" action="/web/call/find/" method="get" class="search">
<label class="search_label">Поиск</label>
<input class="search_text" type="text" name="client">
<input class="search_btn" type="submit" title="Найти">
</form> -->
</div>
<table>
<thead>
<tr>
<th>Номер клиента</th>
<th>Дата и время</th>
<th>Продолжительность</th>
<!-- <th>Смена статуса</th> -->
</tr>
</thead>
<tbody>
{% for c in call %}
<tr>
{% if c.mkt_phone == "83912051045": %}
<td>
<font color="#C30000">{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7],
c.client[7:11]) }}</font>
</td>
{% else %}
<td>{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}</td>
{% endif %}
<td>{{ c.time }} {{ c.important }}</td>
<td>{{ c.answered_duration // 60 }}:{{ "{:02}".format(c.answered_duration % 60) }}</td>
<!-- <td>
<form action="/api/v1/call/set/" method="post" style="border: 0;">
<input type="hidden" name="uuid" value="{{ c._id }}" />
<input type="hidden" name="res" value="truerecall" />
<input type="submit" value="Дозвонились" style="background-color: chartreuse;" />
</form>
<form action="/api/v1/call/set/" method="post">
<input type="hidden" name="uuid" value="{{ c._id }}" />
<input type="hidden" name="res" value="falserecall" />
<input type="submit" value="Не дозвонились" style="background-color: #FFAAAA;" />
</form>
</td> -->
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>

View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Ведутся работы, скоро все заработает</h1>
</body>
</html>

View File

View File

@@ -0,0 +1,112 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<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>Перезвонили успешно</title>
</head>
<style type="text/css" media="screen">
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;
}
form {
height: 40px;
}
</style>
<body>
<div>
<a href="/answer">Входящий вызов принят</a>
<a href="/notanswer">Входящий вызов не принят</a>
<a href="/truerecall">Перезвонили успешно</a>
<a href="/falserecall">Перезвонили безуспешно</a>
</div>
<!-- <div>
<form name="search" action="/web/call/find/" method="get" class="search">
<label class="search_label">Поиск</label>
<input class="search_text" type="text" name="client">
<input class="search_btn" type="submit" title="Найти">
</form>
</div> -->
<table>
<thead>
<tr>
<th>Номер клиента</th>
<th>Дата и время</th>
<th>Продолжительность</th>
<th>Оператор</th>
<th>Запись разговора</th>
</tr>
</thead>
<tbody>
<tr>
{% for c in call %}
<!-- <td>{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}</td> -->
{% if c.mkt_phone == "83912051045": %}
<td>
<font color="#C30000">{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7],
c.client[7:11]) }}</font>
</td>
{% else %}
<td>{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}</td>
{% endif %}
<td>{{ c.time }}</td>
<td>{{ c.answered_duration // 60 }}:{{ "{:02}".format(c.answered_duration % 60) }}</td>
<td>{{ c.operator }}</td>
<td><audio src="{{ c.record_url }}" type="audio/mp3" preload="none" controls>Запись</audio></td>
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>