Skip to content

Commit

Permalink
♻️ Disable share link button when generating, add descriptive page ti…
Browse files Browse the repository at this point in the history
…tle to shared links, try change website link preview
  • Loading branch information
russkyc committed Feb 17, 2024
1 parent a83935b commit da0cd92
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ConflictResolver/Pages/Home.razor
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
</MudDataGrid>
</MudItem>
<MudItem xs="12" Class="flex flex-col">
<MudButton OnClick="@OnShareSchedule" StartIcon="@Icons.Material.Rounded.Link" Class="mx-4 mb-4" DisableElevation="true" Variant="Variant.Filled" Color="Color.Primary">
<MudButton Disabled="@_isGeneratingShareLink" OnClick="@OnShareSchedule" StartIcon="@Icons.Material.Rounded.Link" Class="mx-4 mb-4" DisableElevation="true" Variant="Variant.Filled" Color="Color.Primary">
Copy Share Link
</MudButton>
</MudItem>
Expand All @@ -199,6 +199,8 @@
private IEnumerable<string>? _selectedCourses;
private List<CourseSchedule> _recommendedSchedules = new();

private bool _isGeneratingShareLink = false;

protected override async Task OnInitializedAsync()
{
var courses = await ScheduleRepository.GetSchedulesAsync();
Expand Down Expand Up @@ -274,13 +276,17 @@

private async Task OnShareSchedule()
{
_isGeneratingShareLink = true;
var schedules = _courses.Select(course => course.Course);
var recommendedSchedules = _recommendedSchedules.Select(course => course.Course);
var recommendedBlocks = _recommendedSchedules.Select(course => course.Block);
var sharingUrl = $"{NavigationManager.BaseUri}resolve?blocks={_selectedBlocks.SerializeAndEscape()}&recommendedBlocks={recommendedBlocks.SerializeAndEscape()}&courses={schedules.SerializeAndEscape()}&alternatives={recommendedSchedules.SerializeAndEscape()}";

await ClipboardHandler.CopyTextToClipboardAsync(sharingUrl);
await Task.Delay(500);

Snackbar.Add("Sharing link has been copied to clipboard", Severity.Success);
_isGeneratingShareLink = false;
}

}
4 changes: 4 additions & 0 deletions ConflictResolver/Pages/Resolve.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
@inject NavigationManager NavigationManager
@inject ScheduleRepository ScheduleRepository

<PageTitle>@_pageTitle</PageTitle>

<MudStack Class="flex my-8" Spacing="8">
<MudPaper Class="rounded-lg">
<MudGrid>
Expand Down Expand Up @@ -157,6 +159,7 @@
[SupplyParameterFromQuery(Name = "alternatives")]
public string? AlternativeData { get; set; }

private string? _pageTitle;
private IEnumerable<CourseSchedule>? _courses { get; set; }
private IEnumerable<CourseSchedule>? _alternatives { get; set; }

Expand All @@ -168,6 +171,7 @@
var alternatives = AlternativeData.DeserializeAndUnescape<IEnumerable<string>>();
var alternativeSchedules = await ScheduleRepository.GetSchedulesByCourseCodeAsync(blocks: recommendedBlocks, courses: alternatives);

_pageTitle = $"Resolv - Schedule Alternatives for {string.Join(", ",alternatives.Distinct())}";
_courses = await ScheduleRepository.GetSchedulesByCourseCodeAsync(blocks: blocks, courses: courses, conflicts: true);

_alternatives = alternativeSchedules
Expand Down
Binary file added ConflictResolver/wwwroot/images/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ConflictResolver/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
<script src="scripts/tailwind-341.js"></script>
<meta property="og:image" content="images/preview.png">
</head>

<body class="bg-[#32333d]">
Expand Down

0 comments on commit da0cd92

Please sign in to comment.