diff --git a/angular-app/package-lock.json b/angular-app/package-lock.json index 4163c4b6..e29d9390 100644 --- a/angular-app/package-lock.json +++ b/angular-app/package-lock.json @@ -1,12 +1,12 @@ { "name": "jasmarty-app", - "version": "2.4.22", + "version": "2.4.29", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "jasmarty-app", - "version": "2.4.22", + "version": "2.4.29", "dependencies": { "@angular/animations": "18.2.4", "@angular/cdk": "18.2.4", diff --git a/angular-app/package.json b/angular-app/package.json index ad919b7a..259d5f24 100644 --- a/angular-app/package.json +++ b/angular-app/package.json @@ -1,6 +1,6 @@ { "name": "jasmarty-app", - "version": "2.4.28", + "version": "2.4.29", "scripts": { "ng": "ng", "start": "ng serve --host 0.0.0.0 --port 3000 --disable-host-check", diff --git a/angular-app/src/app/components/_wipf/daylog/daylog.eventlist.ts b/angular-app/src/app/components/_wipf/daylog/daylog.eventlist.ts index 1f596986..e2fc6ab8 100644 --- a/angular-app/src/app/components/_wipf/daylog/daylog.eventlist.ts +++ b/angular-app/src/app/components/_wipf/daylog/daylog.eventlist.ts @@ -241,7 +241,7 @@ export class DaylogComponentDialogEventComponent implements OnInit { ngOnInit(): void { this.loadDaylogTypes(); - // Beim bearbeiten die Vorschläge bereits vorladen + // Beim bearbeiten die Vorschläge bereits initial vorladen if (this.data.text.length > 2) { this.getTextVorschlag(); } @@ -272,10 +272,16 @@ export class DaylogComponentDialogEventComponent implements OnInit { this.sListVorschlag = resdata; }); } else { - this.sListVorschlag = []; + this.loadLastVorschlaege(7); } } + private loadLastVorschlaege(nAnzahl: number): void { + this.rest.getNoWartenDialog('daylog/event/getLastByType/' + this.data.typid + '/' + nAnzahl).then((resdata: string[]) => { + this.sListVorschlag = resdata; + }); + } + public vorschlagToData(sItem: string): void { this.data.text = sItem; this.loadTextVorschlag(); diff --git a/src/main/java/org/wipf/jasmarty/databasetypes/daylog/DaylogEvent.java b/src/main/java/org/wipf/jasmarty/databasetypes/daylog/DaylogEvent.java index 960f7f6b..5c2c702f 100644 --- a/src/main/java/org/wipf/jasmarty/databasetypes/daylog/DaylogEvent.java +++ b/src/main/java/org/wipf/jasmarty/databasetypes/daylog/DaylogEvent.java @@ -103,4 +103,14 @@ public static PanacheQuery findByTypeIds(List typids) { return find("select e from DaylogEvent e where typid IN (?1)", typids); } + /** + * Das neueste Datum oben + * + * @param nAnzahl + * @return + */ + public static PanacheQuery findLastByTypeId(String sType) { + return find("select e from DaylogEvent e where typid =?1 ORDER by id DESC", sType); + } + } diff --git a/src/main/java/org/wipf/jasmarty/logic/base/MainHome.java b/src/main/java/org/wipf/jasmarty/logic/base/MainHome.java index 286e4b38..4642b9b1 100644 --- a/src/main/java/org/wipf/jasmarty/logic/base/MainHome.java +++ b/src/main/java/org/wipf/jasmarty/logic/base/MainHome.java @@ -41,7 +41,7 @@ public class MainHome { AuthKeyService authKeyService; private static final Logger LOGGER = Logger.getLogger("_MainHome_"); - public static final String VERSION = "2.4.28"; + public static final String VERSION = "2.4.29"; public static final String AUTH_KEY_NAME = "authKey"; /** diff --git a/src/main/java/org/wipf/jasmarty/logic/daylog/DaylogEventService.java b/src/main/java/org/wipf/jasmarty/logic/daylog/DaylogEventService.java index 3cd00880..7b76b48c 100644 --- a/src/main/java/org/wipf/jasmarty/logic/daylog/DaylogEventService.java +++ b/src/main/java/org/wipf/jasmarty/logic/daylog/DaylogEventService.java @@ -57,6 +57,26 @@ public List getByDateId(Integer nId) { return resultListe; } + /** + * @param nAnzahl + * @return + */ + public LinkedHashSet getLastByTypeId(String sTypId, Integer nAnzahl) { + LinkedHashSet o = new LinkedHashSet<>(); + int count = 0; + + for (DaylogEvent d : DaylogEvent.findLastByTypeId(sTypId).list()) { + if (!o.contains(d.text)) { + o.add(d.text); + count++; + if (count > nAnzahl) { + return o; + } + } + } + return o; + } + /** * @param nTypId * @return diff --git a/src/main/java/org/wipf/jasmarty/rest/daylog/DaylogEventRest.java b/src/main/java/org/wipf/jasmarty/rest/daylog/DaylogEventRest.java index b1157b3a..ce4c053a 100644 --- a/src/main/java/org/wipf/jasmarty/rest/daylog/DaylogEventRest.java +++ b/src/main/java/org/wipf/jasmarty/rest/daylog/DaylogEventRest.java @@ -63,6 +63,15 @@ public Response getByDateQuery(@PathParam("search") String sSearch, @PathParam(" return Response.status(471).build(); } + @GET + @Path("getLastByType/{type}/{anzahl}") + public Response getLastByType(@PathParam("type") String sType, @PathParam("anzahl") Integer nAnzahl, @CookieParam(MainHome.AUTH_KEY_NAME) String key) { + if (aks.isKeyInCache(key)) { + return Response.ok(daylogEventDB.getLastByTypeId(sType, nAnzahl)).build(); + } + return Response.status(471).build(); + } + @POST @Path("save") public Response save(DaylogEvent d, @CookieParam(MainHome.AUTH_KEY_NAME) String key) {