This commit is contained in:
SuperSonic 2020-02-08 13:36:30 +08:00
parent 8ec9e1592a
commit 650c8d4a3d
10 changed files with 163 additions and 4 deletions

View file

@ -26,6 +26,11 @@ class Yuuki_WebAdminAPI:
pass
return self.YukkiData.getData(["Global", "GroupJoined"])
def get_helpers(self, data):
if data:
pass
return self.YukkiData.getData(["Global", "GroupJoined"])
def get_logs(self, data):
return self.Yuuki_DataHandle.get_logs(data)

View file

@ -67,7 +67,8 @@ class Yuuki_WebAdmin:
if "yuuki_admin" in request.cookies:
if request.cookies["yuuki_admin"] in passports:
return render_template(
'manage/groups.html'
'manage/groups.html',
LINE_Media_server=Yuuki_Handle.LINE_Media_server
)
response = redirect("/")
response.set_cookie(
@ -99,7 +100,9 @@ class Yuuki_WebAdmin:
if "yuuki_admin" in request.cookies:
if request.cookies["yuuki_admin"] in passports:
return render_template(
'manage/settings.html'
'manage/settings.html',
version=Yuuki_Handle.YuukiConfigs["version"],
project_url=Yuuki_Handle.YuukiConfigs["project_url"]
)
response = redirect("/")
response.set_cookie(

View file

@ -11,6 +11,11 @@ body {
color: #ff0000;
}
.mini-logo {
max-width:32px;
height:32px;
}
.password_box {
margin: 0;
position: absolute;

View file

@ -11,7 +11,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
var events = [
"JoinGroup",
"KickEvent",
"CancelEvent"
"CancelEvent",
"BlackList"
];
function format2html(title, context) {
@ -31,7 +32,7 @@ function log_query(data) {
task: "get_logs",
data: data
},
error: function (xhr) {
error: function () {
alert("Something was wrong.");
},
success: function (response) {

View file

@ -0,0 +1,54 @@
/*jshint esversion: 6 */
/*
Yuuki_Libs
(c) 2020 Star Inc.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var events = [
"JoinGroup",
"KickEvent",
"CancelEvent"
];
function format2html(title, context) {
return "<div class=\"media pt-3\">" +
"<img class=\"mini-logo mr-2 rounded\" src=\"" + object_server + "/os/g/" + title + "\">" +
"<p class=\"media-body pb-3 mb-0 small lh-125 border-bottom border-gray\">" +
"<strong class=\"d-block text-gray-dark\">" + title + "</strong>" +
context +
"</p>" +
"</div>";
}
$(function () {
url = window.location.href;
$.ajax({
url: "/api",
type: "POST",
data: {
task: "get_groups_joined"
},
error: function () {
alert("Something was wrong.");
},
success: function (response) {
let show = "";
if (response.result.length) {
response.result.forEach(element => {
show += format2html(
element,
element
);
});
} else {
show += "<p class=\"pt-3\">Nothing</p>";
}
$("#groups").html(show);
$("#groups").fadeIn();
}
});
});

View file

@ -0,0 +1,37 @@
/*jshint esversion: 6 */
/*
Yuuki_Libs
(c) 2020 Star Inc.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
function init(id, data) {
$.ajax({
url: "/api",
type: "POST",
data: {
task: "get_logs",
data: data
},
error: function () {
alert("Something was wrong.");
},
success: function (response) {
let ajax_result = response.result;
if (ajax_result.length)
$(id).text(ajax_result[ajax_result.length - 1]);
else
$(id).text("Nothing");
}
});
}
$(function () {
init("#Join_Event", "JoinGroup");
init("#Kick_Event", "KickEvent");
init("#Cancel_Event", "CancelEvent");
init("#Block_Event", "BlackList");
});

View file

@ -31,6 +31,7 @@
<!-- Optional JavaScript -->
{{ bootstrap.load_js() }}
<script>var object_server="{{ LINE_Media_server }}";</script>
<script src="{{ url_for('static', filename='js/header.js') }}"></script>
<script src="{{ url_for('static', filename='js/groups.js') }}"></script>
</body>

View file

@ -0,0 +1,38 @@
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
{{ bootstrap.load_css() }}
<link rel="stylesheet" href="https://unpkg.com/lookforward@0.1.1/css/lookforward.min.css">
<link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}" />
<title>Star Yuuki BOT - WebAdmin</title>
</head>
<body>
{% from 'bootstrap/nav.html' import render_nav_item %}
<div id="header"></div>
<main role="main" class="container">
<div class="my-3 p-3 bg-white rounded shadow-sm">
<h6 class="border-bottom border-gray pb-2 mb-0">Helpers</h6>
<div id="groups">
<p class="pt-3">Loading...</p>
</div>
</div>
</main>
<!-- Optional JavaScript -->
{{ bootstrap.load_js() }}
<script src="{{ url_for('static', filename='js/header.js') }}"></script>
<script src="{{ url_for('static', filename='js/helpers.js') }}"></script>
</body>
</html>

View file

@ -67,6 +67,18 @@
<span id="Cancel_Event">Please wait.</span>
</p>
</a>
<a class="media text-muted pt-3" href="/events#BlackList">
<svg class="bd-placeholder-img mr-2 rounded" width="32" height="32" xmlns="http://www.w3.org/2000/svg"
preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: 32x32">
<title>Block Event</title>
<rect width="100%" height="100%" fill="#00ff00" />
<text x="50%" y="50%" fill="#00ff00" dy=".3em">32x32</text>
</svg>
<p class="media-body pb-3 mb-0 small lh-125 border-bottom border-gray">
<strong class="d-block text-gray-dark">[Block Event]</strong>
<span id="Block_Event">Please wait.</span>
</p>
</a>
</div>
</main>

View file

@ -59,6 +59,9 @@
Turn off the BOT.
</p>
</a>
<small class="d-block text-right mt-3">
<a href="{{ project_url }}" target="_blank">Version: {{ version }}</a>
</small>
</div>
</main>