Skip to content

Commit 382ef95

Browse files
committed
feat: show split button and hash on main layout
1 parent 21b61cc commit 382ef95

5 files changed

Lines changed: 152 additions & 2 deletions

File tree

TelegramDownloader/Pages/Partials/UploadsTable.razor

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@
6060

6161
<GridColumn TItem="UploadModel" HeaderText="Actions">
6262
<div class="action-buttons">
63-
@if (context.state == StateTask.Working && !isPending)
63+
@if (IsSplitting(context) && context.state == StateTask.Working && !isPending)
64+
{
65+
<button class="action-btn splitting" disabled title="Splitting file...">
66+
<i class="bi bi-scissors spin"></i>
67+
</button>
68+
}
69+
else if (context.state == StateTask.Working && !isPending)
6470
{
6571
<button class="action-btn cancel" @onclick="() => cancel(context)" title="Cancel">
6672
<i class="bi bi-x-lg"></i>
@@ -121,16 +127,29 @@
121127
};
122128
}
123129

130+
private bool IsSplitting(UploadModel um)
131+
{
132+
return um is SplitModel || um.action == "Splitting";
133+
}
134+
135+
private bool IsMd5Calculating(UploadModel um)
136+
{
137+
return um is Md5Model || um.action == "MD5 Calc" || um is XxHashModel || um.action == "XxHash Calc";
138+
}
139+
124140
private string GetProgressClass(UploadModel um)
125141
{
126142
if (um.state == StateTask.Completed || um.progress >= 100) return "complete";
127143
if (um.state == StateTask.Error || um.state == StateTask.Canceled) return "error";
144+
if (IsSplitting(um)) return "splitting";
128145
return "";
129146
}
130147

