This commit is contained in:
2024-06-17 18:57:08 +07:00
parent e03a34c47a
commit fc75f83926
45 changed files with 1181 additions and 431 deletions

140
backup/web-dev/app.py Normal file
View File

@@ -0,0 +1,140 @@
from urllib import request
from flask import Flask, jsonify, render_template, url_for, request, redirect
import json
import datetime
from pymongo import MongoClient
import requests
CONNECTION_STRING = "mongodb://mongodb:Cc03Wz5XX3iI3uY3@mongo"
db_connection = MongoClient(CONNECTION_STRING)
db_base = db_connection["phone-dev"]
coll = db_base["phone"]
bl = db_base["blacklist"]
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")
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")
@app.route("/blacklist")
def blacklist():
call = bl.find().sort('_id')
return render_template("blacklist.html", call=call) if rep == False else render_template("repair.html")
@app.route("/test")
def ttt():
res = []
for p in request.environ:
try:
res.append(p + " = " + request.environ[p])
except:
pass
# #"<br>".join(request.environ)
return str(res)
@app.route("/work/<uuid>")
def work_uuid(uuid):
coll.update_one({"uuid": uuid}, {"$set": {"status": "INWORK"}})
call = coll.find({"uuid": uuid})
return render_template("work.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_many({"uuid": request.form["uuid"], "status": "RECALL_FALSE"}, {
"$set": {"status": "DELETED"}})
return redirect("/falserecall")
@app.route("/api/v1/work/", methods=["POST"])
def work():
dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
coll.update_one({"uuid": request.form["uuid"]}, {"$set": {"status": "RECALL_" + str(request.form["recall"]).upper(), "dt": dt}})
return redirect("/")
@app.route("/api/v1/blacklist/add/<number>", methods=["POST"])
def blacklist_put(number):
insdict = {"_id": number, "desc": datetime.datetime.now()}
bl.update_one({"_id": number}, {"$set": insdict}, True)
coll.update_many({"client": number, "status": {
"$in": ["RECALL_TRUE", "RECALL_FALSE", "NOT_ANSWERED"]}}, {"$set": {"status": "IGNORED"}})
return redirect("/blacklist")
@app.route("/api/v1/blacklist/delete/<number>", methods=["POST"])
def blacklist_delete(number):
bl.delete_many({"_id": number})
return redirect("/blacklist")
@app.route("/api/v1/blacklist/get/<number>")
def blacklist_get(number):
try:
return [i for i in bl.find({"_id": number})][0]
except:
return {}
@app.route("/api/v1/sync")
def sync():
j = []
for x in coll.find({"status": "NOT_ANSWERED"}):
t_req = "https://callinfo.services.mobilon.ru/api/call/info/1e86a98e026578eb5f6bf8c092c0c4a2/" + \
x["uuid"]
res: dict = json.loads(requests.get(t_req).content)
j.append(res)
coll.update_one({"uuid": x["uuid"]}, {"$set": res})
return j
if __name__ == "__main__":
app.debug = True
app.run(host="0.0.0.0", port=6001)

16
backup/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"]

View File

@@ -0,0 +1,11 @@
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
requests==2.28.2

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,115 @@
<!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: #7A1E99;
padding-right: 50px;
}
header {
height: 50px;
vertical-align: middle;
}
form {
height: 40px;
}
.inl {display: inline;}
.inl-active {
display: inline;
background-color: #FFD300;
}
</style>
<body>
<div>
<div class="inl-active"><a href="/answer">Входящий вызов принят</a></div>
<div class="inl"><a href="/notanswer">Входящий вызов не принят</a></div>
<div class="inl"><a href="/truerecall">Перезвонили успешно</a></div>
<div class="inl"><a href="/falserecall">Перезвонили безуспешно</a></div>
</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,97 @@
<!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>
<table>
<thead>
<tr>
<th>Номер клиента</th>
<th>Комментарий</th>
<th>Действие</th>
</tr>
</thead>
<tbody>
{% for c in call %}
<tr>
<td>{{ c._id }}</td>
<td>{{ c.desc }}</td>
<td>
<form method="post" action="/api/v1/blacklist/delete/{{ c._id }}">
<input type="submit" value="Удалить" />
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>

