From 86913d5c2f00d08b385cab944d9e50e506e8764e Mon Sep 17 00:00:00 2001 From: Chad Elliott Date: Fri, 27 Sep 2024 14:53:46 -0500 Subject: [PATCH 1/3] Moved description from earned_certificate to certificate and renamed certificate_image_url to validation_url. --- .../services/certification/Certification.java | 17 +++-- .../CertificationController.java | 2 + .../certification/CertificationDTO.java | 9 ++- .../certification/EarnedCertification.java | 22 ++----- .../EarnedCertificationController.java | 6 +- .../certification/EarnedCertificationDTO.java | 13 ++-- .../EarnedCertificationRepository.java | 8 +-- .../common/V106__add_certificate_tables.sql | 4 +- .../resources/db/dev/R__Load_testing_data.sql | 20 +++--- .../EarnedCertificationsTable.css | 8 +++ .../EarnedCertificationsTable.jsx | 65 ++++++++++--------- web-ui/src/pages/ProfilePage.jsx | 4 +- 12 files changed, 93 insertions(+), 85 deletions(-) diff --git a/server/src/main/java/com/objectcomputing/checkins/services/certification/Certification.java b/server/src/main/java/com/objectcomputing/checkins/services/certification/Certification.java index e52af0cd8..a8c082586 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/certification/Certification.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/certification/Certification.java @@ -35,6 +35,12 @@ public class Certification { @Schema(description = "name of the certification") private String name; + @NotBlank + @Column(name = "description") + @TypeDef(type = DataType.STRING) + @Schema(description = "description of the certification") + private String description; + @Nullable @Column(name = "badge_url") @Schema(description = "url of the badge") @@ -47,18 +53,19 @@ public class Certification { public Certification() { } - Certification(UUID id, String name, @Nullable String badgeUrl, boolean active) { + Certification(UUID id, String name, @NotBlank String description, @Nullable String badgeUrl, boolean active) { this.id = id; this.name = name; + this.description = description; this.badgeUrl = badgeUrl; this.active = active; } - public Certification(String name, @Nullable String badgeUrl) { - this(null, name, badgeUrl, true); + public Certification(String name, @NotBlank String description, @Nullable String badgeUrl) { + this(null, name, description, badgeUrl, true); } - public Certification(String name, String badgeUrl, boolean active) { - this(null, name, badgeUrl, active); + public Certification(String name, String description, String badgeUrl, boolean active) { + this(null, name, description, badgeUrl, active); } } diff --git a/server/src/main/java/com/objectcomputing/checkins/services/certification/CertificationController.java b/server/src/main/java/com/objectcomputing/checkins/services/certification/CertificationController.java index 3956ae3c0..a39deff8e 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/certification/CertificationController.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/certification/CertificationController.java @@ -54,6 +54,7 @@ List findAll(@Nullable Boolean includeInactive) { Certification create(@Body @Valid CertificationDTO certification) { return certificationService.saveCertification(new Certification( certification.getName(), + certification.getDescription(), certification.getBadgeUrl(), !Boolean.FALSE.equals(certification.getActive()) )); @@ -72,6 +73,7 @@ Certification update(@NotNull UUID id, @Body @Valid CertificationDTO certificati return certificationService.updateCertification(new Certification( id, certification.getName(), + certification.getDescription(), certification.getBadgeUrl(), !Boolean.FALSE.equals(certification.getActive()) )); diff --git a/server/src/main/java/com/objectcomputing/checkins/services/certification/CertificationDTO.java b/server/src/main/java/com/objectcomputing/checkins/services/certification/CertificationDTO.java index 713abbfba..98e98deed 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/certification/CertificationDTO.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/certification/CertificationDTO.java @@ -3,6 +3,7 @@ import io.micronaut.core.annotation.Introspected; import io.micronaut.core.annotation.Nullable; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Getter; @@ -18,6 +19,10 @@ class CertificationDTO { @Schema(description = "name of the certification") private String name; + @NotBlank + @Schema(description = "description of the certification") + private String description; + @Nullable @Schema(description = "badge url of the certification") private String badgeUrl; @@ -26,7 +31,7 @@ class CertificationDTO { @Schema(description = "whether the Certification is active") private Boolean active; - CertificationDTO(String name, String badgeUrl) { - this(name, badgeUrl, true); + CertificationDTO(String name, String description, String badgeUrl) { + this(name, description, badgeUrl, true); } } diff --git a/server/src/main/java/com/objectcomputing/checkins/services/certification/EarnedCertification.java b/server/src/main/java/com/objectcomputing/checkins/services/certification/EarnedCertification.java index 066622442..f7c784574 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/certification/EarnedCertification.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/certification/EarnedCertification.java @@ -13,7 +13,6 @@ import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.Table; -import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.Getter; import lombok.Setter; @@ -47,12 +46,6 @@ public class EarnedCertification { @Schema(description = "id of the certification") private UUID certificationId; - @NotBlank - @Column(name = "description") - @TypeDef(type = DataType.STRING) - @Schema(description = "description of the certification earned") - private String description; - @NotNull @Column(name = "earned_date") @TypeDef(type = DataType.DATE, converter = LocalDateConverter.class) @@ -68,26 +61,25 @@ public class EarnedCertification { private LocalDate expirationDate; @Nullable - @Column(name = "certificate_image_url") + @Column(name = "validation_url") @TypeDef(type = DataType.STRING) - @Schema(description = "optionally the url of the certificate image") - private String certificateImageUrl; + @Schema(description = "optionally the url of the validation") + private String validationUrl; public EarnedCertification() { } - public EarnedCertification(UUID memberId, UUID certificationId, String description, LocalDate earnedDate, LocalDate expirationDate, String certificateImageUrl) { - this(null, memberId, certificationId, description, earnedDate, expirationDate, certificateImageUrl); + public EarnedCertification(UUID memberId, UUID certificationId, LocalDate earnedDate, LocalDate expirationDate, String validationUrl) { + this(null, memberId, certificationId, earnedDate, expirationDate, validationUrl); } - public EarnedCertification(UUID id, UUID memberId, UUID certificationId, String description, LocalDate earnedDate, LocalDate expirationDate, String certificateImageUrl) { + public EarnedCertification(UUID id, UUID memberId, UUID certificationId, LocalDate earnedDate, LocalDate expirationDate, String validationUrl) { this.id = id; this.memberId = memberId; this.certificationId = certificationId; - this.description = description; this.earnedDate = earnedDate; this.expirationDate = expirationDate; - this.certificateImageUrl = certificateImageUrl; + this.validationUrl = validationUrl; } EarnedCertification withCertification(@NonNull UUID certificationId) { diff --git a/server/src/main/java/com/objectcomputing/checkins/services/certification/EarnedCertificationController.java b/server/src/main/java/com/objectcomputing/checkins/services/certification/EarnedCertificationController.java index 416990a17..85561ca84 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/certification/EarnedCertificationController.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/certification/EarnedCertificationController.java @@ -63,10 +63,9 @@ EarnedCertification create(@Body @Valid EarnedCertificationDTO certification, Ht new EarnedCertification( certification.getMemberId(), certification.getCertificationId(), - certification.getDescription(), certification.getEarnedDate(), certification.getExpirationDate(), - certification.getCertificateImageUrl() + certification.getValidationUrl() ) ); } @@ -86,10 +85,9 @@ EarnedCertification update(@NotNull UUID id, @Body @Valid EarnedCertificationDTO id, certification.getMemberId(), certification.getCertificationId(), - certification.getDescription(), certification.getEarnedDate(), certification.getExpirationDate(), - certification.getCertificateImageUrl() + certification.getValidationUrl() ) ); } diff --git a/server/src/main/java/com/objectcomputing/checkins/services/certification/EarnedCertificationDTO.java b/server/src/main/java/com/objectcomputing/checkins/services/certification/EarnedCertificationDTO.java index a0432aa61..f0d1e17d0 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/certification/EarnedCertificationDTO.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/certification/EarnedCertificationDTO.java @@ -2,7 +2,6 @@ import io.micronaut.core.annotation.Introspected; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Getter; @@ -25,10 +24,6 @@ class EarnedCertificationDTO { @Schema(description = "id of the certification") private UUID certificationId; - @NotBlank - @Schema(description = "description of the certification earned") - private String description; - @NotNull @Schema(description = "when the certification was earned") private LocalDate earnedDate; @@ -36,10 +31,10 @@ class EarnedCertificationDTO { @Schema(description = "optionally when the certification expires") private LocalDate expirationDate; - @Schema(description = "optionally the image of the certification") - private String certificateImageUrl; + @Schema(description = "optionally the validation URL of the certification") + private String validationUrl; - EarnedCertificationDTO(UUID memberId, UUID certificationId, String description, LocalDate earnedDate) { - this(memberId, certificationId, description, earnedDate, null, null); + EarnedCertificationDTO(UUID memberId, UUID certificationId, LocalDate earnedDate) { + this(memberId, certificationId, earnedDate, null, null); } } diff --git a/server/src/main/java/com/objectcomputing/checkins/services/certification/EarnedCertificationRepository.java b/server/src/main/java/com/objectcomputing/checkins/services/certification/EarnedCertificationRepository.java index c0ce1eb28..fca924b69 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/certification/EarnedCertificationRepository.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/certification/EarnedCertificationRepository.java @@ -21,7 +21,7 @@ public interface EarnedCertificationRepository extends CrudRepository findAllOrderByEarnedDateDesc(boolean includeDeactivated); @Query(value = """ @@ -30,7 +30,7 @@ JOIN certification AS cert USING(certification_id) JOIN certification AS cert USING(certification_id) WHERE earned.certification_id = :certificationId AND (cert.is_active = TRUE OR :includeDeactivated = TRUE) - ORDER BY earned.earned_date DESC, earned.description""", nativeQuery = true) + ORDER BY earned.earned_date DESC""", nativeQuery = true) List findByCertificationIdOrderByEarnedDateDesc(@NotNull UUID certificationId, boolean includeDeactivated); @Query(value = """ @@ -39,7 +39,7 @@ JOIN certification AS cert USING(certification_id) JOIN certification AS cert USING(certification_id) WHERE earned.member_id = :memberId AND (cert.is_active = TRUE OR :includeDeactivated = TRUE) - ORDER BY earned.earned_date DESC, earned.description""", nativeQuery = true) + ORDER BY earned.earned_date DESC""", nativeQuery = true) List findByMemberIdOrderByEarnedDateDesc(@NotNull UUID memberId, boolean includeDeactivated); @Query(value = """ @@ -49,7 +49,7 @@ JOIN certification AS cert USING(certification_id) WHERE earned.certification_id = :certificationId AND earned.member_id = :memberId AND (cert.is_active = TRUE OR :includeDeactivated = TRUE) - ORDER BY earned.earned_date DESC, earned.description""", nativeQuery = true) + ORDER BY earned.earned_date DESC""", nativeQuery = true) List findByMemberIdAndCertificationIdOrderByEarnedDateDesc(@NotNull UUID memberId, @NotNull UUID certificationId, boolean includeDeactivated); Optional findById(@Nullable UUID id); diff --git a/server/src/main/resources/db/common/V106__add_certificate_tables.sql b/server/src/main/resources/db/common/V106__add_certificate_tables.sql index 7d5107b3a..67deb66c7 100644 --- a/server/src/main/resources/db/common/V106__add_certificate_tables.sql +++ b/server/src/main/resources/db/common/V106__add_certificate_tables.sql @@ -6,6 +6,7 @@ CREATE TABLE certification ( certification_id varchar PRIMARY KEY, name varchar NOT NULL UNIQUE, + description varchar NOT NULL, badge_url varchar, is_active boolean NOT NULL DEFAULT TRUE ); @@ -15,8 +16,7 @@ CREATE TABLE earned_certification earned_certification_id varchar PRIMARY KEY, member_id varchar REFERENCES member_profile (id), certification_id varchar REFERENCES certification (certification_id), - description varchar NOT NULL, earned_date timestamp NOT NULL, expiration_date timestamp, - certificate_image_url varchar + validation_url varchar ); diff --git a/server/src/main/resources/db/dev/R__Load_testing_data.sql b/server/src/main/resources/db/dev/R__Load_testing_data.sql index 027b7f6f0..01ac0c33b 100644 --- a/server/src/main/resources/db/dev/R__Load_testing_data.sql +++ b/server/src/main/resources/db/dev/R__Load_testing_data.sql @@ -1828,31 +1828,31 @@ values --- CERTIFICATIONS INSERT INTO certification -(certification_id, name, badge_url) +(certification_id, name, description, badge_url) VALUES - ('23b248e1-40f3-4477-b1b6-544b743e6ee3', 'Java', 'https://images.credly.com/images/235d5b25-d41e-48c2-9c0e-63b373e78fc8/image.png'); + ('23b248e1-40f3-4477-b1b6-544b743e6ee3', 'Java', 'Java Certification', 'https://images.credly.com/images/235d5b25-d41e-48c2-9c0e-63b373e78fc8/image.png'); INSERT INTO certification -(certification_id, name, badge_url) +(certification_id, name, description, badge_url) VALUES - ('68343978-4072-4b48-aa9c-01f7ec910c9b', 'Python', 'https://pythoninstitute.org/assets/61f11f7719dd3800707549.png'); + ('68343978-4072-4b48-aa9c-01f7ec910c9b', 'Python', 'Python Certification', 'https://pythoninstitute.org/assets/61f11f7719dd3800707549.png'); --- MEMBER CERTIFICATIONS INSERT INTO earned_certification -(earned_certification_id, member_id, certification_id, description, earned_date) +(earned_certification_id, member_id, certification_id, earned_date) VALUES -- Michael Kimberlin, Java - ('d946dfaa-4bae-4a4e-a3c3-9378ce1cae37', '6207b3fd-042d-49aa-9e28-dcc04f537c2d', '23b248e1-40f3-4477-b1b6-544b743e6ee3', 'Java certification', '2024-04-01'); + ('d946dfaa-4bae-4a4e-a3c3-9378ce1cae37', '6207b3fd-042d-49aa-9e28-dcc04f537c2d', '23b248e1-40f3-4477-b1b6-544b743e6ee3', '2024-04-01'); INSERT INTO earned_certification -(earned_certification_id, member_id, certification_id, description, earned_date) +(earned_certification_id, member_id, certification_id, earned_date) VALUES -- Revolver Ocelot, Java - ('42471a8c-8851-42a0-8cc2-bc42cb1020cc', '105f2968-a182-45a3-892c-eeff76383fe0', '23b248e1-40f3-4477-b1b6-544b743e6ee3', 'Java certification', '2022-06-01'); + ('42471a8c-8851-42a0-8cc2-bc42cb1020cc', '105f2968-a182-45a3-892c-eeff76383fe0', '23b248e1-40f3-4477-b1b6-544b743e6ee3', '2022-06-01'); INSERT INTO earned_certification -(earned_certification_id, member_id, certification_id, description, earned_date) +(earned_certification_id, member_id, certification_id, earned_date) VALUES -- Revolver Ocelot, Python - ('1f4272da-6ecb-4c15-b4a8-28739405bd1c', '105f2968-a182-45a3-892c-eeff76383fe0', '68343978-4072-4b48-aa9c-01f7ec910c9b', 'Python certification', '2024-03-01'); + ('1f4272da-6ecb-4c15-b4a8-28739405bd1c', '105f2968-a182-45a3-892c-eeff76383fe0', '68343978-4072-4b48-aa9c-01f7ec910c9b', '2024-03-01'); -- Volunteering diff --git a/web-ui/src/components/certifications/EarnedCertificationsTable.css b/web-ui/src/components/certifications/EarnedCertificationsTable.css index 1c715f006..6f42f758b 100644 --- a/web-ui/src/components/certifications/EarnedCertificationsTable.css +++ b/web-ui/src/components/certifications/EarnedCertificationsTable.css @@ -1,4 +1,7 @@ #earned-certifications-table { + display: flex; + justify-content: center; + .MuiCardHeader-root { padding-bottom: 0; } @@ -9,6 +12,7 @@ } table { + margin: 0 auto; border-collapse: collapse; img { @@ -19,12 +23,15 @@ td, th { padding: 0.5rem; + text-align: center; + color: black; } th { background-color: var(--oci-orange); border-right: 1px solid var(--oci-light-blue); } + th:last-child { border-right: none; } @@ -32,6 +39,7 @@ tr:nth-child(even) { background-color: #eee; } + tr:nth-child(odd) { background-color: #ffffff; } diff --git a/web-ui/src/components/certifications/EarnedCertificationsTable.jsx b/web-ui/src/components/certifications/EarnedCertificationsTable.jsx index 5e4b9c2d9..dc5feeb87 100644 --- a/web-ui/src/components/certifications/EarnedCertificationsTable.jsx +++ b/web-ui/src/components/certifications/EarnedCertificationsTable.jsx @@ -45,7 +45,7 @@ const tableColumns = [ 'Description', 'Earned On', 'Expiration', - 'Certificate Image', + 'Validation Image', 'Badge' ]; @@ -63,6 +63,7 @@ const EarnedCertificationsTable = ({ const [certificationDialogOpen, setCertificationDialogOpen] = useState(false); const [certificationMap, setCertificationMap] = useState({}); const [certificationName, setCertificationName] = useState(''); + const [certificationDescription, setCertificationDescription] = useState(''); const [certifications, setCertifications] = useState([]); const [confirmDeleteOpen, setConfirmDeleteOpen] = useState(false); const [earnedCertifications, setEarnedCertifications] = useState([]); @@ -140,6 +141,8 @@ const EarnedCertificationsTable = ({ const cancelCertification = useCallback(() => { setCertificationName(''); + setCertificationDescription(''); + setBadgeUrl(''); setCertificationDialogOpen(false); }, []); @@ -166,8 +169,13 @@ const EarnedCertificationsTable = ({ value={certificationName} /> setCertificationDescription(e.target.value)} + value={certificationDescription} + /> + setBadgeUrl(e.target.value)} value={badgeUrl} /> @@ -177,7 +185,7 @@ const EarnedCertificationsTable = ({