Compare commits
4 Commits
master
...
traffic-wa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e2325f717 | ||
|
|
773e8470b0 | ||
|
|
5388c0c974 | ||
|
|
6770b38aa0 |
6
pom.xml
6
pom.xml
@@ -14,7 +14,7 @@
|
|||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
|
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
|
||||||
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
|
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
|
||||||
<quarkus.platform.version>2.2.2.Final</quarkus.platform.version>
|
<quarkus.platform.version>2.3.1.Final</quarkus.platform.version>
|
||||||
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
|
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.quarkus</groupId>
|
<groupId>io.quarkus</groupId>
|
||||||
<artifactId>quarkus-resteasy</artifactId>
|
<artifactId>quarkus-resteasy-jsonb</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.quarkus</groupId>
|
<groupId>io.quarkus</groupId>
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.webjars</groupId>
|
<groupId>org.webjars</groupId>
|
||||||
<artifactId>bootstrap</artifactId>
|
<artifactId>bootstrap</artifactId>
|
||||||
<version>5.0.0</version>
|
<version>5.1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.webjars.npm</groupId>
|
<groupId>org.webjars.npm</groupId>
|
||||||
|
|||||||
41
src/main/java/de/mbremer/configuration/Configuration.java
Normal file
41
src/main/java/de/mbremer/configuration/Configuration.java
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package de.mbremer.configuration;
|
||||||
|
|
||||||
|
import io.quarkus.hibernate.orm.panache.PanacheEntity;
|
||||||
|
import io.quarkus.hibernate.orm.panache.PanacheQuery;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.NoResultException;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Configuration extends PanacheEntity {
|
||||||
|
public static final String GOOGLE_API_KEY = "google_api_key";
|
||||||
|
public static final String OFFICE_ADRESS_KEY = "office_address";
|
||||||
|
|
||||||
|
private String propertyName;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public static String findGooleApiKey() {
|
||||||
|
return findValueOrEmpty(GOOGLE_API_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String findOfficeAdress() {
|
||||||
|
return findValueOrEmpty(OFFICE_ADRESS_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String findValueOrEmpty(String key) {
|
||||||
|
PanacheQuery<Configuration> configuration = find("propertyName", key);
|
||||||
|
try {
|
||||||
|
return configuration.singleResult().getValue();
|
||||||
|
} catch (NoResultException e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package de.mbremer.configuration;
|
||||||
|
|
||||||
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
|
import javax.enterprise.context.ApplicationScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.persistence.NoResultException;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
|
@ApplicationScoped
|
||||||
|
public class ConfigurationService {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Logger log;
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void createOrUpdate(String configurationKey, String configurationValue) {
|
||||||
|
try {
|
||||||
|
Configuration apiKeyConfig = Configuration.find("propertyName", configurationKey).singleResult();
|
||||||
|
apiKeyConfig.setValue(configurationValue);
|
||||||
|
log.info("update " + configurationKey + ": " + configurationValue);
|
||||||
|
} catch (NoResultException e) {
|
||||||
|
new Configuration(configurationKey, configurationValue).persist();
|
||||||
|
log.info("create " + configurationKey + ": " + configurationValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,18 @@
|
|||||||
package de.mbremer.secutity;
|
package de.mbremer.secutity;
|
||||||
|
|
||||||
|
import de.mbremer.configuration.Configuration;
|
||||||
|
import de.mbremer.configuration.ConfigurationService;
|
||||||
import de.mbremer.room.Room;
|
import de.mbremer.room.Room;
|
||||||
|
import de.mbremer.traffic.TrafficAdminForm;
|
||||||
|
import de.mbremer.traffic.TrafficUserForm;
|
||||||
|
import de.mbremer.traffic.TrafficWarningConfig;
|
||||||
import io.quarkus.panache.common.Sort;
|
import io.quarkus.panache.common.Sort;
|
||||||
import io.quarkus.qute.Location;
|
import io.quarkus.qute.Location;
|
||||||
import io.quarkus.qute.Template;
|
import io.quarkus.qute.Template;
|
||||||
import io.quarkus.qute.TemplateInstance;
|
import io.quarkus.qute.TemplateInstance;
|
||||||
import io.quarkus.security.identity.SecurityIdentity;
|
import io.quarkus.security.identity.SecurityIdentity;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
import org.jboss.resteasy.annotations.jaxrs.PathParam;
|
||||||
import org.jboss.resteasy.annotations.providers.multipart.MultipartForm;
|
import org.jboss.resteasy.annotations.providers.multipart.MultipartForm;
|
||||||
|
|
||||||
import javax.annotation.security.PermitAll;
|
import javax.annotation.security.PermitAll;
|
||||||
@@ -19,6 +25,8 @@ import javax.ws.rs.core.NewCookie;
|
|||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
import static de.mbremer.configuration.Configuration.GOOGLE_API_KEY;
|
||||||
|
import static de.mbremer.configuration.Configuration.OFFICE_ADRESS_KEY;
|
||||||
import static de.mbremer.secutity.Role.ADMIN;
|
import static de.mbremer.secutity.Role.ADMIN;
|
||||||
|
|
||||||
@Path("/user")
|
@Path("/user")
|
||||||
@@ -32,6 +40,8 @@ public class UserResource {
|
|||||||
@Inject
|
@Inject
|
||||||
UserService userService;
|
UserService userService;
|
||||||
@Inject
|
@Inject
|
||||||
|
ConfigurationService configurationService;
|
||||||
|
@Inject
|
||||||
Template userinit;
|
Template userinit;
|
||||||
@Inject
|
@Inject
|
||||||
@Location("user.html")
|
@Location("user.html")
|
||||||
@@ -41,14 +51,31 @@ public class UserResource {
|
|||||||
@Produces(MediaType.TEXT_HTML)
|
@Produces(MediaType.TEXT_HTML)
|
||||||
@RolesAllowed({"USER", "ADMIN"})
|
@RolesAllowed({"USER", "ADMIN"})
|
||||||
public TemplateInstance getUser() {
|
public TemplateInstance getUser() {
|
||||||
|
|
||||||
|
TrafficWarningConfig trafficWarningConfig =
|
||||||
|
(TrafficWarningConfig) TrafficWarningConfig.find("user", userService.getCurrentUser()).singleResultOptional().orElse(null);
|
||||||
|
|
||||||
TemplateInstance templateInstance = userTemplate
|
TemplateInstance templateInstance = userTemplate
|
||||||
.data("current_user", User.find("username", identity.getPrincipal().getName()).singleResult());
|
.data("current_user", User.find("username", identity.getPrincipal().getName()).singleResult());
|
||||||
|
|
||||||
|
if (trafficWarningConfig != null) {
|
||||||
|
log.info(trafficWarningConfig.toString());
|
||||||
|
templateInstance
|
||||||
|
.data("traffic_email", trafficWarningConfig.getEmailadress())
|
||||||
|
.data("traffic_active", trafficWarningConfig.isActive())
|
||||||
|
.data("traffic_address", trafficWarningConfig.getAddress())
|
||||||
|
.data("traffic_away", trafficWarningConfig.getTimeAway())
|
||||||
|
.data("traffic_back", trafficWarningConfig.getTimeBack())
|
||||||
|
.data("traffic_duration", trafficWarningConfig.getThreshold());
|
||||||
|
}
|
||||||
|
|
||||||
if (identity.hasRole("ADMIN")) {
|
if (identity.hasRole("ADMIN")) {
|
||||||
templateInstance
|
templateInstance
|
||||||
.data("is_admin", true)
|
.data("is_admin", true)
|
||||||
.data("users", User.listAll(Sort.by("username")))
|
.data("users", User.listAll(Sort.by("username")))
|
||||||
.data("rooms", Room.listAll(Sort.by("name")));
|
.data("rooms", Room.listAll(Sort.by("name")))
|
||||||
|
.data("google_api_key", Configuration.findGooleApiKey())
|
||||||
|
.data("office_address", Configuration.findOfficeAdress());
|
||||||
}
|
}
|
||||||
|
|
||||||
return templateInstance;
|
return templateInstance;
|
||||||
@@ -60,10 +87,10 @@ public class UserResource {
|
|||||||
@Path("init")
|
@Path("init")
|
||||||
@PermitAll
|
@PermitAll
|
||||||
public Response initialAdd(@MultipartForm UserForm userForm) {
|
public Response initialAdd(@MultipartForm UserForm userForm) {
|
||||||
if(User.count("role", ADMIN.name()) > 0) {
|
if (User.count("role", ADMIN.name()) > 0) {
|
||||||
throw new BadRequestException("Only allowed on initial set up");
|
throw new BadRequestException("Only allowed on initial set up");
|
||||||
}
|
}
|
||||||
if(!ADMIN.name().equals(userForm.role)) {
|
if (!ADMIN.name().equals(userForm.role)) {
|
||||||
throw new BadRequestException("Only role ADMIN");
|
throw new BadRequestException("Only role ADMIN");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +107,7 @@ public class UserResource {
|
|||||||
@Path("init")
|
@Path("init")
|
||||||
@PermitAll
|
@PermitAll
|
||||||
public TemplateInstance initial() {
|
public TemplateInstance initial() {
|
||||||
if(User.count("role", ADMIN.name()) > 0) {
|
if (User.count("role", ADMIN.name()) > 0) {
|
||||||
throw new BadRequestException("Only allowed on initial set up");
|
throw new BadRequestException("Only allowed on initial set up");
|
||||||
}
|
}
|
||||||
return userinit.instance();
|
return userinit.instance();
|
||||||
@@ -93,7 +120,7 @@ public class UserResource {
|
|||||||
public Response logout() {
|
public Response logout() {
|
||||||
return Response
|
return Response
|
||||||
.temporaryRedirect(URI.create("/"))
|
.temporaryRedirect(URI.create("/"))
|
||||||
.cookie(new NewCookie("quarkus-credential", null, "/", null, null, 0, false,true))
|
.cookie(new NewCookie("quarkus-credential", null, "/", null, null, 0, false, true))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,4 +171,39 @@ public class UserResource {
|
|||||||
|
|
||||||
return getUser();
|
return getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||||
|
@Produces(MediaType.TEXT_HTML)
|
||||||
|
@Transactional
|
||||||
|
@Path("/traffic/config/")
|
||||||
|
public TemplateInstance configureTrafficAdmin(@MultipartForm TrafficAdminForm trafficAdminForm) {
|
||||||
|
configurationService.createOrUpdate(GOOGLE_API_KEY, trafficAdminForm.googleApiKey);
|
||||||
|
configurationService.createOrUpdate(OFFICE_ADRESS_KEY, trafficAdminForm.officeAddress);
|
||||||
|
|
||||||
|
return getUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||||
|
@Produces(MediaType.TEXT_HTML)
|
||||||
|
@Transactional
|
||||||
|
@Path("/traffic/config/{username}")
|
||||||
|
public TemplateInstance configureTrafficUser(@PathParam("username") String username, @MultipartForm TrafficUserForm trafficUserForm) {
|
||||||
|
log.info("configure traffic for " + username);
|
||||||
|
|
||||||
|
User currentUser = userService.getCurrentUser();
|
||||||
|
TrafficWarningConfig trafficWarningConfig = (TrafficWarningConfig) TrafficWarningConfig.find("user", currentUser).singleResultOptional().orElse(null);
|
||||||
|
|
||||||
|
if (trafficWarningConfig == null) {
|
||||||
|
log.info("create new trafficWarningConfig. user " + currentUser.getUsername());
|
||||||
|
trafficWarningConfig = new TrafficWarningConfig();
|
||||||
|
trafficWarningConfig.setUser(currentUser);
|
||||||
|
}
|
||||||
|
trafficWarningConfig = trafficUserForm.updateTrafficWarningConfig(trafficWarningConfig);
|
||||||
|
log.info(trafficWarningConfig.toString());
|
||||||
|
|
||||||
|
trafficWarningConfig.persist();
|
||||||
|
return getUser();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package de.mbremer.traffic;
|
||||||
|
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.WebApplicationException;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.MultivaluedMap;
|
||||||
|
import javax.ws.rs.ext.MessageBodyReader;
|
||||||
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
|
@Provider
|
||||||
|
@Produces(MediaType.TEXT_PLAIN)
|
||||||
|
public class LocalTimeMessageBodyReader implements MessageBodyReader<LocalTime> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
|
||||||
|
return type == LocalTime.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocalTime readFrom(Class<LocalTime> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
|
||||||
|
return LocalTime.parse(new String(entityStream.readAllBytes()));
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/main/java/de/mbremer/traffic/TrafficAdminForm.java
Normal file
11
src/main/java/de/mbremer/traffic/TrafficAdminForm.java
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package de.mbremer.traffic;
|
||||||
|
|
||||||
|
import javax.ws.rs.FormParam;
|
||||||
|
|
||||||
|
|
||||||
|
public class TrafficAdminForm {
|
||||||
|
public @FormParam("googleapikey")
|
||||||
|
String googleApiKey;
|
||||||
|
public @FormParam("officeaddress")
|
||||||
|
String officeAddress;
|
||||||
|
}
|
||||||
29
src/main/java/de/mbremer/traffic/TrafficUserForm.java
Normal file
29
src/main/java/de/mbremer/traffic/TrafficUserForm.java
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package de.mbremer.traffic;
|
||||||
|
|
||||||
|
import javax.ws.rs.FormParam;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
|
public class TrafficUserForm {
|
||||||
|
public @FormParam("traffic_email")
|
||||||
|
String email;
|
||||||
|
public @FormParam("traffic_address")
|
||||||
|
String address;
|
||||||
|
public @FormParam("traffic_away")
|
||||||
|
LocalTime away;
|
||||||
|
public @FormParam("traffic_back")
|
||||||
|
LocalTime back;
|
||||||
|
public @FormParam("traffic_duration")
|
||||||
|
Integer duration;
|
||||||
|
public @FormParam("traffic_active")
|
||||||
|
boolean active;
|
||||||
|
|
||||||
|
public TrafficWarningConfig updateTrafficWarningConfig(TrafficWarningConfig trafficWarningConfig) {
|
||||||
|
trafficWarningConfig.setEmailadress(email);
|
||||||
|
trafficWarningConfig.setAddress(address);
|
||||||
|
trafficWarningConfig.setThreshold(duration);
|
||||||
|
trafficWarningConfig.setTimeAway(away);
|
||||||
|
trafficWarningConfig.setTimeBack(back);
|
||||||
|
trafficWarningConfig.setActive(active);
|
||||||
|
return trafficWarningConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
31
src/main/java/de/mbremer/traffic/TrafficWarningConfig.java
Normal file
31
src/main/java/de/mbremer/traffic/TrafficWarningConfig.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package de.mbremer.traffic;
|
||||||
|
|
||||||
|
import de.mbremer.secutity.User;
|
||||||
|
import io.quarkus.hibernate.orm.panache.PanacheEntity;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Entity
|
||||||
|
@ToString(exclude = "user")
|
||||||
|
public class TrafficWarningConfig extends PanacheEntity {
|
||||||
|
@NotNull
|
||||||
|
private String emailadress;
|
||||||
|
@NotNull
|
||||||
|
private String address;
|
||||||
|
LocalTime timeAway;
|
||||||
|
LocalTime timeBack;
|
||||||
|
private Integer threshold;
|
||||||
|
private boolean active;
|
||||||
|
@NotNull
|
||||||
|
@OneToOne
|
||||||
|
private User user;
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="stylesheet" href="/webjars/bootstrap/5.0.0/css/bootstrap.min.css">
|
<link rel="stylesheet" href="/webjars/bootstrap/5.1.1/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="/webjars/bootstrap-icons/1.5.0/font/bootstrap-icons.css">
|
<link rel="stylesheet" href="/webjars/bootstrap-icons/1.5.0/font/bootstrap-icons.css">
|
||||||
<title>Bürokalender</title>
|
<title>Bürokalender</title>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="stylesheet" href="/webjars/bootstrap/5.0.0/css/bootstrap.min.css">
|
<link rel="stylesheet" href="/webjars/bootstrap/5.1.1/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="/webjars/bootstrap-icons/1.5.0/font/bootstrap-icons.css">
|
<link rel="stylesheet" href="/webjars/bootstrap-icons/1.5.0/font/bootstrap-icons.css">
|
||||||
<title>Bürokalender</title>
|
<title>Bürokalender</title>
|
||||||
</head>
|
</head>
|
||||||
@@ -28,6 +28,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="/webjars/bootstrap/5.0.0/js/bootstrap.min.js"></script>
|
<script src="/webjars/bootstrap/5.1.1/js/bootstrap.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
quarkus.datasource.db-kind=postgresql
|
quarkus.datasource.db-kind=postgresql
|
||||||
|
|
||||||
quarkus.hibernate-orm.dialect=org.hibernate.dialect.PostgreSQL95Dialect
|
quarkus.hibernate-orm.dialect=org.hibernate.dialect.PostgreSQL95Dialect
|
||||||
%dev.quarkus.hibernate-orm.log.sql=true
|
%dev.quarkus.hibernate-orm.log.sql=false
|
||||||
|
|
||||||
quarkus.flyway.migrate-at-start=true
|
quarkus.flyway.migrate-at-start=true
|
||||||
# theoretische soll auch 'filesystem:' funktionieren
|
# theoretische soll auch 'filesystem:' funktionieren
|
||||||
|
|||||||
5
src/main/resources/db/migration/V0004__configuration.sql
Normal file
5
src/main/resources/db/migration/V0004__configuration.sql
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
create table configuration (
|
||||||
|
id bigint not null primary key,
|
||||||
|
propertyName varchar not null unique,
|
||||||
|
value varchar not null
|
||||||
|
);
|
||||||
10
src/main/resources/db/migration/V0005__trafficwarning.sql
Normal file
10
src/main/resources/db/migration/V0005__trafficwarning.sql
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
create table trafficwarningconfig (
|
||||||
|
id bigint not null primary key,
|
||||||
|
emailadress varchar not null,
|
||||||
|
address varchar not null,
|
||||||
|
timeaway time,
|
||||||
|
timeback time,
|
||||||
|
threshold integer not null,
|
||||||
|
active boolean not null,
|
||||||
|
user_id bigint unique not null references users
|
||||||
|
);
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="stylesheet" href="/webjars/bootstrap/5.0.0/css/bootstrap.min.css">
|
<link rel="stylesheet" href="/webjars/bootstrap/5.1.1/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="/webjars/bootstrap-icons/1.5.0/font/bootstrap-icons.css">
|
<link rel="stylesheet" href="/webjars/bootstrap-icons/1.5.0/font/bootstrap-icons.css">
|
||||||
|
|
||||||
<title>Bürokalender</title>
|
<title>Bürokalender</title>
|
||||||
@@ -30,6 +30,6 @@
|
|||||||
{#insert contents}No contents!{/}
|
{#insert contents}No contents!{/}
|
||||||
</div>
|
</div>
|
||||||
<script src="/webjars/popper.js/2.9.2/umd/popper.min.js"></script>
|
<script src="/webjars/popper.js/2.9.2/umd/popper.min.js"></script>
|
||||||
<script src="/webjars/bootstrap/5.0.0/js/bootstrap.min.js"></script>
|
<script src="/webjars/bootstrap/5.1.1/js/bootstrap.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -2,9 +2,11 @@
|
|||||||
{#user_active}active{/}
|
{#user_active}active{/}
|
||||||
{#contents}
|
{#contents}
|
||||||
|
|
||||||
|
{#if is_admin??}
|
||||||
|
<h2>Admin-Konfiguration</h2>
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<h2>Hallo {current_user.username}</h2>
|
|
||||||
{#if is_admin??}
|
<h3>Benutzer</h3>
|
||||||
<table class="table table-striped table-bordered">
|
<table class="table table-striped table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -30,18 +32,101 @@
|
|||||||
{/for}
|
{/for}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{/if}
|
<a class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#userModal" role="button">neuer Benutzer</a>
|
||||||
|
{#include user-modal.html rooms=rooms user=current_user}{/include}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div class="mt-4">
|
||||||
|
<h3>Verkehrsinfos</h3>
|
||||||
|
<div class="mx-auto">
|
||||||
|
<form class="row g-3 mt-2" action="/user/traffic/config" method="POST" name="trafficAdminForm" enctype="multipart/form-data">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="form-floating">
|
||||||
|
<input type="text" name="googleapikey" class="form-control" id="key" placeholder="google-API-Key" value="{google_api_key}" required>
|
||||||
|
<label for="key">google-API-Key</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-8">
|
||||||
|
<div class="form-floating">
|
||||||
|
<input type="text" name="officeaddress" class="form-control" id="office" placeholder="Büroadresse" value="{office_address}"
|
||||||
|
required>
|
||||||
|
<label for="home">Büroadresse</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-1 mt-4">
|
||||||
|
<button type="submit" class="btn btn-primary">Speichern</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-2" >
|
<hr class="mz-4">
|
||||||
{#if is_admin??}
|
|
||||||
<a class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#userModal" role="button">neuer Benutzer</a>
|
<div class="mt-5">
|
||||||
{/if}
|
<h2>Persönliche Konfiguration von {current_user.username}</h2>
|
||||||
<a class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#passwordModal" role="button">Passwort ändern</a>
|
<a class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#passwordModal" role="button">Passwort ändern</a>
|
||||||
{#if is_admin??}
|
{#include password-modal.html}{/include}
|
||||||
{#include user-modal.html rooms=rooms user=current_user}{/include}
|
</div>
|
||||||
{/if}
|
<div class="mt-4">
|
||||||
{#include password-modal.html}{/include}
|
<h3>Verkehrsinfos</h3>
|
||||||
|
Die Fahrzeit wird über die googlemaps-API ermittelt und bei Überschreitung des Grenzwerts via E-Mail gewarnt.
|
||||||
|
<div class="mx-auto">
|
||||||
|
<form class="row g-3 mt-2" action="/user/traffic/config/{current_user.username}" method="POST" name="trafficUserForm"
|
||||||
|
enctype="multipart/form-data">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="form-floating">
|
||||||
|
<input type="email" name="traffic_email" class="form-control" id="email" placeholder="E-Mail-Adresse"
|
||||||
|
value="{traffic_email ?: ''}" required>
|
||||||
|
<label for="email">E-Mail-Adresse</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-8">
|
||||||
|
<div class="form-floating">
|
||||||
|
<input type="text" name="traffic_address" class="form-control" id="home" placeholder="Heimatadresse"
|
||||||
|
value="{traffic_address ?: ''}" required>
|
||||||
|
<label for="home">Heimatadresse</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-2">
|
||||||
|
<div class="form-floating">
|
||||||
|
<input type="time" name="traffic_away" class="form-control" id="away" value="{traffic_away ?: ''}" required>
|
||||||
|
<label for="away">Hinfahrt</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-2">
|
||||||
|
<div class="form-floating">
|
||||||
|
<input type="time" name="traffic_back" class="form-control" id="back" value="{traffic_back ?: ''}" required>
|
||||||
|
<label for="back">Rückfahrt</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-floating">
|
||||||
|
<input type="number" min="1" max="999" name="traffic_duration" class="form-control" placeholder="Grenzwert Fahrzeit" id="duration"
|
||||||
|
value="{traffic_duration ?: ''}" required>
|
||||||
|
<label for="duration">Grenzwert Fahrzeit</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input id="trafficswitch" class="form-check-input" type="checkbox" name="traffic_active"
|
||||||
|
{#if traffic_active??}checked{/if} value="true" >
|
||||||
|
<label class="form-check-label" for="trafficswitch">Verkehrsinfos via google-API aktiv</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-1 mt-4">
|
||||||
|
<button type="submit" class="btn btn-primary">Speichern</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{/contents}
|
{/contents}
|
||||||
{/include}
|
{/include}
|
||||||
|
|||||||
Reference in New Issue
Block a user