-
-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathUploadFileModalDialog.razor
More file actions
75 lines (70 loc) · 2.93 KB
/
Copy pathUploadFileModalDialog.razor
File metadata and controls
75 lines (70 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<div class="modal @modalClass" tabindex="-1" role="dialog" style="display:@modalDisplay; overflow-y: auto;">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Configuration</h5>
<button type="button" class="btn-close" @onclick="Abort"></button>
</div>
<div class="modal-body">
<EditForm Model="@model" OnValidSubmit="Ok">
<DataAnnotationsValidator />
<div class="form-floating mb-3">
<InputText type="text" class="form-control" id="name" placeholder="Filename"
@bind-Value="model.Name"/>
<label for="name">The filename of the media file. On services like Azure, this can include the directory path.</label>
<ValidationMessage For="() => model.Name"></ValidationMessage>
</div>
<div class="form-check form-switch mb-3">
<InputCheckbox class="form-check-input" id="cache" @bind-Value="model.CacheMedia" />
<label class="form-check-label" for="cache">Enable Media Caching</label><br />
<small class="form-text text-body-secondary">
If enabled, the "Cache-Control" header will be set automatically.<br/>
The value is set to one week. If disabled, no header will be set.
</small>
</div>
</EditForm>
</div>
<div class="modal-footer">
<button id="abort" type="button" class="btn btn-secondary" @onclick="Abort">Abort</button>
<button type="button" class="btn btn-primary" @onclick="Ok">OK</button>
</div>
</div>
</div>
</div>
@if (showBackdrop)
{
<div class="modal-backdrop fade show"></div>
}
@code {
private TaskCompletionSource<UploadFileModalDialogObject?> result = null!;
private string modalDisplay = "none;";
private string modalClass = "";
private bool showBackdrop;
private readonly UploadFileModalDialogObject model = new();
public async Task<UploadFileModalDialogObject?> ShowAsync(string fileName)
{
modalDisplay = "block;";
modalClass = "show";
showBackdrop = true;
model.Name = fileName;
result = new TaskCompletionSource<UploadFileModalDialogObject?>();
StateHasChanged();
return await result.Task;
}
private void Abort()
{
modalDisplay = "none";
modalClass = string.Empty;
showBackdrop = false;
result.SetResult(null);
StateHasChanged();
}
private void Ok()
{
modalDisplay = "none";
modalClass = string.Empty;
showBackdrop = false;
result.SetResult(model);
StateHasChanged();
}
}