Changeset 2998dc4
- Timestamp:
- 07/30/22 15:39:04 (2 years ago)
- Branches:
- main
- Children:
- e958037
- Parents:
- 3a44163
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
reactapp/package-lock.json
r3a44163 r2998dc4 12 12 "@testing-library/react": "^13.3.0", 13 13 "@testing-library/user-event": "^13.5.0", 14 "jsog": "^1.0.7", 14 15 "react": "^18.2.0", 15 16 "react-dom": "^18.2.0", … … 11226 11227 } 11227 11228 }, 11229 "node_modules/jsog": { 11230 "version": "1.0.7", 11231 "resolved": "https://registry.npmjs.org/jsog/-/jsog-1.0.7.tgz", 11232 "integrity": "sha512-9IA6ZY6g5rSgRTvHO7B4Ro9LGGqJEPXdKRkvPohmzdk777fldQ3rjbUkmiIG3gxswLi2ZiAKsdgqfs+zMwmRcg==" 11233 }, 11228 11234 "node_modules/json-parse-even-better-errors": { 11229 11235 "version": "2.3.1", … … 24734 24740 "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==" 24735 24741 }, 24742 "jsog": { 24743 "version": "1.0.7", 24744 "resolved": "https://registry.npmjs.org/jsog/-/jsog-1.0.7.tgz", 24745 "integrity": "sha512-9IA6ZY6g5rSgRTvHO7B4Ro9LGGqJEPXdKRkvPohmzdk777fldQ3rjbUkmiIG3gxswLi2ZiAKsdgqfs+zMwmRcg==" 24746 }, 24736 24747 "json-parse-even-better-errors": { 24737 24748 "version": "2.3.1", -
reactapp/package.json
r3a44163 r2998dc4 7 7 "@testing-library/react": "^13.3.0", 8 8 "@testing-library/user-event": "^13.5.0", 9 "jsog": "^1.0.7", 9 10 "react": "^18.2.0", 10 11 "react-dom": "^18.2.0", -
reactapp/src/App.css
r3a44163 r2998dc4 2 2 text-align: center; 3 3 } 4 5 .App-logo {6 height: 40vmin;7 pointer-events: none;8 }9 10 @media (prefers-reduced-motion: no-preference) {11 .App-logo {12 animation: App-logo-spin infinite 20s linear;13 }14 }15 16 .App-header {17 background-color: #282c34;18 min-height: 100vh;19 display: flex;20 flex-direction: column;21 align-items: center;22 justify-content: center;23 font-size: calc(10px + 2vmin);24 color: white;25 }26 27 .App-link {28 color: #61dafb;29 }30 31 @keyframes App-logo-spin {32 from {33 transform: rotate(0deg);34 }35 to {36 transform: rotate(360deg);37 }38 } -
reactapp/src/App.js
r3a44163 r2998dc4 4 4 return ( 5 5 <div> 6 <h1>Main App Page</h1> 7 <nav 8 style={{ 9 borderBottom: "solid 1px", 10 paddingBottom: "1rem", 11 }} 12 > 13 <Link to="/professor">Professor</Link> 14 </nav> 6 <h1>profesori.mk</h1> 15 7 <Outlet /> 16 8 </div> -
reactapp/src/Components/OpinionTree.js
r3a44163 r2998dc4 1 1 function OpinionTree({ professor }) { 2 function displayChildPosts(post) { 3 if (post == null) return; 2 var renderedOpinionIds = []; 3 var postCount; // za da ne go pokazuva ispod postot 4 5 function displayChildPosts(child) { 6 if (child == null) return; 7 postCount = renderedOpinionIds.push(child.postId); 4 8 return ( 5 <div key={post.postId}> 6 <p>Содржина: {post.content}</p> 7 {post.children.map((child) => displayChildPosts(child))} 9 <div key={child.postId}> 10 <p>{child.author.username} реплицирал</p> 11 <p>Содржина: {child.content}</p> 12 {child.children.map((childOfChild) => displayChildPosts(childOfChild))} 8 13 </div> 9 14 ); … … 13 18 <div className="opinionTree"> 14 19 {professor.relatedOpinions.map((opinion) => { 15 if (opinion.hasOwnProperty("title")) { 20 if (!renderedOpinionIds.includes(opinion.postId)) { 21 postCount = renderedOpinionIds.push(opinion.postId); 16 22 return ( 17 23 <div key={opinion.postId}> 24 <p>{opinion.author.username} напишал</p> 18 25 <p>Наслов: {opinion.title}</p> 19 26 <p>Содржина: {opinion.content}</p> 20 27 {opinion.children.map((child) => displayChildPosts(child))} 28 <hr /> 21 29 </div> 22 30 ); -
reactapp/src/Pages/Professor.js
r3a44163 r2998dc4 1 1 import React, { useEffect, useState } from "react"; 2 2 import { Outlet, useParams } from "react-router-dom"; 3 import JSOG from "jsog"; 3 4 import OpinionTree from "../Components/OpinionTree"; 4 5 … … 15 16 try { 16 17 const response = await fetch(url); 17 const json = await response.json(); 18 setProfessor(json); 18 var cyclicGraph = await response.json(); 19 var jsogStructure = JSOG.encode(cyclicGraph); // has { '@ref': 'ID' } links instead of cycles 20 cyclicGraph = JSOG.decode(jsogStructure); 21 setProfessor(cyclicGraph); 19 22 setLoaded(true); 20 23 } catch (error) { -
springapp/pom.xml
r3a44163 r2998dc4 57 57 <version>2.7.2</version> 58 58 </dependency> 59 <dependency> 60 <groupId>com.voodoodyne.jackson.jsog</groupId> 61 <artifactId>jackson-jsog</artifactId> 62 <version>1.1.2</version> 63 <scope>compile</scope> 64 </dependency> 59 65 </dependencies> 60 66 -
springapp/src/main/java/mk/profesori/springapp/Model/CustomUserDetails.java
r3a44163 r2998dc4 23 23 24 24 import com.fasterxml.jackson.annotation.JsonIdentityInfo; 25 import com. fasterxml.jackson.annotation.ObjectIdGenerators;25 import com.voodoodyne.jackson.jsog.JSOGGenerator; 26 26 27 27 import lombok.EqualsAndHashCode; … … 35 35 @NoArgsConstructor 36 36 @Entity 37 @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")37 @JsonIdentityInfo(generator = JSOGGenerator.class) 38 38 public class CustomUserDetails implements UserDetails { 39 39 … … 45 45 private String username; 46 46 private String email; 47 private String password; 47 private String password; // TODO dont expose password in api 48 48 @Enumerated(EnumType.STRING) 49 49 private UserRole userRole; -
springapp/src/main/java/mk/profesori/springapp/Model/Post.java
r3a44163 r2998dc4 20 20 21 21 import com.fasterxml.jackson.annotation.JsonIdentityInfo; 22 import com. fasterxml.jackson.annotation.ObjectIdGenerators;22 import com.voodoodyne.jackson.jsog.JSOGGenerator; 23 23 24 24 import lombok.NoArgsConstructor; … … 27 27 @Inheritance(strategy = InheritanceType.SINGLE_TABLE) 28 28 @DiscriminatorColumn(name = "post_type", discriminatorType = DiscriminatorType.STRING) 29 @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "postId")29 @JsonIdentityInfo(generator = JSOGGenerator.class) 30 30 @NoArgsConstructor 31 31 public class Post { -
springapp/src/main/java/mk/profesori/springapp/Model/_Thread.java
r3a44163 r2998dc4 27 27 private Subject targetSubject; 28 28 29 // TODO 29 // TODO threadovi 30 30 /* 31 31 * public _Thread(String title, String content, List<String> tags, Section
Note:
See TracChangeset
for help on using the changeset viewer.