diff --git a/backend_app/app.py b/backend_app/app.py index 8c19963..207d0b6 100644 --- a/backend_app/app.py +++ b/backend_app/app.py @@ -3,6 +3,8 @@ from backend_app.request_handler import RequestHandler from backend_app import view from backend_app.resources import get_resource +from flask_cors import CORS, cross_origin + with open(get_resource('idp.yml')) as c_file: RequestHandler.idp_repo = yaml.safe_load(c_file) @@ -12,10 +14,13 @@ app = Flask(__name__, template_folder=get_resource('templates'), - static_folder=get_resource('static')) - + static_folder=get_resource('static'), + ) +CORS(app) app.register_blueprint(view.view) if __name__ == '__main__': app.debug = True - app.run() + app.run( + use_reloader=False + ) diff --git a/react_app/src/components/AssertionCard.js b/react_app/src/components/AssertionCard.js new file mode 100644 index 0000000..48f8b9c --- /dev/null +++ b/react_app/src/components/AssertionCard.js @@ -0,0 +1,67 @@ +import React from "react"; +import "../index.css"; + +function AssertionCard(props) { + + if (props.res.assertion_attributes) { + let link = props.res.assertion_attributes.errors_found.link; + let description = props.res.assertion_attributes.description; + let keyArr = []; + let values = props.res.assertion_attributes.value; + for (let key in values) { + if(values.hasOwnProperty(key)) { + keyArr.push(key) + } + } + const assertKeys = keyArr.map((key) => +
  • {key} : {values[key]}
  • + ); + + if (props.res.assertion_attributes.errors_found) { + let errors = props.res.assertion_attributes.errors_found; + let errorArr = []; + for (let key in errors) { + if (errors.hasOwnProperty(key)) { + errorArr.push(key) + } + } + const assertErrors = errorArr.map((key) => +
  • {errors[key]}
  • + ) + + return ( +
    +
    +
    Assertion Attributes
    +

    {description}

    +

    {assertKeys}

    +

    {assertErrors}

    + {link} +
    +
    + ); + } + + return ( +
    +
    +
    Assertion Attributes
    +

    {description}

    +

    {assertKeys}

    + {link} +
    +
    + ); + } else { + return( +
    + +
    + ) + } + + + +} + +export default AssertionCard; \ No newline at end of file diff --git a/react_app/src/components/DestinationCard.js b/react_app/src/components/DestinationCard.js new file mode 100644 index 0000000..0a0ee62 --- /dev/null +++ b/react_app/src/components/DestinationCard.js @@ -0,0 +1,37 @@ +import React from "react"; +import "../index.css"; + +function DestinationCard(props) { + // console.log("Destination Card") + // console.log(props.res.destination) + if (props.res.destination) { + return ( +
    +
    + + + Attribute + Value + Message + + + + + {props.res.destination.description} + {props.res.destination.value} + + +
    +
    + ); + } else { + return( +
    + +
    + ) + } + +} + +export default DestinationCard; \ No newline at end of file diff --git a/react_app/src/components/ErrorTable.js b/react_app/src/components/ErrorTable.js new file mode 100644 index 0000000..2def33e --- /dev/null +++ b/react_app/src/components/ErrorTable.js @@ -0,0 +1,28 @@ +import React from "react"; +import "../index.css"; + +function ErrorTable(props) { + return ( +
    +
    + + + Attribute + Value + Message + + + + + {props.description} + {props.hint} + {props.link} + + +
    +
    + ); + +} + +export default ErrorTable; \ No newline at end of file diff --git a/react_app/src/components/Form.js b/react_app/src/components/Form.js index 3565e36..e2d2d3e 100644 --- a/react_app/src/components/Form.js +++ b/react_app/src/components/Form.js @@ -1,51 +1,151 @@ -import React, { Component } from "react"; +import React, { Component } from 'react'; import "../index.css"; +import axios from "axios"; +import Table from "../components/Table"; +import MappedCard from "../components/MappedCard"; +import DestinationCard from "./DestinationCard"; +import AssertionCard from "./AssertionCard"; class Form extends Component { - render() { - return ( -
    -
    -
    -
    -
    -
    - Upload -
    -
    - - + + state = { + saml_file: null, + idp_name: "", + data: [], + // description: "" + } + + handleInputChange = event => { + const { name, value } = event.target; + this.setState({ + [name]: value + }); + } + + handleFile(e) { + let file = e.target.files[0]; + this.setState({file: file}) + } + + handleUpload(e) { + let file = this.state.file; + let idp_name = this.state.idp_name; + let formdata = new FormData(); + formdata.append('saml_file', file); + formdata.append('idp_name', idp_name); + + axios({ + url: "/upload", + method: "POST", + data: formdata + }).then((res)=> { + if (res.data) { + // res.data[0] = + this.setState({data: res.data}) + + // console.log("ARR BELOW") + // console.log(arr) + // Object.entries(this.state.data).map(([key, value]) =>{ + // return( + //
    {key} : {value}
    + // ) + // }) + } + }, (err)=> { + console.log(err) + }) + } + + render() { + let keyArr = []; + let errorArr = []; + let jsonData = this.state.data; + + for (let key in jsonData) { + if (jsonData.hasOwnProperty(key) && key !== "assertion_attributes" && !("errors_found" in jsonData[key])) { + keyArr.push(key); + } else if (jsonData.hasOwnProperty(key) && key !== "assertion_attributes" && ("errors_found" in jsonData[key])) { + errorArr.push(key); + } + } + const mappedKeys = keyArr.map((key) => +
    +
    +
    {key}
    +

    {jsonData[key].description}

    +

    {jsonData[key].value}

    -
    -
    - + ); + const errorKeys = errorArr.map((key) => +
    +
    +
    {key}
    +

    {jsonData[key].description}

    +

    {jsonData[key].value}

    +

    {jsonData[key].errors_found.description}

    +

    {jsonData[key].errors_found.hint}

    + {jsonData[key].errors_found.link} +
    -
    - + ); + + + return ( +
    + +
    +
    +
    +
    + XML +
    +
    + this.handleFile(e)} + /> + + +
    +
    +
    + +
    + +
    +
    + +
    + + {/**/} +
  • {errorKeys}
  • +
  • {mappedKeys}
  • + + {/*
  • {arr.map(item => )}
  • */} + {/*{arr.map(item =>
    )}
    */} +
    +
    -
    - -
    - ); - } + ) + } } export default Form; \ No newline at end of file diff --git a/react_app/src/components/MappedCard.js b/react_app/src/components/MappedCard.js new file mode 100644 index 0000000..793d7c5 --- /dev/null +++ b/react_app/src/components/MappedCard.js @@ -0,0 +1,39 @@ +// import React from "react"; +// import "../index.css"; +// +// function MappedCard(props) { +// if(props.res) { +// +// let description = "" +// let keyArr = []; +// let jsonData = props.res +// +// for (let key in jsonData) { +// console.log(key); +// if (jsonData.hasOwnProperty(key) && key !== "assertion_attributes") { +// console.log("KEY BELOW"); +// console.log(key); +// keyArr.push(key); +// } +// } +// const mappedKeys = keyArr.map((key) => +//
  • {key} : {jsonData[key].description} &&& {jsonData[key].value}
  • +// ); +// +// return ( +//
    +//
    +//
    Assertion Attributes
    +//

    {description}

    +//

    {mappedKeys}

    +//
    +//
    +// ) +// } +// } +// +// +// +// +// +// export default MappedCard; \ No newline at end of file diff --git a/react_app/src/components/Table.js b/react_app/src/components/Table.js index b07b660..2c82813 100644 --- a/react_app/src/components/Table.js +++ b/react_app/src/components/Table.js @@ -1,12 +1,12 @@ import React from "react"; import "../index.css"; -class Table extends React.Component { - render() { +function Table(props) { return (
    - +
  • {props.description + " === " + props.value}
  • + @@ -16,41 +16,14 @@ class Table extends React.Component { - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + -
    Attribute
    FirstNameSamwell
    LastNameTarly
    Emailbigsammyt@hotmail.bizEmail 'bigsammyt@hotmail.biz' does not match user
    Larrythe Bird@twitter
    Larrythe Bird@twitter
    Larrythe Bird@twitter{props.description}{props.value}
    ); - } + } export default Table; \ No newline at end of file diff --git a/react_app/src/index.css b/react_app/src/index.css index 40cda8d..22128cb 100644 --- a/react_app/src/index.css +++ b/react_app/src/index.css @@ -1,9 +1,10 @@ body { - background-color: rgb(32, 32, 32); + /*background-color: rgb(32, 32, 32);*/ + background-color: white; + } h1 { - color: white; text-align: center; margin-top: 50px; } @@ -39,7 +40,8 @@ table { margin-top: 50px; } thead { - background-color: #ffc107; + /*background-color: #ffc107;*/ + background-color: white; border: none; } @@ -58,4 +60,19 @@ thead { .small-form { width: 400px; +} + +.error-title { + color: red; +} +.card { + width: 18rem; +} + +.error-card { + border: red 1px solid; +} + +li { + list-style-type: none; } \ No newline at end of file diff --git a/react_app/src/pages/Home.js b/react_app/src/pages/Home.js index 0d5c10c..57233bd 100644 --- a/react_app/src/pages/Home.js +++ b/react_app/src/pages/Home.js @@ -2,14 +2,15 @@ import React, { Component } from "react"; import Form from "../components/Form" import Title from "../components/Title"; import PracticeForm from "../components/PracticeForm"; +import Table from "../components/Table" +import MappedCard from "../components/MappedCard"; class Home extends Component { render() { return (
    - {/*<Form />*/} - <PracticeForm /> + <Form /> </div> ) } diff --git a/react_app/src/pages/NoMatch.js b/react_app/src/pages/NoMatch.js index 6b6dddb..b0ccc7d 100644 --- a/react_app/src/pages/NoMatch.js +++ b/react_app/src/pages/NoMatch.js @@ -5,7 +5,7 @@ class NoMatch extends Component { render() { return ( <div className={'container'}> - <h1>No Match Found</h1> + <h1>Page Not Found</h1> </div> ); } diff --git a/react_app/src/utils/API.js b/react_app/src/utils/API.js index 57df48f..e69de29 100644 --- a/react_app/src/utils/API.js +++ b/react_app/src/utils/API.js @@ -1,11 +0,0 @@ -import axios from "axios"; -require("dotenv").config(); - -export default { - addStuff: function (data) { - console.log('data is'); - console.log(data); - return axios.post("/api/data", data); - } - -} \ No newline at end of file