From 53326b97ee166c8dde2dde875669c0f713667724 Mon Sep 17 00:00:00 2001 From: rgao Date: Sun, 29 Mar 2020 01:46:26 -0700 Subject: [PATCH 01/24] implemented frontend for contacts page --- package.json | 1 + server/src/app.py | 12 ++++ server/src/services/githubRequest.py | 33 ++++++++++ src/components/contact/Contact.jsx | 11 +++- src/components/contact/ContactForm.jsx | 80 +++++++++++++++++++++++++ src/components/contact/ContactImage.jsx | 11 ++++ src/components/contact/ContactIntro.jsx | 14 +++++ src/styles/contact/_contact.scss | 7 +++ src/styles/contact/_contactform.scss | 67 +++++++++++++++++++++ src/styles/contact/_contactimage.scss | 24 ++++++++ src/styles/contact/_contactintro.scss | 17 ++++++ src/styles/styles.scss | 5 ++ 12 files changed, 280 insertions(+), 2 deletions(-) create mode 100644 server/src/services/githubRequest.py create mode 100644 src/components/contact/ContactForm.jsx create mode 100644 src/components/contact/ContactImage.jsx create mode 100644 src/components/contact/ContactIntro.jsx create mode 100644 src/styles/contact/_contact.scss create mode 100644 src/styles/contact/_contactform.scss create mode 100644 src/styles/contact/_contactimage.scss create mode 100644 src/styles/contact/_contactintro.scss diff --git a/package.json b/package.json index 53ff31a92..953c57fc7 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "dotenv": "^8.2.0", "dotenv-webpack": "^1.7.0", "eslint-import-resolver-webpack": "^0.12.1", + "express": "^4.17.1", "gh-pages": "^2.1.1", "html-webpack-plugin": "^3.2.0", "html2canvas": "^1.0.0-rc.5", diff --git a/server/src/app.py b/server/src/app.py index 8f4ca68b9..781b0a7e6 100644 --- a/server/src/app.py +++ b/server/src/app.py @@ -15,6 +15,7 @@ from services.requestDetailService import RequestDetailService from services.ingress_service import ingress_service from services.sqlIngest import DataHandler +from services.githubRequest import GithubService app = Sanic(__name__) CORS(app) @@ -180,6 +181,17 @@ async def requestDetails(request, srnumber): return json(return_data) +@app.route('/githubrequest', methods=["GET", "POST"]) +async def githubrequest(request): + github_worker = GithubService(app.config['Settings']) + + data = await github_worker.create_issue(title='test', + body='test', + assignee='', + labels=[]) + return json(data) + + @app.route('/test_multiple_workers') @compress.compress() async def test_multiple_workers(request): diff --git a/server/src/services/githubRequest.py b/server/src/services/githubRequest.py new file mode 100644 index 000000000..de7e0e91d --- /dev/null +++ b/server/src/services/githubRequest.py @@ -0,0 +1,33 @@ +import json +import requests + + +class GithubService(object): + def __init__(self, config=None): + self.config = config + self.username = None if not self.config \ + else self.config['Authentication']['USERNAME'] + self.password = None if not self.config \ + else self.config['Authentication']['PASSWORD'] + pass + + def create_issue(self, title, body=None, assignee=None, + milestone=None, labels=None): + '''Create an issue on github.com using the given parameters.''' + # Our url to create issues via POST + url = 'https://api.github.com/repos/rgao/python_course/issues' + # Create an authenticated session to create the issue + s = requests.Session() + s.auth = requests.auth.HTTPDigestAuth(self.username, self.password) + # Create our issue + issue = {'title': title, + 'body': body, + 'assignee': assignee, + 'labels': labels} + + r = s.post(url, json.dumps(issue)) + if r.status_code == 201: + print('Successfully created Issue "%s"') % title + else: + print('Could not create Issue') + print('Response:', r.content) diff --git a/src/components/contact/Contact.jsx b/src/components/contact/Contact.jsx index 8244e52a0..7f4be40ab 100644 --- a/src/components/contact/Contact.jsx +++ b/src/components/contact/Contact.jsx @@ -1,8 +1,15 @@ import React from 'react'; +import ContactImage from './ContactImage'; +import ContactIntro from './ContactIntro'; +import ContactForm from './ContactForm'; + +// uncomment About and remove slice limit from Pin map const Contact = () => ( -
- Contact +
+ + +
); diff --git a/src/components/contact/ContactForm.jsx b/src/components/contact/ContactForm.jsx new file mode 100644 index 000000000..726e701f2 --- /dev/null +++ b/src/components/contact/ContactForm.jsx @@ -0,0 +1,80 @@ +import React, { Component } from 'react'; +import axios from 'axios'; + +class ContactForm extends Component { + constructor(props) { + super(props); + this.state = { + firstName: '', + lastName: '', + email: '', + association: '', + message: '', + error_message: '', + }; + }; + + +render() { + return( +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +