diff --git a/DirectReport/browserview/app.py b/DirectReport/browserview/app.py index 7397f537..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(): @@ -96,5 +87,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/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..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 @@ -91,7 +93,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/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 7429f1b4..10959e90 100644 --- a/DirectReport/browserview/reportbp.py +++ b/DirectReport/browserview/reportbp.py @@ -1,15 +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 .modelclient import RAW_REPORT_DATA -from .modelclient import RAW_REPORT_DATA_2 -from DirectReport.models.report_builder import ReportBuilder + 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__) @@ -18,26 +18,21 @@ def report(): prompt = "" prompt = request.get_json()["prompt"] - elements = RAW_REPORT_DATA_2 client = GithubClient() user_repos = client.get_user_repos("chriswebb09") + repodata = [] 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" + 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("\'", "\"") 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) + data_json["repos"] = repodata ReportBuilder.new(data_json, prompt, current_user.id) return data_json, 201 @@ -45,11 +40,9 @@ 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") - return render_template('teamreport.html', title='Team Report', data=[]) + json_data = request.get_json() + report_model = ReportModel(json_data["id"], json_data['summary'], json_data['created_at']) + return render_template('team/teamreport.html', title='Team Report', data=[]) @reportsbp.route('/entry/', methods=['GET', 'POST']) @login_required @@ -60,58 +53,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 +86,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 = { 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 44c5a9f5..2f21a4ba 100644 --- a/DirectReport/browserview/static/js/account.js +++ b/DirectReport/browserview/static/js/account.js @@ -1,7 +1,36 @@ const { useState, useEffect } = React; -const Account = () => { +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({}); const [actualData, setActualData] = useState({}); const [reportData, setReportData] = useState([]); @@ -19,16 +48,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) }) @@ -37,56 +62,21 @@ const Account = () => { }); }, []); - - if (loading) { return (
{`There is a problem fetching the post data - ${error}`}
) } else { - return ( -
-
-
-
-

Account: {userData.name}

-

Email: {userData.userid}

-

Username: {userData.username}

-

Number of reports saved {reportData.length}

-
-
-
-
- +
+
+

+ User Account +

- -
- + +
+ {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/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 3c2dec78..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}

@@ -36,6 +39,7 @@ class EmptyEntryList extends React.Component { const App = () => { + const [listData, setListData] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); @@ -70,7 +74,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 da60aab9..7493d7c1 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 } @@ -36,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 deleted file mode 100644 index f4981c23..00000000 --- a/DirectReport/browserview/static/js/teamreport.js +++ /dev/null @@ -1,233 +0,0 @@ -const { useState, useEffect } = React; -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 = { - "prompt": commentText - }; - const formDataJsonString = JSON.stringify(dataForm); - fetch("/report", { - method: "POST", - headers: { - "Content-Type": "application/json", - "Accept": "application/json" - }, - body: formDataJsonString - }).then(function(res) { - return res.json(); - }).then(function(data) { - console.log(data); - setTeamData(data); - toggle(); - showGraphics(data, '#map-container'); - showGraphics2(data, '#map-container2'); - showGraphics3(data, '#map-container3'); - }).then(function() { - console.log('done'); - - }); - }; - - const handleClick = e => { - - e.preventDefault() - - var dataForm = { - "prompt": JSON.stringify(teamData) - }; - const formDataJsonString = JSON.stringify(dataForm); - fetch("/generate_email", { - method: "POST", - headers: { - "Content-Type": "application/json", - "Accept": "application/json" - }, - body: formDataJsonString - }).then(function(res) { - return res.json(); - }).then(function(data) { - setGeneratedEmail(data["email"]); - toggleHide(); - }); - } - - const closePopover = () => { - document.getElementById('popover-id-left-purple').classList.toggle("hidden"); - } - - const openPopover = (e: ChangeEvent, teammember) => { - e.preventDefault(); - let element = e.target; - while("BUTTON" !== element.nodeName) { - element = element.parentNode; - } - Popper.createPopper(element, document.getElementById('popover-id-left-purple'), { - 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; - } - - const popoverUI = () => { - return ( -
- ) - } - - const formUI = () => { - return ( -
-
-

Enter - Github Data -

-
-
- -
-
- -
-
-
-
- ) - } - - function toggle() { - setIsOpened(isOpened => !isOpened); - } - - function toggleHide() { - setIsHidden(isHidden => !isHidden); - } - - return ( -
-

- Generate Team Report From Metadata -

-
-
- {formUI()} -
-
-
-

- Summary -

-
- {isOpened && ( -
-

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

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

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

    - {hightlight.title} -

    -

    - {hightlight.description} -

    -
  • - )} -
-
-
- )} -
-
-
-
-
-

Team

- {popoverUI()} -
- {isOpened && ( -
-
- {teamData["team"] && - teamData["team"].map(teammember => - - )} -
-
- )} -
-
-
- - {isOpened && ( -
-

- Data -

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- )} -
- ); -}; - -const domContainer = document.querySelector('#root'); -ReactDOM.render(, domContainer); 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/teamreport.js b/DirectReport/browserview/static/js/teamreport/teamreport.js new file mode 100644 index 00000000..7598b50c --- /dev/null +++ b/DirectReport/browserview/static/js/teamreport/teamreport.js @@ -0,0 +1,179 @@ +const { useState, useEffect } = React; + +const TeamData = () => { + + const [teamData, setTeamData] = useState({}) + const [commentText, setCommentText] = useState("") + const [isOpened, setIsOpened] = useState(false) + + const handleSubmit = e => { + e.preventDefault() + var dataForm = { + "prompt": commentText + }; + const formDataJsonString = JSON.stringify(dataForm); + fetch("/report", { + method: "POST", + headers: { + "Content-Type": "application/json", + "Accept": "application/json" + }, + body: formDataJsonString + }).then(function(res) { + return res.json(); + }).then(function(data) { + setTeamData(data); + toggle(); + showGraphics(data, '#map-container'); + showGraphics2(data, '#map-container2'); + showGraphics3(data, '#map-container3'); + }).then(function() { + console.log('done'); + }); + }; + + const handleClick = e => { + e.preventDefault() + var dataForm = { + "prompt": JSON.stringify(teamData) + }; + const formDataJsonString = JSON.stringify(dataForm); + fetch("/generate_email", { + method: "POST", + headers: { + "Content-Type": "application/json", + "Accept": "application/json" + }, + body: formDataJsonString + }).then(function(res) { + return res.json(); + }).then(function(data) { + setGeneratedEmail(data["email"]); + toggleHide(); + }); + } + + const closePopover = () => { + 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; + while("BUTTON" !== element.nodeName) { + element = element.parentNode; + } + Popper.createPopper(element, document.getElementById('popover-id-left-purple'), { + strategy: 'fixed' + }); + document.getElementById('popover-id-left-purple').classList.toggle("hidden"); + 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" + } + }] + }); + document.getElementById('popover-repo-left-purple').classList.toggle("hidden"); + document.getElementById('popover-repo-TitleContent').innerHTML = "Repos" + "(" + teamData["repos"].length + ")"; + var list = ''; + document.getElementById('popover-repo-Content').innerHTML = list; + } + + const repoPopoverUI = () => { + return ( +
+
+
+ + +
+
+ {/*
*/} + {/*
*/} +
+
+ ) + } + + function toggle() { + setIsOpened(isOpened => !isOpened); + } + + function toggleHide() { + setIsHidden(isHidden => !isHidden); + } + + function toggle() { + setIsOpened(isOpened => !isOpened); + } + + return ( +
+

+ Generate Team Report From Metadata +

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

Summary

+
+ {isOpened && ( +
+ {ShowSummary(teamData["report"])} + {ShowHighlights(teamData["report"])} +
+ )} +
+
+
+
+
+

Team

+ {PopoverUI(closePopover)} +
+ {isOpened && ( +
+ {ShowTeamList(teamData["team"], openPopover)} +
+ )} +
+
+
+ {isOpened && ( + + )} +
+ ); +}; + +const domContainer = document.querySelector('#root'); +ReactDOM.render(, domContainer); 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 @@ -