Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update with react memo #74

Merged
merged 8 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DirectReport/browserview/dashboard/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def dashboard_reports_saved():
@bp.route("/reports/new", methods=['GET', 'POST'])
@login_required
def dashboard_reports_new():
return render_template('team/teamreport.html', title='Team Report', data=[])
return render_template('team/team_report.html', title='Team Report', data=[])


@bp.route("/reports/<uid>", methods=['GET'])
Expand Down
19 changes: 1 addition & 18 deletions DirectReport/browserview/main/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from flask_login import current_user
from DirectReport.models.user_model import UserModel
from DirectReport.browserview.main import bp
from DirectReport.browserview.services.github import GithubClient
from DirectReport.datadependencies import appsecrets


Expand Down Expand Up @@ -61,20 +60,4 @@ def ouath2_callback():
user_info = json_data["user"]
user_model = UserModel()
user_model.update_github_username(current_user.email, user_info["login"])
return render_template('team/teamreport.html', title='Team', data=[])


@bp.route("/team", methods=['GET'])
def team():
return render_template('team/team.html', title='Team', data=[])


@bp.route("/repo/<reponame>", methods=['GET'])
def repo(reponame=None):
client = GithubClient()
repo = []
try:
repo = client.get_repo_issues(current_user.github_username, reponame)
except Exception as e:
print(e)
return render_template('team/team.html', title='Team', data=repo)
return render_template('team/team_report.html', title='Team', data=[])
17 changes: 14 additions & 3 deletions DirectReport/browserview/static/js/account/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const Account = () => {
const [error, setError] = useState(null);

useEffect(() => {
document.getElementById('AuthSpinnerUI').classList.toggle("hidden");
fetch('/api/account_data')
.then((response) => {
if (!response.ok) {
Expand All @@ -23,17 +24,27 @@ const Account = () => {
setError(null);
})
.catch((err) => {
setUserData(null)
setReportData(null)
setUserData(null);
setReportData(null);
setError(err.message);
})
.finally(() => {
setLoading(false);
document.getElementById('AuthSpinnerUI').classList.toggle("hidden");
});
}, []);

if (loading) {
return (
<div>{`There is a problem fetching the post data - ${error}`}</div>
<div className="my-50 py-20">
<div className="py-10 mt-20">
<AuthSpinnerUI/>
</div>
<div className="mx-0 min-w-full flex flex-col items-center">
<div className="mt-10 py-10">{`There is a problem fetching the post data - ${error}`}</div>
<div className="mt-20 py-20"></div>
</div>
</div>
)
} else {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ const AccountUserInfo = (userData, reportData) => {
</l>
</ul>
</div>


<div className="rounded-2xl flex items-center justify-center pb-2">
<button className="bg-blue-600 hover:bg-slate-100 self-center text-white font-mono tracking-wide shadow-[1.5px_2px_1.0px_0.7px_rgba(0,0,0,0.48)] hover:white hover:text-blue-500 hover:border-gray-200 text-lg font-bold py-3 px-10 rounded-3xl mt-4 mb-6" type="button">
<svg xmlns="http://www.w3.org/2000/svg" className="h-7 w-6 inline-block ml-20" fill="currentColor" viewBox="0 0 24 24">
Expand All @@ -85,4 +83,5 @@ const AccountUserInfo = (userData, reportData) => {
</div>
</div>
)
}
}

6 changes: 3 additions & 3 deletions DirectReport/browserview/static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ class Home extends React.Component {
React.createElement(
'div',
{
className: "pt-20 pb-20 flex h-50",
className: "pt-5 pb-10 flex h-30",
style: {background: "linear-gradient(90deg, #667eea 0%, #764ba2 100%)"}
},
React.createElement(
"div",
{
className: "container mx-auto px-6"
className: "container mx-10 px-10 py-10"
},
React.createElement(
"h2",
{
className: "text-3xl font-bold mb-3 text-white"
className: "text-2xl font-bold mb-3 text-white"
},
"DirectReport."
),
Expand Down
64 changes: 64 additions & 0 deletions DirectReport/browserview/static/js/main_components.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const { useState, useEffect, memo } = React;

const SpinnerUI = () => {
return (
<div className="hidden rounded-2xl col-span-1" id="AuthSpinnerUI" style={{zIndex: 100}}>
<div>
<div role="status" className="mx-0 min-w-full flex flex-col items-center">
<div>
<svg aria-hidden="true" className="w-10 h-10 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"/>
</svg>
<span className="sr-only">Loading...</span>
</div>
</div>
</div>
</div>
)
}


const closeRepoPopover = () => {
document.getElementById('popover-repo-left-purple').classList.toggle("hidden");
}

const closePopover = () => {
document.getElementById('popover-id-left-purple').classList.toggle("hidden");
}

const GraphElement = (title, id, mapcontainer_id) => {
return (
<div>
<h1 id="title_element" className="self-center text-center text-white text-lg text-center font-bold font-mono mb-1 mt-3 py-2">{title}</h1>
<div className="lg:col-span-1 sm:col-span-3 justify-center mt-7 mb-7 bg-white shadow-[1.0px_1.0px_6.0px_0.0px_rgba(0,0,0,0.58)] rounded-3xl px-10 ml-5" id={id}>
<div className="flex justify-center my-2 px-3" id="data_display_div">
<div id={mapcontainer_id} className="pl-2 pr-2 rounded-3xl"></div>
</div>
</div>
</div>
)
}


const GraphDiv = () => {
return (
<div className="grid grid-cols-3 gap-10 mt-5 mx-20 bg-blue-600 shadow-[1.0px_1.0px_5.0px_0.0px_rgba(0,0,0,0.58)] rounded-3xl px-5 py-3">
{GraphElement("Number of Pull Requests", "dd", "map-container")}
{GraphElement("Commits Over Times", "dd", "map-container2")}
{GraphElement("Broad Areas of Work", "dd", "map-container3")}
</div>
)
}

const GraphicsUI = memo(function Graphics() {
return (
<div>
<h3 className="text-xl text-blue-800 font-mono font-semibold mt-10 mb-8 mx-10 px-12">Graphic Data</h3>
<GraphDiv/>
</div>
)
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
'use strict';

const {useState, useCallback, useEffect} = React;
const {useState, useCallback, useEffect, memo} = React;


const ShowSpinner = () => {
return (
<div className="my-50 py-20">
<div className="py-10 mt-20">
<SpinnerUI/>
</div>
<div className="mx-0 min-w-full flex flex-col items-center">
<div className="mt-10 py-10">There is a problem fetching the post data</div>
<div className="mt-20 py-20"></div>
</div>
</div>
)
}



class TeamReport extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -146,16 +163,15 @@ class TeamReport extends React.Component {
};

render() {

return (
<div id>
<h1 id="h1content" className="self-center text-center text-2xl text-blue-800 text-center font-bold font-mono pt-10 mb-10 pt-8 mx-30 px-20">Generate Team Report From Metadata</h1>
{repoPopoverUI()}
{spinnerUI()}
{RepoPopoverUI()}
{SpinnerUI()}
<div id="topRow" className="grid grid-cols-3 gap-10 rounded-3xl mx-20 mt-6">
{EditSummaryElem({"repos": this.state.repos, "commits": this.state.commits}, this.state, this.openRepoPopover)}
{SummarySection(this.state.reportData)}
{TeamSection(this.state.teamData, this.closePopover)}
<EditSummaryElem props={{"repos": this.state.repos, "commits": this.state.commits, "state": this.state, "openRepoPopover": this.openRepoPopover}} />
<SummarySection reportData={this.state.reportData}/>
<TeamSection props={{"teamData": this.state.teamData, "closePopover": this.closePopover}} />
</div>
{this.state.commits.length <= 0 && (
<div id="padding-content" className="pb-[340px] h-10">
Expand Down
Loading
Loading