TDD: 1, Me: 0

This commit is contained in:
2024-12-13 18:08:44 +02:00
commit 9c1cfa7c23
36 changed files with 2374 additions and 0 deletions

202
app/ui/Apache-2.0 Normal file
View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

9
app/ui/__init__.py Normal file
View File

@@ -0,0 +1,9 @@
from flask import Blueprint
ui_bp = Blueprint(
'ui',
__name__,
template_folder='templates', # Path to your HTML templates folder
static_folder='static', # Path to your static files folder
static_url_path='/ui/static' # URL path to access static files
)

1
app/ui/static/css/flexboxgrid.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
@font-face {
font-family: 'Oswald';
font-style: normal;
font-weight: 200;
font-display: swap;
src: url(./TK3_WkUHHAIjg75cFRf3bXL8LICs13FvgUE.ttf) format('truetype');
}
@font-face {
font-family: 'Oswald';
font-style: normal;
font-weight: 600;
font-display: swap;
src: url(./TK3_WkUHHAIjg75cFRf3bXL8LICs1y9ogUE.ttf) format('truetype');
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

1
app/ui/static/css/reset.min.css vendored Normal file
View File

@@ -0,0 +1 @@
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}table{border-collapse:collapse;border-spacing:0}

419
app/ui/static/css/style.css Normal file
View File

