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

Unit dates selector Component review #573

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 0 additions & 4 deletions .vscode/extensions.json

This file was deleted.

156 changes: 78 additions & 78 deletions docs/ConvertTrello.py
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
import json
import csv
# Load the JSON file
with open('Trello.json', 'r') as file:
data = json.load(file)
# Define the backlogs of interest/Sprints Of interest
backlogs_of_interest_names = [
"Sprint 1 -Upstream Review", "Sprint 1 Complete",
"Sprint 2 Code Review", "Sprint 2 -Upstream Review", "Sprint 2 Complete",
"Sprint 3 Review", "Sprint 3 Complete",
"Sprint 4 Review", "Sprint 4 Complete",
"Numbas - Code-Review", "Numbas - Complete"
]
# Map the list names to their IDs/Names
list_id_to_name_mapping = {}
backlogs_of_interest = []
for list_ in data["lists"]:
if list_["name"] in backlogs_of_interest_names:
backlogs_of_interest.append(list_["id"])
list_id_to_name_mapping[list_["id"]] = list_["name"]
# Extract members
members = {member["id"]: member["fullName"] for member in data["members"]}
# Process cards
cards_by_member = {}
total_story_points = {}
for card in data["cards"]:
if card["idList"] in backlogs_of_interest:
for member in card["idMembers"]:
if member in cards_by_member:
cards_by_member[member].append(card)
else:
cards_by_member[member] = [card]
# Extract story points
story_points = 0
for plugin_data in card.get("pluginData", []):
if "storyPoints" in plugin_data["value"]:
story_points = int(json.loads(plugin_data["value"])["storyPoints"])
# Update total story points for member
if member in total_story_points:
total_story_points[member] += story_points
else:
total_story_points[member] = story_points
# Write the CSV
with open('OntrackTrelloReview.csv', 'w', newline='') as file:
writer = csv.writer(file)
writer.writerow(["Sprint", "Full Name", "Card Name", "GitHub Link", "Story Points", "Total Story Points"])
for member_id, cards in cards_by_member.items():
for index, card in enumerate(cards):
# Extract story points for the current card
story_points = 0
for plugin_data in card.get("pluginData", []):
if "storyPoints" in plugin_data["value"]:
story_points = int(json.loads(plugin_data["value"])["storyPoints"])
# Check for GitHub related info
github_link = None
for attachment in card.get("attachments", []):
if "github.com" in attachment["url"]:
github_link = attachment["url"]
break
# Determine if we should show the total story points for this row
show_total = total_story_points[member_id] if index == len(cards) - 1 else ""
sprint_name = list_id_to_name_mapping[card["idList"]]
writer.writerow([sprint_name, members[member_id], card["name"], github_link, story_points, show_total])
import json
import csv

# Load the JSON file
with open('Trello.json', 'r') as file:
data = json.load(file)

# Define the backlogs of interest/Sprints Of interest
backlogs_of_interest_names = [
"Sprint 1 -Upstream Review", "Sprint 1 Complete",
"Sprint 2 Code Review", "Sprint 2 -Upstream Review", "Sprint 2 Complete",
"Sprint 3 Review", "Sprint 3 Complete",
"Sprint 4 Review", "Sprint 4 Complete",
"Numbas - Code-Review", "Numbas - Complete"
]

# Map the list names to their IDs/Names
list_id_to_name_mapping = {}
backlogs_of_interest = []

for list_ in data["lists"]:
if list_["name"] in backlogs_of_interest_names:
backlogs_of_interest.append(list_["id"])
list_id_to_name_mapping[list_["id"]] = list_["name"]


# Extract members
members = {member["id"]: member["fullName"] for member in data["members"]}

# Process cards
cards_by_member = {}
total_story_points = {}
for card in data["cards"]:
if card["idList"] in backlogs_of_interest:
for member in card["idMembers"]:
if member in cards_by_member:
cards_by_member[member].append(card)
else:
cards_by_member[member] = [card]

# Extract story points
story_points = 0
for plugin_data in card.get("pluginData", []):
if "storyPoints" in plugin_data["value"]:
story_points = int(json.loads(plugin_data["value"])["storyPoints"])

