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 for archived reports #70

Merged
merged 2 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
27 changes: 24 additions & 3 deletions DirectReport/browserview/dashboard/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
: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')

Check warning on line 40 in DirectReport/browserview/dashboard/routes.py

View check run for this annotation

Codecov / codecov/patch

DirectReport/browserview/dashboard/routes.py#L40

Added line #L40 was not covered by tests
return render_template('list.html', title='List', data=results)


Expand Down Expand Up @@ -76,6 +76,7 @@
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)

Check warning on line 79 in DirectReport/browserview/dashboard/routes.py

View check run for this annotation

Codecov / codecov/patch

DirectReport/browserview/dashboard/routes.py#L79

Added line #L79 was not covered by tests
response_data["commit_nums"] = {
"15 days": 4,
"30 days": (commits_last_month / 10),
Expand All @@ -92,6 +93,7 @@
"1 year": 30,
}
response_data["repos"] = repo_data
print(repo_data)

Check warning on line 96 in DirectReport/browserview/dashboard/routes.py

View check run for this annotation

Codecov / codecov/patch

DirectReport/browserview/dashboard/routes.py#L96

Added line #L96 was not covered by tests
ReportBuilder.new(response_data, prompt, current_user.id, current_user.github_repo)
return response_data, 201

Expand All @@ -101,7 +103,26 @@
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"] = {

Check warning on line 107 in DirectReport/browserview/dashboard/routes.py

View check run for this annotation

Codecov / codecov/patch

DirectReport/browserview/dashboard/routes.py#L106-L107

Added lines #L106 - L107 were not covered by tests
"15 days": 4,
"30 days": (8 / 10),
"60 days": (10 / 10),
"90 days": (12 / 10),
"120 days": 3,
}
report["pull_requests"] = {

Check warning on line 114 in DirectReport/browserview/dashboard/routes.py

View check run for this annotation

Codecov / codecov/patch

DirectReport/browserview/dashboard/routes.py#L114

Added line #L114 was not covered by tests
"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"],
)
1 change: 1 addition & 0 deletions DirectReport/browserview/main/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
'X-GitHub-Api-Version': '2022-11-28',
}
response_data = requests.get(url=repo_name, headers=headers, auth=(client_id, client_secret))
print(response_data)

Check warning on line 75 in DirectReport/browserview/main/routes.py

View check run for this annotation

Codecov / codecov/patch

DirectReport/browserview/main/routes.py#L75

Added line #L75 was not covered by tests
if response_data.status_code == 200:
json_response_data = json.loads(response_data.content)
res_json = {"json_array": json_response_data}
Expand Down
80 changes: 80 additions & 0 deletions DirectReport/browserview/static/js/archived_report.js
Original file line number Diff line number Diff line change
@@ -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 (
<div>
<h1 id="h1content" className="self-center text-center text-2xl text-blue-800 text-center font-bold font-mono pt-5 mb-8 pt-8 mx-30 px-20">
Archived Team Report
</h1>
<div id="topRow" className="grid grid-cols-3 gap-10 rounded-3xl mx-20 mt-6">
{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')}
</div>
<GraphicsUI/>
</div>
)
}
129 changes: 129 additions & 0 deletions DirectReport/browserview/static/js/archived_report_components.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
const EditArchiveSummaryElem = (props, state, openRepoPopover) => {
let raw_text = props['raw_text'];
return (
<div className="lg:col-span-1 sm:col-span-3 justify-center" id="edit_summary_div">
<div className="pb-6 pt-2 bg-blue-600 rounded-3xl px-6 shadow-[1.0px_1.0px_2.0px_1.0px_rgba(0,0,0,0.58)]">
<h1 id="title_element" className="self-center text-center text-white text-xl text-center font-bold font-mono mb-1 mt-3 py-2">Github Data</h1>
<div className="h-30 px-2 pt-2 pb-1">
<div className="overflow-y-scroll h-80 rounded-3xl tracking-wide bg-white shadow-[1.0px_1.0px_6.0px_0.0px_rgba(0,0,0,0.58)]">
{ArchivedEntry(raw_text)}
</div>
</div>

</div>
</div>
)
}


const ShowArchivedSummary = (report) => {
return (
<p id="show_summary" className="w-97 sm:w-97 overflow-y-auto break-words">
{report &&
<div className="px-2 mb-1 text-xs text-blue-700 px-2 pt-2 pb-3">
{report.summary}
</div>
}
</p>
);
};

