Merge pull request 'Pull from piair:master' (#1) from piair/MsRewards-Reborn:master into master

Reviewed-on: augustin64/MsRewards-Reborn#1
This commit is contained in:
augustin64 2023-09-21 13:49:23 +02:00
commit c224ad9591
19 changed files with 141 additions and 377 deletions

View File

@ -8,7 +8,7 @@ RUN curl -sSLO https://piair.xyz/download/chrome.deb \
&& wget -q -O /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key \
&& echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" | tee -a /etc/apt/sources.list.d/grafana.list \
&& apt update \
&& apt install grafana xvfb nginx nano tzdata sqlite3 apt-transport-https software-properties-common wget wfrench tigervnc-standalone-server libasound2 libatk-bridge2.0-0 libnss3 libnspr4 xvfb libgbm1 libatk1.0-0 libu2f-udev libatspi2.0-0 libcups2 libxkbcommon0 libxrandr2 libdbus-1-3 xdg-utils fonts-liberation libdrm2 -y \
&& apt install novnc websockify grafana xvfb nginx nano tzdata sqlite3 apt-transport-https software-properties-common wget wfrench tigervnc-standalone-server libasound2 libatk-bridge2.0-0 libnss3 libnspr4 xvfb libgbm1 libatk1.0-0 libu2f-udev libatspi2.0-0 libcups2 libxkbcommon0 libxrandr2 libdbus-1-3 xdg-utils fonts-liberation libdrm2 -y \
&& bash MsRewards-Reborn/config/config.sh \
&& dpkg -i chrome.deb

View File

@ -134,7 +134,7 @@ def login():
login_user(user)
if password == "ChangeMe":
return(redirect('/change_password'))
return(redirect('/override'))
return(redirect('/schedule'))
else:
return abort(401)
else:
@ -175,7 +175,7 @@ def load_user(userid):
def main():
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
configs = json.load(inFile)
return(render_template("override.html", data=configs))
return(render_template("schedule.html", data=configs))
@app.route("/discord/")
@ -282,15 +282,15 @@ def proxy_post():
return(render_template("proxy.html", data=data, len=maxi(data)))
@app.route("/override/")
def override_get():
@app.route("/schedule/")
def schedule_get():
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
configs = json.load(inFile)
return(render_template("override.html", data=configs))
return(render_template("schedule.html", data=configs))
@app.route("/override/", methods=["post"])
def override_post():
@app.route("/schedule/", methods=["post"])
def schedule_post():
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
configs = json.load(inFile)
@ -308,7 +308,7 @@ def override_post():
with open("/app/MsRewards-Reborn/user_data/configs.json", "w") as inFile:
json.dump(configs, inFile)
update_jobs()
return(render_template("override.html", data=configs))
return(render_template("schedule.html", data=configs))
@app.route("/config/")
@ -363,11 +363,16 @@ def logs():
print(configs)
return(render_template("logs.html", data=configs))
@app.route("/stats/", methods=["GET", "POST"])
def stats():
return(render_template("stats.html"))
@app.route("/override/", methods=["GET", "POST"])
def override():
return(render_template("vnc.html"))
@app.route('/download/<path:filename>', methods=['GET', 'POST'])
@login_required

View File

@ -3,7 +3,6 @@ function addline(ligne){
document.getElementById("table").insertRow(lplus).insertCell(0).innerHTML = '<input type="file" id="file' + lplus + '" name="file' + lplus + '" onchange="addline(' + lplus + ')">'
}
function change_discord(value, data, len) {
if (value == len){
document.getElementById("name").value = "";
@ -25,6 +24,7 @@ function change_discord(value, data, len) {
}
function change_config(value, data, len) {
console.log(data[2]);
document.getElementById("delete").style.visibility = "hidden";
if (value == len){
document.getElementById("submit").value = "Create !";
@ -52,7 +52,6 @@ function change_config(value, data, len) {
}
}
function change_proxy(value, data, len) {
if (value == len){
document.getElementById("submit").value = "Create";
@ -68,7 +67,6 @@ function change_proxy(value, data, len) {
}
}
function change_logs(value) {
document.getElementById("embed").src = "/static/logs/" + value + ".txt";
}

View File

@ -24,8 +24,49 @@
</div>
</label>
<div class="left-pannel">
{% block left_pannel %}
{% endblock %}
<table>
<tr>
<td>
<button class="unselected" id="sidebar_schedule" onclick="location.href = '/schedule';">schedule</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" id="sidebar_config" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" id="sidebar_discord" onclick="location.href = '/discord';">discord</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" id="sidebar_proxy" onclick="location.href = '/proxy';">proxy</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" id="sidebar_logs" onclick="location.href = '/logs';">logs</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" id="sidebar_stats" onclick="location.href = '/stats';">stats</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" id="sidebar_override" onclick="location.href = '/override';">Override</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" id="sidebar_settings" onclick="location.href = '/settings';">settings</button>
</td>
</tr>
</table>
<script>document.getElementById("sidebar_{% block left_pannel %}{% endblock %}").className = "selected"</script>
</div>
<div class="content">
{% block content %}

View File

@ -1,43 +1,5 @@
{% extends "base.html" %}
{% block left_pannel %}
<table>
<tr>
<td>
<button class="unselected" onclick="location.href = '/override';">override</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/discord';">discord</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/proxy';">proxy</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/logs';">logs</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/grafana';">stats</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/settings';">settings</button>
</td>
</tr>
</table>
{% endblock %}
{% block content %}

View File

@ -1,48 +1,10 @@
{% extends "base.html" %}
{% block left_pannel %}
<table>
<tr>
<td>
<button class="unselected" onclick="location.href = '/override';">override</button>
</td>
</tr>
<tr>
<td>
<button class="selected" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/discord';">discord</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/proxy';">proxy</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/logs';">logs</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/stats';">stats</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/settings';">settings</button>
</td>
</tr>
</table>
{% endblock %}
{% block left_pannel %}config{% endblock %}
{% block content %}
<script>data = JSON.parse('{{data|tojson}}'); </script>
<script>data2 = JSON.parse('{{configs|tojson}}'); </script>
{%if not current_user.is_authenticated %}
<button class="unselected" onclick="location.href = '/login';">login</button>
{% else %}
@ -51,7 +13,7 @@
<tr>
<td style="width: 10%;">config : </td>
<td style="width: 40%;">
<select onchange="change_config(this.value, data, '{{len}}')" name="config">
<select onchange="change_config(this.value, data2, '{{len}}')" name="config">
<option id="config" value="{{len}}">New config</option>
{% for i in configs %}
<option id="{{configs[i]['name']}}" value="{{i}}">{{configs[i]['name']}}</option>

View File

@ -1,44 +1,5 @@
{% extends "base.html" %}
{% block left_pannel %}
<table>
<tr>
<td>
<button class="unselected" onclick="location.href = '/override';">override</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>
<td>
<button class="selected" onclick="location.href = '/discord';">discord</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/proxy';">proxy</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/logs';">logs</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/stats';">stats</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/settings';">settings</button>
</td>
</tr>
</table>
{% endblock %}
{% block left_pannel %}discord{% endblock %}
{% block content %}
<script>data = JSON.parse('{{data|tojson}}'); </script>
{%if not current_user.is_authenticated %}

View File

@ -1,10 +1,5 @@
{% extends "base.html" %}
{% block left_pannel %}
<table>
</table>
{% endblock %}
{% block left_pannel %}login{% endblock %}
{% block content %}
{%if not current_user.is_authenticated %}

View File

@ -1,44 +1,5 @@
{% extends "base.html" %}
{% block left_pannel %}
<table>
<tr>
<td>
<button class="unselected" onclick="location.href = '/override';">override</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/discord';">discord</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/proxy';">proxy</button>
</td>
</tr>
<tr>
<td>
<button class="selected" onclick="location.href = '/logs';">logs</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/stats';">stats</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/settings';">settings</button>
</td>
</tr>
</table>
{% endblock %}
{% block left_pannel %}logs{% endblock %}
{% block content %}
{%if not current_user.is_authenticated %}

View File

@ -1,74 +0,0 @@
{% extends "base.html" %}
{% block left_pannel %}
<table>
<tr>
<td>
<button class="selected" onclick="location.href = '/override';">override</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/discord';">discord</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/proxy';">proxy</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/logs';">logs</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/stats';">stats</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/settings';">settings</button>
</td>
</tr>
</table>
{% endblock %}
{% block content %}
{%if not current_user.is_authenticated %}
<button class="unselected" onclick="location.href = '/login';">login</button>
{% else %}
<form method="post" action="/override/">
<table>
{% for i in data %}
<tr>
<td>{{data[i]['name']}}</td>
<td>
<input type="time" id="{{i}}" name="time{{i}}" value="{{data[i]['time']}}" required>
</td>
<td>
<input type="checkbox" id="switch{{i}}" name="switch{{i}}" {{ "checked" if data[i]['enabled'] == True else "" }} />
<label for="switch{{i}}">
Toggle
</label>
</td>
</tr>
{% endfor %}
</table>
<input type="submit" name="data" value="Update" class="button"/>
</form>
{% endif %}
{%endblock %}

View File

@ -1,44 +1,5 @@
{% extends "base.html" %}
{% block left_pannel %}
<table>
<tr>
<td>
<button class="unselected" onclick="location.href = '/override';">override</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/discord';">discord</button>
</td>
</tr>
<tr>
<td>
<button class="selected" onclick="location.href = '/proxy';">proxy</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/logs';">logs</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/stats';">stats</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/settings';">settings</button>
</td>
</tr>
</table>
{% endblock %}
{% block left_pannel %}proxy{% endblock %}

View File

@ -0,0 +1,35 @@
{% extends "base.html" %}
{% block left_pannel %}schedule{% endblock %}
{% block content %}
{%if not current_user.is_authenticated %}
<button class="unselected" onclick="location.href = '/login';">login</button>
{% else %}
<form method="post" action="/override/">
<table>
{% for i in data %}
<tr>
<td>{{data[i]['name']}}</td>
<td>
<input type="time" id="{{i}}" name="time{{i}}" value="{{data[i]['time']}}" required>
</td>
<td>
<input type="checkbox" id="switch{{i}}" name="switch{{i}}" {{ "checked" if data[i]['enabled'] == True else "" }} />
<label for="switch{{i}}">
Toggle
</label>
</td>
</tr>
{% endfor %}
</table>
<input type="submit" name="data" value="Update" class="button"/>
</form>
{% endif %}
{%endblock %}

View File

@ -1,44 +1,5 @@
{% extends "base.html" %}
{% block left_pannel %}
<table>
<tr>
<td>
<button class="unselected" onclick="location.href = '/override';">override</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/discord';">discord</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/proxy';">proxy</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/logs';">logs</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/stats';">stats</button>
</td>
</tr>
<tr>
<td>
<button class="selected" onclick="location.href = '/settings';">settings</button>
</td>
</tr>
</table>
{% endblock %}
{% block left_pannel %}settings{% endblock %}
{% block content %}
{%if not current_user.is_authenticated %}

View File

@ -1,44 +1,5 @@
{% extends "base.html" %}
{% block left_pannel %}
<table>
<tr>
<td>
<button class="unselected" onclick="location.href = '/override';">override</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/config';">config</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/discord';">discord</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/proxy';">proxy</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/logs';">logs</button>
</td>
</tr>
<tr>
<td>
<button class="selected" onclick="location.href = '/grafana';">stats</button>
</td>
</tr>
<tr>
<td>
<button class="unselected" onclick="location.href = '/settings';">settings</button>
</td>
</tr>
</table>
{% endblock %}
{% block left_pannel %}stats{% endblock %}
{% block content %}

13
Flask/templates/vnc.html Normal file
View File

@ -0,0 +1,13 @@
{% extends "base.html" %}
{% block left_pannel %}override{% endblock %}
{% block content %}
{%if not current_user.is_authenticated %}
<button class="unselected" onclick="location.href = '/login';">login</button>
{% else %}
<iframe src="/novnc/vnc.html?resize=scale&path=novnc/websockify&view_only" width="100%" height="100%" frameborder="0"></iframe>
{% endif %}
{%endblock %}

7
V6.py
View File

@ -366,7 +366,10 @@ def try_play(nom="inconnu"):
driver.find_element(By.CSS_SELECTOR, '[onclick="setsrchusr()"]').click()
custom_sleep(5)
printf("not connected, fixed")
if "legaltextbox" in driver.current_url:
log_error("dev1")
driver.find_element(By.CLASS_NAME, "actionLink").click()
log_error("dev2")
try:
if wait_until_visible(By.ID, "rqStartQuiz", 5, driver):
custom_sleep(3)
@ -826,7 +829,7 @@ else :
display = SmartDisplay(size=(1920, 1080))
display.start()
webhookFailure.send(f"Starting on this config", username="Check de lancement", avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png")
webhookFailure.send(f"@silent Starting on this config", username="Check de lancement", avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png")
if g.custom_start:
CustomStart()

View File

@ -27,6 +27,19 @@ server {
proxy_pass http://grafana;
rewrite ^/grafana/(.*) /\$1 break;
}
location /novnc/ {
proxy_pass http://127.0.0.1:6080/;
}
location /novnc/websockify {
proxy_pass http://127.0.0.1:6080/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
location / {
proxy_set_header X-Forwarded-For \$remote_addr;
proxy_set_header Host \$http_host;
@ -47,4 +60,5 @@ cp /app/MsRewards-Reborn/config/grafana.ini /etc/grafana/
grafana-cli plugins install frser-sqlite-datasource
printf "setting up default dashboard"
cp /app/MsRewards-Reborn/config/Stats-dashbord.json /usr/share/grafana/public/dashboards/home.json
cp /app/MsRewards-Reborn/config/Stats-dashbord.json /usr/share/grafana/public/dashboards/home.json

View File

@ -12,3 +12,8 @@ curl 'http://localhost:1234/grafana/api/dashboards/import' \
--compressed \
--insecure
websockify -D \
--web /usr/share/novnc/ \
6080 \
localhost:2345

View File

@ -1 +1 @@
v6.3.2
v6.4.4