Skip to content

Commit

Permalink
daylog last
Browse files Browse the repository at this point in the history
  • Loading branch information
ToWipf committed Dec 26, 2024
1 parent aede91e commit 15b4e90
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 6 deletions.
4 changes: 2 additions & 2 deletions angular-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion angular-app/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 8 additions & 2 deletions angular-app/src/app/components/_wipf/daylog/daylog.eventlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,14 @@ public static PanacheQuery<DaylogEvent> findByTypeIds(List<String> typids) {
return find("select e from DaylogEvent e where typid IN (?1)", typids);
}

/**
* Das neueste Datum oben
*
* @param nAnzahl
* @return
*/
public static PanacheQuery<DaylogEvent> findLastByTypeId(String sType) {
return find("select e from DaylogEvent e where typid =?1 ORDER by id DESC", sType);
}

}
2 changes: 1 addition & 1 deletion src/main/java/org/wipf/jasmarty/logic/base/MainHome.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ public List<DaylogEvent> getByDateId(Integer nId) {
return resultListe;
}

/**
* @param nAnzahl
* @return
*/
public LinkedHashSet<String> getLastByTypeId(String sTypId, Integer nAnzahl) {
LinkedHashSet<String> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 15b4e90

Please sign in to comment.