feat: add public screen
This commit is contained in:
@@ -17,7 +17,7 @@ public class CombEntity {
|
||||
private String lname;
|
||||
private String fname;
|
||||
Categorie categorie;
|
||||
Long club;
|
||||
String club_uuid;
|
||||
String club_str;
|
||||
Genre genre;
|
||||
String country;
|
||||
@@ -29,7 +29,7 @@ public class CombEntity {
|
||||
return null;
|
||||
|
||||
return new CombEntity(model.getId(), model.getLname(), model.getFname(), model.getCategorie(),
|
||||
model.getClub() == null ? null : model.getClub().getId(),
|
||||
model.getClub() == null ? null : model.getClub().getClubId(),
|
||||
model.getClub() == null ? "Sans club" : model.getClub().getName(), model.getGenre(), model.getCountry(),
|
||||
0, null);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class CombEntity {
|
||||
MembreModel model = registerModel.getMembre();
|
||||
|
||||
return new CombEntity(model.getId(), model.getLname(), model.getFname(), registerModel.getCategorie(),
|
||||
registerModel.getClub2() == null ? null : registerModel.getClub2().getId(),
|
||||
registerModel.getClub2() == null ? null : registerModel.getClub2().getClubId(),
|
||||
registerModel.getClub2() == null ? "Sans club" : registerModel.getClub2().getName(), model.getGenre(),
|
||||
model.getCountry(), registerModel.getOverCategory(), registerModel.getWeight());
|
||||
}
|
||||
|
||||
@@ -186,6 +186,6 @@ public class AffiliationRequestEndpoints {
|
||||
public Uni<Response> getStatus(
|
||||
@Parameter(description = "L'identifiant de la demande d'affiliation") @PathParam("id") long id) throws URISyntaxException {
|
||||
return Utils.getMediaFile(id, media, "aff_request/status", "affiliation_request_" + id,
|
||||
Uni.createFrom().nullItem());
|
||||
Uni.createFrom().nullItem(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ public class ClubEndpoints {
|
||||
@Parameter(description = "Identifiant long (clubId) de club") @PathParam("clubId") String clubId) {
|
||||
return clubService.getByClubId(clubId).chain(Unchecked.function(clubModel -> {
|
||||
try {
|
||||
return Utils.getMediaFile((clubModel != null) ? clubModel.getId() : -1, media, "ppClub",
|
||||
return Utils.getMediaFileNoDefault((clubModel != null) ? clubModel.getId() : -1, media, "ppClub",
|
||||
Uni.createFrom().nullItem());
|
||||
} catch (URISyntaxException e) {
|
||||
throw new InternalError();
|
||||
@@ -358,7 +358,7 @@ public class ClubEndpoints {
|
||||
return clubService.getById(id).onItem().invoke(checkPerm).chain(Unchecked.function(clubModel -> {
|
||||
try {
|
||||
return Utils.getMediaFile(clubModel.getId(), media, "clubStatus",
|
||||
"statue-" + clubModel.getName(), Uni.createFrom().nullItem());
|
||||
"statue-" + clubModel.getName(), Uni.createFrom().nullItem(), false);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new InternalError();
|
||||
}
|
||||
|
||||
@@ -150,11 +150,16 @@ public class Utils {
|
||||
|
||||
public static Uni<Response> getMediaFile(long id, String media, String dirname,
|
||||
Uni<?> uniBase) throws URISyntaxException {
|
||||
return getMediaFile(id, media, dirname, null, uniBase);
|
||||
return getMediaFile(id, media, dirname, null, uniBase, true);
|
||||
}
|
||||
|
||||
public static Uni<Response> getMediaFileNoDefault(long id, String media, String dirname,
|
||||
Uni<?> uniBase) throws URISyntaxException {
|
||||
return getMediaFile(id, media, dirname, null, uniBase, false);
|
||||
}
|
||||
|
||||
public static Uni<Response> getMediaFile(long id, String media, String dirname, String out_filename,
|
||||
Uni<?> uniBase) throws URISyntaxException {
|
||||
Uni<?> uniBase, boolean default_) throws URISyntaxException {
|
||||
Future<Pair<File, byte[]>> future = CompletableFuture.supplyAsync(() -> {
|
||||
FilenameFilter filter = (directory, filename) -> filename.startsWith(id + ".");
|
||||
File[] files = new File(media, dirname).listFiles(filter);
|
||||
@@ -182,19 +187,25 @@ public class Utils {
|
||||
return uniBase.chain(__ -> Uni.createFrom().future(future)
|
||||
.chain(filePair -> {
|
||||
if (filePair == null) {
|
||||
return Uni.createFrom().future(future2).map(data -> {
|
||||
if (data == null)
|
||||
return Response.noContent().build();
|
||||
if (default_) {
|
||||
return Uni.createFrom().future(future2).map(data -> {
|
||||
if (data == null)
|
||||
return Response.noContent().build();
|
||||
|
||||
String mimeType = "image/apng";
|
||||
Response.ResponseBuilder resp = Response.ok(data);
|
||||
resp.type(MediaType.APPLICATION_OCTET_STREAM);
|
||||
resp.header(HttpHeaders.CONTENT_LENGTH, data.length);
|
||||
resp.header(HttpHeaders.CONTENT_TYPE, mimeType);
|
||||
resp.header(HttpHeaders.CONTENT_DISPOSITION,
|
||||
"inline; " + ((out_filename == null) ? "" : "filename=\"" + out_filename + "\""));
|
||||
return resp.build();
|
||||
});
|
||||
String mimeType = "image/apng";
|
||||
Response.ResponseBuilder resp = Response.ok(data);
|
||||
resp.type(MediaType.APPLICATION_OCTET_STREAM);
|
||||
resp.header(HttpHeaders.CONTENT_LENGTH, data.length);
|
||||
resp.header(HttpHeaders.CONTENT_TYPE, mimeType);
|
||||
resp.header(HttpHeaders.CONTENT_DISPOSITION,
|
||||
"inline; " + ((out_filename == null) ? "" : "filename=\"" + out_filename + "\""));
|
||||
return resp.build();
|
||||
});
|
||||
} else {
|
||||
Response.ResponseBuilder resp = Response.status(404);
|
||||
resp.header(HttpHeaders.CACHE_CONTROL, "max-age=600");
|
||||
return Uni.createFrom().item(resp.build());
|
||||
}
|
||||
} else {
|
||||
return Uni.createFrom().item(() -> {
|
||||
String mimeType = URLConnection.guessContentTypeFromName(filePair.getKey().getName());
|
||||
|
||||
@@ -22,7 +22,7 @@ public class RRegister {
|
||||
@Inject
|
||||
CompetitionRepository competitionRepository;
|
||||
|
||||
@WSReceiver(code = "getRegister", permission = PermLevel.ADMIN)
|
||||
@WSReceiver(code = "getRegister", permission = PermLevel.TABLE)
|
||||
public Uni<List<CombEntity>> getRegister(WebSocketConnection connection, Object o) {
|
||||
return competitionRepository.find("uuid", connection.pathParam("uuid")).firstResult()
|
||||
.call(cm -> Mutiny.fetch(cm.getInsc()))
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SRegister {
|
||||
public Uni<Void> send(String uuid, String code, Object data) {
|
||||
List<Uni<Void>> queue = connections.findByEndpointId(CompetitionWS.class.getCanonicalName()).stream()
|
||||
.filter(c -> c.pathParam("uuid").equals(uuid) && PermLevel.valueOf(
|
||||
c.userData().get(UserData.TypedKey.forString("prem"))).ordinal() >= PermLevel.ADMIN.ordinal())
|
||||
c.userData().get(UserData.TypedKey.forString("prem"))).ordinal() >= PermLevel.TABLE.ordinal())
|
||||
.map(c -> c.sendText(
|
||||
new MessageOut(UUID.randomUUID(), code, MessageType.NOTIFY, data)))
|
||||
.toList();
|
||||
|
||||
Reference in New Issue
Block a user