const ArchivedEntry = (raw_input) => {
return (
<div className="px-2">
<p className="text-xs font-regular break-words text-blue-600 px-4 py-2 pb-4">{raw_input}</p>
</div>
)
}


const ShowArchivedHighlights = (report) => {
if (!(report !== undefined)) {
return (
<div className="h-30">
<ul className="px-2 pt-2 pb-3">
</ul>
</div>
)
} else {
return (
<div>
<div className="h-30">
<ul className="px-2 pt-2 pb-3">
{/* Check if 'highlights' in report is not undefined */}
{report["highlights"] !== undefined ?
// Map each highlight to an HTML structure
report["highlights"].map(high_light =>
<li className="mt-1 mb-3">
<h3 className="font-bold text-xs mb-1 mt-1 text-blue-700">
{high_light.title}
</h3>
<p className="w-90 sm:w-90 overflow-y-auto text-xs font-sm break-words tracking-wide text-blue-600">
{high_light.description}
</p>
</li>
) : null // Render nothing if 'highlights' is undefined
}
</ul>
</div>
</div>
)
}

}


const ArchivedSummarySection = (commentText, reportData) => {
console.log("ArchivedSummarySection")
console.log(reportData);
return (
<div id="show_summmary_div" className="lg:col-span-1 sm:col-span-3 justify-center">
<div className="pb-6 pt-2 bg-blue-600 rounded-3xl px-30 shadow-[1.0px_1.0px_5.0px_0.0px_rgba(0,0,0,0.58)]">
<h1 className="self-center text-center text-xl text-white text-center font-bold font-mono mb-1 mt-3 py-2 mt-2 mx-20 px-20">Summary</h1>
<div id="summary" className="px-4 mx-0 mb-1 mt-1">
<div id="summary-container" className="ml-3 mr-3 bg-slate-100 shadow-[1.0px_1.0px_6.0px_0.0px_rgba(0,0,0,0.58)] overflow-y-scroll h-80 rounded-3xl tracking-wide text-gray-500 md:text-gl dark:text-gray-400 mt-3 px-3">
{ShowArchivedSummary(reportData)}
{ShowArchivedHighlights(reportData)}
</div>
</div>
</div>
</div>
)
}


const ShowArchivedTeamSection = (teamData, closePopover) => {
console.log(teamData["teamData"]);
return (
<div id="team_member_to_select" className="lg:col-span-1 sm:col-span-3 justify-center">
<div className="pb-6 pt-2 bg-blue-600 rounded-3xl px-4 mb-2 shadow-[1.0px_1.0px_5.0px_0.0px_rgba(0,0,0,0.58)]">
<h1 className="self-center text-center text-xl text-white text-center font-bold font-mono mb-1 mt-3 py-2 mx-20 px-20">Team</h1>
{PopoverUI(closePopover)}
<div
className="content-center py-2 h-90 rounded-3xl mb-1 bg-slate-100 shadow-[1.0px_1.0px_6.0px_0.0px_rgba(0,0,0,0.58)] mx-1 mt-3 px-3">
{ShowArchivedTeamList(teamData["teamData"])}
</div>
</div>
</div>
)
}
const ShowArchivedTeamList = (team) => {

if (!(team !== undefined)) {
return (
null
)
} else {
return (
<div class="items-center pt-1 select-none">
{team.teamData !== undefined && team.teamData.length > 0?
team.teamData.map(team_member =>
<button class="bg-blue-600 py-1 px-2 pb-1 pt-1 mr-0.5 my-0.5 no-underline rounded-full text-white font-sans border-2 border-gray text-xs btn-primary hover:text-white hover:bg-indigo-700 focus:outline-none active:shadow-none" onClick={(event) => openPopover(event, team_member)}>{
team_member.name}
</button>
) : null
}
</div>
)
}
}
15 changes: 7 additions & 8 deletions DirectReport/browserview/static/js/chart_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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)
})
}
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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");

Expand All @@ -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);

}
Expand Down
5 changes: 3 additions & 2 deletions DirectReport/browserview/static/js/teamreport/teamreport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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');
Expand Down Expand Up @@ -154,7 +155,7 @@ class TeamReport extends React.Component {
{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.teamData, this.state.reportData)}
{SummarySection(this.state.reportData)}
{TeamSection(this.state.teamData, this.closePopover)}
</div>
{this.state.teamData.length <= 0 && (
Expand Down
Loading
Loading