View File

@@ -0,0 +1,114 @@
<!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: #7A1E99;
padding-right: 50px;
}
header {
height: 50px;
vertical-align: middle;
}
form {
height: 40px;
}
.inl {display: inline;}
.inl-active {
display: inline;
background-color: #FFD300;
}
</style>
<body>
<div>
<div class="inl"><a href="/answer">Входящий вызов принят</a></div>
<div class="inl"><a href="/notanswer">Входящий вызов не принят</a></div>
<div class="inl"><a href="/truerecall">Перезвонили успешно</a></div>
<div class="inl-active"><a href="/falserecall">Перезвонили безуспешно</a></div>
</div>
<table>
<thead>
<tr>
<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.dt }}</td>
<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,130 @@
<!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: #7A1E99;
padding-right: 50px;
}
header {
height: 50px;
vertical-align: middle;
}
form {
height: 40px;
}
.inl {
display: inline;
}
.inl-active {
display: inline;
background-color: #FFD300;
}
</style>
<body>
<div>
<div class="inl"><a href="/answer">Входящий вызов принят</a></div>
<div class="inl-active"><a href="/notanswer">Входящий вызов не принят</a></div>
<div class="inl"><a href="/truerecall">Перезвонили успешно</a></div>
<div class="inl"><a href="/falserecall">Перезвонили безуспешно</a></div>
</div>
<div>
</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">
<a href="/work/{{ c.uuid }}">
{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}
</a>
</font>
</td>
{% else %}
<td>
<a href="/work/{{ c.uuid }}">
{{ "%s %s %s %s" |format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}
</a>
</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/blacklist/add/{{ c.client }}" method="post" style="border: 0;" />
<input type="submit" value="В черный список" style="background-color: dimgray; color: #fff;" />
</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

@@ -0,0 +1,104 @@
<!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: #7A1E99;
padding-right: 50px;
}
header {
height: 50px;
vertical-align: middle;
}
form {
height: 40px;
}
.inl {display: inline;}
.inl-active {
display: inline;
background-color: #FFD300;
}
</style>
<body>
<div>
<div class="inl"><a href="/answer">Входящий вызов принят</a></div>
<div class="inl"><a href="/notanswer">Входящий вызов не принят</a></div>
<div class="inl-active"><a href="/truerecall">Перезвонили успешно</a></div>
<div class="inl"><a href="/falserecall">Перезвонили безуспешно</a></div>
</div>
<table>
<thead>
<tr>
<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.dt }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>

View File

@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>В работе</title>
</head>
<body style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;">
{% for c in call %}
<h3>{{ c.client }}</h3>
<table style="width: 500px; border: 1px; border-radius: 5px;">
<tr>
<td>Направление:</td>
<td> {{ c.direction }}</td>
</tr>
<tr>
<td>Продолжительность:</td>
<td> {{ c.answered_duration }}</td>
</tr>
<tr>
<td>Время события:</td>
<td>{{ c.time }}</td>
</tr>
<tr>
<td>Вызываемый номер:</td>
<td>{{ c.mkt_phone }}</td>
</tr>
</table>
<form action="/api/v1/work/" method="post">
<fieldset style="width: 500px;">
<legend>Результат</legend>
<div>
<input type="radio" name="recall" value="true" />
<label for="true">Дозвонились</label>
</div>
<div>
<input type="radio" name="recall" value="false" checked />
<label for="false">Не дозвонились</label>
</div>
<input type="hidden" name="uuid" value="{{ c.uuid }}" />
<p>
<div>
<input type="submit" value="Принять">
</div>
</fieldset>
</form>
{% endfor %}
</body>
</html>