diff --git a/DirectReport/browserview/dashboard/routes.py b/DirectReport/browserview/dashboard/routes.py index 7ee46931..5d74c28c 100644 --- a/DirectReport/browserview/dashboard/routes.py +++ b/DirectReport/browserview/dashboard/routes.py @@ -37,7 +37,7 @@ def dashboard_reports_saved(): :return: Rendered HTML template for the list page. """ - results = requests.get('/api/reports/list') + results = requests.get('http://127.0.0.1:5000/api/reports/list') return render_template('list.html', title='List', data=results) @@ -76,6 +76,7 @@ def dashboard_reports_update(): repo_data.append(repo["name"]) raw_data = team_summary_from_shortlog(prompt)["choices"][0]["message"]["content"] response_data = json.loads(raw_data) + print(response_data) response_data["commit_nums"] = { "15 days": 4, "30 days": (commits_last_month / 10), @@ -92,6 +93,7 @@ def dashboard_reports_update(): "1 year": 30, } response_data["repos"] = repo_data + print(repo_data) ReportBuilder.new(response_data, prompt, current_user.id, current_user.github_repo) return response_data, 201 @@ -101,7 +103,22 @@ def dashboard_reports_update(): def dashboard_saved_report(uid=None): reports = ReportBuilder.get_reports_for_user_id(current_user.id) report = list(filter(lambda report: report["uuid"] == uid, reports))[0] - json_data = json.dumps(report) + print(report) + report["commit_nums"] = { + "15 days": 4, + "30 days": (8 / 10), + "60 days": (10 / 10), + "90 days": (12 / 10), + "120 days": 3, + } + report["pull_requests"] = { + "30 days": 4, + "60 days": 6, + "90 days": 8, + "120 days": 10, + "150 days": 10, + "1 year": 30, + } return render_template( - 'team/teamreport.html', title='Team Report', data=json_data, report=json_data, raw_input=report['raw_input'] + 'archived_report.html', title='Team Report', data=report, raw_input={"raw_input": report["raw_input"]}, report=report["report"] ) diff --git a/DirectReport/browserview/main/routes.py b/DirectReport/browserview/main/routes.py index 3e07f2ef..e247717e 100644 --- a/DirectReport/browserview/main/routes.py +++ b/DirectReport/browserview/main/routes.py @@ -72,6 +72,7 @@ def reponame(): 'X-GitHub-Api-Version': '2022-11-28', } response_data = requests.get(url=repo_name, headers=headers, auth=(client_id, client_secret)) + print(response_data) if response_data.status_code == 200: json_response_data = json.loads(response_data.content) res_json = {"json_array": json_response_data} diff --git a/DirectReport/browserview/static/js/archived_report.js b/DirectReport/browserview/static/js/archived_report.js new file mode 100644 index 00000000..1bc3b7a5 --- /dev/null +++ b/DirectReport/browserview/static/js/archived_report.js @@ -0,0 +1,80 @@ +const {useState, useEffect} = React; +const ArchivedReport = (reportDataElems) => { + + const [teamData, setTeamData] = useState([]); + const [repos, setRepos] = useState([]); + const [reportData, setReportData] = useState({}); + const [commits, setCommits] = useState([]); + const [pullRequests, setPullRequests] = useState({}); + const [broadCategories, setBroadCategories] = useState({}); + const [commitNums, setCommitNums] = useState({}); + const [rawInputText, setRawInputText] = useState(""); + const [commentText, setCommentText] = useState(""); + + + const openRepoPopover = () => { + console.log("open repo popover"); + // setRepoSelected(true); + } + + useEffect(() => { + const results = reportDataElems; + printData({results}) + }, [reportDataElems]); + + function printData(reportDataElems) { + var obj = JSON.parse(JSON.stringify(reportDataElems)); + // var objb = JSON.parse(JSON.stringify(obj)); + var test_data = JSON.parse(JSON.stringify(obj.results.data)) + setCommitNums(test_data.commit_nums); + setPullRequests(test_data.pull_requests); + var test_data2 = JSON.parse(JSON.stringify(obj.results.raw_input_elem)) + setRawInputText(test_data2.raw_input); + var new_data = obj.results.reportDataElems.replace(/\'/g, "\""); + var test1 = JSON.parse(new_data); + Object.entries(test1).forEach((entry) => { + const [key, value] = entry; + var obj_new = JSON.parse(JSON.stringify(value)); + if (key === "team") { + setTeamData({ + teamData:obj_new, + }); + } else if (key === "report") { + setReportData(obj_new); + } else if (key === "commits") { + setCommits({ + commits:obj_new, + }); + } else if (key === "broad_categories") { + setBroadCategories(obj_new); + } else if (key === "repos") { + setRepos({ + repos:obj_new, + }); + } else if (key == "commit_nums") { + setCommitNums(obj_new); + } else if (key == "pull_requests") { + setPullRequests(obj_new); + } + }) + } + + return ( +
+

+ Archived Team Report +

+
+ {EditArchiveSummaryElem({ + "repos": repos, + "commits": commits, + "raw_text": rawInputText + }, {reportData}, openRepoPopover)} + {ArchivedSummarySection(commentText, reportData)} + {ShowArchivedTeamSection({teamData}, closePopover)} + {showAllGraphics({"commit_nums": commitNums, "pull_requests": pullRequests, "broad_categories": broadCategories}, '#map-container', '#map-container2', '#map-container3')} +
+ +
+ ) +} diff --git a/DirectReport/browserview/static/js/archived_report_components.js b/DirectReport/browserview/static/js/archived_report_components.js new file mode 100644 index 00000000..d24ce27f --- /dev/null +++ b/DirectReport/browserview/static/js/archived_report_components.js @@ -0,0 +1,129 @@ +const EditArchiveSummaryElem = (props, state, openRepoPopover) => { + let raw_text = props['raw_text']; + return ( +
+
+

Github Data

+
+
+ {ArchivedEntry(raw_text)} +
+
+ +
+
+ ) +} + + +const ShowArchivedSummary = (report) => { + return ( +

+ {report && +

+ {report.summary} +
+ } +

+ ); +}; + +const ArchivedEntry = (raw_input) => { + return ( +
+

{raw_input}

+
+ ) +} + + +const ShowArchivedHighlights = (report) => { + if (!(report !== undefined)) { + return ( +
+ +
+ ) + } else { + return ( +
+
+ +
+
+ ) + } + +} + + +const ArchivedSummarySection = (commentText, reportData) => { + console.log("ArchivedSummarySection") + console.log(reportData); + return ( +
+
+

Summary

+
+
+ {ShowArchivedSummary(reportData)} + {ShowArchivedHighlights(reportData)} +
+
+
+
+ ) +} + + +const ShowArchivedTeamSection = (teamData, closePopover) => { + console.log(teamData["teamData"]); + return ( +
+
+

Team

+ {PopoverUI(closePopover)} +
+ {ShowArchivedTeamList(teamData["teamData"])} +
+
+
+ ) +} +const ShowArchivedTeamList = (team) => { + + if (!(team !== undefined)) { + return ( + null + ) + } else { + return ( +
+ {team.teamData !== undefined && team.teamData.length > 0? + team.teamData.map(team_member => + + ) : null + } +
+ ) + } +} \ No newline at end of file diff --git a/DirectReport/browserview/static/js/chart_helper.js b/DirectReport/browserview/static/js/chart_helper.js index 0d1a122b..5c9257f8 100644 --- a/DirectReport/browserview/static/js/chart_helper.js +++ b/DirectReport/browserview/static/js/chart_helper.js @@ -60,13 +60,13 @@ function showGraphics(data, divtag) { } }) .attr('y', function (value, index) { - return (chartHeight - 30) - (value[1] * 5) + return (chartHeight - 30) - (value[1] * 8) }) .attr("width", function (value, index) { return (chartWidth / data.length) - padding }) .attr("height", function (value, index) { - return value[1] * 5 + return value[1] * 8 }) .attr("fill", "blueviolet"); @@ -86,7 +86,6 @@ function showGraphics(data, divtag) { .style("font-size", "10px") .style("text-anchor", "center") .text(function (value, index) { - print(value[0].split("_")[0].slice(0, 8)) return value[0].split("_")[0].slice(0, 8) }) } @@ -128,14 +127,14 @@ function showGraphics2(data, divtag) { } }) .attr('y', function (value, index) { - return (chartHeight - 30) - (value[1] * 10) + return (chartHeight - 30) - (value[1] * 18) }) .attr("width", function (value, index) { return (chartWidth / data.length) - padding }) .attr("height", function (value, index) { // console.log(value[1] * 20) - return (value[1] * 10) - 5 + return (value[1] * 18) - 5 }) .attr("fill", "steelblue"); @@ -204,13 +203,13 @@ function showGraphics3(data, divtag) { } }) .attr('y', function (value, index) { - return (chartHeight - 30) - (value[1] * 10) + return (chartHeight - 30) - (value[1] * 17) }) .attr("width", function (value, index) { return (chartWidth / data.length) - padding }) .attr("height", function (value, index) { - return value[1] * 10 + return value[1] * 17 }) .attr("fill", "teal"); @@ -230,7 +229,7 @@ function showGraphics3(data, divtag) { .style("font-size", "8px") .style("text-anchor", "center") .text(function (value, index) { - return value[0].split("_")[0].slice(0, 6) + ' ' + value[0].split("_")[1] + return value[0].split("_")[0] }).call(wrap, 5); } diff --git a/DirectReport/browserview/static/js/teamreport/teamreport.js b/DirectReport/browserview/static/js/teamreport/teamreport.js index 99987519..36482943 100644 --- a/DirectReport/browserview/static/js/teamreport/teamreport.js +++ b/DirectReport/browserview/static/js/teamreport/teamreport.js @@ -62,7 +62,7 @@ class TeamReport extends React.Component { } handleSubmit() { - const payload = {"prompt": this.state.commentText}; + const payload = {"prompt": this.state.commentText} axios({ method: 'post', url: '/dashboard/reports/update', @@ -72,6 +72,7 @@ class TeamReport extends React.Component { "Content-Type": "application/json" } }).then(result => { + console.log(result.data); this.handleTeamDataChange(result.data["team"]); this.handleReportDataChange(result.data["report"]); showAllGraphics(result.data, '#map-container', '#map-container2', '#map-container3'); @@ -154,7 +155,7 @@ class TeamReport extends React.Component { {spinnerUI()}
{EditSummaryElem({"repos": this.state.repos, "commits": this.state.commits}, this.state, this.openRepoPopover)} - {SummarySection(this.state.teamData, this.state.reportData)} + {SummarySection(this.state.reportData)} {TeamSection(this.state.teamData, this.closePopover)}
{this.state.teamData.length <= 0 && ( diff --git a/DirectReport/browserview/static/js/teamreport/teamreport_components.js b/DirectReport/browserview/static/js/teamreport/teamreport_components.js index dcfb646f..af5611d0 100644 --- a/DirectReport/browserview/static/js/teamreport/teamreport_components.js +++ b/DirectReport/browserview/static/js/teamreport/teamreport_components.js @@ -1,10 +1,9 @@ const { useState, useEffect } = React; // Define a functional component named 'ShowSummary' -const ShowSummary = ({ report }) => { +const ShowSummary = (report) => { return (

- {/* Check if 'report' and 'report.summary' are not null or undefined */} {report && report.summary &&

{report.summary} @@ -17,8 +16,10 @@ const ShowSummary = ({ report }) => { // Define a functional component named 'ShowHighlights' const ShowHighlights = (report) => { + console.log(report); return (
+ {/*

{report}

*/}