# Update total story points for member
if member in total_story_points:
total_story_points[member] += story_points
else:
total_story_points[member] = story_points

# Write the CSV
with open('OntrackTrelloReview.csv', 'w', newline='') as file:
writer = csv.writer(file)
writer.writerow(["Sprint", "Full Name", "Card Name", "GitHub Link", "Story Points", "Total Story Points"])

for member_id, cards in cards_by_member.items():
for index, card in enumerate(cards):
# Extract story points for the current card
story_points = 0
for plugin_data in card.get("pluginData", []):
if "storyPoints" in plugin_data["value"]:
story_points = int(json.loads(plugin_data["value"])["storyPoints"])

# Check for GitHub related info
github_link = None
for attachment in card.get("attachments", []):
if "github.com" in attachment["url"]:
github_link = attachment["url"]
break

# Determine if we should show the total story points for this row
show_total = total_story_points[member_id] if index == len(cards) - 1 else ""

sprint_name = list_id_to_name_mapping[card["idList"]]
writer.writerow([sprint_name, members[member_id], card["name"], github_link, story_points, show_total])

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Ontrack Component Review

## Team Member Name
Xin Huang | 218161625

## Component Name
`Unit-dates-selector` Component

## Files in this Component
- `unit-dates-selector.coffee`
- `unit-dates-selector.tpl.html`


## Component Purpose

The `unit-dates-selector` component is a date selection tool for editing a unit's key details during the rollover process. It enables users to configure teaching periods, select start and end dates, and save the updated information for the unit.
**Screenshots:**
Original (PDF): ![unit-dates-selector](unit-dates-selector.png)

## Component Functions
The `unit-dates-selector` component allows users to:

- View and select teaching periods: Dynamically load available teaching periods and display them in a dropdown list.
- Pick start and end dates:Use interactive date pickers for precise selection of custom dates.
- Save updated unit details:Submit teaching period or date information to the backend for processing.
- Receive feedback:Display success or error messages after saving data.

## Interaction with Other Components/Services
- **newTeachingPeriodService**
Output:
- Loads and caches available teaching periods.
- Filters and formats data for display in the dropdown.

- **alertService**
Outputs:
- Displays success or error notifications to users.

- **$state**
Redirects users to the updated unit admin page after successful save.

- **Date Pickers**
Outputs:
- Manages the state of two date pickers for `startDate` and `endDate`.



## Migration Steps
I will be following the
[doubtfire-web's Migration Guide](https://github.com/thoth-tech/doubtfire-web/blob/e70f4c7cd1395eaab942ee389788f75f92e985c9/MIGRATION-GUIDE.md)

1. **Analyze Existing Component:**
- Review the AngularJS implementation.
- Identify key functions, filters, and service dependencies.

2. **Setup Angular Environment:**
- Ensure Angular 17 project setup is ready.
- Install required dependencies (e.g., Angular Material, ngx-pagination).

3. **Create Angular Component:**
- Generate a new Angular component `unit-dates-selector`.
- Transfer HTML template and styles to Angular.

4. **Rewrite Core Logic:**
- Migrate key functions (e.g., filtering, pagination, sorting, and CSV export) into TypeScript.
- Replace AngularJS `$scope` with reactive properties using Angular's `@Input` and `@Output`.

5. **Integrate Services:**
- Migrate services (newTeachingPeriodService, alertService) to Angular’s DI system.
- Use Angular Router for navigation instead of $state.

6. **Replace Date Picker:**
- Integrate Angular Material date pickers.
- Replace $scope.calOptions with reactive form controls.

7. **Testing:**
Validate all functionalities:
- Teaching period dropdown.
- Date pickers’ open/close behavior.
- Successful save and error handling.
- Navigation to the updated unit admin page.

8. **Downgrade Component (if needed):**
- Use `UpgradeModule` to allow Angular and AngularJS components to coexist.

## Component Review Checklist

- [ ] Teaching periods load dynamically and correctly.

- [ ] Date pickers toggle and update values properly.

- [ ] Data submission (teaching period or dates) works as expected.

- [ ] Success and error messages are displayed.

- [ ] Navigation occurs after a successful save.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading