From 9c1520a0169a60fafb8d8c698e69bb041faea8ae Mon Sep 17 00:00:00 2001 From: nishant23122000 Date: Thu, 10 Feb 2022 14:54:10 +0530 Subject: [PATCH 01/76] refactor --- app/components/discourserankedlist.js | 77 +------------- app/components/growthcounters.js | 34 +++--- app/components/infotiles.js | 37 ++----- app/components/newscarousel.js | 10 +- app/components/personalcircle.js | 146 ++------------------------ app/data/DiscourserankedlistData.js | 76 ++++++++++++++ app/data/growthcountersData.js | 18 ++++ app/data/infotilesData.js | 20 ++++ app/data/persionalCircleData.js | 136 ++++++++++++++++++++++++ app/styles/Infotiles.module.css | 6 ++ app/styles/Newscarousel.module.css | 8 ++ 11 files changed, 308 insertions(+), 260 deletions(-) create mode 100644 app/data/DiscourserankedlistData.js create mode 100644 app/data/growthcountersData.js create mode 100644 app/data/infotilesData.js create mode 100644 app/data/persionalCircleData.js diff --git a/app/components/discourserankedlist.js b/app/components/discourserankedlist.js index dfc996fb..8b5d6cc2 100644 --- a/app/components/discourserankedlist.js +++ b/app/components/discourserankedlist.js @@ -2,7 +2,7 @@ import { Col, Row } from 'react-bootstrap'; import styles from '../styles/Discourserankedlist.module.css'; import Like from '../public/svg/like.js'; import Comment from '../public/svg/comment'; - +import Data from '../data/DiscourserankedlistData'; function TimeSince(date) { let seconds = Math.floor((new Date() - date) / 1000); let interval = seconds / 31536000; @@ -29,80 +29,7 @@ function TimeSince(date) { } function Discourserankedlist(props) { - const Data = [ - { - id: 1, - title: - 'Upload stuck at 0% again after initially fixing with chanding site url in General admin options', - time: '6:57 PM', - upvotes: '89', - comments: '91', - }, - { - id: 2, - title: 'Why can’t we have thumbnails for video uploads on mobile?', - time: '4:00 PM', - upvotes: '500', - comments: '4', - }, - { - id: 3, - title: 'Can’t find “Users must use Two Factor Authentication” Option', - time: '12:53 PM', - upvotes: '456', - comments: '75', - }, - { - id: 4, - title: 'Can’t “forget/remove my data” directly in RC 4.3.0 in livechat', - time: '8:36 AM', - upvotes: '234', - comments: '199', - }, - { - id: 5, - title: 'Not migrating, control is locked', - time: '11:30 PM', - upvotes: '441', - comments: '74', - }, - { - id: 6, - title: - 'Upload stuck at 0% again after initially fixing with chanding site url in General admin options', - time: '7:14 PM', - upvotes: '972', - comments: '42', - }, - { - id: 7, - title: 'Can’t find “Users must use Two Factor Authentication” Option', - time: '3:36 PM', - upvotes: '4279', - comments: '98', - }, - { - id: 8, - title: 'Cannot Chat Log Level - Option has disappeared', - time: '11:06 AM', - upvotes: '51', - comments: '291', - }, - { - id: 9, - title: 'Wrong IP Server', - time: '2:00 PM', - upvotes: '478', - comments: '25', - }, - { - id: 10, - title: 'Not migrating, control is locked', - time: '11:03 PM', - upvotes: '16', - comments: '15', - }, - ]; + //generates random colour for border styling const color = [ 'border-primary', diff --git a/app/components/growthcounters.js b/app/components/growthcounters.js index 007236b6..cb0ae981 100644 --- a/app/components/growthcounters.js +++ b/app/components/growthcounters.js @@ -1,37 +1,27 @@ import styles from '../styles/Growthcounters.module.css'; import Countup from './clientsideonly/countup'; - +import content from '../data/growthcountersData'; export default function Growthcounters() { + + return ( <>
-
+ { + content.map((comp)=>{ + return ( +
{process.browser && ( - + )} - Users -
- -
- - {process.browser && ( - - )} - - Messages -
- -
- - {process.browser && ( - - )} - - Online + {comp.title}
+ ) + }) + }
); diff --git a/app/components/infotiles.js b/app/components/infotiles.js index 02221316..f35a46af 100644 --- a/app/components/infotiles.js +++ b/app/components/infotiles.js @@ -1,34 +1,17 @@ -import Styles from '../styles/Infotiles.module.css'; - +import Styles from "../styles/Infotiles.module.css"; +import infotiles from "../data/infotilesData"; export default function Infotiles() { return ( <>
-
-
Documentation
-

- Find in-depth information about Rocket.Chat features and API. -

-
-
-
Learn
-

- Learn about Rocket.Chat in an interactive course with quizzes! -

-
-
-
Examples
-

- Discover and deploy boilerplate example Rocket.Chat projects. -

-
-
-
Deploy
-

- Instantly deploy your Rocket.Chat site to a public URL with - Rocket.Chat SaaS. -

-
+ {infotiles.map((info) => { + return ( +
+
{info.title}
+

{info.body}

+
+ ); + })}
); diff --git a/app/components/newscarousel.js b/app/components/newscarousel.js index 1bef8341..dcafc1fa 100644 --- a/app/components/newscarousel.js +++ b/app/components/newscarousel.js @@ -48,13 +48,21 @@ function Newscarousel(props) { }, }, { - breakpoint: 600, + breakpoint: 800, settings: { slidesToShow: 2, slidesToScroll: 2, initialSlide: 2, }, }, + { + breakpoint: 600, + settings: { + slidesToShow: 1, + slidesToScroll: 2, + initialSlide: 2, + }, + }, ]} prevArrow={ - -
- - - - - -
-
Admin
-
- -
- - - - - - -
-
Developer
-
- -
- - - - - - -
-
Group Chat
-
- -
- - - - - - - - -
-
GSoC
-
+ {personalCircles.map((personal) => { + return ( + +
{personal.svg}
+
{personal.title}
+
+ ); + })} ); diff --git a/app/data/DiscourserankedlistData.js b/app/data/DiscourserankedlistData.js new file mode 100644 index 00000000..3ce13f2d --- /dev/null +++ b/app/data/DiscourserankedlistData.js @@ -0,0 +1,76 @@ +const DiscourserankedlistData = [ + { + id: 1, + title: + 'Upload stuck at 0% again after initially fixing with chanding site url in General admin options', + time: '6:57 PM', + upvotes: '89', + comments: '91', + }, + { + id: 2, + title: 'Why can’t we have thumbnails for video uploads on mobile?', + time: '4:00 PM', + upvotes: '500', + comments: '4', + }, + { + id: 3, + title: 'Can’t find “Users must use Two Factor Authentication” Option', + time: '12:53 PM', + upvotes: '456', + comments: '75', + }, + { + id: 4, + title: 'Can’t “forget/remove my data” directly in RC 4.3.0 in livechat', + time: '8:36 AM', + upvotes: '234', + comments: '199', + }, + { + id: 5, + title: 'Not migrating, control is locked', + time: '11:30 PM', + upvotes: '441', + comments: '74', + }, + { + id: 6, + title: + 'Upload stuck at 0% again after initially fixing with chanding site url in General admin options', + time: '7:14 PM', + upvotes: '972', + comments: '42', + }, + { + id: 7, + title: 'Can’t find “Users must use Two Factor Authentication” Option', + time: '3:36 PM', + upvotes: '4279', + comments: '98', + }, + { + id: 8, + title: 'Cannot Chat Log Level - Option has disappeared', + time: '11:06 AM', + upvotes: '51', + comments: '291', + }, + { + id: 9, + title: 'Wrong IP Server', + time: '2:00 PM', + upvotes: '478', + comments: '25', + }, + { + id: 10, + title: 'Not migrating, control is locked', + time: '11:03 PM', + upvotes: '16', + comments: '15', + }, + ]; + + export default DiscourserankedlistData; \ No newline at end of file diff --git a/app/data/growthcountersData.js b/app/data/growthcountersData.js new file mode 100644 index 00000000..6327cb4e --- /dev/null +++ b/app/data/growthcountersData.js @@ -0,0 +1,18 @@ + + const growthcountersData=[ + { + class:'d-flex flex-column pe-4 px-md-5 mx-md-3', + end:'343433', + title:'Users', + },{ + class:'d-flex flex-column px-4 px-md-5 mx-md-3 border-start border-gray', + end:'1294056', + title:'Messages', + },{ + class:'d-flex flex-column ps-4 px-md-5 mx-md-3 border-start border-gray', + end:'507', + title:'Online', + }, + ] + + export default growthcountersData; \ No newline at end of file diff --git a/app/data/infotilesData.js b/app/data/infotilesData.js new file mode 100644 index 00000000..0ffbecc0 --- /dev/null +++ b/app/data/infotilesData.js @@ -0,0 +1,20 @@ + + + +const infotilesData=[ + { + title:'Documentation', + body:'Find in-depth information about Rocket.Chat features and API.' + },{ + title:'Learn', + body:'Learn about Rocket.Chat in an interactive course with quizzes!' + },{ + title:'Examples', + body:'Discover and deploy boilerplate example Rocket.Chat projects.' + },{ + title:'Deploy', + body:'Instantly deploy your Rocket.Chat site to a public URL with Rocket.Chat SaaS.' + } +] + +export default infotilesData; \ No newline at end of file diff --git a/app/data/persionalCircleData.js b/app/data/persionalCircleData.js new file mode 100644 index 00000000..6396f322 --- /dev/null +++ b/app/data/persionalCircleData.js @@ -0,0 +1,136 @@ +const persionalCircleData = [ + { + svg: ( + + + + + + ), + title: "Admin", + }, + { + svg: ( + + + + + + + ), + title: "Developer", + }, + { + svg: ( + + + + + + + ), + title: "Group Chat", + }, + { + svg: ( + + + + + + + + + ), + title: "GSoC", + }, +]; + +export default persionalCircleData; diff --git a/app/styles/Infotiles.module.css b/app/styles/Infotiles.module.css index 569348cb..47bb1594 100644 --- a/app/styles/Infotiles.module.css +++ b/app/styles/Infotiles.module.css @@ -30,3 +30,9 @@ background: #1d74f5; color: white; } + +@media (max-width: 600px) { + .card { + width: 100%; + } +} diff --git a/app/styles/Newscarousel.module.css b/app/styles/Newscarousel.module.css index 3ce5ad8d..b9c22b86 100644 --- a/app/styles/Newscarousel.module.css +++ b/app/styles/Newscarousel.module.css @@ -26,3 +26,11 @@ .carousel-item-title { font-size: 22.5px; } +@media (max-width: 600px) { + .heading { + font-size: clamp(1.3rem, 1.7vw, 1.2rem); + } + .description { + font-size: clamp(0.8rem, 1.2vw, 0.8rem); + } +} From ca58c55ffa123578f47fdf715b802649533d9442 Mon Sep 17 00:00:00 2001 From: nkpatel23122000 Date: Thu, 17 Feb 2022 12:41:37 +0530 Subject: [PATCH 02/76] fetch from strapi --- app/components/discourserankedlist.js | 6 +- app/components/growthcounters.js | 40 +++--- app/components/infotiles.js | 5 +- .../{personalcircle.js => personcircle.js} | 12 +- app/data/DiscourserankedlistData.js | 76 ---------- app/data/growthcountersData.js | 18 --- app/data/infotilesData.js | 20 --- app/data/persionalCircleData.js | 136 ------------------ app/lib/github.js | 1 - app/pages/index.js | 19 +-- cms/api/community-activity/config/routes.json | 52 +++++++ .../controllers/community-activity.js} | 0 .../models/community-activity.js} | 0 .../models/community-activity.settings.json | 28 ++++ .../services/community-activity.js} | 0 .../{persona => counter}/config/routes.json | 24 ++-- .../controllers/counter.js} | 0 .../models/counter.js} | 0 .../models/counter.settings.json} | 12 +- .../services/counter.js} | 0 .../discourse/models/discourse.settings.json | 21 --- .../config/routes.json | 24 ++-- .../controllers/infotile.js} | 0 .../models/infotile.js} | 0 .../models/infotile.settings.json} | 13 +- .../services/infotile.js} | 0 .../config/routes.json | 24 ++-- cms/api/persons/controllers/persons.js | 8 ++ cms/api/persons/models/persons.js | 8 ++ cms/api/persons/models/persons.settings.json | 30 ++++ cms/api/persons/services/persons.js | 8 ++ 31 files changed, 225 insertions(+), 360 deletions(-) rename app/components/{personalcircle.js => personcircle.js} (54%) delete mode 100644 app/data/DiscourserankedlistData.js delete mode 100644 app/data/growthcountersData.js delete mode 100644 app/data/infotilesData.js delete mode 100644 app/data/persionalCircleData.js create mode 100644 cms/api/community-activity/config/routes.json rename cms/api/{discourse/controllers/discourse.js => community-activity/controllers/community-activity.js} (100%) rename cms/api/{discourse/models/discourse.js => community-activity/models/community-activity.js} (100%) create mode 100644 cms/api/community-activity/models/community-activity.settings.json rename cms/api/{discourse/services/discourse.js => community-activity/services/community-activity.js} (100%) rename cms/api/{persona => counter}/config/routes.json (57%) rename cms/api/{persona-icons/controllers/persona-icons.js => counter/controllers/counter.js} (100%) rename cms/api/{persona-icons/models/persona-icons.js => counter/models/counter.js} (100%) rename cms/api/{persona/models/persona.settings.json => counter/models/counter.settings.json} (67%) rename cms/api/{persona-icons/services/persona-icons.js => counter/services/counter.js} (100%) delete mode 100644 cms/api/discourse/models/discourse.settings.json rename cms/api/{discourse => infotile}/config/routes.json (56%) rename cms/api/{persona/controllers/persona.js => infotile/controllers/infotile.js} (100%) rename cms/api/{persona/models/persona.js => infotile/models/infotile.js} (100%) rename cms/api/{persona-icons/models/persona-icons.settings.json => infotile/models/infotile.settings.json} (58%) rename cms/api/{persona/services/persona.js => infotile/services/infotile.js} (100%) rename cms/api/{persona-icons => persons}/config/routes.json (54%) create mode 100644 cms/api/persons/controllers/persons.js create mode 100644 cms/api/persons/models/persons.js create mode 100644 cms/api/persons/models/persons.settings.json create mode 100644 cms/api/persons/services/persons.js diff --git a/app/components/discourserankedlist.js b/app/components/discourserankedlist.js index 8b5d6cc2..afe8b596 100644 --- a/app/components/discourserankedlist.js +++ b/app/components/discourserankedlist.js @@ -2,7 +2,7 @@ import { Col, Row } from 'react-bootstrap'; import styles from '../styles/Discourserankedlist.module.css'; import Like from '../public/svg/like.js'; import Comment from '../public/svg/comment'; -import Data from '../data/DiscourserankedlistData'; + function TimeSince(date) { let seconds = Math.floor((new Date() - date) / 1000); let interval = seconds / 31536000; @@ -28,7 +28,7 @@ function TimeSince(date) { return Math.floor(seconds) + ' seconds ago'; } -function Discourserankedlist(props) { +function Discourserankedlist({activities}) { //generates random colour for border styling const color = [ @@ -57,7 +57,7 @@ function Discourserankedlist(props) { - {Data.map(item => ( + {activities.map(item => ( -
- { - content.map((comp)=>{ - return ( -
- - {process.browser && ( - - )} - +
+ {counters.map((count, index) => { + return ( +
+ + {process.browser && ( + + )} + - {comp.title} -
- ) - }) - } + {count.title} +
+ ); + })}
); diff --git a/app/components/infotiles.js b/app/components/infotiles.js index f35a46af..cf5f5196 100644 --- a/app/components/infotiles.js +++ b/app/components/infotiles.js @@ -1,6 +1,5 @@ import Styles from "../styles/Infotiles.module.css"; -import infotiles from "../data/infotilesData"; -export default function Infotiles() { +export default function Infotiles({infotiles}) { return ( <>
@@ -8,7 +7,7 @@ export default function Infotiles() { return (
{info.title}
-

{info.body}

+

{info.description}

); })} diff --git a/app/components/personalcircle.js b/app/components/personcircle.js similarity index 54% rename from app/components/personalcircle.js rename to app/components/personcircle.js index ac306049..614c7a9c 100644 --- a/app/components/personalcircle.js +++ b/app/components/personcircle.js @@ -1,17 +1,19 @@ import { Button, ButtonGroup, Col } from "react-bootstrap"; import styles from "../styles/Personacircle.module.css"; -import personalCircles from "../data/persionalCircleData"; -export default function Personacircle(props) { +import {getStrapiURL } from '../lib/api'; +export default function Personcircle({persons}) { return ( <> - {personalCircles.map((personal) => { + {persons.map((person) => { return ( -
{personal.svg}
-
{personal.title}
+
+ +
+
{person.title}
); })} diff --git a/app/data/DiscourserankedlistData.js b/app/data/DiscourserankedlistData.js deleted file mode 100644 index 3ce13f2d..00000000 --- a/app/data/DiscourserankedlistData.js +++ /dev/null @@ -1,76 +0,0 @@ -const DiscourserankedlistData = [ - { - id: 1, - title: - 'Upload stuck at 0% again after initially fixing with chanding site url in General admin options', - time: '6:57 PM', - upvotes: '89', - comments: '91', - }, - { - id: 2, - title: 'Why can’t we have thumbnails for video uploads on mobile?', - time: '4:00 PM', - upvotes: '500', - comments: '4', - }, - { - id: 3, - title: 'Can’t find “Users must use Two Factor Authentication” Option', - time: '12:53 PM', - upvotes: '456', - comments: '75', - }, - { - id: 4, - title: 'Can’t “forget/remove my data” directly in RC 4.3.0 in livechat', - time: '8:36 AM', - upvotes: '234', - comments: '199', - }, - { - id: 5, - title: 'Not migrating, control is locked', - time: '11:30 PM', - upvotes: '441', - comments: '74', - }, - { - id: 6, - title: - 'Upload stuck at 0% again after initially fixing with chanding site url in General admin options', - time: '7:14 PM', - upvotes: '972', - comments: '42', - }, - { - id: 7, - title: 'Can’t find “Users must use Two Factor Authentication” Option', - time: '3:36 PM', - upvotes: '4279', - comments: '98', - }, - { - id: 8, - title: 'Cannot Chat Log Level - Option has disappeared', - time: '11:06 AM', - upvotes: '51', - comments: '291', - }, - { - id: 9, - title: 'Wrong IP Server', - time: '2:00 PM', - upvotes: '478', - comments: '25', - }, - { - id: 10, - title: 'Not migrating, control is locked', - time: '11:03 PM', - upvotes: '16', - comments: '15', - }, - ]; - - export default DiscourserankedlistData; \ No newline at end of file diff --git a/app/data/growthcountersData.js b/app/data/growthcountersData.js deleted file mode 100644 index 6327cb4e..00000000 --- a/app/data/growthcountersData.js +++ /dev/null @@ -1,18 +0,0 @@ - - const growthcountersData=[ - { - class:'d-flex flex-column pe-4 px-md-5 mx-md-3', - end:'343433', - title:'Users', - },{ - class:'d-flex flex-column px-4 px-md-5 mx-md-3 border-start border-gray', - end:'1294056', - title:'Messages', - },{ - class:'d-flex flex-column ps-4 px-md-5 mx-md-3 border-start border-gray', - end:'507', - title:'Online', - }, - ] - - export default growthcountersData; \ No newline at end of file diff --git a/app/data/infotilesData.js b/app/data/infotilesData.js deleted file mode 100644 index 0ffbecc0..00000000 --- a/app/data/infotilesData.js +++ /dev/null @@ -1,20 +0,0 @@ - - - -const infotilesData=[ - { - title:'Documentation', - body:'Find in-depth information about Rocket.Chat features and API.' - },{ - title:'Learn', - body:'Learn about Rocket.Chat in an interactive course with quizzes!' - },{ - title:'Examples', - body:'Discover and deploy boilerplate example Rocket.Chat projects.' - },{ - title:'Deploy', - body:'Instantly deploy your Rocket.Chat site to a public URL with Rocket.Chat SaaS.' - } -] - -export default infotilesData; \ No newline at end of file diff --git a/app/data/persionalCircleData.js b/app/data/persionalCircleData.js deleted file mode 100644 index 6396f322..00000000 --- a/app/data/persionalCircleData.js +++ /dev/null @@ -1,136 +0,0 @@ -const persionalCircleData = [ - { - svg: ( - - - - - - ), - title: "Admin", - }, - { - svg: ( - - - - - - - ), - title: "Developer", - }, - { - svg: ( - - - - - - - ), - title: "Group Chat", - }, - { - svg: ( - - - - - - - - - ), - title: "GSoC", - }, -]; - -export default persionalCircleData; diff --git a/app/lib/github.js b/app/lib/github.js index dd7d1836..38aa12bc 100644 --- a/app/lib/github.js +++ b/app/lib/github.js @@ -15,7 +15,6 @@ export const getIssues = async (owner, repo) => { }, ]; const res = await fetchAPI('/ghissues'); - console.log(res); if (Array.isArray(res) && Array.isArray(res[0].Issues)) { issues = res[0].Issues; } diff --git a/app/pages/index.js b/app/pages/index.js index 618dfa7b..eab53c4a 100644 --- a/app/pages/index.js +++ b/app/pages/index.js @@ -2,7 +2,7 @@ import Head from 'next/head'; import styles from '../styles/Home.module.css'; import Infotiles from '../components/infotiles'; import Newscarousel from '../components/newscarousel'; -import Personacircle from '../components/personalcircle'; +import Personacircle from '../components/personcircle'; import Discourserankedlist from '../components/discourserankedlist'; import Searchbox from '../components/searchbox'; import Growthcounters from '../components/growthcounters'; @@ -43,10 +43,10 @@ function Home(props) { - + - +
Get What You Need... - +

Community Activity

- +
@@ -91,16 +91,19 @@ export default withFirebaseAuthUser()(Home); export async function getStaticProps({ params }) { const carousels = await fetchAPI('/carousels'); - const personas = await fetchAPI('/personas'); + const persons = await fetchAPI('/persons'); const guides = await fetchAPI('/guides'); const releaseNotes = await fetchAPI('/release-notes'); + const infotiles=await fetchAPI('/infotiles'); + const counters=await fetchAPI('/counters'); + const communityActivities=await fetchAPI('/community-activities'); const topNavItems = await fetchAPI('/top-nav-item'); - const topPosts = await fetchAPI('/discourses'); const issues = await getIssues('RocketChat', 'RC4Community'); const contributors = await getContributors(); + return { - props: { carousels, personas, guides, releaseNotes, topNavItems, topPosts, issues, contributors }, + props: { carousels, persons, guides, releaseNotes, topNavItems, issues, contributors,infotiles,counters,communityActivities }, // Next.js will attempt to re-generate the page: // - When a request comes in // - At most once every 1 second diff --git a/cms/api/community-activity/config/routes.json b/cms/api/community-activity/config/routes.json new file mode 100644 index 00000000..7babc65f --- /dev/null +++ b/cms/api/community-activity/config/routes.json @@ -0,0 +1,52 @@ +{ + "routes": [ + { + "method": "GET", + "path": "/community-activities", + "handler": "community-activity.find", + "config": { + "policies": [] + } + }, + { + "method": "GET", + "path": "/community-activities/count", + "handler": "community-activity.count", + "config": { + "policies": [] + } + }, + { + "method": "GET", + "path": "/community-activities/:id", + "handler": "community-activity.findOne", + "config": { + "policies": [] + } + }, + { + "method": "POST", + "path": "/community-activities", + "handler": "community-activity.create", + "config": { + "policies": [] + } + }, + { + "method": "PUT", + "path": "/community-activities/:id", + "handler": "community-activity.update", + "config": { + "policies": [] + } + }, + { + "method": "DELETE", + "path": "/community-activities/:id", + "handler": "community-activity.delete", + "config": { + "policies": [] + } + } + ] +} diff --git a/cms/api/discourse/controllers/discourse.js b/cms/api/community-activity/controllers/community-activity.js similarity index 100% rename from cms/api/discourse/controllers/discourse.js rename to cms/api/community-activity/controllers/community-activity.js diff --git a/cms/api/discourse/models/discourse.js b/cms/api/community-activity/models/community-activity.js similarity index 100% rename from cms/api/discourse/models/discourse.js rename to cms/api/community-activity/models/community-activity.js diff --git a/cms/api/community-activity/models/community-activity.settings.json b/cms/api/community-activity/models/community-activity.settings.json new file mode 100644 index 00000000..70fecfe3 --- /dev/null +++ b/cms/api/community-activity/models/community-activity.settings.json @@ -0,0 +1,28 @@ +{ + "kind": "collectionType", + "collectionName": "community_activities", + "info": { + "name": "CommunityActivity", + "description": "" + }, + "options": { + "increments": true, + "timestamps": true, + "draftAndPublish": true + }, + "pluginOptions": {}, + "attributes": { + "title": { + "type": "text" + }, + "time": { + "type": "string" + }, + "upvotes": { + "type": "integer" + }, + "comments": { + "type": "integer" + } + } +} diff --git a/cms/api/discourse/services/discourse.js b/cms/api/community-activity/services/community-activity.js similarity index 100% rename from cms/api/discourse/services/discourse.js rename to cms/api/community-activity/services/community-activity.js diff --git a/cms/api/persona/config/routes.json b/cms/api/counter/config/routes.json similarity index 57% rename from cms/api/persona/config/routes.json rename to cms/api/counter/config/routes.json index 092f1fe5..b428f153 100644 --- a/cms/api/persona/config/routes.json +++ b/cms/api/counter/config/routes.json @@ -2,48 +2,48 @@ "routes": [ { "method": "GET", - "path": "/personas", - "handler": "persona.find", + "path": "/counters", + "handler": "counter.find", "config": { "policies": [] } }, { "method": "GET", - "path": "/personas/count", - "handler": "persona.count", + "path": "/counters/count", + "handler": "counter.count", "config": { "policies": [] } }, { "method": "GET", - "path": "/personas/:id", - "handler": "persona.findOne", + "path": "/counters/:id", + "handler": "counter.findOne", "config": { "policies": [] } }, { "method": "POST", - "path": "/personas", - "handler": "persona.create", + "path": "/counters", + "handler": "counter.create", "config": { "policies": [] } }, { "method": "PUT", - "path": "/personas/:id", - "handler": "persona.update", + "path": "/counters/:id", + "handler": "counter.update", "config": { "policies": [] } }, { "method": "DELETE", - "path": "/personas/:id", - "handler": "persona.delete", + "path": "/counters/:id", + "handler": "counter.delete", "config": { "policies": [] } diff --git a/cms/api/persona-icons/controllers/persona-icons.js b/cms/api/counter/controllers/counter.js similarity index 100% rename from cms/api/persona-icons/controllers/persona-icons.js rename to cms/api/counter/controllers/counter.js diff --git a/cms/api/persona-icons/models/persona-icons.js b/cms/api/counter/models/counter.js similarity index 100% rename from cms/api/persona-icons/models/persona-icons.js rename to cms/api/counter/models/counter.js diff --git a/cms/api/persona/models/persona.settings.json b/cms/api/counter/models/counter.settings.json similarity index 67% rename from cms/api/persona/models/persona.settings.json rename to cms/api/counter/models/counter.settings.json index ee510d39..7f640007 100644 --- a/cms/api/persona/models/persona.settings.json +++ b/cms/api/counter/models/counter.settings.json @@ -1,8 +1,8 @@ { "kind": "collectionType", - "collectionName": "personas", + "collectionName": "counters", "info": { - "name": "Persona", + "name": "Counter", "description": "" }, "options": { @@ -12,11 +12,11 @@ }, "pluginOptions": {}, "attributes": { - "name": { - "type": "string" + "count": { + "type": "integer" }, - "persona_icon": { - "model": "persona-icons" + "title": { + "type": "string" } } } diff --git a/cms/api/persona-icons/services/persona-icons.js b/cms/api/counter/services/counter.js similarity index 100% rename from cms/api/persona-icons/services/persona-icons.js rename to cms/api/counter/services/counter.js diff --git a/cms/api/discourse/models/discourse.settings.json b/cms/api/discourse/models/discourse.settings.json deleted file mode 100644 index 0ad4a21e..00000000 --- a/cms/api/discourse/models/discourse.settings.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "kind": "collectionType", - "collectionName": "discourses", - "info": { - "name": "discourse", - "description": "" - }, - "options": { - "increments": true, - "timestamps": true, - "draftAndPublish": true - }, - "pluginOptions": {}, - "attributes": { - "TopPost": { - "type": "json", - "required": true, - "unique": false - } - } -} diff --git a/cms/api/discourse/config/routes.json b/cms/api/infotile/config/routes.json similarity index 56% rename from cms/api/discourse/config/routes.json rename to cms/api/infotile/config/routes.json index c1828d63..dbb746f3 100644 --- a/cms/api/discourse/config/routes.json +++ b/cms/api/infotile/config/routes.json @@ -2,48 +2,48 @@ "routes": [ { "method": "GET", - "path": "/discourses", - "handler": "discourse.find", + "path": "/infotiles", + "handler": "infotile.find", "config": { "policies": [] } }, { "method": "GET", - "path": "/discourses/count", - "handler": "discourse.count", + "path": "/infotiles/count", + "handler": "infotile.count", "config": { "policies": [] } }, { "method": "GET", - "path": "/discourses/:id", - "handler": "discourse.findOne", + "path": "/infotiles/:id", + "handler": "infotile.findOne", "config": { "policies": [] } }, { "method": "POST", - "path": "/discourses", - "handler": "discourse.create", + "path": "/infotiles", + "handler": "infotile.create", "config": { "policies": [] } }, { "method": "PUT", - "path": "/discourses/:id", - "handler": "discourse.update", + "path": "/infotiles/:id", + "handler": "infotile.update", "config": { "policies": [] } }, { "method": "DELETE", - "path": "/discourses/:id", - "handler": "discourse.delete", + "path": "/infotiles/:id", + "handler": "infotile.delete", "config": { "policies": [] } diff --git a/cms/api/persona/controllers/persona.js b/cms/api/infotile/controllers/infotile.js similarity index 100% rename from cms/api/persona/controllers/persona.js rename to cms/api/infotile/controllers/infotile.js diff --git a/cms/api/persona/models/persona.js b/cms/api/infotile/models/infotile.js similarity index 100% rename from cms/api/persona/models/persona.js rename to cms/api/infotile/models/infotile.js diff --git a/cms/api/persona-icons/models/persona-icons.settings.json b/cms/api/infotile/models/infotile.settings.json similarity index 58% rename from cms/api/persona-icons/models/persona-icons.settings.json rename to cms/api/infotile/models/infotile.settings.json index b4fc3576..b00ba8af 100644 --- a/cms/api/persona-icons/models/persona-icons.settings.json +++ b/cms/api/infotile/models/infotile.settings.json @@ -1,8 +1,8 @@ { "kind": "collectionType", - "collectionName": "persona_icons", + "collectionName": "infotiles", "info": { - "name": "PersonaIcons" + "name": "infotile" }, "options": { "increments": true, @@ -11,14 +11,11 @@ }, "pluginOptions": {}, "attributes": { - "icon": { + "title": { "type": "string" }, - "size": { - "type": "integer" - }, - "color": { - "type": "string" + "description": { + "type": "text" } } } diff --git a/cms/api/persona/services/persona.js b/cms/api/infotile/services/infotile.js similarity index 100% rename from cms/api/persona/services/persona.js rename to cms/api/infotile/services/infotile.js diff --git a/cms/api/persona-icons/config/routes.json b/cms/api/persons/config/routes.json similarity index 54% rename from cms/api/persona-icons/config/routes.json rename to cms/api/persons/config/routes.json index 1407e41e..7002d114 100644 --- a/cms/api/persona-icons/config/routes.json +++ b/cms/api/persons/config/routes.json @@ -2,48 +2,48 @@ "routes": [ { "method": "GET", - "path": "/persona-icons", - "handler": "persona-icons.find", + "path": "/persons", + "handler": "persons.find", "config": { "policies": [] } }, { "method": "GET", - "path": "/persona-icons/count", - "handler": "persona-icons.count", + "path": "/persons/count", + "handler": "persons.count", "config": { "policies": [] } }, { "method": "GET", - "path": "/persona-icons/:id", - "handler": "persona-icons.findOne", + "path": "/persons/:id", + "handler": "persons.findOne", "config": { "policies": [] } }, { "method": "POST", - "path": "/persona-icons", - "handler": "persona-icons.create", + "path": "/persons", + "handler": "persons.create", "config": { "policies": [] } }, { "method": "PUT", - "path": "/persona-icons/:id", - "handler": "persona-icons.update", + "path": "/persons/:id", + "handler": "persons.update", "config": { "policies": [] } }, { "method": "DELETE", - "path": "/persona-icons/:id", - "handler": "persona-icons.delete", + "path": "/persons/:id", + "handler": "persons.delete", "config": { "policies": [] } diff --git a/cms/api/persons/controllers/persons.js b/cms/api/persons/controllers/persons.js new file mode 100644 index 00000000..e8608953 --- /dev/null +++ b/cms/api/persons/controllers/persons.js @@ -0,0 +1,8 @@ +'use strict'; + +/** + * Read the documentation (https://strapi.io/documentation/developer-docs/latest/development/backend-customization.html#core-controllers) + * to customize this controller + */ + +module.exports = {}; diff --git a/cms/api/persons/models/persons.js b/cms/api/persons/models/persons.js new file mode 100644 index 00000000..0054d33c --- /dev/null +++ b/cms/api/persons/models/persons.js @@ -0,0 +1,8 @@ +'use strict'; + +/** + * Read the documentation (https://strapi.io/documentation/developer-docs/latest/development/backend-customization.html#lifecycle-hooks) + * to customize this model + */ + +module.exports = {}; diff --git a/cms/api/persons/models/persons.settings.json b/cms/api/persons/models/persons.settings.json new file mode 100644 index 00000000..f50483a5 --- /dev/null +++ b/cms/api/persons/models/persons.settings.json @@ -0,0 +1,30 @@ +{ + "kind": "collectionType", + "collectionName": "persons", + "info": { + "name": "persons" + }, + "options": { + "increments": true, + "timestamps": true, + "draftAndPublish": true + }, + "pluginOptions": {}, + "attributes": { + "title": { + "type": "string" + }, + "avatar": { + "model": "file", + "via": "related", + "allowedTypes": [ + "images", + "files", + "videos" + ], + "plugin": "upload", + "required": false, + "pluginOptions": {} + } + } +} diff --git a/cms/api/persons/services/persons.js b/cms/api/persons/services/persons.js new file mode 100644 index 00000000..6538a8c8 --- /dev/null +++ b/cms/api/persons/services/persons.js @@ -0,0 +1,8 @@ +'use strict'; + +/** + * Read the documentation (https://strapi.io/documentation/developer-docs/latest/development/backend-customization.html#core-services) + * to customize this service + */ + +module.exports = {}; From d0bae71e1339afab09d022fc90059cace59c233e Mon Sep 17 00:00:00 2001 From: nkpatel23122000 Date: Thu, 17 Feb 2022 12:47:03 +0530 Subject: [PATCH 03/76] removed unused var --- app/components/personcircle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/personcircle.js b/app/components/personcircle.js index 614c7a9c..70041754 100644 --- a/app/components/personcircle.js +++ b/app/components/personcircle.js @@ -1,4 +1,4 @@ -import { Button, ButtonGroup, Col } from "react-bootstrap"; +import { Col } from "react-bootstrap"; import styles from "../styles/Personacircle.module.css"; import {getStrapiURL } from '../lib/api'; export default function Personcircle({persons}) { From a661f44a8d0a348cb6760a898a6edb2c319604d2 Mon Sep 17 00:00:00 2001 From: Sidharth Mohanty Date: Mon, 21 Feb 2022 11:13:40 +0530 Subject: [PATCH 04/76] Add first version of inappchat component for virtual conference (#78) Emoji support with hard coded tokens --- app/.env.local.sample | 6 + app/.gitignore | 3 + app/components/inappchat/inappchat.js | 146 +++++++++++++++++++++++ app/components/inappchat/lib/api.js | 41 +++++++ app/components/inappchat/lib/fuselage.js | 70 +++++++++++ app/package.json | 5 + app/pages/virtualconf/mainstage/[id].js | 71 ++++++++--- app/styles/Inappchat.module.css | 41 +++++++ app/styles/globals.css | 1 + 9 files changed, 366 insertions(+), 18 deletions(-) create mode 100644 app/components/inappchat/inappchat.js create mode 100644 app/components/inappchat/lib/api.js create mode 100644 app/components/inappchat/lib/fuselage.js create mode 100644 app/styles/Inappchat.module.css diff --git a/app/.env.local.sample b/app/.env.local.sample index 7cfbb2f4..4bc903bf 100644 --- a/app/.env.local.sample +++ b/app/.env.local.sample @@ -19,3 +19,9 @@ NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID= # for cookies signing COOKIE_SECRET_CURRENT= COOKIE_SECRET_PREVIOUS= + +# INAPPCHAT +# for development http://localhost:3000 +NEXT_PUBLIC_ROCKET_CHAT_HOST=required +# id of the room where conf will take place +NEXT_PUBLIC_ROCKET_CHAT_CONF_RID=required \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore index 1437c53f..ce59e3e5 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -32,3 +32,6 @@ yarn-error.log* # vercel .vercel + +# lock files +package-lock.json diff --git a/app/components/inappchat/inappchat.js b/app/components/inappchat/inappchat.js new file mode 100644 index 00000000..f0357025 --- /dev/null +++ b/app/components/inappchat/inappchat.js @@ -0,0 +1,146 @@ +import { useEffect, useState } from "react"; +import { getMessages, sendMessage } from "./lib/api"; +import styles from "../../styles/Inappchat.module.css"; +import { + Message, + MessageBody, + MessageContainer, + TextInput, + Icon, + Box, + MessageHeader, + MessageName, + MessageTimestamp, + MessageToolbox, + MessageToolboxItem, + MessageToolboxWrapper, + MessageUsername, +} from "./lib/fuselage"; +import MDPreview from "../mdpreview"; + +const emojify = (message) => { + return joypixels.toImage(message); +}; + +const emojis = [ + { id: 1, value: ":smile:" }, + { id: 2, value: ":thumbsup:" }, + { id: 3, value: ":heart:" }, + { id: 4, value: ":partying_face:" }, +]; + +const InAppChat = ({ closeChat, cookies, rid }) => { + const [message, setMessage] = useState(""); + const [emojiClicked, setEmojiClicked] = useState(false); + const [data, setData] = useState({}); + + useEffect(() => { + async function getData() { + const data = await getMessages(rid, cookies); + setData(data); + } + getData(); + }, []); + + const sendMsg = async (message) => { + if (message.trim() === "") { + return; + } + const msg = await sendMessage(rid, message, cookies); + setMessage(""); + setData({ ...data, messages: [...data.messages, msg.message] }); + }; + + return ( +
+
+ +
+
+ + {cookies.rc_token && cookies.rc_uid ? ( + data && + data?.messages + ?.sort(function (a, b) { + return a.ts < b.ts ? -1 : a.ts > b.ts ? 1 : 0; + }) + .map((m) => ( + + + + {m.u.name} + @{m.u.username} + + {new Date(m.ts).toDateString()} + + + + + + + + + + + + + + + )) + ) : ( +

+ Please login into{" "} + + RocketChat + {" "} + to chat! +

+ )} +
+
+ {emojiClicked && ( +
+ {emojis.map((e) => ( +
{ + setEmojiClicked((prevState) => !prevState); + sendMsg(e.value); + }} + /> + ))} +
+ )} + { + setMessage(e.target.value); + }} + onKeyDown={(e) => { + if (e.keyCode === 13) { + sendMsg(message); + } + }} + addon={ + <> + {message.trim() !== "" ? ( + sendMsg(message)} name="send" size="x20" /> + ) : ( + setEmojiClicked((prevState) => !prevState)} + /> + )} + + } + w={"400px"} + /> +
+ ); +}; + +export default InAppChat; diff --git a/app/components/inappchat/lib/api.js b/app/components/inappchat/lib/api.js new file mode 100644 index 00000000..6cb51ebd --- /dev/null +++ b/app/components/inappchat/lib/api.js @@ -0,0 +1,41 @@ +// using env variables for now, should be replaced with cookies! + +const host = process.env.NEXT_PUBLIC_ROCKET_CHAT_HOST; + +export const getMessages = async (rid, cookies) => { + try { + const messages = await fetch( + `${host}/api/v1/channels.messages?roomId=${rid}`, + { + headers: { + "Content-Type": "application/json", + "X-Auth-Token": cookies.rc_token ?? "", + "X-User-Id": cookies.rc_uid ?? "", + }, + method: "GET", + } + ); + + return await messages.json(); + } catch (err) { + console.log(err.message); + } +}; + +export const sendMessage = async (rid, message, cookies) => { + try { + const msg = await fetch(`${host}/api/v1/chat.sendMessage`, { + body: `{"message": { "rid": "${rid}", "msg": "${message}" }}`, + headers: { + "Content-Type": "application/json", + "X-Auth-Token": cookies.rc_token ?? "", + "X-User-Id": cookies.rc_uid ?? "", + }, + method: "POST", + }); + + return await msg.json(); + } catch (err) { + console.log(err.message); + } +}; diff --git a/app/components/inappchat/lib/fuselage.js b/app/components/inappchat/lib/fuselage.js new file mode 100644 index 00000000..c6334e4d --- /dev/null +++ b/app/components/inappchat/lib/fuselage.js @@ -0,0 +1,70 @@ +import dynamic from "next/dynamic"; + +export const TextInput = dynamic( + () => import("@rocket.chat/fuselage").then((comp) => comp.TextInput), + { ssr: false } +); + +export const Icon = dynamic( + () => import("@rocket.chat/fuselage").then((comp) => comp.Icon), + { ssr: false } +); + +export const Box = dynamic( + () => import("@rocket.chat/fuselage").then((comp) => comp.Box), + { ssr: false } +); + +export const Message = dynamic( + () => import("@rocket.chat/fuselage").then((comp) => comp.Message), + { ssr: false } +); + +export const MessageContainer = dynamic( + () => import("@rocket.chat/fuselage").then((comp) => comp.MessageContainer), + { ssr: false } +); + +export const MessageHeader = dynamic( + () => import("@rocket.chat/fuselage").then((comp) => comp.MessageHeader), + { ssr: false } +); + +export const MessageName = dynamic( + () => import("@rocket.chat/fuselage").then((comp) => comp.MessageName), + { ssr: false } +); + +export const MessageUsername = dynamic( + () => import("@rocket.chat/fuselage").then((comp) => comp.MessageUsername), + { ssr: false } +); + +export const MessageTimestamp = dynamic( + () => import("@rocket.chat/fuselage").then((comp) => comp.MessageTimestamp), + { ssr: false } +); + +export const MessageBody = dynamic( + () => import("@rocket.chat/fuselage").then((comp) => comp.MessageBody), + { ssr: false } +); + +export const MessageToolbox = dynamic( + () => + import("@rocket.chat/fuselage").then( + ({ MessageToolbox }) => MessageToolbox + ), + { ssr: false } +); + +export const MessageToolboxWrapper = dynamic( + () => + import("@rocket.chat/fuselage").then((comp) => comp.MessageToolboxWrapper), + { ssr: false } +); + +export const MessageToolboxItem = dynamic( + () => import("@rocket.chat/fuselage").then((comp) => comp.MessageToolboxItem), + { ssr: false } +); diff --git a/app/package.json b/app/package.json index 5000e20a..6b04d7e9 100644 --- a/app/package.json +++ b/app/package.json @@ -9,6 +9,10 @@ "lint": "next lint" }, "dependencies": { + "@rocket.chat/fuselage": "^0.31.3", + "@rocket.chat/fuselage-hooks": "^0.31.3", + "@rocket.chat/fuselage-polyfills": "^0.31.3", + "@rocket.chat/icons": "^0.31.3", "bootstrap": "^5.1.3", "dompurify": "^2.3.5", "firebase": "^9.6.3", @@ -22,6 +26,7 @@ "react-i18next": "^11.15.3", "react-icons": "^4.3.1", "react-slick": "^0.28.1", + "react-virtuoso": "^1.2.4", "slick-carousel": "^1.8.1" }, "devDependencies": { diff --git a/app/pages/virtualconf/mainstage/[id].js b/app/pages/virtualconf/mainstage/[id].js index 10bbafa9..34d01224 100644 --- a/app/pages/virtualconf/mainstage/[id].js +++ b/app/pages/virtualconf/mainstage/[id].js @@ -1,27 +1,62 @@ import Head from 'next/head'; -import { Container, Col } from "react-bootstrap"; +import Script from 'next/script'; +import { useState } from "react"; +import { Container, Button } from "react-bootstrap"; import Videostreamer from "../../../components/clientsideonly/videostreamer"; +import InAppChat from '../../../components/inappchat/inappchat'; + +const rid = process.env.NEXT_PUBLIC_ROCKET_CHAT_CONF_RID; + +export default function ConfMainStage({ cookies }) { + const [openChat, setOpenChat] = useState(false); + + const handleOpenChat = () => { + setOpenChat((prevState) => !prevState); + }; -export default function ConfMainStage() { return ( <> -
- - Virtual Conference Main Stage - + + Virtual Conference Main Stage + + + +