Aggiunto componente copia testo da pagina x licenza

This commit is contained in:
Samuele Locatelli
2021-10-14 10:53:53 +02:00
parent 575806e5f3
commit 80df728dd2
5 changed files with 65 additions and 6 deletions
+48
View File
@@ -0,0 +1,48 @@
@using System
@inject IJSRuntime JSRuntime
<div class="form-inline">
<input class="form-control" readonly type="text" value="@Text" />
<button type="button" class="btn @btnStyle" @onclick="CopyTextToClipboard" title="Copy to Clipboard">
@if (copyDone)
{
<span><i class="far fa-thumbs-up"></i></span>
}
else
{
<span><i class="far fa-copy"></i></span>
}
</button>
</div>
@code {
/// <summary>
/// Metodi per copia verso clipboard:
/// link:
/// - https://chrissainty.com/copy-to-clipboard-in-blazor/
/// - https://www.daveabrock.com/2021/02/18/copy-to-clipboard-markdown-editor/
/// - https://www.meziantou.net/
/// </summary>
[Parameter] public string Text { get; set; }
protected string btnStyle = "btn-primary";
protected string btnText = "Copy";
protected bool copyDone = false;
private async Task CopyTextToClipboard()
{
// cambio colore..
btnStyle = "btn-success";
btnText = "Done!";
copyDone = true;
await JSRuntime.InvokeVoidAsync("clipboardCopy.copyText", Text);
await Task.Delay(1100);
// fix cambio colore..
btnStyle = "btn-primary";
btnText = "Copy";
copyDone = false;
await Task.Delay(10);
}
}
+5 -5
View File
@@ -83,9 +83,9 @@
<th>Applicativo</th>
<th>Installazione</th>
<th>Scadenza</th>
<th>Descrizione</th>
<th class="text-right">Num Licenze</th>
<th class="text-right">Codice Licenza</th>
<th class="text-right">Descrizione</th>
<th class="text-right">Payload</th>
<th class="text-right">Enigma</th>
<th class="text-right">Data Enigma</th>
@@ -119,14 +119,14 @@
<td>
<span class="@cssScadenza(record.Scadenza)">@($"{record.Scadenza:yyyy.MM.dd}")</span>
</td>
<td>
<span>@record.Descrizione</span>
</td>
<td class="text-right">
<span>@record.NumLicenze</span>
</td>
<td class="text-right">
<span>@record.Chiave</span>
</td>
<td class="text-right">
<span>@record.Descrizione</span>
<CopyToClipboard Text="@record.Chiave" />
</td>
<td class="text-right">
<span>@record.Payload</span>
+1
View File
@@ -36,6 +36,7 @@
</div>
<!-- inside of body section and after the div/app tag -->
<script src="js/CBCopy.js"></script>
<script src="jquery/jquery.min.js"></script>
<script src="lib/bootstrap/js/bootstrap.min.js"></script>
<script src="lib/font-awesome/js/all.min.js"></script>
+10
View File
@@ -0,0 +1,10 @@
window.clipboardCopy = {
copyText: function (text) {
navigator.clipboard.writeText(text).then(function () {
//alert("Copiato in clipboard!");
})
.catch(function (error) {
alert(error);
});
}
};
+1 -1
View File
@@ -11,7 +11,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LiMan.UI", "LiMan.UI\LiMan.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LiMan.DB", "LiMan.DB\LiMan.DB.csproj", "{C052CE93-FFDE-4B45-B1BC-BD9882797667}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core", "Core\Core.csproj", "{4A7686D3-5BD3-44BE-93DE-CDD72CA703B6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj", "{4A7686D3-5BD3-44BE-93DE-CDD72CA703B6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution