WIP: list scrolling

This commit is contained in:
Michał Zieliński
2023-10-02 19:59:43 +02:00
parent 2f1ef5c9fe
commit f70ba9b701
4 changed files with 78 additions and 77 deletions

View File

@@ -14,6 +14,6 @@
<td mat-cell *matCellDef="let element">{{LayerType[element.type]}}</td> <td mat-cell *matCellDef="let element">{{LayerType[element.type]}}</td>
</ng-container> </ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns, sticky: true"></tr> <tr mat-header-row *matHeaderRowDef="displayedColumns, sticky: false"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['Detail/', row.id]"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['Detail/', row.id]"></tr>
</table> </table>

View File

@@ -29,7 +29,7 @@ export class LayersListComponent implements OnInit {
LayerType = LayerType; LayerType = LayerType;
start = 0; start = 0;
limit = 50; limit = 200;
end: number = this.limit + this.start; end: number = this.limit + this.start;
loadingInProgress = false; loadingInProgress = false;
@@ -40,7 +40,7 @@ export class LayersListComponent implements OnInit {
private _http: HttpClient, private _http: HttpClient,
) { } ) { }
@HostListener('document:scroll', ['$event']) //@HostListener('document:scroll', ['$event'])
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
public async onScroll(event: any) { public async onScroll(event: any) {
console.log('on scrool', event); console.log('on scrool', event);

View File

@@ -7,8 +7,8 @@ export const environment = {
appName: "LOCAL_DiunaBI", appName: "LOCAL_DiunaBI",
production: false, production: false,
api: { api: {
url: "http://localhost:5400/api" //url: "http://localhost:5400/api"
//url: "https://diunabi-morska.bim-it.pl/api" url: "https://diunabi-morska.bim-it.pl/api"
}, },
google: { google: {
clientId: "107631825312-bkfe438ehr9k9ecb2h76g802tj6advma.apps.googleusercontent.com" clientId: "107631825312-bkfe438ehr9k9ecb2h76g802tj6advma.apps.googleusercontent.com"

View File

@@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using WebAPI.dataParsers; using WebAPI.dataParsers;
using WebAPI.dataProcessors; using WebAPI.dataProcessors;
using WebAPI.Exports; using WebAPI.Exports;
using WebAPI.Models; using WebAPI.Models;
@@ -43,6 +43,7 @@ namespace WebAPI.Controllers
{ {
if (codes != null && codes.Length > 0) if (codes != null && codes.Length > 0)
{ {
return Ok(db.Layers.Where(x => !x.IsDeleted) return Ok(db.Layers.Where(x => !x.IsDeleted)
.Where(x => codes.Select(Int32.Parse).ToList().Contains(x.Number)) .Where(x => codes.Select(Int32.Parse).ToList().Contains(x.Number))
.OrderByDescending(x => x.Number) .OrderByDescending(x => x.Number)
@@ -173,8 +174,8 @@ namespace WebAPI.Controllers
return BadRequest(e.ToString()); return BadRequest(e.ToString());
} }
return Ok(); return Ok();
} }
[HttpGet] [HttpGet]
[Route("AutoProcess/{apiKey}")] [Route("AutoProcess/{apiKey}")]
[AllowAnonymous] [AllowAnonymous]
@@ -199,73 +200,73 @@ namespace WebAPI.Controllers
foreach (Layer processWorker in processWorkerLayers) foreach (Layer processWorker in processWorkerLayers)
{ {
string? sourceName = processWorker?.Records?.Single(x => x.Code == "Source")?.Desc1; string? sourceName = processWorker?.Records?.Single(x => x.Code == "Source")?.Desc1;
if (sourceName == null) if (sourceName == null)
{
logsController.AddEntry(new LogEntry
{
Title = "Process error",
Type = LogEntryType.error,
LogType = LogType.import,
Message = processWorker?.Name + " Source record not found",
CreatedAt = DateTime.UtcNow
});
return BadRequest();
} else
{ {
Layer sourceLayer = db.Layers.Include(x => x.Records) logsController.AddEntry(new LogEntry
.Single(x => x.Name == sourceName); {
if (sourceLayer == null) Title = "Process error",
{ Type = LogEntryType.error,
logsController.AddEntry(new LogEntry LogType = LogType.import,
{ Message = processWorker?.Name + " Source record not found",
Title = "Process error", CreatedAt = DateTime.UtcNow
Type = LogEntryType.error, });
LogType = LogType.import, return BadRequest();
Message = processWorker?.Name + " Source layer not found " + sourceLayer, } else
CreatedAt = DateTime.UtcNow {
}); Layer sourceLayer = db.Layers.Include(x => x.Records)
return BadRequest(); .Single(x => x.Name == sourceName);
} else if (sourceLayer == null)
{ {
string startDate = sourceLayer.Records!.Where(x => x.Code == "StartDate").First().Desc1!; logsController.AddEntry(new LogEntry
{
Title = "Process error",
Type = LogEntryType.error,
LogType = LogType.import,
Message = processWorker?.Name + " Source layer not found " + sourceLayer,
CreatedAt = DateTime.UtcNow
});
return BadRequest();
} else
{
string startDate = sourceLayer.Records!.Where(x => x.Code == "StartDate").First().Desc1!;
string endDate = sourceLayer.Records!.Where(x => x.Code == "EndDate").First().Desc1!; string endDate = sourceLayer.Records!.Where(x => x.Code == "EndDate").First().Desc1!;
var startDateParsed = DateTime.ParseExact(startDate, "yyyy.MM.dd", null); var startDateParsed = DateTime.ParseExact(startDate, "yyyy.MM.dd", null);
var endDateParsed = DateTime.ParseExact(endDate, "yyyy.MM.dd", null); var endDateParsed = DateTime.ParseExact(endDate, "yyyy.MM.dd", null);
if (startDateParsed.Date <= DateTime.UtcNow.Date && endDateParsed.Date >= DateTime.UtcNow.Date) if (startDateParsed.Date <= DateTime.UtcNow.Date && endDateParsed.Date >= DateTime.UtcNow.Date)
{ {
string? processType = processWorker?.Records?.Single(x => x.Code == "ProcessType")?.Desc1; string? processType = processWorker?.Records?.Single(x => x.Code == "ProcessType")?.Desc1;
if (processType == null) if (processType == null)
{ {
logsController.AddEntry(new LogEntry logsController.AddEntry(new LogEntry
{ {
Title = "Process error", Title = "Process error",
Type = LogEntryType.error, Type = LogEntryType.error,
LogType = LogType.import, LogType = LogType.import,
Message = processWorker?.Name + " ProcessType record not found", Message = processWorker?.Name + " ProcessType record not found",
CreatedAt = DateTime.UtcNow CreatedAt = DateTime.UtcNow
}); });
return BadRequest(); return BadRequest();
} else } else
{ {
Layer? processedLayer = null; Layer? processedLayer = null;
switch (processType) switch (processType)
{ {
case "Copy": case "Copy":
CopyProcessor cp = new CopyProcessor(db, googleSheetValues); CopyProcessor cp = new CopyProcessor(db, googleSheetValues);
processedLayer = cp.process(sourceLayer, processWorker?.Id); processedLayer = cp.process(sourceLayer, processWorker?.Id);
break; break;
case "Deaggregation": case "Deaggregation":
DeaggregationProcessor dp = new DeaggregationProcessor(db, googleSheetValues); DeaggregationProcessor dp = new DeaggregationProcessor(db, googleSheetValues);
processedLayer = dp.process(sourceLayer, processWorker?.Id); processedLayer = dp.process(sourceLayer, processWorker?.Id);
break; break;
} }
if (processedLayer != null) if (processedLayer != null)
{ {
AddLayer(processedLayer, Guid.Parse("F392209E-123E-4651-A5A4-0B1D6CF9FF9D")); AddLayer(processedLayer, Guid.Parse("F392209E-123E-4651-A5A4-0B1D6CF9FF9D"));
} }
} }
} }
} }
} }
} }
return Ok(); return Ok();
@@ -282,9 +283,9 @@ namespace WebAPI.Controllers
}); });
return BadRequest(e.ToString()); return BadRequest(e.ToString());
} }
} }
[HttpGet] [HttpGet]
[Route("checkDates")] [Route("checkDates")]
public IActionResult checkDates() public IActionResult checkDates()
@@ -420,7 +421,7 @@ namespace WebAPI.Controllers
{ {
throw; throw;
} }
} }
private void SaveSources(ICollection<ProcessSource> sources) private void SaveSources(ICollection<ProcessSource> sources)
{ {
try try