From 037357c9b06f5c6ebb04860b448863274062caed Mon Sep 17 00:00:00 2001 From: chriswebb09 Date: Thu, 14 Dec 2023 06:37:47 -0500 Subject: [PATCH 1/5] cleanup g --- DirectReport/browserview/reportbp.py | 81 +++++++--------------------- 1 file changed, 18 insertions(+), 63 deletions(-) diff --git a/DirectReport/browserview/reportbp.py b/DirectReport/browserview/reportbp.py index 7429f1b4..1766a92e 100644 --- a/DirectReport/browserview/reportbp.py +++ b/DirectReport/browserview/reportbp.py @@ -5,9 +5,10 @@ from flask import Blueprint from DirectReport.browserview.app import login_required from flask_login import login_required, current_user -from .modelclient import RAW_REPORT_DATA -from .modelclient import RAW_REPORT_DATA_2 from DirectReport.models.report_builder import ReportBuilder +from DirectReport.models.report_model import ReportModel +from DirectReport.models.entry_storage import EntryStorage +from DirectReport.models.list_builder import ListBuilder from DirectReport.browserview.github import GithubClient from DirectReport.browserview.github import GoogleAIClient @@ -18,26 +19,17 @@ def report(): prompt = "" prompt = request.get_json()["prompt"] - elements = RAW_REPORT_DATA_2 client = GithubClient() user_repos = client.get_user_repos("chriswebb09") for repo in user_repos: print(repo) - # print(repo["name"]) - # print(repo["full_name"]) - # print(repo["html_url"]) - # print(repo["language"]) - # print(repo["description"]) - # print(repo["stargazers_count"]) - # print(repo["watchers_count"]) - # print("\n") - logitem = "Adrian Prantl (67):\n add mangling testcase\n Debug Info: Represent private discriminators in DWARF.\n Revert \"Debug Info: Represent private discriminators in DWARF.\n Debug Info: Represent private discriminators in DWARF.\n Un-XFAIL and update test.\n Move the logic for ignoring the debug locations for closure setup code into SILGen. NFC-ish.\n Debug Info: Associate a function call with the beginning of the expression.\n Debug Info / SILGen: fix the source location of variable assignments\n typo\n Fix the debug locations of inserted operations in AvailableValueAggregator.\n Don't emit shadow copies for anonymous variables.\n Remove dead API IRGenDebugInfo::setArtificialTrapLocation().\n Use compiler-generated location for func.-sig.-spec. thunks\n whitespace\n Fix the missing inlined-at field of function-level SILDebugScopes.\n Add debug info support for inlined and specialized generic variables.\n Revert Add debug info support for inlined and specialized generic variables.\n Add debug info support for inlined and specialized generic variables.\n Update mangling prefix in Mangling.rst\n Add initial support for debug info for coroutine allocas.\n Temporarily disable failing test case, rdar://problem/43340064\n Add build-script support for the Swift LLDB backwards-compatibility tests.\n Remove accidentally committed debugging code\n Deserialize Swift compatibility version in CompilerInvocation::loadFromSerializedAST()\n SILGen: Preserve function argument debug info for arguments needing alloc_stack\n Use as the filename for SILLocation-less functions to avoid misleading source locatio\nns in backtraces.\n Add a -verify-linetable LLVM option.\n Enable debug info for inlined generics by default. It works now.\n Fix nonasserts compilation\n\nAhmad Alhashemi (5):\n [Parser] Detect nonbreaking space U+00A0 and fixit\n Move non-breaking space handling to lexUnknown\n Add more non-breaking space test cases\n Minor style edits\n Add tests for non-breaking space detect and fix-it\n\nAkshay Shrimali (1):\n Update README.md\n\nAlan Zeino (1):\n Fix typo in code example in libSyntax README\n\nAlbin Sadowski (1):\n Fix syntax highlighting in CHANGELOG (#15107)\n\nAlejandro (3):\n Remove a warning, some doc fixes (#16863)\n [SR-8178] Fix BinaryFloatingPoint.random(in:) open range returning upperBound (#17794)\n [Docs] Fix minor code typo in SILPro..Man..md\n\nAlex Blewitt (5):\n [SR-7032] Fix compare for lhs and rhs\n [SR-7036] Use || instead of && for kind comparison\n [SR-7041] Remove duplicate conditional check\n Remove duplicate verb\n [SR-7043] Remove duplicate if statement" + log_item = "Adrian Prantl (67):\n add mangling testcase\n Debug Info: Represent private discriminators in DWARF.\n Revert \"Debug Info: Represent private discriminators in DWARF.\n Debug Info: Represent private discriminators in DWARF.\n Un-XFAIL and update test.\n Move the logic for ignoring the debug locations for closure setup code into SILGen. NFC-ish.\n Debug Info: Associate a function call with the beginning of the expression.\n Debug Info / SILGen: fix the source location of variable assignments\n typo\n Fix the debug locations of inserted operations in AvailableValueAggregator.\n Don't emit shadow copies for anonymous variables.\n Remove dead API IRGenDebugInfo::setArtificialTrapLocation().\n Use compiler-generated location for func.-sig.-spec. thunks\n whitespace\n Fix the missing inlined-at field of function-level SILDebugScopes.\n Add debug info support for inlined and specialized generic variables.\n Revert Add debug info support for inlined and specialized generic variables.\n Add debug info support for inlined and specialized generic variables.\n Update mangling prefix in Mangling.rst\n Add initial support for debug info for coroutine allocas.\n Temporarily disable failing test case, rdar://problem/43340064\n Add build-script support for the Swift LLDB backwards-compatibility tests.\n Remove accidentally committed debugging code\n Deserialize Swift compatibility version in CompilerInvocation::loadFromSerializedAST()\n SILGen: Preserve function argument debug info for arguments needing alloc_stack\n Use as the filename for SILLocation-less functions to avoid misleading source locatio\nns in backtraces.\n Add a -verify-linetable LLVM option.\n Enable debug info for inlined generics by default. It works now.\n Fix nonasserts compilation\n\nAhmad Alhashemi (5):\n [Parser] Detect nonbreaking space U+00A0 and fixit\n Move non-breaking space handling to lexUnknown\n Add more non-breaking space test cases\n Minor style edits\n Add tests for non-breaking space detect and fix-it\n\nAkshay Shrimali (1):\n Update README.md\n\nAlan Zeino (1):\n Fix typo in code example in libSyntax README\n\nAlbin Sadowski (1):\n Fix syntax highlighting in CHANGELOG (#15107)\n\nAlejandro (3):\n Remove a warning, some doc fixes (#16863)\n [SR-8178] Fix BinaryFloatingPoint.random(in:) open range returning upperBound (#17794)\n [Docs] Fix minor code typo in SILPro..Man..md\n\nAlex Blewitt (5):\n [SR-7032] Fix compare for lhs and rhs\n [SR-7036] Use || instead of && for kind comparison\n [SR-7041] Remove duplicate conditional check\n Remove duplicate verb\n [SR-7043] Remove duplicate if statement" googleAi = GoogleAIClient() response_data = googleAi.get_data_from(prompt).replace("\'", "\"") response_data = response_data.replace("\n", " ") data_json = json.loads(response_data) data_json["broad_categories"] = {"debug_info": 16, "code_maintenance": 9, "documentation": 7, "test_related": 6, "nonbreaking_space_handling": 5, "readme_update": 1, "syntax_fix": 1} - data_json["shortlog"] = client.parse_git_shortlog(logitem) + data_json["shortlog"] = client.parse_git_shortlog(log_item) ReportBuilder.new(data_json, prompt, current_user.id) return data_json, 201 @@ -45,10 +37,8 @@ def report(): @login_required def team_report(): if request.method == "POST": - print("POST") - # json_data = request.get_json() - # report_model = ReportModel(json_data["id"], json_data['summary'], json_data['created_at']) - # print("POST") + json_data = request.get_json() + report_model = ReportModel(json_data["id"], json_data['summary'], json_data['created_at']) return render_template('teamreport.html', title='Team Report', data=[]) @reportsbp.route('/entry/', methods=['GET', 'POST']) @@ -60,58 +50,24 @@ def detail(uid=None): :param uid: The ID of the entry to display. :return: Rendered HTML template for the entry details page. """ - # print(uid) reports = ReportBuilder.get_reports_for_user_id(current_user.id) - # report = list(filter(lambda report: report["uuid"] == uid, reports))[0] - # print(report) - reportJSON = {'report': { - 'broad_categories': {'code_maintenance': 9, 'debug_info': 16, 'documentation': 7, 'nonbreaking_space_handling': 5, 'readme_update': 1, 'syntax_fix': 1, 'test_related': 6}, - 'report': { - 'areas_of_focus': ['DebugInfo and SILGen Enhancements', 'Parser Improvements', 'Various Fixes'], - 'conclusion': 'The team demonstrated good progress this week, with a focus on enhancing DebugInfo and SILGen, improving the Parser, and implementing various fixes. The team should continue to focus on these areas in the coming week.', - 'highlights': [ - {'description': 'Adrian Prantl made significant contributions to the DebugInfo and SILGen, including adding support for debuginfo for coroutine allocas, inlined and specialized generic variables.', 'title': 'DebugInfo and SILGen Enhancements'}, - {'description': 'Ahmad Alhashemi worked on the Parser, detecting non-breaking space U+00A0 and providing a fix.', 'title': 'Parser Improvements'}, - {'description': 'The team worked on several fixes including compare for lhs and rhs, using || instead of && for kind comparison, removing duplicate conditional check and duplicate if statement.', 'title': 'Various Fixes'} - ], - 'summary': 'The team made significant progress this week with a total of 83 commits. The main focus was on DebugInfo and SILGen enhancements, Parser improvements, and various fixes.', - 'total_commits': '83' - }, - 'shortlog': {'Adrian Prantl': 67, 'Ahmad Alhashemi': 5, 'Akshay Shrimali': 1, 'Alan Zeino': 1, 'Albin Sadowski': 1, 'Alejandro': 3, 'Alex Blewitt': 5}, - 'team': [ - {'accomplishments': 'Adrian made significant contributions to the DebugInfo and SILGen, including adding support for debug info for coroutine allocas, inlined and specialized generic variables. He also worked on the mangling testcase, fixed source locations of variable assignments and function calls, and added build-script support for Swift LLDB backwards-compatibility tests.', 'commits': '67', 'name': 'Adrian Prantl'}, - {'accomplishments': 'Alan fixed a typo in the code example in libSyntax README.', 'commits': '1', 'name': 'Alan Zeino'}, - {'accomplishments': 'Alejandro removed a warning, made some documentation fixes, fixed Binary Floating Point. random(in:) open range returning upperBound, and fixed a minor code typo in SILPro.', 'commits': '3', 'name': 'Alejandro'}, - {'accomplishments': 'Akshay updated the README.md file.', 'commits': '1', 'name': 'Akshay Shrimali'}, - {'accomplishments': 'Ahmad worked on the Parser, detecting non-breaking space U+00A0 and providing a fix. He also made minor style edits and added more non-breaking space testcases.', 'commits': '5', 'name': 'Ahmad Alhashemi'}, - {'accomplishments': 'Albin fixed syntax highlighting in CHANGELOG.', 'commits': '1', 'name': 'Albin Sadowski'}, - {'accomplishments': 'Alex worked on several fixes including compare for lhs and rhs, using || instead of && for kind comparison, removing duplicate conditional check and duplicate if statement.', 'commits': '5', 'name': 'Alex Blewitt'} - ] - }, - 'created_at': '1702314769.558132'} - - # json.loads(json.dumps(report)) - # report = {} - # item = EntryStorage('SQLite_Python.db') - # if request.method == "POST": - # json_data = request.get_json() - # ListBuilder.update( - # json_data["id"], json_data['entry'], json_data['topic'], json_data['created_at'], json_data['week_id'] - # ) - # entry = item.get_entry(uid).to_dict() + report = list(filter(lambda report: report["uuid"] == uid, reports))[0] + json.loads(json.dumps(report)) + item = EntryStorage('SQLite_Python.db') + if request.method == "POST": + json_data = request.get_json() + ListBuilder.update( + json_data["id"], json_data['entry'], json_data['topic'], json_data['created_at'], json_data['week_id'] + ) + entry = item.get_entry(uid).to_dict() return render_template('detail.html', title='Detail', data=reportJSON) @reportsbp.route("/getreport/", methods=['GET']) @login_required def get_report(uid=None): - print(uid) reports = ReportBuilder.get_reports_for_user_id(current_user.id) - # report = list(filter(lambda report: report["uuid"] == uid, reports))[0] - # hugClient = HuggingFaceClient() - # result = hugClient.query({ - # "inputs": "Can you please let us know more details about your ", - # }) - return RAW_REPORT_DATA_2, 201 + report = list(filter(lambda report: report["uuid"] == uid, reports))[0] + return report, 201 @reportsbp.route("/getlist", methods=['GET']) @login_required @@ -127,7 +83,6 @@ def list_entries(): :return: Rendered HTML template for the list page. """ reports = ReportBuilder.get_reports_for_user_id(current_user.id) - print(reports) report_results = [] for report in reports: report_element = { From 0ece2cb27d0422205b10681048fd0296cc49f7d9 Mon Sep 17 00:00:00 2001 From: chriswebb09 Date: Thu, 14 Dec 2023 09:02:07 -0500 Subject: [PATCH 2/5] update to pull from repo --- DirectReport/browserview/app.py | 8 ++ DirectReport/browserview/github.py | 1 - DirectReport/browserview/reportbp.py | 4 + .../browserview/static/js/teamreport.js | 114 ++++++++++++++++-- 4 files changed, 114 insertions(+), 13 deletions(-) diff --git a/DirectReport/browserview/app.py b/DirectReport/browserview/app.py index 7397f537..700982e3 100644 --- a/DirectReport/browserview/app.py +++ b/DirectReport/browserview/app.py @@ -96,5 +96,13 @@ def generate_email(): elements = {"email": report.choices[0].message.content} return elements, 201 +@app.route("/repo/", methods=['GET']) +def repo(reponame=None): + + client = GithubClient() + repo = client.get_repo_issues("chriswebb09", reponame) + print(repo) + return render_template('team.html', title='Team', data=[]) + if __name__ == "__main__": app.run(debug=True, port=5000) diff --git a/DirectReport/browserview/github.py b/DirectReport/browserview/github.py index 295f3b6a..3a666659 100644 --- a/DirectReport/browserview/github.py +++ b/DirectReport/browserview/github.py @@ -91,7 +91,6 @@ class GoogleAIClient: def query(self, prompt): - print(prompts.GENERATE_SUMMARY_PROMPT_PREIX) API_URL = f"https://generativelanguage.googleapis.com/v1beta3/models/text-bison-001:generateText?key={appsecrets.GOOGLE_AI_TOKEN}" headers = {"Content-Type": "application/json"} prompt_data = prompts.GENERATE_SUMMARY_PROMPT_PREIX + prompt diff --git a/DirectReport/browserview/reportbp.py b/DirectReport/browserview/reportbp.py index 1766a92e..cf86802b 100644 --- a/DirectReport/browserview/reportbp.py +++ b/DirectReport/browserview/reportbp.py @@ -21,8 +21,11 @@ def report(): prompt = request.get_json()["prompt"] client = GithubClient() user_repos = client.get_user_repos("chriswebb09") + repodata = [] for repo in user_repos: print(repo) + print("\n") + repodata.append(repo["name"]) log_item = "Adrian Prantl (67):\n add mangling testcase\n Debug Info: Represent private discriminators in DWARF.\n Revert \"Debug Info: Represent private discriminators in DWARF.\n Debug Info: Represent private discriminators in DWARF.\n Un-XFAIL and update test.\n Move the logic for ignoring the debug locations for closure setup code into SILGen. NFC-ish.\n Debug Info: Associate a function call with the beginning of the expression.\n Debug Info / SILGen: fix the source location of variable assignments\n typo\n Fix the debug locations of inserted operations in AvailableValueAggregator.\n Don't emit shadow copies for anonymous variables.\n Remove dead API IRGenDebugInfo::setArtificialTrapLocation().\n Use compiler-generated location for func.-sig.-spec. thunks\n whitespace\n Fix the missing inlined-at field of function-level SILDebugScopes.\n Add debug info support for inlined and specialized generic variables.\n Revert Add debug info support for inlined and specialized generic variables.\n Add debug info support for inlined and specialized generic variables.\n Update mangling prefix in Mangling.rst\n Add initial support for debug info for coroutine allocas.\n Temporarily disable failing test case, rdar://problem/43340064\n Add build-script support for the Swift LLDB backwards-compatibility tests.\n Remove accidentally committed debugging code\n Deserialize Swift compatibility version in CompilerInvocation::loadFromSerializedAST()\n SILGen: Preserve function argument debug info for arguments needing alloc_stack\n Use as the filename for SILLocation-less functions to avoid misleading source locatio\nns in backtraces.\n Add a -verify-linetable LLVM option.\n Enable debug info for inlined generics by default. It works now.\n Fix nonasserts compilation\n\nAhmad Alhashemi (5):\n [Parser] Detect nonbreaking space U+00A0 and fixit\n Move non-breaking space handling to lexUnknown\n Add more non-breaking space test cases\n Minor style edits\n Add tests for non-breaking space detect and fix-it\n\nAkshay Shrimali (1):\n Update README.md\n\nAlan Zeino (1):\n Fix typo in code example in libSyntax README\n\nAlbin Sadowski (1):\n Fix syntax highlighting in CHANGELOG (#15107)\n\nAlejandro (3):\n Remove a warning, some doc fixes (#16863)\n [SR-8178] Fix BinaryFloatingPoint.random(in:) open range returning upperBound (#17794)\n [Docs] Fix minor code typo in SILPro..Man..md\n\nAlex Blewitt (5):\n [SR-7032] Fix compare for lhs and rhs\n [SR-7036] Use || instead of && for kind comparison\n [SR-7041] Remove duplicate conditional check\n Remove duplicate verb\n [SR-7043] Remove duplicate if statement" googleAi = GoogleAIClient() response_data = googleAi.get_data_from(prompt).replace("\'", "\"") @@ -30,6 +33,7 @@ def report(): data_json = json.loads(response_data) data_json["broad_categories"] = {"debug_info": 16, "code_maintenance": 9, "documentation": 7, "test_related": 6, "nonbreaking_space_handling": 5, "readme_update": 1, "syntax_fix": 1} data_json["shortlog"] = client.parse_git_shortlog(log_item) + data_json["repos"] = repodata ReportBuilder.new(data_json, prompt, current_user.id) return data_json, 201 diff --git a/DirectReport/browserview/static/js/teamreport.js b/DirectReport/browserview/static/js/teamreport.js index f4981c23..8a1a0af2 100644 --- a/DirectReport/browserview/static/js/teamreport.js +++ b/DirectReport/browserview/static/js/teamreport.js @@ -60,6 +60,11 @@ const TeamData = () => { document.getElementById('popover-id-left-purple').classList.toggle("hidden"); } + const closeRepoPopover = () => { + document.getElementById('popover-repos').classList.toggle("hidden"); + } + + const openPopover = (e: ChangeEvent, teammember) => { e.preventDefault(); let element = e.target; @@ -114,13 +119,21 @@ const TeamData = () => {
-
- +

