|
52 | 52 | </GridColumn> |
53 | 53 |
|
54 | 54 | <GridColumn TItem="UploadModel" HeaderText="Status"> |
55 | | - <span class="status-badge @GetStatusClass(context)"> |
56 | | - <i class="bi @GetStatusIcon(context)"></i> |
57 | | - @GetStatusText(context) |
| 55 | + <span class="status-badge @GetStatusClass(context, isPending)"> |
| 56 | + <i class="bi @GetStatusIcon(context, isPending)"></i> |
| 57 | + @GetStatusText(context, isPending) |
58 | 58 | </span> |
59 | 59 | </GridColumn> |
60 | 60 |
|
61 | 61 | <GridColumn TItem="UploadModel" HeaderText="Actions"> |
62 | 62 | <div class="action-buttons"> |
63 | | - @if (context.state == StateTask.Working) |
| 63 | + @if (context.state == StateTask.Working && !isPending) |
64 | 64 | { |
65 | 65 | <button class="action-btn cancel" @onclick="() => cancel(context)" title="Cancel"> |
66 | 66 | <i class="bi bi-x-lg"></i> |
67 | 67 | </button> |
68 | 68 | } |
69 | 69 |
|
70 | | - @if (context.state == StateTask.Canceled || context.state == StateTask.Error) |
| 70 | + @if ((context.state == StateTask.Canceled || context.state == StateTask.Error) && !isPending) |
71 | 71 | { |
72 | 72 | <button class="action-btn retry" @onclick="() => retry(context)" title="Retry"> |
73 | 73 | <i class="bi bi-arrow-clockwise"></i> |
74 | 74 | </button> |
| 75 | + } |
| 76 | + |
| 77 | + @if (context.state == StateTask.Canceled || context.state == StateTask.Error || isPending) |
| 78 | + { |
75 | 79 | <button class="action-btn delete" @onclick="() => deleteUpload(context)" title="Delete"> |
76 | 80 | <i class="bi bi-trash3"></i> |
77 | 81 | </button> |
|
88 | 92 | <TelegramDownloader.Pages.Modals.InfoModals.UploadFileInfoModal @ref="infoModal" OnClose="OnModalClose"></TelegramDownloader.Pages.Modals.InfoModals.UploadFileInfoModal> |
89 | 93 |
|
90 | 94 | @code { |
| 95 | + [Parameter] |
| 96 | + public bool isPending { get; set; } = false; |
| 97 | + |
91 | 98 | [Parameter] |
92 | 99 | public EventCallback OnUploadModalClose { get; set; } |
93 | 100 |
|
|
121 | 128 | return ""; |
122 | 129 | } |
123 | 130 |
|
124 | | - private string GetStatusClass(UploadModel um) |
| 131 | + private string GetStatusClass(UploadModel um, bool isPending) |
125 | 132 | { |
| 133 | + if (isPending) return "pending"; |
126 | 134 | return um.state switch |
127 | 135 | { |
128 | 136 | StateTask.Working => "working", |
|
133 | 141 | }; |
134 | 142 | } |
135 | 143 |
|
136 | | - private string GetStatusIcon(UploadModel um) |
| 144 | + private string GetStatusIcon(UploadModel um, bool isPending) |
137 | 145 | { |
| 146 | + if (isPending) return "bi-clock"; |
138 | 147 | return um.state switch |
139 | 148 | { |
140 | 149 | StateTask.Working => "bi-arrow-up-circle", |
|
145 | 154 | }; |
146 | 155 | } |
147 | 156 |
|
148 | | - private string GetStatusText(UploadModel um) |
| 157 | + private string GetStatusText(UploadModel um, bool isPending) |
149 | 158 | { |
| 159 | + if (isPending) return "In Queue"; |
150 | 160 | return um.state switch |
151 | 161 | { |
152 | 162 | StateTask.Working => "Uploading", |
|
188 | 198 |
|
189 | 199 | private async Task deleteUpload(UploadModel um) |
190 | 200 | { |
| 201 | + if (isPending) |
| 202 | + { |
| 203 | + tis.deletePendingUploadInList(um); |
| 204 | + return; |
| 205 | + } |
191 | 206 | tis.deleteUploadInList(um); |
192 | 207 | } |
193 | 208 |
|
194 | 209 | private async Task<GridDataProviderResult<UploadModel>> UploadsDataProvider(GridDataProviderRequest<UploadModel> request) |
195 | 210 | { |
196 | 211 | await getUploadModels(request.PageNumber - 1, request.PageSize, lum.Count() == 0); |
197 | | - int totalUploads = tis.getTotalUploads(); |
198 | | - return await Task.FromResult(new GridDataProviderResult<UploadModel> { Data = lum ?? new List<UploadModel>(), TotalCount = totalUploads });//request.ApplyTo(uploads)); |
| 212 | + int totalUploads = tis.getTotalUploads(isPending); |
| 213 | + return await Task.FromResult(new GridDataProviderResult<UploadModel> { Data = lum ?? new List<UploadModel>(), TotalCount = totalUploads }); |
199 | 214 | } |
200 | 215 |
|
201 | 216 | private async Task getUploadModels(int pageNumber, int pageSize, bool mustCallEnventHandler = false) |
202 | 217 | { |
203 | | - lum = tis.GetUploadModels(pageNumber, pageSize); |
| 218 | + lum = tis.GetUploadModels(pageNumber, pageSize, isPending); |
204 | 219 | if (mustCallEnventHandler) |
205 | 220 | checkNewEventsHandler(); |
206 | | - // await InvokeAsync(StateHasChanged); |
207 | 221 | } |
208 | 222 |
|
209 | 223 | private void checkNewEventsHandler() |
|
0 commit comments