diff --git a/frontend/react-material-admin/src/components/Layout/Layout.js b/frontend/react-material-admin/src/components/Layout/Layout.js index 6fe06e47..33ce9b2c 100644 --- a/frontend/react-material-admin/src/components/Layout/Layout.js +++ b/frontend/react-material-admin/src/components/Layout/Layout.js @@ -17,6 +17,8 @@ import Sidebar from "../Sidebar"; // pages import Dashboard from "../../pages/dashboard"; import SqueakAddress from "../../pages/squeakaddress"; +import Profile from "../../pages/profile"; +import CreateSigningProfile from "../../pages/createsigningprofile"; import Notifications from "../../pages/notifications"; import Maps from "../../pages/maps"; import Profiles from "../../pages/profiles"; @@ -46,6 +48,8 @@ function Layout(props) { + + { + history.push("/app/profile/" + profileId); + }; + + function handleSubmit(event) { + event.preventDefault(); + console.log( 'profileName:', profileName); + // You should see email and password in console. + // ..code to submit form to backend here... + createSigningProfile(profileName) + } + + const createSigningProfile = (profileName) => { + console.log("called createSigningProfile"); + + var createSigningProfileRequest = new CreateSigningProfileRequest() + createSigningProfileRequest.setProfileName(profileName); + console.log(createSigningProfileRequest); + + client.createSigningProfile(createSigningProfileRequest, {}, (err, response) => { + console.log(response); + console.log(response.getProfileId()); + goToProfilePage(response.getProfileId()); + }); + }; + + return ( + <> + < PageTitle title = "Create Signing Profile" /> + +
+ setProfileName(e.target.value)} + /> + + + +
+); +} diff --git a/frontend/react-material-admin/src/pages/createsigningprofile/package.json b/frontend/react-material-admin/src/pages/createsigningprofile/package.json new file mode 100644 index 00000000..26d35c84 --- /dev/null +++ b/frontend/react-material-admin/src/pages/createsigningprofile/package.json @@ -0,0 +1,6 @@ +{ + "name": "CreateSigningProfile", + "version": "0.0.0", + "main": "CreateSigningProfile.js", + "private": true +} diff --git a/frontend/react-material-admin/src/pages/createsigningprofile/styles.js b/frontend/react-material-admin/src/pages/createsigningprofile/styles.js new file mode 100644 index 00000000..39d05eff --- /dev/null +++ b/frontend/react-material-admin/src/pages/createsigningprofile/styles.js @@ -0,0 +1,21 @@ +import { makeStyles } from "@material-ui/styles"; + +export default makeStyles(theme => ({ + dashedBorder: { + border: "1px dashed", + borderColor: theme.palette.primary.main, + padding: theme.spacing(2), + paddingTop: theme.spacing(4), + paddingBottom: theme.spacing(4), + marginTop: theme.spacing(1), + }, + text: { + marginBottom: theme.spacing(2), + }, + root: { + '& .MuiTextField-root': { + margin: theme.spacing(1), + width: '25ch', + }, +}, +})); diff --git a/frontend/react-material-admin/src/pages/profile/Profile.js b/frontend/react-material-admin/src/pages/profile/Profile.js new file mode 100644 index 00000000..4111d7ce --- /dev/null +++ b/frontend/react-material-admin/src/pages/profile/Profile.js @@ -0,0 +1,62 @@ +import React, { useState, useEffect } from 'react'; +import { useParams } from 'react-router-dom'; +import { Grid } from "@material-ui/core"; + +// styles +import useStyles from "./styles"; + +// components +import PageTitle from "../../components/PageTitle"; +import Widget from "../../components/Widget"; +// import { Typography } from "../../components/Wrappers"; + +import { GetSqueakProfileRequest } from "../../proto/squeak_admin_pb" +import { SqueakAdminClient } from "../../proto/squeak_admin_grpc_web_pb" + +var client = new SqueakAdminClient('http://' + window.location.hostname + ':8080') + +export default function ProfilePage() { + var classes = useStyles(); + const { id } = useParams(); + const [squeakProfile, setSqueakProfile] = useState(null); + + const getSqueakProfile = () => { + console.log("called getSqueakProfile with profileId: " + id); + + var getSqueaksRequest = new GetSqueakProfileRequest() + getSqueaksRequest.setProfileId(id); + console.log(getSqueaksRequest); + + client.getSqueakProfile(getSqueaksRequest, {}, (err, response) => { + console.log(err); + console.log(response); + console.log(response.getSqueakProfile()); + // console.log(response.getSqueakDisplayEntriesList(),length); + setSqueakProfile(response.getSqueakProfile()) + }); + }; + useEffect(()=>{ + getSqueakProfile() + },[]); + + function NoProfileContent() { + return

No profile loaded...