+
@@ -128,6 +141,64 @@ const TeamData = () => { ) } + const openRepoPopover = (e: ChangeEvent) => { + const element = document.getElementById('formUI'); + Popper.createPopper(element, document.getElementById('popover-repo-left-purple'), { + strategy: 'fixed', + modifiers: [ + { + name: "offset", //offsets popper from the reference/button + options: { + offset: [0, 8] + } + + }, + { + name: "flip", //flips popper with allowed placements + options: { + allowedAutoPlacements: ["right", "left", "top", "bottom"], + rootBoundary: "viewport" + } + } + ] + }); + document.getElementById('popover-repo-left-purple').classList.toggle("hidden"); + const popoverReposTitleContent = document.getElementById('popover-repo-TitleContent'); + popoverReposTitleContent.innerHTML = "Repos" + "(" + teamData["repos"].length + ")"; + const popoverRepoContent = document.getElementById('popover-repo-Content'); + var myList = ''; + console.log(myList) + popoverRepoContent.innerHTML = myList; + } + + const repoPopoverUI = () => { + return ( +
+
+
+ + + +
+
+
+ {/*
*/} + + {/*
*/} +
+
+ ) + } + function toggle() { setIsOpened(isOpened => !isOpened); } @@ -136,23 +207,31 @@ const TeamData = () => { setIsHidden(isHidden => !isHidden); } + function toggle() { + setIsOpened(isOpened => !isOpened); + } + return (

Generate Team Report From Metadata

-
+ {repoPopoverUI()} +
+
{formUI()}
-
+

Summary

{isOpened && ( -
+

{teamData["report"] !== undefined ?

@@ -180,16 +259,20 @@ const TeamData = () => {
-
+

Team

{popoverUI()}
{isOpened && ( -
+
{teamData["team"] && teamData["team"].map(teammember => - + )}
@@ -203,20 +286,27 @@ const TeamData = () => {

Data

-
-
+
+
-
+
-
+
From e3d8c747f3842eb3e650510b2b4c71ed5b4536f5 Mon Sep 17 00:00:00 2001 From: chriswebb09 Date: Fri, 15 Dec 2023 05:17:06 -0500 Subject: [PATCH 3/5] move react ui into separate elements --- DirectReport/browserview/static/js/account.js | 33 +-- DirectReport/browserview/static/js/list.js | 1 + DirectReport/browserview/static/js/note.js | 3 +- .../browserview/static/js/teamreport.js | 204 ++++++++---------- 4 files changed, 114 insertions(+), 127 deletions(-) diff --git a/DirectReport/browserview/static/js/account.js b/DirectReport/browserview/static/js/account.js index 44c5a9f5..17762242 100644 --- a/DirectReport/browserview/static/js/account.js +++ b/DirectReport/browserview/static/js/account.js @@ -1,5 +1,23 @@ const { useState, useEffect } = React; + +const AccountUserInfo = (userData, reportData) => { + return ( +
+
+
+

Account: {userData.name}

+

Email: {userData.userid}

+

Username: {userData.username} +

+

Number of reports saved {reportData.length}

+
+
+
+ ) +} + const Account = () => { const [userData, setUserData] = useState({}); @@ -19,16 +37,12 @@ const Account = () => { return response.json(); }) .then((actualData) => { - console.log(actualData) setUserData(actualData["user"]); setReportData(actualData["reports"]); setActualData(actualData); setError(null); - // showGraphics(actualData); }) .catch((err) => { - // setError(err.message); - // showGraphics(null); setUserData(null) setReportData(null) }) @@ -47,16 +61,7 @@ const Account = () => { return (
-
-
-
-

Account: {userData.name}

-

Email: {userData.userid}

-

Username: {userData.username}

-

Number of reports saved {reportData.length}

-
-
-
+ {userData && AccountUserInfo(userData, reportData)}
diff --git a/DirectReport/browserview/static/js/list.js b/DirectReport/browserview/static/js/list.js index 3c2dec78..be5e4f52 100644 --- a/DirectReport/browserview/static/js/list.js +++ b/DirectReport/browserview/static/js/list.js @@ -19,6 +19,7 @@ class EntryList extends React.Component {
); } + // Thest } class EmptyEntryList extends React.Component { diff --git a/DirectReport/browserview/static/js/note.js b/DirectReport/browserview/static/js/note.js index da60aab9..97d502e1 100644 --- a/DirectReport/browserview/static/js/note.js +++ b/DirectReport/browserview/static/js/note.js @@ -11,15 +11,14 @@ class ReportItem extends React.Component { console.log(this.props.report["total_commits"]) console.log(this.props.report["conclusion"]) console.log(this.props.report["highlights"]) - return ( + return (

Report

{this.props.report !== undefined ?
{this.props.report["summary"]}
: null } - {this.props.report !== undefined ?
{this.props.report["conclusion"]}
: null } diff --git a/DirectReport/browserview/static/js/teamreport.js b/DirectReport/browserview/static/js/teamreport.js index 8a1a0af2..c6992b71 100644 --- a/DirectReport/browserview/static/js/teamreport.js +++ b/DirectReport/browserview/static/js/teamreport.js @@ -1,4 +1,82 @@ const { useState, useEffect } = React; + +const GraphDiv = () => { + return ( +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ) +} + +const FormDiv = (handleSubmit, openRepoPopover, commentText) => { + return ( +
+
+

Enter + Github Data +

+
+
+ +
+
+ +

+ +
+
+
+
+ ) +} + +const PopoverUI = (closePopover) => { + return ( +
+
+
+ + + +
+
+
+
+
+ +
+
+ ) +} + const TeamData = () => { const [teamData, setTeamData] = useState({}); const [commentText, setCommentText] = useState("") @@ -60,7 +138,7 @@ const TeamData = () => { document.getElementById('popover-id-left-purple').classList.toggle("hidden"); } - const closeRepoPopover = () => { + const closeRepoPopover = () => { document.getElementById('popover-repos').classList.toggle("hidden"); } @@ -83,64 +161,6 @@ const TeamData = () => { popoverCommits.innerHTML = "Commits: " + teammember.commits; } - const popoverUI = () => { - return ( -
-
-
- - - -
-
-
-
-
- -
-
- ) - } - - const formUI = () => { - return ( -
-
-

Enter - Github Data -

-
-
- -
-
- -

- -
-
-
-
- ) - } - const openRepoPopover = (e: ChangeEvent) => { const element = document.getElementById('formUI'); Popper.createPopper(element, document.getElementById('popover-repo-left-purple'), { @@ -175,11 +195,11 @@ const TeamData = () => { popoverRepoContent.innerHTML = myList; } + + const repoPopoverUI = () => { return ( -
+
@@ -216,22 +236,17 @@ const TeamData = () => {

Generate Team Report From Metadata

- {repoPopoverUI()} + {/*{repoPopoverUI()}*/}
-
- {formUI()} + {FormDiv(handleSubmit, openRepoPopover, commentText)}
-
-

- Summary -

+
+

Summary

{isOpened && ( -
+

{teamData["report"] !== undefined ?

@@ -259,20 +274,16 @@ const TeamData = () => {
-
+

Team

- {popoverUI()} +
{isOpened && ( -
+
{teamData["team"] && teamData["team"].map(teammember => - + )}
@@ -280,39 +291,10 @@ const TeamData = () => {
- {isOpened && (
-

- Data -

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+

Data

+
)}
From 1ba99c8f97563d1d6d5726d1ecd93dc5101987ec Mon Sep 17 00:00:00 2001 From: chriswebb09 Date: Fri, 15 Dec 2023 06:02:18 -0500 Subject: [PATCH 4/5] separate ui react components --- DirectReport/browserview/static/js/account.js | 80 +++++--- .../browserview/static/js/chart_helper.js | 16 +- DirectReport/browserview/static/js/list.js | 6 +- DirectReport/browserview/static/js/note.js | 1 + .../browserview/static/js/teamreport.js | 190 ++++-------------- .../browserview/templates/teamreport.html | 1 + 6 files changed, 109 insertions(+), 185 deletions(-) diff --git a/DirectReport/browserview/static/js/account.js b/DirectReport/browserview/static/js/account.js index 17762242..03cc85e1 100644 --- a/DirectReport/browserview/static/js/account.js +++ b/DirectReport/browserview/static/js/account.js @@ -18,6 +18,52 @@ const AccountUserInfo = (userData, reportData) => { ) } +const ReportInfo = () => { + return ( +
+ +
+ ) +} + +const ListDiv = () => { + return ( + + ) +} + + +const LogoutDiv = () => { + return ( +
+ ) +} const Account = () => { const [userData, setUserData] = useState({}); @@ -62,37 +108,9 @@ const Account = () => { return (
{userData && AccountUserInfo(userData, reportData)} - - -
- -
+ + +
) } diff --git a/DirectReport/browserview/static/js/chart_helper.js b/DirectReport/browserview/static/js/chart_helper.js index f5eb12f0..d60244e1 100644 --- a/DirectReport/browserview/static/js/chart_helper.js +++ b/DirectReport/browserview/static/js/chart_helper.js @@ -1,7 +1,10 @@ function showGraphics(data, divtag) { + const newData = data + const stringData = JSON.stringify(newData['broad_categories']); + const values = Object.keys(newData['broad_categories']).map(function (key) { return [key, Number(newData['broad_categories'][key])] }); @@ -9,8 +12,10 @@ function showGraphics(data, divtag) { const chartWidth = 350 const chartHeight = 300 const padding = 25 + var data = values const heightScalingFactor = chartHeight / 67 + var container = d3.select(divtag) .append('svg') .attr('width', chartWidth) @@ -63,8 +68,11 @@ function showGraphics(data, divtag) { } function showGraphics2(data, divtag) { + const newData = data + const stringData = JSON.stringify(newData['broad_categories']); + const values = Object.keys(newData['broad_categories']).map(function (key) { return [key, Number(newData['broad_categories'][key])] }); @@ -72,14 +80,16 @@ function showGraphics2(data, divtag) { const chartWidth = 350 const chartHeight = 300 const padding = 25 + var data = values const heightScalingFactor = chartHeight / 67 + var container = d3.select(divtag) .append('svg') .attr('width', chartWidth) .attr('height', chartHeight) - var svg = d3.select(divtag).select("svg") + var svg = d3.select(divtag).select("svg") var groups = svg.selectAll(".groups") .data(data) .enter() @@ -126,8 +136,11 @@ function showGraphics2(data, divtag) { } function showGraphics3(data, divtag) { + const newData = data + const stringData = JSON.stringify(newData['broad_categories']); + const values = Object.keys(newData['broad_categories']).map(function (key) { return [key, Number(newData['broad_categories'][key])] }); @@ -135,6 +148,7 @@ function showGraphics3(data, divtag) { const chartWidth = 350 const chartHeight = 300 const padding = 25 + var data = values const heightScalingFactor = chartHeight / 67 var container = d3.select(divtag) diff --git a/DirectReport/browserview/static/js/list.js b/DirectReport/browserview/static/js/list.js index be5e4f52..b405ec8f 100644 --- a/DirectReport/browserview/static/js/list.js +++ b/DirectReport/browserview/static/js/list.js @@ -19,7 +19,6 @@ class EntryList extends React.Component {
); } - // Thest } class EmptyEntryList extends React.Component { @@ -37,6 +36,7 @@ class EmptyEntryList extends React.Component { const App = () => { + const [listData, setListData] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); @@ -71,7 +71,9 @@ const App = () => { } else { if (listData.length > 0) { return ( -
+
+ +
) } else { return ( diff --git a/DirectReport/browserview/static/js/note.js b/DirectReport/browserview/static/js/note.js index 97d502e1..7493d7c1 100644 --- a/DirectReport/browserview/static/js/note.js +++ b/DirectReport/browserview/static/js/note.js @@ -35,6 +35,7 @@ class ReportItem extends React.Component { } const App = () => { + const [reportData, setReportData] = useState(null); const [teamData, setTeamData] = useState([]); const [loading, setLoading] = useState(true); diff --git a/DirectReport/browserview/static/js/teamreport.js b/DirectReport/browserview/static/js/teamreport.js index c6992b71..00bf4e8f 100644 --- a/DirectReport/browserview/static/js/teamreport.js +++ b/DirectReport/browserview/static/js/teamreport.js @@ -1,88 +1,10 @@ const { useState, useEffect } = React; -const GraphDiv = () => { - return ( -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ) -} - -const FormDiv = (handleSubmit, openRepoPopover, commentText) => { - return ( -
-
-

Enter - Github Data -

-
-
- -
-
- -

- -
-
-
-
- ) -} - -const PopoverUI = (closePopover) => { - return ( -
-
-
- - - -
-
-
-
-
- -
-
- ) -} - const TeamData = () => { + const [teamData, setTeamData] = useState({}); const [commentText, setCommentText] = useState("") - const [generatedEmail, setGeneratedEmail] = useState("") const [isOpened, setIsOpened] = useState(false); - const [isHidden, setIsHidden] = useState(false); const handleSubmit = e => { e.preventDefault() var dataForm = { @@ -99,7 +21,6 @@ const TeamData = () => { }).then(function(res) { return res.json(); }).then(function(data) { - console.log(data); setTeamData(data); toggle(); showGraphics(data, '#map-container'); @@ -107,14 +28,11 @@ const TeamData = () => { showGraphics3(data, '#map-container3'); }).then(function() { console.log('done'); - }); }; const handleClick = e => { - e.preventDefault() - var dataForm = { "prompt": JSON.stringify(teamData) }; @@ -153,66 +71,48 @@ const TeamData = () => { strategy: 'fixed' }); document.getElementById('popover-id-left-purple').classList.toggle("hidden"); - const popoverTitle = document.getElementById('popoverTitleContent'); - popoverTitle.innerHTML = teammember.name - const popoverContent = document.getElementById('popoverContent'); - popoverContent.innerHTML = teammember.accomplishments; - const popoverCommits = document.getElementById('popoverCommits'); - popoverCommits.innerHTML = "Commits: " + teammember.commits; + document.getElementById('popoverTitleContent').innerHTML = teammember.name + document.getElementById('popoverContent').innerHTML = teammember.accomplishments; + document.getElementById('popoverCommits').innerHTML = "Commits: " + teammember.commits; } const openRepoPopover = (e: ChangeEvent) => { const element = document.getElementById('formUI'); Popper.createPopper(element, document.getElementById('popover-repo-left-purple'), { strategy: 'fixed', - modifiers: [ - { - name: "offset", //offsets popper from the reference/button - options: { - offset: [0, 8] - } - - }, - { - name: "flip", //flips popper with allowed placements - options: { - allowedAutoPlacements: ["right", "left", "top", "bottom"], - rootBoundary: "viewport" - } + modifiers: [{ + name: "offset", // offsets popper from the reference/button + options: { + offset: [0, 8] + } + }, { + name: "flip", // flips popper with allowed placements + options: { + allowedAutoPlacements: ["right", "left", "top", "bottom"], + rootBoundary: "viewport" } - ] + }] }); document.getElementById('popover-repo-left-purple').classList.toggle("hidden"); - const popoverReposTitleContent = document.getElementById('popover-repo-TitleContent'); - popoverReposTitleContent.innerHTML = "Repos" + "(" + teamData["repos"].length + ")"; - const popoverRepoContent = document.getElementById('popover-repo-Content'); - var myList = ''; + document.getElementById('popover-repo-Content').innerHTML = list; } - - const repoPopoverUI = () => { return (
-
- - - -
-
+
+ +
+
{/*
*/} - {/*
*/}
@@ -231,6 +131,18 @@ const TeamData = () => { setIsOpened(isOpened => !isOpened); } + const ShowSummary = (report) => { + return ( +

+ {report !== undefined ? +

+ {report["summary"]} +
: null + } +

+ ) + } + return (

@@ -247,27 +159,8 @@ const TeamData = () => {
{isOpened && (
-

- {teamData["report"] !== undefined ? -

- {teamData["report"]["summary"]} -
: null - } -

-
-
    - {teamData["report"]["highlights"] && teamData["report"]["highlights"].map(hightlight => -
  • -

    - {hightlight.title} -

    -

    - {hightlight.description} -

    -
  • - )} -
-
+ {ShowSummary(teamData["report"])} + {ShowHighlights(teamData["report"])}
)}
@@ -280,12 +173,7 @@ const TeamData = () => {
{isOpened && (
-
- {teamData["team"] && - teamData["team"].map(teammember => - - )} -
+ {ShowTeamList(teamData["team"], openPopover)}
)}

diff --git a/DirectReport/browserview/templates/teamreport.html b/DirectReport/browserview/templates/teamreport.html index ca6aea50..faacde27 100644 --- a/DirectReport/browserview/templates/teamreport.html +++ b/DirectReport/browserview/templates/teamreport.html @@ -7,6 +7,7 @@ {% block content %}
+
From 7d10ffc5a17b6385240bb6ba71af0f752ef77392 Mon Sep 17 00:00:00 2001 From: chriswebb09 Date: Fri, 15 Dec 2023 09:08:52 -0500 Subject: [PATCH 5/5] add in drop down menu, remove menu options from profile --- DirectReport/browserview/app.py | 27 ++-- DirectReport/browserview/github.py | 4 +- DirectReport/browserview/prompt_logic.py | 1 + DirectReport/browserview/reportbp.py | 15 +- DirectReport/browserview/static/css/main.css | 3 + DirectReport/browserview/static/js/account.js | 93 ++++--------- DirectReport/browserview/static/js/index.js | 6 +- DirectReport/browserview/static/js/list.js | 9 +- .../static/js/{ => teamreport}/teammember.js | 0 .../static/js/{ => teamreport}/teamreport.js | 24 +--- .../js/teamreport/teamreportcomponents.js | 130 ++++++++++++++++++ .../browserview/templates/_navigation.html | 48 +++++-- .../browserview/templates/account.html | 2 +- .../templates/{ => team}/team.html | 0 .../templates/{ => team}/team_member.html | 0 .../templates/{ => team}/teamreport.html | 6 +- DirectReport/tests/test_db.py | 2 - DirectReport/tests/test_list_builder.py | 9 +- 18 files changed, 242 insertions(+), 137 deletions(-) rename DirectReport/browserview/static/js/{ => teamreport}/teammember.js (100%) rename DirectReport/browserview/static/js/{ => teamreport}/teamreport.js (91%) create mode 100644 DirectReport/browserview/static/js/teamreport/teamreportcomponents.js rename DirectReport/browserview/templates/{ => team}/team.html (100%) rename DirectReport/browserview/templates/{ => team}/team_member.html (100%) rename DirectReport/browserview/templates/{ => team}/teamreport.html (74%) diff --git a/DirectReport/browserview/app.py b/DirectReport/browserview/app.py index 700982e3..f4d83134 100644 --- a/DirectReport/browserview/app.py +++ b/DirectReport/browserview/app.py @@ -1,26 +1,17 @@ #!/usr/bin/env python3 +import sys +from pathlib import Path + from flask import Flask, render_template, request, redirect, json, url_for -from werkzeug.security import generate_password_hash -from DirectReport.models.user_model import UserModel -from DirectReport.models.list_builder import ListBuilder -from DirectReport.models.report_model import ReportModel -from DirectReport.models.report_builder import ReportBuilder -from DirectReport.models.report import Report -from DirectReport.browserview.prompt_logic import generate_email +from flask_login import LoginManager, login_required, current_user + from DirectReport.browserview.github import GithubClient -from DirectReport.browserview.github import GoogleAIClient -from DirectReport.browserview.github import HuggingFaceClient -from flask_login import LoginManager, login_user, login_required, logout_user, current_user +from DirectReport.browserview.prompt_logic import generate_email from DirectReport.datadependencies import appsecrets +from DirectReport.models.user_model import UserModel from .auth.auth import auth from .reportbp import reportsbp -from .modelclient import TEST_DATA_ELEMENTS -from .modelclient import RAW_REPORT_DATA -from .modelclient import RAW_REPORT_DATA_2 - -import sys -from pathlib import Path file = Path(__file__).resolve() package_root_directory = file.parents[1] @@ -85,7 +76,7 @@ def unauthorized_handler(): @app.route("/team", methods=['GET']) def team(): - return render_template('team.html', title='Team', data=[]) + return render_template('team/team.html', title='Team', data=[]) @app.route("/generate_email", methods=['POST']) def generate_email(): @@ -102,7 +93,7 @@ def repo(reponame=None): client = GithubClient() repo = client.get_repo_issues("chriswebb09", reponame) print(repo) - return render_template('team.html', title='Team', data=[]) + return render_template('team/team.html', title='Team', data=[]) if __name__ == "__main__": app.run(debug=True, port=5000) diff --git a/DirectReport/browserview/github.py b/DirectReport/browserview/github.py index 3a666659..28fc4e7d 100644 --- a/DirectReport/browserview/github.py +++ b/DirectReport/browserview/github.py @@ -1,8 +1,10 @@ #!/usr/bin/env python3 +import json import re + import requests -import json + from DirectReport.datadependencies import appsecrets, prompts diff --git a/DirectReport/browserview/prompt_logic.py b/DirectReport/browserview/prompt_logic.py index a2954989..2894599a 100644 --- a/DirectReport/browserview/prompt_logic.py +++ b/DirectReport/browserview/prompt_logic.py @@ -2,6 +2,7 @@ import openai + from DirectReport.datadependencies import appsecrets, prompts openai.api_key = appsecrets.SECRET_KEY diff --git a/DirectReport/browserview/reportbp.py b/DirectReport/browserview/reportbp.py index cf86802b..10959e90 100644 --- a/DirectReport/browserview/reportbp.py +++ b/DirectReport/browserview/reportbp.py @@ -1,16 +1,15 @@ #!/usr/bin/env python3 -import ast -from flask import Flask, render_template, request, json from flask import Blueprint -from DirectReport.browserview.app import login_required +from flask import render_template, request, json from flask_login import login_required, current_user -from DirectReport.models.report_builder import ReportBuilder -from DirectReport.models.report_model import ReportModel -from DirectReport.models.entry_storage import EntryStorage -from DirectReport.models.list_builder import ListBuilder + from DirectReport.browserview.github import GithubClient from DirectReport.browserview.github import GoogleAIClient +from DirectReport.models.entry_storage import EntryStorage +from DirectReport.models.list_builder import ListBuilder +from DirectReport.models.report_builder import ReportBuilder +from DirectReport.models.report_model import ReportModel reportsbp = Blueprint('reportsbp', __name__) @@ -43,7 +42,7 @@ def team_report(): if request.method == "POST": json_data = request.get_json() report_model = ReportModel(json_data["id"], json_data['summary'], json_data['created_at']) - return render_template('teamreport.html', title='Team Report', data=[]) + return render_template('team/teamreport.html', title='Team Report', data=[]) @reportsbp.route('/entry/', methods=['GET', 'POST']) @login_required diff --git a/DirectReport/browserview/static/css/main.css b/DirectReport/browserview/static/css/main.css index e69de29b..b060507f 100644 --- a/DirectReport/browserview/static/css/main.css +++ b/DirectReport/browserview/static/css/main.css @@ -0,0 +1,3 @@ +.dropdown:hover .dropdown-menu { + display: block; +} \ No newline at end of file diff --git a/DirectReport/browserview/static/js/account.js b/DirectReport/browserview/static/js/account.js index 03cc85e1..2f21a4ba 100644 --- a/DirectReport/browserview/static/js/account.js +++ b/DirectReport/browserview/static/js/account.js @@ -3,69 +3,34 @@ const { useState, useEffect } = React; const AccountUserInfo = (userData, reportData) => { return ( -
-
-
-

Account: {userData.name}

-

Email: {userData.userid}

-

Username: {userData.username} -

-

Number of reports saved {reportData.length}

+
+
+
+
+

+ Account: {userData.name} +

+

+ Email: {userData.userid} +

+
-
-
- ) -} - -const ReportInfo = () => { - return ( -
-
-
- - - +
+
+

+ Username: {userData.username} +

+

+ Number of reports saved: {reportData.length} +

+
) } -const ListDiv = () => { - return ( - - ) -} - - -const LogoutDiv = () => { - return ( -
- -
- ) -} const Account = () => { - const [userData, setUserData] = useState({}); const [actualData, setActualData] = useState({}); const [reportData, setReportData] = useState([]); @@ -97,20 +62,22 @@ const Account = () => { }); }, []); - - if (loading) { return (
{`There is a problem fetching the post data - ${error}`}
) } else { - return ( -
- {userData && AccountUserInfo(userData, reportData)} - - - +
+
+

+ User Account +

+
+ +
+ {userData && AccountUserInfo(userData, reportData)} +
) } diff --git a/DirectReport/browserview/static/js/index.js b/DirectReport/browserview/static/js/index.js index 042ecb7f..3b132732 100644 --- a/DirectReport/browserview/static/js/index.js +++ b/DirectReport/browserview/static/js/index.js @@ -20,21 +20,21 @@ class Home extends React.Component { React.createElement( "h2", { - className: "my-1 text-3xl font-bold mb-5 text-white" + className: "mt-1 text-3xl font-bold mb-3 text-white" }, "DirectReport." ), React.createElement( "h3", { - className: "my-1 text-lg mb-8 text-gray-200" + className: "mt-4 text-lg mb-11 text-gray-200" }, "Keep track of your accomplishments each day of the workweek." ), React.createElement( "div", { - className: "my-8" + className: "my-15" }, React.createElement( "a", diff --git a/DirectReport/browserview/static/js/list.js b/DirectReport/browserview/static/js/list.js index b405ec8f..0dd7c843 100644 --- a/DirectReport/browserview/static/js/list.js +++ b/DirectReport/browserview/static/js/list.js @@ -3,10 +3,13 @@ const { useState, useEffect } = React; class EntryList extends React.Component { render() { return ( -
+
+

+ Saved Reports +

{this.props.listdata.map(item => -
-
+
+

{'Topic: ' + item.user_id}

diff --git a/DirectReport/browserview/static/js/teammember.js b/DirectReport/browserview/static/js/teamreport/teammember.js similarity index 100% rename from DirectReport/browserview/static/js/teammember.js rename to DirectReport/browserview/static/js/teamreport/teammember.js diff --git a/DirectReport/browserview/static/js/teamreport.js b/DirectReport/browserview/static/js/teamreport/teamreport.js similarity index 91% rename from DirectReport/browserview/static/js/teamreport.js rename to DirectReport/browserview/static/js/teamreport/teamreport.js index 00bf4e8f..7598b50c 100644 --- a/DirectReport/browserview/static/js/teamreport.js +++ b/DirectReport/browserview/static/js/teamreport/teamreport.js @@ -2,9 +2,10 @@ const { useState, useEffect } = React; const TeamData = () => { - const [teamData, setTeamData] = useState({}); + const [teamData, setTeamData] = useState({}) const [commentText, setCommentText] = useState("") - const [isOpened, setIsOpened] = useState(false); + const [isOpened, setIsOpened] = useState(false) + const handleSubmit = e => { e.preventDefault() var dataForm = { @@ -131,18 +132,6 @@ const TeamData = () => { setIsOpened(isOpened => !isOpened); } - const ShowSummary = (report) => { - return ( -

- {report !== undefined ? -

- {report["summary"]} -
: null - } -

- ) - } - return (

@@ -169,7 +158,7 @@ const TeamData = () => {

Team

- + {PopoverUI(closePopover)}
{isOpened && (
@@ -180,10 +169,7 @@ const TeamData = () => {
{isOpened && ( -
-

Data

- -
+ )}
); diff --git a/DirectReport/browserview/static/js/teamreport/teamreportcomponents.js b/DirectReport/browserview/static/js/teamreport/teamreportcomponents.js new file mode 100644 index 00000000..29dd0f02 --- /dev/null +++ b/DirectReport/browserview/static/js/teamreport/teamreportcomponents.js @@ -0,0 +1,130 @@ +const { useState, useEffect } = React; + + +const ShowSummary = (report) => { + return ( +

+ {report !== undefined ? +

+ {report["summary"]} +
: null + } +

+ ) +} + +const ShowHighlights = (report) => { + return ( +
+
    + {report["highlights"] && report["highlights"].map(hightlight => +
  • +

    + {hightlight.title} +

    +

    + {hightlight.description} +

    +
  • + )} +
+
+ ) +} + +const ShowTeamList = (team, openPopover) => { + return ( +
+ {team + && team.map(teammember => + + ) + } +
+ ) +} + +class GraphDiv extends React.Component { + render() { + return ( +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ) + } +} + +const GraphicsUI = () => { + return ( +
+

Data

+ +
+ ) +} + +const FormDiv = (handleSubmit, openRepoPopover, commentText) => { + return ( +
+
+

Enter + Github Data +

+
+
+ +
+
+ +

+ +
+
+
+
+ ) +} + +const PopoverUI = (closePopover) => { + return ( +
+ ) +} \ No newline at end of file diff --git a/DirectReport/browserview/templates/_navigation.html b/DirectReport/browserview/templates/_navigation.html index adaf15e9..427dbd1d 100644 --- a/DirectReport/browserview/templates/_navigation.html +++ b/DirectReport/browserview/templates/_navigation.html @@ -1,12 +1,40 @@ -