@@ -0,0 +1,419 @@
@import url("./fonts/oswald.css");
body {
overflow: hidden;
font-family: "Oswald", sans-serif;
background-color: #212121;
}
body section {
width: 90%;
max-width: 1200px;
margin: 0 auto;
}
body section .row {
align-items: center;
height: 100vh;
}
.card {
position: relative;
height: 400px;
width: 100%;
margin: 10px 0;
transition: ease all 2.3s;
perspective: 1200px;
}
.card:hover .cover {
transform: rotateX(0deg) rotateY(-180deg);
}
.card:hover .cover:before {
transform: translateZ(30px);
}
.card:hover .cover:after {
background-color: black;
}
.card:hover .cover h1 {
transform: translateZ(100px);
}
.card:hover .cover .price {
transform: translateZ(60px);
}
.card:hover .cover a {
transform: translateZ(-60px) rotatey(-180deg);
}
.card .cover {
position: absolute;
height: 100%;
width: 100%;
transform-style: preserve-3d;
transition: ease all 2.3s;
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}
.card .cover:before {
content: "";
position: absolute;
border: 5px solid rgba(255, 255, 255, 0.5);
box-shadow: 0 0 12px rgba(0, 0, 0, 0.3);
top: 20px;
left: 20px;
right: 20px;
bottom: 20px;
z-index: 2;
transition: ease all 2.3s;
transform-style: preserve-3d;
transform: translateZ(0px);
}
.card .cover:after {
content: "";
position: absolute;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
z-index: 2;
transition: ease all 1.3s;
background: rgba(0, 0, 0, 0.4);
}
.card .cover.item-a {
background-image: url("./images/img1.jpeg");
}
.card .cover.item-b {
background-image: url("./images/img2.jpeg");
}
.card .cover.item-c {
background-image: url("./images/img3.jpeg");
}
.card .cover h1 {
font-weight: 600;
position: absolute;
bottom: 55px;
left: 50px;
color: white;
transform-style: preserve-3d;
transition: ease all 2.3s;
z-index: 3;
font-size: 3em;
transform: translateZ(0px);
}
.card .cover .price {
font-weight: 200;
position: absolute;
top: 55px;
right: 50px;
color: white;
transform-style: preserve-3d;
transition: ease all 2.3s;
z-index: 4;
font-size: 2em;
transform: translateZ(0px);
}
.card .card-back {
position: absolute;
height: 100%;
width: 100%;
background: #0b0f08;
transform-style: preserve-3d;
transition: ease all 2.3s;
transform: translateZ(-1px);
display: flex;
align-items: center;
justify-content: center;
}
.card .card-back a {
transform-style: preserve-3d;
transition: ease transform 2.3s, ease background 0.5s;
transform: translateZ(-1px) rotatey(-180deg);
background: transparent;
border: 1px solid white;
font-weight: 200;
font-size: 1.3em;
color: white;
padding: 14px 32px;
outline: none;
text-decoration: none;
}
.card .card-back a:hover {
background-color: white;
color: #0b0f08;
}
h3 {
color: #62f5c8;
}
.modal-wrapper {
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
background: rgba(0, 0, 0, 0); /* Start with transparent background */
box-sizing: border-box;
cursor: auto;
opacity: 1;
overflow-y: auto;
transition: 0.5s background ease, 0.5s opacity ease;
z-index: 100;
align-items: center;
display: flex;
justify-content: center;
padding: 15px;
display:none;
opacity:0;
}
.modal-container {
background-color: #001020;
border-radius: 5px;
margin: auto;
max-width: 700px;
min-width: 200px;
position: relative;
padding: 20px;
color: #fff;
transform: scale(0);
transition: transform 0.5s ease;
}
.modal-wrapper.show .modal-container {
transform: scale(1);
}
.modal-wrapper.show {
background: #254642d9;
}
.modal-close {
background: none;
border: none;
color: #62f5c8;
cursor: pointer;
outline: none;
padding: 0;
position: absolute;
right: 20px;
top: 20px;
z-index: 10;
}
.modal-heading {
text-align: center; /* Center align the heading */
}
.modal-timer {
width: 0%;
height: 4px;
background: #42C0F2; /* Change color as needed */
position: absolute;
bottom: 0;
left: 0;
border-top-right-radius: 5px;
box-shadow: 0 0 8px #42C0F2;
}
.timer-animation {
animation: countdown 5s linear forwards;
}
@keyframes countdown {
from {
width: 100%;
}
to {
width: 0%;
}
}
.spinner {
color: #45d6b5;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 280px;
height: 280px;
display: flex;
align-items: center;
justify-content: center;
}
.semi-circle {
position: absolute;
border-radius: 50%;
border: 10px solid transparent;
border-top-color: transparent; /* Color for the first semi-circle */
transform-origin: center;
}
.semi-circle-1 {
width: 300px; /* Smaller radius */ height: 300px; top: 50%; left: 50%; transform: translate(-50%, -50%);
border-top-color: #45d6b5;
animation: rotate-circle-1 2s linear infinite;
}
.semi-circle-2 {
width: 350px; /* Medium radius */ height: 350px; top: 50%; left: 50%; transform: translate(-50%, -50%);
border-top-color: #ff5733;
animation: rotate-circle-2 3s linear infinite;
}
.semi-circle-3 {
width: 400px; /* Larger radius */ height: 400px; top: 50%; left: 50%; transform: translate(-50%, -50%);
border-top-color: #42f58d;
animation: rotate-circle-3 4s linear infinite;
}
@keyframes rotate-circle-1 {
0% { transform: translate(-50%, -50%) rotate(0deg); }
100% { transform: translate(-50%, -50%) rotate(360deg); }
}
@keyframes rotate-circle-2 {
0% { transform: translate(-50%, -50%) rotate(120deg); }
100% { transform: translate(-50%, -50%) rotate(480deg); }
}
@keyframes rotate-circle-3 {
0% { transform: translate(-50%, -50%) rotate(240deg); }
100% { transform: translate(-50%, -50%) rotate(600deg); }
}
.preloader {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
display: none;
justify-content: center;
align-items: center;
flex-direction: column;
z-index: 1000;
}
.progress-container {
width: 300px;
height: 2px;
background: rgba(255, 255, 255, 0.1);
margin-bottom: 20px;
position: relative;
z-index: 2;
}
.progress-bar {
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 0%;
}
.percentage {
position: fixed;
bottom: 32px;
right: 32px;
font-weight: 300;
font-size: 15rem;
line-height: 0.8;
opacity: 0.1;
}
.text-container {
height: 3em;
position: relative;
overflow: hidden;
margin: 20px 0;
width: 200px;
}
.loading-text {
font-weight: 300;
font-size: 1rem;
text-transform: uppercase;
letter-spacing: -0.02em;
position: absolute;
width: 100%;
text-align: center;
}
.loading-text.initial {
transform: translateY(0);
}
.loading-text.complete {
transform: translateY(100%);
}
.loading-text .char {
display: inline-block;
}
.content {
margin: auto;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
visibility: hidden;
z-index: 1;
overflow: auto;
}
.content h1 {
font-size: 3rem;
margin-bottom: 1rem;
overflow: hidden;
}
.content p {
font-size: 1.2rem;
overflow: hidden;
}
.content .char {
display: inline-block;
transform: translateY(100%);
opacity: 0;
}
/* Add these classes for the stagger animation */
.preloader-item {
opacity: 1;
transform: translateY(0);
}
/* Media Queries for Mobile Devices */
@media (max-width: 768px) {
.spinner {
width: 140px;
height: 140px;
}
.semi-circle-1 {
width: 150px;
height: 150px;
}
.semi-circle-2 {
width: 175px;
height: 175px;
}
.semi-circle-3 {
width: 200px;
height: 200px;
}
.percentage {
font-size: 10rem;
}
.content {
max-height: calc(100vh - 7vh);
}
body section .row{
padding-top: 3.5vh; /* Adjust this value as needed */
padding-bottom: 3.5vh; /* Adjust this value as needed */
box-sizing: border-box;
}
}

