Add PNG icon support for shift types (#18)

* Initial plan

* Add PNG icon support for shifts with sample coffee cup icon

Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com>

* Add more icons

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com>
Co-authored-by: Claudio Schaad <c.schaad@pog.ch>
This commit is contained in:
Copilot 2025-08-21 23:09:45 +02:00 committed by GitHub
parent d26b3319b9
commit a25d8f1cc2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 67 additions and 18 deletions

View file

@ -39,9 +39,16 @@ else
<span class="loading-spinner">⏳</span> <span class="loading-spinner">⏳</span>
} }
else else
{
@if (shift.IsPngIcon)
{
<img src="icons\@shift.Icon" alt="@shift.Name" style="width: 24px; height: 24px;" />
}
else
{ {
@shift.Icon @shift.Icon
} }
}
</button> </button>
<span class="tooltip">@shift.Name</span> <span class="tooltip">@shift.Name</span>
</div> </div>

View file

@ -16,4 +16,31 @@
<ProjectReference Include="..\Services\ShiftScheduler.Services.csproj" /> <ProjectReference Include="..\Services\ShiftScheduler.Services.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Update="wwwroot\break-icon.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\icons\break-icon.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\icons\G2.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\icons\Bg.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\icons\F1.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\icons\G1.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\icons\G2TS.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\icons\Kompensation.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project> </Project>

BIN
Client/wwwroot/icons/Bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
Client/wwwroot/icons/F1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
Client/wwwroot/icons/G1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
Client/wwwroot/icons/G2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

View file

@ -28,6 +28,12 @@
"MorningTime": "", "MorningTime": "",
"AfternoonTime": "" "AfternoonTime": ""
}, },
{
"Name": "Pause",
"Icon": "break-icon.png",
"MorningTime": "10:00-10:15",
"AfternoonTime": "15:00-15:15"
},
{ {
"Name": "Früh", "Name": "Früh",
"Icon": "🌅", "Icon": "🌅",

View file

@ -98,20 +98,27 @@ namespace ShiftScheduler.Services
foreach (var day in Enumerable.Range(0, dayInWeek)) foreach (var day in Enumerable.Range(0, dayInWeek))
{ {
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day)); var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
var icon = shiftWithTransport?.Shift.Icon ?? ""; var shift = shiftWithTransport?.Shift;
if (shift != null && shift.IsPngIcon)
{
// For PNG icons, embed the image
var iconPath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "icons", shift.Icon);
if (File.Exists(iconPath))
{
table.Cell().Height(24).Element(CellStyleMiddle).Image(iconPath).FitArea();
}
else
{
table.Cell().Element(CellStyleMiddle).Text(shift.Name);
}
}
else
{
// For text/emoji icons, render as text
var icon = shift?.Icon ?? shift?.Name;
table.Cell().Element(CellStyleMiddle).Text(icon); table.Cell().Element(CellStyleMiddle).Text(icon);
} }
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
{
RenderEmptyCell(table);
}
// Shifname
foreach (var day in Enumerable.Range(0, dayInWeek))
{
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
var shiftName = shiftWithTransport?.Shift.Name ?? "";
table.Cell().Element(CellStyleMiddle).Text(shiftName);
} }
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek)) foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
{ {
@ -122,7 +129,7 @@ namespace ShiftScheduler.Services
foreach (var day in Enumerable.Range(0, dayInWeek)) foreach (var day in Enumerable.Range(0, dayInWeek))
{ {
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day)); var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
var morningTime = $"🌅 {shiftWithTransport?.Shift.MorningTime}"; var morningTime = shiftWithTransport?.Shift.MorningTime.Length > 0 ? $"🌅 {shiftWithTransport?.Shift.MorningTime}" : "";
table.Cell().Element(CellStyleMiddle).Text(morningTime); table.Cell().Element(CellStyleMiddle).Text(morningTime);
} }
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek)) foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
@ -134,7 +141,7 @@ namespace ShiftScheduler.Services
foreach (var day in Enumerable.Range(0, dayInWeek)) foreach (var day in Enumerable.Range(0, dayInWeek))
{ {
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day)); var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
var afternoonTime = $"🌆 {shiftWithTransport?.Shift.AfternoonTime}"; var afternoonTime = shiftWithTransport?.Shift.AfternoonTime.Length > 0 ? $"🌆 {shiftWithTransport?.Shift.AfternoonTime}" : "";
table.Cell().Element(CellStyleMiddle).Text(afternoonTime); table.Cell().Element(CellStyleMiddle).Text(afternoonTime);
} }
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek)) foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
@ -181,7 +188,7 @@ namespace ShiftScheduler.Services
transportLines.Add(afternoonInfo); transportLines.Add(afternoonInfo);
} }
return transportLines.Count > 0 ? string.Join("\n", transportLines) : "-"; return transportLines.Count > 0 ? string.Join("\n", transportLines) : "";
} }
private static string FormatTransportConnection(TransportConnection transport) private static string FormatTransportConnection(TransportConnection transport)

View file

@ -6,5 +6,7 @@ namespace ShiftScheduler.Shared.Models
public string Icon { get; set; } = string.Empty; public string Icon { get; set; } = string.Empty;
public string MorningTime { get; set; } = string.Empty; public string MorningTime { get; set; } = string.Empty;
public string AfternoonTime { get; set; } = string.Empty; public string AfternoonTime { get; set; } = string.Empty;
public bool IsPngIcon => Icon.EndsWith(".png", StringComparison.OrdinalIgnoreCase);
} }
} }