Rilascia gestione completa progetti e aggiornamenti 0.4.0
This commit is contained in:
1 parent
620a4bec26
commit
205a520708
10 files changed
+1366
-65
No files matched your search
+348
-17
@@ -8,6 +8,8 @@
|
||||
@inject AzureMapsService AzureMapsService
|
||||
@inject ProjectStorageService ProjectStorageService
|
||||
@inject MapExportService MapExportService
|
||||
@inject CloudSyncService CloudSyncService
|
||||
@inject AppUpdateService AppUpdateService
|
||||
@implements IAsyncDisposable
|
||||
|
||||
<PageTitle>LME Mappe Catastali</PageTitle>
|
||||
@@ -19,9 +21,11 @@
|
||||
<header class="map-toolbar">
|
||||
<div class="app-identity">
|
||||
<strong>LME Catasto</strong>
|
||||
<span>@Status</span>
|
||||
<span class="app-status-line">@Status @if (HasUnsavedChanges) { <i title="Modifiche non salvate"></i> }</span>
|
||||
</div>
|
||||
<div class="toolbar-actions">
|
||||
<button class="map-icon-command" title="Annulla ultima operazione" aria-label="Annulla" @onclick="UndoMapChange">↶</button>
|
||||
<button class="map-icon-command" title="Ripristina operazione" aria-label="Ripristina" @onclick="RedoMapChange">↷</button>
|
||||
<button class="toolbar-button layer-button @(LayerPanelOpen ? "is-active" : null)"
|
||||
title="Layer catastali"
|
||||
aria-expanded="@LayerPanelOpen"
|
||||
@@ -29,10 +33,25 @@
|
||||
<span class="layer-symbol" aria-hidden="true"></span>
|
||||
<span>Layer</span>
|
||||
</button>
|
||||
<button class="toolbar-button" @onclick='() => SelectTab(ActiveTab == "search" ? "map" : "search")'>Cerca</button>
|
||||
<button class="map-menu-button @(NavigationMenuOpen ? "is-active" : null)" title="Apri menu" aria-label="Apri menu" aria-expanded="@NavigationMenuOpen" @onclick="ToggleNavigationMenu">☰</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@if (NavigationMenuOpen)
|
||||
{
|
||||
<nav class="map-navigation-menu" aria-label="Menu principale">
|
||||
<button @onclick='() => SelectTab("map")'>Mappa</button>
|
||||
<button @onclick='() => SelectTab("search")'>Cerca località</button>
|
||||
<button @onclick='() => SelectTab("cadastre")'>Ricerca catastale</button>
|
||||
<button @onclick='() => SelectTab("data")'>Dati e disegni</button>
|
||||
<button @onclick='() => SelectTab("projects")'>Progetti</button>
|
||||
<button @onclick='() => SelectTab("save")'>Esporta</button>
|
||||
<button @onclick='() => SelectTab("tools")'>Strumenti avanzati</button>
|
||||
<button @onclick='() => SelectTab("settings")'>Impostazioni</button>
|
||||
<div class="menu-credits"><strong>LME Mappe Catastali</strong><span>Autore: Livio Merola</span><a href="mailto:info@liviomerola.net">info@liviomerola.net</a><span>Mappe: Esri, OpenStreetMap, CARTO, OpenTopoMap. Catasto: Agenzia delle Entrate CC BY 4.0.</span></div>
|
||||
</nav>
|
||||
}
|
||||
|
||||
<div class="map-search @(ActiveTab == "search" ? "is-open" : null)">
|
||||
<input @bind="SearchText" @bind:event="oninput" placeholder="Localita, indirizzo o coordinate" />
|
||||
<button @onclick="SearchLocation">Vai</button>
|
||||
@@ -317,14 +336,13 @@
|
||||
<option value="">Seleziona un progetto</option>
|
||||
@foreach (var project in Projects)
|
||||
{
|
||||
<option value="@project.Id">@(project.IsArchived ? "[ARCHIVIATO] " : "")@(string.IsNullOrWhiteSpace(project.Folder) ? "" : $"{project.Folder} / ")@project.Name - @project.UpdatedAt.ToLocalTime().ToString("dd/MM/yyyy HH:mm")</option>
|
||||
<option value="@project.Id">@(project.IsArchived ? "[ARCHIVIATO] " : "")@(project.IsReadOnly ? "[SOLA LETTURA] " : "")@(string.IsNullOrWhiteSpace(project.Folder) ? "" : $"{project.Folder} / ")@project.Name - @project.UpdatedAt.ToLocalTime().ToString("dd/MM/yyyy HH:mm")</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<div class="button-row">
|
||||
<button @onclick="LoadProject" disabled="@(ProjectBusy || string.IsNullOrWhiteSpace(SelectedProjectId))">Apri</button>
|
||||
<button class="danger-command" @onclick="DeleteProject" disabled="@(ProjectBusy || string.IsNullOrWhiteSpace(SelectedProjectId))">Elimina</button>
|
||||
</div>
|
||||
<label>
|
||||
Cartella
|
||||
<input @bind="ProjectFolder" placeholder="Es. Cantieri 2026" maxlength="60" />
|
||||
@@ -335,7 +353,13 @@
|
||||
</div>
|
||||
<div class="button-row">
|
||||
<button class="secondary-command" @onclick="ToggleProjectArchive" disabled="@(ProjectBusy || string.IsNullOrWhiteSpace(SelectedProjectId))">@(SelectedProject?.IsArchived == true ? "Ripristina" : "Archivia")</button>
|
||||
<button class="secondary-command" @onclick="ShareProject" disabled="@(ProjectBusy || string.IsNullOrWhiteSpace(SelectedProjectId))">Condividi</button>
|
||||
<button class="secondary-command" @onclick='() => ShareProject(false)' disabled="@(ProjectBusy || string.IsNullOrWhiteSpace(SelectedProjectId))">Condividi modificabile</button>
|
||||
</div>
|
||||
<button class="secondary-command" @onclick='() => ShareProject(true)' disabled="@(ProjectBusy || string.IsNullOrWhiteSpace(SelectedProjectId))">Condividi in sola lettura</button>
|
||||
@if (SelectedProject?.IsReadOnly == true)
|
||||
{
|
||||
<small class="field-help">Questo progetto è protetto. Usa Duplica per crearne una copia modificabile.</small>
|
||||
}
|
||||
</div>
|
||||
<label>
|
||||
Revisione precedente
|
||||
@@ -385,6 +409,46 @@
|
||||
</section>
|
||||
</section>
|
||||
}
|
||||
else if (ActiveTab == "tools")
|
||||
{
|
||||
<section class="panel-content">
|
||||
<section class="panel-section">
|
||||
<h2>Oggetti e coordinate</h2>
|
||||
<button class="primary-command" @onclick="ShowObjectTable">Apri tabella oggetti e particelle</button>
|
||||
<button class="secondary-command" @onclick="ShowCoordinateInspector">Coordinate WGS84 e UTM</button>
|
||||
<button class="secondary-command" @onclick="ShowAuditLog">Registro operazioni</button>
|
||||
</section>
|
||||
<section class="panel-section">
|
||||
<h2>Controllo geometrie</h2>
|
||||
<small class="field-help">Seleziona gli oggetti dalla mappa o dal pannello Layer.</small>
|
||||
<div class="button-row">
|
||||
<button class="secondary-command" @onclick="ValidateSelectedGeometries">Controlla e ripara</button>
|
||||
<button class="secondary-command" @onclick="CreateSelectedHole">Crea foro</button>
|
||||
</div>
|
||||
<button class="secondary-command" @onclick="CompareSelectedGeometries">Confronta due confini</button>
|
||||
</section>
|
||||
<section class="panel-section">
|
||||
<h2>Cestino</h2>
|
||||
<div class="button-row">
|
||||
<button class="secondary-command" @onclick="RestoreTrashItem">Ripristina ultima rimozione</button>
|
||||
<button class="danger-command" @onclick="EmptyTrash">Svuota cestino</button>
|
||||
</div>
|
||||
</section>
|
||||
<section class="panel-section">
|
||||
<h2>Mappe offline</h2>
|
||||
<label>
|
||||
Livelli di zoom aggiuntivi
|
||||
<input type="number" min="0" max="4" @bind="OfflineExtraZoomLevels" />
|
||||
</label>
|
||||
<button class="primary-command" @onclick="DownloadOfflineArea" disabled="@OfflineBusy">@(OfflineBusy ? "Download in corso..." : "Scarica area visibile")</button>
|
||||
<div class="button-row">
|
||||
<button class="secondary-command" @onclick="UseOfflineMap">Usa mappe offline</button>
|
||||
<button class="danger-command" @onclick="ClearOfflineArea">Svuota archivio</button>
|
||||
</div>
|
||||
<small class="field-help">@OfflineStatus</small>
|
||||
</section>
|
||||
</section>
|
||||
}
|
||||
else if (ActiveTab == "settings")
|
||||
{
|
||||
<section class="panel-content">
|
||||
@@ -399,7 +463,7 @@
|
||||
<option value="topographic">Topografica - Esri World Topographic</option>
|
||||
<option value="terrain">Terreno - OpenTopoMap</option>
|
||||
<option value="carto">Strade chiare - CARTO Voyager</option>
|
||||
<option value="offline">Offline - solo dati vettoriali</option>
|
||||
<option value="offline">Mappe salvate offline</option>
|
||||
<option value="azure-road">Strade - Azure Maps</option>
|
||||
<option value="azure-satellite">Satellite - Azure Maps</option>
|
||||
<option value="google-satellite">Satellite - Google Maps</option>
|
||||
@@ -436,6 +500,18 @@
|
||||
<input type="checkbox" @bind="AutoSaveEnabled" @bind:after="ApplyAdvancedOptions" />
|
||||
<span>Autosalvataggio locale dopo ogni modifica</span>
|
||||
</label>
|
||||
<label class="toggle-line project-save-option">
|
||||
<input type="checkbox" @bind="AutoSaveOpenProject" @bind:after="SaveFlagPreferences" />
|
||||
<span>Aggiorna automaticamente il progetto aperto</span>
|
||||
</label>
|
||||
<label>
|
||||
Backup automatico
|
||||
<select @bind="AutomaticBackupFrequency" @bind:after="SaveFlagPreferences">
|
||||
<option value="off">Disattivato</option>
|
||||
<option value="daily">Giornaliero</option>
|
||||
<option value="weekly">Settimanale</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="toggle-line project-save-option">
|
||||
<input type="checkbox" @bind="SnapEnabled" @bind:after="ApplyAdvancedOptions" />
|
||||
<span>Aggancia i vertici agli oggetti vicini</span>
|
||||
@@ -446,6 +522,42 @@
|
||||
</label>
|
||||
</section>
|
||||
|
||||
<section class="panel-section">
|
||||
<h2>Sincronizzazione WebDAV</h2>
|
||||
<label>
|
||||
Indirizzo cartella o file WebDAV
|
||||
<input type="url" @bind="WebDavEndpoint" placeholder="https://server/remote.php/dav/files/utente/cartella" />
|
||||
</label>
|
||||
<label>
|
||||
Nome utente
|
||||
<input @bind="WebDavUserName" autocomplete="username" />
|
||||
</label>
|
||||
<label>
|
||||
Password o password applicazione
|
||||
<input type="password" @bind="WebDavPassword" autocomplete="current-password" />
|
||||
</label>
|
||||
<button class="secondary-command" @onclick="SaveWebDavSettings">Salva configurazione</button>
|
||||
<div class="button-row">
|
||||
<button class="primary-command" @onclick="SyncUpload" disabled="@SyncBusy">Invia al cloud</button>
|
||||
<button class="secondary-command" @onclick="SyncDownload" disabled="@SyncBusy">Scarica dal cloud</button>
|
||||
</div>
|
||||
<small class="field-help">@SyncStatus</small>
|
||||
</section>
|
||||
|
||||
<section class="panel-section">
|
||||
<h2>Aggiornamenti applicazione</h2>
|
||||
<button class="primary-command" @onclick="CheckForUpdates" disabled="@UpdateBusy">@(UpdateBusy ? "Controllo..." : "Controlla nuova versione")</button>
|
||||
@if (!string.IsNullOrWhiteSpace(UpdateDownloadUrl))
|
||||
{
|
||||
<button class="secondary-command" @onclick="OpenUpdateDownload">Scarica aggiornamento</button>
|
||||
}
|
||||
<small class="field-help">@UpdateStatus</small>
|
||||
@if (!string.IsNullOrWhiteSpace(UpdateReleaseNotes))
|
||||
{
|
||||
<pre class="release-notes">@UpdateReleaseNotes</pre>
|
||||
}
|
||||
</section>
|
||||
|
||||
<section class="panel-section">
|
||||
<h2>GPS e percorso</h2>
|
||||
<label class="toggle-line project-save-option">
|
||||
@@ -456,6 +568,10 @@
|
||||
<input type="checkbox" @bind="TrailEnabled" @bind:after="ApplyTrailOption" />
|
||||
<span>Registra la traccia mentre cammini</span>
|
||||
</label>
|
||||
<div class="button-row">
|
||||
<button class="secondary-command" @onclick="ShowTrailStats">Riepilogo traccia</button>
|
||||
<button class="danger-command" @onclick="ClearGpsTrail">Elimina traccia</button>
|
||||
</div>
|
||||
<label class="toggle-line project-save-option">
|
||||
<input type="checkbox" @bind="GpsProximityEnabled" @bind:after="ApplyAdvancedOptions" />
|
||||
<span>Distanza e direzione dal bordo selezionato</span>
|
||||
@@ -504,14 +620,6 @@
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<nav class="bottom-tabs" aria-label="Sezioni principali">
|
||||
<button class="@(ActiveTab == "map" || ActiveTab == "search" ? "active" : null)" @onclick='() => SelectTab("map")'>Mappa</button>
|
||||
<button class="@(ActiveTab == "cadastre" ? "active" : null)" @onclick='() => SelectTab("cadastre")'>Catasto</button>
|
||||
<button class="@(ActiveTab == "data" ? "active" : null)" @onclick='() => SelectTab("data")'>Dati</button>
|
||||
<button class="@(ActiveTab == "projects" ? "active" : null)" @onclick='() => SelectTab("projects")'>Progetti</button>
|
||||
<button class="@(ActiveTab == "save" ? "active" : null)" @onclick='() => SelectTab("save")'>Salvataggio</button>
|
||||
<button class="@(ActiveTab == "settings" ? "active" : null)" @onclick='() => SelectTab("settings")'>Impostazioni</button>
|
||||
</nav>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@@ -546,6 +654,8 @@
|
||||
private bool DrawToolsVisible { get; set; }
|
||||
private bool TrailEnabled { get; set; }
|
||||
private bool LayerPanelOpen { get; set; }
|
||||
private bool NavigationMenuOpen { get; set; }
|
||||
private bool HasUnsavedChanges { get; set; }
|
||||
private DotNetObjectReference<Home>? MapCallbackReference { get; set; }
|
||||
private bool IncludeCadastralParcels { get; set; } = true;
|
||||
private bool IncludeKmlSheetLayer { get; set; }
|
||||
@@ -562,12 +672,27 @@
|
||||
private bool ExportTrail { get; set; } = true;
|
||||
private bool ExportSelectedOnly { get; set; }
|
||||
private bool AutoSaveEnabled { get; set; } = true;
|
||||
private bool AutoSaveOpenProject { get; set; }
|
||||
private string AutomaticBackupFrequency { get; set; } = "daily";
|
||||
private bool SnapEnabled { get; set; } = true;
|
||||
private int SnapDistancePixels { get; set; } = 14;
|
||||
private bool GpsProximityEnabled { get; set; } = true;
|
||||
private bool GpsBoundaryAlertEnabled { get; set; }
|
||||
private int OfflineExtraZoomLevels { get; set; } = 2;
|
||||
private bool OfflineBusy { get; set; }
|
||||
private string OfflineStatus { get; set; } = "Nessuna area verificata.";
|
||||
private string WebDavEndpoint { get; set; } = string.Empty;
|
||||
private string WebDavUserName { get; set; } = string.Empty;
|
||||
private string WebDavPassword { get; set; } = string.Empty;
|
||||
private bool SyncBusy { get; set; }
|
||||
private string SyncStatus { get; set; } = "Sincronizzazione non configurata.";
|
||||
private bool UpdateBusy { get; set; }
|
||||
private string UpdateStatus { get; set; } = $"Versione installata: {AppUpdateService.CurrentVersion}";
|
||||
private string UpdateDownloadUrl { get; set; } = string.Empty;
|
||||
private string UpdateReleaseNotes { get; set; } = string.Empty;
|
||||
private CancellationTokenSource? CatalogCancellation { get; set; }
|
||||
private CancellationTokenSource? GpsLookupCancellation { get; set; }
|
||||
private CancellationTokenSource? ProjectAutoSaveCancellation { get; set; }
|
||||
private long LastGpsLookupAt;
|
||||
private int GpsLookupInProgress;
|
||||
|
||||
@@ -591,6 +716,7 @@
|
||||
"data" => "Dati e disegni",
|
||||
"projects" => "Archivio progetti",
|
||||
"save" => "Salvataggio ed esportazione",
|
||||
"tools" => "Strumenti avanzati",
|
||||
"settings" => "Impostazioni",
|
||||
_ => string.Empty
|
||||
};
|
||||
@@ -601,6 +727,7 @@
|
||||
"data" => "File GIS, misure e POI",
|
||||
"projects" => "Salva, apri e visualizza i tuoi lavori",
|
||||
"save" => "Esporta file GIS",
|
||||
"tools" => "Oggetti, geometrie, coordinate e offline",
|
||||
"settings" => "Mappa, GPS e servizi ufficiali",
|
||||
_ => string.Empty
|
||||
};
|
||||
@@ -637,6 +764,11 @@
|
||||
AzureMapsSubscriptionKey = string.Empty;
|
||||
}
|
||||
|
||||
WebDavEndpoint = Preferences.Default.Get("webdav_endpoint", string.Empty);
|
||||
WebDavUserName = Preferences.Default.Get("webdav_username", string.Empty);
|
||||
try { WebDavPassword = await SecureStorage.Default.GetAsync("webdav_password") ?? string.Empty; }
|
||||
catch { WebDavPassword = string.Empty; }
|
||||
|
||||
try
|
||||
{
|
||||
Regions = await CatalogService.GetRegionsAsync();
|
||||
@@ -659,6 +791,9 @@
|
||||
await ApplyAdvancedOptions();
|
||||
await CenterOnInitialLocationAsync();
|
||||
await MigrateLegacyProjectAsync();
|
||||
var offlineCount = await JS.InvokeAsync<int>("lmeMap.getOfflineTileStats");
|
||||
OfflineStatus = offlineCount == 0 ? "Nessuna tessera salvata." : $"{offlineCount} tessere disponibili offline.";
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -778,6 +913,7 @@
|
||||
|
||||
private async Task SelectTab(string tab)
|
||||
{
|
||||
NavigationMenuOpen = false;
|
||||
ActiveTab = tab;
|
||||
if (tab != "map")
|
||||
{
|
||||
@@ -795,6 +931,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleNavigationMenu()
|
||||
{
|
||||
NavigationMenuOpen = !NavigationMenuOpen;
|
||||
if (NavigationMenuOpen) LayerPanelOpen = false;
|
||||
}
|
||||
|
||||
private async Task ToggleLayerPanel()
|
||||
{
|
||||
LayerPanelOpen = !LayerPanelOpen;
|
||||
@@ -1147,6 +1289,46 @@
|
||||
return InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
[JSInvokable]
|
||||
public Task OnMapChanged(string action)
|
||||
{
|
||||
HasUnsavedChanges = true;
|
||||
if (AutoSaveOpenProject && SelectedProject is { IsReadOnly: false })
|
||||
{
|
||||
ProjectAutoSaveCancellation?.Cancel();
|
||||
ProjectAutoSaveCancellation?.Dispose();
|
||||
ProjectAutoSaveCancellation = new CancellationTokenSource();
|
||||
_ = AutoSaveCurrentProjectAsync(ProjectAutoSaveCancellation.Token);
|
||||
}
|
||||
return InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
[JSInvokable]
|
||||
public Task OnProjectSaved()
|
||||
{
|
||||
HasUnsavedChanges = false;
|
||||
return InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task AutoSaveCurrentProjectAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(3), cancellationToken);
|
||||
var project = SelectedProject;
|
||||
if (project is null || project.IsReadOnly) return;
|
||||
var snapshot = await JS.InvokeAsync<string>("lmeMap.createProjectSnapshot", IncludeCadastralParcels);
|
||||
await ProjectStorageService.SaveAsync(project.Name, snapshot, IncludeCadastralParcels, project.Id);
|
||||
await JS.InvokeVoidAsync("lmeMap.markProjectSaved");
|
||||
await RefreshProjectsAsync();
|
||||
}
|
||||
catch (OperationCanceledException) { }
|
||||
catch (Exception error)
|
||||
{
|
||||
await JS.InvokeVoidAsync("lmeMap.showInfo", $"Autosalvataggio progetto non riuscito: {error.GetBaseException().Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ToggleDrawTools()
|
||||
{
|
||||
DrawToolsVisible = !DrawToolsVisible;
|
||||
@@ -1194,6 +1376,13 @@
|
||||
private Task RedoMapChange() => JS.InvokeVoidAsync("lmeMap.redoMapChange").AsTask();
|
||||
private Task RestoreAutosave() => JS.InvokeVoidAsync("lmeMap.restoreAutosave").AsTask();
|
||||
private Task SaveGpsMeasurementPoint() => JS.InvokeVoidAsync("lmeMap.saveGpsMeasurementPoint").AsTask();
|
||||
private async Task ShowTrailStats()
|
||||
{
|
||||
var stats = await JS.InvokeAsync<TrailStats>("lmeMap.getGpsTrailStats");
|
||||
var duration = TimeSpan.FromSeconds(stats.DurationSeconds);
|
||||
await JS.InvokeVoidAsync("lmeMap.showInfo", $"Traccia: {stats.Points} punti, {stats.Length:0} m, durata {duration:hh\\:mm\\:ss}, {(stats.Recording ? "in registrazione" : "in pausa")}.");
|
||||
}
|
||||
private Task ClearGpsTrail() => JS.InvokeVoidAsync("lmeMap.clearGpsTrail").AsTask();
|
||||
|
||||
private async Task DuplicateProject()
|
||||
{
|
||||
@@ -1221,11 +1410,11 @@
|
||||
await JS.InvokeVoidAsync("lmeMap.showInfo", project.IsArchived ? "Progetto ripristinato." : "Progetto archiviato.");
|
||||
}
|
||||
|
||||
private async Task ShareProject()
|
||||
private async Task ShareProject(bool readOnly)
|
||||
{
|
||||
if (SelectedProject is null) return;
|
||||
var path = await ProjectStorageService.CreateProjectPackageAsync(SelectedProject.Id);
|
||||
await Share.Default.RequestAsync(new ShareFileRequest { Title = "Condividi progetto LME", File = new ShareFile(path, "application/json") });
|
||||
var path = await ProjectStorageService.CreateProjectPackageAsync(SelectedProject.Id, readOnly);
|
||||
await Share.Default.RequestAsync(new ShareFileRequest { Title = readOnly ? "Condividi progetto LME in sola lettura" : "Condividi progetto LME modificabile", File = new ShareFile(path, "application/json") });
|
||||
}
|
||||
|
||||
private async Task ShareFullBackup()
|
||||
@@ -1267,6 +1456,7 @@
|
||||
private async Task LoadProjectVersion()
|
||||
{
|
||||
if (SelectedProject is null || string.IsNullOrWhiteSpace(SelectedVersionId)) return;
|
||||
if (!await JS.InvokeAsync<bool>("lmeMap.confirmDiscardChanges", "aprire la revisione")) return;
|
||||
var snapshot = await ProjectStorageService.LoadVersionAsync(SelectedProject.Id, SelectedVersionId);
|
||||
var options = await JS.InvokeAsync<ProjectDisplayOptions>("lmeMap.loadProjectSnapshot", snapshot, $"{SelectedProject.Name} - revisione");
|
||||
ApplyProjectDisplayOptions(options);
|
||||
@@ -1352,6 +1542,10 @@
|
||||
await RefreshProjectsAsync();
|
||||
SelectedProjectId = saved.Id;
|
||||
NewProjectName = saved.Name;
|
||||
await JS.InvokeVoidAsync("lmeMap.setProjectReadOnly", false);
|
||||
await JS.InvokeVoidAsync("lmeMap.markProjectSaved");
|
||||
HasUnsavedChanges = false;
|
||||
await CreateAutomaticBackupIfDue();
|
||||
await JS.InvokeVoidAsync(
|
||||
"lmeMap.showInfo",
|
||||
IncludeCadastralParcels
|
||||
@@ -1376,6 +1570,7 @@
|
||||
await JS.InvokeVoidAsync("lmeMap.showInfo", "Seleziona il progetto da caricare.");
|
||||
return;
|
||||
}
|
||||
if (!await JS.InvokeAsync<bool>("lmeMap.confirmDiscardChanges", "aprire un altro progetto")) return;
|
||||
|
||||
ProjectBusy = true;
|
||||
try
|
||||
@@ -1387,6 +1582,9 @@
|
||||
NewProjectName = project.Name;
|
||||
ExportFileName = project.Name;
|
||||
IncludeCadastralParcels = project.IncludesCadastralParcels;
|
||||
await JS.InvokeVoidAsync("lmeMap.setProjectReadOnly", project.IsReadOnly);
|
||||
await JS.InvokeVoidAsync("lmeMap.markProjectSaved");
|
||||
HasUnsavedChanges = false;
|
||||
ActiveTab = "map";
|
||||
await Task.Delay(30);
|
||||
await JS.InvokeVoidAsync("lmeMap.resize");
|
||||
@@ -1452,6 +1650,115 @@
|
||||
ProjectBusy = false;
|
||||
}
|
||||
}
|
||||
|
||||
private Task ShowObjectTable() => JS.InvokeVoidAsync("lmeMap.showObjectTable").AsTask();
|
||||
private Task ShowAuditLog() => JS.InvokeVoidAsync("lmeMap.showAuditLog").AsTask();
|
||||
private Task ShowCoordinateInspector() => JS.InvokeVoidAsync("lmeMap.showCoordinateInspector").AsTask();
|
||||
private Task ValidateSelectedGeometries() => JS.InvokeVoidAsync("lmeMap.validateAndRepairSelected").AsTask();
|
||||
private Task CreateSelectedHole() => JS.InvokeVoidAsync("lmeMap.createHoleFromSelected").AsTask();
|
||||
private Task CompareSelectedGeometries() => JS.InvokeVoidAsync("lmeMap.compareSelectedGeometries").AsTask();
|
||||
private Task RestoreTrashItem() => JS.InvokeVoidAsync("lmeMap.restoreLastTrashItem").AsTask();
|
||||
private Task EmptyTrash() => JS.InvokeVoidAsync("lmeMap.emptyTrash").AsTask();
|
||||
|
||||
private async Task DownloadOfflineArea()
|
||||
{
|
||||
OfflineBusy = true;
|
||||
try
|
||||
{
|
||||
var result = await JS.InvokeAsync<OfflineDownloadResult>("lmeMap.downloadOfflineArea", OfflineExtraZoomLevels);
|
||||
OfflineStatus = $"{result.Saved} tessere disponibili, zoom {result.StartZoom}-{result.EndZoom}.";
|
||||
}
|
||||
catch (Exception error) { OfflineStatus = $"Download non riuscito: {error.GetBaseException().Message}"; }
|
||||
finally { OfflineBusy = false; }
|
||||
}
|
||||
|
||||
private async Task UseOfflineMap()
|
||||
{
|
||||
await JS.InvokeVoidAsync("lmeMap.setBaseLayer", "offline");
|
||||
SelectedBaseLayer = "offline";
|
||||
}
|
||||
|
||||
private async Task ClearOfflineArea()
|
||||
{
|
||||
if (!await JS.InvokeAsync<bool>("confirm", "Svuotare tutte le mappe salvate offline?")) return;
|
||||
await JS.InvokeVoidAsync("lmeMap.clearOfflineTiles");
|
||||
OfflineStatus = "Nessuna tessera salvata.";
|
||||
}
|
||||
|
||||
private async Task SaveWebDavSettings()
|
||||
{
|
||||
Preferences.Default.Set("webdav_endpoint", WebDavEndpoint.Trim());
|
||||
Preferences.Default.Set("webdav_username", WebDavUserName.Trim());
|
||||
if (string.IsNullOrWhiteSpace(WebDavPassword)) SecureStorage.Default.Remove("webdav_password");
|
||||
else await SecureStorage.Default.SetAsync("webdav_password", WebDavPassword);
|
||||
SyncStatus = "Configurazione WebDAV salvata sul dispositivo.";
|
||||
}
|
||||
|
||||
private async Task SyncUpload()
|
||||
{
|
||||
SyncBusy = true;
|
||||
try
|
||||
{
|
||||
await SaveWebDavSettings();
|
||||
var backup = await ProjectStorageService.CreateBackupAsync();
|
||||
await CloudSyncService.UploadAsync(WebDavEndpoint, WebDavUserName, WebDavPassword, backup);
|
||||
SyncStatus = $"Archivio inviato al cloud il {DateTime.Now:dd/MM/yyyy HH:mm}.";
|
||||
}
|
||||
catch (Exception error) { SyncStatus = $"Invio non riuscito: {error.GetBaseException().Message}"; }
|
||||
finally { SyncBusy = false; }
|
||||
}
|
||||
|
||||
private async Task SyncDownload()
|
||||
{
|
||||
if (!await JS.InvokeAsync<bool>("lmeMap.confirmDiscardChanges", "ripristinare l'archivio cloud")) return;
|
||||
SyncBusy = true;
|
||||
try
|
||||
{
|
||||
await SaveWebDavSettings();
|
||||
var backup = await CloudSyncService.DownloadAsync(WebDavEndpoint, WebDavUserName, WebDavPassword);
|
||||
var count = await ProjectStorageService.RestoreBackupAsync(backup);
|
||||
await RefreshProjectsAsync();
|
||||
SyncStatus = $"Sincronizzazione completata: {count} progetti ripristinati.";
|
||||
}
|
||||
catch (Exception error) { SyncStatus = $"Download non riuscito: {error.GetBaseException().Message}"; }
|
||||
finally { SyncBusy = false; }
|
||||
}
|
||||
|
||||
private async Task CheckForUpdates()
|
||||
{
|
||||
UpdateBusy = true;
|
||||
UpdateDownloadUrl = string.Empty;
|
||||
UpdateReleaseNotes = string.Empty;
|
||||
try
|
||||
{
|
||||
var update = await AppUpdateService.CheckAsync();
|
||||
UpdateReleaseNotes = update.ReleaseNotes;
|
||||
if (update.IsAvailable)
|
||||
{
|
||||
UpdateStatus = $"Installata {AppUpdateService.CurrentVersion}. Disponibile {update.Version}.";
|
||||
UpdateDownloadUrl = update.DownloadUrl;
|
||||
}
|
||||
else UpdateStatus = $"Versione {AppUpdateService.CurrentVersion} aggiornata. Ultima release Gitea: {update.Version}.";
|
||||
}
|
||||
catch (Exception error) { UpdateStatus = $"Controllo non riuscito: {error.GetBaseException().Message}"; }
|
||||
finally { UpdateBusy = false; }
|
||||
}
|
||||
|
||||
private Task OpenUpdateDownload() => string.IsNullOrWhiteSpace(UpdateDownloadUrl)
|
||||
? Task.CompletedTask
|
||||
: Launcher.Default.OpenAsync(new Uri(UpdateDownloadUrl));
|
||||
|
||||
private async Task CreateAutomaticBackupIfDue()
|
||||
{
|
||||
if (AutomaticBackupFrequency == "off") return;
|
||||
var latest = ProjectStorageService.GetLatestScheduledBackupTime();
|
||||
var interval = AutomaticBackupFrequency == "weekly" ? TimeSpan.FromDays(7) : TimeSpan.FromDays(1);
|
||||
if (latest is null || DateTimeOffset.UtcNow - latest.Value.ToUniversalTime() >= interval)
|
||||
{
|
||||
await ProjectStorageService.CreateScheduledBackupAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private Task CenterOnGps() => JS.InvokeVoidAsync("lmeMap.centerOnGps").AsTask();
|
||||
private async Task ApplyTrailOption()
|
||||
{
|
||||
@@ -1584,8 +1891,11 @@
|
||||
ExportTrail = GetFlagPreference("export_trail", true);
|
||||
ExportSelectedOnly = GetFlagPreference("export_selected_only", false);
|
||||
AutoSaveEnabled = GetFlagPreference("auto_save", true);
|
||||
AutoSaveOpenProject = GetFlagPreference("auto_save_project", false);
|
||||
AutomaticBackupFrequency = Preferences.Default.Get($"{FlagPreferencePrefix}backup_frequency", "daily");
|
||||
SnapEnabled = GetFlagPreference("snap_enabled", true);
|
||||
SnapDistancePixels = Preferences.Default.Get($"{FlagPreferencePrefix}snap_distance", 14);
|
||||
OfflineExtraZoomLevels = Preferences.Default.Get($"{FlagPreferencePrefix}offline_zoom_levels", 2);
|
||||
GpsProximityEnabled = GetFlagPreference("gps_proximity", true);
|
||||
GpsBoundaryAlertEnabled = GetFlagPreference("gps_boundary_alert", false);
|
||||
|
||||
@@ -1615,8 +1925,11 @@
|
||||
SetFlagPreference("export_trail", ExportTrail);
|
||||
SetFlagPreference("export_selected_only", ExportSelectedOnly);
|
||||
SetFlagPreference("auto_save", AutoSaveEnabled);
|
||||
SetFlagPreference("auto_save_project", AutoSaveOpenProject);
|
||||
Preferences.Default.Set($"{FlagPreferencePrefix}backup_frequency", AutomaticBackupFrequency);
|
||||
SetFlagPreference("snap_enabled", SnapEnabled);
|
||||
Preferences.Default.Set($"{FlagPreferencePrefix}snap_distance", SnapDistancePixels);
|
||||
Preferences.Default.Set($"{FlagPreferencePrefix}offline_zoom_levels", OfflineExtraZoomLevels);
|
||||
SetFlagPreference("gps_proximity", GpsProximityEnabled);
|
||||
SetFlagPreference("gps_boundary_alert", GpsBoundaryAlertEnabled);
|
||||
|
||||
@@ -1718,12 +2031,30 @@
|
||||
public bool TrailEnabled { get; init; }
|
||||
}
|
||||
|
||||
private sealed class OfflineDownloadResult
|
||||
{
|
||||
public int Saved { get; init; }
|
||||
public int Requested { get; init; }
|
||||
public int StartZoom { get; init; }
|
||||
public int EndZoom { get; init; }
|
||||
}
|
||||
|
||||
private sealed class TrailStats
|
||||
{
|
||||
public int Points { get; init; }
|
||||
public double Length { get; init; }
|
||||
public int DurationSeconds { get; init; }
|
||||
public bool Recording { get; init; }
|
||||
}
|
||||
|
||||
public ValueTask DisposeAsync()
|
||||
{
|
||||
CancelCatalogWork();
|
||||
LocationService.StopTracking();
|
||||
GpsLookupCancellation?.Cancel();
|
||||
GpsLookupCancellation?.Dispose();
|
||||
ProjectAutoSaveCancellation?.Cancel();
|
||||
ProjectAutoSaveCancellation?.Dispose();
|
||||
MapCallbackReference?.Dispose();
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user