BIN
app/ui/static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 687 B

260
app/ui/static/script.js Normal file
View File

@@ -0,0 +1,260 @@
// Disable GSAP's use of requestAnimationFrame
gsap.ticker.fps(60);
gsap.ticker.lagSmoothing(0);
// Add an event listener to call showLoadingSpinner when the DOM is fully loaded
// document.addEventListener('DOMContentLoaded', function() { showLoadingSpinner(); });
function select(selector) {
return document.querySelector(selector);
}
function showLoadingSpinner() {
const spinner = select("#loading-spinner");
spinner.style.display = "block";
}
function hideLoadingSpinner() {
const spinner = select("#loading-spinner");
spinner.style.display = "none";
}
document.addEventListener("click", debounce((e) => {
if (e.target.closest(`[data-action="openModal"]`)) {
const device = e.target.dataset.device;
const action = e.target.dataset.actionType;
let url = `/${action}/${device}`;
if (action === "wol") {
fetchKey().then((key) => {
url += `?key=${key}`;
showLoadingSpinner();
openModal(url);
}).catch(error => {
console.error('Error fetching key:', error);
});
} else {
showLoadingSpinner();
openModal(url);
}
}
if (
e.target.closest(`[data-action="closeModal"]`) ||
e.target.classList.contains("modal-wrapper")
) {
closeModal();
}
}, 300));
let countdown;
async function fetchKey() {
try {
const response = await fetch('/get_key');
const data = await response.json();
return data.key;
} catch (error) {
console.error('Error fetching key:', error);
throw error;
}
}
function openModal(url) {
closeExistingModal().then(() => {
fetch(url)
.then(response => response.text())
.then(html => {
hideLoadingSpinner();
const modal = `
<div class="modal-wrapper">
<div class="modal-container">
<button class="modal-close" data-action="closeModal">
<svg viewBox="0 0 20 20" width="16" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round">
<path d="M 2 2 L 18 18" stroke-width="3" fill="transparent"></path>
<path d="M 18 2 L 2 18" stroke-width="3" fill="transparent"></path>
</svg>
</button>
<h3 class="modal-heading">Server says</h3>
<br>
${html}
<div class="modal-timer" id="modal-timer"></div>
</div>
</div>`;
select("body").insertAdjacentHTML("beforeend", modal);
const wrapper = select(".modal-wrapper");
wrapper.style.display = "flex";
select("body").style.overflow = "hidden";
setTimeout(() => {
wrapper.style.opacity = 1;
wrapper.classList.add("show");
startCountdown();
}, 100);
}).catch(error => {
hideLoadingSpinner();
console.error('Error fetching content:', error)
});
});
}
function closeModal() {
const wrapper = document.querySelector(".modal-wrapper");
return new Promise((resolve) => {
if (wrapper) {
const container = document.querySelector(".modal-container");
if (container) {
container.style.transform = 'scale(0)';
}
wrapper.style.opacity = 0;
setTimeout(() => {
if (wrapper.parentNode) {
wrapper.remove();
}
select("body").style.overflow = "";
clearTimeout(countdown);
resolve();
}, 500);
} else {
resolve();
}
});
}
function closeExistingModal() {
const existingWrapper = document.querySelector(".modal-wrapper");
return new Promise((resolve) => {
if (existingWrapper) {
existingWrapper.style.opacity = 0;
setTimeout(() => {
if (existingWrapper.parentNode) {
existingWrapper.remove();
}
select("body").style.overflow = ""; // Reset body overflow
clearTimeout(countdown); // Clear any existing countdown
resolve();
}, 500);
} else {
resolve();
}
});
}
function startCountdown() {
const timer = document.getElementById('modal-timer');
if (timer) {
timer.classList.add('timer-animation');
countdown = setTimeout(() => {
closeModal();
}, 5000);
}
}
/* Debounce Function */
function debounce(func, wait) {
let timeout;
return function(...args) {
clearTimeout(timeout);
timeout = setTimeout(() => func.apply(this, args), wait);
};
}
window.onload = function() {
document.querySelector(".preloader").style.display = 'flex';
const loadingText = new SplitType(".loading-text.initial", { types: "chars" });
const completeText = new SplitType(".loading-text.complete", { types: "chars" });
const titleText = new SplitType(".content h1", { types: "chars" });
const paragraphText = new SplitType(".content p", { types: "chars" });
gsap.set(".loading-text.complete", { y: "100%" });
gsap.set(loadingText.chars, { opacity: 0, y: 100 });
gsap.set(completeText.chars, { opacity: 0, y: 100 });
gsap.to(loadingText.chars, {
opacity: 1,
y: 0,
duration: 0.5,
stagger: 0.05,
ease: "power2.out"
});
const colorStages = [
{ bg: "rgb(60, 66, 55)", text: "rgb(230, 225, 215)" },
{ bg: "rgb(200, 180, 160)", text: "rgb(60, 66, 55)" },
{ bg: "rgb(230, 225, 215)", text: "rgb(60, 66, 55)" },
{ bg: "rgb(100, 110, 90)", text: "rgb(230, 225, 215)" }
];
function updateColors(progress) {
const stage = Math.floor(progress / 25);
if (stage < colorStages.length) {
document.querySelector(".preloader").style.backgroundColor = colorStages[stage].bg;
document.querySelector(".progress-bar").style.backgroundColor = colorStages[stage].text;
document.querySelectorAll(".loading-text .char, .percentage").forEach((el) => {
el.style.color = colorStages[stage].text;
});
}
}
const tl = gsap.timeline({ paused: true });
tl.to(".progress-bar", {
width: "100%",
duration: 5,
ease: "power1.inOut",
onUpdate: function () {
const progress = Math.round(this.progress() * 100);
document.querySelector(".percentage").textContent = progress;
updateColors(progress);
}
}).to(".loading-text.initial", {
y: "-100%",
duration: 0.5,
ease: "power2.inOut"
}).to(".loading-text.complete", {
y: "0%",
duration: 0.5,
ease: "power2.inOut"
}, "<" ).to(completeText.chars, {
opacity: 1,
y: 0,
duration: 0.3,
stagger: 0.03,
ease: "power2.out"
}, "<0.2" ).to(".preloader", {
y: "-100vh",
duration: 1,
ease: "power2.inOut",
delay: 0.8
}).set(".content", {
visibility: "visible"
}, "-=1").to([titleText.chars, paragraphText.chars], {
opacity: 1,
y: 0,
duration: 1,
stagger: 0.02,
ease: "power4.out"
}, "-=0.5").set(".preloader", {
display: "none" });
let isFirstLoad = !localStorage.getItem('firstLoadDone');
if (!isFirstLoad) {
const tl = gsap.timeline();
tl.set(".preloader", {
display: "none"
}).set(".content", {
visibility: "visible"
}, "-=1").to([titleText.chars, paragraphText.chars], {
opacity: 1,
y: 0,
duration: 2,
stagger: 0.04,
ease: "power2.out"
}, "=0.5")
} else {
document.querySelector('.preloader').style.display = 'flex';
tl.play(); // Start the GSAP timeline
localStorage.setItem('firstLoadDone', 'true');
}
};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="{{ url_for('ui.static', filename='css/style.css') }}">
<link rel="stylesheet" href="{{ url_for('ui.static', filename='css/reset.min.css') }}">
<link rel="stylesheet" href="{{ url_for('ui.static', filename='css/flexboxgrid.min.css') }}">
<link rel="icon" href="{{ url_for('ui.static', filename='favicon.ico') }}" type="image/x-icon">
<script src="{{ url_for('ui.static', filename='split-type.js') }}"></script>
<script src="{{ url_for('ui.static', filename='gsap.min.js') }}"></script>
<script src="{{ url_for('ui.static', filename='script.js') }}"></script>
<title>Devices</title>
</head>
<body>
<div class="preloader">
<div class="progress-container">
<div class="progress-bar"></div>
</div>
<div class="text-container">
<div class="loading-text initial">Loading</div>
<div class="loading-text complete">Complete</div>
</div>
<div class="percentage">0</div>
</div>
<div class="content">
<section>
<div class="row">
{% set classes = ["item-a", "item-b", "item-c"] %}
{% for device in devices %}
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="card">
<div class="cover {{ classes[loop.index0 % classes|length] }}">
<h1>{{ device|capitalize }}</h1>
<div class="card-back">
<a href="javascript:void(0);" data-action="openModal" data-action-type="wol" data-device="{{ device }}">Wake Up</a>
<a href="javascript:void(0);" data-action="openModal" data-action-type="ping" data-device="{{ device }}">Ping</a>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</section>
<div id="loading-spinner" class="spinner" style="display: none;">
<div class="semi-circle semi-circle-1"></div>
<div class="semi-circle semi-circle-2"></div>
<div class="semi-circle semi-circle-3"></div>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1"> <path opacity="0.3"> <animate attributeName="d" dur="1s" repeatCount="indefinite" values="M12 2 Q9 2.2 7.3 7 Q6.5 9.5 6.5 12 Q6.5 15 7.3 17 Q9 22 12 22;M12 2 Q6.5 2.2 3.3 7 Q2 9.5 2 12 Q2 15 3.4 17 Q6.5 22 12 22;" /> </path> <path opacity="0.3"> <animate attributeName="d" dur="1s" repeatCount="indefinite" values="M12 2 Q12 2.2 12 7 Q12 9.5 12 12 Q12 15 12 17 Q12 22 12 22;M12 2 Q9 2.2 7.3 7 Q6.5 9.5 6.5 12 Q6.5 15 7.3 17 Q9 22 12 22;" /> </path> <path opacity="0.3"> <animate attributeName="d" dur="1s" repeatCount="indefinite" values="M12 2 Q15 2.2 16.6 7 Q17.5 9.5 17.5 12 Q17.5 15 16.7 17 Q15 22 12 22;M12 2 Q12 2.2 12 7 Q12 9.5 12 12 Q12 15 12 17 Q12 22 12 22;" /> </path> <path opacity="0.3"> <animate attributeName="d" dur="1s" repeatCount="indefinite" values="M12 2 Q17.5 2.2 20.7 7 Q22 9.5 22 12 Q22 15 20.6 17 Q17.5 22 12 22;M12 2 Q15 2.2 16.6 7 Q17.5 9.5 17.5 12 Q17.5 15 16.7 17 Q15 22 12 22;" /> </path> <circle cx="12" cy="12" r="10" /> <path d="M2.4 8.6 Q6 7.1 12 7 Q18 7.1 21.6 8.6" /> <path d="M2.4 15.2 Q6 17.1 12 17.2 Q17 17.1 21.6 15.2" /> <path> <animate attributeName="d" dur="1s" repeatCount="indefinite" values="M12 2 Q6.5 2.2 3.3 7 Q2 9.5 2 12 Q2 15 3.4 17 Q6.5 22 12 22;M12 2 Q9 2.2 7.3 7 Q6.5 9.5 6.5 12 Q6.5 15 7.3 17 Q9 22 12 22;" /> </path> <path> <animate attributeName="d" dur="1s" repeatCount="indefinite" values="M12 2 Q9 2.2 7.3 7 Q6.5 9.5 6.5 12 Q6.5 15 7.3 17 Q9 22 12 22;M12 2 Q12 2.2 12 7 Q12 9.5 12 12 Q12 15 12 17 Q12 22 12 22;" /> </path> <path> <animate attributeName="d" dur="1s" repeatCount="indefinite" values="M12 2 Q12 2.2 12 7 Q12 9.5 12 12 Q12 15 12 17 Q12 22 12 22;M12 2 Q15 2.2 16.6 7 Q17.5 9.5 17.5 12 Q17.5 15 16.7 17 Q15 22 12 22;M12 2 Q17.5 2.2 20.7 7 Q22 9.5 22 12 Q22 15 20.6 17 Q17.5 22 12 22;" /> </path> </svg>
</div>
</div>
</body>
</html>

33
app/ui/ui.py Normal file
View File

@@ -0,0 +1,33 @@
from flask import Flask, render_template, request, send_from_directory
import httpx
import asyncio
from dotenv import load_dotenv
from . import ui_bp
import os
load_dotenv() # Load environment variables from .env file
def get_devices():
devices = []
for key in os.environ:
if key.endswith('_MAC'):
device_name = key[:-4].lower() # Get device name
devices.append(device_name)
return devices
def setup_ui(limiter, app):
# Serve static files and exempt from rate limiting
@app.route('/ui/static/<path:filename>')
@limiter.exempt
def serve_static(filename):
static_dir = os.path.join(app.root_path, 'ui', 'static')
return send_from_directory(static_dir, filename)
@ui_bp.route('/')
@limiter.exempt
def home():
devices = get_devices()
return render_template('home.html', devices=devices)
app.register_blueprint(ui_bp)