; + } + + function ProfileContent() { + return

{squeakProfile.getProfileName()}

; + } + + return ( + <> + +
+ Hello! + {squeakProfile + ? ProfileContent() + : NoProfileContent() + } +
+ + ); +} diff --git a/frontend/react-material-admin/src/pages/profile/package.json b/frontend/react-material-admin/src/pages/profile/package.json new file mode 100644 index 00000000..baf8166f --- /dev/null +++ b/frontend/react-material-admin/src/pages/profile/package.json @@ -0,0 +1,6 @@ +{ + "name": "Profile", + "version": "0.0.0", + "main": "Profile.js", + "private": true +} diff --git a/frontend/react-material-admin/src/pages/profile/styles.js b/frontend/react-material-admin/src/pages/profile/styles.js new file mode 100644 index 00000000..976accde --- /dev/null +++ b/frontend/react-material-admin/src/pages/profile/styles.js @@ -0,0 +1,15 @@ +import { makeStyles } from "@material-ui/styles"; + +export default makeStyles(theme => ({ + dashedBorder: { + border: "1px dashed", + borderColor: theme.palette.primary.main, + padding: theme.spacing(2), + paddingTop: theme.spacing(4), + paddingBottom: theme.spacing(4), + marginTop: theme.spacing(1), + }, + text: { + marginBottom: theme.spacing(2), + }, +})); diff --git a/frontend/react-material-admin/src/pages/profiles/Profiles.js b/frontend/react-material-admin/src/pages/profiles/Profiles.js index 448ca243..1d96701f 100644 --- a/frontend/react-material-admin/src/pages/profiles/Profiles.js +++ b/frontend/react-material-admin/src/pages/profiles/Profiles.js @@ -1,8 +1,11 @@ -import React, { useState, useEffect } from 'react'; -import { useHistory } from "react-router-dom"; -import { Grid } from "@material-ui/core"; +import React, {useState, useEffect} from 'react'; +import {useHistory} from "react-router-dom"; +import {Grid, Button} from "@material-ui/core"; import MUIDataTable from "mui-datatables"; +// styles +import {makeStyles} from '@material-ui/core/styles'; + // components import PageTitle from "../../components/PageTitle"; import Widget from "../../components/Widget"; @@ -11,127 +14,169 @@ import Table from "../dashboard/components/Table/Table"; // data import mock from "../dashboard/mock"; -import { GetInfoRequest } from "../../proto/lnd_pb" -import { HelloRequest, - GetFollowedSqueakDisplaysRequest, - GetSigningProfilesRequest } from "../../proto/squeak_admin_pb" -import { SqueakAdminClient } from "../../proto/squeak_admin_grpc_web_pb" +import {GetInfoRequest} from "../../proto/lnd_pb" +import {HelloRequest, GetFollowedSqueakDisplaysRequest, GetSigningProfilesRequest} from "../../proto/squeak_admin_pb" +import {SqueakAdminClient} from "../../proto/squeak_admin_grpc_web_pb" var client = new SqueakAdminClient('http://' + window.location.hostname + ':8080') const datatableData = [ - ["Joe James", "Example Inc.", "Yonkers", "NY"], - ["John Walsh", "Example Inc.", "Hartford", "CT"], - ["Bob Herm", "Example Inc.", "Tampa", "FL"], - ["James Houston", "Example Inc.", "Dallas", "TX"], - ["Prabhakar Linwood", "Example Inc.", "Hartford", "CT"], - ["Kaui Ignace", "Example Inc.", "Yonkers", "NY"], - ["Esperanza Susanne", "Example Inc.", "Hartford", "CT"], - ["Christian Birgitte", "Example Inc.", "Tampa", "FL"], - ["Meral Elias", "Example Inc.", "Hartford", "CT"], - ["Deep Pau", "Example Inc.", "Yonkers", "NY"], - ["Sebastiana Hani", "Example Inc.", "Dallas", "TX"], - ["Marciano Oihana", "Example Inc.", "Yonkers", "NY"], - ["Brigid Ankur", "Example Inc.", "Dallas", "TX"], - ["Anna Siranush", "Example Inc.", "Yonkers", "NY"], - ["Avram Sylva", "Example Inc.", "Hartford", "CT"], - ["Serafima Babatunde", "Example Inc.", "Tampa", "FL"], - ["Gaston Festus", "Example Inc.", "Tampa", "FL"], + [ + "Joe James", "Example Inc.", "Yonkers", "NY" + ], + [ + "John Walsh", "Example Inc.", "Hartford", "CT" + ], + [ + "Bob Herm", "Example Inc.", "Tampa", "FL" + ], + [ + "James Houston", "Example Inc.", "Dallas", "TX" + ], + [ + "Prabhakar Linwood", "Example Inc.", "Hartford", "CT" + ], + [ + "Kaui Ignace", "Example Inc.", "Yonkers", "NY" + ], + [ + "Esperanza Susanne", "Example Inc.", "Hartford", "CT" + ], + [ + "Christian Birgitte", "Example Inc.", "Tampa", "FL" + ], + [ + "Meral Elias", "Example Inc.", "Hartford", "CT" + ], + [ + "Deep Pau", "Example Inc.", "Yonkers", "NY" + ], + [ + "Sebastiana Hani", "Example Inc.", "Dallas", "TX" + ], + [ + "Marciano Oihana", "Example Inc.", "Yonkers", "NY" + ], + [ + "Brigid Ankur", "Example Inc.", "Dallas", "TX" + ], + [ + "Anna Siranush", "Example Inc.", "Yonkers", "NY" + ], + [ + "Avram Sylva", "Example Inc.", "Hartford", "CT" + ], + [ + "Serafima Babatunde", "Example Inc.", "Tampa", "FL" + ], + [ + "Gaston Festus", "Example Inc.", "Tampa", "FL" + ] ]; +const useStyles = makeStyles((theme) => ({ + root: { + '& > *': { + margin: theme.spacing(1) + } + } +})); + export default function Profiles() { + const classes = useStyles(); + const [msg, setMsg] = useState("waiting for message..."); const [squeaks, setSqueaks] = useState([]); const [signingProfiles, setSigningProfiles] = useState([]); const history = useHistory(); const getMsg = () => { - console.log("called getMsg"); + console.log("called getMsg"); - var helloRequest = new HelloRequest() - helloRequest.setName('World'); + var helloRequest = new HelloRequest() + helloRequest.setName('World'); - client.sayHello(helloRequest, {}, (err, response) => { - console.log(response.getMessage()); - setMsg(response.getMessage()) - }); + client.sayHello(helloRequest, {}, (err, response) => { + console.log(response.getMessage()); + setMsg(response.getMessage()) + }); }; const getSqueaks = () => { - console.log("called getSqueaks"); + console.log("called getSqueaks"); - var getSqueaksRequest = new GetFollowedSqueakDisplaysRequest() + var getSqueaksRequest = new GetFollowedSqueakDisplaysRequest() - client.getFollowedSqueakDisplays(getSqueaksRequest, {}, (err, response) => { - console.log(response); - console.log(response.getSqueakDisplayEntriesList()); - // console.log(response.getSqueakDisplayEntriesList(),length); - setSqueaks(response.getSqueakDisplayEntriesList()) - }); + client.getFollowedSqueakDisplays(getSqueaksRequest, {}, (err, response) => { + console.log(response); + console.log(response.getSqueakDisplayEntriesList()); + // console.log(response.getSqueakDisplayEntriesList(),length); + setSqueaks(response.getSqueakDisplayEntriesList()) + }); }; const getLndInfo = () => { - console.log("called getLndInfo"); + console.log("called getLndInfo"); - var getInfoRequest = new GetInfoRequest() + var getInfoRequest = new GetInfoRequest() - client.lndGetInfo(getInfoRequest, {}, (err, response) => { - console.log(response); - }); + client.lndGetInfo(getInfoRequest, {}, (err, response) => { + console.log(response); + }); }; const getSigningProfiles = () => { - console.log("called getSigningProfiles"); + console.log("called getSigningProfiles"); - var getSigningProfilesRequest = new GetSigningProfilesRequest() + var getSigningProfilesRequest = new GetSigningProfilesRequest() - client.getSigningProfiles(getSigningProfilesRequest, {}, (err, response) => { - console.log(response); - var signingProfileRows = response.getSqueakProfilesList().map(p => - [ - p.getProfileName(), - p.getAddress(), - p.getFollowing().toString(), - p.getSharing().toString(), - ] - ); - setSigningProfiles(signingProfileRows); - }); + client.getSigningProfiles(getSigningProfilesRequest, {}, (err, response) => { + console.log(response); + var signingProfileRows = response.getSqueakProfilesList().map(p => [p.getProfileName(), p.getAddress(), p.getFollowing().toString(), p.getSharing().toString()]); + setSigningProfiles(signingProfileRows); + }); }; - useEffect(()=>{ - getMsg() - },[]); - useEffect(()=>{ - getSqueaks() - },[]); - useEffect(()=>{ - getLndInfo() - },[]); - useEffect(()=>{ - getSigningProfiles() - },[]); - return ( - <> - - - - { - console.log(rowData); - var address = rowData[1]; - console.log(address); - history.push("/app/squeakaddress/" + address); - }, - }} - /> - - - - ); + const goToCreateSigningProfilePage = () => { + history.push("/app/createsigningprofile"); + }; + + const goToSqueakAddressPage = (squeakAddress) => { + history.push("/app/squeakaddress/" + squeakAddress); + }; + + useEffect(() => { + getMsg() + }, []); + useEffect(() => { + getSqueaks() + }, []); + useEffect(() => { + getLndInfo() + }, []); + useEffect(() => { + getSigningProfiles() + }, []); + + return (<> < PageTitle title = "Profiles" /> + +
+ + +
+
+ + { + var address = rowData[1]; + goToSqueakAddressPage(address); + } + }}/> + +
< />); } diff --git a/frontend/react-material-admin/src/pages/squeakaddress/SqueakAddress.js b/frontend/react-material-admin/src/pages/squeakaddress/SqueakAddress.js index 60a27ad6..aa2068d3 100644 --- a/frontend/react-material-admin/src/pages/squeakaddress/SqueakAddress.js +++ b/frontend/react-material-admin/src/pages/squeakaddress/SqueakAddress.js @@ -41,12 +41,10 @@ export default function SqueakAddressPage() { return ( <> -
Hello! Number of squeaks for address: {squeaks.length}
-
); }