131148
private string GetStatusClass(UploadModel um, bool isPending)
132149
{
133150
if (isPending) return "pending";
151+
if (IsSplitting(um) && um.state == StateTask.Working) return "splitting";
152+
if (IsMd5Calculating(um) && um.state == StateTask.Working) return "calculating";
134153
return um.state switch
135154
{
136155
StateTask.Working => "working",
@@ -144,6 +163,8 @@
144163
private string GetStatusIcon(UploadModel um, bool isPending)
145164
{
146165
if (isPending) return "bi-clock";
166+
if (IsSplitting(um) && um.state == StateTask.Working) return "bi-scissors";
167+
if (IsMd5Calculating(um) && um.state == StateTask.Working) return "bi-calculator";
147168
return um.state switch
148169
{
149170
StateTask.Working => "bi-arrow-up-circle",
@@ -157,6 +178,8 @@
157178
private string GetStatusText(UploadModel um, bool isPending)
158179
{
159180
if (isPending) return "In Queue";
181+
if (IsSplitting(um) && um.state == StateTask.Working) return "Splitting";
182+
if (IsMd5Calculating(um) && um.state == StateTask.Working) return um.action;
160183
return um.state switch
161184
{
162185
StateTask.Working => "Uploading",

TelegramDownloader/Pages/Partials/UploadsTable.razor.css

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,33 @@
257257
color: #ffc107;
258258
}
259259

260+
::deep .status-badge.splitting {
261+
background: rgba(168, 85, 247, 0.2);
262+
color: #a855f7;
263+
}
264+
265+
::deep .status-badge.splitting i {
266+
animation: spin 1s linear infinite;
267+
}
268+
269+
::deep .status-badge.calculating {
270+
background: rgba(59, 130, 246, 0.2);
271+
color: #3b82f6;
272+
}
273+
274+
::deep .status-badge.calculating i {
275+
animation: pulse 1s ease-in-out infinite;
276+
}
277+
260278
::deep .status-badge i {
261279
font-size: 0.6rem;
262280
}
263281

282+
/* Progress bar for splitting */
283+
::deep .progress-bar.splitting {
284+
background: linear-gradient(90deg, #a855f7 0%, #c084fc 100%);
285+
}
286+
264287
/* Action buttons */
265288
::deep .action-buttons {
266289
display: flex;
@@ -310,10 +333,35 @@
310333
color: #5bc0de;
311334
}
312335

336+
::deep .action-btn.splitting {
337+
background: rgba(168, 85, 247, 0.2);
338+
border-color: rgba(168, 85, 247, 0.3);
339+
color: #a855f7;
340+
cursor: not-allowed;
341+
}
342+
343+
::deep .action-btn.splitting:hover {
344+
transform: none;
345+
}
346+
313347
::deep .action-btn i {
314348
font-size: 0.875rem;
315349
}
316350

351+
::deep .action-btn i.spin {
352+
animation: spin 1s linear infinite;
353+
}
354+
355+
@keyframes spin {
356+
from { transform: rotate(0deg); }
357+
to { transform: rotate(360deg); }
358+
}
359+
360+
@keyframes pulse {
361+
0%, 100% { opacity: 1; }
362+
50% { opacity: 0.5; }
363+
}
364+
317365
/* Empty state */
318366
::deep .empty-state {
319367
text-align: center;

TelegramDownloader/Services/TransactionInfoService.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ public bool isUploading()
7575
return uploadModels.Any(x => x.state == StateTask.Working);
7676
}
7777

78+
public bool isSplitting()
79+
{
80+
return uploadModels.Any(x => x.state == StateTask.Working && (x is SplitModel || x.action == "Splitting"));
81+
}
82+
83+
public bool isCalculatingHash()
84+
{
85+
return uploadModels.Any(x => x.state == StateTask.Working && (x is Md5Model || x is XxHashModel || x.action == "MD5 Calc" || x.action == "XxHash Calc"));
86+
}
87+
88+
public bool isRealUploading()
89+
{
90+
return uploadModels.Any(x => x.state == StateTask.Working && x.action == "Upload");
91+
}
92+
7893
public bool isDownloading()
7994
{
8095
return downloadModels.Any(x => x.state == StateTask.Working);

TelegramDownloader/Shared/MainLayout.razor

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,23 @@
8282

8383
<div class="top-row-actions">
8484
@if(active) {
85-
@if (tis.isUploading())
85+
@if (tis.isSplitting())
86+
{
87+
<button class="btn status-btn splitting"
88+
@onclick='() => Navigateto("/downloads?tab=uploads")' title="Splitting file...">
89+
<i class="bi bi-scissors spin"></i>
90+
<span>Splitting</span>
91+
</button>
92+
}
93+
else if (tis.isCalculatingHash())
94+
{
95+
<button class="btn status-btn calculating"
96+
@onclick='() => Navigateto("/downloads?tab=uploads")' title="Calculating hash...">
97+
<i class="bi bi-calculator"></i>
98+
<span>Hashing</span>
99+
</button>
100+
}
101+
else if (tis.isUploading())
86102
{
87103
<button class="btn water-fill-button upload @(GetUploadProgress() > 50 ? "filled-high" : "")"
88104
@onclick='() => Navigateto("/downloads?tab=uploads")' title="Upload in progress">

TelegramDownloader/Shared/MainLayout.razor.css

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,54 @@ main {
122122
color: #e94560;
123123
}
124124

125+
/* Status buttons (splitting, calculating) */
126+
.top-row ::deep .status-btn {
127+
display: flex;
128+
align-items: center;
129+
gap: 0.5rem;
130+
padding: 0.375rem 0.875rem;
131+
border-radius: 2rem;
132+
font-size: 0.8rem;
133+
font-weight: 500;
134+
border: 1px solid;
135+
transition: all 0.2s ease;
136+
}
137+
138+
.top-row ::deep .status-btn.splitting {
139+
background: rgba(168, 85, 247, 0.15);
140+
border-color: rgba(168, 85, 247, 0.3);
141+
color: #c084fc;
142+
}
143+
144+
.top-row ::deep .status-btn.splitting:hover {
145+
background: rgba(168, 85, 247, 0.25);
146+
border-color: rgba(168, 85, 247, 0.5);
147+
}
148+
149+
.top-row ::deep .status-btn.calculating {
150+
background: rgba(59, 130, 246, 0.15);
151+
border-color: rgba(59, 130, 246, 0.3);
152+
color: #60a5fa;
153+
}
154+
155+
.top-row ::deep .status-btn.calculating:hover {
156+
background: rgba(59, 130, 246, 0.25);
157+
border-color: rgba(59, 130, 246, 0.5);
158+
}
159+
160+
.top-row ::deep .status-btn i {
161+
font-size: 1rem;
162+
}
163+
164+
.top-row ::deep .status-btn i.spin {
165+
animation: spin 1s linear infinite;
166+
}
167+
168+
@keyframes spin {
169+
from { transform: rotate(0deg); }
170+
to { transform: rotate(360deg); }
171+
}
172+
125173
@media (max-width: 2048px) {
126174
.page {
127175
flex-direction: column;

0 commit comments

Comments
 (0)