Add debounce and stylize

This commit is contained in:
2026-03-06 17:19:45 -08:00
parent 405872da39
commit 54ea7c3027
2 changed files with 84 additions and 45 deletions
+36 -22
View File
@@ -29,6 +29,7 @@
<!-- User Frame --> <!-- User Frame -->
}else{ }else{
<div class="gridFrame"> <div class="gridFrame">
<div><h2>Account</h2></div>
<span>UserName: @Session.UserName</span><br /> <span>UserName: @Session.UserName</span><br />
<div> <div>
@foreach(PurchasedStock cur in Session.TrackedStocks){ @foreach(PurchasedStock cur in Session.TrackedStocks){
@@ -42,10 +43,16 @@
<!-- Tool Frame --> <!-- Tool Frame -->
<div class="gridFrame"> <div class="gridFrame">
<div> <div>
<span>Actions</span> <div><h2>Actions</h2></div>
@if (Debounce){
<button @onclick="pull">@pullButtonText</button> <button @onclick="pull">@pullButtonText</button>
<button @onclick="train">@trainButtonText</button> <button @onclick="train">@trainButtonText</button>
<button @onclick="predict">@predictButtonText</button> <button @onclick="predict">@predictButtonText</button>
}else{
<button disabled>@pullButtonText</button>
<button disabled>@trainButtonText</button>
<button disabled>@predictButtonText</button>
}
<span>@PredictError</span> <span>@PredictError</span>
</div> </div>
</div> </div>
@@ -54,23 +61,27 @@
<!-- AI Frame --> <!-- AI Frame -->
<div class="gridFrame"> <div class="gridFrame">
<div> <div>
<h2>Current Signal</h2>
</div>
@foreach (stockPredictionPair cur in predictions){
<div class="signalBlock">
<div>
<p>@cur.Symbol</p>
</div>
<div>
<span>-></span>
</div>
@if (cur.Movement == -1){
<div style="background-color: red;"><p style=>Sell</p></div>
} else if (cur.Movement == 1){
<div style="background-color: green;"><p>Buy</p></div>
} else{
<div style="background-color: #444;"><p>Hold</p></div>
}
</div> </div>
<div>
@foreach (stockPredictionPair cur in predictions){
<div>
<h1>Symbol: @cur.Symbol</h1><br />
@if (cur.Movement == -1){
<p>Sell</p>
} else if (cur.Movement == 1){
<p>Buy</p>
} else{
<p>Hold</p>
} }
</div> </div>
}
</div>
</div>
</div> </div>
@@ -127,11 +138,11 @@
string predictButtonText = "Predict AI"; string predictButtonText = "Predict AI";
string PredictError = ""; string PredictError = "";
bool pullDebounce = true; bool Debounce = true;
async Task pull(){ async Task pull(){
PredictError = ""; PredictError = "";
if (pullDebounce){ if (Debounce){
pullDebounce = false; Debounce = false;
pullButtonText = "Do not refresh the page. The data is pulling."; pullButtonText = "Do not refresh the page. The data is pulling.";
await Task.Delay(1); await Task.Delay(1);
Task thread = new Task(async () => { Task thread = new Task(async () => {
@@ -141,17 +152,16 @@
await Task.Delay(2000); await Task.Delay(2000);
pullButtonText = "Pull Data"; pullButtonText = "Pull Data";
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
pullDebounce = true; Debounce = true;
}); });
thread.Start(); thread.Start();
} }
} }
bool trainDebounce = true;
async Task train(){ async Task train(){
PredictError = ""; PredictError = "";
if (trainDebounce){ if (Debounce){
trainDebounce = false; Debounce = false;
trainButtonText = "Do not refresh the page. The AI is training."; trainButtonText = "Do not refresh the page. The AI is training.";
await Task.Delay(1); await Task.Delay(1);
Task thread = new Task(async () => { Task thread = new Task(async () => {
@@ -161,7 +171,7 @@
await Task.Delay(2000); await Task.Delay(2000);
trainButtonText = "Train AI"; trainButtonText = "Train AI";
StateHasChanged(); StateHasChanged();
trainDebounce = true; Debounce = true;
}); });
thread.Start(); thread.Start();
} }
@@ -169,6 +179,8 @@
async Task predict(){ async Task predict(){
PredictError = ""; PredictError = "";
if (Debounce){
Debounce = false;
predictButtonText = "Do not refresh the page. The AI is predicting"; predictButtonText = "Do not refresh the page. The AI is predicting";
await Task.Delay(1); await Task.Delay(1);
List<Task> threadpool = new List<Task>(); List<Task> threadpool = new List<Task>();
@@ -189,6 +201,8 @@
predictButtonText = "Predictions loaded"; predictButtonText = "Predictions loaded";
await Task.Delay(2000); await Task.Delay(2000);
predictButtonText = "Predict AI"; predictButtonText = "Predict AI";
Debounce = true;
}
} }
// Data Types // Data Types
+26 -1
View File
@@ -5,7 +5,6 @@
grid-auto-columns: auto; grid-auto-columns: auto;
grid-auto-flow: column; grid-auto-flow: column;
grid-template-columns: max-content; grid-template-columns: max-content;
overflow: scroll;
} }
.gridFrame { .gridFrame {
@@ -60,3 +59,29 @@
.loginRow button:last-of-type{ .loginRow button:last-of-type{
float: right; float: right;
} }
.signalBlock {
display: flex;
}
.signalBlock > :nth-child(1) {
border: solid #040 1px;
border-radius: 15px;
width: 40px;
padding: 0px 20px;
background-color: greenyellow;
}
.signalBlock > :nth-child(2) {
padding: 0 30px;
font-size: 30px;
align-content: center;
}
.signalBlock > :nth-child(3) {
color: white;
padding: 0 30px;
width: 40px;
border: solid #000 1px;
border-radius: 15px;
}