├── .classpath ├── .github └── workflows │ └── codeql-analysis.yml ├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── .project ├── .travis.yml ├── .vscode └── launch.json ├── Dockerfile ├── LICENSE.md ├── README.md ├── backend ├── .classpath ├── .gitignore ├── .project ├── pom.xml └── src │ ├── main │ ├── java │ │ ├── META-INF │ │ │ └── MANIFEST.MF │ │ └── ch │ │ │ └── xxx │ │ │ └── messenger │ │ │ ├── MessengerApplication.java │ │ │ ├── adapter │ │ │ ├── config │ │ │ │ ├── FlapDoodleConfig.java │ │ │ │ ├── ForwardServletFilter.java │ │ │ │ ├── GlobalErrorWebExceptionHandler.java │ │ │ │ ├── JwtTokenFilter.java │ │ │ │ ├── RestJwtFilter.java │ │ │ │ ├── SpringMongoConfig.java │ │ │ │ └── WebSecurityConfig.java │ │ │ ├── controller │ │ │ │ ├── AiFriendController.java │ │ │ │ ├── AuthenticationController.java │ │ │ │ ├── BingoController.java │ │ │ │ ├── ContactController.java │ │ │ │ └── MessageController.java │ │ │ ├── cron │ │ │ │ └── MessageCronJob.java │ │ │ ├── handler │ │ │ │ ├── SignalingHandler.java │ │ │ │ └── WebSocketConfig.java │ │ │ └── repository │ │ │ │ └── ClientMongoRepository.java │ │ │ ├── domain │ │ │ ├── common │ │ │ │ ├── JwtTokenProvider.java │ │ │ │ ├── Role.java │ │ │ │ ├── TokenSubjectRoles.java │ │ │ │ └── WebUtils.java │ │ │ ├── exception │ │ │ │ ├── JwtTokenValidationException.java │ │ │ │ ├── MyErrorAttributes.java │ │ │ │ └── TooManyMsgException.java │ │ │ └── model │ │ │ │ ├── AiConfig.java │ │ │ │ ├── AiMessageDto.java │ │ │ │ ├── AuthCheck.java │ │ │ │ ├── BingoGame.java │ │ │ │ ├── Contact.java │ │ │ │ ├── ContactIdsRequest.java │ │ │ │ ├── ContactUpdate.java │ │ │ │ ├── Message.java │ │ │ │ ├── MsgUser.java │ │ │ │ ├── MyMongoRepository.java │ │ │ │ └── SyncMsgs.java │ │ │ └── usecase │ │ │ └── service │ │ │ ├── AiFriendService.java │ │ │ ├── AuthenticationService.java │ │ │ ├── BingoService.java │ │ │ ├── ContactService.java │ │ │ ├── MailService.java │ │ │ └── MessageService.java │ └── resources │ │ ├── application-ollama.properties │ │ ├── application-prod.properties │ │ ├── application-ssl.properties │ │ ├── application.properties │ │ ├── log4j.xml │ │ ├── static │ │ ├── .gitignore │ │ └── index.html │ │ └── testCert │ │ └── server.p12 │ └── test │ └── java │ └── ch │ └── xxx │ └── messenger │ ├── MessengerApplicationTests.java │ ├── RandomNumberTest.java │ ├── adapter │ ├── controller │ │ └── MessageControllerTest.java │ └── repository │ │ └── ClientMongoRepositoryTest.java │ ├── architecture │ ├── MyArchitectureTests.java │ └── PatternTest.java │ └── usecase │ └── service │ └── MessageServiceTest.java ├── buildDocker.sh ├── frontend ├── .classpath ├── .gitignore ├── .project ├── pom.xml └── src │ └── angular │ ├── .editorconfig │ ├── .eslintrc.json │ ├── .gitignore │ ├── README.md │ ├── angular.json │ ├── base │ └── index.html │ ├── browserslist │ ├── e2e │ ├── protractor.conf.js │ ├── src │ │ ├── app.e2e-spec.ts │ │ └── app.po.ts │ └── tsconfig.e2e.json │ ├── i18n │ └── messages.de.json │ ├── karma.conf.js │ ├── ngsw-config.json │ ├── package-lock.json │ ├── package.json │ ├── proxy.conf.json │ ├── src │ ├── app │ │ ├── add-contacts │ │ │ ├── add-contacts.component.html │ │ │ ├── add-contacts.component.scss │ │ │ ├── add-contacts.component.spec.ts │ │ │ └── add-contacts.component.ts │ │ ├── app-routing.module.ts │ │ ├── app.component.html │ │ ├── app.component.scss │ │ ├── app.component.spec.ts │ │ ├── app.component.ts │ │ ├── app.module.ts │ │ ├── camera │ │ │ ├── camera.component.html │ │ │ ├── camera.component.scss │ │ │ ├── camera.component.spec.ts │ │ │ └── camera.component.ts │ │ ├── common │ │ │ ├── base.component.ts │ │ │ ├── constants.ts │ │ │ ├── messages.ts │ │ │ └── tuple.ts │ │ ├── contacts │ │ │ ├── contacts.component.html │ │ │ ├── contacts.component.scss │ │ │ ├── contacts.component.spec.ts │ │ │ └── contacts.component.ts │ │ ├── fileupload │ │ │ ├── fileupload.component.html │ │ │ ├── fileupload.component.scss │ │ │ ├── fileupload.component.spec.ts │ │ │ └── fileupload.component.ts │ │ ├── games │ │ │ ├── bingo │ │ │ │ ├── bingo.component.html │ │ │ │ ├── bingo.component.scss │ │ │ │ ├── bingo.component.spec.ts │ │ │ │ └── bingo.component.ts │ │ │ ├── games.component.html │ │ │ ├── games.component.scss │ │ │ ├── games.component.spec.ts │ │ │ ├── games.component.ts │ │ │ ├── games.routes.ts │ │ │ └── index.ts │ │ ├── login │ │ │ ├── login.component.html │ │ │ ├── login.component.scss │ │ │ ├── login.component.spec.ts │ │ │ └── login.component.ts │ │ ├── main │ │ │ ├── main.component.html │ │ │ ├── main.component.scss │ │ │ ├── main.component.spec.ts │ │ │ └── main.component.ts │ │ ├── messages │ │ │ ├── messages.component.html │ │ │ ├── messages.component.scss │ │ │ ├── messages.component.spec.ts │ │ │ └── messages.component.ts │ │ ├── model │ │ │ ├── aiFriend │ │ │ │ ├── ai-config.ts │ │ │ │ ├── ai-message.ts │ │ │ │ └── ai-result.ts │ │ │ ├── auth-check.ts │ │ │ ├── contact-update.ts │ │ │ ├── contact.ts │ │ │ ├── games │ │ │ │ └── bingo-game.ts │ │ │ ├── jwt-token.ts │ │ │ ├── local-contact.ts │ │ │ ├── local-message.ts │ │ │ ├── local-user.ts │ │ │ ├── message.ts │ │ │ ├── my-user.ts │ │ │ ├── private-key.ts │ │ │ ├── sync-msgs.ts │ │ │ └── voice-msg.ts │ │ ├── services │ │ │ ├── aiFriend │ │ │ │ ├── ai-friend.service.spec.ts │ │ │ │ └── ai-friend.service.ts │ │ │ ├── authentication.service.spec.ts │ │ │ ├── authentication.service.ts │ │ │ ├── contact.service.spec.ts │ │ │ ├── contact.service.ts │ │ │ ├── crypto.service.spec.ts │ │ │ ├── crypto.service.ts │ │ │ ├── games │ │ │ │ ├── bingo.service.spec.ts │ │ │ │ ├── bingo.service.ts │ │ │ │ ├── games.service.spec.ts │ │ │ │ └── games.service.ts │ │ │ ├── http-profile.interceptor.ts │ │ │ ├── jwt-token.service.spec.ts │ │ │ ├── jwt-token.service.ts │ │ │ ├── localdb.service.spec.ts │ │ │ ├── localdb.service.ts │ │ │ ├── message.service.spec.ts │ │ │ ├── message.service.ts │ │ │ ├── net-connection.service.spec.ts │ │ │ ├── net-connection.service.ts │ │ │ ├── token.interceptor.ts │ │ │ ├── translations.service.spec.ts │ │ │ ├── translations.service.ts │ │ │ ├── utils.service.ts │ │ │ ├── voice.service.spec.ts │ │ │ ├── voice.service.ts │ │ │ ├── webrtc.service.spec.ts │ │ │ └── webrtc.service.ts │ │ └── voice │ │ │ ├── voice.component.html │ │ │ ├── voice.component.scss │ │ │ ├── voice.component.spec.ts │ │ │ └── voice.component.ts │ ├── assets │ │ ├── .gitkeep │ │ └── icons │ │ │ ├── icon-128x128.png │ │ │ ├── icon-144x144.png │ │ │ ├── icon-152x152.png │ │ │ ├── icon-192x192.png │ │ │ ├── icon-384x384.png │ │ │ ├── icon-512x512.png │ │ │ ├── icon-72x72.png │ │ │ ├── icon-96x96.png │ │ │ ├── smiley-640.jpg │ │ │ └── smiling-face-with-sunglasses.svg │ ├── environments │ │ ├── environment.prod.ts │ │ └── environment.ts │ ├── favicon.ico │ ├── index.html │ ├── main.ts │ ├── manifest.json │ ├── polyfills.ts │ ├── styles.scss │ └── test.ts │ ├── tsconfig.app.json │ ├── tsconfig.json │ └── tsconfig.spec.json ├── helm ├── .helmignore ├── Chart.yaml ├── addIngress.sh ├── ca.crt ├── ca.csr ├── ca.key ├── ca.srl ├── cert.conf ├── cert.local.conf ├── helm.sh ├── ingress.yaml ├── rootCa.key ├── rootCa.pem ├── rootCa.srl ├── server.conf ├── server.crt ├── server.csr ├── server.key ├── server.local.conf ├── server.p12 ├── templates │ ├── _helpers.tpl │ └── kubTemplate.yaml └── values.yaml ├── mvnw ├── mvnw.cmd ├── pom.xml ├── prometheus-local.yml ├── runGrafana.sh ├── runMongoDBDocker.sh ├── runOllama.sh ├── runPrometheus.sh ├── runStructurizr.sh └── structurizr ├── .gitignore ├── diagrams ├── structurizr-1-Components.svg ├── structurizr-1-Containers.svg └── structurizr-1-SystemContext.svg └── workspace.dsl /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | /src/main/resources/static 4 | 5 | ### STS ### 6 | .apt_generated 7 | .factorypath 8 | .settings 9 | .springBeans 10 | .sts4-cache 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | /nbproject/private/ 20 | /build/ 21 | /nbbuild/ 22 | /dist/ 23 | /nbdist/ 24 | /.nb-gradle/ -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Angular2Guy/AngularPwaMessenger/09e31743a730756358cda21187f9c157f5beab3f/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 3 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | messenger 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.common.project.facet.core.builder 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.jboss.tools.jst.web.kb.kbbuilder 20 | 21 | 22 | 23 | 24 | org.jboss.tools.cdi.core.cdibuilder 25 | 26 | 27 | 28 | 29 | org.eclipse.wst.validation.validationbuilder 30 | 31 | 32 | 33 | 34 | org.eclipse.m2e.core.maven2Builder 35 | 36 | 37 | 38 | 39 | 40 | org.eclipse.jem.workbench.JavaEMFNature 41 | org.eclipse.jdt.core.javanature 42 | org.eclipse.m2e.core.maven2Nature 43 | org.eclipse.wst.common.modulecore.ModuleCoreNature 44 | org.eclipse.wst.common.project.facet.core.nature 45 | org.jboss.tools.jst.web.kb.kbnature 46 | org.jboss.tools.cdi.core.cdinature 47 | 48 | 49 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | jdk: 4 | - oraclejdk11 5 | 6 | addons: 7 | chrome: beta 8 | 9 | services: 10 | - docker 11 | 12 | addons: 13 | chrome: stable 14 | 15 | notifications: 16 | email: 17 | - angular2guy@gmx.ch 18 | on_success: always 19 | on_failure: always 20 | 21 | before_install: 22 | - nvm install 14.15 23 | - nvm use 14.15 24 | 25 | script: 26 | ./mvnw clean install -Ddocker=true 27 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | { 9 | "type": "jdk", 10 | "request": "launch", 11 | "name": "Launch Java App", 12 | "mainClass": "ch.xxx.messenger.MessengerApplication", 13 | "args": "--spring.profiles.active=ollama" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM eclipse-temurin:24-jdk-alpine 2 | VOLUME /tmp 3 | ARG JAR_FILE 4 | ADD backend/target/${JAR_FILE} /app.jar 5 | ENV JAVA_OPTS="-XX:+UseG1GC -XX:MaxGCPauseMillis=50 -XX:+UseStringDeduplication -XX:MaxDirectMemorySize=64m" 6 | ENTRYPOINT exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar -------------------------------------------------------------------------------- /backend/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /backend/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /backend/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | messenger-backend 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /backend/src/main/java/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/MessengerApplication.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger; 14 | 15 | import org.springframework.boot.SpringApplication; 16 | import org.springframework.boot.autoconfigure.SpringBootApplication; 17 | 18 | import io.swagger.v3.oas.annotations.OpenAPIDefinition; 19 | import io.swagger.v3.oas.annotations.info.Info; 20 | 21 | @SpringBootApplication 22 | @OpenAPIDefinition(info = @Info(title = "Messenger API", version = "1.0", description = "Messanger Api")) 23 | public class MessengerApplication { 24 | 25 | public static void main(String[] args) { 26 | SpringApplication.run(MessengerApplication.class, args); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/adapter/config/FlapDoodleConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Sven Loesekann 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package ch.xxx.messenger.adapter.config; 17 | 18 | import org.slf4j.Logger; 19 | import org.slf4j.LoggerFactory; 20 | import org.springframework.beans.factory.annotation.Value; 21 | 22 | //@Configuration 23 | public class FlapDoodleConfig { 24 | private static final Logger LOGGER = LoggerFactory.getLogger(FlapDoodleConfig.class); 25 | private static final int MONGO_DB_PORT = 27017; 26 | // private MongodExecutable mongodExecutable = null; 27 | // private MongodProcess mongod = null; 28 | @Value("${server.port:}") 29 | private String serverPort; 30 | @Value("${spring.profiles.active:}") 31 | private String activeProfiles; 32 | /* 33 | @PostConstruct 34 | public void initMongoDb() { 35 | if (this.serverPort.isBlank() || this.serverPort.contains("8080") 36 | && (this.activeProfiles.isBlank() || !this.activeProfiles.toLowerCase().contains("prod"))) { 37 | try { 38 | MongodStarter starter = MongodStarter.getDefaultInstance(); 39 | MongodConfig mongodConfig = MongodConfig.builder().version(Version.Main.V4_4) 40 | .net(new Net(MONGO_DB_PORT, Network.localhostIsIPv6())).build(); 41 | this.mongodExecutable = starter.prepare(mongodConfig); 42 | this.mongod = this.mongodExecutable.start(); 43 | LOGGER.info("MongoDb process: {}, state: {}", this.mongod.getProcessId(), 44 | this.mongod.isProcessRunning()); 45 | } catch (IOException e) { 46 | throw new RuntimeException(e); 47 | } 48 | } 49 | } 50 | 51 | @PreDestroy 52 | public void stopMongoDb() { 53 | if (this.serverPort.isBlank() || this.serverPort.contains("8080") 54 | && (this.activeProfiles.isBlank() || !this.activeProfiles.toLowerCase().contains("prod"))) { 55 | try { 56 | this.mongodExecutable.stop(); 57 | LOGGER.info("MongoDb proces: {}, state: {}", this.mongod.getProcessId(), 58 | this.mongod.isProcessRunning()); 59 | } catch (Exception e) { 60 | throw new RuntimeException(e); 61 | } 62 | } 63 | } 64 | */ 65 | } 66 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/adapter/config/JwtTokenFilter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.adapter.config; 14 | 15 | import java.io.IOException; 16 | 17 | import jakarta.servlet.FilterChain; 18 | import jakarta.servlet.ServletException; 19 | import jakarta.servlet.ServletRequest; 20 | import jakarta.servlet.ServletResponse; 21 | import jakarta.servlet.http.HttpServletRequest; 22 | 23 | import org.springframework.security.core.Authentication; 24 | import org.springframework.security.core.context.SecurityContextHolder; 25 | import org.springframework.web.filter.GenericFilterBean; 26 | 27 | import ch.xxx.messenger.domain.common.JwtTokenProvider; 28 | 29 | public class JwtTokenFilter extends GenericFilterBean { 30 | 31 | private JwtTokenProvider jwtTokenProvider; 32 | 33 | public JwtTokenFilter(JwtTokenProvider jwtTokenProvider) { 34 | this.jwtTokenProvider = jwtTokenProvider; 35 | } 36 | 37 | @Override 38 | public void doFilter(ServletRequest req, ServletResponse res, FilterChain filterChain) 39 | throws IOException, ServletException { 40 | 41 | String token = jwtTokenProvider.resolveToken((HttpServletRequest) req); 42 | if (token != null && jwtTokenProvider.validateToken(token)) { 43 | Authentication auth = token != null ? jwtTokenProvider.getAuthentication(token) : null; 44 | SecurityContextHolder.getContext().setAuthentication(auth); 45 | } 46 | 47 | filterChain.doFilter(req, res); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/adapter/controller/AiFriendController.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.adapter.controller; 14 | 15 | import org.slf4j.Logger; 16 | import org.slf4j.LoggerFactory; 17 | import org.springframework.ai.chat.messages.UserMessage; 18 | import org.springframework.ai.chat.model.ChatResponse; 19 | import org.springframework.web.bind.annotation.GetMapping; 20 | import org.springframework.web.bind.annotation.PostMapping; 21 | import org.springframework.web.bind.annotation.RequestBody; 22 | import org.springframework.web.bind.annotation.RequestMapping; 23 | import org.springframework.web.bind.annotation.RestController; 24 | 25 | import ch.xxx.messenger.domain.model.AiConfig; 26 | import ch.xxx.messenger.domain.model.AiMessageDto; 27 | import ch.xxx.messenger.usecase.service.AiFriendService; 28 | import reactor.core.publisher.Flux; 29 | 30 | @RestController 31 | @RequestMapping("/rest/aifriend") 32 | public class AiFriendController { 33 | private static final Logger LOGGER = LoggerFactory.getLogger(AiFriendController.class); 34 | private final AiFriendService aiFriendService; 35 | 36 | public AiFriendController(AiFriendService aiFriendService) { 37 | this.aiFriendService = aiFriendService; 38 | } 39 | 40 | @GetMapping("/config") 41 | public AiConfig getAiConfig() { 42 | return this.aiFriendService.createAiConfig(); 43 | } 44 | 45 | @PostMapping("/talk") 46 | public Flux talkToSam(@RequestBody AiMessageDto aiMessageDto) { 47 | var userMessage = new UserMessage(aiMessageDto.getContent()); 48 | return this.aiFriendService.talkToSam(userMessage); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/adapter/controller/AuthenticationController.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.adapter.controller; 14 | 15 | import java.util.Map; 16 | 17 | import org.slf4j.Logger; 18 | import org.slf4j.LoggerFactory; 19 | import org.springframework.web.bind.annotation.GetMapping; 20 | import org.springframework.web.bind.annotation.PathVariable; 21 | import org.springframework.web.bind.annotation.PostMapping; 22 | import org.springframework.web.bind.annotation.RequestBody; 23 | import org.springframework.web.bind.annotation.RequestHeader; 24 | import org.springframework.web.bind.annotation.RequestMapping; 25 | import org.springframework.web.bind.annotation.RestController; 26 | 27 | import ch.xxx.messenger.domain.model.AuthCheck; 28 | import ch.xxx.messenger.domain.model.MsgUser; 29 | import ch.xxx.messenger.usecase.service.AuthenticationService; 30 | import reactor.core.publisher.Mono; 31 | 32 | @RestController 33 | @RequestMapping("/rest/auth") 34 | public class AuthenticationController { 35 | private static final Logger LOG = LoggerFactory.getLogger(AuthenticationController.class); 36 | 37 | private final AuthenticationService authenticationService; 38 | 39 | public AuthenticationController(AuthenticationService authenticationService) { 40 | this.authenticationService = authenticationService; 41 | } 42 | 43 | @PostMapping("/authorize") 44 | public Mono postAuthorize(@RequestBody AuthCheck authcheck, @RequestHeader Map header) { 45 | return this.authenticationService.authorizeUser(authcheck, header); 46 | } 47 | 48 | @PostMapping("/signin") 49 | public Mono postUserSignin(@RequestBody MsgUser myUser) { 50 | return this.authenticationService.userSignin(myUser); 51 | } 52 | 53 | @GetMapping("/confirm/{uuid}") 54 | public Mono getConfirmUuid(@PathVariable String uuid) { 55 | return this.authenticationService.confirmUuid(uuid); 56 | } 57 | 58 | @PostMapping("/login") 59 | public Mono postUserLogin(@RequestBody MsgUser myUser) { 60 | return this.authenticationService.userLogin(myUser); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/adapter/controller/BingoController.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.adapter.controller; 14 | 15 | import org.springframework.web.bind.annotation.GetMapping; 16 | import org.springframework.web.bind.annotation.PathVariable; 17 | import org.springframework.web.bind.annotation.PostMapping; 18 | import org.springframework.web.bind.annotation.RequestBody; 19 | import org.springframework.web.bind.annotation.RequestMapping; 20 | import org.springframework.web.bind.annotation.RestController; 21 | 22 | import ch.xxx.messenger.domain.model.BingoGame; 23 | import ch.xxx.messenger.usecase.service.BingoService; 24 | import reactor.core.publisher.Mono; 25 | 26 | @RestController 27 | @RequestMapping("/rest/games/bingo") 28 | public class BingoController { 29 | private final BingoService bingoService; 30 | 31 | public BingoController(BingoService bingoService) { 32 | this.bingoService = bingoService; 33 | } 34 | 35 | @PostMapping("/newgame") 36 | public Mono postStartGame(@RequestBody BingoGame bingoGame) { 37 | return this.bingoService.startBingoGame(bingoGame); 38 | } 39 | 40 | @GetMapping("/updategame/{uuid}") 41 | public Mono getUpdateGame(@PathVariable("uuid") String uuid) { 42 | return this.bingoService.updateBingoGame(uuid); 43 | } 44 | 45 | @GetMapping("/checkwin/{gameUuid}/user/{userUuid}") 46 | public Mono getCheckWin(@PathVariable("gameUuid") String gameUuid, @PathVariable("userUuid") String userUuid) { 47 | return this.bingoService.checkWin(gameUuid, userUuid); 48 | } 49 | 50 | @GetMapping("/endgame/{gameUuid}") 51 | public Mono getEndGame(@PathVariable("gameUuid") String gameUuid) { 52 | return this.bingoService.endGame(gameUuid); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/adapter/controller/ContactController.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.adapter.controller; 14 | 15 | import java.util.List; 16 | 17 | import org.springframework.web.bind.annotation.PostMapping; 18 | import org.springframework.web.bind.annotation.RequestBody; 19 | import org.springframework.web.bind.annotation.RequestMapping; 20 | import org.springframework.web.bind.annotation.RestController; 21 | 22 | import ch.xxx.messenger.domain.model.Contact; 23 | import ch.xxx.messenger.domain.model.ContactIdsRequest; 24 | import ch.xxx.messenger.domain.model.ContactUpdate; 25 | import ch.xxx.messenger.usecase.service.ContactService; 26 | import reactor.core.publisher.Flux; 27 | import reactor.core.publisher.Mono; 28 | 29 | @RestController 30 | @RequestMapping("/rest/contact") 31 | public class ContactController { 32 | private final ContactService contactService; 33 | 34 | public ContactController(ContactService contactService) { 35 | this.contactService = contactService; 36 | } 37 | 38 | @PostMapping("/findcontacts") 39 | public Flux getFindContacts(@RequestBody Contact contact) { 40 | return this.contactService.findContacts(contact); 41 | } 42 | 43 | @PostMapping("/updatecontacts") 44 | public Mono postUpdateContacts(@RequestBody ContactUpdate contactUpdate) { 45 | return this.contactService.updateContacts(contactUpdate); 46 | } 47 | 48 | @PostMapping("/findcontactsbyIds") 49 | public Flux findContactByIds(@RequestBody ContactIdsRequest contactIdsRequest) { 50 | return this.contactService.findContactsByIds(List.of(contactIdsRequest.getContactIds())); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/adapter/controller/MessageController.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.adapter.controller; 14 | 15 | import org.springframework.http.ResponseEntity; 16 | import org.springframework.web.bind.annotation.PostMapping; 17 | import org.springframework.web.bind.annotation.RequestBody; 18 | import org.springframework.web.bind.annotation.RequestMapping; 19 | import org.springframework.web.bind.annotation.RestController; 20 | 21 | import ch.xxx.messenger.domain.model.Contact; 22 | import ch.xxx.messenger.domain.model.Message; 23 | import ch.xxx.messenger.domain.model.SyncMsgs; 24 | import ch.xxx.messenger.usecase.service.MessageService; 25 | import reactor.core.publisher.Flux; 26 | 27 | @RestController 28 | @RequestMapping("/rest/message") 29 | public class MessageController { 30 | 31 | private final MessageService messageService; 32 | 33 | public MessageController(MessageService messageService) { 34 | this.messageService = messageService; 35 | } 36 | 37 | @PostMapping("/findMsgs") 38 | public Flux getFindMessages(@RequestBody SyncMsgs syncMsgs) { 39 | return this.messageService.findMessages(syncMsgs); 40 | } 41 | 42 | @PostMapping("/receivedMsgs") 43 | public Flux getReceivedMessages(@RequestBody Contact contact) { 44 | return this.messageService.receivedMessages(contact); 45 | } 46 | 47 | @PostMapping("/storeMsgs") 48 | public ResponseEntity> putStoreMessages(@RequestBody SyncMsgs syncMsgs) { 49 | return this.messageService.storeMessages(syncMsgs); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/adapter/cron/MessageCronJob.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.adapter.cron; 14 | 15 | import org.slf4j.Logger; 16 | import org.slf4j.LoggerFactory; 17 | import org.springframework.beans.factory.annotation.Value; 18 | import org.springframework.scheduling.annotation.Scheduled; 19 | import org.springframework.stereotype.Component; 20 | 21 | import ch.xxx.messenger.usecase.service.BingoService; 22 | import ch.xxx.messenger.usecase.service.MessageService; 23 | import jakarta.annotation.PostConstruct; 24 | import net.javacrumbs.shedlock.spring.annotation.SchedulerLock; 25 | 26 | @Component 27 | public class MessageCronJob { 28 | private static final Logger LOG = LoggerFactory.getLogger(MessageCronJob.class); 29 | @Value("${cronjob.message.ttl.days}") 30 | private Long messageTtl; 31 | private final MessageService messageService; 32 | private final BingoService bingoService; 33 | 34 | public MessageCronJob(MessageService messageService, BingoService bingoService) { 35 | this.messageService = messageService; 36 | this.bingoService = bingoService; 37 | } 38 | 39 | @PostConstruct 40 | public void init() { 41 | LOG.info("Message ttl: {}", this.messageTtl); 42 | } 43 | 44 | /** 45 | * remove messages that are older than 30 days. (unreceived/unrequested) 46 | */ 47 | @Scheduled(cron = "5 0 1 * * ?") 48 | @SchedulerLock(name = "MessageCleanUp_scheduledTask", lockAtLeastFor = "PT2H", lockAtMostFor = "PT3H") 49 | public void cleanUpOldMessages() { 50 | this.messageService.cleanUpMessages(this.messageTtl); 51 | } 52 | 53 | /** 54 | * remove last updated more than a day ago. 55 | */ 56 | @Scheduled(cron = "0 5 2 * * ?") 57 | @SchedulerLock(name = "BingoCleanUp_scheduledTask", lockAtLeastFor = "PT2H", lockAtMostFor = "PT3H") 58 | public void cleanUpOldBingoGames() { 59 | this.bingoService.cleanUpGames(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/adapter/handler/WebSocketConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.adapter.handler; 14 | 15 | import java.util.List; 16 | 17 | import org.springframework.context.annotation.Configuration; 18 | import org.springframework.core.env.Environment; 19 | import org.springframework.web.socket.config.annotation.EnableWebSocket; 20 | import org.springframework.web.socket.config.annotation.WebSocketConfigurer; 21 | import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration; 22 | import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; 23 | 24 | @Configuration 25 | @EnableWebSocket 26 | public class WebSocketConfig implements WebSocketConfigurer{ 27 | private SignalingHandler socketHandler; 28 | private Environment environment; 29 | 30 | public WebSocketConfig(SignalingHandler socketHandler, Environment environment) { 31 | this.socketHandler = socketHandler; 32 | this.environment = environment; 33 | } 34 | 35 | @Override 36 | public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { 37 | WebSocketHandlerRegistration handlerRegistration = registry.addHandler(this.socketHandler, "/signalingsocket"); 38 | if(List.of(this.environment.getActiveProfiles()).stream().noneMatch(myProfile -> myProfile.toLowerCase().contains("prod"))) { 39 | handlerRegistration.setAllowedOrigins("*"); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/domain/common/Role.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.domain.common; 14 | 15 | import org.springframework.security.core.GrantedAuthority; 16 | 17 | public enum Role implements GrantedAuthority{ 18 | USERS, GUEST; 19 | 20 | @Override 21 | public String getAuthority() { 22 | return this.name(); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/domain/common/TokenSubjectRoles.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.domain.common; 14 | 15 | public record TokenSubjectRoles(String subject, String roles) { } 16 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/domain/exception/JwtTokenValidationException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.domain.exception; 14 | 15 | public class JwtTokenValidationException extends RuntimeException { 16 | 17 | private static final long serialVersionUID = 4495144584990207860L; 18 | 19 | public JwtTokenValidationException(String message) { 20 | super(message); 21 | } 22 | 23 | public JwtTokenValidationException(String message, Throwable throwable) { 24 | super(message,throwable); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/domain/exception/MyErrorAttributes.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.domain.exception; 14 | 15 | import org.springframework.boot.web.reactive.error.DefaultErrorAttributes; 16 | import org.springframework.stereotype.Component; 17 | 18 | @Component 19 | public class MyErrorAttributes extends DefaultErrorAttributes { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/domain/exception/TooManyMsgException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.domain.exception; 14 | 15 | public class TooManyMsgException extends RuntimeException { 16 | private static final long serialVersionUID = 1191680533563683261L; 17 | 18 | public TooManyMsgException(String message) { 19 | super(message); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/domain/model/AiConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.domain.model; 14 | 15 | public record AiConfig(Boolean enabled, String aiModel) { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/domain/model/AiMessageDto.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.domain.model; 14 | 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | public class AiMessageDto { 19 | private String content; 20 | private Map properties = new HashMap<>(); 21 | private String messageType; 22 | 23 | public AiMessageDto() {} 24 | 25 | public void setContent(String content) { 26 | this.content = content; 27 | } 28 | 29 | public void setMessageType(String messageType) { 30 | this.messageType = messageType; 31 | } 32 | 33 | public String getContent() { 34 | return this.content; 35 | } 36 | 37 | public String getMessageType() { 38 | return this.messageType; 39 | } 40 | 41 | public Map getProperties() { 42 | return properties; 43 | } 44 | 45 | public void setProperties(Map properties) { 46 | this.properties = properties; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/domain/model/AuthCheck.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.domain.model; 14 | 15 | import com.fasterxml.jackson.annotation.JsonProperty; 16 | 17 | public class AuthCheck { 18 | private final String path; 19 | private final boolean authorized; 20 | 21 | public AuthCheck(@JsonProperty("path") String path, @JsonProperty("authorized") boolean authorized) { 22 | super(); 23 | this.path = path; 24 | this.authorized = authorized; 25 | } 26 | 27 | public boolean isAuthorized() { 28 | return authorized; 29 | } 30 | 31 | public String getPath() { 32 | return path; 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/domain/model/BingoGame.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Sven Loesekann 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package ch.xxx.messenger.domain.model; 17 | 18 | import java.time.LocalDateTime; 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | import org.bson.types.ObjectId; 23 | import org.springframework.data.annotation.Id; 24 | import org.springframework.data.mongodb.core.mapping.Document; 25 | 26 | import com.fasterxml.jackson.annotation.JsonProperty; 27 | 28 | @Document 29 | public class BingoGame { 30 | public record BingoBoard(int[][] board, boolean[][] hits) {} 31 | 32 | @Id 33 | private ObjectId id; 34 | @JsonProperty 35 | private String uuid; 36 | @JsonProperty 37 | private LocalDateTime lastUpdate = LocalDateTime.now(); 38 | @JsonProperty 39 | private List bingoBoards = new ArrayList<>(); 40 | @JsonProperty 41 | private List playerUserIds = new ArrayList<>(); 42 | @JsonProperty 43 | private List randomValues = new ArrayList<>(); 44 | 45 | public ObjectId getId() { 46 | return id; 47 | } 48 | public void setId(ObjectId id) { 49 | this.id = id; 50 | } 51 | public String getUuid() { 52 | return uuid; 53 | } 54 | public void setUuid(String uuid) { 55 | this.uuid = uuid; 56 | } 57 | public List getBingoBoards() { 58 | return bingoBoards; 59 | } 60 | public List getPlayerUserIds() { 61 | return playerUserIds; 62 | } 63 | public void setRandomValues(List randomValues) { 64 | this.randomValues = randomValues; 65 | } 66 | public LocalDateTime getLastUpdate() { 67 | return lastUpdate; 68 | } 69 | public void setLastUpdate(LocalDateTime lastUpdate) { 70 | this.lastUpdate = lastUpdate; 71 | } 72 | public List getRandomValues() { 73 | return randomValues; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/domain/model/Contact.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.domain.model; 14 | 15 | import jakarta.validation.constraints.NotBlank; 16 | import jakarta.validation.constraints.Size; 17 | 18 | public class Contact { 19 | @NotBlank 20 | @Size(min = 4) 21 | private String name; 22 | private String base64Avatar; 23 | @NotBlank 24 | private String publicKey; 25 | @NotBlank 26 | private String userId; 27 | 28 | public Contact() { 29 | } 30 | 31 | public Contact(String name, String base64Avatar, String publicKey, String userId) { 32 | super(); 33 | this.name = name; 34 | this.base64Avatar = base64Avatar; 35 | this.publicKey = publicKey; 36 | this.userId = userId; 37 | } 38 | 39 | public String getName() { 40 | return name; 41 | } 42 | public String getBase64Avatar() { 43 | return base64Avatar; 44 | } 45 | public void setName(String name) { 46 | this.name = name; 47 | } 48 | public void setBase64Avatar(String base64Avatar) { 49 | this.base64Avatar = base64Avatar; 50 | } 51 | public String getUserId() { 52 | return userId; 53 | } 54 | public void setUserId(String userId) { 55 | this.userId = userId; 56 | } 57 | 58 | public String getPublicKey() { 59 | return publicKey; 60 | } 61 | 62 | public void setPublicKey(String publicKey) { 63 | this.publicKey = publicKey; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/domain/model/ContactIdsRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.domain.model; 14 | 15 | public class ContactIdsRequest { 16 | private String[] contactIds; 17 | 18 | public String[] getContactIds() { 19 | return contactIds; 20 | } 21 | 22 | public void setContactIds(String[] contactIds) { 23 | this.contactIds = contactIds; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/domain/model/ContactUpdate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.domain.model; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | import jakarta.validation.constraints.NotBlank; 19 | 20 | public class ContactUpdate { 21 | @NotBlank 22 | private String userId; 23 | private List contacts = new ArrayList<>(); 24 | 25 | public String getUserId() { 26 | return userId; 27 | } 28 | public void setUserId(String userId) { 29 | this.userId = userId; 30 | } 31 | public List getContacts() { 32 | return contacts; 33 | } 34 | public void setContacts(List contacts) { 35 | this.contacts = contacts; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/domain/model/MyMongoRepository.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Sven Loesekann 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package ch.xxx.messenger.domain.model; 17 | 18 | import java.util.Collection; 19 | 20 | import org.bson.Document; 21 | import org.springframework.data.mongodb.core.query.Query; 22 | 23 | import com.mongodb.client.result.DeleteResult; 24 | import com.mongodb.reactivestreams.client.MongoCollection; 25 | 26 | import reactor.core.publisher.Flux; 27 | import reactor.core.publisher.Mono; 28 | 29 | public interface MyMongoRepository { 30 | 31 | Mono findOne(Query query, Class entityClass); 32 | 33 | Mono findOne(Query query, Class entityClass, String name); 34 | 35 | Flux find(Query query, Class entityClass); 36 | 37 | Flux find(Query query, Class entityClass, String collectionName); 38 | 39 | Flux findAllAndRemove(Query query, Class entityClass); 40 | 41 | Flux insertAll(Collection batchToSave); 42 | 43 | Mono collectionExists(String collectionName); 44 | 45 | Mono> createCollection(String collectionName); 46 | 47 | Mono save(T objectToSave); 48 | 49 | Mono save(Mono monoObjectToSave); 50 | 51 | Mono remove(Object object); 52 | 53 | Mono remove(Query query, Class entityClass); 54 | } 55 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/domain/model/SyncMsgs.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.domain.model; 14 | 15 | import java.util.ArrayList; 16 | import java.util.Date; 17 | import java.util.List; 18 | 19 | import jakarta.validation.constraints.NotBlank; 20 | import jakarta.validation.constraints.NotNull; 21 | 22 | import org.springframework.data.mongodb.core.mapping.Document; 23 | 24 | import com.fasterxml.jackson.annotation.JsonProperty; 25 | 26 | @Document 27 | public class SyncMsgs { 28 | @NotNull 29 | @JsonProperty 30 | private Date lastUpdate; 31 | @NotBlank 32 | @JsonProperty 33 | private String ownId; 34 | @JsonProperty 35 | private List contactIds = new ArrayList<>(); 36 | @JsonProperty 37 | private List msgs = new ArrayList<>(); 38 | 39 | public String getOwnId() { 40 | return ownId; 41 | } 42 | 43 | public void setOwnId(String ownId) { 44 | this.ownId = ownId; 45 | } 46 | 47 | public List getMsgs() { 48 | return msgs; 49 | } 50 | 51 | public void setMsgs(List msgs) { 52 | this.msgs = msgs; 53 | } 54 | 55 | public List getContactIds() { 56 | return contactIds; 57 | } 58 | 59 | public void setContactIds(List contactIds) { 60 | this.contactIds = contactIds; 61 | } 62 | 63 | public Date getLastUpdate() { 64 | return lastUpdate; 65 | } 66 | 67 | public void setLastUpdate(Date lastUpdate) { 68 | this.lastUpdate = lastUpdate; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/usecase/service/AiFriendService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger.usecase.service; 14 | 15 | import org.slf4j.Logger; 16 | import org.slf4j.LoggerFactory; 17 | import org.springframework.ai.chat.messages.UserMessage; 18 | import org.springframework.ai.chat.model.ChatResponse; 19 | import org.springframework.ai.chat.model.StreamingChatModel; 20 | import org.springframework.ai.chat.prompt.Prompt; 21 | import org.springframework.beans.factory.annotation.Value; 22 | import org.springframework.stereotype.Service; 23 | 24 | import ch.xxx.messenger.domain.model.AiConfig; 25 | import reactor.core.publisher.Flux; 26 | 27 | @Service 28 | public class AiFriendService { 29 | private static final Logger LOGGER = LoggerFactory.getLogger(AiFriendService.class); 30 | @Value("${spring.profiles.active:}") 31 | private String activeProfile; 32 | @Value("${spring.ai.ollama.chat.options.model:}") 33 | private String aiModel; 34 | private final StreamingChatModel streamingChatClient; 35 | 36 | public AiFriendService(StreamingChatModel streamingChatClient) { 37 | this.streamingChatClient = streamingChatClient; 38 | } 39 | 40 | public AiConfig createAiConfig() { 41 | return new AiConfig(this.activeProfile.contains("ollama"), this.aiModel); 42 | } 43 | 44 | public Flux talkToSam(UserMessage statement) { 45 | //LOGGER.info(this.streamingChatClient.stream(statement.getText()).reduce("", (acc, value) -> acc+value).block()); 46 | Prompt prompt = new Prompt(statement); 47 | return this.streamingChatClient.stream(prompt); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /backend/src/main/java/ch/xxx/messenger/usecase/service/MailService.java: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Copyright 2018 Sven Loesekann 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | package ch.xxx.messenger.usecase.service; 15 | 16 | import jakarta.validation.Valid; 17 | 18 | import org.slf4j.Logger; 19 | import org.slf4j.LoggerFactory; 20 | import org.springframework.beans.factory.annotation.Value; 21 | import org.springframework.mail.SimpleMailMessage; 22 | import org.springframework.mail.javamail.JavaMailSender; 23 | import org.springframework.stereotype.Service; 24 | 25 | import ch.xxx.messenger.domain.model.MsgUser; 26 | 27 | @Service 28 | public class MailService { 29 | private static final Logger LOG = LoggerFactory.getLogger(MailService.class); 30 | 31 | private final JavaMailSender javaMailSender; 32 | 33 | @Value("${spring.mail.username}") 34 | private String mailuser; 35 | @Value("${spring.mail.password}") 36 | private String mailpwd; 37 | 38 | public MailService(JavaMailSender javaMailSender) { 39 | this.javaMailSender = javaMailSender; 40 | } 41 | 42 | public void sendConfirmMail(@Valid MsgUser myUser, String confirmUrl) { 43 | if (confirmUrl != null && !confirmUrl.isBlank()) { 44 | SimpleMailMessage msg = new SimpleMailMessage(); 45 | msg.setTo(myUser.getEmail()); 46 | msg.setSubject("AngularPwaMessenger Account Confirmation Mail"); 47 | String url = confirmUrl + "/" + myUser.getUuid(); 48 | msg.setText(String.format( 49 | "Welcome to the AngularPwaMessenger please use this link(%s) to confirm your account.", url)); 50 | this.javaMailSender.send(msg); 51 | LOG.info("Confirm Mail send to: "+myUser.getEmail()); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /backend/src/main/resources/application-ollama.properties: -------------------------------------------------------------------------------- 1 | spring.ai.ollama.base-url=${OLLAMA-BASE-URL:http://localhost:11434} 2 | spring.ai.ollama.chat.options.model=samantha-mistral:7b 3 | spring.mvc.async.request-timeout=180000 -------------------------------------------------------------------------------- /backend/src/main/resources/application-prod.properties: -------------------------------------------------------------------------------- 1 | spring.lifecycle.timeout-per-shutdown-phase=${SHUTDOWN_PHASE:3s} 2 | server.shutdown=graceful -------------------------------------------------------------------------------- /backend/src/main/resources/application-ssl.properties: -------------------------------------------------------------------------------- 1 | //Ssl 2 | security.require-ssl=true 3 | server.ssl.key-store=classpath:testCert/server.p12 4 | server.ssl.key-store-password=apwamessenger 5 | server.ssl.key-store-type=pkcs12 6 | server.ssl.key-alias=tomcat 7 | server.port=8443 -------------------------------------------------------------------------------- /backend/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /backend/src/main/resources/static/.gitignore: -------------------------------------------------------------------------------- 1 | /de/ 2 | /en/ 3 | -------------------------------------------------------------------------------- /backend/src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | The languages german and english are supported:
11 | German 12 | English 13 | 14 | -------------------------------------------------------------------------------- /backend/src/main/resources/testCert/server.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Angular2Guy/AngularPwaMessenger/09e31743a730756358cda21187f9c157f5beab3f/backend/src/main/resources/testCert/server.p12 -------------------------------------------------------------------------------- /backend/src/test/java/ch/xxx/messenger/MessengerApplicationTests.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger; 14 | 15 | //@SpringBootTest 16 | public class MessengerApplicationTests { 17 | 18 | // @Test 19 | public void contextLoads() { 20 | } 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /backend/src/test/java/ch/xxx/messenger/RandomNumberTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package ch.xxx.messenger; 14 | 15 | import java.nio.ByteBuffer; 16 | import java.nio.charset.StandardCharsets; 17 | import java.util.Base64; 18 | import java.util.Random; 19 | 20 | import org.junit.jupiter.api.Assertions; 21 | import org.junit.jupiter.api.Test; 22 | 23 | public class RandomNumberTest { 24 | private Random rand = new Random(); 25 | 26 | @Test 27 | public void generateRandomNumber() { 28 | Assertions.assertNotNull(rand.nextLong()); 29 | } 30 | 31 | // generates the bas64 encoded random number for the jwt signature 32 | // property: security.jwt.token.secret-key 33 | @Test 34 | public void generateBase64RandomNumber() { 35 | final int numberOfBytes = 32; 36 | ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES*numberOfBytes); 37 | for(int i = 0;i testStrings = List.of( 31 | "ch.xxx.trader.adapter.controller.StatisticsController__BeanDefinitions.class", 32 | "file:/home/sven/git/AngularAndSpring/backend/target/classes/ch/xxx/trader/TraderApplication$$SpringCGLIB$$0.class", 33 | "ch.xxx.maps.usecase.service.CompanySiteService__TestContext001_BeanDefinitions.class"); 34 | private final DoNotIncludeAotGenerated importOption = new MyArchitectureTests.DoNotIncludeAotGenerated(); 35 | 36 | @Test 37 | public void testMatcherBeanDefinition() throws URISyntaxException { 38 | Assertions.assertFalse(importOption.includes(Location.of(Path.of(testStrings.get(0))))); 39 | } 40 | 41 | @Test 42 | public void testMatcherCgLib() throws URISyntaxException { 43 | Assertions.assertFalse(importOption.includes(Location.of(Path.of(testStrings.get(1))))); 44 | } 45 | 46 | @Test 47 | public void testMatcherTests() throws URISyntaxException { 48 | Assertions.assertFalse(importOption.includes(Location.of(Path.of(testStrings.get(2))))); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /buildDocker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #./mvnw clean install -Ddocker=true -Dnpm.test.script=test-chromium 3 | ./mvnw clean install -Ddocker=true 4 | docker build -t angular2guy/angularpwamessenger:latest --build-arg JAR_FILE=messenger-backend-0.0.1-SNAPSHOT.jar --no-cache . 5 | docker run -p 8080:8080 --memory="512m" --network="host" angular2guy/angularpwamessenger:latest -------------------------------------------------------------------------------- /frontend/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /frontend/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /frontend/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | messenger-frontend 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /frontend/src/angular/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /frontend/src/angular/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "ignorePatterns": [ 4 | "projects/**/*" 5 | ], 6 | "overrides": [ 7 | { 8 | "files": [ 9 | "*.ts" 10 | ], 11 | "parserOptions": { 12 | "project": [ 13 | "tsconfig.json", 14 | "e2e/tsconfig.json" 15 | ], 16 | "createDefaultProgram": true 17 | }, 18 | "extends": [ 19 | "plugin:@angular-eslint/ng-cli-compat", 20 | "plugin:@angular-eslint/ng-cli-compat--formatting-add-on", 21 | "plugin:@angular-eslint/template/process-inline-templates" 22 | ], 23 | "rules": { 24 | "@angular-eslint/component-selector": [ 25 | "error", 26 | { 27 | "type": "element", 28 | "prefix": "app", 29 | "style": "kebab-case" 30 | } 31 | ], 32 | "@angular-eslint/directive-selector": [ 33 | "error", 34 | { 35 | "type": "attribute", 36 | "prefix": "app", 37 | "style": "camelCase" 38 | } 39 | ], 40 | "@typescript-eslint/explicit-member-accessibility": [ 41 | "off", 42 | { 43 | "accessibility": "explicit" 44 | } 45 | ], 46 | "arrow-parens": [ 47 | "off", 48 | "always" 49 | ], 50 | "import/order": "off" 51 | } 52 | }, 53 | { 54 | "files": [ 55 | "*.html" 56 | ], 57 | "extends": [ 58 | "plugin:@angular-eslint/template/recommended" 59 | ], 60 | "rules": {} 61 | } 62 | ] 63 | } 64 | -------------------------------------------------------------------------------- /frontend/src/angular/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # profiling files 12 | chrome-profiler-events.json 13 | speed-measure-plugin.json 14 | 15 | # IDEs and editors 16 | /.idea 17 | .project 18 | .classpath 19 | .c9/ 20 | *.launch 21 | .settings/ 22 | *.sublime-workspace 23 | 24 | # IDE - VSCode 25 | .vscode/* 26 | !.vscode/settings.json 27 | !.vscode/tasks.json 28 | !.vscode/launch.json 29 | !.vscode/extensions.json 30 | 31 | # misc 32 | /.angular/cache 33 | /.sass-cache 34 | /connect.lock 35 | /coverage 36 | /libpeerconnection.log 37 | npm-debug.log 38 | yarn-error.log 39 | testem.log 40 | /typings 41 | 42 | # System Files 43 | .DS_Store 44 | Thumbs.db 45 | /.angular/ 46 | -------------------------------------------------------------------------------- /frontend/src/angular/README.md: -------------------------------------------------------------------------------- 1 | # Messenger 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.1.4. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 28 | -------------------------------------------------------------------------------- /frontend/src/angular/base/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | The languages german and english are supported:
11 | German 12 | English 13 | 14 | -------------------------------------------------------------------------------- /frontend/src/angular/browserslist: -------------------------------------------------------------------------------- 1 | last 2 Chrome version 2 | last 2 Firefox version 3 | last 2 Edge major versions 4 | last 2 Safari major version 5 | last 2 iOS major versions 6 | Firefox ESR 7 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the `not` prefix on this line..<% } %> 8 | -------------------------------------------------------------------------------- /frontend/src/angular/e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: require('path').join(__dirname, './tsconfig.e2e.json') 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; -------------------------------------------------------------------------------- /frontend/src/angular/e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('workspace-project App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getTitleText()).toEqual('Welcome to messenger!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /frontend/src/angular/e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getTitleText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontend/src/angular/e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /frontend/src/angular/i18n/messages.de.json: -------------------------------------------------------------------------------- 1 | { 2 | "locale": "de", 3 | "translations": { 4 | "addContactsAdd": "Add", 5 | "cameraSendImageTo": "Send Image to: ", 6 | "cameraEnableCamera": "Please enable your camera in the browser.", 7 | "cameraPreview": "Preview", 8 | "cameraCapture": "Capture", 9 | "cameraSend": "Send", 10 | "cameraCancel": "Cancel", 11 | "fileuploadSendFileTo": "Send File to: ", 12 | "fileuploadSelectFile": "Select File", 13 | "fileuploadFileSizeTooBig": "File size too big. Limit 2 MB.", 14 | "fileuploadUpload": "Upload", 15 | "fileuploadCancel": "Cancel", 16 | "bingoHeading": "Lets play Bingo", 17 | "bingoNewNumber": "New Number:", 18 | "bingoStart": "Start", 19 | "bingoStop": "Stop", 20 | "bingoGames": "Games", 21 | "back": "Back", 22 | "loginLogin": "Login", 23 | "loginUsername": "Username", 24 | "loginPassword": "Password", 25 | "loginLoginFailed": " Login Failed ", 26 | "loginOk": "Ok", 27 | "loginCancel": "Cancel", 28 | "loginSignin": "Signin", 29 | "loginPasswordNotMatch": " Passwords do not match ", 30 | "loginEmail": "Email", 31 | "loginSinginFailed": " Signin Failed ", 32 | "loginCreateRandomPassword": "Create a secure random/long password. It needs to be pasted into a password manager you trust.", 33 | "loginCreatePassword": "Create Password", 34 | "mainMessenger": "Messenger_de", 35 | "mainGames": "Games", 36 | "mainLogin": "Login", 37 | "mainLogout": "Logout", 38 | "mainLoginMessage": "{$START_TAG_DIV}Please Login{$CLOSE_TAG_DIV}", 39 | "IdontKnow": "I am sorry. I do not have an answer.", 40 | "samIsThinking": "Samantha is thinking.", 41 | "onlineAgainMsg": "You are online again and your token is expired. To reconnect please logout and login again.", 42 | "voiceLandscapeNotSupported": "Landscape orientation not supported on small devices.", 43 | "voiceRemote": "Remote", 44 | "voiceCall": "Call", 45 | "voiceHangup": "Hangup", 46 | "voiceMute": "Mute", 47 | "voiceUnmute": "Unmute", 48 | "voiceLocal": "Local", 49 | "voiceActivateCallerVideo": "Activate", 50 | "voiceDeactivateCallerVideo": "Deactivate" 51 | } 52 | } -------------------------------------------------------------------------------- /frontend/src/angular/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma'), 14 | require('karma-junit-reporter') 15 | ], 16 | client: { 17 | clearContext: false, // leave Jasmine Spec Runner output visible in browser 18 | jasmine: { 19 | random: false 20 | } 21 | }, 22 | coverageIstanbulReporter: { 23 | dir: require('path').join(__dirname, '../coverage'), 24 | reports: ['html', 'lcovonly', 'text-summary'], 25 | fixWebpackSourcePaths: true 26 | }, 27 | reporters: ['progress', 'kjhtml'], 28 | junitReporter: { 29 | outputDir: 'reports', // results will be saved as $outputDir/$browserName.xml 30 | outputFile: 'junit.xml', // if included, results will be saved as $outputDir/$browserName/$outputFile 31 | useBrowserName: false // add browser name to report and classes names 32 | }, 33 | port: 9876, 34 | colors: true, 35 | logLevel: config.LOG_INFO, 36 | autoWatch: true, 37 | // browsers: ['Chromium'], 38 | browsers: ['Chromium', 'ChromeHeadless', 'ChromiumHeadless'], 39 | customLaunchers: { 40 | ChromeHeadless: { 41 | base: 'Chrome', 42 | flags: ['--no-sandbox','--headless', '--disable-gpu', '--remote-debugging-port=9222'] 43 | }, 44 | ChromiumHeadless: { 45 | base: 'Chromium', 46 | flags: ['--no-sandbox','--headless', '--disable-gpu', '--remote-debugging-port=9222'] 47 | } 48 | }, 49 | singleRun: false, 50 | restartOnFileChange: true 51 | }); 52 | }; -------------------------------------------------------------------------------- /frontend/src/angular/ngsw-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "index": "/index.html", 3 | "assetGroups": [ 4 | { 5 | "name": "app", 6 | "installMode": "prefetch", 7 | "resources": { 8 | "files": [ 9 | "/favicon.ico", 10 | "/index.html", 11 | "/*.css", 12 | "/*.js", 13 | "/*.json" 14 | ] 15 | } 16 | }, { 17 | "name": "assets", 18 | "installMode": "lazy", 19 | "updateMode": "prefetch", 20 | "resources": { 21 | "files": [ 22 | "/assets/**" 23 | ] 24 | } 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /frontend/src/angular/proxy.conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "/rest": { 3 | "target": "http://localhost:8080/", 4 | "secure": false 5 | }, 6 | "/signalingsocket": { 7 | "target": "http://localhost:8080/", 8 | "secure": false, 9 | "ws": true 10 | } 11 | } -------------------------------------------------------------------------------- /frontend/src/angular/src/app/add-contacts/add-contacts.component.html: -------------------------------------------------------------------------------- 1 |
2 | @if (contactsLoading) { 3 |
4 | 9 |
10 | } 11 | 12 | 21 | 22 | @for (option of filteredOptions; track option) { 23 | 27 | {{ option.name }} 28 | 29 | } 30 | 31 | 32 |
33 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/add-contacts/add-contacts.component.scss: -------------------------------------------------------------------------------- 1 | .container { 2 | display: flex; 3 | align-items: center; 4 | height: 70px; 5 | } 6 | 7 | .input-style { 8 | margin-top: 15px; 9 | height: inherit; 10 | } 11 | 12 | .spinner { 13 | margin: 20px; 14 | height: 50px; 15 | width: 50px; 16 | } 17 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/add-contacts/add-contacts.component.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing"; 14 | 15 | import { AddContactsComponent } from "./add-contacts.component"; 16 | 17 | //describe('AddContactsComponent', () => { 18 | // let component: AddContactsComponent; 19 | // let fixture: ComponentFixture; 20 | // 21 | // beforeEach(async(() => { 22 | // TestBed.configureTestingModule({ 23 | // declarations: [ AddContactsComponent ] 24 | // }) 25 | // .compileComponents(); 26 | // })); 27 | // 28 | // beforeEach(() => { 29 | // fixture = TestBed.createComponent(AddContactsComponent); 30 | // component = fixture.componentInstance; 31 | // fixture.detectChanges(); 32 | // }); 33 | // 34 | // it('should create', () => { 35 | // expect(component).toBeTruthy(); 36 | // }); 37 | //}); 38 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { NgModule } from "@angular/core"; 14 | import { Routes, RouterModule } from "@angular/router"; 15 | import { MainComponent } from "./main/main.component"; 16 | 17 | const routes: Routes = [ 18 | { 19 | path: "games", 20 | loadChildren: () => import("./games").then((mod) => mod.GAMES), 21 | }, 22 | { path: "**", component: MainComponent }, 23 | ]; 24 | 25 | @NgModule({ 26 | imports: [RouterModule.forRoot(routes, {})], 27 | exports: [RouterModule], 28 | }) 29 | export class AppRoutingModule {} 30 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/app.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Angular2Guy/AngularPwaMessenger/09e31743a730756358cda21187f9c157f5beab3f/frontend/src/angular/src/app/app.component.scss -------------------------------------------------------------------------------- /frontend/src/angular/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { TestBed, waitForAsync } from "@angular/core/testing"; 14 | import { RouterTestingModule } from "@angular/router/testing"; 15 | import { AppComponent } from "./app.component"; 16 | 17 | describe("AppComponent", () => { 18 | beforeEach(waitForAsync(() => { 19 | TestBed.configureTestingModule({ 20 | imports: [RouterTestingModule], 21 | declarations: [AppComponent], 22 | }).compileComponents(); 23 | })); 24 | 25 | it("should create the app", () => { 26 | const fixture = TestBed.createComponent(AppComponent); 27 | const app = fixture.debugElement.componentInstance; 28 | expect(app).toBeTruthy(); 29 | }); 30 | 31 | // it(`should have as title 'messenger'`, () => { 32 | // const fixture = TestBed.createComponent(AppComponent); 33 | // const app = fixture.debugElement.componentInstance; 34 | // expect(app.title).toEqual('messenger'); 35 | // }); 36 | // 37 | // it('should render title in a h1 tag', () => { 38 | // const fixture = TestBed.createComponent(AppComponent); 39 | // fixture.detectChanges(); 40 | // const compiled = fixture.debugElement.nativeElement; 41 | // expect(compiled.querySelector('h1').textContent).toContain('Welcome to messenger!'); 42 | // }); 43 | }); 44 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { Component } from "@angular/core"; 14 | 15 | @Component({ 16 | selector: "app-root", 17 | templateUrl: "./app.component.html", 18 | styleUrls: ["./app.component.scss"], 19 | standalone: false 20 | }) 21 | export class AppComponent { 22 | protected title = "messenger"; 23 | } 24 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/camera/camera.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | Send Image to: {{ data.receiver.name }} 5 |
6 | @if (showCameraMsg) { 7 |
8 | Please enable your camera in the browser. 9 |
10 | } 11 | 12 | 13 | 14 | 22 | 30 | 31 |
32 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/camera/camera.component.scss: -------------------------------------------------------------------------------- 1 | .video { 2 | width: 100%; 3 | } 4 | 5 | .hide { 6 | display: none; 7 | } 8 | 9 | .container { 10 | margin: 10px; 11 | } 12 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/camera/camera.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing"; 2 | 3 | import { CameraComponent } from "./camera.component"; 4 | 5 | //describe('CameraComponent', () => { 6 | // let component: CameraComponent; 7 | // let fixture: ComponentFixture; 8 | // 9 | // beforeEach(async(() => { 10 | // TestBed.configureTestingModule({ 11 | // declarations: [ CameraComponent ] 12 | // }) 13 | // .compileComponents(); 14 | // })); 15 | // 16 | // beforeEach(() => { 17 | // fixture = TestBed.createComponent(CameraComponent); 18 | // component = fixture.componentInstance; 19 | // fixture.detectChanges(); 20 | // }); 21 | // 22 | // it('should create', () => { 23 | // expect(component).toBeTruthy(); 24 | // }); 25 | //}); 26 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/common/constants.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | /* eslint-disable @typescript-eslint/naming-convention */ 14 | 15 | export class Constants { 16 | static readonly IMAGE_TYPE = "image/jpeg"; 17 | static readonly IMAGE_PREFIX = "data:" + Constants.IMAGE_TYPE + ";base64,"; 18 | static readonly B64_IMAGE_PREFIX = "JPGBASE64"; 19 | } 20 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/common/messages.ts: -------------------------------------------------------------------------------- 1 | export interface Message { 2 | type: string; 3 | data: T; 4 | } 5 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/common/tuple.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | export class Tuple { 14 | private localA: A; 15 | private localB: B; 16 | 17 | constructor(a: A, b: B) { 18 | this.localA = a; 19 | this.localB = b; 20 | } 21 | 22 | get a(): A { 23 | return this.localA; 24 | } 25 | 26 | get b(): B { 27 | return this.localB; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/contacts/contacts.component.html: -------------------------------------------------------------------------------- 1 |
2 | @for (contact of contacts; track contact) { 3 |
4 | @if(!contact?.base64Avatar && contact?.name !== AiName.AiSam) { 5 | 14 | } @else { 15 | 20 | } 21 |
27 | {{ contact.name }} 28 |
29 |
30 | } 31 |
32 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/contacts/contacts.component.scss: -------------------------------------------------------------------------------- 1 | .contact-name { 2 | margin-left: 10px; 3 | height: min-content; 4 | } 5 | 6 | .con-selected { 7 | color: green; 8 | } 9 | 10 | .myrow { 11 | display: flex; 12 | align-items: center; 13 | margin: 5px 0 5px 0; 14 | } 15 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/contacts/contacts.component.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing"; 14 | 15 | import { ContactsComponent } from "./contacts.component"; 16 | 17 | //describe('ContactsComponent', () => { 18 | // let component: ContactsComponent; 19 | // let fixture: ComponentFixture; 20 | // 21 | // beforeEach(async(() => { 22 | // TestBed.configureTestingModule({ 23 | // declarations: [ ContactsComponent ] 24 | // }) 25 | // .compileComponents(); 26 | // })); 27 | // 28 | // beforeEach(() => { 29 | // fixture = TestBed.createComponent(ContactsComponent); 30 | // component = fixture.componentInstance; 31 | // fixture.detectChanges(); 32 | // }); 33 | // 34 | // it('should create', () => { 35 | // expect(component).toBeTruthy(); 36 | // }); 37 | //}); 38 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/contacts/contacts.component.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core"; 14 | import { Contact } from "../model/contact"; 15 | 16 | import { AiName } from "../model/aiFriend/ai-config"; 17 | 18 | @Component({ 19 | selector: "app-contacts", 20 | templateUrl: "./contacts.component.html", 21 | styleUrls: ["./contacts.component.scss"], 22 | imports: [] 23 | }) 24 | export class ContactsComponent implements OnInit { 25 | AiName = AiName; 26 | @Input() 27 | selectedContact: Contact; 28 | @Input() 29 | contacts: Contact[] = []; 30 | @Output() 31 | selContact = new EventEmitter(); 32 | 33 | constructor() {} 34 | 35 | ngOnInit() {} 36 | 37 | select(contact: Contact) { 38 | this.selContact.emit(contact); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/fileupload/fileupload.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | Send File to: {{ data.receiver.name }} 5 |
6 |
7 |
8 | 15 | 16 |
17 | @if (showFileSizeMsg) { 18 |
22 | File size too big. Limit 2 MB. 23 |
24 | } 25 |
26 |
27 |
28 | 31 |
32 |
33 | 36 |
37 |
38 |
39 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/fileupload/fileupload.component.scss: -------------------------------------------------------------------------------- 1 | .filesizemsg { 2 | color: red; 3 | } 4 | 5 | .buttons { 6 | display: flex; 7 | } 8 | 9 | .container { 10 | margin: 10px; 11 | } 12 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/fileupload/fileupload.component.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing"; 14 | 15 | import { FileuploadComponent } from "./fileupload.component"; 16 | 17 | /*describe('FileuploadComponent', () => { 18 | let component: FileuploadComponent; 19 | let fixture: ComponentFixture; 20 | 21 | beforeEach(async(() => { 22 | TestBed.configureTestingModule({ 23 | declarations: [ FileuploadComponent ] 24 | }) 25 | .compileComponents(); 26 | })); 27 | 28 | beforeEach(() => { 29 | fixture = TestBed.createComponent(FileuploadComponent); 30 | component = fixture.componentInstance; 31 | fixture.detectChanges(); 32 | }); 33 | 34 | it('should create', () => { 35 | expect(component).toBeTruthy(); 36 | }); 37 | });*/ 38 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/fileupload/fileupload.component.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { Component, OnInit, Inject } from "@angular/core"; 14 | import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material/dialog"; 15 | import { MainComponent } from "../main/main.component"; 16 | import { Contact } from "../model/contact"; 17 | import { Message } from "../model/message"; 18 | 19 | @Component({ 20 | selector: "app-fileupload", 21 | templateUrl: "./fileupload.component.html", 22 | styleUrls: ["./fileupload.component.scss"], 23 | standalone: false 24 | }) 25 | export class FileuploadComponent implements OnInit { 26 | protected currentFile: File; 27 | protected fileContent: string; 28 | protected showFileSizeMsg: boolean; 29 | // eslint-disable-next-line @typescript-eslint/naming-convention 30 | private readonly MB: number = 1024 * 1024; 31 | 32 | constructor( 33 | public dialogRef: MatDialogRef, 34 | @Inject(MAT_DIALOG_DATA) public data: any 35 | ) {} 36 | 37 | ngOnInit() { 38 | this.showFileSizeMsg = false; 39 | } 40 | 41 | filechange(fileInput: any) { 42 | this.currentFile = fileInput.target.files[0]; 43 | const reader = new FileReader(); 44 | reader.onload = () => { 45 | const textstr: string = reader.result as string; 46 | const textstrs = textstr.split(";"); 47 | this.fileContent = textstrs[1]; 48 | //console.log(textstrs[1]); 49 | }; 50 | reader.readAsDataURL(this.currentFile); 51 | } 52 | 53 | upload() { 54 | if (this.fileContent && this.fileContent.length < 2 * this.MB) { 55 | const receiver = this.data.receiver as Contact; 56 | const msg: Message = { 57 | fromId: null, 58 | toId: receiver.userId, 59 | text: this.fileContent, 60 | filename: this.currentFile.name, 61 | send: false, 62 | received: false, 63 | }; 64 | this.dialogRef.close(msg); 65 | } else { 66 | this.showFileSizeMsg = true; 67 | } 68 | } 69 | 70 | cancel() { 71 | this.dialogRef.close(null); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/games/bingo/bingo.component.html: -------------------------------------------------------------------------------- 1 |
2 |
Lets play Bingo
3 | @if (gameUuid && !bingoResult) { 4 |
8 | New Number: 9 |
10 | } 11 | @if (!gameUuid || bingoResult) { 12 |
13 | 21 |
22 | } 23 |
24 | {{ bingoNumber > 0 && !bingoResult ? bingoNumber : "-" }} 25 |
26 | @if (bingoResult) { 27 |
Won
28 | } 29 | @if (!bingoResult && bingoNumber <= 0) { 30 |
31 | } 32 | @if (!bingoResult && bingoNumber > 0) { 33 |
34 | 42 |
43 | } 44 |
45 | @for (bingoCell of bingoCells; track bingoCell) { 46 |
52 | {{ bingoCell.value }} 53 |
54 | } 55 |
56 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/games/bingo/bingo.component.scss: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | @media (max-width: 900px), (max-height: 480px) { 15 | .custom-toolbar { 16 | height: fit-content; 17 | overflow: hidden; 18 | } 19 | .icon-bar { 20 | justify-content: space-between; 21 | width: 60%; 22 | } 23 | } 24 | 25 | .container { 26 | display: grid; 27 | grid-template-columns: 20% 20% 20% 20% 20%; 28 | grid-template-rows: 40px auto; 29 | } 30 | 31 | .bingo-cell { 32 | display: flex; 33 | justify-content: center; 34 | align-items: center; 35 | font-size: 32px; 36 | } 37 | 38 | .bingo-cell-selected { 39 | background-color: #fcf638; 40 | border-radius: 50%; 41 | } 42 | 43 | .bingo-cell-bingo { 44 | background-color: #98fa98; 45 | border-radius: 50%; 46 | } 47 | 48 | .header-cell { 49 | font-size: 20px; 50 | } 51 | 52 | .game-won { 53 | font-size: 32px; 54 | color: #ff0000; 55 | } 56 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/games/bingo/bingo.component.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { ComponentFixture, TestBed } from "@angular/core/testing"; 14 | 15 | import { BingoComponent } from "./bingo.component"; 16 | /* 17 | describe('BingoComponent', () => { 18 | let component: BingoComponent; 19 | let fixture: ComponentFixture; 20 | 21 | beforeEach(() => { 22 | TestBed.configureTestingModule({ 23 | declarations: [BingoComponent] 24 | }); 25 | fixture = TestBed.createComponent(BingoComponent); 26 | component = fixture.componentInstance; 27 | fixture.detectChanges(); 28 | }); 29 | 30 | it('should create', () => { 31 | expect(component).toBeTruthy(); 32 | }); 33 | }); 34 | */ 35 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/games/games.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
Games
4 |
5 |
6 | 9 |
10 |
11 |
12 | 16 | 17 | 22 | hallo 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/games/games.component.scss: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | .toolbar-content { 15 | display: flex; 16 | align-items: center; 17 | justify-content: center; 18 | flex-wrap: wrap; 19 | width: 100%; 20 | } 21 | 22 | .example-fill-remaining-space { 23 | // This fills the remaining space, by using flexbox. 24 | // Every toolbar row uses a flexbox row layout. 25 | flex: 1 1 auto; 26 | } 27 | 28 | .contact-list { 29 | width: 300px; 30 | overflow-x: hidden; 31 | overflow-y: auto; 32 | } 33 | 34 | @media (max-width: 900px), (max-height: 480px) { 35 | .custom-toolbar { 36 | height: fit-content; 37 | overflow: hidden; 38 | } 39 | .icon-bar { 40 | justify-content: space-between; 41 | width: 60%; 42 | } 43 | } 44 | 45 | .container { 46 | } 47 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/games/games.component.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { ComponentFixture, TestBed } from "@angular/core/testing"; 14 | 15 | import { GamesComponent } from "./games.component"; 16 | /* 17 | describe('GamesComponent', () => { 18 | let component: GamesComponent; 19 | let fixture: ComponentFixture; 20 | 21 | beforeEach(() => { 22 | TestBed.configureTestingModule({ 23 | declarations: [GamesComponent] 24 | }); 25 | fixture = TestBed.createComponent(GamesComponent); 26 | component = fixture.componentInstance; 27 | fixture.detectChanges(); 28 | }); 29 | 30 | it('should create', () => { 31 | expect(component).toBeTruthy(); 32 | }); 33 | }); 34 | */ 35 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/games/games.routes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { Routes } from "@angular/router"; 14 | import { GamesComponent } from "./games.component"; 15 | import { BingoComponent } from "./bingo/bingo.component"; 16 | 17 | export const GAMES: Routes = [ 18 | { 19 | path: "", 20 | component: GamesComponent, 21 | children: [ 22 | { path: "**", redirectTo: "bingo" }, 23 | { path: "bingo", component: BingoComponent }, 24 | ], 25 | }, 26 | { path: "**", redirectTo: "" }, 27 | ]; 28 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/games/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | export * from "./games.routes"; 14 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/login/login.component.scss: -------------------------------------------------------------------------------- 1 | ul { 2 | list-style-type: none; 3 | } 4 | 5 | .error-text { 6 | color: red; 7 | } 8 | 9 | .space-below { 10 | margin-bottom: 10px; 11 | } 12 | 13 | .spacer-left { 14 | margin-left: 20px; 15 | } 16 | 17 | ::ng-deep { 18 | .cdk-overlay-backdrop-showing { 19 | backdrop-filter: blur(3px); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/login/login.component.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing"; 14 | 15 | import { LoginComponent } from "./login.component"; 16 | 17 | //describe('LoginComponent', () => { 18 | // let component: LoginComponent; 19 | // let fixture: ComponentFixture; 20 | // 21 | // beforeEach(async(() => { 22 | // TestBed.configureTestingModule({ 23 | // declarations: [ LoginComponent ] 24 | // }) 25 | // .compileComponents(); 26 | // })); 27 | // 28 | // beforeEach(() => { 29 | // fixture = TestBed.createComponent(LoginComponent); 30 | // component = fixture.componentInstance; 31 | // fixture.detectChanges(); 32 | // }); 33 | // 34 | // it('should create', () => { 35 | // expect(component).toBeTruthy(); 36 | // }); 37 | //}); 38 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/main/main.component.scss: -------------------------------------------------------------------------------- 1 | .icon { 2 | display: flex; 3 | align-items: center; 4 | justify-content: center; 5 | width: 100px; 6 | height: 100%; 7 | cursor: pointer; 8 | } 9 | .icon-container { 10 | width: 24px !important; 11 | } 12 | 13 | .container { 14 | } 15 | 16 | .contact-list { 17 | width: 300px; 18 | overflow-x: hidden; 19 | overflow-y: auto; 20 | } 21 | 22 | .popup { 23 | display: none; 24 | } 25 | 26 | .cell:hover { 27 | .popup { 28 | display: block; 29 | width: 160px; 30 | margin-top: 0px; 31 | margin-left: 100px; 32 | background: #ffffff; 33 | border-radius: 6px; 34 | padding: 8px 0; 35 | position: absolute; 36 | z-index: 1; 37 | color: blue; 38 | border: solid 1px black; 39 | } 40 | color: blue; 41 | cursor: pointer; 42 | } 43 | 44 | .example-container { 45 | display: flex; 46 | flex-direction: column; 47 | } 48 | 49 | .mat-mdc-table { 50 | overflow: auto; 51 | } 52 | 53 | .example-fill-remaining-space { 54 | // This fills the remaining space, by using flexbox. 55 | // Every toolbar row uses a flexbox row layout. 56 | flex: 1 1 auto; 57 | } 58 | 59 | .icon-bar { 60 | display: flex; 61 | } 62 | 63 | .toolbar-content { 64 | display: flex; 65 | align-items: center; 66 | justify-content: center; 67 | flex-wrap: wrap; 68 | width: 100%; 69 | } 70 | 71 | .icon-bar { 72 | display: flex; 73 | padding-top: 5px; 74 | } 75 | 76 | .login-message-container { 77 | display: flex; 78 | justify-content: center; 79 | align-items: center; 80 | height: 100%; 81 | width: 100%; 82 | margin: 0; 83 | } 84 | 85 | .login-message { 86 | height: fit-content; 87 | width: fit-content; 88 | } 89 | 90 | .login-logout { 91 | display: flex; 92 | margin-left: 20px; 93 | align-content: center; 94 | justify-content: center; 95 | } 96 | 97 | .people-button { 98 | display: flex; 99 | align-content: center; 100 | justify-content: center; 101 | height: 100%; 102 | max-height: 64px; 103 | } 104 | 105 | @media (max-width: 900px), (max-height: 480px) { 106 | .custom-toolbar { 107 | height: fit-content; 108 | overflow: hidden; 109 | } 110 | .icon-bar { 111 | justify-content: space-between; 112 | width: 60%; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/main/main.component.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing"; 14 | 15 | import { MainComponent } from "./main.component"; 16 | 17 | //describe('MainComponent', () => { 18 | // let component: MainComponent; 19 | // let fixture: ComponentFixture; 20 | // 21 | // beforeEach(async(() => { 22 | // TestBed.configureTestingModule({ 23 | // declarations: [ MainComponent ] 24 | // }) 25 | // .compileComponents(); 26 | // })); 27 | // 28 | // beforeEach(() => { 29 | // fixture = TestBed.createComponent(MainComponent); 30 | // component = fixture.componentInstance; 31 | // fixture.detectChanges(); 32 | // }); 33 | // 34 | // it('should create', () => { 35 | // expect(component).toBeTruthy(); 36 | // }); 37 | //}); 38 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/messages/messages.component.html: -------------------------------------------------------------------------------- 1 | @for (message of messages; track message) { 2 |
3 | @if (receiver !== null) { 4 |
8 | 9 | @if (!isImageMsg(message) && !message.filename) { 10 | {{ 11 | message.text 12 | }} 13 | } 14 | @if (isImageMsg(message)) { 15 | 16 | } 17 | @if (message.filename) { 18 | {{ 20 | message.filename 21 | }} 23 | } 24 | @if ( 25 | message.toId === receiver.userId && message.send && !message.received 26 | ) { 27 | done_alt 31 | } 32 | @if ( 33 | message.toId === receiver.userId && message.send && message.received 34 | ) { 35 | done_all_alt 39 | } 40 | 41 |
42 | } 43 |
44 | } 45 | @if (showSpinner) { 46 |
47 | 48 | Samantha is thinking. 49 |
50 | } 51 |
52 | 53 |
54 | 59 |
60 | send_alt 61 |
62 |
63 |
64 |
65 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/messages/messages.component.scss: -------------------------------------------------------------------------------- 1 | .receiver { 2 | text-align: right; 3 | background-color: #ddddff; 4 | border-radius: 10px; 5 | padding: 0 8px; 6 | } 7 | .sender { 8 | text-align: left; 9 | background-color: #ccffcc; 10 | border-radius: 10px; 11 | padding: 0 8px; 12 | } 13 | .message-input { 14 | width: 100%; 15 | overflow-x: hidden; 16 | } 17 | .myInput { 18 | display: flex; 19 | align-items: center; 20 | } 21 | .send-icon { 22 | padding: 10px; 23 | margin: 10px; 24 | border-radius: 50%; 25 | background-color: red; 26 | cursor: pointer; 27 | width: 20px; 28 | height: 20px; 29 | } 30 | .spinner { 31 | display: flex; 32 | justify-content: center; 33 | align-items: center; 34 | column-gap: 20px; 35 | background-color: #ffff00; 36 | border-radius: 20px; 37 | } 38 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/messages/messages.component.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing"; 14 | 15 | import { MessagesComponent } from "./messages.component"; 16 | 17 | //describe('MessagesComponent', () => { 18 | // let component: MessagesComponent; 19 | // let fixture: ComponentFixture; 20 | // 21 | // beforeEach(async(() => { 22 | // TestBed.configureTestingModule({ 23 | // declarations: [ MessagesComponent ] 24 | // }) 25 | // .compileComponents(); 26 | // })); 27 | // 28 | // beforeEach(() => { 29 | // fixture = TestBed.createComponent(MessagesComponent); 30 | // component = fixture.componentInstance; 31 | // fixture.detectChanges(); 32 | // }); 33 | // 34 | // it('should create', () => { 35 | // expect(component).toBeTruthy(); 36 | // }); 37 | //}); 38 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/messages/messages.component.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core"; 14 | import { Message } from "../model/message"; 15 | import { Contact } from "../model/contact"; 16 | import { FormGroup, FormBuilder, Validators } from "@angular/forms"; 17 | import { Constants } from "../common/constants"; 18 | 19 | @Component({ 20 | selector: "app-messages", 21 | templateUrl: "./messages.component.html", 22 | styleUrls: ["./messages.component.scss"], 23 | standalone: false 24 | }) 25 | export class MessagesComponent implements OnInit { 26 | @Input() 27 | messages: Message[]; 28 | @Input() 29 | receiver: Contact; 30 | @Input() 31 | showSpinner: boolean; 32 | @Output() 33 | sendMsg = new EventEmitter(); 34 | protected readonly formKeyMessage = "message"; 35 | protected messageForm: FormGroup; 36 | 37 | constructor(private fb: FormBuilder) { 38 | this.messageForm = fb.group({ 39 | [this.formKeyMessage]: ["", Validators.required], 40 | }); 41 | } 42 | 43 | ngOnInit(): void {} 44 | 45 | isImageMsg(msg: Message): boolean { 46 | if (msg.text.startsWith(Constants.B64_IMAGE_PREFIX, 0)) { 47 | msg.text = 48 | Constants.IMAGE_PREFIX + 49 | msg.text.substr(Constants.B64_IMAGE_PREFIX.length); 50 | } 51 | const result = msg.text.startsWith(Constants.IMAGE_PREFIX, 0); 52 | return result; 53 | } 54 | 55 | sendMessage() { 56 | if (this.messageForm.valid) { 57 | const msg: Message = { 58 | fromId: null, 59 | toId: this.receiver.userId, 60 | text: this.messageForm.controls.message.value, 61 | send: false, 62 | received: false, 63 | }; 64 | this.messageForm.reset(); 65 | this.sendMsg.emit(msg); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/model/aiFriend/ai-config.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | export enum AiName { 14 | AiSam = "Ai Samantha", 15 | } 16 | 17 | export const AiUserId = "-1"; 18 | 19 | export interface AiConfig { 20 | enabled: boolean; 21 | aiModel: string; 22 | } 23 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/model/aiFriend/ai-message.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | export enum MessageType { 14 | USER = "user", 15 | ASSISTANT = "assistant", 16 | SYSTEM = "system", 17 | FUNCTION = "function", 18 | } 19 | 20 | export interface AiMessage { 21 | content: string; 22 | properties: Map; 23 | messageType: MessageType; 24 | } 25 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/model/aiFriend/ai-result.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | export interface AiResultDto { 14 | result: AiResult; 15 | results: Array; 16 | metadata: AiMetadata; 17 | } 18 | 19 | export interface AiResults { 20 | metadata: ResultsMetadata; 21 | output: AiOutput; 22 | } 23 | 24 | export interface AiResult { 25 | metadata: AiMetadata; 26 | output: AiOutput; 27 | } 28 | 29 | export interface AiOutput { 30 | messageType: string; 31 | text: string; 32 | metadata: OutputMetadata; 33 | toolCalls: string[]; 34 | media: string[]; 35 | } 36 | 37 | export interface OutputMetadata { 38 | messageType: string; 39 | } 40 | 41 | export interface ResultsMetadata { 42 | finishReason: string; 43 | contentFilters: string[]; 44 | empty: boolean; 45 | } 46 | 47 | export interface ResultMetadata { 48 | contentFilterMetadata: unknown; 49 | finishReason: unknown; 50 | } 51 | 52 | export interface AiMetadata { 53 | id: string; 54 | model: string; 55 | rateLimit: RateLimit; 56 | usage: Usage; 57 | promptMetadata: string[]; 58 | empty: boolean; 59 | } 60 | 61 | export interface RateLimit { 62 | requestsLimit: number; 63 | requestsRemaining: number; 64 | requestsReset: string; 65 | tokensLimit: number; 66 | tokensRemaining: number; 67 | tokensReset: string; 68 | } 69 | 70 | export interface Usage { 71 | completionTokens: number; 72 | promptTokens: number; 73 | totalTokens: number; 74 | } 75 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/model/auth-check.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | export class AuthCheck { 14 | createdAt: Date; 15 | route: string; 16 | authorized: boolean; 17 | } 18 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/model/contact-update.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { Contact } from "./contact"; 14 | 15 | export interface ContactUpdate { 16 | userId: string; 17 | contacts: Contact[]; 18 | } 19 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/model/contact.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | export interface Contact { 14 | localId?: number; 15 | name: string; 16 | base64Avatar: string; 17 | publicKey: string; 18 | userId: string; 19 | } 20 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/model/games/bingo-game.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | export interface BingoGame { 15 | uuid: string; 16 | lastUpdate: string; 17 | bingoBoards: BingoBoard[]; 18 | playerUserIds: string[]; 19 | randomValues: number[]; 20 | } 21 | 22 | export interface BingoBoard { 23 | board: number[][]; 24 | hits: boolean[][]; 25 | } 26 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/model/jwt-token.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | export interface JwtToken { 14 | exp: number; 15 | iat: number; 16 | lastmsg: number; 17 | sub: string; 18 | auth: MyAuth[]; 19 | } 20 | 21 | export interface MyAuth { 22 | autority: string; 23 | } 24 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/model/local-contact.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { Contact } from "./contact"; 14 | 15 | export interface LocalContact extends Contact { 16 | ownerId: string; 17 | id?: number; 18 | } 19 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/model/local-message.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { Message } from "./message"; 14 | 15 | export interface LocalMessage extends Message { 16 | id?: number; 17 | } 18 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/model/local-user.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | export interface LocalUser { 14 | id?: number; 15 | createdAt: Date; 16 | username: string; 17 | hash: string; 18 | salt: string; 19 | email: string; 20 | base64Avatar: string; 21 | publicKey: string; 22 | privateKey: string; 23 | userId: string; 24 | } 25 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/model/message.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { SafeUrl } from "@angular/platform-browser"; 14 | 15 | export interface Message { 16 | localId?: number; 17 | fromId: string; 18 | toId: string; 19 | timestamp?: Date; 20 | text: string; 21 | filename?: string; 22 | send: boolean; 23 | received: boolean; 24 | url?: SafeUrl; 25 | } 26 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/model/my-user.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | export class MyUser { 15 | id?: number; 16 | createdAt: Date; 17 | username: string; 18 | password: string; 19 | email: string; 20 | token: string; 21 | base64Avatar: string; 22 | publicKey: string; 23 | privateKey: string; 24 | userId: string; 25 | salt: string; 26 | contacts?: string[]; 27 | } 28 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/model/private-key.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | export interface PrivateKey { 14 | key: string; 15 | salt: string; 16 | } 17 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/model/sync-msgs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { Message } from "./message"; 14 | 15 | export class SyncMsgs { 16 | lastUpdate?: Date; 17 | ownId: string; 18 | contactIds?: string[]; 19 | msgs?: Message[]; 20 | } 21 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/model/voice-msg.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | export interface VoiceMsg { 14 | type: VoiceMsgType; 15 | senderId: string; 16 | receiverId: string; 17 | data: any; 18 | } 19 | 20 | export enum VoiceMsgType { 21 | offer = "offer", 22 | answer = "answer", 23 | hangup = "hangup", 24 | iceCandidate = "ice-candidate", 25 | } 26 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/aiFriend/ai-friend.service.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { TestBed } from "@angular/core/testing"; 14 | 15 | import { AiFriendService } from "./ai-friend.service"; 16 | /* 17 | describe('AiFriendService', () => { 18 | let service: AiFriendService; 19 | 20 | beforeEach(() => { 21 | TestBed.configureTestingModule({}); 22 | service = TestBed.inject(AiFriendService); 23 | }); 24 | 25 | it('should be created', () => { 26 | expect(service).toBeTruthy(); 27 | }); 28 | }); 29 | */ 30 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/aiFriend/ai-friend.service.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { HttpClient } from "@angular/common/http"; 14 | import { Injectable } from "@angular/core"; 15 | import { Observable } from "rxjs"; 16 | import { AiConfig } from "src/app/model/aiFriend/ai-config"; 17 | import { AiMessage } from "src/app/model/aiFriend/ai-message"; 18 | import { AiResultDto } from "src/app/model/aiFriend/ai-result"; 19 | 20 | @Injectable({ 21 | providedIn: "root", 22 | }) 23 | export class AiFriendService { 24 | constructor(private http: HttpClient) {} 25 | 26 | public getAiConfig(): Observable { 27 | return this.http.get("/rest/aifriend/config"); 28 | } 29 | 30 | public postTalkToSam(aiMessage: AiMessage): Observable { 31 | return this.http.post("/rest/aifriend/talk", aiMessage); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/authentication.service.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { TestBed } from "@angular/core/testing"; 14 | 15 | import { AuthenticationService } from "./authentication.service"; 16 | 17 | //describe('AuthenticationService', () => { 18 | // beforeEach(() => TestBed.configureTestingModule({})); 19 | // 20 | // it('should be created', () => { 21 | // const service: AuthenticationService = TestBed.get(AuthenticationService); 22 | // expect(service).toBeTruthy(); 23 | // }); 24 | //}); 25 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/authentication.service.ts: -------------------------------------------------------------------------------- 1 | /** Copyright 2018 Sven Loesekann 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | Unless required by applicable law or agreed to in writing, software 7 | distributed under the License is distributed on an "AS IS" BASIS, 8 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | See the License for the specific language governing permissions and 10 | limitations under the License. 11 | */ 12 | import { Injectable } from "@angular/core"; 13 | import { HttpClient, HttpHeaders } from "@angular/common/http"; 14 | import { MyUser } from "../model/my-user"; 15 | import { AuthCheck } from "../model/auth-check"; 16 | import { Observable } from "rxjs"; 17 | import { JwtTokenService } from "./jwt-token.service"; 18 | 19 | @Injectable({ 20 | providedIn: "root", 21 | }) 22 | export class AuthenticationService { 23 | private reqOptionsArgs = { 24 | headers: new HttpHeaders().set("Content-Type", "application/json"), 25 | }; 26 | private readonly authUrl = "/rest/auth"; 27 | constructor( 28 | private http: HttpClient, 29 | private jwttokenService: JwtTokenService 30 | ) {} 31 | 32 | postLogin(user: MyUser): Observable { 33 | return this.http.post( 34 | this.authUrl + "/login", 35 | user, 36 | this.reqOptionsArgs 37 | ); 38 | } 39 | 40 | postSignin(user: MyUser): Observable { 41 | return this.http.post( 42 | this.authUrl + "/signin", 43 | user, 44 | this.reqOptionsArgs 45 | ); 46 | } 47 | 48 | postCheckAuthorisation(route: string): Observable { 49 | const authCheck = new AuthCheck(); 50 | authCheck.route = route; 51 | const myReqOptionsArgs = { 52 | headers: new HttpHeaders() 53 | .set("Content-Type", "application/json") 54 | .set("Authorization", this.jwttokenService.jwtToken), 55 | }; 56 | return this.http.post( 57 | this.authUrl + "/authorize", 58 | authCheck, 59 | myReqOptionsArgs 60 | ); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/contact.service.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { TestBed } from "@angular/core/testing"; 14 | 15 | import { ContactService } from "./contact.service"; 16 | 17 | //describe('ContactService', () => { 18 | // beforeEach(() => TestBed.configureTestingModule({})); 19 | // 20 | // it('should be created', () => { 21 | // const service: ContactService = TestBed.get(ContactService); 22 | // expect(service).toBeTruthy(); 23 | // }); 24 | //}); 25 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/contact.service.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { Injectable } from "@angular/core"; 14 | import { LocaldbService } from "./localdb.service"; 15 | import { HttpClient } from "@angular/common/http"; 16 | import { Contact } from "../model/contact"; 17 | import { from, Observable } from "rxjs"; 18 | import { ContactUpdate } from "../model/contact-update"; 19 | 20 | interface ContactsIdRequest { 21 | contactIds: string[]; 22 | } 23 | 24 | @Injectable({ 25 | providedIn: "root", 26 | }) 27 | export class ContactService { 28 | private readonly contactUrl = "/rest/contact"; 29 | private myOwnContact: Contact = null; 30 | 31 | constructor( 32 | private localdbService: LocaldbService, 33 | private http: HttpClient 34 | ) {} 35 | 36 | get ownContact() { 37 | return this.myOwnContact; 38 | } 39 | 40 | set ownContact(ownContact1: Contact) { 41 | this.myOwnContact = ownContact1; 42 | } 43 | 44 | loadContacts(contact: Contact): Observable { 45 | return from(this.localdbService.loadContacts(contact)); 46 | } 47 | 48 | loadContactsByIds(contactIds: string[]): Observable { 49 | return this.http.post(this.contactUrl + "/findcontactsbyIds", { 50 | contactIds: contactIds, 51 | } as ContactsIdRequest); 52 | } 53 | 54 | findContacts(conName: string): Observable { 55 | const con: Contact = { 56 | name: conName, 57 | base64Avatar: null, 58 | publicKey: null, 59 | userId: null, 60 | }; 61 | return this.http.post(this.contactUrl + "/findcontacts", con); 62 | } 63 | 64 | updateContacts(contactUpdate: ContactUpdate): Observable { 65 | return this.http.post( 66 | this.contactUrl + "/updatecontacts", 67 | contactUpdate 68 | ); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/games/bingo.service.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { TestBed } from "@angular/core/testing"; 14 | 15 | import { BingoService } from "./bingo.service"; 16 | 17 | /* 18 | describe('BingoService', () => { 19 | let service: BingoService; 20 | 21 | beforeEach(() => { 22 | TestBed.configureTestingModule({}); 23 | service = TestBed.inject(BingoService); 24 | }); 25 | 26 | it('should be created', () => { 27 | expect(service).toBeTruthy(); 28 | }); 29 | }); 30 | */ 31 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/games/bingo.service.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { HttpClient } from "@angular/common/http"; 14 | import { Injectable } from "@angular/core"; 15 | import { Observable } from "rxjs"; 16 | import { BingoGame } from "src/app/model/games/bingo-game"; 17 | 18 | @Injectable({ 19 | providedIn: "root", 20 | }) 21 | export class BingoService { 22 | private readonly baseUrl = "/rest/games/bingo"; 23 | 24 | constructor(private http: HttpClient) {} 25 | 26 | newGame(userIds: string[]): Observable { 27 | const bingoGame = { 28 | bingoBoards: [], 29 | lastUpdate: null, 30 | randomValues: [], 31 | uuid: null, 32 | playerUserIds: userIds, 33 | } as BingoGame; 34 | return this.http.post(this.baseUrl + "/newgame", bingoGame); 35 | } 36 | 37 | updateGame(gameUuid: string): Observable { 38 | return this.http.get(`${this.baseUrl}/updategame/${gameUuid}`); 39 | } 40 | 41 | checkWin(gameUuid: string, userUuid: string): Observable { 42 | return this.http.get( 43 | `${this.baseUrl}/checkwin/${gameUuid}/user/${userUuid}` 44 | ); 45 | } 46 | 47 | endGame(gameUuid: string): Observable { 48 | return this.http.get(`${this.baseUrl}/endgame/${gameUuid}`); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/games/games.service.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { TestBed } from "@angular/core/testing"; 14 | 15 | import { GamesService } from "./games.service"; 16 | /* 17 | describe('GamesService', () => { 18 | let service: GamesService; 19 | 20 | beforeEach(() => { 21 | TestBed.configureTestingModule({}); 22 | service = TestBed.inject(GamesService); 23 | }); 24 | 25 | it('should be created', () => { 26 | expect(service).toBeTruthy(); 27 | }); 28 | }); 29 | */ 30 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/games/games.service.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { Injectable } from "@angular/core"; 14 | import { Contact } from "src/app/model/contact"; 15 | import { MyUser } from "src/app/model/my-user"; 16 | 17 | @Injectable({ 18 | providedIn: "root", 19 | }) 20 | export class GamesService { 21 | public myUser: MyUser = null; 22 | public contacts: Contact[] = []; 23 | public selectedContact: Contact = null; 24 | public windowHeight: number = 0; 25 | constructor() {} 26 | } 27 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/http-profile.interceptor.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { Injectable } from "@angular/core"; 14 | import { HttpInterceptor, HttpRequest, HttpResponse, HttpHandler, HttpEvent, HttpErrorResponse } from "@angular/common/http"; 15 | import { Observable } from "rxjs"; 16 | import { finalize, tap } from "rxjs/operators"; 17 | 18 | @Injectable() 19 | export class HttpProfileInterceptor implements HttpInterceptor { 20 | intercept( 21 | request: HttpRequest, 22 | next: HttpHandler 23 | ): Observable> { 24 | const started = Date.now(); 25 | let ok: string; 26 | 27 | return next.handle(request).pipe( 28 | tap( 29 | (event: HttpEvent) => 30 | (ok = event instanceof HttpResponse ? "succeeded" : ""), 31 | (error: HttpErrorResponse) => (ok = "failed") 32 | ), 33 | finalize(() => { 34 | const elapsed = Date.now() - started; 35 | const msg = `${request.method} "${request.urlWithParams}" ${ok} in ${elapsed} ms.`; 36 | console.log(msg); 37 | }) 38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/jwt-token.service.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { TestBed } from "@angular/core/testing"; 14 | 15 | import { JwtTokenService } from "./jwt-token.service"; 16 | 17 | //describe('JwtTokenService', () => { 18 | // beforeEach(() => TestBed.configureTestingModule({})); 19 | // 20 | // it('should be created', () => { 21 | // const service: JwttokenService = TestBed.get(JwttokenService); 22 | // expect(service).toBeTruthy(); 23 | // }); 24 | //}); 25 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/jwt-token.service.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { Injectable } from "@angular/core"; 14 | import { JwtToken } from "../model/jwt-token"; 15 | 16 | @Injectable({ 17 | providedIn: "root", 18 | }) 19 | export class JwtTokenService { 20 | private localJwtToken: string = null; 21 | 22 | constructor() {} 23 | 24 | get jwtToken(): string { 25 | return this.localJwtToken === null ? "" : this.localJwtToken; 26 | } 27 | 28 | set jwtToken(token: string) { 29 | this.localJwtToken = !token ? null : token; 30 | } 31 | 32 | // eslint-disable-next-line @typescript-eslint/member-ordering 33 | get localLogin(): boolean { 34 | return this.localJwtToken ? false : true; 35 | } 36 | 37 | getExpiryDate(): Date { 38 | if (!this.localLogin) { 39 | const jwtToken = this.urlBase64Decode(this.localJwtToken); 40 | return new Date(jwtToken.exp * 1000); 41 | } else { 42 | return new Date("2000-01-01"); 43 | } 44 | } 45 | 46 | private urlBase64Decode(str: string): JwtToken { 47 | let output = str.replace(/-/g, "+").replace(/_/g, "/"); 48 | if (output) { 49 | if (output.length % 4 === 1) { 50 | throw new Error("Invalid Token"); 51 | } 52 | output += new Array(5 - (output.length % 4)).join("="); 53 | } 54 | const outputArr = output.split("."); 55 | return JSON.parse(atob(outputArr[1])) as JwtToken; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/localdb.service.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { TestBed } from "@angular/core/testing"; 14 | 15 | import { LocaldbService } from "./localdb.service"; 16 | 17 | //describe('LocaldbService', () => { 18 | // beforeEach(() => TestBed.configureTestingModule({})); 19 | // 20 | // it('should be created', () => { 21 | // const service: LocaldbService = TestBed.get(LocaldbService); 22 | // expect(service).toBeTruthy(); 23 | // }); 24 | //}); 25 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/message.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from "@angular/core/testing"; 2 | 3 | import { MessageService } from "./message.service"; 4 | 5 | //describe('MessageService', () => { 6 | // beforeEach(() => TestBed.configureTestingModule({})); 7 | // 8 | // it('should be created', () => { 9 | // const service: MessageService = TestBed.get(MessageService); 10 | // expect(service).toBeTruthy(); 11 | // }); 12 | //}); 13 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/message.service.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { Injectable } from "@angular/core"; 14 | import { HttpClient } from "@angular/common/http"; 15 | import { Contact } from "../model/contact"; 16 | import { Message } from "../model/message"; 17 | import { Observable } from "rxjs"; 18 | import { SyncMsgs } from "../model/sync-msgs"; 19 | 20 | @Injectable({ 21 | providedIn: "root", 22 | }) 23 | export class MessageService { 24 | private readonly contactUrl = "/rest/message"; 25 | 26 | constructor(private http: HttpClient) {} 27 | 28 | findMessages(syncMsgs: SyncMsgs): Observable { 29 | return this.http.post(this.contactUrl + "/findMsgs", syncMsgs); 30 | } 31 | 32 | sendMessages(syncMsgs: SyncMsgs): Observable { 33 | return this.http.post(this.contactUrl + "/storeMsgs", syncMsgs); 34 | } 35 | 36 | findReceivedMessages(contact: Contact): Observable { 37 | return this.http.post( 38 | this.contactUrl + "/receivedMsgs", 39 | contact 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/net-connection.service.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { TestBed } from "@angular/core/testing"; 14 | 15 | import { NetConnectionService } from "./net-connection.service"; 16 | 17 | //describe('NetConnectionService', () => { 18 | // beforeEach(() => TestBed.configureTestingModule({})); 19 | // 20 | // it('should be created', () => { 21 | // const service: NetConnectionService = TestBed.get(NetConnectionService); 22 | // expect(service).toBeTruthy(); 23 | // }); 24 | //}); 25 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/net-connection.service.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { Injectable } from "@angular/core"; 14 | import { Observable } from "rxjs"; 15 | 16 | @Injectable({ 17 | providedIn: "root", 18 | }) 19 | export class NetConnectionService { 20 | private localConnectionMonitor: Observable; 21 | private localCconnectionStatus: boolean; 22 | 23 | constructor() { 24 | this.localCconnectionStatus = navigator.onLine; 25 | this.localConnectionMonitor = new Observable((observer) => { 26 | window.addEventListener("offline", (e) => { 27 | this.localCconnectionStatus = false; 28 | observer.next(false); 29 | }); 30 | window.addEventListener("online", (e) => { 31 | this.localCconnectionStatus = true; 32 | observer.next(true); 33 | }); 34 | }); 35 | } 36 | 37 | get connectionMonitor(): Observable { 38 | return this.localConnectionMonitor; 39 | } 40 | 41 | get connetionStatus(): boolean { 42 | return this.localCconnectionStatus; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/token.interceptor.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { Injectable } from "@angular/core"; 14 | import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HttpErrorResponse } from "@angular/common/http"; 15 | import { Observable, of } from "rxjs"; 16 | import { tap } from "rxjs/operators"; 17 | import { UtilsService } from "./utils.service"; 18 | 19 | @Injectable() 20 | export class TokenInterceptor implements HttpInterceptor { 21 | constructor(private utilsService: UtilsService) {} 22 | 23 | intercept( 24 | req: HttpRequest, 25 | next: HttpHandler 26 | ): Observable> { 27 | req = req.clone({ 28 | headers: this.utilsService.createHeader(), 29 | }); 30 | return next.handle(req).pipe( 31 | tap( 32 | (event) => event, 33 | (event) => this.handleError(event) 34 | ) 35 | ); 36 | } 37 | 38 | private handleError(event: HttpEvent): HttpEvent { 39 | if (event instanceof HttpErrorResponse) { 40 | const error = event as HttpErrorResponse; 41 | console.log(`failed: ${error.message}`); 42 | } 43 | return event; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/translations.service.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { TestBed } from "@angular/core/testing"; 14 | 15 | import { TranslationsService } from "./translations.service"; 16 | 17 | /*describe('TranslationsService', () => { 18 | let service: TranslationsService; 19 | 20 | beforeEach(() => { 21 | TestBed.configureTestingModule({}); 22 | service = TestBed.inject(TranslationsService); 23 | }); 24 | 25 | it('should be created', () => { 26 | expect(service).toBeTruthy(); 27 | }); 28 | });*/ 29 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/translations.service.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | /* eslint-disable @typescript-eslint/naming-convention */ 14 | import { Injectable } from "@angular/core"; 15 | 16 | @Injectable({ 17 | providedIn: "root", 18 | }) 19 | export class TranslationsService { 20 | public static readonly ONLINE_AGAIN_MSG = "onlineAgainMsg"; 21 | public static readonly MAIN_COMPONENT = "main"; 22 | private translatonsMap = new Map(); 23 | 24 | constructor() { 25 | const str = $localize`:@@onlineAgainMsg:You are online again and your token is expired. To reconnect please logout and login again.`; 26 | this.translatonsMap.set( 27 | TranslationsService.MAIN_COMPONENT + 28 | "_" + 29 | TranslationsService.ONLINE_AGAIN_MSG, 30 | str 31 | ); 32 | } 33 | 34 | public getTranslation(componentKey: string, key: string): string { 35 | const result = this.translatonsMap.get(componentKey + "_" + key); 36 | return !!result ? result : this.translatonsMap.get(key); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/utils.service.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { HttpHeaders } from "@angular/common/http"; 14 | import { JwtTokenService } from "../services/jwt-token.service"; 15 | import { Injectable } from "@angular/core"; 16 | 17 | @Injectable({ 18 | providedIn: "root", 19 | }) 20 | export class UtilsService { 21 | constructor(private jwttokenService: JwtTokenService) {} 22 | 23 | createHeader() { 24 | return new HttpHeaders() 25 | .set("Content-Type", "application/json") 26 | .set("Authorization", `Bearer ${this.jwttokenService.jwtToken}`); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/voice.service.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { TestBed } from "@angular/core/testing"; 14 | 15 | import { VoiceService } from "./voice.service"; 16 | 17 | /*describe('VoiceService', () => { 18 | let service: VoiceService; 19 | 20 | beforeEach(() => { 21 | TestBed.configureTestingModule({}); 22 | service = TestBed.inject(VoiceService); 23 | }); 24 | 25 | it('should be created', () => { 26 | expect(service).toBeTruthy(); 27 | }); 28 | }); 29 | */ 30 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/services/webrtc.service.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { TestBed } from "@angular/core/testing"; 14 | 15 | import { WebrtcService } from "./webrtc.service"; 16 | /* 17 | describe('WebrtcService', () => { 18 | let service: WebrtcService; 19 | 20 | beforeEach(() => { 21 | TestBed.configureTestingModule({}); 22 | service = TestBed.inject(WebrtcService); 23 | }); 24 | 25 | it('should be created', () => { 26 | expect(service).toBeTruthy(); 27 | }); 28 | }); 29 | */ 30 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/voice/voice.component.scss: -------------------------------------------------------------------------------- 1 | @use "@angular/material" as mat; 2 | 3 | $called-palette: mat.$blue-palette; 4 | 5 | $caller-palette: mat.$green-palette; 6 | 7 | .landscape-orientation { 8 | visibility: visible; 9 | } 10 | 11 | .portrait-orientation { 12 | visibility: collapse; 13 | } 14 | 15 | .video-container { 16 | display: flex; 17 | align-items: flex-start; 18 | } 19 | 20 | .called { 21 | flex: 1 0 auto; 22 | position: relative; 23 | width: calc(100% - 200px); 24 | &:after { 25 | content: ""; 26 | display: block; 27 | padding-bottom: 100%; 28 | } 29 | } 30 | 31 | .called-content { 32 | display: flex; 33 | flex-direction: column; 34 | align-items: stretch; 35 | height: 100%; 36 | //@debug mat.get-color-from-palette($called-palette, 50); 37 | $theme: mat.define-theme(( 38 | color: ( 39 | theme-type: light, 40 | primary: $called-palette, 41 | ) 42 | )); 43 | background-color: mat.get-theme-color($theme, primary, 70); 44 | } 45 | 46 | .local { 47 | flex: 0 0 auto; 48 | height: fit-content; 49 | width: 200px; 50 | $theme: mat.define-theme(( 51 | color: ( 52 | theme-type: light, 53 | primary: $caller-palette, 54 | ) 55 | )); 56 | background-color: mat.get-theme-color($theme, primary, 70); 57 | } 58 | 59 | .video-button { 60 | //margin: 5px 0 5px 5px; 61 | margin-left: 5px; 62 | flex: 1 1 auto; 63 | } 64 | 65 | .call-video { 66 | width: calc(100% - 10px); 67 | margin: auto; 68 | padding: 5px; 69 | } 70 | 71 | .local-video { 72 | height: 150px; 73 | width: 200px; 74 | } 75 | 76 | @media (max-width: 900px) and (orientation: portrait), 77 | (max-height: 480px) and (orientation: portrait) { 78 | .video-container { 79 | flex-direction: column; 80 | } 81 | .called { 82 | margin-top: 5px; 83 | width: 100%; 84 | &:after { 85 | padding-bottom: 0; 86 | } 87 | } 88 | .local { 89 | margin-top: 5px; 90 | width: 100%; 91 | } 92 | } 93 | 94 | @media (max-width: 900px) and (orientation: landscape), 95 | (max-height: 480px) and (orientation: landscape) { 96 | .landscape-orientation { 97 | visibility: hidden; 98 | } 99 | .portrait-orientation { 100 | visibility: visible; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /frontend/src/angular/src/app/voice/voice.component.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { ComponentFixture, TestBed } from "@angular/core/testing"; 14 | 15 | import { VoiceComponent } from "./voice.component"; 16 | 17 | /*describe('PhoneCallComponent', () => { 18 | let component: PhoneCallComponent; 19 | let fixture: ComponentFixture; 20 | 21 | beforeEach(async () => { 22 | await TestBed.configureTestingModule({ 23 | declarations: [ PhoneCallComponent ] 24 | }) 25 | .compileComponents(); 26 | }); 27 | 28 | beforeEach(() => { 29 | fixture = TestBed.createComponent(PhoneCallComponent); 30 | component = fixture.componentInstance; 31 | fixture.detectChanges(); 32 | }); 33 | 34 | it('should create', () => { 35 | expect(component).toBeTruthy(); 36 | }); 37 | });*/ 38 | -------------------------------------------------------------------------------- /frontend/src/angular/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Angular2Guy/AngularPwaMessenger/09e31743a730756358cda21187f9c157f5beab3f/frontend/src/angular/src/assets/.gitkeep -------------------------------------------------------------------------------- /frontend/src/angular/src/assets/icons/icon-128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Angular2Guy/AngularPwaMessenger/09e31743a730756358cda21187f9c157f5beab3f/frontend/src/angular/src/assets/icons/icon-128x128.png -------------------------------------------------------------------------------- /frontend/src/angular/src/assets/icons/icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Angular2Guy/AngularPwaMessenger/09e31743a730756358cda21187f9c157f5beab3f/frontend/src/angular/src/assets/icons/icon-144x144.png -------------------------------------------------------------------------------- /frontend/src/angular/src/assets/icons/icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Angular2Guy/AngularPwaMessenger/09e31743a730756358cda21187f9c157f5beab3f/frontend/src/angular/src/assets/icons/icon-152x152.png -------------------------------------------------------------------------------- /frontend/src/angular/src/assets/icons/icon-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Angular2Guy/AngularPwaMessenger/09e31743a730756358cda21187f9c157f5beab3f/frontend/src/angular/src/assets/icons/icon-192x192.png -------------------------------------------------------------------------------- /frontend/src/angular/src/assets/icons/icon-384x384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Angular2Guy/AngularPwaMessenger/09e31743a730756358cda21187f9c157f5beab3f/frontend/src/angular/src/assets/icons/icon-384x384.png -------------------------------------------------------------------------------- /frontend/src/angular/src/assets/icons/icon-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Angular2Guy/AngularPwaMessenger/09e31743a730756358cda21187f9c157f5beab3f/frontend/src/angular/src/assets/icons/icon-512x512.png -------------------------------------------------------------------------------- /frontend/src/angular/src/assets/icons/icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Angular2Guy/AngularPwaMessenger/09e31743a730756358cda21187f9c157f5beab3f/frontend/src/angular/src/assets/icons/icon-72x72.png -------------------------------------------------------------------------------- /frontend/src/angular/src/assets/icons/icon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Angular2Guy/AngularPwaMessenger/09e31743a730756358cda21187f9c157f5beab3f/frontend/src/angular/src/assets/icons/icon-96x96.png -------------------------------------------------------------------------------- /frontend/src/angular/src/assets/icons/smiley-640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Angular2Guy/AngularPwaMessenger/09e31743a730756358cda21187f9c157f5beab3f/frontend/src/angular/src/assets/icons/smiley-640.jpg -------------------------------------------------------------------------------- /frontend/src/angular/src/assets/icons/smiling-face-with-sunglasses.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /frontend/src/angular/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true, 3 | wsPath: "ws://localhost:8080/signalingsocket", 4 | wssPath: "wss://REPLACEME/signalingsocket", 5 | // eslint-disable-next-line @typescript-eslint/naming-convention 6 | RTCPeerConfiguration: { 7 | iceServers: [ 8 | { 9 | urls: "stun:stun1.l.google.com:19302", 10 | }, 11 | ], 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /frontend/src/angular/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false, 7 | wsPath: "ws://localhost:4200/signalingsocket", 8 | // for Angular Cli development with generated ssl certificate(helm directory) 9 | wssPath: "wss://REPLACEME/signalingsocket", 10 | // eslint-disable-next-line @typescript-eslint/naming-convention 11 | RTCPeerConfiguration: { 12 | iceServers: [ 13 | { 14 | urls: "stun:stun1.l.google.com:19302", 15 | // urls: 'stun:stun.t-online.de:3478' 16 | }, 17 | { 18 | urls: "turn:openrelay.metered.ca:80", 19 | username: "openrelayproject", 20 | credential: "openrelayproject", 21 | }, 22 | { 23 | urls: "turn:openrelay.metered.ca:443", 24 | username: "openrelayproject", 25 | credential: "openrelayproject", 26 | }, 27 | ], 28 | }, 29 | }; 30 | 31 | /* 32 | * For easier debugging in development mode, you can import the following file 33 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 34 | * 35 | * This import should be commented out in production mode because it will have a negative impact 36 | * on performance if an error is thrown. 37 | */ 38 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 39 | -------------------------------------------------------------------------------- /frontend/src/angular/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Angular2Guy/AngularPwaMessenger/09e31743a730756358cda21187f9c157f5beab3f/frontend/src/angular/src/favicon.ico -------------------------------------------------------------------------------- /frontend/src/angular/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Messenger 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /frontend/src/angular/src/main.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Sven Loesekann 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | import { enableProdMode } from "@angular/core"; 14 | import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; 15 | 16 | import { AppModule } from "./app/app.module"; 17 | import { environment } from "./environments/environment"; 18 | 19 | if (environment.production) { 20 | enableProdMode(); 21 | } 22 | 23 | platformBrowserDynamic() 24 | .bootstrapModule(AppModule) 25 | .catch((err) => console.error(err)); 26 | -------------------------------------------------------------------------------- /frontend/src/angular/src/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "messenger", 3 | "short_name": "messenger", 4 | "theme_color": "#1976d2", 5 | "background_color": "#fafafa", 6 | "display": "standalone", 7 | "scope": "/en/", 8 | "start_url": "/en/index.html", 9 | "icons": [ 10 | { 11 | "src": "assets/icons/icon-72x72.png", 12 | "sizes": "72x72", 13 | "type": "image/png" 14 | }, 15 | { 16 | "src": "assets/icons/icon-96x96.png", 17 | "sizes": "96x96", 18 | "type": "image/png" 19 | }, 20 | { 21 | "src": "assets/icons/icon-128x128.png", 22 | "sizes": "128x128", 23 | "type": "image/png" 24 | }, 25 | { 26 | "src": "assets/icons/icon-144x144.png", 27 | "sizes": "144x144", 28 | "type": "image/png" 29 | }, 30 | { 31 | "src": "assets/icons/icon-152x152.png", 32 | "sizes": "152x152", 33 | "type": "image/png" 34 | }, 35 | { 36 | "src": "assets/icons/icon-192x192.png", 37 | "sizes": "192x192", 38 | "type": "image/png" 39 | }, 40 | { 41 | "src": "assets/icons/icon-384x384.png", 42 | "sizes": "384x384", 43 | "type": "image/png" 44 | }, 45 | { 46 | "src": "assets/icons/icon-512x512.png", 47 | "sizes": "512x512", 48 | "type": "image/png" 49 | } 50 | ] 51 | } 52 | -------------------------------------------------------------------------------- /frontend/src/angular/src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | 3 | @use "material-icons/iconfont/material-icons.scss"; 4 | -------------------------------------------------------------------------------- /frontend/src/angular/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import "zone.js/testing"; 4 | import { getTestBed } from "@angular/core/testing"; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting, 8 | } from "@angular/platform-browser-dynamic/testing"; 9 | 10 | // First, initialize the Angular testing environment. 11 | getTestBed().initTestEnvironment( 12 | BrowserDynamicTestingModule, 13 | platformBrowserDynamicTesting(), 14 | { 15 | teardown: { destroyAfterEach: false }, 16 | } 17 | ); 18 | -------------------------------------------------------------------------------- /frontend/src/angular/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/app", 5 | "types": [] 6 | }, 7 | "files": [ 8 | "src/main.ts", 9 | "src/polyfills.ts" 10 | ], 11 | "include": [ 12 | "src/**/*.d.ts" 13 | ] 14 | } -------------------------------------------------------------------------------- /frontend/src/angular/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "forceConsistentCasingInFileNames": true, 7 | "esModuleInterop": true, 8 | "noImplicitReturns": true, 9 | "noFallthroughCasesInSwitch": true, 10 | "sourceMap": true, 11 | "declaration": false, 12 | "experimentalDecorators": true, 13 | "module": "esnext", 14 | "moduleResolution": "bundler", 15 | "importHelpers": true, 16 | "target": "ES2022", 17 | "typeRoots": [ 18 | "node_modules/@types" 19 | ], 20 | "lib": [ 21 | "es2018", 22 | "dom" 23 | ], 24 | "useDefineForClassFields": false 25 | }, 26 | "angularCompilerOptions": { 27 | "strictTemplates": true, 28 | "fullTemplateTypeCheck": true, 29 | "strictInjectionParameters": true, 30 | "noImplicitAny": false 31 | } 32 | } -------------------------------------------------------------------------------- /frontend/src/angular/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } -------------------------------------------------------------------------------- /helm/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj -------------------------------------------------------------------------------- /helm/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | appVersion: "1.0" 3 | description: AngularPwaMessenger Config 4 | name: angularpwamessenger 5 | version: 0.1.0 6 | icon: "https://angular.io/assets/images/logos/angular/angular.png" -------------------------------------------------------------------------------- /helm/addIngress.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | minikube addons enable ingress 3 | 4 | # minikube setup 5 | #openssl genrsa -out rootCa.key 4096 6 | #openssl req -x509 -new -key rootCa.key -sha256 -nodes -keyout rootCa.key -out rootCa.pem -days 3650 -subj "/C=ry/ST=te/L=ty/O=on/OU=it/CN=minikube" 7 | #openssl genrsa -out ca.key 4096 8 | #openssl req -new -key ca.key -out ca.csr -subj "/C=ry/ST=te/L=ty/O=on/OU=it/CN=minikube" 9 | #openssl x509 -req -in ca.csr -CA rootCa.pem -CAkey rootCa.key -CAcreateserial -out ca.crt -days 3650 -sha256 -extfile cert.conf 10 | kubectl create secret tls minikube-tls --cert=ca.crt --key=ca.key 11 | kubectl create -f ./ingress.yaml 12 | 13 | # local test cert 14 | #openssl genrsa -out rootCa.key 4096 15 | #openssl req -x509 -new -key rootCa.key -sha256 -nodes -keyout rootCa.key -out rootCa.pem -days 3650 -subj "/C=ry/ST=te/L=ty/O=on/OU=it/CN=hostname.domain.com" 16 | #openssl genrsa -out ca.key 4096 17 | #openssl req -new -key ca.key -sha256 -nodes -out ca.csr -subj "/CN=hostname.domain.com" 18 | #openssl x509 -req -in ca.csr -CA rootCa.pem -CAkey rootCa.key -CAcreateserial -out ca.crt -days 3650 -sha256 -extfile cert.local.conf 19 | #openssl genrsa -out server.key 4096 20 | #openssl req -new -key server.key -out server.csr -config server.local.conf 21 | #openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 3650 -extensions v3_ext -extfile server.local.conf 22 | #openssl pkcs12 -export -in server.crt -inkey server.key -out server.p12 -name tomcat //password for this file(change for non test use!!!): apwamessenger 23 | #keytool -list -v -keystore server.p12 //check keystore 24 | # copy server.p12 to testCert/server.p12 -------------------------------------------------------------------------------- /helm/ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIF8jCCA9qgAwIBAgIUIZwBHerP0a73RODOFcCDhsDq8NgwDQYJKoZIhvcNAQEL 3 | BQAwVDELMAkGA1UEBhMCcnkxCzAJBgNVBAgMAnRlMQswCQYDVQQHDAJ0eTELMAkG 4 | A1UECgwCb24xCzAJBgNVBAsMAml0MREwDwYDVQQDDAhtaW5pa3ViZTAeFw0yMjA3 5 | MTIxMjExMzBaFw0zMjA3MDkxMjExMzBaMFQxCzAJBgNVBAYTAnJ5MQswCQYDVQQI 6 | DAJ0ZTELMAkGA1UEBwwCdHkxCzAJBgNVBAoMAm9uMQswCQYDVQQLDAJpdDERMA8G 7 | A1UEAwwIbWluaWt1YmUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDa 8 | jY6s7psfBSedjJSV2du+KyOZqvURtapx8a75lm+QeezaHwNlQr9KpzmV3twG6Je5 9 | /kDnXvespa8yf4ERowgQUnifgGNuIkaXjuQZaYakWBuKGjIA34nVVeIiYyd0RbN4 10 | UUPhq93XtSyMXPhxkJkOkcwuJG/9rPaEVlWaS141yKU4lk/pV3RUnPJtRKArUxUu 11 | FqaDddoH3vDlpA6QF6kpihSUHf2EUWnJuF8M0vTdPopYbsR6y1b95gc0YNKBMEGh 12 | yrWcGNAqXFj8l8mm7P/F0PIoAlYDr/h5GMom6HWZNVAUHTXcWzSFTCVL50ChR/06 13 | YAjzBq2PdXyEuQfCctwDOtvhfMpfD5WVU/OUYJquCr/JRpfEh1qOPod4N1QF/wYz 14 | hWpD6z8aR+8v4SMcV1gIHNhpljPfzCz9QAuy6TsthnpLAL2qiXGZJSF/gX+YAa3N 15 | T0gTSv7rCKjk6uRKY+BSfO8u+AUJ9kORVCGricJMNhQCQbu44zQT2LkjauiiyqQw 16 | rQRuD6GIPXmJf041v3CwGRHWqETKOHtGZ7E4OeTqqLZjZikI2TwzDQvtM34hRs/0 17 | UrkFgBM9Hry2elcbYA4M2J229f2pa/aKfXN1yN4ZNw066WYZlvC0CPYDfCM5wBrl 18 | /QB1le2PIdEt0gEEiShAjtl6HsIFVc31RCFhpjAekwIDAQABo4G7MIG4MB8GA1Ud 19 | IwQYMBaAFDPhh80/Q2brOODFpmzw/WM4pHbsMAkGA1UdEwQCMAAwCwYDVR0PBAQD 20 | AgTwMH0GA1UdEQR2MHSCCG1pbmlrdWJlghBtaW5pa3ViZS5kZWZhdWx0ghRtaW5p 21 | a3ViZS5kZWZhdWx0LnN2Y4IcbWluaWt1YmUuZGVmYXVsdC5zdmMuY2x1c3RlcoIi 22 | bWluaWt1YmUuZGVmYXVsdC5zdmMuY2x1c3Rlci5sb2NhbDANBgkqhkiG9w0BAQsF 23 | AAOCAgEAkgGOJxJhgWNd2a/n5zlkC9Aus8GC1kelcZt8qStrVi6UXu43sdStSxnr 24 | 1qKzTpqCTjXULNrI82Um+JKzEroRwT2ajJ+U3R+V4eGq3c/AQ12tJvNPLXEZL5N1 25 | J5vd3vvFBetcpWo5iAvXcVlYj6CJhwpnVnNV9OhB3cIQ75qJnJklthDjwgDz0E6h 26 | lsIL8rSVjRouFidaVfsoTRAorV6fj2gQdxG2T/EOd1kJ3dUqeO/Y0fd0Yiv4upIY 27 | +LILwLQJ7utojqDYwe8X4+0Uuxp7e0P8paBwDKcjpErq4TGMhsFhU7h72t0fZ7PY 28 | hmqNVXAwNzI6QTMV+GpnpKfmi0cyj8X5j4JRvzNzC0Fsko/K0dX3CKbD86DIef7k 29 | hZLYP9ctUjtPR5T1jVdIvzDIimUDFD1qCKSdnuWH0vrmHMzbvx2Cc0YLscYrbxN1 30 | 4cXLwLmzfCBucBV1XjY7ZJQygrvAUvlVR1rXUypfNI5omixU7WDQSNnRCZzVk4S+ 31 | W5D62QIn2qsxQ0uhJ+IrkEsMuAynXPGTFAJ5CJRoArfRBsin2G2AYLgxQTLuPI+b 32 | grl5hFf4hlUC82yk9ulnYnY8SCIrIj7tzhn08zrYcRcd3XfONR/jtNOWPjJqyroK 33 | oLKwTJqpV+6r5fIG4m1mWp3Ptxay0O/tzMc9dctTh3usMk3Ww+0= 34 | -----END CERTIFICATE----- 35 | -------------------------------------------------------------------------------- /helm/ca.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIIEmTCCAoECAQAwVDELMAkGA1UEBhMCcnkxCzAJBgNVBAgMAnRlMQswCQYDVQQH 3 | DAJ0eTELMAkGA1UECgwCb24xCzAJBgNVBAsMAml0MREwDwYDVQQDDAhtaW5pa3Vi 4 | ZTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANqNjqzumx8FJ52MlJXZ 5 | 274rI5mq9RG1qnHxrvmWb5B57NofA2VCv0qnOZXe3Abol7n+QOde96ylrzJ/gRGj 6 | CBBSeJ+AY24iRpeO5BlphqRYG4oaMgDfidVV4iJjJ3RFs3hRQ+Gr3de1LIxc+HGQ 7 | mQ6RzC4kb/2s9oRWVZpLXjXIpTiWT+lXdFSc8m1EoCtTFS4WpoN12gfe8OWkDpAX 8 | qSmKFJQd/YRRacm4XwzS9N0+ilhuxHrLVv3mBzRg0oEwQaHKtZwY0CpcWPyXyabs 9 | /8XQ8igCVgOv+HkYyibodZk1UBQdNdxbNIVMJUvnQKFH/TpgCPMGrY91fIS5B8Jy 10 | 3AM62+F8yl8PlZVT85Rgmq4Kv8lGl8SHWo4+h3g3VAX/BjOFakPrPxpH7y/hIxxX 11 | WAgc2GmWM9/MLP1AC7LpOy2GeksAvaqJcZklIX+Bf5gBrc1PSBNK/usIqOTq5Epj 12 | 4FJ87y74BQn2Q5FUIauJwkw2FAJBu7jjNBPYuSNq6KLKpDCtBG4PoYg9eYl/TjW/ 13 | cLAZEdaoRMo4e0ZnsTg55OqotmNmKQjZPDMNC+0zfiFGz/RSuQWAEz0evLZ6Vxtg 14 | DgzYnbb1/alr9op9c3XI3hk3DTrpZhmW8LQI9gN8IznAGuX9AHWV7Y8h0S3SAQSJ 15 | KECO2XoewgVVzfVEIWGmMB6TAgMBAAGgADANBgkqhkiG9w0BAQsFAAOCAgEAoCEs 16 | 2AGnZd4fq+iceyaM0WMhP5z5qAL2sJ1HbS6hY7O3LvgmBDgF7vXJHWCY/RKEUftZ 17 | GvLtxAWn0WdaWbQA8YmfthabGBLYF+T2KL44LRorOhQTqg0UNFq1l8oTiq5uKW9/ 18 | QnBuPdRlNpyCUmuAomK5wFwmcnMm6JxKTbszZztstyD4i2kRs+pUqC8X09KSWXlH 19 | Nj5g5ZRMfhLinCRpFYxR1VGYv8HmNOCASUvf0Vnaeg6yrPIQrKMCW8W/7UAgC/rh 20 | 588oAE/ubNsMbLvd5luMIN6rdAHRTAOC9FP+puMUbn9GvUHN8WRFP0erwwsB24cU 21 | gl8jetnPZ0qdzYgRf7L+gilt4zORULEgDp2e1z7nTBKCzNDTzGxT2FObb+D3LnuM 22 | x5ra/7gHlfbE5xxXwWeG6Ll2AG2Ndyj48AfqyTlAEhel7dzuk7IZRrGTaWNVfv8U 23 | SE9fkeOVap1j+SpRaHUbJnNsJu45OkPWWHNfsWImQVj1t8N1kddISD4yaG4j9c8K 24 | beVRMvuqI0Z3Jml3c/r1yRQJ5Ig5ykmN8Lw2a1LwD9ZpSDSTWgWo9b5nl3oYskML 25 | UilOFuhkc1bUOWdDLtexgG8s4R2jhtSSpVQKen8irp1PKTpLJN9UXnJb5AZnw+RP 26 | +OejQsr/L1s2eLFABuRNAyc6qwfzNDcVo4tuQjs= 27 | -----END CERTIFICATE REQUEST----- 28 | -------------------------------------------------------------------------------- /helm/ca.srl: -------------------------------------------------------------------------------- 1 | D827F040908FA3A6 2 | -------------------------------------------------------------------------------- /helm/cert.conf: -------------------------------------------------------------------------------- 1 | authorityKeyIdentifier=keyid,issuer 2 | basicConstraints=CA:FALSE 3 | keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment 4 | subjectAltName = @alt_names 5 | [alt_names] 6 | DNS.1 = minikube 7 | DNS.2 = minikube.default 8 | DNS.3 = minikube.default.svc 9 | DNS.4 = minikube.default.svc.cluster 10 | DNS.5 = minikube.default.svc.cluster.local 11 | -------------------------------------------------------------------------------- /helm/cert.local.conf: -------------------------------------------------------------------------------- 1 | authorityKeyIdentifier=keyid,issuer 2 | basicConstraints=CA:FALSE 3 | keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment 4 | subjectAltName = @alt_names 5 | [alt_names] 6 | DNS.1 = host 7 | DNS.2 = host.domain 8 | DNS.3 = host.domain.com 9 | -------------------------------------------------------------------------------- /helm/helm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | helm delete messenger 3 | helm install messenger ./ --set serviceType=NodePort -------------------------------------------------------------------------------- /helm/ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1 2 | kind: Ingress 3 | metadata: 4 | name: angularpwa-ingress 5 | annotations: 6 | kubernetes.io/ingress.class: nginx 7 | nginx.ingress.kubernetes.io/ssl-redirect: "true" 8 | spec: 9 | tls: 10 | - secretName: minikube-tls 11 | hosts: 12 | - minikube 13 | rules: 14 | - host: minikube 15 | http: 16 | paths: 17 | - backend: 18 | service: 19 | name: angularpwa 20 | port: 21 | number: 8080 22 | path: / 23 | pathType: Prefix -------------------------------------------------------------------------------- /helm/rootCa.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIFiTCCA3GgAwIBAgIURwpd8yLbFCXWDxQD2b5DLaxsYLYwDQYJKoZIhvcNAQEL 3 | BQAwVDELMAkGA1UEBhMCcnkxCzAJBgNVBAgMAnRlMQswCQYDVQQHDAJ0eTELMAkG 4 | A1UECgwCb24xCzAJBgNVBAsMAml0MREwDwYDVQQDDAhtaW5pa3ViZTAeFw0yMjA3 5 | MTIxMjEwNTBaFw0zMjA3MDkxMjEwNTBaMFQxCzAJBgNVBAYTAnJ5MQswCQYDVQQI 6 | DAJ0ZTELMAkGA1UEBwwCdHkxCzAJBgNVBAoMAm9uMQswCQYDVQQLDAJpdDERMA8G 7 | A1UEAwwIbWluaWt1YmUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC1 8 | ILdFVq0cLSirPUuwcjb3kozkGiZHf0pahF9mJoaJj7TaCuMYNthjWGzdDObGMl2d 9 | O+D9zt8TDzKQ6Fil6aigpaVICdjyXjd7kIAGfouokfY/Zpj2LSBuA1BvZe4Dp3/0 10 | tXlicpa+9/45Ctn+YA6fwryrNUM76H58xTv/RXiuSNlIM4ZUcUiLrX0KYUdTnNoD 11 | pLmO51+/n50+FjxFmSgsD4nb3I2jClY2dGFLFXpcSVhRrPU/9SCa1zC4KW6jBgZ2 12 | QSKnThaeLMyBObooqE+UpGeYOW8Ra8LJlsnk7cbV5u87OvhZ4q2EH/v3McB0MP2+ 13 | ilDEbE0d16RiahzcVnYqL0RJuaIz4GP5whwcwNCscGQIl7iqk9iYy4nLuzkz1Xk2 14 | 6BPkrUmDiGnLONdAhUb/eZ3cMwXyGrdh+8iwiY4KP1G+0snrd6rWKMxFJPe2m1xV 15 | hkvG3gw8XEuUukjuZMs3ShOR234P+oiUuJyOUlLZ18+58oqKSyHIPKNToRpTSoQI 16 | LhQH+4r679CdtbgWHFDFFeQ0cZ6Fta96R53LmsZIprLZzO6+XeC21ZQmcXTJBhzl 17 | PdEUmDJDazP5tcSG+R9ylD5GiOMA44bhIH7omHtHMgJitmkj/Bmr0Svi+UQ5VOfp 18 | 9pyiZ6zy3dZnqryxO4LZWi9QoDtsBNhmcZRWC3z2TQIDAQABo1MwUTAdBgNVHQ4E 19 | FgQUM+GHzT9DZus44MWmbPD9YzikduwwHwYDVR0jBBgwFoAUM+GHzT9DZus44MWm 20 | bPD9YzikduwwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEALdG0 21 | XZe8H6pWSL8da0333cOP2lh8rV/SoIIQp4d/K2khBHrJXos8LkHGyHsYX66jnBHq 22 | xyR+GV50dpiPZnXEH0zfgxPeJG3JAes7Jj3F46SJTd4PppxRegC16nt/wGxogxE/ 23 | T+R5Y0SXIVhP8BybX+NkyzGeOzTHuaYiK9GdCrRM8kzRcf7hFlV9AgQtrJxsSZfm 24 | ZZ8zbl1Sl9dvjkbDeQNoue5ATS2iTROULtFqVLR4gFiiZEUUxs6zyGMh7xrRyU/n 25 | WIj3PySBlJehxLKEuo5YITvmg/tNSH2nV/BZ6iZUEBwkxkcZ+0iTbrJrVnfDeUy8 26 | Z8w2QtfwqRxyC9vjR9z9iGhc4Y7Hm6A4IEhNvKTCJCYzwWH3r2VlSMkqIcpCxWNN 27 | i44fd8YEeWlBHPqxbw+sgBQ+8alY/GHHdfqem0H9wKE6Z9wl/RzxkaAjWXLyaRcl 28 | XuURrqMaPZVWl3Z+68GdQe6PLpHMjbNUy0XSBhe5rd6qFSvvnBTECl2Ro3UsxqOR 29 | W/6F/ddKaPgYSYFTPUmr1B+OmdSm+dO8nhS//Xg8tpS2U1EzRL7YYL4Zc8Ccc+2F 30 | xbr6KNWwE9OQGDb3o5Ooanpv58mbeM/pAAH/dun+pnQjwibsBcCNnzE7fn8cEvzd 31 | d/p3sfuokk6zwzQ2+eAgbGe4wCQz9xhdlA6yK+U= 32 | -----END CERTIFICATE----- 33 | -------------------------------------------------------------------------------- /helm/rootCa.srl: -------------------------------------------------------------------------------- 1 | 219C011DEACFD1AEF744E0CE15C08386C0EAF0D8 2 | -------------------------------------------------------------------------------- /helm/server.conf: -------------------------------------------------------------------------------- 1 | [ req ] 2 | default_bits = 4096 3 | prompt = no 4 | default_md = sha256 5 | req_extensions = req_ext 6 | distinguished_name = dn 7 | x509_extensions = v3_ext 8 | 9 | [ dn ] 10 | C = ry 11 | ST = te 12 | L = ty 13 | O = on 14 | OU = it 15 | CN = minikube 16 | 17 | [ req_ext ] 18 | subjectAltName = @alt_names 19 | 20 | [ alt_names ] 21 | DNS.1 = minikube 22 | DNS.2 = minikube.default 23 | DNS.3 = minikube.default.svc 24 | DNS.4 = minikube.default.svc.cluster 25 | DNS.5 = minikube.default.svc.cluster.local 26 | IP.1 = 192.168.49.2 27 | IP.2 = 192.168.49.2 28 | 29 | [ v3_ext ] 30 | authorityKeyIdentifier=keyid,issuer:always 31 | basicConstraints=CA:FALSE 32 | keyUsage = nonRepudiation, digitalSignature, keyEncipherment 33 | extendedKeyUsage=serverAuth,clientAuth 34 | subjectAltName=@alt_names -------------------------------------------------------------------------------- /helm/server.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIID+jCCAuKgAwIBAgIJANgn8ECQj6OfMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNV 3 | BAMMCG1pbmlrdWJlMB4XDTE5MDQxOTIyMTg0MFoXDTI5MDQxNjIyMTg0MFowVDEL 4 | MAkGA1UEBhMCcnkxCzAJBgNVBAgMAnRlMQswCQYDVQQHDAJ0eTELMAkGA1UECgwC 5 | b24xCzAJBgNVBAsMAml0MREwDwYDVQQDDAhtaW5pa3ViZTCCASIwDQYJKoZIhvcN 6 | AQEBBQADggEPADCCAQoCggEBAJq7IVJaWyWzRxGjIi1YUo1vCAxdfG5JGWUTkPeZ 7 | 5YKQc/3uAgERPSG8A8T+xb+aGKgsups5civFnEPLfrbJvH/pftNNXcKqebfo0oMA 8 | sAoIvUHqJ0FrEDZrkk6S/BeDEKnFkT3uKCljLB76mUXdw1Sv7NlqfT5mOvSVIk0j 9 | okr7slaTGPcQqLNsGIMH3QLgNhx44+MYmzzVKwrrvLxBGyY/ys1c7sv8n2nWbP+D 10 | cdb9vRBqw9UeKo5pEXzPnbgp9SkKArth/clMJjIldLNycqk6s6KbUc9Yff9Y+7Rd 11 | 4vnyhLzTVSSXvFxgffkylDSN4pPKEQmcm6cN9ub6rqJcznkCAwEAAaOCAQ4wggEK 12 | MEMGA1UdIwQ8MDqAFN7lZ5FAVrXZQsuIY4cKd5ttN1+BoRekFTATMREwDwYDVQQD 13 | DAhtaW5pa3ViZYIJAIcjzzKMWX87MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgQwMB0G 14 | A1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjCBiwYDVR0RBIGDMIGAgghtaW5p 15 | a3ViZYIQbWluaWt1YmUuZGVmYXVsdIIUbWluaWt1YmUuZGVmYXVsdC5zdmOCHG1p 16 | bmlrdWJlLmRlZmF1bHQuc3ZjLmNsdXN0ZXKCIm1pbmlrdWJlLmRlZmF1bHQuc3Zj 17 | LmNsdXN0ZXIubG9jYWyHBMCoY2SHBMCoY2QwDQYJKoZIhvcNAQELBQADggEBABK6 18 | zjd9eMOg/lYRzrXm8hDqp3fyRuwpxAPvEweU+l4N7Slfq/+EEjdzMn7kkeRMVC5K 19 | aD1q4B/LjRSx+Q35K019SeJPAH0UkPWgdUsKhNjz37j2AxDAT+oYhBoohOfcmH54 20 | EVhBww688xEvRDKcoNARM7BeZae4R0vXGODubuRDBKd2tC6SZL6SF89NE/RkAd9o 21 | RTbnjtFCgIKogqO6hUXqQwVqii5ik+Vq8qtD3tA1Sv22osHc+RDEEn7+6QAZSljP 22 | OzS5nNMIamCWa72qBEZQXZ5SrEDSKiykEh5gqcAPt1Ru/36A1h0vUFuXl4IwMqs/ 23 | apbdLGN3RXK4QJAMWAE= 24 | -----END CERTIFICATE----- 25 | -------------------------------------------------------------------------------- /helm/server.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIIFPDCCAyQCAQAwVDELMAkGA1UEBhMCcnkxCzAJBgNVBAgMAnRlMQswCQYDVQQH 3 | DAJ0eTELMAkGA1UECgwCb24xCzAJBgNVBAsMAml0MREwDwYDVQQDDAhtaW5pa3Vi 4 | ZTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAM9S06MDN8GF4HgSM5X3 5 | 3i7G82BQ8sj466YPUutwaRFbN8E+trmd/VyZHW+Qza4B2Q030ARFc2v+/laWbTnj 6 | a9TrP2W6qBNRBOW/sfGcXwKI9fNEnGXDktBHF0Py2ujGiiiOh5loBMzV569WufRm 7 | ZFGCd8f4rvKjkmr2gK0dL++tjMuhbIETCVYSLzvKKKe3ynpMOC5Lnu3oawIjzcMw 8 | eT/yeal+AqEa0fypyAbkJogNsGZIOe9+jwi6nZSrid6IvhWbq7F27g2kE8Bw5o8Q 9 | k4CeR4Fnuvz3RMAam1gChPEH2h79HDxKuLvTDqCh+dv7OKj5QsrPxKi1UQaPUmPA 10 | Olr+7sjRjcr15JNrMNM2z2glJ/bi6cq2PxuU5Rd/w/REJdQUynkVir7ctLPHjQvc 11 | W0DkRN+AVnel2cJld96x7gCe9rc8SGnIXmHBmaTKCKmHcnbWY6eNm7EhUZ4kDa4N 12 | 2i9jkFdS3qlbQXeC/Hx7MEneeGdjoaSe9YQ7CLcCNFCMVWpTtzYqFAhCPEPEJ2Ek 13 | dPIGleE87WjSANY9foHmctl1fwoCpxZZvuWd8AqrXRw0Eo7C/9FMJ3TIJRcQtseK 14 | 6HdxYSHQCXSQnGOnrPT0Du0puOZzUbwhHWjqKPGetu9GQeg4+8/903VAtK/xITdq 15 | 6uHWs7jfjBEqBlFoXg/u3lfBAgMBAAGggaIwgZ8GCSqGSIb3DQEJDjGBkTCBjjCB 16 | iwYDVR0RBIGDMIGAgghtaW5pa3ViZYIQbWluaWt1YmUuZGVmYXVsdIIUbWluaWt1 17 | YmUuZGVmYXVsdC5zdmOCHG1pbmlrdWJlLmRlZmF1bHQuc3ZjLmNsdXN0ZXKCIm1p 18 | bmlrdWJlLmRlZmF1bHQuc3ZjLmNsdXN0ZXIubG9jYWyHBMCoMQKHBMCoMQIwDQYJ 19 | KoZIhvcNAQELBQADggIBAME9dJSpvR8Yw9fUAbdDtvIPt+HXaBxSOfhYUJF4P50V 20 | m/tnZ/SibslSSQcEANPLco6Q0TOhNAHhTxLLkIcuv8MuKyLsxxYSTqd6P71oGest 21 | v4zBiVwHnvsYHqU8GNO4IyhJP0o7s7z2ncPK0kFihKBg4UG+fiYFOisIEBLsyJX/ 22 | 9tYYunaaSdjmp5BMfHH7je99AiR3fXXxDo1aZov+a++h/9QBfWg1yTXVlLaSTVrW 23 | GVSL9ZibjITJk3MkngIcAAvc4CpDw5yhvOeTCGCMHF5b3PWDDsKl/6TpfF0w0877 24 | bKwOsEmZxzcCccYcuknVeGFCFs2P+oVzpyOrtEuPJTix8oKxuU7LaT84a6TSesr+ 25 | 7Zk1ePtdFX1h88nH5lYAHTwu0f7psL4kdVqrn6mQg6vmcCdU9uZrN5/Lbem+C+40 26 | jrKy8GgVxuga4/ph4RyE+zomcLZwPBW9qDAUHWnKjy70xRFrqCIgb3GKxTYcGkin 27 | 6fD0wAqYWylEG+UmXZu0a+8pIqMTg1u1U3Q3x1JVP9uKOJBHUjCo21qN7W+une73 28 | J5U85N/0vlxpZpXzU0lQ4EZwqLNxfpICXGOJd/IBabXy3dz+te+5sJ0HED46btlK 29 | /HOyQICZ0xTT9rzZmqbDwdgHcLFvh8qgid1dIiK8oEa9KoiYRlnevfjn9sp++OLf 30 | -----END CERTIFICATE REQUEST----- 31 | -------------------------------------------------------------------------------- /helm/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEowIBAAKCAQEAmrshUlpbJbNHEaMiLVhSjW8IDF18bkkZZROQ95nlgpBz/e4C 3 | ARE9IbwDxP7Fv5oYqCy6mzlyK8WcQ8t+tsm8f+l+001dwqp5t+jSgwCwCgi9Qeon 4 | QWsQNmuSTpL8F4MQqcWRPe4oKWMsHvqZRd3DVK/s2Wp9PmY69JUiTSOiSvuyVpMY 5 | 9xCos2wYgwfdAuA2HHjj4xibPNUrCuu8vEEbJj/KzVzuy/yfadZs/4Nx1v29EGrD 6 | 1R4qjmkRfM+duCn1KQoCu2H9yUwmMiV0s3JyqTqzoptRz1h9/1j7tF3i+fKEvNNV 7 | JJe8XGB9+TKUNI3ik8oRCZybpw325vquolzOeQIDAQABAoIBAEaOwLIqC9hUOTs8 8 | tbARz4s5L2VcGAq+gLsLwhZ2cicosgwARZ+w+bxxXRKuzwQBQ+8kfm+cMYjuUsTD 9 | fePieHenxTKb2/6R+HE51Qzx+lSJCayOFxqItNrsEMqN0jDyjl2sfv/LozrEQ3FY 10 | +x3V82Wh15KJMdWLjqTLgNnGPxKLoJGcNTIEqSvpISGu2OdgkAsP6T+QLRgr0E/+ 11 | HsB6MEQsSPVrM6udfLbkZyDDJuEjlrD2QtH53ZMsRX9/DG/Z8aQPkBYCwfbHOdwq 12 | 8NwB9DKdhigPjxKaner/T8ucy6JaTQiXhd4OENGe2aXPS7cIV8dsmi6Hh3vsnzFR 13 | AxlEMlECgYEAyECPe8ulYEBDQyaGU0uernsEl+shUeAQDb4q31tLyuKqpRz61wrr 14 | HyfQcmM8MVJir6gpQRhvIEIQuO4YW8mAo6gh+BdRoq6ytbqW0dBDkgtYgMpL+pta 15 | oXgyhtnkuat9RPENF86f7FLc5+qyDX4/cskrCe0/i6Ttly3ho+qAoTUCgYEAxc5k 16 | 75UyBDuHOUUsBFAdg5c1pCCpAwf5aCKyxo2oM/vla2/ycvoVXI0E6HLiWqsDKsRy 17 | CAZN2jC2QnnTrA81p1qJaxuxGavAYl0dd+cgCf65/a/WU0Cweo9YmJVkADRoqYVF 18 | IFfLDjRdZVgAEm6fyo1TtXT5dquDVE4LbToOBLUCgYAb97BSaNm6/J6oRTwja/9I 19 | fRPiJ8uqhLGZScLxGO4X8tpEXyzFVdgKrOPW5fclKE1yHPlOBxyWE8QEH/S09QqL 20 | UNMVtCQJpX5+FQY1XXHidsUwj5BW+tWIkaH05X+lUscXFtduSMRbHCOQHF4rtkMk 21 | Q+ZH56OlXC52m8jUvM6kNQKBgEwgQIxL+PHUDxilXGlUg+dO3GAMCb+W5A+FuxPb 22 | FK7c9NBCRyakxG/X/dmPzTljs1ZUQCaCdpfQQ3SV+javq9B6cYR9Jc1hYir49wxc 23 | MOJn3CCb+XoU3VZtsIUYiWHiyZzkI1RtNUKEOKV2FqEBXhHQDjU5jYB0RZi+aHti 24 | 6l45AoGBAIHXjKAns4Y7XHZXC+1JVqxmIylp2eG+tUNNZJcxt/YpCpa8EF8ccVfo 25 | OHpQZb+WNwrGBne736K/qd00A+/+xeS2iuY+MxAYF28D2jBdm5JYFnVt802Un1B5 26 | LKaZT9zf9ZuiAZs04CSf3Y01F4sZCuAgnVJV1b/Gg5Bc0cO1If4L 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /helm/server.local.conf: -------------------------------------------------------------------------------- 1 | [ req ] 2 | default_bits = 4096 3 | prompt = no 4 | default_md = sha256 5 | req_extensions = req_ext 6 | distinguished_name = dn 7 | x509_extensions = v3_ext 8 | 9 | [ dn ] 10 | C = ry 11 | ST = te 12 | L = ty 13 | O = on 14 | OU = it 15 | CN = host.domain.com 16 | 17 | [ req_ext ] 18 | subjectAltName = @alt_names 19 | 20 | [ alt_names ] 21 | DNS.1 = host 22 | DNS.2 = host.domain 23 | DNS.3 = host.domain.com 24 | IP.1 = 192.168.1.50 25 | IP.2 = 192.168.1.50 26 | 27 | [ v3_ext ] 28 | authorityKeyIdentifier=keyid,issuer:always 29 | basicConstraints=CA:FALSE 30 | keyUsage = nonRepudiation, digitalSignature, keyEncipherment 31 | extendedKeyUsage=serverAuth,clientAuth 32 | subjectAltName=@alt_names -------------------------------------------------------------------------------- /helm/server.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Angular2Guy/AngularPwaMessenger/09e31743a730756358cda21187f9c157f5beab3f/helm/server.p12 -------------------------------------------------------------------------------- /helm/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* vim: set filetype=mustache: */}} 2 | {{/* 3 | Expand the name of the chart. 4 | */}} 5 | {{- define "helm-chart.name" -}} 6 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} 7 | {{- end -}} 8 | 9 | {{/* 10 | Create a default fully qualified app name. 11 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 12 | If release name contains chart name it will be used as a full name. 13 | */}} 14 | {{- define "helm-chart.fullname" -}} 15 | {{- if .Values.fullnameOverride -}} 16 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} 17 | {{- else -}} 18 | {{- $name := default .Chart.Name .Values.nameOverride -}} 19 | {{- if contains $name .Release.Name -}} 20 | {{- .Release.Name | trunc 63 | trimSuffix "-" -}} 21 | {{- else -}} 22 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} 23 | {{- end -}} 24 | {{- end -}} 25 | {{- end -}} 26 | 27 | {{/* 28 | Create chart name and version as used by the chart label. 29 | */}} 30 | {{- define "helm-chart.chart" -}} 31 | {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} 32 | {{- end -}} 33 | 34 | Create envApp values 35 | */}} 36 | {{- define "helpers.list-envApp-variables"}} 37 | {{- $secretName := .Values.secret.name -}} 38 | {{- range $key, $val := .Values.envApp.secret }} 39 | - name: {{ $key }} 40 | valueFrom: 41 | secretKeyRef: 42 | name: {{ $secretName }} 43 | key: {{ $key }} 44 | {{- end}} 45 | {{- range $key, $val := .Values.envApp.normal }} 46 | - name: {{ $key }} 47 | value: {{ $val | quote }} 48 | {{- end}} 49 | {{- end }} -------------------------------------------------------------------------------- /helm/values.yaml: -------------------------------------------------------------------------------- 1 | webAppName: angularpwamsg 2 | dbName: mongodbserver 3 | webImageName: angular2guy/angularpwamessenger 4 | webImageVersion: latest 5 | dbImageName: mongo 6 | dbImageVersion: 4.4 7 | volumeClaimName: mongo-pv-claim 8 | persistentVolumeName: task-pv-volume 9 | webServiceName: angularpwa 10 | dbServiceName: mongodb 11 | #for production use replace the jwtTokenSecrect value with a random alphanumeric string of the same length or longer 12 | jwtTokenSecrect: secret-key1234567890abcdefghijklmnopqrstuvpxyz 13 | 14 | secret: 15 | name: app-env-secret 16 | 17 | envApp: 18 | normal: 19 | MONGODB_HOST: mongodb 20 | SHUTDOWN_PHASE: 10s 21 | secret: 22 | JWTTOKEN_SECRET: secret-key1234567890abcdefghijklmnopqrstuvwxyz -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 12 | 4.0.0 13 | 14 | org.springframework.boot 15 | spring-boot-starter-parent 16 | 3.5.0 17 | 18 | 19 | ch.xxx 20 | messenger 21 | 0.0.1-SNAPSHOT 22 | AngularPwaMessenger 23 | Demo project for Spring Boot 24 | pom 25 | 26 | 27 | UTF-8 28 | UTF-8 29 | AngularPwaMessenger 30 | 24 31 | angular2guy 32 | 33 | test 34 | 35 | 36 | 37 | 38 | Apache License, Version 2.0 39 | repo 40 | http://www.apache.org/licenses/LICENSE-2.0.html 41 | 42 | 43 | 44 | 45 | frontend 46 | backend 47 | 48 | 49 | -------------------------------------------------------------------------------- /prometheus-local.yml: -------------------------------------------------------------------------------- 1 | global: 2 | scrape_interval: 15s 3 | 4 | scrape_configs: 5 | - job_name: 'prometheus' 6 | scrape_interval: 5s 7 | 8 | static_configs: 9 | - targets: ['localhost:9090'] 10 | 11 | - job_name: 'spring-actuator' 12 | metrics_path: '/actuator/prometheus' 13 | scrape_interval: 5s 14 | static_configs: 15 | - targets: ['localhost:8080'] -------------------------------------------------------------------------------- /runGrafana.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #docker pull grafana/grafana 3 | MYID=`id -u` 4 | #data will be stored in ~/tmp/data 5 | #mkdir ~/tmp/data 6 | MYDATA=echo ~/tmp/data 7 | docker run --user "$MYID" --volume "$MYID:$MYDATA" --network "host" grafana/grafana -------------------------------------------------------------------------------- /runMongoDBDocker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | docker pull mongo:6.0 3 | docker run --name local-mongo -p 27017:27017 --cpus=2.0 --memory=3g mongo:4.4 --wiredTigerCacheSizeGB 2.0 4 | #docker run --name local-mongo -p 27017:27017 --cpus=1.0 --memory=2g -v :/data/db mongo:6.0 --wiredTigerCacheSizeGB 1.0 5 | #docker start local-mongo 6 | #docker stop local-mongo 7 | #docker exec -it local-mongo bash -------------------------------------------------------------------------------- /runOllama.sh: -------------------------------------------------------------------------------- 1 | docker pull ollama/ollama:latest 2 | #docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama 3 | docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama 4 | docker start ollama 5 | docker stop ollama 6 | docker exec -it ollama ollama run samantha-mistral:7b 7 | #docker exec -it ollama bash -------------------------------------------------------------------------------- /runPrometheus.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #docker pull prom/prometheus 3 | LOCALDIR=pwd 4 | docker run --network "host" -v "$LOCALDIR/prometheus-local.yml:/etc/prometheus/prometheus.yml" prom/prometheus -------------------------------------------------------------------------------- /runStructurizr.sh: -------------------------------------------------------------------------------- 1 | docker pull structurizr/lite 2 | docker run -it --rm -p 8080:8080 -v ~/git/AngularPwaMessenger/structurizr:/usr/local/structurizr structurizr/lite -------------------------------------------------------------------------------- /structurizr/.gitignore: -------------------------------------------------------------------------------- 1 | /workspace.json 2 | .structurizr/ --------------------------------------------------------------------------------