-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
AlixH
committed
Feb 17, 2020
1 parent
27251ae
commit 3907d64
Showing
13 changed files
with
487 additions
and
515 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,63 @@ | ||
import React from 'react'; | ||
import React, {useEffect} from 'react'; | ||
import './style.css'; | ||
|
||
import Plugin from "../Plugin/Plugin"; | ||
import {useDispatch, useStore} from "react-redux"; | ||
import {useDispatch, useSelector} from "react-redux"; | ||
import {SET_PLUGIN_LIST} from "../../store/actions/PluginList"; | ||
import Plugin from "../Plugin/Plugin"; | ||
import shallowEqual from "react-redux/lib/utils/shallowEqual"; | ||
import NavBar from "../Navbar/Navbar"; | ||
|
||
|
||
function Home(properties) { | ||
|
||
const url = "http://localhost:4000/plugins"; | ||
const fetchDetails = { | ||
method: 'get', | ||
mode: 'cors', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json' | ||
} | ||
}; | ||
function fetchPlugins() { | ||
const response = await fetch(url, fetchDetails); | ||
return await response.json(); | ||
} | ||
async function Home(properties){ | ||
//on render, fetch the list of all plugins | ||
const plugins = fetchPlugins().then(); | ||
const dispatch = useDispatch(); | ||
dispatch({ | ||
type:SET_PLUGIN_LIST, | ||
list:plugins | ||
const pluginsList = useSelector(state => state.pluginListReducer.pluginsList, shallowEqual); | ||
|
||
async function fetchPlugins() { | ||
|
||
const url = "http://localhost:4000/plugins"; | ||
const fetchDetails = { | ||
method: 'get', | ||
mode: 'cors', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json' | ||
} | ||
}; | ||
try { | ||
let response = await fetch(url, fetchDetails); | ||
if (!response || response.status !== 200) { | ||
console.error("Error while fetching from server") | ||
} else { | ||
response = await response.json(); | ||
if (response && response.data && response.data.plugins) { | ||
dispatch({ | ||
type: SET_PLUGIN_LIST, | ||
pluginsList: response.data.plugins | ||
}); | ||
} | ||
} | ||
} catch (e) { | ||
console.error(e); | ||
|
||
} | ||
} | ||
|
||
useEffect(() => { | ||
fetchPlugins(); | ||
}, []); | ||
|
||
let list = (pluginsList || []).map(plugin => { | ||
return <Plugin plugin={plugin}/> | ||
}); | ||
//let pluginList = plugins.data.plugins.map(plugin => { | ||
//return <Plugin />}); | ||
|
||
return ( | ||
<div> | ||
<p>Hello from Home !</p> | ||
<div id={"page"}> | ||
<NavBar/> | ||
<div id={"list"}> | ||
{list} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default Home |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#list{ | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: wrap; | ||
width: 80%; | ||
justify-content: space-evenly; | ||
} | ||
|
||
#page{ | ||
background-color: white; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.nav-bar{ | ||
background-color: black; | ||
height: 7%; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// eslint-disable-file no-unused-vars | ||
import React from 'react'; | ||
import "./NavBar.css"; | ||
import AppBar from "@material-ui/core/AppBar"; | ||
import Tabs from "@material-ui/core/Tabs"; | ||
|
||
const PluginModel = require("../../model/plugin-model"); | ||
|
||
|
||
function NavBar(properties) { | ||
// let plugin = new PluginModel(...properties.plugin); | ||
return ( | ||
<div > | ||
<AppBar className={"nav-bar"} style={{backgroundColor : "#69585F"}} position="fixed"> | ||
<Tabs | ||
variant="fullWidth" | ||
aria-label="nav tabs example" | ||
> | ||
</Tabs> | ||
</AppBar> | ||
</div> | ||
|
||
) | ||
} | ||
|
||
export default NavBar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,44 @@ | ||
#plugin-preview{ | ||
.plugin_preview{ | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
width: 100%; | ||
} | ||
img{ | ||
width: 80%; | ||
} | ||
|
||
.tags{ | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
justify-content: flex-start; | ||
width: 100%; | ||
} | ||
|
||
.tag{ | ||
margin-right: 2%; | ||
} | ||
|
||
.plugin{ | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
h2, h1{ | ||
color: #69585F; | ||
font-family: "Calibri Light"; | ||
} | ||
|
||
h1{ | ||
font-weight: bolder; | ||
} | ||
|
||
.card{ | ||
width: 30%; | ||
min-width: 400px; | ||
margin-bottom: 3%; | ||
color: #69585F; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const SET_PLUGIN_LIST = "SET_PLUGIN_LIST"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {SET_PLUGIN_LIST} from "../actions/PluginList"; | ||
|
||
const defaultState = {pluginsList:[]}; | ||
|
||
const pluginListReducer = (state = defaultState, action) => { | ||
if (action.type === SET_PLUGIN_LIST) { | ||
return {...state, pluginsList:action.pluginsList}; | ||
} else { | ||
return state; | ||
} | ||
}; | ||
export default pluginListReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.