Skip to content

Solution for #34 A user receives emails for his tasks #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ the PostgreSQL docker container. Run `./gradlew bootRun` for a dev server. The s

Run `./gradlew test` to execute the tests.

When any problem occurs during database synchronization, Flyway commands should be executed

`flyway -url=jdbc:postgresql://localhost:5432/tiny_task -user=tiny_task -password=demo123 -locations=\tiny-tasks\src\main\resources\db\migration repair`

`flyway -url=jdbc:postgresql://localhost:5432/tiny_task -user=tiny_task -password=demo123 -locations=\tiny-tasks\src\main\resources\db\migration migrate`

## Let's go

As you can see, there's a lot to do. Just pick one of the [issues](https://github.com/mindsmash/tiny-tasks/issues) and
Expand Down
8 changes: 6 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@
"src/main/webapp/assets"
],
"styles": [
"src/main/webapp/styles.scss"
"src/main/webapp/styles.scss",
"node_modules/bootstrap/dist/css/bootstrap.min.css"
],
"scripts": []
"scripts": [
"node_modules/bootstrap/dist/js/bootstrap.min.js",
]
},
"configurations": {
"production": {
Expand Down Expand Up @@ -100,6 +103,7 @@
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"codeCoverage": true,
"main": "src/main/webapp/test.ts",
"polyfills": "src/main/webapp/polyfills.ts",
"tsConfig": "src/main/webapp/tsconfig.spec.json",
Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ test {
}

dependencies {
implementation 'org.freemarker:freemarker:2.3.31'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.flywaydb:flyway-core'
implementation 'org.modelmapper:modelmapper:3.2.0'
implementation 'org.postgresql:postgresql'
testImplementation 'org.projectlombok:lombok:1.18.26'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
Expand Down
27 changes: 27 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { defineConfig } from "cypress";

export default defineConfig({
projectId: "sgxb9c",
videosFolder: "src/main/cypress/videos",
screenshotsFolder: "src/main/cypress/screenshots",
fixturesFolder: "src/main/cypress/fixtures",

e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require("./src/main/cypress/plugins/index.ts")(on, config);
},
specPattern: "src/main/cypress/integration/**/*.cy.{js,jsx,ts,tsx}",
supportFile: "src/main/cypress/support/index.ts",
baseUrl: "http://localhost:4200",
},

component: {
devServer: {
framework: "angular",
bundler: "webpack",
},
specPattern: "**/*.cy.ts",
},
});
9 changes: 0 additions & 9 deletions cypress.json

This file was deleted.

5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
37 changes: 37 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
12 changes: 12 additions & 0 deletions cypress/support/component-index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Components App</title>
</head>
<body>
<div data-cy-root></div>
</body>
</html>
39 changes: 39 additions & 0 deletions cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// ***********************************************************
// This example support/component.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')

import { mount } from 'cypress/angular'

// Augment the Cypress namespace to include type definitions for
// your custom command.
// Alternatively, can be defined in cypress/support/component.d.ts
// with a <reference path="./component" /> at the top of your spec.
declare global {
namespace Cypress {
interface Chainable {
mount: typeof mount
}
}
}

Cypress.Commands.add('mount', mount)

// Example use:
// cy.mount(MyComponent)
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"@angular/platform-browser": "~17.3.9",
"@angular/platform-browser-dynamic": "~17.3.9",
"@angular/router": "~17.3.9",
"@ng-bootstrap/ng-bootstrap": "^16.0.0",
"@popperjs/core": "^2.11.8",
"bootstrap": "^5.3.2",
"ng-bootstrap": "^1.1.16",
"ngx-bootstrap": "^12.0.0",
"rxjs": "~7.8.1",
"tslib": "^2.3.0",
"uuid": "^9.0.1",
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/coyoapp/tinytask/TinyTaskApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@SpringBootApplication(scanBasePackages = {"com.coyoapp.tinytask"})
public class TinyTaskApplication {

public static void main(String[] args) {
SpringApplication.run(TinyTaskApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.coyoapp.tinytask.configuration;

import freemarker.template.TemplateExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FreeMarkerConfig {
@Bean
public freemarker.template.Configuration freemarkerConfiguration() {
freemarker.template.Configuration configuration = new freemarker.template.Configuration(freemarker.template.Configuration.VERSION_2_3_31);
configuration.setClassForTemplateLoading(this.getClass(), "/templates");
configuration.setDefaultEncoding("UTF-8");
configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
return configuration;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
import org.modelmapper.ModelMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@EnableWebMvc
@EnableScheduling
public class WebConfig implements WebMvcConfigurer {

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:4200")
.allowedMethods("POST", "GET", "DELETE")
.allowedMethods("POST", "PUT", "GET", "DELETE")
.maxAge(3600);
}

Expand Down
34 changes: 34 additions & 0 deletions src/main/java/com/coyoapp/tinytask/domain/NotificationSetting.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.coyoapp.tinytask.domain;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDate;

@Table(name = "notification_setting")
@Entity
@Setter
@Getter
@EntityListeners(AuditingEntityListener.class)
public class NotificationSetting {
@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "id", nullable = false, updatable = false)
private String id;

private String duration;

private String email;

private boolean isActive;

private boolean isOnlyDueDate;

private Integer dayBeforeDueDate;

private LocalDate requestedNotificationDate;
}
4 changes: 4 additions & 0 deletions src/main/java/com/coyoapp/tinytask/domain/Task.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.coyoapp.tinytask.domain;

import java.time.Instant;
import java.time.LocalDate;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
Expand Down Expand Up @@ -30,4 +32,6 @@ public class Task {

@CreatedDate
private Instant created;

private LocalDate dueDate;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.coyoapp.tinytask.dto;

import jakarta.validation.constraints.NotEmpty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class NotificationSettingModel {
@NotEmpty
private String duration;

@NotEmpty
private String email;

@NotEmpty
private boolean isActive;

@NotEmpty
private boolean isOnlyDueDate;

@NotEmpty
private Integer dayBeforeDueDate;

@NotEmpty
private LocalDate requestedNotificationDate;
}
3 changes: 3 additions & 0 deletions src/main/java/com/coyoapp/tinytask/dto/TaskRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;

@Data
@Builder
@NoArgsConstructor
Expand All @@ -15,4 +17,5 @@ public class TaskRequest {
@NotEmpty
private String name;

private LocalDate dueDate;
}
4 changes: 4 additions & 0 deletions src/main/java/com/coyoapp/tinytask/dto/TaskResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;

@Data
@Builder
@NoArgsConstructor
Expand All @@ -15,4 +17,6 @@ public class TaskResponse {

private String name;

private LocalDate dueDate;

}
18 changes: 18 additions & 0 deletions src/main/java/com/coyoapp/tinytask/enums/Duration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.coyoapp.tinytask.enums;

public enum Duration {
EVERY_24H(1),
EVERY_48H(2),
EVERY_72H(3),
ONCE_A_WEEK(7);

private final int day;

Duration(int day) {
this.day = day;
}

public long getDurationInDay() {
return day;
}
}
Loading