2024-06-07 04:25:21 +00:00
|
|
|
@inject IJSRuntime JS
|
|
|
|
@inject State State
|
|
|
|
|
|
|
|
<div class="overlay" data-ui="#@id"></div>
|
|
|
|
<dialog id="@id">
|
2024-06-11 07:24:52 +00:00
|
|
|
<img src="@Pic?.Url" />
|
2024-06-07 04:25:21 +00:00
|
|
|
<div class="row">
|
|
|
|
<div class="field textarea label border max">
|
|
|
|
<InputTextArea @bind-Value="Description"></InputTextArea>
|
|
|
|
<label>Description</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<nav class="right-align no-space">
|
|
|
|
<button class="transparent link" data-ui="#@id" disabled="@loading">Cancel</button>
|
|
|
|
<button @onclick="PostPic" disabled="@loading">
|
|
|
|
@if (loading) {
|
|
|
|
<span>Saving...</span>
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
<i class="fa-solid fa-floppy-disk"></i> <span>Save</span>
|
|
|
|
}
|
|
|
|
</button>
|
|
|
|
</nav>
|
|
|
|
</dialog>
|
|
|
|
|
|
|
|
@code {
|
|
|
|
private Pic? _pic;
|
2024-06-11 07:24:52 +00:00
|
|
|
|
2024-06-07 04:25:21 +00:00
|
|
|
public Pic? Pic {
|
|
|
|
get => _pic;
|
|
|
|
set {
|
|
|
|
_pic = value;
|
|
|
|
Description = _pic?.Description;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public string? Description { get; set; }
|
|
|
|
private bool loading = false;
|
|
|
|
[Parameter]
|
|
|
|
public string id { get; set; }
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync() {
|
|
|
|
Description = Pic?.Description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task PostPic() {
|
|
|
|
loading = true;
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
|
|
|
|
RestService api = new RestService();
|
|
|
|
if(!string.IsNullOrEmpty(Pic.Id)) {
|
|
|
|
await api.PostPicDescription(State.SelectedAddressName, Pic.Id, Description);
|
|
|
|
await State.RefreshPics();
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
await JS.InvokeVoidAsync("ui", "#" + id);
|
|
|
|
// clear input
|
|
|
|
Description = string.Empty;
|
|
|
|
Pic = null;
|
|
|
|
loading = false;
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|