Anul 3 Semestrul 1
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"husky": {
|
||||
"version": "0.7.1",
|
||||
"commands": [
|
||||
"husky"
|
||||
],
|
||||
"rollForward": false
|
||||
},
|
||||
"dotnet-format": {
|
||||
"version": "5.1.250801",
|
||||
"commands": [
|
||||
"dotnet-format"
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
# .NET Core
|
||||
bin/
|
||||
obj/
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# Auto-generated files
|
||||
*.generated.cs
|
||||
*.generated.ts
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
x64/
|
||||
x86/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# Visual Studio Code
|
||||
.vscode/
|
||||
|
||||
# Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# User-specific files (Mono Auto Generated)
|
||||
mono_crash.*
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# VS Code directories
|
||||
.vscode/
|
||||
.history/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
/.vs
|
||||
/WebApi/.vs
|
||||
/WebApi/.vs/WebApi/CopilotIndices/0.2.1657.32929
|
||||
/WebApi/.vs/WebApi/FileContentIndex
|
||||
/WebApi/.vs/WebApi/copilot-chat/6ceaa888/sessions
|
||||
/WebApi/.vs/ProjectEvaluation
|
||||
/WebApi/.vs/WebApi/DesignTimeBuild
|
||||
/WebApi/.vs/WebApi/v17
|
||||
|
||||
|
||||
/WebApi/AIModels
|
||||
*.onnx
|
||||
.DS_Store
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"$schema": "https://alirezanet.github.io/Husky.Net/schema.json",
|
||||
"tasks": [
|
||||
{
|
||||
"name": "welcome-message-example",
|
||||
"command": "bash",
|
||||
"args": [ "-c", "echo Husky.Net is awesome!" ],
|
||||
"windows": {
|
||||
"command": "cmd",
|
||||
"args": ["/c", "echo Husky.Net is awesome!" ]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
# Setting Up SQL Server and Configuring Local Database
|
||||
|
||||
This guide will help you set up SQL Server, add a connection string to your project using user secrets, and update the local database using the `dotnet-ef` tool.
|
||||
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before proceeding, ensure you have the following installed:
|
||||
|
||||
- **SQL Server**: Download and install SQL Server [here](https://www.microsoft.com/en-us/sql-server/sql-server-downloads).
|
||||
- **SQL Server Management Studio (SSMS)**: Download and install SSMS [here](https://learn.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms).
|
||||
- **.NET SDK**: Install the latest .NET SDK [here](https://dotnet.microsoft.com/en-us/download).
|
||||
|
||||
---
|
||||
|
||||
## Step 1: Download and Set Up SQL Server
|
||||
|
||||
1. **Download SQL Server**:
|
||||
- Visit the [SQL Server download page](https://www.microsoft.com/en-us/sql-server/sql-server-downloads).
|
||||
- Choose the edition (Developer or Express is free).
|
||||
|
||||
2. **Install SQL Server**:
|
||||
- Follow the installation wizard.
|
||||
- During setup, choose the "Mixed Mode" authentication option to enable both SQL Server Authentication and Windows Authentication.
|
||||
- Note the username (e.g., `sa`) and password you set during installation.
|
||||
|
||||
3. **Verify Installation**:
|
||||
- Open SQL Server Management Studio (SSMS).
|
||||
- Connect to the server using:
|
||||
- **Server name**: `localhost` or `localhost\SQLEXPRESS` (depending on your configuration).
|
||||
- **Authentication**: SQL Server Authentication or Windows Authentication.
|
||||
|
||||
---
|
||||
## Step 2: Create a Database Using SQL Queries
|
||||
|
||||
1. Open **SQL Server Management Studio (SSMS)** and connect to your SQL Server instance.
|
||||
|
||||
2. In the query editor, run the following SQL command to create a database named `Jyros`:
|
||||
```sql
|
||||
CREATE DATABASE Jyros;
|
||||
---
|
||||
## Step 3: Add Connection String in User Secrets
|
||||
|
||||
### Enable User Secrets for Your Project
|
||||
|
||||
1. In the project directory, run:
|
||||
```bash
|
||||
dotnet user-secrets init
|
||||
```
|
||||
|
||||
### Add the Connection String
|
||||
|
||||
2. Run the following command to set the connection string:
|
||||
```bash
|
||||
dotnet user-secrets set "JyrosContext" "Data Source=<server_name>;Initial Catalog=Jyros;Integrated Security=True;TrustServerCertificate=True;"
|
||||
```
|
||||
|
||||
Replace the following placeholders:
|
||||
- `<server_name>`: The name of your server.
|
||||
---
|
||||
|
||||
## Step 4: Update Local Database Using `dotnet-ef`
|
||||
|
||||
### Install `dotnet-ef` Tool
|
||||
|
||||
1. If not already installed, install the `dotnet-ef` CLI tool:
|
||||
```bash
|
||||
dotnet tool install --global dotnet-ef
|
||||
```
|
||||
|
||||
### Apply Migrations
|
||||
|
||||
2. Run the following command to update the local database with the latest migration:
|
||||
```bash
|
||||
dotnet ef database update
|
||||
```
|
||||
|
||||
### Verify Database Changes
|
||||
|
||||
3. Open SSMS and connect to your SQL Server instance.
|
||||
|
||||
4. Verify that the database has been created and updated with the specified tables and schema.
|
||||
|
||||
---
|
||||
|
||||
## Step 5: Add Mock Data to the Database
|
||||
|
||||
After setting up the database and applying migrations, you can insert mock data to test your application.
|
||||
|
||||
1. Open **SQL Server Management Studio (SSMS)** and connect to your SQL Server instance.
|
||||
|
||||
2. In the query editor, select the `Jyros` database, and run the following SQL commands:
|
||||
|
||||
```sql
|
||||
-- Adding mock data for Users
|
||||
INSERT INTO Users (username, Password) VALUES
|
||||
('Alice', 'pass1'),
|
||||
('Bob', 'pass2'),
|
||||
('Charlie', 'pass3'),
|
||||
('Diana', 'pass4');
|
||||
|
||||
-- Adding mock data for Teams
|
||||
INSERT INTO Teams (team_name, team_description, team_lead_id) VALUES
|
||||
('Team Alpha', 'Handles Alpha projects', 1),
|
||||
('Team Beta', 'Focuses on Beta tasks', 2);
|
||||
|
||||
-- Adding mock data for UsersTeams
|
||||
INSERT INTO UsersTeams (user_id, team_id) VALUES
|
||||
(1, 1),
|
||||
(2, 1),
|
||||
(3, 2),
|
||||
(4, 2);
|
||||
|
||||
-- Adding mock data for Sprints
|
||||
INSERT INTO Sprints (name, goal, start_date, end_date, status, team_id) VALUES
|
||||
('Sprint 1', 'Complete initial setup', '2023-01-01', '2023-01-15', 'Active', 1),
|
||||
('Sprint 2', 'Develop core features', '2023-01-16', '2023-01-31', 'Active', 2);
|
||||
|
||||
-- Adding mock data for Stories
|
||||
INSERT INTO Stories (title, description, status, parent_id, sprint_id, created_by, story_points) VALUES
|
||||
('Setup database', 'Create and configure the database', 'To Do', NULL, 1, 1, 5),
|
||||
('Build API', 'Develop the API for the app', 'To Do', NULL, 2, 2, 8);
|
||||
|
||||
-- Adding mock data for UsersStories
|
||||
INSERT INTO UsersStories (story_id, user_id) VALUES
|
||||
(1, 1),
|
||||
(2, 2);
|
||||
|
||||
-- Adding mock data for TeamMemberAvailabilities
|
||||
INSERT INTO TeamMemberAvailabilities (user_id, sprint_id, availability_points) VALUES
|
||||
(1, 1, 20),
|
||||
(2, 1, 15),
|
||||
(3, 2, 18),
|
||||
(4, 2, 22);
|
||||
|
||||
-- Adding mock data for Adjustments
|
||||
INSERT INTO Adjustments (sprint_id, adjustment_points, reason) VALUES
|
||||
( 1, -2, 'lmao'),
|
||||
( 1, 3, 'UwU'),
|
||||
( 2, 0, 'bruh'),
|
||||
( 2, 1, 'bro dieded');
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- **Connection Issues**:
|
||||
- Double-check your connection string in user secrets.
|
||||
- Ensure SQL Server is running (`SQL Server Configuration Manager` > SQL Server Services).
|
||||
- If using `localhost`, try using `127.0.0.1` instead.
|
||||
|
||||
- **`dotnet-ef` Errors**:
|
||||
- Ensure migrations have been created:
|
||||
```bash
|
||||
dotnet ef migrations add InitialCreate
|
||||
```
|
||||
- Ensure the `dotnet-ef` tool is installed.
|
||||
|
||||
---
|
||||
|
||||
You're all set! 🎉 Your local database is now configured and ready for use with your .NET application.
|
||||
@@ -0,0 +1,231 @@
|
||||
# Remove the line below if you want to inherit .editorconfig settings from higher directories
|
||||
root = true
|
||||
|
||||
# C# files
|
||||
[*.cs]
|
||||
|
||||
#### Core EditorConfig Options ####
|
||||
|
||||
# Indentation and spacing
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
tab_width = 4
|
||||
|
||||
# New line preferences
|
||||
end_of_line = crlf
|
||||
insert_final_newline = false
|
||||
|
||||
#### .NET Coding Conventions ####
|
||||
|
||||
# Organize usings
|
||||
dotnet_separate_import_directive_groups = false
|
||||
dotnet_sort_system_directives_first = false
|
||||
file_header_template = unset
|
||||
|
||||
# this. and Me. preferences
|
||||
dotnet_style_qualification_for_event = false
|
||||
dotnet_style_qualification_for_field = false
|
||||
dotnet_style_qualification_for_method = false
|
||||
dotnet_style_qualification_for_property = false
|
||||
|
||||
# Language keywords vs BCL types preferences
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true
|
||||
dotnet_style_predefined_type_for_member_access = true
|
||||
|
||||
# Parentheses preferences
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
|
||||
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
|
||||
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
|
||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
|
||||
|
||||
# Modifier preferences
|
||||
dotnet_style_require_accessibility_modifiers = for_non_interface_members
|
||||
|
||||
# Expression-level preferences
|
||||
dotnet_style_coalesce_expression = true
|
||||
dotnet_style_collection_initializer = true
|
||||
dotnet_style_explicit_tuple_names = true
|
||||
dotnet_style_namespace_match_folder = true
|
||||
dotnet_style_null_propagation = true
|
||||
dotnet_style_object_initializer = true
|
||||
dotnet_style_operator_placement_when_wrapping = beginning_of_line
|
||||
dotnet_style_prefer_auto_properties = true
|
||||
dotnet_style_prefer_collection_expression = when_types_loosely_match
|
||||
dotnet_style_prefer_compound_assignment = true
|
||||
dotnet_style_prefer_conditional_expression_over_assignment = true
|
||||
dotnet_style_prefer_conditional_expression_over_return = true
|
||||
dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed
|
||||
dotnet_style_prefer_inferred_anonymous_type_member_names = true
|
||||
dotnet_style_prefer_inferred_tuple_names = true
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true
|
||||
dotnet_style_prefer_simplified_boolean_expressions = true
|
||||
dotnet_style_prefer_simplified_interpolation = true
|
||||
|
||||
# Field preferences
|
||||
dotnet_style_readonly_field = true
|
||||
|
||||
# Parameter preferences
|
||||
dotnet_code_quality_unused_parameters = all:silent
|
||||
|
||||
# Suppression preferences
|
||||
dotnet_remove_unnecessary_suppression_exclusions = none
|
||||
|
||||
# New line preferences
|
||||
dotnet_style_allow_multiple_blank_lines_experimental = true
|
||||
dotnet_style_allow_statement_immediately_after_block_experimental = true
|
||||
|
||||
#### C# Coding Conventions ####
|
||||
|
||||
# var preferences
|
||||
csharp_style_var_elsewhere = false
|
||||
csharp_style_var_for_built_in_types = false
|
||||
csharp_style_var_when_type_is_apparent = false
|
||||
|
||||
# Expression-bodied members
|
||||
csharp_style_expression_bodied_accessors = true
|
||||
csharp_style_expression_bodied_constructors = false
|
||||
csharp_style_expression_bodied_indexers = true
|
||||
csharp_style_expression_bodied_lambdas = true
|
||||
csharp_style_expression_bodied_local_functions = false
|
||||
csharp_style_expression_bodied_methods = false
|
||||
csharp_style_expression_bodied_operators = false
|
||||
csharp_style_expression_bodied_properties = true
|
||||
|
||||
# Pattern matching preferences
|
||||
csharp_style_pattern_matching_over_as_with_null_check = true
|
||||
csharp_style_pattern_matching_over_is_with_cast_check = true
|
||||
csharp_style_prefer_extended_property_pattern = true
|
||||
csharp_style_prefer_not_pattern = true
|
||||
csharp_style_prefer_pattern_matching = true
|
||||
csharp_style_prefer_switch_expression = true
|
||||
|
||||
# Null-checking preferences
|
||||
csharp_style_conditional_delegate_call = true
|
||||
|
||||
# Modifier preferences
|
||||
csharp_prefer_static_local_function = true
|
||||
csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async
|
||||
csharp_style_prefer_readonly_struct = true
|
||||
csharp_style_prefer_readonly_struct_member = true
|
||||
|
||||
# Code-block preferences
|
||||
csharp_prefer_braces = true
|
||||
csharp_prefer_simple_using_statement = true
|
||||
csharp_style_namespace_declarations = block_scoped
|
||||
csharp_style_prefer_method_group_conversion = true
|
||||
csharp_style_prefer_primary_constructors = true
|
||||
csharp_style_prefer_top_level_statements = true
|
||||
|
||||
# Expression-level preferences
|
||||
csharp_prefer_simple_default_expression = true
|
||||
csharp_style_deconstructed_variable_declaration = true
|
||||
csharp_style_implicit_object_creation_when_type_is_apparent = true
|
||||
csharp_style_inlined_variable_declaration = true
|
||||
csharp_style_prefer_index_operator = true
|
||||
csharp_style_prefer_local_over_anonymous_function = true
|
||||
csharp_style_prefer_null_check_over_type_check = true
|
||||
csharp_style_prefer_range_operator = true
|
||||
csharp_style_prefer_tuple_swap = true
|
||||
csharp_style_prefer_utf8_string_literals = true
|
||||
csharp_style_throw_expression = true
|
||||
csharp_style_unused_value_assignment_preference = discard_variable
|
||||
csharp_style_unused_value_expression_statement_preference = discard_variable
|
||||
|
||||
# 'using' directive preferences
|
||||
csharp_using_directive_placement = outside_namespace
|
||||
|
||||
# New line preferences
|
||||
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true
|
||||
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true
|
||||
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true
|
||||
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true
|
||||
csharp_style_allow_embedded_statements_on_same_line_experimental = true
|
||||
|
||||
#### C# Formatting Rules ####
|
||||
|
||||
# New line preferences
|
||||
csharp_new_line_before_catch = true
|
||||
csharp_new_line_before_else = true
|
||||
csharp_new_line_before_finally = true
|
||||
csharp_new_line_before_members_in_anonymous_types = true
|
||||
csharp_new_line_before_members_in_object_initializers = true
|
||||
csharp_new_line_before_open_brace = all
|
||||
csharp_new_line_between_query_expression_clauses = true
|
||||
|
||||
# Indentation preferences
|
||||
csharp_indent_block_contents = true
|
||||
csharp_indent_braces = false
|
||||
csharp_indent_case_contents = true
|
||||
csharp_indent_case_contents_when_block = true
|
||||
csharp_indent_labels = one_less_than_current
|
||||
csharp_indent_switch_labels = true
|
||||
|
||||
# Space preferences
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_after_colon_in_inheritance_clause = true
|
||||
csharp_space_after_comma = true
|
||||
csharp_space_after_dot = false
|
||||
csharp_space_after_keywords_in_control_flow_statements = true
|
||||
csharp_space_after_semicolon_in_for_statement = true
|
||||
csharp_space_around_binary_operators = before_and_after
|
||||
csharp_space_around_declaration_statements = false
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
csharp_space_before_comma = false
|
||||
csharp_space_before_dot = false
|
||||
csharp_space_before_open_square_brackets = false
|
||||
csharp_space_before_semicolon_in_for_statement = false
|
||||
csharp_space_between_empty_square_brackets = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_name_and_open_parenthesis = false
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = false
|
||||
csharp_space_between_square_brackets = false
|
||||
|
||||
# Wrapping preferences
|
||||
csharp_preserve_single_line_blocks = true
|
||||
csharp_preserve_single_line_statements = true
|
||||
|
||||
#### Naming styles ####
|
||||
|
||||
# Naming rules
|
||||
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
|
||||
|
||||
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
|
||||
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
|
||||
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
|
||||
|
||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
|
||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
|
||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
|
||||
|
||||
# Symbol specifications
|
||||
|
||||
dotnet_naming_symbols.interface.applicable_kinds = interface
|
||||
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.interface.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
|
||||
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.types.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
|
||||
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.non_field_members.required_modifiers =
|
||||
|
||||
# Naming styles
|
||||
|
||||
dotnet_naming_style.pascal_case.required_prefix =
|
||||
dotnet_naming_style.pascal_case.required_suffix =
|
||||
dotnet_naming_style.pascal_case.word_separator =
|
||||
dotnet_naming_style.pascal_case.capitalization = pascal_case
|
||||
|
||||
dotnet_naming_style.begins_with_i.required_prefix = I
|
||||
dotnet_naming_style.begins_with_i.required_suffix =
|
||||
dotnet_naming_style.begins_with_i.word_separator =
|
||||
dotnet_naming_style.begins_with_i.capitalization = pascal_case
|
||||
@@ -0,0 +1,196 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using WebApi.Models;
|
||||
|
||||
namespace WebApi.Context;
|
||||
|
||||
public partial class JyrosContext : DbContext
|
||||
{
|
||||
public JyrosContext()
|
||||
{
|
||||
}
|
||||
|
||||
public JyrosContext(DbContextOptions<JyrosContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public required virtual DbSet<Sprint> Sprints { get; set; }
|
||||
|
||||
public required virtual DbSet<Story> Stories { get; set; }
|
||||
|
||||
|
||||
public required virtual DbSet<Team> Teams { get; set; }
|
||||
|
||||
public required virtual DbSet<User> Users { get; set; }
|
||||
|
||||
public required virtual DbSet<TeamMemberAvailability> TeamMemberAvailabilities { get; set; }
|
||||
|
||||
public required virtual DbSet<Adjustment> Adjustments { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Sprint>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.SprintId).HasName("PK__Sprints__396C1802EFA36E05");
|
||||
|
||||
entity.Property(e => e.SprintId).HasColumnName("sprint_id");
|
||||
entity.Property(e => e.EndDate).HasColumnName("end_date");
|
||||
entity.Property(e => e.Goal)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("goal");
|
||||
entity.Property(e => e.Name)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("name");
|
||||
entity.Property(e => e.StartDate).HasColumnName("start_date");
|
||||
entity.Property(e => e.Status)
|
||||
.HasMaxLength(50)
|
||||
.HasDefaultValue("planned")
|
||||
.HasColumnName("status");
|
||||
entity.Property(e => e.TeamId).HasColumnName("team_id");
|
||||
|
||||
entity.HasOne(d => d.Team).WithMany(p => p.Sprints)
|
||||
.HasForeignKey(d => d.TeamId)
|
||||
.HasConstraintName("FK__Sprints__team_id__693CA210");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Story>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.StoryId).HasName("PK__Stories__66339C56B86254B8");
|
||||
|
||||
entity.Property(e => e.StoryId).HasColumnName("story_id");
|
||||
entity.Property(e => e.CreatedBy).HasColumnName("created_by");
|
||||
entity.Property(e => e.Description)
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnName("description");
|
||||
entity.Property(e => e.ParentId).HasColumnName("parent_id");
|
||||
entity.Property(e => e.SprintId).HasColumnName("sprint_id");
|
||||
entity.Property(e => e.Status)
|
||||
.HasMaxLength(15)
|
||||
.HasDefaultValue("open")
|
||||
.HasColumnName("status");
|
||||
entity.Property(e => e.Priority).HasDefaultValue(1).HasColumnName("priority");
|
||||
entity.Property(e => e.StoryPoints).HasColumnName("story_points");
|
||||
entity.Property(e => e.Title)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("title");
|
||||
|
||||
entity.HasOne(d => d.CreatedByNavigation).WithMany(p => p.Stories)
|
||||
.HasForeignKey(d => d.CreatedBy)
|
||||
.HasConstraintName("FK__Stories__created__6FE99F9F");
|
||||
|
||||
entity.HasOne(d => d.Parent).WithMany(p => p.InverseParent)
|
||||
.HasForeignKey(d => d.ParentId)
|
||||
.HasConstraintName("FK__Stories__parent___70DDC3D8");
|
||||
|
||||
entity.HasOne(d => d.Sprint).WithMany(p => p.Stories)
|
||||
.HasForeignKey(d => d.SprintId)
|
||||
.HasConstraintName("FK__Stories__sprint___6EF57B66");
|
||||
|
||||
entity.HasMany(d => d.Users).WithMany(p => p.StoriesNavigation)
|
||||
.UsingEntity<Dictionary<string, object>>(
|
||||
"UsersStory",
|
||||
r => r.HasOne<User>().WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK__UsersStor__user___74AE54BC"),
|
||||
l => l.HasOne<Story>().WithMany()
|
||||
.HasForeignKey("StoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK__UsersStor__story__73BA3083"),
|
||||
j =>
|
||||
{
|
||||
j.HasKey("StoryId", "UserId").HasName("PK__UsersSto__8DA87F2683494916");
|
||||
j.ToTable("UsersStories");
|
||||
j.IndexerProperty<int>("StoryId").HasColumnName("story_id");
|
||||
j.IndexerProperty<int>("UserId").HasColumnName("user_id");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Team>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.TeamId).HasName("PK__Teams__F82DEDBCAAB0C3AF");
|
||||
|
||||
entity.HasIndex(e => e.TeamName, "UQ__Teams__29E35E0C9F1894C7").IsUnique();
|
||||
|
||||
entity.Property(e => e.TeamId).HasColumnName("team_id");
|
||||
entity.Property(e => e.TeamDescription)
|
||||
.HasMaxLength(500)
|
||||
.HasColumnName("team_description");
|
||||
entity.Property(e => e.TeamLeadId).HasColumnName("team_lead_id");
|
||||
entity.Property(e => e.TeamName)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("team_name");
|
||||
|
||||
entity.HasOne(d => d.TeamLead).WithMany(p => p.Teams)
|
||||
.HasForeignKey(d => d.TeamLeadId)
|
||||
.HasConstraintName("FK__Teams__team_lead__60A75C0F");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<User>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.UserId).HasName("PK__Users__B9BE370FA0824176");
|
||||
|
||||
entity.HasIndex(e => e.Username, "UQ__Users__F3DBC572843AEA6F").IsUnique();
|
||||
|
||||
entity.Property(e => e.UserId).HasColumnName("user_id");
|
||||
entity.Property(e => e.Username)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("username");
|
||||
|
||||
entity.HasMany(d => d.TeamsNavigation).WithMany(p => p.Users)
|
||||
.UsingEntity<Dictionary<string, object>>(
|
||||
"UsersTeam",
|
||||
r => r.HasOne<Team>().WithMany()
|
||||
.HasForeignKey("TeamId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK__UsersTeam__team___6477ECF3"),
|
||||
l => l.HasOne<User>().WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK__UsersTeam__user___6383C8BA"),
|
||||
j =>
|
||||
{
|
||||
j.HasKey("UserId", "TeamId").HasName("PK__UsersTea__663CE9D4131E7ED3");
|
||||
j.ToTable("UsersTeams");
|
||||
j.IndexerProperty<int>("UserId").HasColumnName("user_id");
|
||||
j.IndexerProperty<int>("TeamId").HasColumnName("team_id");
|
||||
});
|
||||
});
|
||||
modelBuilder.Entity<TeamMemberAvailability>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK__TeamMemb__3214EC07A9A5EE06");
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.UserId).HasColumnName("user_id");
|
||||
entity.Property(e => e.SprintId).HasColumnName("sprint_id");
|
||||
entity.Property(e => e.AvailabilityPoints).HasColumnName("availability_points");
|
||||
|
||||
entity.HasOne(d => d.Sprint).WithMany(p => p.TeamMemberAvailabilities)
|
||||
.HasForeignKey(d => d.SprintId)
|
||||
.HasConstraintName("FK__TeamMembe__sprin__6DCC4D03");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Adjustment>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK__Adjustme__3214EC07B3BFDA02");
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.SprintId).HasColumnName("sprint_id");
|
||||
entity.Property(e => e.AdjustmentPoints).HasColumnName("adjustment_points");
|
||||
entity.Property(e => e.Reason)
|
||||
.HasMaxLength(100)
|
||||
.HasColumnName("reason");
|
||||
|
||||
entity.HasOne(d => d.Sprint).WithMany(p => p.Adjustments)
|
||||
.HasForeignKey(d => d.SprintId)
|
||||
.HasConstraintName("FK__Adjustmen__sprin__6EC0713C");
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||
}
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WebApi.Context;
|
||||
using WebApi.Models;
|
||||
using WebApi.Repositories;
|
||||
using WebApi.RepositoryInterfaces;
|
||||
|
||||
namespace WebApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class BacklogController : ControllerBase
|
||||
{
|
||||
private readonly User user = Globals.curretUser;
|
||||
private readonly IStoryRepository _storyRepository;
|
||||
private readonly ISprintRepository _sprintRepository;
|
||||
private readonly IAdjustmentRepository _adjustmentRepository;
|
||||
private readonly ITeamMemberAvailabilityRepository _teamMemberAvailabilityRepository;
|
||||
|
||||
public BacklogController(IStoryRepository storyRepository,
|
||||
ISprintRepository sprintRepository,
|
||||
IAdjustmentRepository adjustmentRepository,
|
||||
ITeamMemberAvailabilityRepository teamMemberAvailabilityRepository)
|
||||
{
|
||||
_storyRepository = storyRepository;
|
||||
_sprintRepository = sprintRepository;
|
||||
user = new User
|
||||
{
|
||||
UserId = 1,
|
||||
Username = "alice_smith"
|
||||
};
|
||||
_adjustmentRepository = adjustmentRepository;
|
||||
_teamMemberAvailabilityRepository = teamMemberAvailabilityRepository;
|
||||
}
|
||||
|
||||
[HttpGet("{page}/{count}")]
|
||||
public async Task<IActionResult> GetAsync(int page, int count)
|
||||
{
|
||||
if (count <= 200)
|
||||
return Ok(await _storyRepository.GetPaginated(page, count));
|
||||
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
[HttpGet("details/{id}")]
|
||||
public async Task<IActionResult> Get(int id)
|
||||
{
|
||||
var story = await _storyRepository.GetById(id);
|
||||
|
||||
return story != null ? Ok(story) : NotFound();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostAsync([FromBody] Story story)
|
||||
{
|
||||
try
|
||||
{
|
||||
story.CreatedBy = user.UserId;
|
||||
story.StoryId = default;
|
||||
await _storyRepository.Add(story);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutAsync([FromBody] Story story)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _storyRepository.Update(story);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteAsync(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _storyRepository.Delete(id);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{searchKey}/{page}/{pageSize}")]
|
||||
public async Task<IActionResult> GetFilteredPaginated(string searchKey, int page, int pageSize)
|
||||
{
|
||||
if (pageSize <= 200)
|
||||
return Ok(await _storyRepository.GetFilteredPaginated(searchKey, page, pageSize));
|
||||
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
[HttpGet("shift/{page}/{count}")]
|
||||
public async Task<IActionResult> GetShiftAsync(int page, int count)
|
||||
{
|
||||
if (count <= 200)
|
||||
return Ok(await _sprintRepository.GetPaginated(page, count));
|
||||
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("shift/details/{id}")]
|
||||
public async Task<IActionResult> GetShift(int id)
|
||||
{
|
||||
var sprint = await _sprintRepository.GetById(id);
|
||||
|
||||
return sprint != null ? Ok(sprint) : NotFound();
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("shift")]
|
||||
public async Task<IActionResult> PostSprintAsync([FromBody] Sprint sprint)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _sprintRepository.Add(sprint);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("availability")]
|
||||
public async Task<IActionResult> GetNetAvailabilityOnShift()
|
||||
{
|
||||
var availabilities = (await _sprintRepository.GetAll())
|
||||
.Select(async s => new
|
||||
{
|
||||
sprintId = s.SprintId,
|
||||
availability = await _teamMemberAvailabilityRepository.GetTotalAvailabilityPerSprint(s.SprintId) -
|
||||
await _adjustmentRepository.GetAdjustmentsPerSprint(s.SprintId)
|
||||
})
|
||||
.Select(s => s.Result);
|
||||
|
||||
return Ok(availabilities);
|
||||
|
||||
/*int adjustmentsPerSprintTask =
|
||||
await _adjustmentRepository.GetAdjustmentsPerSprint(sprint_id);
|
||||
int devAvailabilityPerSprintTask =
|
||||
await _teamMemberAvailabilityRepository.GetTotalAvailabilityPerSprint(sprint_id);
|
||||
|
||||
return Ok(devAvailabilityPerSprintTask - adjustmentsPerSprintTask);*/
|
||||
}
|
||||
}
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WebApi.Context;
|
||||
using WebApi.Models;
|
||||
|
||||
namespace WebApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class TestController : ControllerBase
|
||||
{
|
||||
private readonly JyrosContext _context;
|
||||
|
||||
public TestController(JyrosContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> Index()
|
||||
{
|
||||
try
|
||||
{
|
||||
var teams = await _context.Teams.Include(t => t.TeamLead).ToListAsync();
|
||||
return Ok(teams);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return BadRequest(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("AddRandomTeam")]
|
||||
public async Task<ActionResult> AddRandomTeam()
|
||||
{
|
||||
try
|
||||
{
|
||||
var random = new Random();
|
||||
var team = new Team
|
||||
{
|
||||
TeamName = "Team " + random.Next(1, 1000),
|
||||
TeamDescription = "Description for team " + random.Next(1, 1000),
|
||||
TeamLeadId = 1
|
||||
};
|
||||
|
||||
_context.Teams.Add(team);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Ok(team);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return BadRequest(e.Message);
|
||||
}
|
||||
}
|
||||
//add a method that gets a team id and returns the teamlead of that team
|
||||
[HttpGet("GetTeamLead/{teamId}")]
|
||||
public async Task<ActionResult> GetTeamLead(int teamId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var team = await _context.Teams.FirstOrDefaultAsync(t => t.TeamId == teamId);
|
||||
return Ok(team?.TeamLead);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return BadRequest(e.Message);
|
||||
}
|
||||
}
|
||||
//add a methode that adds a team
|
||||
[HttpPost("AddTeam")]
|
||||
public async Task<ActionResult> AddTeam(Team team)
|
||||
{
|
||||
try
|
||||
{
|
||||
_context.Teams.Add(team);
|
||||
await _context.SaveChangesAsync();
|
||||
return Ok(team);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return BadRequest(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
//get all users
|
||||
[HttpGet("GetAllUsers")]
|
||||
public async Task<ActionResult> GetAllUsers()
|
||||
{
|
||||
try
|
||||
{
|
||||
var users = await _context.Users.ToListAsync();
|
||||
return Ok(users);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return BadRequest(e.Message);
|
||||
}
|
||||
}
|
||||
//get users in a team
|
||||
[HttpGet("GetUsersInTeam/{teamId}")]
|
||||
public async Task<ActionResult> GetUsersInTeam(int teamId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var team = await _context.Teams.Include(t => t.Users).FirstOrDefaultAsync(t => t.TeamId == teamId);
|
||||
return Ok(team?.Users);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return BadRequest(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WebApi.Models;
|
||||
using WebApi.RepositoryInterfaces;
|
||||
|
||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
namespace WebApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
|
||||
public class ShiftAvailabilityController : Controller
|
||||
{
|
||||
private readonly IUserRepository _userRepository;
|
||||
private readonly ITeamMemberAvailabilityRepository _teamMemberAvailabilityRepository;
|
||||
private readonly ISprintRepository _sprintRepository;
|
||||
private readonly IAdjustmentRepository _adjustmentRepository;
|
||||
|
||||
public ShiftAvailabilityController(IUserRepository userRepository, ITeamMemberAvailabilityRepository teamMemberAvailabilityRepository, ISprintRepository sprintRepository, IAdjustmentRepository adjustmentRepository)
|
||||
{
|
||||
_userRepository = userRepository;
|
||||
_teamMemberAvailabilityRepository = teamMemberAvailabilityRepository;
|
||||
_sprintRepository = sprintRepository;
|
||||
_adjustmentRepository = adjustmentRepository;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
return Ok(await _teamMemberAvailabilityRepository.GetAll());
|
||||
}
|
||||
|
||||
[HttpGet("{sprintId}/{userId}")]
|
||||
public async Task<IActionResult> GetAvailability(int sprintId, int userId)
|
||||
{
|
||||
var teamMemberAvailability = await _teamMemberAvailabilityRepository.GetBySprintIdAndUserId(sprintId, userId);
|
||||
return teamMemberAvailability != null ? Ok(teamMemberAvailability) : NotFound();
|
||||
}
|
||||
|
||||
[HttpGet("{sprintId}/adjustment")]
|
||||
public async Task<IActionResult> GetAdjustmentLength(int sprintId)
|
||||
{
|
||||
var adjustments = await _adjustmentRepository.GetAll();
|
||||
var filteredAdjustments = adjustments.Where(a => a.SprintId == sprintId).ToList();
|
||||
|
||||
var totalAdjustment = filteredAdjustments.Sum(a => a.AdjustmentPoints);
|
||||
|
||||
return Ok(totalAdjustment);
|
||||
}
|
||||
|
||||
[HttpGet("{sprintId}/adjustment/all")]
|
||||
public async Task<IActionResult> GetAllAdjustments(int sprintId)
|
||||
{
|
||||
var adjustments = await _adjustmentRepository.GetAll();
|
||||
var filteredAdjustments = adjustments.Where(a => a.SprintId == sprintId).ToList();
|
||||
return Ok(filteredAdjustments);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("sprints")]
|
||||
public async Task<IActionResult> GetSprints()
|
||||
{
|
||||
return Ok(await _sprintRepository.GetAll());
|
||||
}
|
||||
|
||||
[HttpGet("sprints/{sprintId}/users")]
|
||||
public async Task<IActionResult> GetUsers(int sprintId)
|
||||
{
|
||||
return Ok(await _userRepository.GetUsersBySprintId(sprintId));
|
||||
}
|
||||
|
||||
[HttpPost("{sprintId}/adjustment")]
|
||||
public async Task<IActionResult> PostAdjustment(int sprintId, [FromBody] Adjustment adjustment)
|
||||
{
|
||||
try
|
||||
{
|
||||
adjustment.SprintId = sprintId;
|
||||
adjustment.Id = default;
|
||||
await _adjustmentRepository.Add(adjustment);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut("{sprintId}/{userId}")]
|
||||
public async Task<IActionResult> PutAvailability(int sprintId, int userId, [FromBody] TeamMemberAvailability teamMemberAvailability)
|
||||
{
|
||||
try
|
||||
{
|
||||
TeamMemberAvailability existingAvailability = await _teamMemberAvailabilityRepository.GetBySprintIdAndUserId(sprintId, userId);
|
||||
existingAvailability.AvailabilityPoints = teamMemberAvailability.AvailabilityPoints;
|
||||
await _teamMemberAvailabilityRepository.Update(existingAvailability);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WebApi.Context;
|
||||
using WebApi.Models;
|
||||
using WebApi.RepositoryInterfaces;
|
||||
using WebApi.Services;
|
||||
|
||||
namespace WebApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class TicketController : ControllerBase
|
||||
{
|
||||
private readonly User user = Globals.curretUser;
|
||||
private readonly IStoryRepository _storyRepository;
|
||||
private readonly StoryPointEstimator _storyPointEstimator;
|
||||
public TicketController(IStoryRepository storyRepository)
|
||||
{
|
||||
_storyRepository = storyRepository;
|
||||
user = new User
|
||||
{
|
||||
UserId = 1,
|
||||
Username = "alice_smith"
|
||||
};
|
||||
_storyPointEstimator = new StoryPointEstimator();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAsync()
|
||||
{
|
||||
return Ok(await _storyRepository.GetAll());
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public async Task<IActionResult> Get(int id)
|
||||
{
|
||||
var story = await _storyRepository.GetById(id);
|
||||
|
||||
return story != null ? Ok(story) : NotFound();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostAsync([FromBody] Story story)
|
||||
{
|
||||
try
|
||||
{
|
||||
story.CreatedBy = user.UserId;
|
||||
story.StoryId = default;
|
||||
story.ParentId = default;
|
||||
await _storyRepository.Add(story);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public struct StatusUpdate
|
||||
{
|
||||
public string Status { get; set; }
|
||||
}
|
||||
|
||||
[HttpPut("{id}/status")]
|
||||
public async Task<IActionResult> PutAsync([FromBody] StatusUpdate status, int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var story = await _storyRepository.GetById(id);
|
||||
story.Status = status.Status;
|
||||
await _storyRepository.Update(story);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutAsync([FromBody] Story story, int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
story.StoryId = id;
|
||||
await _storyRepository.Update(story);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteAsync(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var story = await _storyRepository.GetById(id);
|
||||
if (story == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
await _storyRepository.Delete(id);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("EstimateStoryPoints")]
|
||||
public async Task<IActionResult> EstimateStoryPointsAsync(string title, string? description)
|
||||
{
|
||||
var stories = await _storyRepository.GetAll();
|
||||
var storyPoints = await _storyPointEstimator.EstimateStoryPoints(title, description ?? string.Empty);
|
||||
return Ok(storyPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WebApi.Models;
|
||||
using WebApi.RepositoryInterfaces;
|
||||
|
||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
namespace WebApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class UserController : ControllerBase
|
||||
{
|
||||
|
||||
private readonly IUserRepository _userRepository;
|
||||
|
||||
public UserController(IUserRepository userRepository)
|
||||
{
|
||||
_userRepository = userRepository;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
return Ok(await _userRepository.GetAll());
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public async Task<IActionResult> Get(int id)
|
||||
{
|
||||
var user = await _userRepository.GetById(id);
|
||||
return user != null ? Ok(user) : NotFound();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Post([FromBody] User user)
|
||||
{
|
||||
try
|
||||
{
|
||||
user.UserId = default;
|
||||
await _userRepository.Add(user);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("/login")]
|
||||
public async Task<IActionResult> LogIn([FromBody]User user)
|
||||
{
|
||||
var userDb = await _userRepository.GetUserByName(user.Username);
|
||||
Console.WriteLine(user.Username);
|
||||
if (user == null)
|
||||
{
|
||||
return BadRequest(new { Message = "Invalid username" });
|
||||
}
|
||||
else if (user.Password != userDb.Password)
|
||||
{
|
||||
return BadRequest(new { Message = "Password is incorect" });
|
||||
}
|
||||
Globals.curretUser = user;
|
||||
return Ok(new {Message = "Login succes", User = userDb});
|
||||
}
|
||||
|
||||
[HttpGet("currentUser")]
|
||||
public async Task<IActionResult> GetGlobalUser()
|
||||
{
|
||||
return Ok(Globals.curretUser);
|
||||
}
|
||||
|
||||
[HttpGet("isLoggedIn")]
|
||||
public async Task<IActionResult> IsLoggedIn()
|
||||
{
|
||||
return Ok(Globals.curretUser.Username == null ? false : true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace WebApi.Enums
|
||||
{
|
||||
public enum Status
|
||||
{
|
||||
[Description("open")]
|
||||
Open,
|
||||
[Description("in progress")]
|
||||
InProgress,
|
||||
[Description("completed")]
|
||||
Completed
|
||||
}
|
||||
}
|
||||
+413
@@ -0,0 +1,413 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using WebApi.Context;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WebApi.Migrations
|
||||
{
|
||||
[DbContext(typeof(JyrosContext))]
|
||||
[Migration("20241221184059_db-creation")]
|
||||
partial class dbcreation
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.10")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("UsersStory", b =>
|
||||
{
|
||||
b.Property<int>("StoryId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("story_id");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.HasKey("StoryId", "UserId")
|
||||
.HasName("PK__UsersSto__8DA87F2683494916");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("UsersStories", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UsersTeam", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.Property<int>("TeamId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_id");
|
||||
|
||||
b.HasKey("UserId", "TeamId")
|
||||
.HasName("PK__UsersTea__663CE9D4131E7ED3");
|
||||
|
||||
b.HasIndex("TeamId");
|
||||
|
||||
b.ToTable("UsersTeams", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Adjustment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AdjustmentPoints")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("adjustment_points");
|
||||
|
||||
b.Property<int>("SprintId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("PK__Adjustme__3214EC07B3BFDA02");
|
||||
|
||||
b.HasIndex("SprintId");
|
||||
|
||||
b.ToTable("Adjustments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Sprint", b =>
|
||||
{
|
||||
b.Property<int>("SprintId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("SprintId"));
|
||||
|
||||
b.Property<DateOnly>("EndDate")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("end_date");
|
||||
|
||||
b.Property<string>("Goal")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("goal");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("name");
|
||||
|
||||
b.Property<DateOnly>("StartDate")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("start_date");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasDefaultValue("planned")
|
||||
.HasColumnName("status");
|
||||
|
||||
b.Property<int?>("TeamId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_id");
|
||||
|
||||
b.HasKey("SprintId")
|
||||
.HasName("PK__Sprints__396C1802EFA36E05");
|
||||
|
||||
b.HasIndex("TeamId");
|
||||
|
||||
b.ToTable("Sprints");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Story", b =>
|
||||
{
|
||||
b.Property<int>("StoryId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("story_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("StoryId"));
|
||||
|
||||
b.Property<int?>("CreatedBy")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("created_by");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("nvarchar(1000)")
|
||||
.HasColumnName("description");
|
||||
|
||||
b.Property<int?>("ParentId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("parent_id");
|
||||
|
||||
b.Property<int?>("SprintId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasMaxLength(15)
|
||||
.HasColumnType("nvarchar(15)")
|
||||
.HasDefaultValue("open")
|
||||
.HasColumnName("status");
|
||||
|
||||
b.Property<int?>("StoryPoints")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("story_points");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("title");
|
||||
|
||||
b.HasKey("StoryId")
|
||||
.HasName("PK__Stories__66339C56B86254B8");
|
||||
|
||||
b.HasIndex("CreatedBy");
|
||||
|
||||
b.HasIndex("ParentId");
|
||||
|
||||
b.HasIndex("SprintId");
|
||||
|
||||
b.ToTable("Stories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Team", b =>
|
||||
{
|
||||
b.Property<int>("TeamId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("TeamId"));
|
||||
|
||||
b.Property<string>("TeamDescription")
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("nvarchar(500)")
|
||||
.HasColumnName("team_description");
|
||||
|
||||
b.Property<int?>("TeamLeadId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_lead_id");
|
||||
|
||||
b.Property<string>("TeamName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("team_name");
|
||||
|
||||
b.HasKey("TeamId")
|
||||
.HasName("PK__Teams__F82DEDBCAAB0C3AF");
|
||||
|
||||
b.HasIndex("TeamLeadId");
|
||||
|
||||
b.HasIndex(new[] { "TeamName" }, "UQ__Teams__29E35E0C9F1894C7")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Teams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.TeamMemberAvailability", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AvailabilityPoints")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("availability_points");
|
||||
|
||||
b.Property<int>("SprintId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("PK__TeamMemb__3214EC07A9A5EE06");
|
||||
|
||||
b.HasIndex("SprintId");
|
||||
|
||||
b.ToTable("TeamMemberAvailabilities");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("UserId"));
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("username");
|
||||
|
||||
b.HasKey("UserId")
|
||||
.HasName("PK__Users__B9BE370FA0824176");
|
||||
|
||||
b.HasIndex(new[] { "Username" }, "UQ__Users__F3DBC572843AEA6F")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UsersStory", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Story", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("StoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersStor__story__73BA3083");
|
||||
|
||||
b.HasOne("WebApi.Models.User", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersStor__user___74AE54BC");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UsersTeam", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Team", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("TeamId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersTeam__team___6477ECF3");
|
||||
|
||||
b.HasOne("WebApi.Models.User", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersTeam__user___6383C8BA");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Adjustment", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Sprint", "Sprint")
|
||||
.WithMany("Adjustments")
|
||||
.HasForeignKey("SprintId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__Adjustmen__sprin__6EC0713C");
|
||||
|
||||
b.Navigation("Sprint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Sprint", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Team", "Team")
|
||||
.WithMany("Sprints")
|
||||
.HasForeignKey("TeamId")
|
||||
.HasConstraintName("FK__Sprints__team_id__693CA210");
|
||||
|
||||
b.Navigation("Team");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Story", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.User", "CreatedByNavigation")
|
||||
.WithMany("Stories")
|
||||
.HasForeignKey("CreatedBy")
|
||||
.HasConstraintName("FK__Stories__created__6FE99F9F");
|
||||
|
||||
b.HasOne("WebApi.Models.Story", "Parent")
|
||||
.WithMany("InverseParent")
|
||||
.HasForeignKey("ParentId")
|
||||
.HasConstraintName("FK__Stories__parent___70DDC3D8");
|
||||
|
||||
b.HasOne("WebApi.Models.Sprint", "Sprint")
|
||||
.WithMany("Stories")
|
||||
.HasForeignKey("SprintId")
|
||||
.HasConstraintName("FK__Stories__sprint___6EF57B66");
|
||||
|
||||
b.Navigation("CreatedByNavigation");
|
||||
|
||||
b.Navigation("Parent");
|
||||
|
||||
b.Navigation("Sprint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Team", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.User", "TeamLead")
|
||||
.WithMany("Teams")
|
||||
.HasForeignKey("TeamLeadId")
|
||||
.HasConstraintName("FK__Teams__team_lead__60A75C0F");
|
||||
|
||||
b.Navigation("TeamLead");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.TeamMemberAvailability", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Sprint", "Sprint")
|
||||
.WithMany("TeamMemberAvailabilities")
|
||||
.HasForeignKey("SprintId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__TeamMembe__sprin__6DCC4D03");
|
||||
|
||||
b.Navigation("Sprint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Sprint", b =>
|
||||
{
|
||||
b.Navigation("Adjustments");
|
||||
|
||||
b.Navigation("Stories");
|
||||
|
||||
b.Navigation("TeamMemberAvailabilities");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Story", b =>
|
||||
{
|
||||
b.Navigation("InverseParent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Team", b =>
|
||||
{
|
||||
b.Navigation("Sprints");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.User", b =>
|
||||
{
|
||||
b.Navigation("Stories");
|
||||
|
||||
b.Navigation("Teams");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
+280
@@ -0,0 +1,280 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using System;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WebApi.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class dbcreation : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Users",
|
||||
columns: table => new
|
||||
{
|
||||
user_id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
username = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK__Users__B9BE370FA0824176", x => x.user_id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Teams",
|
||||
columns: table => new
|
||||
{
|
||||
team_id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
team_name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
||||
team_description = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
|
||||
team_lead_id = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK__Teams__F82DEDBCAAB0C3AF", x => x.team_id);
|
||||
table.ForeignKey(
|
||||
name: "FK__Teams__team_lead__60A75C0F",
|
||||
column: x => x.team_lead_id,
|
||||
principalTable: "Users",
|
||||
principalColumn: "user_id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Sprints",
|
||||
columns: table => new
|
||||
{
|
||||
sprint_id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
||||
goal = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
|
||||
start_date = table.Column<DateOnly>(type: "date", nullable: false),
|
||||
end_date = table.Column<DateOnly>(type: "date", nullable: false),
|
||||
status = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true, defaultValue: "planned"),
|
||||
team_id = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK__Sprints__396C1802EFA36E05", x => x.sprint_id);
|
||||
table.ForeignKey(
|
||||
name: "FK__Sprints__team_id__693CA210",
|
||||
column: x => x.team_id,
|
||||
principalTable: "Teams",
|
||||
principalColumn: "team_id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "UsersTeams",
|
||||
columns: table => new
|
||||
{
|
||||
user_id = table.Column<int>(type: "int", nullable: false),
|
||||
team_id = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK__UsersTea__663CE9D4131E7ED3", x => new { x.user_id, x.team_id });
|
||||
table.ForeignKey(
|
||||
name: "FK__UsersTeam__team___6477ECF3",
|
||||
column: x => x.team_id,
|
||||
principalTable: "Teams",
|
||||
principalColumn: "team_id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK__UsersTeam__user___6383C8BA",
|
||||
column: x => x.user_id,
|
||||
principalTable: "Users",
|
||||
principalColumn: "user_id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Adjustments",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
user_id = table.Column<int>(type: "int", nullable: false),
|
||||
sprint_id = table.Column<int>(type: "int", nullable: false),
|
||||
adjustment_points = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK__Adjustme__3214EC07B3BFDA02", x => x.id);
|
||||
table.ForeignKey(
|
||||
name: "FK__Adjustmen__sprin__6EC0713C",
|
||||
column: x => x.sprint_id,
|
||||
principalTable: "Sprints",
|
||||
principalColumn: "sprint_id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Stories",
|
||||
columns: table => new
|
||||
{
|
||||
story_id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
title = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
||||
description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
|
||||
status = table.Column<string>(type: "nvarchar(15)", maxLength: 15, nullable: true, defaultValue: "open"),
|
||||
parent_id = table.Column<int>(type: "int", nullable: true),
|
||||
sprint_id = table.Column<int>(type: "int", nullable: true),
|
||||
created_by = table.Column<int>(type: "int", nullable: true),
|
||||
story_points = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK__Stories__66339C56B86254B8", x => x.story_id);
|
||||
table.ForeignKey(
|
||||
name: "FK__Stories__created__6FE99F9F",
|
||||
column: x => x.created_by,
|
||||
principalTable: "Users",
|
||||
principalColumn: "user_id");
|
||||
table.ForeignKey(
|
||||
name: "FK__Stories__parent___70DDC3D8",
|
||||
column: x => x.parent_id,
|
||||
principalTable: "Stories",
|
||||
principalColumn: "story_id");
|
||||
table.ForeignKey(
|
||||
name: "FK__Stories__sprint___6EF57B66",
|
||||
column: x => x.sprint_id,
|
||||
principalTable: "Sprints",
|
||||
principalColumn: "sprint_id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "TeamMemberAvailabilities",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
user_id = table.Column<int>(type: "int", nullable: false),
|
||||
sprint_id = table.Column<int>(type: "int", nullable: false),
|
||||
availability_points = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK__TeamMemb__3214EC07A9A5EE06", x => x.id);
|
||||
table.ForeignKey(
|
||||
name: "FK__TeamMembe__sprin__6DCC4D03",
|
||||
column: x => x.sprint_id,
|
||||
principalTable: "Sprints",
|
||||
principalColumn: "sprint_id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "UsersStories",
|
||||
columns: table => new
|
||||
{
|
||||
story_id = table.Column<int>(type: "int", nullable: false),
|
||||
user_id = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK__UsersSto__8DA87F2683494916", x => new { x.story_id, x.user_id });
|
||||
table.ForeignKey(
|
||||
name: "FK__UsersStor__story__73BA3083",
|
||||
column: x => x.story_id,
|
||||
principalTable: "Stories",
|
||||
principalColumn: "story_id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK__UsersStor__user___74AE54BC",
|
||||
column: x => x.user_id,
|
||||
principalTable: "Users",
|
||||
principalColumn: "user_id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Adjustments_sprint_id",
|
||||
table: "Adjustments",
|
||||
column: "sprint_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Sprints_team_id",
|
||||
table: "Sprints",
|
||||
column: "team_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Stories_created_by",
|
||||
table: "Stories",
|
||||
column: "created_by");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Stories_parent_id",
|
||||
table: "Stories",
|
||||
column: "parent_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Stories_sprint_id",
|
||||
table: "Stories",
|
||||
column: "sprint_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_TeamMemberAvailabilities_sprint_id",
|
||||
table: "TeamMemberAvailabilities",
|
||||
column: "sprint_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Teams_team_lead_id",
|
||||
table: "Teams",
|
||||
column: "team_lead_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "UQ__Teams__29E35E0C9F1894C7",
|
||||
table: "Teams",
|
||||
column: "team_name",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "UQ__Users__F3DBC572843AEA6F",
|
||||
table: "Users",
|
||||
column: "username",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UsersStories_user_id",
|
||||
table: "UsersStories",
|
||||
column: "user_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UsersTeams_team_id",
|
||||
table: "UsersTeams",
|
||||
column: "team_id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Adjustments");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "TeamMemberAvailabilities");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "UsersStories");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "UsersTeams");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Stories");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Sprints");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Teams");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Users");
|
||||
}
|
||||
}
|
||||
}
|
||||
+419
@@ -0,0 +1,419 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using WebApi.Context;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WebApi.Migrations
|
||||
{
|
||||
[DbContext(typeof(JyrosContext))]
|
||||
[Migration("20241221195345_added-priority")]
|
||||
partial class addedpriority
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.10")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("UsersStory", b =>
|
||||
{
|
||||
b.Property<int>("StoryId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("story_id");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.HasKey("StoryId", "UserId")
|
||||
.HasName("PK__UsersSto__8DA87F2683494916");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("UsersStories", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UsersTeam", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.Property<int>("TeamId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_id");
|
||||
|
||||
b.HasKey("UserId", "TeamId")
|
||||
.HasName("PK__UsersTea__663CE9D4131E7ED3");
|
||||
|
||||
b.HasIndex("TeamId");
|
||||
|
||||
b.ToTable("UsersTeams", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Adjustment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AdjustmentPoints")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("adjustment_points");
|
||||
|
||||
b.Property<int>("SprintId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("PK__Adjustme__3214EC07B3BFDA02");
|
||||
|
||||
b.HasIndex("SprintId");
|
||||
|
||||
b.ToTable("Adjustments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Sprint", b =>
|
||||
{
|
||||
b.Property<int>("SprintId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("SprintId"));
|
||||
|
||||
b.Property<DateOnly>("EndDate")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("end_date");
|
||||
|
||||
b.Property<string>("Goal")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("goal");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("name");
|
||||
|
||||
b.Property<DateOnly>("StartDate")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("start_date");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasDefaultValue("planned")
|
||||
.HasColumnName("status");
|
||||
|
||||
b.Property<int?>("TeamId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_id");
|
||||
|
||||
b.HasKey("SprintId")
|
||||
.HasName("PK__Sprints__396C1802EFA36E05");
|
||||
|
||||
b.HasIndex("TeamId");
|
||||
|
||||
b.ToTable("Sprints");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Story", b =>
|
||||
{
|
||||
b.Property<int>("StoryId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("story_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("StoryId"));
|
||||
|
||||
b.Property<int?>("CreatedBy")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("created_by");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("nvarchar(1000)")
|
||||
.HasColumnName("description");
|
||||
|
||||
b.Property<int?>("ParentId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("parent_id");
|
||||
|
||||
b.Property<int>("Priority")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasDefaultValue(1)
|
||||
.HasColumnName("priority");
|
||||
|
||||
b.Property<int?>("SprintId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasMaxLength(15)
|
||||
.HasColumnType("nvarchar(15)")
|
||||
.HasDefaultValue("open")
|
||||
.HasColumnName("status");
|
||||
|
||||
b.Property<int?>("StoryPoints")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("story_points");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("title");
|
||||
|
||||
b.HasKey("StoryId")
|
||||
.HasName("PK__Stories__66339C56B86254B8");
|
||||
|
||||
b.HasIndex("CreatedBy");
|
||||
|
||||
b.HasIndex("ParentId");
|
||||
|
||||
b.HasIndex("SprintId");
|
||||
|
||||
b.ToTable("Stories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Team", b =>
|
||||
{
|
||||
b.Property<int>("TeamId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("TeamId"));
|
||||
|
||||
b.Property<string>("TeamDescription")
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("nvarchar(500)")
|
||||
.HasColumnName("team_description");
|
||||
|
||||
b.Property<int?>("TeamLeadId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_lead_id");
|
||||
|
||||
b.Property<string>("TeamName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("team_name");
|
||||
|
||||
b.HasKey("TeamId")
|
||||
.HasName("PK__Teams__F82DEDBCAAB0C3AF");
|
||||
|
||||
b.HasIndex("TeamLeadId");
|
||||
|
||||
b.HasIndex(new[] { "TeamName" }, "UQ__Teams__29E35E0C9F1894C7")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Teams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.TeamMemberAvailability", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AvailabilityPoints")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("availability_points");
|
||||
|
||||
b.Property<int>("SprintId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("PK__TeamMemb__3214EC07A9A5EE06");
|
||||
|
||||
b.HasIndex("SprintId");
|
||||
|
||||
b.ToTable("TeamMemberAvailabilities");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("UserId"));
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("username");
|
||||
|
||||
b.HasKey("UserId")
|
||||
.HasName("PK__Users__B9BE370FA0824176");
|
||||
|
||||
b.HasIndex(new[] { "Username" }, "UQ__Users__F3DBC572843AEA6F")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UsersStory", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Story", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("StoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersStor__story__73BA3083");
|
||||
|
||||
b.HasOne("WebApi.Models.User", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersStor__user___74AE54BC");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UsersTeam", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Team", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("TeamId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersTeam__team___6477ECF3");
|
||||
|
||||
b.HasOne("WebApi.Models.User", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersTeam__user___6383C8BA");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Adjustment", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Sprint", "Sprint")
|
||||
.WithMany("Adjustments")
|
||||
.HasForeignKey("SprintId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__Adjustmen__sprin__6EC0713C");
|
||||
|
||||
b.Navigation("Sprint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Sprint", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Team", "Team")
|
||||
.WithMany("Sprints")
|
||||
.HasForeignKey("TeamId")
|
||||
.HasConstraintName("FK__Sprints__team_id__693CA210");
|
||||
|
||||
b.Navigation("Team");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Story", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.User", "CreatedByNavigation")
|
||||
.WithMany("Stories")
|
||||
.HasForeignKey("CreatedBy")
|
||||
.HasConstraintName("FK__Stories__created__6FE99F9F");
|
||||
|
||||
b.HasOne("WebApi.Models.Story", "Parent")
|
||||
.WithMany("InverseParent")
|
||||
.HasForeignKey("ParentId")
|
||||
.HasConstraintName("FK__Stories__parent___70DDC3D8");
|
||||
|
||||
b.HasOne("WebApi.Models.Sprint", "Sprint")
|
||||
.WithMany("Stories")
|
||||
.HasForeignKey("SprintId")
|
||||
.HasConstraintName("FK__Stories__sprint___6EF57B66");
|
||||
|
||||
b.Navigation("CreatedByNavigation");
|
||||
|
||||
b.Navigation("Parent");
|
||||
|
||||
b.Navigation("Sprint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Team", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.User", "TeamLead")
|
||||
.WithMany("Teams")
|
||||
.HasForeignKey("TeamLeadId")
|
||||
.HasConstraintName("FK__Teams__team_lead__60A75C0F");
|
||||
|
||||
b.Navigation("TeamLead");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.TeamMemberAvailability", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Sprint", "Sprint")
|
||||
.WithMany("TeamMemberAvailabilities")
|
||||
.HasForeignKey("SprintId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__TeamMembe__sprin__6DCC4D03");
|
||||
|
||||
b.Navigation("Sprint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Sprint", b =>
|
||||
{
|
||||
b.Navigation("Adjustments");
|
||||
|
||||
b.Navigation("Stories");
|
||||
|
||||
b.Navigation("TeamMemberAvailabilities");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Story", b =>
|
||||
{
|
||||
b.Navigation("InverseParent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Team", b =>
|
||||
{
|
||||
b.Navigation("Sprints");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.User", b =>
|
||||
{
|
||||
b.Navigation("Stories");
|
||||
|
||||
b.Navigation("Teams");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WebApi.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class addedpriority : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "priority",
|
||||
table: "Stories",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 1);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "priority",
|
||||
table: "Stories");
|
||||
}
|
||||
}
|
||||
}
|
||||
+421
@@ -0,0 +1,421 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using WebApi.Context;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WebApi.Migrations
|
||||
{
|
||||
[DbContext(typeof(JyrosContext))]
|
||||
[Migration("20241222003947_test")]
|
||||
partial class test
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.10")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("UsersStory", b =>
|
||||
{
|
||||
b.Property<int>("StoryId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("story_id");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.HasKey("StoryId", "UserId")
|
||||
.HasName("PK__UsersSto__8DA87F2683494916");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("UsersStories", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UsersTeam", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.Property<int>("TeamId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_id");
|
||||
|
||||
b.HasKey("UserId", "TeamId")
|
||||
.HasName("PK__UsersTea__663CE9D4131E7ED3");
|
||||
|
||||
b.HasIndex("TeamId");
|
||||
|
||||
b.ToTable("UsersTeams", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Adjustment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AdjustmentPoints")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("adjustment_points");
|
||||
|
||||
b.Property<string>("Reason")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)")
|
||||
.HasColumnName("reason");
|
||||
|
||||
b.Property<int>("SprintId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("PK__Adjustme__3214EC07B3BFDA02");
|
||||
|
||||
b.HasIndex("SprintId");
|
||||
|
||||
b.ToTable("Adjustments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Sprint", b =>
|
||||
{
|
||||
b.Property<int>("SprintId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("SprintId"));
|
||||
|
||||
b.Property<DateOnly>("EndDate")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("end_date");
|
||||
|
||||
b.Property<string>("Goal")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("goal");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("name");
|
||||
|
||||
b.Property<DateOnly>("StartDate")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("start_date");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasDefaultValue("planned")
|
||||
.HasColumnName("status");
|
||||
|
||||
b.Property<int?>("TeamId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_id");
|
||||
|
||||
b.HasKey("SprintId")
|
||||
.HasName("PK__Sprints__396C1802EFA36E05");
|
||||
|
||||
b.HasIndex("TeamId");
|
||||
|
||||
b.ToTable("Sprints");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Story", b =>
|
||||
{
|
||||
b.Property<int>("StoryId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("story_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("StoryId"));
|
||||
|
||||
b.Property<int?>("CreatedBy")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("created_by");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("nvarchar(1000)")
|
||||
.HasColumnName("description");
|
||||
|
||||
b.Property<int?>("ParentId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("parent_id");
|
||||
|
||||
b.Property<int>("Priority")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasDefaultValue(1)
|
||||
.HasColumnName("priority");
|
||||
|
||||
b.Property<int?>("SprintId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasMaxLength(15)
|
||||
.HasColumnType("nvarchar(15)")
|
||||
.HasDefaultValue("open")
|
||||
.HasColumnName("status");
|
||||
|
||||
b.Property<int?>("StoryPoints")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("story_points");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("title");
|
||||
|
||||
b.HasKey("StoryId")
|
||||
.HasName("PK__Stories__66339C56B86254B8");
|
||||
|
||||
b.HasIndex("CreatedBy");
|
||||
|
||||
b.HasIndex("ParentId");
|
||||
|
||||
b.HasIndex("SprintId");
|
||||
|
||||
b.ToTable("Stories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Team", b =>
|
||||
{
|
||||
b.Property<int>("TeamId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("TeamId"));
|
||||
|
||||
b.Property<string>("TeamDescription")
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("nvarchar(500)")
|
||||
.HasColumnName("team_description");
|
||||
|
||||
b.Property<int?>("TeamLeadId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_lead_id");
|
||||
|
||||
b.Property<string>("TeamName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("team_name");
|
||||
|
||||
b.HasKey("TeamId")
|
||||
.HasName("PK__Teams__F82DEDBCAAB0C3AF");
|
||||
|
||||
b.HasIndex("TeamLeadId");
|
||||
|
||||
b.HasIndex(new[] { "TeamName" }, "UQ__Teams__29E35E0C9F1894C7")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Teams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.TeamMemberAvailability", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AvailabilityPoints")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("availability_points");
|
||||
|
||||
b.Property<int>("SprintId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("PK__TeamMemb__3214EC07A9A5EE06");
|
||||
|
||||
b.HasIndex("SprintId");
|
||||
|
||||
b.ToTable("TeamMemberAvailabilities");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("UserId"));
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("username");
|
||||
|
||||
b.HasKey("UserId")
|
||||
.HasName("PK__Users__B9BE370FA0824176");
|
||||
|
||||
b.HasIndex(new[] { "Username" }, "UQ__Users__F3DBC572843AEA6F")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UsersStory", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Story", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("StoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersStor__story__73BA3083");
|
||||
|
||||
b.HasOne("WebApi.Models.User", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersStor__user___74AE54BC");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UsersTeam", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Team", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("TeamId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersTeam__team___6477ECF3");
|
||||
|
||||
b.HasOne("WebApi.Models.User", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersTeam__user___6383C8BA");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Adjustment", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Sprint", "Sprint")
|
||||
.WithMany("Adjustments")
|
||||
.HasForeignKey("SprintId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__Adjustmen__sprin__6EC0713C");
|
||||
|
||||
b.Navigation("Sprint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Sprint", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Team", "Team")
|
||||
.WithMany("Sprints")
|
||||
.HasForeignKey("TeamId")
|
||||
.HasConstraintName("FK__Sprints__team_id__693CA210");
|
||||
|
||||
b.Navigation("Team");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Story", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.User", "CreatedByNavigation")
|
||||
.WithMany("Stories")
|
||||
.HasForeignKey("CreatedBy")
|
||||
.HasConstraintName("FK__Stories__created__6FE99F9F");
|
||||
|
||||
b.HasOne("WebApi.Models.Story", "Parent")
|
||||
.WithMany("InverseParent")
|
||||
.HasForeignKey("ParentId")
|
||||
.HasConstraintName("FK__Stories__parent___70DDC3D8");
|
||||
|
||||
b.HasOne("WebApi.Models.Sprint", "Sprint")
|
||||
.WithMany("Stories")
|
||||
.HasForeignKey("SprintId")
|
||||
.HasConstraintName("FK__Stories__sprint___6EF57B66");
|
||||
|
||||
b.Navigation("CreatedByNavigation");
|
||||
|
||||
b.Navigation("Parent");
|
||||
|
||||
b.Navigation("Sprint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Team", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.User", "TeamLead")
|
||||
.WithMany("Teams")
|
||||
.HasForeignKey("TeamLeadId")
|
||||
.HasConstraintName("FK__Teams__team_lead__60A75C0F");
|
||||
|
||||
b.Navigation("TeamLead");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.TeamMemberAvailability", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Sprint", "Sprint")
|
||||
.WithMany("TeamMemberAvailabilities")
|
||||
.HasForeignKey("SprintId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__TeamMembe__sprin__6DCC4D03");
|
||||
|
||||
b.Navigation("Sprint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Sprint", b =>
|
||||
{
|
||||
b.Navigation("Adjustments");
|
||||
|
||||
b.Navigation("Stories");
|
||||
|
||||
b.Navigation("TeamMemberAvailabilities");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Story", b =>
|
||||
{
|
||||
b.Navigation("InverseParent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Team", b =>
|
||||
{
|
||||
b.Navigation("Sprints");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.User", b =>
|
||||
{
|
||||
b.Navigation("Stories");
|
||||
|
||||
b.Navigation("Teams");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WebApi.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class test : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "user_id",
|
||||
table: "Adjustments");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "reason",
|
||||
table: "Adjustments",
|
||||
type: "nvarchar(100)",
|
||||
maxLength: 100,
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "reason",
|
||||
table: "Adjustments");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "user_id",
|
||||
table: "Adjustments",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
+425
@@ -0,0 +1,425 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using WebApi.Context;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WebApi.Migrations
|
||||
{
|
||||
[DbContext(typeof(JyrosContext))]
|
||||
[Migration("20250118125647_password")]
|
||||
partial class password
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.10")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("UsersStory", b =>
|
||||
{
|
||||
b.Property<int>("StoryId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("story_id");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.HasKey("StoryId", "UserId")
|
||||
.HasName("PK__UsersSto__8DA87F2683494916");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("UsersStories", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UsersTeam", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.Property<int>("TeamId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_id");
|
||||
|
||||
b.HasKey("UserId", "TeamId")
|
||||
.HasName("PK__UsersTea__663CE9D4131E7ED3");
|
||||
|
||||
b.HasIndex("TeamId");
|
||||
|
||||
b.ToTable("UsersTeams", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Adjustment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AdjustmentPoints")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("adjustment_points");
|
||||
|
||||
b.Property<string>("Reason")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)")
|
||||
.HasColumnName("reason");
|
||||
|
||||
b.Property<int>("SprintId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("PK__Adjustme__3214EC07B3BFDA02");
|
||||
|
||||
b.HasIndex("SprintId");
|
||||
|
||||
b.ToTable("Adjustments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Sprint", b =>
|
||||
{
|
||||
b.Property<int>("SprintId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("SprintId"));
|
||||
|
||||
b.Property<DateOnly>("EndDate")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("end_date");
|
||||
|
||||
b.Property<string>("Goal")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("goal");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("name");
|
||||
|
||||
b.Property<DateOnly>("StartDate")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("start_date");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasDefaultValue("planned")
|
||||
.HasColumnName("status");
|
||||
|
||||
b.Property<int?>("TeamId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_id");
|
||||
|
||||
b.HasKey("SprintId")
|
||||
.HasName("PK__Sprints__396C1802EFA36E05");
|
||||
|
||||
b.HasIndex("TeamId");
|
||||
|
||||
b.ToTable("Sprints");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Story", b =>
|
||||
{
|
||||
b.Property<int>("StoryId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("story_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("StoryId"));
|
||||
|
||||
b.Property<int?>("CreatedBy")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("created_by");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("nvarchar(1000)")
|
||||
.HasColumnName("description");
|
||||
|
||||
b.Property<int?>("ParentId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("parent_id");
|
||||
|
||||
b.Property<int>("Priority")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasDefaultValue(1)
|
||||
.HasColumnName("priority");
|
||||
|
||||
b.Property<int?>("SprintId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasMaxLength(15)
|
||||
.HasColumnType("nvarchar(15)")
|
||||
.HasDefaultValue("open")
|
||||
.HasColumnName("status");
|
||||
|
||||
b.Property<int?>("StoryPoints")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("story_points");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("title");
|
||||
|
||||
b.HasKey("StoryId")
|
||||
.HasName("PK__Stories__66339C56B86254B8");
|
||||
|
||||
b.HasIndex("CreatedBy");
|
||||
|
||||
b.HasIndex("ParentId");
|
||||
|
||||
b.HasIndex("SprintId");
|
||||
|
||||
b.ToTable("Stories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Team", b =>
|
||||
{
|
||||
b.Property<int>("TeamId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("TeamId"));
|
||||
|
||||
b.Property<string>("TeamDescription")
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("nvarchar(500)")
|
||||
.HasColumnName("team_description");
|
||||
|
||||
b.Property<int?>("TeamLeadId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_lead_id");
|
||||
|
||||
b.Property<string>("TeamName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("team_name");
|
||||
|
||||
b.HasKey("TeamId")
|
||||
.HasName("PK__Teams__F82DEDBCAAB0C3AF");
|
||||
|
||||
b.HasIndex("TeamLeadId");
|
||||
|
||||
b.HasIndex(new[] { "TeamName" }, "UQ__Teams__29E35E0C9F1894C7")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Teams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.TeamMemberAvailability", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AvailabilityPoints")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("availability_points");
|
||||
|
||||
b.Property<int>("SprintId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("PK__TeamMemb__3214EC07A9A5EE06");
|
||||
|
||||
b.HasIndex("SprintId");
|
||||
|
||||
b.ToTable("TeamMemberAvailabilities");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("UserId"));
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("username");
|
||||
|
||||
b.HasKey("UserId")
|
||||
.HasName("PK__Users__B9BE370FA0824176");
|
||||
|
||||
b.HasIndex(new[] { "Username" }, "UQ__Users__F3DBC572843AEA6F")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UsersStory", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Story", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("StoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersStor__story__73BA3083");
|
||||
|
||||
b.HasOne("WebApi.Models.User", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersStor__user___74AE54BC");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UsersTeam", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Team", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("TeamId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersTeam__team___6477ECF3");
|
||||
|
||||
b.HasOne("WebApi.Models.User", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersTeam__user___6383C8BA");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Adjustment", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Sprint", "Sprint")
|
||||
.WithMany("Adjustments")
|
||||
.HasForeignKey("SprintId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__Adjustmen__sprin__6EC0713C");
|
||||
|
||||
b.Navigation("Sprint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Sprint", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Team", "Team")
|
||||
.WithMany("Sprints")
|
||||
.HasForeignKey("TeamId")
|
||||
.HasConstraintName("FK__Sprints__team_id__693CA210");
|
||||
|
||||
b.Navigation("Team");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Story", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.User", "CreatedByNavigation")
|
||||
.WithMany("Stories")
|
||||
.HasForeignKey("CreatedBy")
|
||||
.HasConstraintName("FK__Stories__created__6FE99F9F");
|
||||
|
||||
b.HasOne("WebApi.Models.Story", "Parent")
|
||||
.WithMany("InverseParent")
|
||||
.HasForeignKey("ParentId")
|
||||
.HasConstraintName("FK__Stories__parent___70DDC3D8");
|
||||
|
||||
b.HasOne("WebApi.Models.Sprint", "Sprint")
|
||||
.WithMany("Stories")
|
||||
.HasForeignKey("SprintId")
|
||||
.HasConstraintName("FK__Stories__sprint___6EF57B66");
|
||||
|
||||
b.Navigation("CreatedByNavigation");
|
||||
|
||||
b.Navigation("Parent");
|
||||
|
||||
b.Navigation("Sprint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Team", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.User", "TeamLead")
|
||||
.WithMany("Teams")
|
||||
.HasForeignKey("TeamLeadId")
|
||||
.HasConstraintName("FK__Teams__team_lead__60A75C0F");
|
||||
|
||||
b.Navigation("TeamLead");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.TeamMemberAvailability", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Sprint", "Sprint")
|
||||
.WithMany("TeamMemberAvailabilities")
|
||||
.HasForeignKey("SprintId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__TeamMembe__sprin__6DCC4D03");
|
||||
|
||||
b.Navigation("Sprint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Sprint", b =>
|
||||
{
|
||||
b.Navigation("Adjustments");
|
||||
|
||||
b.Navigation("Stories");
|
||||
|
||||
b.Navigation("TeamMemberAvailabilities");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Story", b =>
|
||||
{
|
||||
b.Navigation("InverseParent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Team", b =>
|
||||
{
|
||||
b.Navigation("Sprints");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.User", b =>
|
||||
{
|
||||
b.Navigation("Stories");
|
||||
|
||||
b.Navigation("Teams");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WebApi.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class password : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Password",
|
||||
table: "Users",
|
||||
type: "nvarchar(max)",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Password",
|
||||
table: "Users");
|
||||
}
|
||||
}
|
||||
}
|
||||
+422
@@ -0,0 +1,422 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using WebApi.Context;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WebApi.Migrations
|
||||
{
|
||||
[DbContext(typeof(JyrosContext))]
|
||||
partial class JyrosContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.10")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("UsersStory", b =>
|
||||
{
|
||||
b.Property<int>("StoryId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("story_id");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.HasKey("StoryId", "UserId")
|
||||
.HasName("PK__UsersSto__8DA87F2683494916");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("UsersStories", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UsersTeam", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.Property<int>("TeamId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_id");
|
||||
|
||||
b.HasKey("UserId", "TeamId")
|
||||
.HasName("PK__UsersTea__663CE9D4131E7ED3");
|
||||
|
||||
b.HasIndex("TeamId");
|
||||
|
||||
b.ToTable("UsersTeams", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Adjustment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AdjustmentPoints")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("adjustment_points");
|
||||
|
||||
b.Property<string>("Reason")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)")
|
||||
.HasColumnName("reason");
|
||||
|
||||
b.Property<int>("SprintId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("PK__Adjustme__3214EC07B3BFDA02");
|
||||
|
||||
b.HasIndex("SprintId");
|
||||
|
||||
b.ToTable("Adjustments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Sprint", b =>
|
||||
{
|
||||
b.Property<int>("SprintId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("SprintId"));
|
||||
|
||||
b.Property<DateOnly>("EndDate")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("end_date");
|
||||
|
||||
b.Property<string>("Goal")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("goal");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("name");
|
||||
|
||||
b.Property<DateOnly>("StartDate")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("start_date");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasDefaultValue("planned")
|
||||
.HasColumnName("status");
|
||||
|
||||
b.Property<int?>("TeamId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_id");
|
||||
|
||||
b.HasKey("SprintId")
|
||||
.HasName("PK__Sprints__396C1802EFA36E05");
|
||||
|
||||
b.HasIndex("TeamId");
|
||||
|
||||
b.ToTable("Sprints");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Story", b =>
|
||||
{
|
||||
b.Property<int>("StoryId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("story_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("StoryId"));
|
||||
|
||||
b.Property<int?>("CreatedBy")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("created_by");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("nvarchar(1000)")
|
||||
.HasColumnName("description");
|
||||
|
||||
b.Property<int?>("ParentId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("parent_id");
|
||||
|
||||
b.Property<int>("Priority")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasDefaultValue(1)
|
||||
.HasColumnName("priority");
|
||||
|
||||
b.Property<int?>("SprintId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasMaxLength(15)
|
||||
.HasColumnType("nvarchar(15)")
|
||||
.HasDefaultValue("open")
|
||||
.HasColumnName("status");
|
||||
|
||||
b.Property<int?>("StoryPoints")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("story_points");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("title");
|
||||
|
||||
b.HasKey("StoryId")
|
||||
.HasName("PK__Stories__66339C56B86254B8");
|
||||
|
||||
b.HasIndex("CreatedBy");
|
||||
|
||||
b.HasIndex("ParentId");
|
||||
|
||||
b.HasIndex("SprintId");
|
||||
|
||||
b.ToTable("Stories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Team", b =>
|
||||
{
|
||||
b.Property<int>("TeamId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("TeamId"));
|
||||
|
||||
b.Property<string>("TeamDescription")
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("nvarchar(500)")
|
||||
.HasColumnName("team_description");
|
||||
|
||||
b.Property<int?>("TeamLeadId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("team_lead_id");
|
||||
|
||||
b.Property<string>("TeamName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("team_name");
|
||||
|
||||
b.HasKey("TeamId")
|
||||
.HasName("PK__Teams__F82DEDBCAAB0C3AF");
|
||||
|
||||
b.HasIndex("TeamLeadId");
|
||||
|
||||
b.HasIndex(new[] { "TeamName" }, "UQ__Teams__29E35E0C9F1894C7")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Teams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.TeamMemberAvailability", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AvailabilityPoints")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("availability_points");
|
||||
|
||||
b.Property<int>("SprintId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("sprint_id");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("PK__TeamMemb__3214EC07A9A5EE06");
|
||||
|
||||
b.HasIndex("SprintId");
|
||||
|
||||
b.ToTable("TeamMemberAvailabilities");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("UserId"));
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("username");
|
||||
|
||||
b.HasKey("UserId")
|
||||
.HasName("PK__Users__B9BE370FA0824176");
|
||||
|
||||
b.HasIndex(new[] { "Username" }, "UQ__Users__F3DBC572843AEA6F")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UsersStory", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Story", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("StoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersStor__story__73BA3083");
|
||||
|
||||
b.HasOne("WebApi.Models.User", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersStor__user___74AE54BC");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UsersTeam", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Team", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("TeamId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersTeam__team___6477ECF3");
|
||||
|
||||
b.HasOne("WebApi.Models.User", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__UsersTeam__user___6383C8BA");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Adjustment", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Sprint", "Sprint")
|
||||
.WithMany("Adjustments")
|
||||
.HasForeignKey("SprintId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__Adjustmen__sprin__6EC0713C");
|
||||
|
||||
b.Navigation("Sprint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Sprint", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Team", "Team")
|
||||
.WithMany("Sprints")
|
||||
.HasForeignKey("TeamId")
|
||||
.HasConstraintName("FK__Sprints__team_id__693CA210");
|
||||
|
||||
b.Navigation("Team");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Story", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.User", "CreatedByNavigation")
|
||||
.WithMany("Stories")
|
||||
.HasForeignKey("CreatedBy")
|
||||
.HasConstraintName("FK__Stories__created__6FE99F9F");
|
||||
|
||||
b.HasOne("WebApi.Models.Story", "Parent")
|
||||
.WithMany("InverseParent")
|
||||
.HasForeignKey("ParentId")
|
||||
.HasConstraintName("FK__Stories__parent___70DDC3D8");
|
||||
|
||||
b.HasOne("WebApi.Models.Sprint", "Sprint")
|
||||
.WithMany("Stories")
|
||||
.HasForeignKey("SprintId")
|
||||
.HasConstraintName("FK__Stories__sprint___6EF57B66");
|
||||
|
||||
b.Navigation("CreatedByNavigation");
|
||||
|
||||
b.Navigation("Parent");
|
||||
|
||||
b.Navigation("Sprint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Team", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.User", "TeamLead")
|
||||
.WithMany("Teams")
|
||||
.HasForeignKey("TeamLeadId")
|
||||
.HasConstraintName("FK__Teams__team_lead__60A75C0F");
|
||||
|
||||
b.Navigation("TeamLead");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.TeamMemberAvailability", b =>
|
||||
{
|
||||
b.HasOne("WebApi.Models.Sprint", "Sprint")
|
||||
.WithMany("TeamMemberAvailabilities")
|
||||
.HasForeignKey("SprintId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK__TeamMembe__sprin__6DCC4D03");
|
||||
|
||||
b.Navigation("Sprint");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Sprint", b =>
|
||||
{
|
||||
b.Navigation("Adjustments");
|
||||
|
||||
b.Navigation("Stories");
|
||||
|
||||
b.Navigation("TeamMemberAvailabilities");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Story", b =>
|
||||
{
|
||||
b.Navigation("InverseParent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.Team", b =>
|
||||
{
|
||||
b.Navigation("Sprints");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApi.Models.User", b =>
|
||||
{
|
||||
b.Navigation("Stories");
|
||||
|
||||
b.Navigation("Teams");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WebApi.Models;
|
||||
|
||||
public partial class Adjustment
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int SprintId { get; set; }
|
||||
public int AdjustmentPoints { get; set; }
|
||||
public string Reason { get; set; } = null!;
|
||||
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public virtual Sprint? Sprint { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WebApi.Models;
|
||||
|
||||
public partial class Sprint
|
||||
{
|
||||
|
||||
public int SprintId { get; set; }
|
||||
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
public string? Goal { get; set; }
|
||||
|
||||
public DateOnly StartDate { get; set; }
|
||||
|
||||
public DateOnly EndDate { get; set; }
|
||||
|
||||
public string? Status { get; set; }
|
||||
|
||||
public int? TeamId { get; set; }
|
||||
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public virtual ICollection<Story> Stories { get; set; } = new List<Story>();
|
||||
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public virtual ICollection<TeamMemberAvailability> TeamMemberAvailabilities { get; set; } = new List<TeamMemberAvailability>();
|
||||
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public virtual ICollection<Adjustment> Adjustments { get; set; } = new List<Adjustment>();
|
||||
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public virtual Team? Team { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WebApi.Models;
|
||||
|
||||
public partial class Story
|
||||
{
|
||||
public int StoryId { get; set; }
|
||||
|
||||
public string Title { get; set; } = null!;
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
public string? Status { get; set; }
|
||||
|
||||
public int Priority { get; set; }
|
||||
|
||||
public int? ParentId { get; set; }
|
||||
|
||||
public int? SprintId { get; set; }
|
||||
|
||||
public int? CreatedBy { get; set; }
|
||||
|
||||
public int? StoryPoints { get; set; }
|
||||
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
|
||||
public virtual User? CreatedByNavigation { get; set; }
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
|
||||
public virtual ICollection<Story> InverseParent { get; set; } = new List<Story>();
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
|
||||
public virtual Story? Parent { get; set; }
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
|
||||
public virtual Sprint? Sprint { get; set; }
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
|
||||
public virtual ICollection<User> Users { get; set; } = new List<User>();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WebApi.Models;
|
||||
|
||||
public partial class Team
|
||||
{
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public int TeamId { get; set; }
|
||||
|
||||
public string TeamName { get; set; } = null!;
|
||||
|
||||
public string? TeamDescription { get; set; }
|
||||
|
||||
public int? TeamLeadId { get; set; }
|
||||
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public virtual ICollection<Sprint> Sprints { get; set; } = new List<Sprint>();
|
||||
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public virtual User? TeamLead { get; set; }
|
||||
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public virtual ICollection<User> Users { get; set; } = new List<User>();
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WebApi.Models;
|
||||
|
||||
public partial class TeamMemberAvailability
|
||||
{
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
|
||||
public int SprintId { get; set; }
|
||||
|
||||
public int AvailabilityPoints { get; set; }
|
||||
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public virtual Sprint? Sprint { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WebApi.Models;
|
||||
|
||||
public partial class User
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
|
||||
public string Username { get; set; } = null!;
|
||||
|
||||
public string Password { get; set; } = string.Empty!;
|
||||
|
||||
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public virtual ICollection<Story> Stories { get; set; } = new List<Story>();
|
||||
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public virtual ICollection<Team> Teams { get; set; } = new List<Team>();
|
||||
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public virtual ICollection<Story> StoriesNavigation { get; set; } = new List<Story>();
|
||||
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public virtual ICollection<Team> TeamsNavigation { get; set; } = new List<Team>();
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WebApi.Context;
|
||||
using WebApi.Models;
|
||||
using WebApi.Repositories;
|
||||
using WebApi.RepositoryInterfaces;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("AllowLocalhost3000",
|
||||
builder => builder
|
||||
.WithOrigins("http://localhost:5173", "https://localhost:5173", "http://192.168.1.138") // Include both HTTP and HTTPS origins
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod()
|
||||
.AllowCredentials());
|
||||
});
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
builder.Services.AddDbContext<JyrosContext>(options =>
|
||||
{
|
||||
options.UseSqlServer(builder.Configuration["JyrosContext"]);
|
||||
});
|
||||
|
||||
builder.Services.AddScoped<IStoryRepository, StoryRepository>();
|
||||
builder.Services.AddScoped<ITeamRepository, TeamRepository>();
|
||||
builder.Services.AddScoped<ISprintRepository, SprintRepository>();
|
||||
builder.Services.AddScoped<IUserRepository, UserRepository>();
|
||||
builder.Services.AddScoped<ITeamMemberAvailabilityRepository, TeamMemberAvailabilityRepository>();
|
||||
builder.Services.AddScoped<IAdjustmentRepository, AdjustmentRepository>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseCors("AllowLocalhost3000");
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
public static class Globals
|
||||
{
|
||||
public static User curretUser = new User();
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:21000",
|
||||
"sslPort": 44376
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "http://localhost:5047",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7048;http://localhost:5047",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WebApi.Context;
|
||||
using WebApi.Models;
|
||||
using WebApi.RepositoryInterfaces;
|
||||
|
||||
namespace WebApi.Repositories
|
||||
{
|
||||
public class AdjustmentRepository : IAdjustmentRepository
|
||||
{
|
||||
private readonly JyrosContext _context;
|
||||
public AdjustmentRepository(JyrosContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Adjustment>> GetAll()
|
||||
{
|
||||
return await _context.Adjustments.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Adjustment> Add(Adjustment entity)
|
||||
{
|
||||
try
|
||||
{
|
||||
entity.Id = default;
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
_context.Adjustments.Add(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<Adjustment> Delete(int id)
|
||||
{
|
||||
var entity = await _context.Adjustments.FindAsync(id);
|
||||
if (entity == null)
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
_context.Adjustments.Remove(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<Adjustment> GetById(int id)
|
||||
{
|
||||
return await _context.Adjustments.FindAsync(id);
|
||||
}
|
||||
|
||||
public async Task<Adjustment> Update(Adjustment entity)
|
||||
{
|
||||
_context.Entry(entity).State = EntityState.Modified;
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Adjustment>> GetPaginated(int page, int pageSize)
|
||||
{
|
||||
return await _context.Adjustments.Skip((page - 1) * pageSize).Take(pageSize).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<int> GetAdjustmentsPerSprint(int sprintId)
|
||||
{
|
||||
return await _context.Adjustments
|
||||
.Where(a => a.SprintId == sprintId)
|
||||
.SumAsync(a => a.AdjustmentPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WebApi.Context;
|
||||
using WebApi.Models;
|
||||
using WebApi.RepositoryInterfaces;
|
||||
|
||||
namespace WebApi.Repositories
|
||||
{
|
||||
public class SprintRepository : ISprintRepository
|
||||
{
|
||||
public readonly JyrosContext _context;
|
||||
|
||||
public SprintRepository(JyrosContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Sprint>> GetAll()
|
||||
{
|
||||
return await _context.Sprints.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Sprint> Add(Sprint entity)
|
||||
{
|
||||
_context.Sprints.Add(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<Sprint> Delete(int id)
|
||||
{
|
||||
var entity = await _context.Sprints.FindAsync(id);
|
||||
if (entity == null)
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
|
||||
_context.Sprints.Remove(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<Sprint> GetById(int id)
|
||||
{
|
||||
return await _context.Sprints.FindAsync(id);
|
||||
}
|
||||
|
||||
public async Task<Sprint> Update(Sprint entity)
|
||||
{
|
||||
_context.Entry(entity).State = EntityState.Modified;
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Sprint>> GetPaginated(int page, int pageSize)
|
||||
{
|
||||
return await _context.Sprints.Skip((page - 1) * pageSize).Take(pageSize).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WebApi.Context;
|
||||
using WebApi.Models;
|
||||
using WebApi.RepositoryInterfaces;
|
||||
|
||||
|
||||
namespace WebApi.Repositories
|
||||
{
|
||||
public class StoryRepository : IStoryRepository
|
||||
{
|
||||
public readonly JyrosContext _context;
|
||||
public StoryRepository(JyrosContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Story>> GetAll()
|
||||
{
|
||||
return await _context.Stories.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Story> Add(Story entity)
|
||||
{
|
||||
_context.Stories.Add(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<Story> Delete(int id)
|
||||
{
|
||||
var entity = await _context.Stories.FindAsync(id);
|
||||
if (entity == null)
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
|
||||
_context.Stories.Remove(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<Story> GetById(int id)
|
||||
{
|
||||
return await _context.Stories.FindAsync(id);
|
||||
}
|
||||
|
||||
public async Task<Story> Update(Story entity)
|
||||
{
|
||||
_context.Entry(entity).State = EntityState.Modified;
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Story>> GetPaginated(int page, int pageSize)
|
||||
{
|
||||
return await _context.Stories.Skip((page - 1) * pageSize).Take(pageSize).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Story>> GetFilteredPaginated(string searchKey, int page, int pageSize)
|
||||
{
|
||||
return await _context.Stories.Where(s => s.Title.Contains(searchKey)).Skip((page - 1) * pageSize).Take(pageSize).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using WebApi.Context;
|
||||
using WebApi.Models;
|
||||
using WebApi.RepositoryInterfaces;
|
||||
|
||||
namespace WebApi.Repositories
|
||||
{
|
||||
public class TeamMemberAvailabilityRepository : ITeamMemberAvailabilityRepository
|
||||
{
|
||||
private readonly JyrosContext _context;
|
||||
public TeamMemberAvailabilityRepository(JyrosContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
public async Task<IEnumerable<TeamMemberAvailability>> GetAll()
|
||||
{
|
||||
return await _context.TeamMemberAvailabilities.ToListAsync();
|
||||
}
|
||||
public async Task<TeamMemberAvailability> Add(TeamMemberAvailability entity)
|
||||
{
|
||||
_context.TeamMemberAvailabilities.Add(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
public async Task<TeamMemberAvailability> Delete(int id)
|
||||
{
|
||||
var entity = await _context.TeamMemberAvailabilities.FindAsync(id);
|
||||
if (entity == null)
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
_context.TeamMemberAvailabilities.Remove(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
public async Task<TeamMemberAvailability> GetById(int id)
|
||||
{
|
||||
return await _context.TeamMemberAvailabilities.FindAsync(id);
|
||||
}
|
||||
public async Task<TeamMemberAvailability> Update(TeamMemberAvailability entity)
|
||||
{
|
||||
_context.Entry(entity).State = EntityState.Modified;
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TeamMemberAvailability>> GetPaginated(int page, int pageSize)
|
||||
{
|
||||
return await _context.TeamMemberAvailabilities.Skip((page - 1) * pageSize).Take(pageSize).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<TeamMemberAvailability> GetBySprintIdAndUserId(int sprintId, int userId)
|
||||
{
|
||||
return await _context.TeamMemberAvailabilities.FirstOrDefaultAsync(tma => tma.SprintId == sprintId && tma.UserId == userId);
|
||||
}
|
||||
|
||||
public async Task<TeamMemberAvailability> GetAvailabilityBySprintIdAndUserId(int sprintId, int userId)
|
||||
{
|
||||
return await _context.TeamMemberAvailabilities.FirstOrDefaultAsync(tma => tma.SprintId == sprintId && tma.UserId == userId);
|
||||
}
|
||||
|
||||
public async Task<int> GetTotalAvailabilityPerSprint(int sprintId)
|
||||
{
|
||||
return await _context.TeamMemberAvailabilities
|
||||
.Where(tma => tma.SprintId == sprintId)
|
||||
.SumAsync(tma => tma.AvailabilityPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WebApi.Context;
|
||||
using WebApi.Models;
|
||||
using WebApi.RepositoryInterfaces;
|
||||
|
||||
namespace WebApi.Repositories
|
||||
{
|
||||
public class TeamRepository : ITeamRepository
|
||||
{
|
||||
|
||||
private readonly JyrosContext _context;
|
||||
public TeamRepository(JyrosContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Team>> GetAll()
|
||||
{
|
||||
return await _context.Teams.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Team> Add(Team entity)
|
||||
{
|
||||
_context.Teams.Add(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<Team> Delete(int id)
|
||||
{
|
||||
var entity = await _context.Teams.FindAsync(id);
|
||||
if (entity == null)
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
|
||||
_context.Teams.Remove(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<Team> GetById(int id)
|
||||
{
|
||||
return await _context.Teams.FindAsync(id);
|
||||
}
|
||||
|
||||
public async Task<Team> Update(Team entity)
|
||||
{
|
||||
_context.Entry(entity).State = EntityState.Modified;
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Team>> GetPaginated(int page, int pageSize)
|
||||
{
|
||||
return await _context.Teams.Skip((page - 1) * pageSize).Take(pageSize).ToListAsync();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WebApi.Context;
|
||||
using WebApi.Models;
|
||||
using WebApi.RepositoryInterfaces;
|
||||
|
||||
namespace WebApi.Repositories
|
||||
{
|
||||
public class UserRepository : IUserRepository
|
||||
{
|
||||
private readonly JyrosContext _context;
|
||||
public UserRepository(JyrosContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<User>> GetAll()
|
||||
{
|
||||
return await _context.Users.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
public async Task<User> Add(User entity)
|
||||
{
|
||||
try
|
||||
{
|
||||
entity.UserId =default;
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
_context.Users.Add(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<User> Delete(int id)
|
||||
{
|
||||
var entity = await _context.Users.FindAsync(id);
|
||||
if (entity == null)
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
|
||||
_context.Users.Remove(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<User> GetById(int id)
|
||||
{
|
||||
return await _context.Users.FindAsync(id);
|
||||
}
|
||||
|
||||
public async Task<User> Update(User entity)
|
||||
{
|
||||
_context.Entry(entity).State = EntityState.Modified;
|
||||
await _context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<User>> GetPaginated(int page, int pageSize)
|
||||
{
|
||||
return await _context.Users.Skip((page - 1) * pageSize).Take(pageSize).ToListAsync();
|
||||
}
|
||||
public async Task<IEnumerable<User>> GetUsersBySprintId(int sprintId)
|
||||
{
|
||||
return await _context.TeamMemberAvailabilities
|
||||
.Where(tma => tma.SprintId == sprintId)
|
||||
.Join(_context.Users,
|
||||
tma => tma.UserId,
|
||||
user => user.UserId,
|
||||
(tma, user) => user)
|
||||
.ToListAsync();
|
||||
}
|
||||
public async Task<User> GetUserByName(string name)
|
||||
{
|
||||
return await _context.Users.Where(u => u.Username == name).FirstAsync();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
|
||||
|
||||
using WebApi.Models;
|
||||
|
||||
namespace WebApi.RepositoryInterfaces
|
||||
{
|
||||
public interface IAdjustmentRepository : IRepository<Adjustment>
|
||||
{
|
||||
Task<int> GetAdjustmentsPerSprint(int sprintId);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
namespace WebApi.RepositoryInterfaces
|
||||
{
|
||||
public interface IRepository<T> where T : class
|
||||
{
|
||||
Task<IEnumerable<T>> GetAll();
|
||||
Task<T> GetById(int id);
|
||||
Task<T> Add(T entity);
|
||||
Task<T> Update(T entity);
|
||||
Task<T> Delete(int id);
|
||||
Task<IEnumerable<T>> GetPaginated(int page, int pageSize);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WebApi.Context;
|
||||
using WebApi.Models;
|
||||
|
||||
namespace WebApi.RepositoryInterfaces
|
||||
{
|
||||
public interface ISprintRepository : IRepository<Sprint>
|
||||
{
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WebApi.Context;
|
||||
using WebApi.Models;
|
||||
|
||||
namespace WebApi.RepositoryInterfaces
|
||||
{
|
||||
public interface IStoryRepository : IRepository<Story>
|
||||
{
|
||||
public Task<IEnumerable<Story>> GetFilteredPaginated(string searchKey, int page, int pageSize);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WebApi.Context;
|
||||
using WebApi.Models;
|
||||
|
||||
namespace WebApi.RepositoryInterfaces
|
||||
{
|
||||
public interface ITeamMemberAvailabilityRepository : IRepository<TeamMemberAvailability>
|
||||
{
|
||||
Task<TeamMemberAvailability> GetBySprintIdAndUserId(int sprintId, int userId);
|
||||
Task<int> GetTotalAvailabilityPerSprint(int sprintId);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WebApi.Context;
|
||||
using WebApi.Models;
|
||||
|
||||
namespace WebApi.RepositoryInterfaces
|
||||
{
|
||||
public interface ITeamRepository : IRepository<Team>
|
||||
{
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WebApi.Context;
|
||||
using WebApi.Models;
|
||||
|
||||
namespace WebApi.RepositoryInterfaces
|
||||
{
|
||||
public interface IUserRepository : IRepository<User>
|
||||
{
|
||||
public Task<IEnumerable<User>> GetUsersBySprintId(int sprintId);
|
||||
public Task<User> GetUserByName (string name);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
|
||||
using BERTTokenizers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using Microsoft.ML;
|
||||
using Microsoft.ML.Data;
|
||||
using Microsoft.ML.Transforms.Onnx;
|
||||
using System.Collections.Generic;
|
||||
using Tokenizers.DotNet;
|
||||
using WebApi.Models;
|
||||
|
||||
namespace WebApi.Services
|
||||
{
|
||||
public class ModelInput
|
||||
{
|
||||
[VectorType(1, 128)]
|
||||
[ColumnName("input_ids")]
|
||||
public long[] InputIds { get; set; }
|
||||
|
||||
[VectorType(1, 128)]
|
||||
[ColumnName("attention_mask")]
|
||||
public long[] AttentionMask { get; set; }
|
||||
|
||||
[VectorType(1, 128)]
|
||||
[ColumnName("token_type_ids")]
|
||||
public long[] TokenTypeIds { get; set; }
|
||||
}
|
||||
|
||||
public class ModelOutput
|
||||
{
|
||||
[VectorType(1, 6)]
|
||||
[ColumnName("output")]
|
||||
public float[] Output { get; set; }
|
||||
}
|
||||
|
||||
public class StoryPointEstimator
|
||||
{
|
||||
private readonly MLContext _mlContext;
|
||||
private readonly OnnxScoringEstimator estimator;
|
||||
private readonly String ModelPath = "./AIModels/storypoint_estimator.onnx";
|
||||
private readonly String GithubRepo = "Not-Atlassian/StoryPointEstimator";
|
||||
private readonly String ModelFilename = "storypoint_estimator.onnx";
|
||||
|
||||
public StoryPointEstimator()
|
||||
{
|
||||
_mlContext = new MLContext();
|
||||
EnsureModelExists().Wait();
|
||||
estimator = _mlContext.Transforms.ApplyOnnxModel("./AIModels/storypoint_estimator.onnx");
|
||||
}
|
||||
|
||||
|
||||
private async Task EnsureModelExists()
|
||||
{
|
||||
if (!File.Exists(ModelPath))
|
||||
{
|
||||
Console.WriteLine("Model file not found locally. Downloading...");
|
||||
await DownloadModelFromGithub();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async Task DownloadModelFromGithub()
|
||||
{
|
||||
using var httpClient = new HttpClient();
|
||||
var apiUrl = $"https://api.github.com/repos/{GithubRepo}/releases/latest";
|
||||
|
||||
httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (compatible; StoryPointEstimator)");
|
||||
|
||||
var response = await httpClient.GetAsync(apiUrl);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var releaseData = await response.Content.ReadAsStringAsync();
|
||||
|
||||
var releaseJson = System.Text.Json.JsonDocument.Parse(releaseData);
|
||||
var assets = releaseJson.RootElement.GetProperty("assets");
|
||||
|
||||
string? downloadUrl = null;
|
||||
foreach (var asset in assets.EnumerateArray())
|
||||
{
|
||||
if (asset.GetProperty("name").GetString() == ModelFilename)
|
||||
{
|
||||
downloadUrl = asset.GetProperty("browser_download_url").GetString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (downloadUrl == null)
|
||||
{
|
||||
throw new FileNotFoundException("Model file not found in the latest GitHub release.");
|
||||
}
|
||||
|
||||
Console.WriteLine($"Downloading model from {downloadUrl}...");
|
||||
|
||||
var modelData = await httpClient.GetByteArrayAsync(downloadUrl);
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(ModelPath)!);
|
||||
|
||||
await File.WriteAllBytesAsync(ModelPath, modelData);
|
||||
|
||||
Console.WriteLine($"Model downloaded and saved to {ModelPath}");
|
||||
}
|
||||
|
||||
|
||||
public async Task<int> EstimateStoryPoints(string title, string description)
|
||||
{
|
||||
var tokenizer = new BertUncasedBaseTokenizer();
|
||||
|
||||
var encoded = tokenizer.Encode(128, title + " " + description);
|
||||
|
||||
var bertInput = new ModelInput()
|
||||
{
|
||||
InputIds = encoded.Select(t => t.InputIds).ToArray(),
|
||||
AttentionMask = encoded.Select(t => t.AttentionMask).ToArray(),
|
||||
TokenTypeIds = encoded.Select(t => t.TokenTypeIds).ToArray()
|
||||
};
|
||||
var data = _mlContext.Data.LoadFromEnumerable(new List<ModelInput>());
|
||||
var transformedData = estimator.Fit(data);
|
||||
var predictionEngine = _mlContext.Model.CreatePredictionEngine<ModelInput, ModelOutput>(transformedData);
|
||||
var prediction = predictionEngine.Predict(bertInput);
|
||||
var index = prediction.Output.ToList().IndexOf(prediction.Output.Max());
|
||||
return index switch
|
||||
{
|
||||
0 => 1,
|
||||
1 => 2,
|
||||
2 => 3,
|
||||
3 => 5,
|
||||
4 => 8,
|
||||
5 => 13,
|
||||
6 => int.MaxValue,
|
||||
_ => 1
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+28996
File diff suppressed because it is too large
Load Diff
+31102
File diff suppressed because it is too large
Load Diff
+28996
File diff suppressed because it is too large
Load Diff
+119547
File diff suppressed because it is too large
Load Diff
+30522
File diff suppressed because it is too large
Load Diff
+30522
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,41 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>30b475b2-745a-4042-a3e9-adb472f73fd6</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BERTTokenizers" Version="1.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.10" />
|
||||
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="1.20.0" />
|
||||
<PackageReference Include="Microsoft.ML.OnnxTransformer" Version="4.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||
<PackageReference Include="Tokenizers.DotNet" Version="1.0.5" />
|
||||
<PackageReference Include="Tokenizers.DotNet.runtime.win" Version="1.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="AIModels\" />
|
||||
<Folder Include="Migrations\" />
|
||||
<Folder Include="Vocabularies\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="AIModels\tokenizer.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="C:\Users\danie\.nuget\packages\berttokenizers\1.2.0\contentFiles\any\net6.0\Vocabularies\base_uncased.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
@WebApi_HostAddress = http://localhost:5047
|
||||
|
||||
GET {{WebApi_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"JyrosContext": ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "react"
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
@@ -0,0 +1,50 @@
|
||||
# React + TypeScript + Vite
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
|
||||
Currently, two official plugins are available:
|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
||||
|
||||
## Expanding the ESLint configuration
|
||||
|
||||
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
|
||||
|
||||
- Configure the top-level `parserOptions` property like this:
|
||||
|
||||
```js
|
||||
export default tseslint.config({
|
||||
languageOptions: {
|
||||
// other options...
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
|
||||
- Optionally add `...tseslint.configs.stylisticTypeChecked`
|
||||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
|
||||
|
||||
```js
|
||||
// eslint.config.js
|
||||
import react from 'eslint-plugin-react'
|
||||
|
||||
export default tseslint.config({
|
||||
// Set the react version
|
||||
settings: { react: { version: '18.3' } },
|
||||
plugins: {
|
||||
// Add the react plugin
|
||||
react,
|
||||
},
|
||||
rules: {
|
||||
// other rules...
|
||||
// Enable its recommended rules
|
||||
...react.configs.recommended.rules,
|
||||
...react.configs['jsx-runtime'].rules,
|
||||
},
|
||||
})
|
||||
```
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"$schema": "https://ui.shadcn.com/schema.json",
|
||||
"style": "default",
|
||||
"rsc": false,
|
||||
"tsx": true,
|
||||
"tailwind": {
|
||||
"config": "tailwind.config.js",
|
||||
"css": "src/index.css",
|
||||
"baseColor": "neutral",
|
||||
"cssVariables": true,
|
||||
"prefix": ""
|
||||
},
|
||||
"aliases": {
|
||||
"components": "@/components",
|
||||
"utils": "@/lib/utils",
|
||||
"ui": "@/components/ui",
|
||||
"lib": "@/lib",
|
||||
"hooks": "@/hooks"
|
||||
},
|
||||
"iconLibrary": "lucide"
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import js from '@eslint/js'
|
||||
import globals from 'globals'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
import tseslint from 'typescript-eslint'
|
||||
|
||||
export default tseslint.config(
|
||||
{ ignores: ['dist'] },
|
||||
{
|
||||
settings: { react: { version: '18.3' } },
|
||||
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
},
|
||||
plugins: {
|
||||
'react-hooks': reactHooks,
|
||||
'react-refresh': reactRefresh,
|
||||
react,
|
||||
},
|
||||
rules: {
|
||||
...reactHooks.configs.recommended.rules,
|
||||
'react-refresh/only-export-components': [
|
||||
'warn',
|
||||
{ allowConstantExport: true,
|
||||
...react.configs.recommended.rules,
|
||||
...react.configs['jsx-runtime'].rules,
|
||||
},
|
||||
|
||||
],
|
||||
},
|
||||
},
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>JyrosXD</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
+10654
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"name": "jyros",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"lint": "eslint src",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mynaui/icons-react": "^0.3.2",
|
||||
"@radix-ui/react-avatar": "^1.1.1",
|
||||
"@radix-ui/react-checkbox": "^1.1.2",
|
||||
"@radix-ui/react-dialog": "^1.1.2",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
||||
"@radix-ui/react-icons": "^1.3.1",
|
||||
"@radix-ui/react-label": "^2.1.0",
|
||||
"@radix-ui/react-select": "^2.1.2",
|
||||
"@radix-ui/react-separator": "^1.1.0",
|
||||
"@radix-ui/react-slot": "^1.1.0",
|
||||
"@radix-ui/react-tooltip": "^1.1.4",
|
||||
"@types/react-beautiful-dnd": "^13.1.8",
|
||||
"@vitejs/plugin-react": "^4.3.3",
|
||||
"axios": "^1.7.9",
|
||||
"chart.js": "^4.4.7",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"clsx": "^2.1.1",
|
||||
"lucide-react": "^0.454.0",
|
||||
"react": "^18.3.1",
|
||||
"react-beautiful-dnd": "^13.1.1",
|
||||
"react-chartjs-2": "^5.3.0",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-router-dom": "^6.28.0",
|
||||
"recharts": "^2.15.0",
|
||||
"tailwind-merge": "^2.5.4",
|
||||
"tailwindcss-animate": "^1.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.13.0",
|
||||
"@types/node": "^22.10.2",
|
||||
"@types/react": "^18.3.12",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@vitejs/plugin-react-swc": "^3.5.0",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"eslint": "^8.57.1",
|
||||
"eslint-config-react": "^1.1.7",
|
||||
"eslint-config-react-app": "^7.0.1",
|
||||
"eslint-plugin-react": "^7.37.2",
|
||||
"eslint-plugin-react-hooks": "^5.0.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.14",
|
||||
"globals": "^15.11.0",
|
||||
"husky": "^8.0.0",
|
||||
"postcss": "^8.4.47",
|
||||
"tailwindcss": "^3.4.14",
|
||||
"typescript": "~5.6.2",
|
||||
"typescript-eslint": "^8.11.0",
|
||||
"vite": "^5.4.10"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,49 @@
|
||||
import React from 'react';
|
||||
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
|
||||
import { AppProvider } from './context/AppContext';
|
||||
import BacklogPage from './pages/BacklogPage';
|
||||
import TicketView from './ticketPopup/TicketView';
|
||||
import TicketCreate from './ticketPopup/TicketCreate';
|
||||
import Board from './components/Board/Board';
|
||||
import Availability from './components/AvailabiltyPage/Availability';
|
||||
import LoginPage from './assets/user/LoginPage';
|
||||
import PrivateRoute from '@/assets/user/PrivatRoute'
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<AppProvider>
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/login" element={<LoginPage />} />
|
||||
<Route path="/" element={<Navigate to="/board" />} />
|
||||
<Route
|
||||
path="/board"
|
||||
element={
|
||||
<PrivateRoute>
|
||||
<Board />
|
||||
</PrivateRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/backlog"
|
||||
element={
|
||||
<PrivateRoute>
|
||||
<BacklogPage />
|
||||
</PrivateRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/availability"
|
||||
element={
|
||||
<PrivateRoute>
|
||||
<Availability />
|
||||
</PrivateRoute>
|
||||
}
|
||||
/>
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
</AppProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 116 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
+46
@@ -0,0 +1,46 @@
|
||||
import { useState, useContext } from 'react'
|
||||
import { SignUpForm } from '@/assets/user/SignUpPage'
|
||||
import '@/assets/user/index.css'
|
||||
import { AppContext } from '@/context/AppContext';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
export default function LoginPage() {
|
||||
|
||||
const [isLogin, setIsLogin] = useState(true);
|
||||
const {LogIn, SignIn} = useContext(AppContext) as any;
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const navigate = useNavigate(); // Initialize navigate hook
|
||||
|
||||
const handleSubmit = async (username: string, password: string) => {
|
||||
if (isLogin) {
|
||||
try {
|
||||
await LogIn(username, password);
|
||||
navigate('/board'); // Redirect to board page
|
||||
} catch (error) {
|
||||
setError(error.message);
|
||||
}
|
||||
}else{
|
||||
await SignIn(username, password);
|
||||
setIsLogin(true);
|
||||
}
|
||||
};
|
||||
|
||||
const toggleAuthMode = () => {
|
||||
setIsLogin(!isLogin)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className=" items-center justify-center bg-gray-100">
|
||||
<div className="bg-white w-full max-w-md">
|
||||
<h1 className="text-2xl font-bold mb-6 text-center text-gray-800">
|
||||
{isLogin ? 'Log In' : 'Sign Up'}
|
||||
</h1>
|
||||
<SignUpForm
|
||||
isLogin={isLogin}
|
||||
onSubmit={handleSubmit}
|
||||
onToggle={toggleAuthMode}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { Navigate } from 'react-router-dom';
|
||||
import { AppContext } from '@/context/AppContext';
|
||||
|
||||
function PrivateRoute({ children }) {
|
||||
const { isAuthenticated } = useContext(AppContext);
|
||||
|
||||
return isAuthenticated ? children : <Navigate to="/login" />;
|
||||
}
|
||||
|
||||
export default PrivateRoute;
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
import { useContext, useState } from 'react'
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { AppContext } from '@/context/AppContext'
|
||||
|
||||
interface SignUpProps {
|
||||
isLogin: boolean
|
||||
onSubmit: (username: string, password: string, confirmPassword?: string) => void
|
||||
onToggle: () => void
|
||||
}
|
||||
|
||||
export function SignUpForm({ isLogin, onSubmit, onToggle }: SignUpProps) {
|
||||
const [username, setUsername] = useState('')
|
||||
const [password, setPassword] = useState('')
|
||||
const [confirmPassword, setConfirmPassword] = useState('')
|
||||
const {SignIn, LogIn} = useContext(AppContext) as any;
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault()
|
||||
|
||||
if (isLogin) {
|
||||
try {
|
||||
await onSubmit(username, password);
|
||||
// LogIn(username, password);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
} else {
|
||||
if (password === confirmPassword) {
|
||||
try {
|
||||
await SignIn(username, password);
|
||||
await onSubmit(username, password);
|
||||
isLogin = true;
|
||||
window.location.reload();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit} className="space-y-4 w-full max-w-sm">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="username" className="text-sm font-medium text-gray-700">
|
||||
Username
|
||||
</Label>
|
||||
<Input
|
||||
id="username"
|
||||
type="text"
|
||||
placeholder="Enter your username"
|
||||
value={username}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
required
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-gray-400"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="password" className="text-sm font-medium text-gray-700">
|
||||
Password
|
||||
</Label>
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
placeholder="Enter your password"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
required
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-gray-400"
|
||||
/>
|
||||
</div>
|
||||
{!isLogin && (
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="confirmPassword" className="text-sm font-medium text-gray-700">
|
||||
Confirm Password
|
||||
</Label>
|
||||
<Input
|
||||
id="confirmPassword"
|
||||
type="password"
|
||||
placeholder="Reenter your password"
|
||||
value={confirmPassword}
|
||||
onChange={(e) => setConfirmPassword(e.target.value)}
|
||||
required
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-gray-400"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<Button type="submit" className="w-full bg-black text-white hover:bg-gray-800">
|
||||
{isLogin ? 'Log In' : 'Sign Up'}
|
||||
</Button>
|
||||
<div className="text-center">
|
||||
<button
|
||||
type="button"
|
||||
onClick={onToggle}
|
||||
className="text-sm text-gray-600 hover:underline focus:outline-none"
|
||||
>
|
||||
{isLogin ? "Don't have an account? Sign up" : "Already have an account? Log in"}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 100vh;
|
||||
background-color: #f3f4f6; /* Tailwind's bg-gray-100 equivalent */
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
+35
@@ -0,0 +1,35 @@
|
||||
import SideBar from "@/components/Shared/SideBar/SideBar"
|
||||
import { SidebarProvider, SidebarInset } from "@/components/ui/sidebar"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { MoreVertical } from "lucide-react"
|
||||
import ShiftAvailability from "./ShiftAvailability"
|
||||
|
||||
|
||||
const Availability = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<SidebarProvider>
|
||||
<SideBar />
|
||||
<SidebarInset className="flex-1 overflow-auto">
|
||||
<header className="flex items-center justify-between border-b p-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<h1 className="text-xl font-semibold">Team Name/ Project Name/ Backlog</h1>
|
||||
</div>
|
||||
<Button variant="ghost" size="icon">
|
||||
<MoreVertical className="h-4 w-4" />
|
||||
</Button>
|
||||
</header>
|
||||
<div style={{ "marginLeft": "5rem" }}>
|
||||
<ShiftAvailability/>
|
||||
</div>
|
||||
</SidebarInset>
|
||||
</SidebarProvider>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
export default Availability
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
'use client'
|
||||
|
||||
import { useContext, useEffect, useState } from 'react'
|
||||
import { X } from 'lucide-react'
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select"
|
||||
import { Textarea } from "@/components/ui/textarea"
|
||||
|
||||
import { AppContext } from '@/context/AppContext'
|
||||
import { parse } from 'path'
|
||||
|
||||
|
||||
interface Developer {
|
||||
id: number
|
||||
name: string
|
||||
availableDays: number
|
||||
}
|
||||
|
||||
interface Adjustment {
|
||||
adjustmentPoints: number
|
||||
reason: string
|
||||
}
|
||||
|
||||
export default function ShiftAvailability() {
|
||||
|
||||
const {usersInShift, fetchUsersInShift, fetchUserAvailability, shifts, fetchShifts, fetchShiftAdjustment, addAdjustment, updateAvailability, shiftAdjustment, fetchShiftAdjustmentList, setAdjustments,adjustments} = useContext(AppContext) as any;
|
||||
|
||||
const [currentShift, setCurrentShift] = useState<number>(1);
|
||||
const [developers, setDevelopers] = useState<Developer[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
fetchUsersInShift(currentShift);
|
||||
fetchShifts();
|
||||
fetchShiftAdjustment(currentShift);
|
||||
const fetchTest = async () => {
|
||||
let test = await fetchShiftAdjustmentList(currentShift);
|
||||
}
|
||||
fetchTest();
|
||||
|
||||
}, [fetchUsersInShift, fetchShifts, currentShift]);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchAvailability = async () => {
|
||||
let newDevelopers: Developer[] = [];
|
||||
for (let i = 0; i < usersInShift.length; i++) {
|
||||
const user = usersInShift[i];
|
||||
const availability = await fetchUserAvailability(user.userId, currentShift);
|
||||
newDevelopers.push({
|
||||
id: user.userId,
|
||||
name: user.username,
|
||||
availableDays: availability.availabilityPoints
|
||||
});
|
||||
}
|
||||
setDevelopers(newDevelopers);
|
||||
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
||||
sleep(1000);
|
||||
// setTotalDays(developers.reduce((sum, dev) => sum + dev.availableDays, 0));
|
||||
};
|
||||
|
||||
if (usersInShift.length > 0) {
|
||||
fetchAvailability();
|
||||
}
|
||||
}, [usersInShift, fetchUserAvailability]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setTotalDays(developers.reduce((sum, dev) => sum + dev.availableDays, 0));
|
||||
}, [developers])
|
||||
|
||||
// const [adjustments, setAdjustments] = useState<Adjustment[]>([
|
||||
// { days: 1, reason: 'Team Planning Meeting' }
|
||||
// ])
|
||||
|
||||
const [newAdjustment, setNewAdjustment] = useState<Adjustment>({
|
||||
adjustmentPoints: 0,
|
||||
reason: ''
|
||||
})
|
||||
|
||||
// let totalDays = developers.reduce((sum, dev) => sum + dev.availableDays, 0)
|
||||
const [totalDays, setTotalDays] = useState(0);
|
||||
|
||||
|
||||
const handleUpdateAvailability = () => {
|
||||
developers.forEach(developer => {
|
||||
let newAvailability = { userId : developer.id,sprintId: currentShift, availabilityPoints: developer.availableDays }
|
||||
updateAvailability(developer.id, currentShift, newAvailability);
|
||||
})
|
||||
}
|
||||
|
||||
const handleAddAdjustment = () => {
|
||||
if (newAdjustment.adjustmentPoints && newAdjustment.reason) {
|
||||
setAdjustments([...adjustments, newAdjustment])
|
||||
setNewAdjustment({ adjustmentPoints: 0, reason: '' })
|
||||
let adjustmentToAdd = {
|
||||
AdjustmentPoints: newAdjustment.adjustmentPoints,
|
||||
reason: newAdjustment.reason
|
||||
}
|
||||
addAdjustment(currentShift, adjustmentToAdd);
|
||||
setTotalDays(totalDays - newAdjustment.adjustmentPoints);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const handleRemoveAdjustment = (index: number) => {
|
||||
setAdjustments(adjustments.filter((_, i) => i !== index))
|
||||
}
|
||||
|
||||
const onShiftChange = (e: any) => {
|
||||
setDevelopers([]);
|
||||
setAdjustments([]);
|
||||
setCurrentShift(e);
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto p-6 pl-0 pr-12 space-y-8">
|
||||
<div className="space-y-4">
|
||||
<h1 className="text-2xl font-semibold text-center">Shift Availability</h1>
|
||||
<div className="flex justify-center">
|
||||
<Select
|
||||
value={currentShift.toString()}
|
||||
onValueChange={onShiftChange}
|
||||
>
|
||||
<SelectTrigger className="w-[250px]">
|
||||
<SelectValue placeholder="Select shift" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{shifts.map((shift: any) => (
|
||||
<SelectItem key={shift.sprintId} value={shift.sprintId.toString()}>
|
||||
{shift.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-center items-center gap-6 text-base text-muted-foreground">
|
||||
<div className="flex items-center gap-2">
|
||||
<svg width="20" height="20" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="1" y="1" width="14" height="14" rx="2" stroke="currentColor" strokeWidth="2"/>
|
||||
</svg>
|
||||
<span>{totalDays} Availablilty Points</span>
|
||||
</div>
|
||||
<span>•</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<svg width="20" height="20" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M8 3V13M3 8H13" stroke="currentColor" strokeWidth="2"/>
|
||||
</svg>
|
||||
<span>{shiftAdjustment} Adjustments</span>
|
||||
</div>
|
||||
<span>•</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<svg width="20" height="20" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="8" cy="8" r="7" stroke="currentColor" strokeWidth="2"/>
|
||||
</svg>
|
||||
<span>{totalDays - shiftAdjustment} Total Days</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
{developers.map((developer, index) => (
|
||||
<div key={index} className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<label className="text-base text-muted-foreground">Developer Name</label>
|
||||
<Input
|
||||
value={developer.name}
|
||||
onChange={(e) => {
|
||||
const newDevelopers = [...developers]
|
||||
newDevelopers[index].name = e.target.value
|
||||
setDevelopers(newDevelopers)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<label className="text-base text-muted-foreground">Availabilty Points</label>
|
||||
<Input
|
||||
type="number"
|
||||
value={developer.availableDays !== undefined ? developer.availableDays : 0}
|
||||
onChange={(e) => {
|
||||
const newDevelopers = [...developers]
|
||||
newDevelopers[index].availableDays = parseInt(e.target.value)
|
||||
setDevelopers(newDevelopers)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
<div className="flex justify-center">
|
||||
<Button onClick={handleUpdateAvailability}>Update Availability</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
<h2 className="text-xl font-semibold">Adjustments</h2>
|
||||
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<label className="text-base text-muted-foreground">Days</label>
|
||||
<Input
|
||||
type="number"
|
||||
value={newAdjustment.adjustmentPoints || ''}
|
||||
onChange={(e) => setNewAdjustment({
|
||||
...newAdjustment,
|
||||
adjustmentPoints: parseInt(e.target.value)
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<label className="text-base text-muted-foreground">Reason</label>
|
||||
<Textarea
|
||||
value={newAdjustment.reason}
|
||||
onChange={(e) => setNewAdjustment({
|
||||
...newAdjustment,
|
||||
reason: e.target.value
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Button onClick={handleAddAdjustment}>Add Adjustment</Button>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
{adjustments.map((adjustment, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className="flex items-center justify-between p-4 bg-muted rounded-lg"
|
||||
>
|
||||
<span className="text-base">
|
||||
{adjustment.adjustmentPoints} {adjustment.adjustmentPoints === 1 ? 'day' : 'days'} - {adjustment.reason}
|
||||
</span>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => handleRemoveAdjustment(index)}
|
||||
>
|
||||
<X className="h-5 w-5" />
|
||||
</Button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
'use client'
|
||||
|
||||
import { useState, useEffect, useContext } from 'react'
|
||||
import { DragDropContext, Droppable, Draggable, DropResult } from 'react-beautiful-dnd'
|
||||
import { MoreVertical, Utensils, UtensilsCrossed } from 'lucide-react'
|
||||
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
import {
|
||||
SidebarProvider,
|
||||
SidebarInset,
|
||||
} from "@/components/ui/sidebar"
|
||||
import TicketCreate from '../../ticketPopup/TicketCreate'
|
||||
import TeamMates from '@/components/TeamMates/TeamMates'
|
||||
import SideBar from '@/components/Shared/SideBar/SideBar'
|
||||
import TicketView from '@/ticketPopup/TicketView'
|
||||
|
||||
import { AppContext } from '@/context/AppContext'
|
||||
|
||||
const ForkIcon = () => (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="25"
|
||||
height="25"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
>
|
||||
<path d="M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2" />
|
||||
<path d="M7 2v20" />
|
||||
</svg>
|
||||
)
|
||||
|
||||
|
||||
interface Task {
|
||||
id: string
|
||||
content: string
|
||||
state: string,
|
||||
priority?: number,
|
||||
intId: number
|
||||
}
|
||||
|
||||
interface Column {
|
||||
id: string
|
||||
title: string
|
||||
tasks: Task[]
|
||||
}
|
||||
|
||||
interface ColumnState {
|
||||
[key: string]: Column
|
||||
}
|
||||
|
||||
const Tasks = [
|
||||
]
|
||||
|
||||
const initcolumns: ColumnState = {
|
||||
'1': { id: '1', title: 'To Do UwU', tasks: [] },
|
||||
'2': { id: '2', title: 'Cooking UwU', tasks: [] },
|
||||
'3': { id: '3', title: 'In Plating UwU', tasks: [] },
|
||||
'4': { id: '4', title: 'Bon appetit UwU', tasks: [] },
|
||||
}
|
||||
|
||||
const status_to_state: { [key: string]: string } = {
|
||||
"To Do": "1",
|
||||
"Cooking": "2",
|
||||
"In Plating": "3",
|
||||
"Bon appétit": "4"
|
||||
}
|
||||
|
||||
const getPriorityIcon = (priority: number) => {
|
||||
switch (priority) {
|
||||
case 3:
|
||||
return <UtensilsCrossed className="h-4 w-4" />;
|
||||
case 2:
|
||||
return <Utensils className="h-4 w-4" />;
|
||||
case 1:
|
||||
return <ForkIcon />;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export default function Board() {
|
||||
const [columns, setColumns] = useState<ColumnState>(initcolumns);
|
||||
const [taskId, setTaskId] = useState<number>(0);
|
||||
const [viewOpen, setViewOpen] = useState<boolean>(false);
|
||||
const [storyTickets, setStoryTickets] = useState<any>([]);
|
||||
const context = useContext(AppContext);
|
||||
const { tickets, fetchTickets, updateTicketStatus } = context as any;
|
||||
|
||||
useEffect(() => {
|
||||
const asyncFunc = async () => {
|
||||
await fetchTickets();
|
||||
};
|
||||
asyncFunc();
|
||||
}, [fetchTickets]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const asyncFunc = async () => {
|
||||
if (!tickets || tickets.length === 0) {
|
||||
console.error('No tickets available');
|
||||
return;
|
||||
}
|
||||
|
||||
const stories = JSON.parse(JSON.stringify(tickets));
|
||||
if (!stories) {
|
||||
console.error('Failed to parse stories');
|
||||
return;
|
||||
}
|
||||
|
||||
setStoryTickets(stories);
|
||||
Tasks.splice(0, Tasks.length);
|
||||
stories.forEach((story: any) => {
|
||||
Tasks.push({
|
||||
id: `task-${story.storyId}`,
|
||||
content: story.title,
|
||||
state: status_to_state[story.status as string],
|
||||
priority: story.priority,
|
||||
intId: story.storyId,
|
||||
});
|
||||
});
|
||||
|
||||
const columnsCopy = { ...initcolumns };
|
||||
Object.values(columnsCopy).forEach((column) => {
|
||||
column.tasks = [];
|
||||
});
|
||||
Tasks.forEach((task) => {
|
||||
columnsCopy[task.state].tasks.push(task);
|
||||
});
|
||||
setColumns(columnsCopy);
|
||||
};
|
||||
|
||||
asyncFunc();
|
||||
}, [tickets]);
|
||||
|
||||
const onDragEnd = (result: DropResult) => {
|
||||
const { source, destination } = result;
|
||||
if (!destination) return;
|
||||
|
||||
const sourceColumn = columns[source.droppableId];
|
||||
const destColumn = columns[destination.droppableId];
|
||||
const sourceTasks = [...sourceColumn.tasks];
|
||||
const destTasks = [...destColumn.tasks];
|
||||
|
||||
if (source.droppableId === destination.droppableId) {
|
||||
const [reorderedItem] = sourceTasks.splice(source.index, 1);
|
||||
sourceTasks.splice(destination.index, 0, reorderedItem);
|
||||
setColumns({
|
||||
...columns,
|
||||
[source.droppableId]: {
|
||||
...sourceColumn,
|
||||
tasks: sourceTasks,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const [movedItem] = sourceTasks.splice(source.index, 1);
|
||||
movedItem.state = destination.droppableId; // Update the state of the moved task
|
||||
const story = storyTickets.find((story: any) => story.storyId === movedItem.intId);
|
||||
story.status = Object.keys(status_to_state).find(key => status_to_state[key] === movedItem.state);
|
||||
updateTicketStatus(movedItem.intId, story.status);
|
||||
destTasks.splice(destination.index, 0, movedItem);
|
||||
setColumns({
|
||||
...columns,
|
||||
[source.droppableId]: {
|
||||
...sourceColumn,
|
||||
tasks: sourceTasks,
|
||||
},
|
||||
[destination.droppableId]: {
|
||||
...destColumn,
|
||||
tasks: destTasks,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return (
|
||||
<SidebarProvider>
|
||||
<div className="flex h-screen">
|
||||
<SideBar />
|
||||
<SidebarInset className="flex-1 overflow-auto">
|
||||
<header className="flex items-center justify-between border-b p-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<h1 className="text-xl font-semibold">Team Name/ Project Name/ Board</h1>
|
||||
</div>
|
||||
<Button variant="ghost" size="icon">
|
||||
<MoreVertical className="h-4 w-4" />
|
||||
</Button>
|
||||
</header>
|
||||
<main className="p-6">
|
||||
<div className="mb-6 flex items-center justify-between">
|
||||
<TeamMates teamId={1} />
|
||||
<TicketCreate />
|
||||
{
|
||||
viewOpen ? (<TicketView id={taskId} handleClose={() => setViewOpen(false)} />) : ""
|
||||
}
|
||||
</div>
|
||||
<DragDropContext onDragEnd={onDragEnd}>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
||||
{Object.values(columns).map((column) => (
|
||||
<Droppable key={column.id} droppableId={column.id}>
|
||||
{(provided) => (
|
||||
<Card {...provided.droppableProps} ref={provided.innerRef}>
|
||||
<CardHeader>
|
||||
<CardTitle>{column.title} ({column.tasks.length})</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{column.tasks.map((task, index) => (
|
||||
<Draggable key={task.id} draggableId={task.id} index={index}>
|
||||
{(provided) => (
|
||||
<Card
|
||||
onClick={() => {
|
||||
setTaskId(task.intId);
|
||||
setViewOpen(true)
|
||||
}}
|
||||
ref={provided.innerRef}
|
||||
{...provided.draggableProps}
|
||||
{...provided.dragHandleProps}
|
||||
className="p-4"
|
||||
>
|
||||
<div className="flex justify-between items-start">
|
||||
<div>
|
||||
<h3 className="font-semibold mb-2">{task.content}</h3>
|
||||
<span className="inline-block bg-green-100 text-green-800 text-xs px-2 py-1 rounded">Parent</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{getPriorityIcon(task.priority as number)}
|
||||
<Avatar className="h-6 w-6">
|
||||
<AvatarFallback>U</AvatarFallback>
|
||||
</Avatar>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
</Draggable>
|
||||
))}
|
||||
{provided.placeholder}
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</Droppable>
|
||||
))}
|
||||
</div>
|
||||
</DragDropContext>
|
||||
</main>
|
||||
</SidebarInset>
|
||||
</div>
|
||||
</SidebarProvider>
|
||||
);
|
||||
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
.filter-menu{
|
||||
background-color: white;
|
||||
border: 1px solid #d6d4d4;
|
||||
width: 200px;
|
||||
height: 40px;
|
||||
padding: 0%;
|
||||
padding-left: 10px;
|
||||
text-align:start;
|
||||
font-weight: 400; /*Optional: change font, font weight or font-size*/
|
||||
}
|
||||
|
||||
.filter-item{
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.filter-text {
|
||||
display: flex;
|
||||
align-items: center; /* Centers text and icon vertically */
|
||||
}
|
||||
|
||||
.chevron-icon {
|
||||
margin-left: 100px; /* Adjust spacing between text and icon */
|
||||
}
|
||||
|
||||
.custom-checkbox {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
padding: 0;
|
||||
/* margin-bottom: 5px; */
|
||||
margin-right: 10px;
|
||||
background-color: white;
|
||||
border: 2px solid #ccc;
|
||||
border-radius: 5px;
|
||||
position: relative;
|
||||
/* display: block; */
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s, border-color 0.3s;
|
||||
}
|
||||
|
||||
.custom-checkbox[data-state="checked"] {
|
||||
background-color: black; /* Background color when checked */
|
||||
border-color: black; /* Border color when checked */
|
||||
}
|
||||
|
||||
/* Add a tick mark with CSS */
|
||||
.custom-checkbox[data-state="checked"] .indicator::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 5px;
|
||||
height: 10px;
|
||||
border-right: 2px solid white;
|
||||
border-bottom: 2px solid white;
|
||||
top: 3px;
|
||||
left: 6px;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuCheckboxItem,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import "./FilterDropdown.css";
|
||||
import { ChevronDown, ChevronUp } from "@mynaui/icons-react"; // import ChevronUp
|
||||
import { useState } from "react";
|
||||
import { Button } from "../ui/button";
|
||||
|
||||
const FilterDropdown = () => {
|
||||
// State for individual filter checkboxes
|
||||
const [selectedFilters, setSelectedFilters] = useState<{ [key: string]: boolean }>({
|
||||
Epic: false,
|
||||
Done: false,
|
||||
"In Plating": false,
|
||||
Cooking: false,
|
||||
"To Do": false,
|
||||
});
|
||||
|
||||
// State to track if the dropdown is open
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
// List of filters
|
||||
const filterList = ["Epic", "Done", "In Plating", "Cooking", "To Do"];
|
||||
|
||||
// Handle individual filter change
|
||||
const handleFilterChange = (filter: string, isChecked: boolean) => {
|
||||
setSelectedFilters((prevSelected) => ({
|
||||
...prevSelected,
|
||||
[filter]: isChecked,
|
||||
}));
|
||||
};
|
||||
|
||||
return (
|
||||
<DropdownMenu onOpenChange={(open) => setIsOpen(open)}> {/* Track dropdown open state */}
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="outline" style={{paddingRight: "5px"}}>
|
||||
Filter by {isOpen ? <ChevronUp style={{marginLeft: "60px"}}/> : <ChevronDown style={{marginLeft: "60px"}}/>} {/* Conditionally render chevron */}
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="w-56">
|
||||
{/* Render filter checkboxes */}
|
||||
{filterList.map((filter) => (
|
||||
<DropdownMenuCheckboxItem
|
||||
key={filter}
|
||||
checked={selectedFilters[filter] || false}
|
||||
onCheckedChange={(isChecked) => handleFilterChange(filter, isChecked)}
|
||||
>
|
||||
{filter}
|
||||
</DropdownMenuCheckboxItem>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
);
|
||||
};
|
||||
|
||||
export default FilterDropdown;
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
.search-bar {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 10rem;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.search-icon {
|
||||
position: absolute;
|
||||
left: 1rem; /* Adjust based on preference */
|
||||
color: #5f5c5c; /* Optional: change icon color */
|
||||
}
|
||||
|
||||
.search-input {
|
||||
padding-left: 3rem; /* Adjust based on icon width */
|
||||
border-radius: 100px;
|
||||
border: 1px solid #1d1c1c; /* Optional: change border color */
|
||||
/* font: ""; */
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// SearchBar.tsx
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { Search } from "@mynaui/icons-react"
|
||||
import "./SearchBar.css"
|
||||
|
||||
interface SearchBarProps {
|
||||
searchQuery: string;
|
||||
setSearchQuery: React.Dispatch<React.SetStateAction<string>>;
|
||||
}
|
||||
|
||||
const SearchBar = ({ searchQuery, setSearchQuery }: SearchBarProps) => {
|
||||
return (
|
||||
<div className="search-bar">
|
||||
<Search className="search-icon" />
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="Search task"
|
||||
className="search-input"
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)} // Handle input change
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
export default SearchBar;
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
import { Archive, ClipboardList, Users } from 'lucide-react'
|
||||
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
|
||||
import { useNavigate, useLocation } from 'react-router-dom' // Import useLocation
|
||||
import {
|
||||
Sidebar,
|
||||
SidebarContent,
|
||||
SidebarHeader,
|
||||
SidebarMenu,
|
||||
SidebarMenuItem,
|
||||
SidebarMenuButton,
|
||||
} from "@/components/ui/sidebar"
|
||||
|
||||
const SideBar = () => {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation(); // Get current route
|
||||
|
||||
return (
|
||||
<Sidebar className="w-64 border-r">
|
||||
<SidebarHeader className="border-b p-4 pl-6">
|
||||
<div className="flex items-center gap-3">
|
||||
<Avatar className="h-10 w-10">
|
||||
<AvatarFallback className="bg-primary text-primary-foreground text-lg">TN</AvatarFallback>
|
||||
</Avatar>
|
||||
<span className="font-semibold text-xl">Team Name</span>
|
||||
</div>
|
||||
</SidebarHeader>
|
||||
<SidebarContent className="pl-6">
|
||||
<SidebarMenu>
|
||||
<SidebarMenuItem>
|
||||
<SidebarMenuButton
|
||||
onClick={() => navigate("/backlog")}
|
||||
className={`justify-start text-base ${
|
||||
location.pathname === "/backlog" ? "bg-gray-300 dark:bg-gray-700" : ""
|
||||
}`}
|
||||
>
|
||||
<ClipboardList className="h-5 w-5 mr-3" />
|
||||
<span>Backlog</span>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
<SidebarMenuItem>
|
||||
<SidebarMenuButton
|
||||
onClick={() => navigate("/board")}
|
||||
className={`justify-start text-base ${
|
||||
location.pathname === "/board" ? "bg-gray-300 dark:bg-gray-700" : ""
|
||||
}`}
|
||||
>
|
||||
<Archive className="h-5 w-5 mr-3" />
|
||||
<span>Board</span>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
<SidebarMenuItem>
|
||||
<SidebarMenuButton
|
||||
onClick={() => navigate("/availability")}
|
||||
className={`justify-start text-base ${
|
||||
location.pathname === "/availability" ? "bg-gray-300 dark:bg-gray-700" : ""
|
||||
}`}
|
||||
>
|
||||
<Users className="h-5 w-5 mr-3" />
|
||||
<span>Availability</span>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
</SidebarMenu>
|
||||
</SidebarContent>
|
||||
</Sidebar>
|
||||
)
|
||||
}
|
||||
|
||||
export default SideBar
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
.user-card {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 2.5vw;
|
||||
height: 2.5vw;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.user-logo {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
border-radius: 50%;
|
||||
margin-right: 0.5em;
|
||||
margin-left: 0.5em;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.user-logo-hover-text {
|
||||
position: absolute;
|
||||
bottom: -25px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background-color: rgba(0, 0, 0, 0.7);
|
||||
color: white;
|
||||
padding: 5px;
|
||||
border-radius: 5px;
|
||||
white-space: nowrap;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.3s ease;
|
||||
font-size: 0.75em;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.user-card:hover .user-logo-hover-text {
|
||||
opacity: 1;
|
||||
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
import { useEffect } from "react";
|
||||
import "./UserCard.css";
|
||||
const UserCard = ({ hoverName }: { hoverName?: string }) => {
|
||||
const id=`user-${hoverName}`;
|
||||
useEffect(() => {
|
||||
const hoverElement = document.getElementById(id);
|
||||
const hoverText = document.getElementById(`${id}-hover-text`);
|
||||
|
||||
if (hoverElement && hoverText && hoverName) {
|
||||
const handleMouseEnter = () => {
|
||||
hoverText.style.display = 'block';
|
||||
};
|
||||
const handleMouseLeave = () => {
|
||||
hoverText.style.display = 'none';
|
||||
};
|
||||
|
||||
hoverElement.addEventListener('mouseenter', handleMouseEnter);
|
||||
hoverElement.addEventListener('mouseleave', handleMouseLeave);
|
||||
|
||||
// Cleanup listeners on unmount
|
||||
return () => {
|
||||
hoverElement.removeEventListener('mouseenter', handleMouseEnter);
|
||||
hoverElement.removeEventListener('mouseleave', handleMouseLeave);
|
||||
};
|
||||
}
|
||||
}, [id]);
|
||||
if(hoverName === undefined){
|
||||
return (<div className="user-card">
|
||||
<img className="user-logo" id={`user-${hoverName}`} src="src/assets/solid_red.png">
|
||||
|
||||
</img>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return (<div className="user-card">
|
||||
<img className="user-logo" id={`user-${hoverName}`} src="src/assets/user_logo.png">
|
||||
|
||||
</img>
|
||||
<p className="user-logo-hover-text" id={`user-${hoverName}-hover-text`}>{hoverName}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export default UserCard;
|
||||
+236
@@ -0,0 +1,236 @@
|
||||
/* Custom checkbox styling */
|
||||
.custom-checkbox {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
padding: 0;
|
||||
/* margin-bottom: 5px; */
|
||||
margin-right: 10px;
|
||||
background-color: white;
|
||||
border: 2px solid #ccc;
|
||||
border-radius: 5px;
|
||||
position: relative;
|
||||
/* display: block; */
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s, border-color 0.3s;
|
||||
}
|
||||
|
||||
.custom-checkbox[data-state="checked"] {
|
||||
background-color: black; /* Background color when checked */
|
||||
border-color: black; /* Border color when checked */
|
||||
}
|
||||
|
||||
/* Add a tick mark with CSS */
|
||||
.custom-checkbox[data-state="checked"] .indicator::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 5px;
|
||||
height: 10px;
|
||||
border-right: 2px solid white;
|
||||
border-bottom: 2px solid white;
|
||||
top: 3px;
|
||||
left: 6px;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.task-table {
|
||||
width: 70vw;
|
||||
/* height: 100vh; */
|
||||
display: table;
|
||||
border-collapse: collapse;
|
||||
border: #e1dfdf 1px solid;
|
||||
table-layout: fixed; /* Ensures consistent column width */
|
||||
|
||||
}
|
||||
|
||||
.task-table th,
|
||||
.task-table td {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis; /* Ensures ellipsis for overflow text */
|
||||
white-space: nowrap; /* Prevents wrapping of text */
|
||||
}
|
||||
|
||||
.arrow{
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.status-div {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.status-bubble {
|
||||
width: 50%;
|
||||
height: 30px;
|
||||
padding: 5px;
|
||||
border-radius: 50px;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.status-cell{
|
||||
justify-content: flex;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.status-to-do {
|
||||
background-color: #a7f3d0; /* Light green */
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.status-cooking {
|
||||
background-color: #d9f99d; /* Light lime */
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.status-in-plating {
|
||||
background-color: #fdba74; /* Light orange */
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.status-bon-appetit {
|
||||
background-color: #fca5a5; /* Light red */
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.status-default {
|
||||
background-color: #9ca3af; /* Light gray */
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.search-dropdown-div{
|
||||
display: flex;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
.dropdown-div{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: 2rem;
|
||||
}
|
||||
|
||||
/* General Button Styling */
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
/* Modal Overlay */
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
/* Modal Content */
|
||||
.modal-content {
|
||||
background-color: #fff;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
width: 400px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
/* Modal Header */
|
||||
.modal-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.modal-header h2 {
|
||||
margin: 0;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
.close-button {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 1.5em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Modal Body */
|
||||
.modal-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.modal-body label {
|
||||
font-weight: bold;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.modal-body input,
|
||||
.modal-body select,
|
||||
.modal-body textarea {
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.modal-body textarea {
|
||||
resize: none;
|
||||
}
|
||||
|
||||
/* Modal Footer */
|
||||
.modal-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.cancel-button {
|
||||
background-color: #ccc;
|
||||
color: #000;
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.submit-button {
|
||||
background-color: #007bff;
|
||||
color: #fff;
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.submit-button:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
input, select, textarea{
|
||||
background-color: rgb(228, 224, 224); /* Set background to white */
|
||||
color: black; /* Set text color to black */
|
||||
padding: 0.5rem; /* Add padding for better appearance */
|
||||
}
|
||||
|
||||
input, textarea {
|
||||
border: 1px solid #ccc; /* Optional: Add a visible border */
|
||||
}
|
||||
|
||||
.select-task {
|
||||
background-color: transparent;
|
||||
/*height: fit-content;*/
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.select-task:focus {
|
||||
outline: none;
|
||||
}
|
||||
+572
@@ -0,0 +1,572 @@
|
||||
'use client'
|
||||
|
||||
|
||||
import { useContext, useEffect, useState } from 'react'
|
||||
import { ArrowUpDown, BaggageClaim, ChevronDown, ChevronDownCircle, ChevronUp, Icon, PlusCircleIcon } from 'lucide-react'
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
|
||||
import { Utensils, UtensilsCrossed } from 'lucide-react'
|
||||
import { Checkbox } from '@/components/ui/checkbox'
|
||||
import { Button } from '@/components/ui/button'
|
||||
|
||||
import TeamMates from '../TeamMates/TeamMates'
|
||||
import TicketCreate from '@/ticketPopup/TicketCreate'
|
||||
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuCheckboxItem,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu'
|
||||
import SearchBar from '@/components/SearchBar/SearchBar'
|
||||
import './TaskTable.css'
|
||||
import { Badge } from '../ui/badge'
|
||||
import UserCard from '../Shared/UserCard/UserCard'
|
||||
import { AppContext } from '@/context/AppContext'
|
||||
import { Password } from '@mynaui/icons-react'
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select'
|
||||
|
||||
const ForkIcon = () => (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="25"
|
||||
height="25"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
>
|
||||
<path d="M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2" />
|
||||
<path d="M7 2v20" />
|
||||
</svg>
|
||||
)
|
||||
|
||||
|
||||
// const tasksData = [
|
||||
// { task: 'Task 1', title: 'Title 1', priority: 1, status: 'Cooking', shift: 'Shift 1' },
|
||||
// { task: 'Task 2', title: 'Title 2', priority: 2, status: 'To Do', shift: 'Shift 2' },
|
||||
// { task: 'Task 3', title: 'Title 3', priority: 3, status: 'Cooking', shift: 'Shift 1' },
|
||||
// { task: 'Task 4', title: 'Title 4', priority: 1, status: 'Bon appétit', shift: 'Shift 2' },
|
||||
// { task: 'Task 5', title: 'Title 5', priority: 2, status: 'Bon appétit', shift: 'Shift 1' },
|
||||
// { task: 'Task 6', title: 'Title 6', priority: 3, status: 'In Plating', shift: 'Shift 2' },
|
||||
// { task: 'Task 7', title: 'Title 7', priority: 1, status: 'In Plating', shift: 'Shift 1' },
|
||||
// ]
|
||||
|
||||
// const shiftsData = [
|
||||
// { task: 1, title: 'Title 1', startDate: '2022-10-01', endDate: '2022-10-03', description: 'Description 1' },
|
||||
// { task: 2, title: 'Title 2', startDate: '2022-10-04', endDate: '2022-10-06', description: 'Description 2' },
|
||||
// ]
|
||||
|
||||
|
||||
const filterList = ['Bon appétit', 'In Plating', 'Cooking', 'To Do']
|
||||
|
||||
|
||||
|
||||
const FilterableTaskTable = () => {
|
||||
const [tasksLocal, setTasks] = useState([]);
|
||||
const [shiftsLocal, setShifts] = useState([]);
|
||||
|
||||
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [selectedFilters, setSelectedFilters] = useState<{ [key: string]: boolean }>({})
|
||||
// const [selectedFilters, setSelectedFilters] = useState({});
|
||||
const [selectedTasks, setSelectedTasks] = useState(new Set());
|
||||
// const [sortConfig, setSortConfig] = useState(null);
|
||||
const [isOpen, setIsOpen] = useState(false)
|
||||
const [sortConfig, setSortConfig] = useState<{ key: keyof typeof tickets[0]; direction: 'asc' | 'desc' } | null>(null)
|
||||
// const [selectedTasks, setSelectedTasks] = useState<Set<string>>(new Set()) // Track selected tasks
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
const [isTaskModalOpen, setIsTaskModalOpen] = useState(false);
|
||||
|
||||
const [localUsers, setLocalUsers] = useState([]);
|
||||
|
||||
|
||||
const [viewOpen, setViewOpen] = useState<boolean>(false);
|
||||
|
||||
const { tickets, fetchTickets, shifts, fetchShifts, addTicket, addShift, fetchUser, users, fetchUsers, availabilities, fetchSprintAvailability, updateTicketStatus } = useContext(AppContext) as any;
|
||||
|
||||
useEffect(() => {
|
||||
const asyncFunc = async () => {
|
||||
await fetchTickets();
|
||||
};
|
||||
asyncFunc();
|
||||
}, [fetchTickets]);
|
||||
|
||||
useEffect(() => {
|
||||
const asyncFunc = async () => {
|
||||
if (!tickets || tickets.length === 0) {
|
||||
console.error('No tickets available');
|
||||
return;
|
||||
}
|
||||
|
||||
const newTasks = tickets.map((ticket: any) => ({
|
||||
taskId: ticket.storyId,
|
||||
title: ticket.title,
|
||||
priority: ticket.priority,
|
||||
status: ticket.status,
|
||||
shiftId: ticket.sprintId,
|
||||
createdBy: ticket.createdBy,
|
||||
}));
|
||||
|
||||
setTasks(newTasks);
|
||||
}
|
||||
asyncFunc();
|
||||
}, [tickets])
|
||||
|
||||
useEffect(() => {
|
||||
const asyncFunc = async () => {
|
||||
await fetchShifts();
|
||||
};
|
||||
asyncFunc();
|
||||
}, [fetchShifts]);
|
||||
|
||||
useEffect(() => {
|
||||
const asyncFunc = async () => {
|
||||
if (!shifts || shifts.length === 0) {
|
||||
console.error('No shifts available');
|
||||
return;
|
||||
}
|
||||
|
||||
const newShifts = shifts.map((shift: any) => ({
|
||||
shiftId: shift.sprintId,
|
||||
name: shift.name,
|
||||
startDate: shift.startDate,
|
||||
endDate: shift.endDate,
|
||||
goal: shift.goal,
|
||||
}));
|
||||
setShifts(newShifts);
|
||||
}
|
||||
asyncFunc();
|
||||
}, [shifts]);
|
||||
|
||||
useEffect(() => {
|
||||
const asyncFunc = async () => {
|
||||
await fetchSprintAvailability();
|
||||
}
|
||||
asyncFunc();
|
||||
}, [fetchSprintAvailability]);
|
||||
|
||||
useEffect(() => {
|
||||
const asyncFunc = async () => {
|
||||
await fetchUsers();
|
||||
console.log(users);
|
||||
console.log("users----------------------------------------------------------", users);
|
||||
};
|
||||
asyncFunc();
|
||||
}, [fetchUsers]);
|
||||
|
||||
useEffect(() => {
|
||||
const asyncFunc = async () => {
|
||||
if (!users || users.length === 0) {
|
||||
console.error('No users available');
|
||||
return;
|
||||
}
|
||||
|
||||
const newUsers = users.map((user: any) => ({
|
||||
id: user.userId,
|
||||
name: user.username,
|
||||
Password: user.password,
|
||||
}));
|
||||
setLocalUsers(newUsers);
|
||||
}
|
||||
asyncFunc();
|
||||
}, [users])
|
||||
|
||||
|
||||
const handleFilterChange = (filter: string, isChecked: boolean) => {
|
||||
setSelectedFilters((prev) => ({ ...prev, [filter]: isChecked }))
|
||||
}
|
||||
|
||||
const handleCreateShift = (event: React.FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault();
|
||||
const target = event.target as typeof event.target & {
|
||||
title: { value: string };
|
||||
startDate: { value: string };
|
||||
endDate: { value: string };
|
||||
description: { value: string };
|
||||
};
|
||||
event.preventDefault();
|
||||
const newShift = {
|
||||
name: target.title.value,
|
||||
startDate: target.startDate.value,
|
||||
endDate: target.endDate.value,
|
||||
goal: target.description.value,
|
||||
sprintId: 0,
|
||||
status: "Active",
|
||||
teamId: 1
|
||||
};
|
||||
console.log("newShift", newShift)
|
||||
addShift(newShift);
|
||||
setIsModalOpen(false);
|
||||
};
|
||||
|
||||
|
||||
const statusOrder: { [key: string]: number } = {
|
||||
"To Do": 1,
|
||||
"Cooking": 2,
|
||||
"In Plating": 3,
|
||||
"Bon appétit": 4,
|
||||
}
|
||||
|
||||
const handleSort = (key: keyof typeof tasksLocal[0]) => {
|
||||
setSortConfig((prev) => ({
|
||||
key,
|
||||
direction: prev?.key === key && prev.direction === "asc" ? "desc" : "asc",
|
||||
}));
|
||||
};
|
||||
|
||||
// Filter tasks based on selected filters
|
||||
const filteredTasks = tasksLocal.filter((task) => {
|
||||
if (Object.values(selectedFilters).every((v) => !v)) return true
|
||||
return selectedFilters[task.status]
|
||||
})
|
||||
|
||||
// Further filter tasks based on the search query
|
||||
const searchFilteredTasks = filteredTasks.filter((task) => {
|
||||
const normalizedQuery = searchQuery.replace(/\s+/g, '').toLowerCase();
|
||||
const normalizedTitle = task.title.replace(/\s+/g, '').toLowerCase();
|
||||
return normalizedTitle.includes(normalizedQuery);
|
||||
});
|
||||
|
||||
// Sort tasks based on sortConfig
|
||||
const sortedTasks = [...searchFilteredTasks].sort((a, b) => {
|
||||
// console.log("searchFilteredTasks", searchFilteredTasks);
|
||||
if (!sortConfig) return 0;
|
||||
const { key, direction } = sortConfig;
|
||||
|
||||
// Custom comparison for 'status'
|
||||
if (key === 'status') {
|
||||
const orderA = statusOrder[a.status] || 0;
|
||||
const orderB = statusOrder[b.status] || 0;
|
||||
return direction === 'asc' ? orderA - orderB : orderB - orderA;
|
||||
}
|
||||
|
||||
// Default comparison for other fields
|
||||
if (a[key] < b[key]) return direction === 'asc' ? -1 : 1;
|
||||
if (a[key] > b[key]) return direction === 'asc' ? 1 : -1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
// Handle selecting or deselecting all tasks
|
||||
const handleSelectAll = (isChecked: boolean) => {
|
||||
if (isChecked) {
|
||||
setSelectedTasks(new Set(sortedTasks.map((task) => task.taskId))) // Select all tasks
|
||||
} else {
|
||||
setSelectedTasks(new Set()) // Deselect all tasks
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Handle individual task selection
|
||||
const handleTaskSelect = (task: string, isChecked: boolean) => {
|
||||
setSelectedTasks((prev) => {
|
||||
const updated = new Set(prev)
|
||||
if (isChecked) {
|
||||
updated.add(task)
|
||||
} else {
|
||||
updated.delete(task)
|
||||
}
|
||||
return updated
|
||||
})
|
||||
}
|
||||
const groupedTasks = shiftsLocal.map((shift) => {
|
||||
|
||||
//console.log("sortedTasks", sortedTasks);
|
||||
const tasksForShift = sortedTasks.filter(
|
||||
(task) =>
|
||||
task.shiftId === shift.shiftId
|
||||
|
||||
|
||||
);
|
||||
|
||||
|
||||
//console.log("tasksForShift", tasksForShift);
|
||||
//console.log("shiftsLocal", shiftsLocal);
|
||||
|
||||
// Count tasks based on their status
|
||||
const statusCounts = tasksForShift.reduce(
|
||||
(counts, task) => {
|
||||
if (task.status === 'To Do') counts.toDo++;
|
||||
if (task.status === 'Cooking') counts.cooking++;
|
||||
if (task.status === 'In Plating') counts.inPlating++;
|
||||
if (task.status === 'Bon appétit') counts.bonAppetit++;
|
||||
return counts;
|
||||
},
|
||||
{ toDo: 0, cooking: 0, inPlating: 0, bonAppetit: 0 }
|
||||
);
|
||||
|
||||
return {
|
||||
shiftId: shift.shiftId,
|
||||
shiftName: shift.name,
|
||||
tasks: tasksForShift,
|
||||
statusCounts, // Add the status counts here
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Function to get the appropriate class based on status
|
||||
const getStatusClass = (status: string) => {
|
||||
switch (status) {
|
||||
case 'To Do':
|
||||
return 'status-bubble status-to-do';
|
||||
case 'Cooking':
|
||||
return 'status-bubble status-cooking';
|
||||
case 'In Plating':
|
||||
return 'status-bubble status-in-plating';
|
||||
case 'Bon appétit':
|
||||
return 'status-bubble status-bon-appetit';
|
||||
default:
|
||||
return 'status-bubble status-default';
|
||||
}
|
||||
}
|
||||
|
||||
const handleCreateTask = (event: React.FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault();
|
||||
const target = event.target as typeof event.target & {
|
||||
title: { value: string };
|
||||
shift: { value: string };
|
||||
priority: { value: string };
|
||||
status: { value: string };
|
||||
};
|
||||
const newTask = {
|
||||
storyId: tasksLocal.length + 1,
|
||||
title: target.title.value,
|
||||
sprintId: parseInt(target.shift.value),
|
||||
priority: parseInt(target.priority.value),
|
||||
status: target.status.value,
|
||||
};
|
||||
addTicket(newTask);
|
||||
setIsTaskModalOpen(false);
|
||||
}
|
||||
|
||||
const handleStatusChange = (taskId: number, newStatus: string) => {
|
||||
console.log("taskId --------------", taskId);
|
||||
updateTicketStatus(taskId, newStatus);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4 mb-20">
|
||||
{/* Search Bar */}
|
||||
<div className="search-dropdown-div">
|
||||
<SearchBar searchQuery={searchQuery} setSearchQuery={setSearchQuery} />
|
||||
|
||||
<div className='dropdown-div'>
|
||||
<DropdownMenu onOpenChange={setIsOpen}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="outline" className="w-[150px] justify-between">
|
||||
Filter by
|
||||
{isOpen ? <ChevronUp className="ml-2 h-4 w-4" /> : <ChevronDown className="ml-2 h-4 w-4" />}
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="w-56">
|
||||
{filterList.map((filter) => (
|
||||
<DropdownMenuCheckboxItem
|
||||
key={filter}
|
||||
checked={selectedFilters[filter] || false}
|
||||
onCheckedChange={(isChecked) => handleFilterChange(filter, isChecked)}
|
||||
>
|
||||
{filter}
|
||||
</DropdownMenuCheckboxItem>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
|
||||
<div className="bg-white-500 text-gray flex items-center justify-between">
|
||||
<TicketCreate />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{groupedTasks.map((group) => (
|
||||
<div key={group.shiftId} className="task-group">
|
||||
<div className="flex items-center justify-between gap-4 p-2 border border-gray-300 rounded-md bg-white shadow-sm">
|
||||
<div className="flex items-center gap-4">
|
||||
<span className="text-s font-bold text-gray-400">{group.shiftName}</span>
|
||||
<span className="text-s font-bold text-gray-400">
|
||||
Availability: {availabilities.find((a: any) => a.sprintId === group.shiftId).availability}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-4 ml-auto">
|
||||
<span className="text-xs font-bold text-gray-400">To do:
|
||||
<Badge variant="outline" className="status-to-do mr-2">
|
||||
{group.statusCounts.toDo}
|
||||
</Badge></span>
|
||||
<span className="text-xs font-bold text-gray-400">Cooking:
|
||||
<Badge variant="outline" className="status-cooking mr-2">
|
||||
{group.statusCounts.cooking}
|
||||
</Badge></span>
|
||||
<span className="text-xs font-bold text-gray-400">In plating:
|
||||
<Badge variant="outline" className="status-in-plating mr-2">
|
||||
{group.statusCounts.inPlating}
|
||||
</Badge></span>
|
||||
<span className="text-xs font-bold text-gray-400">Bon appétit:
|
||||
<Badge variant="outline" className="status-bon-appetit mr-2">
|
||||
{group.statusCounts.bonAppetit}
|
||||
</Badge></span>
|
||||
</div>
|
||||
</div>
|
||||
<Table className="task-table">
|
||||
<TableHeader>
|
||||
<TableRow className="bg-gray-100">
|
||||
<TableHead className="w-[100px] pl-2">
|
||||
{/* <Checkbox
|
||||
checked={sortedTasks.length > 0 && sortedTasks.every((task) => selectedTasks.has(task.taskId))}
|
||||
onCheckedChange={handleSelectAll}
|
||||
className="custom-checkbox"
|
||||
color='grey'
|
||||
/> */}
|
||||
Task
|
||||
</TableHead>
|
||||
<TableHead onClick={() => handleSort('title')} className="cursor-pointer w-[150px]">
|
||||
Title <ArrowUpDown className='inline h-4 w-4' />
|
||||
</TableHead>
|
||||
<TableHead onClick={() => handleSort('priority')} className="cursor-pointer w-[100px]">
|
||||
Priority <ArrowUpDown className='inline h-4 w-4' />
|
||||
</TableHead>
|
||||
<TableHead onClick={() => handleSort('status')} className="cursor-pointer w-[200px] text-center">
|
||||
Status <ArrowUpDown className='inline h-4 w-4' />
|
||||
</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{group.tasks.map((task) => (
|
||||
<TableRow key={task.taskId}>
|
||||
<TableCell className="font-medium truncate max-w-[100px] text-gray-500" >
|
||||
<Checkbox
|
||||
checked={selectedTasks.has(task.taskId)}
|
||||
onCheckedChange={(isChecked) => handleTaskSelect(task.taskId, isChecked as boolean)}
|
||||
className="mr-2 custom-checkbox"
|
||||
/>
|
||||
Task {task.taskId}
|
||||
</TableCell>
|
||||
<TableCell className='truncate max-w-[150px] font-bold'>{task.title} </TableCell>
|
||||
<TableCell className='truncate max-w-[100px]'>
|
||||
{task.priority === 1 ? <ForkIcon /> : task.priority === 2 ? <Utensils /> : <UtensilsCrossed />}
|
||||
</TableCell>
|
||||
<TableCell className='status-cell'>
|
||||
<Badge variant="outline" className="bg-green-300 mr-4 w-[100px] status-div h-[30px]">
|
||||
Parent
|
||||
</Badge>
|
||||
|
||||
<div className={`${getStatusClass(task.status)}`}>
|
||||
<Select value={task.status} onValueChange={(value: string) => handleStatusChange(task.taskId, value)}>
|
||||
<SelectTrigger className={`border-0 select-task focus:ring-0 focus:box-shadow-0`}>
|
||||
<SelectValue placeholder="Select status" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="To Do">To Do</SelectItem>
|
||||
<SelectItem value="Cooking">Cooking</SelectItem>
|
||||
<SelectItem value="In Plating">In Plating</SelectItem>
|
||||
<SelectItem value="Bon appétit">Bon appétit</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
{/*<DropdownMenu onOpenChange={setIsOpen}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<div className={`status-div`}>
|
||||
{task.status}
|
||||
{<ChevronDownCircle />}
|
||||
</div>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="w-56">
|
||||
{filterList.map((status) => (
|
||||
<DropdownMenuItem
|
||||
key={status}
|
||||
checked={selectedFilters[filter] || false}
|
||||
onCheckedChange={(isChecked) => handleFilterChange(filter, isChecked)}
|
||||
>
|
||||
{filter}
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>*/}
|
||||
</div>
|
||||
|
||||
{/* <img className="user-logo" src="src/assets/user_logo.png"></img> */}
|
||||
<UserCard hoverName={users.find((user) => user.userId == task.createdBy).username} />
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
))}
|
||||
|
||||
<div>
|
||||
{/* Modal for Shift Creation */}
|
||||
<Button onClick={() => setIsModalOpen(true)} className="bg-white-500 hover:bg-gray-300 text-gray">
|
||||
<PlusCircleIcon size={18} /> Create Shift
|
||||
</Button>
|
||||
{isModalOpen && (
|
||||
<div className="modal-overlay">
|
||||
<div className="modal-content">
|
||||
<h2 className="text-xl font-bold mb-4">Create New Shift</h2>
|
||||
<form onSubmit={handleCreateShift} className="space-y-4">
|
||||
<div className="form-group">
|
||||
<label htmlFor="title" className="block font-medium mb-1">Shift Name</label>
|
||||
<input
|
||||
id="title"
|
||||
name="title"
|
||||
className="input-field w-full p-2 border border-gray-300 rounded-md"
|
||||
placeholder="Enter shift name"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label htmlFor="startDate" className="block font-medium mb-1">Start Date</label>
|
||||
<input
|
||||
id="startDate"
|
||||
name="startDate"
|
||||
type="date"
|
||||
className="input-field w-full p-2 border border-gray-300 rounded-md"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label htmlFor="endDate" className="block font-medium mb-1">End Date</label>
|
||||
<input
|
||||
id="endDate"
|
||||
name="endDate"
|
||||
type="date"
|
||||
className="input-field w-full p-2 border border-gray-300 rounded-md"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label htmlFor="description" className="block font-medium mb-1">Description</label>
|
||||
<textarea
|
||||
id="description"
|
||||
name="description"
|
||||
className="input-field w-full p-2 border border-gray-300 rounded-md"
|
||||
// rows="4"
|
||||
placeholder="Enter shift description"
|
||||
required
|
||||
></textarea>
|
||||
</div>
|
||||
<div className="form-actions flex items-center justify-end space-x-4">
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => setIsModalOpen(false)}
|
||||
className="bg-gray-200 hover:bg-gray-300 text-gray-800"
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button type="submit" className="bg-blue-500 hover:bg-blue-600 text-white">
|
||||
Create
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default FilterableTaskTable
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
.flex-container {
|
||||
display: flex; /* Flexbox for alignment */
|
||||
flex-wrap: wrap; /* Allow cards to wrap to the next line */
|
||||
gap: 1em; /* Even spacing between cards */
|
||||
justify-content: flex-start; /* Align items to the left (or adjust as needed) */
|
||||
align-items: center; /* Ensure items align properly */
|
||||
flex-direction: row; /* Align items horizontally */
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
import React, { useContext, useEffect, useState } from "react";
|
||||
import UserCard from "../Shared/UserCard/UserCard";
|
||||
import './TeamMates.css';
|
||||
import { AppContext } from "@/context/AppContext";
|
||||
|
||||
const TeamMates = ({ teamId }: { teamId: number }) => {
|
||||
|
||||
const {teamMates, fetchTeamMates} = useContext(AppContext) as any;
|
||||
|
||||
useEffect(() => {
|
||||
// fetch(`http://localhost:5073/Test/GetUsersInTeam/${teamId}`)
|
||||
// .then((response) => response.json())
|
||||
// .then((data: { username: string }[]) => {
|
||||
// const usernames = data.map(user => user.username);
|
||||
// setTeamMates(usernames);
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// console.error("Error fetching teammates:", error);
|
||||
// });
|
||||
async function fetchTeamMates1(teamId: number) {
|
||||
fetchTeamMates(teamId);
|
||||
}
|
||||
fetchTeamMates1(teamId);
|
||||
}, [teamId]);
|
||||
|
||||
return (
|
||||
<div className="flex-container teammates-component">
|
||||
<span>Team Mates: </span>
|
||||
{
|
||||
teamMates.map((teammate, index) => (
|
||||
<UserCard key={index} hoverName={teammate.username} />
|
||||
))
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default TeamMates;
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
import * as React from "react"
|
||||
import * as AvatarPrimitive from "@radix-ui/react-avatar"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const Avatar = React.forwardRef<
|
||||
React.ElementRef<typeof AvatarPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AvatarPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
Avatar.displayName = AvatarPrimitive.Root.displayName
|
||||
|
||||
const AvatarImage = React.forwardRef<
|
||||
React.ElementRef<typeof AvatarPrimitive.Image>,
|
||||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AvatarPrimitive.Image
|
||||
ref={ref}
|
||||
className={cn("aspect-square h-full w-full", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AvatarImage.displayName = AvatarPrimitive.Image.displayName
|
||||
|
||||
const AvatarFallback = React.forwardRef<
|
||||
React.ElementRef<typeof AvatarPrimitive.Fallback>,
|
||||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AvatarPrimitive.Fallback
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex h-full w-full items-center justify-center rounded-full bg-muted",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName
|
||||
|
||||
export { Avatar, AvatarImage, AvatarFallback }
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
import * as React from "react"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const badgeVariants = cva(
|
||||
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default:
|
||||
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
|
||||
secondary:
|
||||
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
||||
destructive:
|
||||
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
|
||||
outline: "text-foreground",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
export interface BadgeProps
|
||||
extends React.HTMLAttributes<HTMLDivElement>,
|
||||
VariantProps<typeof badgeVariants> {}
|
||||
|
||||
function Badge({ className, variant, ...props }: BadgeProps) {
|
||||
return (
|
||||
<div className={cn(badgeVariants({ variant }), className)} {...props} />
|
||||
)
|
||||
}
|
||||
|
||||
export { Badge, badgeVariants }
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
import * as React from "react"
|
||||
import { Slot } from "@radix-ui/react-slot"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const buttonVariants = cva(
|
||||
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
||||
destructive:
|
||||
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
||||
outline:
|
||||
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
||||
secondary:
|
||||
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
||||
ghost: "hover:bg-accent hover:text-accent-foreground",
|
||||
link: "text-primary underline-offset-4 hover:underline",
|
||||
},
|
||||
size: {
|
||||
default: "h-10 px-4 py-2",
|
||||
sm: "h-9 rounded-md px-3",
|
||||
lg: "h-11 rounded-md px-8",
|
||||
icon: "h-10 w-10",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
export interface ButtonProps
|
||||
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
||||
VariantProps<typeof buttonVariants> {
|
||||
asChild?: boolean
|
||||
}
|
||||
|
||||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
({ className, variant, size, asChild = false, ...props }, ref) => {
|
||||
const Comp = asChild ? Slot : "button"
|
||||
return (
|
||||
<Comp
|
||||
className={cn(buttonVariants({ variant, size, className }))}
|
||||
ref={ref}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
)
|
||||
Button.displayName = "Button"
|
||||
|
||||
export { Button, buttonVariants }
|
||||
@@ -0,0 +1,79 @@
|
||||
import * as React from "react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const Card = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.HTMLAttributes<HTMLDivElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"rounded-lg border bg-card text-card-foreground shadow-sm",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
Card.displayName = "Card"
|
||||
|
||||
const CardHeader = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.HTMLAttributes<HTMLDivElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div
|
||||
ref={ref}
|
||||
className={cn("flex flex-col space-y-1.5 p-6", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
CardHeader.displayName = "CardHeader"
|
||||
|
||||
const CardTitle = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.HTMLAttributes<HTMLDivElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"text-2xl font-semibold leading-none tracking-tight",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
CardTitle.displayName = "CardTitle"
|
||||
|
||||
const CardDescription = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.HTMLAttributes<HTMLDivElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div
|
||||
ref={ref}
|
||||
className={cn("text-sm text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
CardDescription.displayName = "CardDescription"
|
||||
|
||||
const CardContent = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.HTMLAttributes<HTMLDivElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
|
||||
))
|
||||
CardContent.displayName = "CardContent"
|
||||
|
||||
const CardFooter = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.HTMLAttributes<HTMLDivElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div
|
||||
ref={ref}
|
||||
className={cn("flex items-center p-6 pt-0", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
CardFooter.displayName = "CardFooter"
|
||||
|
||||
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
import * as React from "react"
|
||||
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { CheckIcon } from "@radix-ui/react-icons"
|
||||
|
||||
const Checkbox = React.forwardRef<
|
||||
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<CheckboxPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<CheckboxPrimitive.Indicator
|
||||
className={cn("flex items-center justify-center text-current")}
|
||||
>
|
||||
<CheckIcon className="h-4 w-4" />
|
||||
</CheckboxPrimitive.Indicator>
|
||||
</CheckboxPrimitive.Root>
|
||||
))
|
||||
Checkbox.displayName = CheckboxPrimitive.Root.displayName
|
||||
|
||||
export { Checkbox }
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
import * as React from "react"
|
||||
import * as DialogPrimitive from "@radix-ui/react-dialog"
|
||||
import { X } from "lucide-react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const Dialog = DialogPrimitive.Root
|
||||
|
||||
const DialogTrigger = DialogPrimitive.Trigger
|
||||
|
||||
const DialogPortal = DialogPrimitive.Portal
|
||||
|
||||
const DialogClose = DialogPrimitive.Close
|
||||
|
||||
const DialogOverlay = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Overlay
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
|
||||
|
||||
const DialogContent = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<DialogPortal>
|
||||
<DialogOverlay />
|
||||
<DialogPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
||||
<X className="h-4 w-4" />
|
||||
<span className="sr-only">Close</span>
|
||||
</DialogPrimitive.Close>
|
||||
</DialogPrimitive.Content>
|
||||
</DialogPortal>
|
||||
))
|
||||
DialogContent.displayName = DialogPrimitive.Content.displayName
|
||||
|
||||
const DialogHeader = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-col space-y-1.5 text-center sm:text-left",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
DialogHeader.displayName = "DialogHeader"
|
||||
|
||||
const DialogFooter = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
DialogFooter.displayName = "DialogFooter"
|
||||
|
||||
const DialogTitle = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Title>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Title
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"text-lg font-semibold leading-none tracking-tight",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DialogTitle.displayName = DialogPrimitive.Title.displayName
|
||||
|
||||
const DialogDescription = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Description>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Description
|
||||
ref={ref}
|
||||
className={cn("text-sm text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DialogDescription.displayName = DialogPrimitive.Description.displayName
|
||||
|
||||
export {
|
||||
Dialog,
|
||||
DialogPortal,
|
||||
DialogOverlay,
|
||||
DialogClose,
|
||||
DialogTrigger,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogFooter,
|
||||
DialogTitle,
|
||||
DialogDescription,
|
||||
}
|
||||
+198
@@ -0,0 +1,198 @@
|
||||
import * as React from "react"
|
||||
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { CheckIcon, ChevronRightIcon, DotFilledIcon } from "@radix-ui/react-icons"
|
||||
|
||||
const DropdownMenu = DropdownMenuPrimitive.Root
|
||||
|
||||
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
|
||||
|
||||
const DropdownMenuGroup = DropdownMenuPrimitive.Group
|
||||
|
||||
const DropdownMenuPortal = DropdownMenuPrimitive.Portal
|
||||
|
||||
const DropdownMenuSub = DropdownMenuPrimitive.Sub
|
||||
|
||||
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
|
||||
|
||||
const DropdownMenuSubTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
||||
inset?: boolean
|
||||
}
|
||||
>(({ className, inset, children, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.SubTrigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
||||
inset && "pl-8",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ChevronRightIcon className="ml-auto" />
|
||||
</DropdownMenuPrimitive.SubTrigger>
|
||||
))
|
||||
DropdownMenuSubTrigger.displayName =
|
||||
DropdownMenuPrimitive.SubTrigger.displayName
|
||||
|
||||
const DropdownMenuSubContent = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.SubContent
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DropdownMenuSubContent.displayName =
|
||||
DropdownMenuPrimitive.SubContent.displayName
|
||||
|
||||
const DropdownMenuContent = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
||||
>(({ className, sideOffset = 4, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Portal>
|
||||
<DropdownMenuPrimitive.Content
|
||||
ref={ref}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
|
||||
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</DropdownMenuPrimitive.Portal>
|
||||
))
|
||||
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
|
||||
|
||||
const DropdownMenuItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
||||
inset?: boolean
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
inset && "pl-8",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
|
||||
|
||||
const DropdownMenuCheckboxItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
|
||||
>(({ className, children, checked, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.CheckboxItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
className
|
||||
)}
|
||||
checked={checked}
|
||||
{...props}
|
||||
>
|
||||
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<DropdownMenuPrimitive.ItemIndicator>
|
||||
<CheckIcon className="h-4 w-4" />
|
||||
</DropdownMenuPrimitive.ItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</DropdownMenuPrimitive.CheckboxItem>
|
||||
))
|
||||
DropdownMenuCheckboxItem.displayName =
|
||||
DropdownMenuPrimitive.CheckboxItem.displayName
|
||||
|
||||
const DropdownMenuRadioItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.RadioItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<DropdownMenuPrimitive.ItemIndicator>
|
||||
<DotFilledIcon className="h-2 w-2 fill-current" />
|
||||
</DropdownMenuPrimitive.ItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</DropdownMenuPrimitive.RadioItem>
|
||||
))
|
||||
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName
|
||||
|
||||
const DropdownMenuLabel = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
||||
inset?: boolean
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Label
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"px-2 py-1.5 text-sm font-semibold",
|
||||
inset && "pl-8",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
|
||||
|
||||
const DropdownMenuSeparator = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Separator
|
||||
ref={ref}
|
||||
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
|
||||
|
||||
const DropdownMenuShortcut = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
||||
return (
|
||||
<span
|
||||
className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
DropdownMenuShortcut.displayName = "DropdownMenuShortcut"
|
||||
|
||||
export {
|
||||
DropdownMenu,
|
||||
DropdownMenuTrigger,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuCheckboxItem,
|
||||
DropdownMenuRadioItem,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuShortcut,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuPortal,
|
||||
DropdownMenuSub,
|
||||
DropdownMenuSubContent,
|
||||
DropdownMenuSubTrigger,
|
||||
DropdownMenuRadioGroup,
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import * as React from "react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
|
||||
({ className, type, ...props }, ref) => {
|
||||
return (
|
||||
<input
|
||||
type={type}
|
||||
className={cn(
|
||||
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
||||
className
|
||||
)}
|
||||
ref={ref}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
)
|
||||
Input.displayName = "Input"
|
||||
|
||||
export { Input }
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import * as React from "react"
|
||||
import * as LabelPrimitive from "@radix-ui/react-label"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const labelVariants = cva(
|
||||
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
||||
)
|
||||
|
||||
const Label = React.forwardRef<
|
||||
React.ElementRef<typeof LabelPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
||||
VariantProps<typeof labelVariants>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<LabelPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(labelVariants(), className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
Label.displayName = LabelPrimitive.Root.displayName
|
||||
|
||||
export { Label }
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
import * as React from "react"
|
||||
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const ScrollArea = React.forwardRef<
|
||||
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<ScrollAreaPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn("relative overflow-hidden", className)}
|
||||
{...props}
|
||||
>
|
||||
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
|
||||
{children}
|
||||
</ScrollAreaPrimitive.Viewport>
|
||||
<ScrollBar />
|
||||
<ScrollAreaPrimitive.Corner />
|
||||
</ScrollAreaPrimitive.Root>
|
||||
))
|
||||
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName
|
||||
|
||||
const ScrollBar = React.forwardRef<
|
||||
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
||||
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||
>(({ className, orientation = "vertical", ...props }, ref) => (
|
||||
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
||||
ref={ref}
|
||||
orientation={orientation}
|
||||
className={cn(
|
||||
"flex touch-none select-none transition-colors",
|
||||
orientation === "vertical" &&
|
||||
"h-full w-2.5 border-l border-l-transparent p-[1px]",
|
||||
orientation === "horizontal" &&
|
||||
"h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
|
||||
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||
))
|
||||
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName
|
||||
|
||||
export { ScrollArea, ScrollBar }
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
import * as React from "react"
|
||||
import * as SelectPrimitive from "@radix-ui/react-select"
|
||||
import { Check, ChevronDown, ChevronUp } from "lucide-react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const Select = SelectPrimitive.Root
|
||||
|
||||
const SelectGroup = SelectPrimitive.Group
|
||||
|
||||
const SelectValue = SelectPrimitive.Value
|
||||
|
||||
const SelectTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<SelectPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<SelectPrimitive.Icon asChild>
|
||||
<ChevronDown className="h-4 w-4 opacity-50" />
|
||||
</SelectPrimitive.Icon>
|
||||
</SelectPrimitive.Trigger>
|
||||
))
|
||||
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
|
||||
|
||||
const SelectScrollUpButton = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SelectPrimitive.ScrollUpButton
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex cursor-default items-center justify-center py-1",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ChevronUp className="h-4 w-4" />
|
||||
</SelectPrimitive.ScrollUpButton>
|
||||
))
|
||||
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName
|
||||
|
||||
const SelectScrollDownButton = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SelectPrimitive.ScrollDownButton
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex cursor-default items-center justify-center py-1",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ChevronDown className="h-4 w-4" />
|
||||
</SelectPrimitive.ScrollDownButton>
|
||||
))
|
||||
SelectScrollDownButton.displayName =
|
||||
SelectPrimitive.ScrollDownButton.displayName
|
||||
|
||||
const SelectContent = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
||||
>(({ className, children, position = "popper", ...props }, ref) => (
|
||||
<SelectPrimitive.Portal>
|
||||
<SelectPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||
position === "popper" &&
|
||||
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
||||
className
|
||||
)}
|
||||
position={position}
|
||||
{...props}
|
||||
>
|
||||
<SelectScrollUpButton />
|
||||
<SelectPrimitive.Viewport
|
||||
className={cn(
|
||||
"p-1",
|
||||
position === "popper" &&
|
||||
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</SelectPrimitive.Viewport>
|
||||
<SelectScrollDownButton />
|
||||
</SelectPrimitive.Content>
|
||||
</SelectPrimitive.Portal>
|
||||
))
|
||||
SelectContent.displayName = SelectPrimitive.Content.displayName
|
||||
|
||||
const SelectLabel = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Label>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SelectPrimitive.Label
|
||||
ref={ref}
|
||||
className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
SelectLabel.displayName = SelectPrimitive.Label.displayName
|
||||
|
||||
const SelectItem = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<SelectPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<SelectPrimitive.ItemIndicator>
|
||||
<Check className="h-4 w-4" />
|
||||
</SelectPrimitive.ItemIndicator>
|
||||
</span>
|
||||
|
||||
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
||||
</SelectPrimitive.Item>
|
||||
))
|
||||
SelectItem.displayName = SelectPrimitive.Item.displayName
|
||||
|
||||
const SelectSeparator = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Separator>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SelectPrimitive.Separator
|
||||
ref={ref}
|
||||
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
SelectSeparator.displayName = SelectPrimitive.Separator.displayName
|
||||
|
||||
export {
|
||||
Select,
|
||||
SelectGroup,
|
||||
SelectValue,
|
||||
SelectTrigger,
|
||||
SelectContent,
|
||||
SelectLabel,
|
||||
SelectItem,
|
||||
SelectSeparator,
|
||||
SelectScrollUpButton,
|
||||
SelectScrollDownButton,
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import * as SeparatorPrimitive from "@radix-ui/react-separator"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const Separator = React.forwardRef<
|
||||
React.ElementRef<typeof SeparatorPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
|
||||
>(
|
||||
(
|
||||
{ className, orientation = "horizontal", decorative = true, ...props },
|
||||
ref
|
||||
) => (
|
||||
<SeparatorPrimitive.Root
|
||||
ref={ref}
|
||||
decorative={decorative}
|
||||
orientation={orientation}
|
||||
className={cn(
|
||||
"shrink-0 bg-border",
|
||||
orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
)
|
||||
Separator.displayName = SeparatorPrimitive.Root.displayName
|
||||
|
||||
export { Separator }
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
import * as React from "react"
|
||||
import * as SheetPrimitive from "@radix-ui/react-dialog"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Cross2Icon } from "@radix-ui/react-icons"
|
||||
|
||||
const Sheet = SheetPrimitive.Root
|
||||
|
||||
const SheetTrigger = SheetPrimitive.Trigger
|
||||
|
||||
const SheetClose = SheetPrimitive.Close
|
||||
|
||||
const SheetPortal = SheetPrimitive.Portal
|
||||
|
||||
const SheetOverlay = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Overlay>,
|
||||
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SheetPrimitive.Overlay
|
||||
className={cn(
|
||||
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
ref={ref}
|
||||
/>
|
||||
))
|
||||
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName
|
||||
|
||||
const sheetVariants = cva(
|
||||
"fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",
|
||||
{
|
||||
variants: {
|
||||
side: {
|
||||
top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
|
||||
bottom:
|
||||
"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
|
||||
left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
|
||||
right:
|
||||
"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
side: "right",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
interface SheetContentProps
|
||||
extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
|
||||
VariantProps<typeof sheetVariants> {}
|
||||
|
||||
const SheetContent = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Content>,
|
||||
SheetContentProps
|
||||
>(({ side = "right", className, children, ...props }, ref) => (
|
||||
<SheetPortal>
|
||||
<SheetOverlay />
|
||||
<SheetPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(sheetVariants({ side }), className)}
|
||||
{...props}
|
||||
>
|
||||
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
|
||||
<Cross2Icon className="h-4 w-4" />
|
||||
<span className="sr-only">Close</span>
|
||||
</SheetPrimitive.Close>
|
||||
{children}
|
||||
</SheetPrimitive.Content>
|
||||
</SheetPortal>
|
||||
))
|
||||
SheetContent.displayName = SheetPrimitive.Content.displayName
|
||||
|
||||
const SheetHeader = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-col space-y-2 text-center sm:text-left",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
SheetHeader.displayName = "SheetHeader"
|
||||
|
||||
const SheetFooter = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
SheetFooter.displayName = "SheetFooter"
|
||||
|
||||
const SheetTitle = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Title>,
|
||||
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SheetPrimitive.Title
|
||||
ref={ref}
|
||||
className={cn("text-lg font-semibold text-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
SheetTitle.displayName = SheetPrimitive.Title.displayName
|
||||
|
||||
const SheetDescription = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Description>,
|
||||
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SheetPrimitive.Description
|
||||
ref={ref}
|
||||
className={cn("text-sm text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
SheetDescription.displayName = SheetPrimitive.Description.displayName
|
||||
|
||||
export {
|
||||
Sheet,
|
||||
SheetPortal,
|
||||
SheetOverlay,
|
||||
SheetTrigger,
|
||||
SheetClose,
|
||||
SheetContent,
|
||||
SheetHeader,
|
||||
SheetFooter,
|
||||
SheetTitle,
|
||||
SheetDescription,
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user