Merge branch 'main' into Hargata/reminders

# Conflicts:
#	Controllers/HomeController.cs
This commit is contained in:
DESKTOP-GENO133\IvanPlex 2024-01-07 08:45:32 -07:00
commit f805e311b0
15 changed files with 115 additions and 35 deletions

2
.env Normal file
View File

@ -0,0 +1,2 @@
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8

19
.github/workflows/docker-image.yml vendored Normal file
View File

@ -0,0 +1,19 @@
name: Docker Image CI
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build and push the Docker image
run: |
docker login -u "hargata" -p "${{ secrets.GHCR_PAT }}" ghcr.io
docker build . --file Dockerfile --tag ghcr.io/hargata/lubelogger:latest
docker push ghcr.io/hargata/lubelogger:latest

View File

@ -55,6 +55,11 @@ namespace CarCareTracker.Controllers
{
try
{
if (!System.IO.File.Exists(StaticHelper.UserConfigPath))
{
//if file doesn't exist it might be because it's running on a mounted volume in docker.
System.IO.File.WriteAllText(StaticHelper.UserConfigPath, System.Text.Json.JsonSerializer.Serialize(new UserConfig()));
}
var configFileContents = System.IO.File.ReadAllText(StaticHelper.UserConfigPath);
var existingUserConfig = System.Text.Json.JsonSerializer.Deserialize<UserConfig>(configFileContents);
if (existingUserConfig is not null)

View File

@ -545,13 +545,23 @@ namespace CarCareTracker.Controllers
#region "Reminders"
private int GetMaxMileage(int vehicleId)
{
var numbersArray = new List<int>
var numbersArray = new List<int>();
var serviceRecords = _serviceRecordDataAccess.GetServiceRecordsByVehicleId(vehicleId);
if (serviceRecords.Any())
{
_serviceRecordDataAccess.GetServiceRecordsByVehicleId(vehicleId).Max(x => x.Mileage),
_collisionRecordDataAccess.GetCollisionRecordsByVehicleId(vehicleId).Max(x => x.Mileage),
_gasRecordDataAccess.GetGasRecordsByVehicleId(vehicleId).Max(x => x.Mileage)
};
return numbersArray.Max();
numbersArray.Add(serviceRecords.Max(x => x.Mileage));
}
var repairRecords = _collisionRecordDataAccess.GetCollisionRecordsByVehicleId(vehicleId);
if (repairRecords.Any())
{
numbersArray.Add(repairRecords.Max(x => x.Mileage));
}
var gasRecords = _gasRecordDataAccess.GetGasRecordsByVehicleId(vehicleId);
if (gasRecords.Any())
{
numbersArray.Add(gasRecords.Max(x => x.Mileage));
}
return numbersArray.Any() ? numbersArray.Max() : 0;
}
private List<ReminderRecordViewModel> GetRemindersAndUrgency(int vehicleId)
{
@ -567,7 +577,8 @@ namespace CarCareTracker.Controllers
Date = reminder.Date,
Mileage = reminder.Mileage,
Description = reminder.Description,
Notes = reminder.Notes
Notes = reminder.Notes,
Metric = reminder.Metric
};
if (reminder.Metric == ReminderMetric.Both)
{
@ -646,7 +657,9 @@ namespace CarCareTracker.Controllers
Date = result.Date.ToShortDateString(),
Description = result.Description,
Notes = result.Notes,
VehicleId = result.VehicleId
VehicleId = result.VehicleId,
Mileage = result.Mileage,
Metric = result.Metric
};
return PartialView("_ReminderRecordModal", convertedResult);
}

View File

@ -9,6 +9,4 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /App
COPY --from=build-env /App/out .
EXPOSE 8080
ENV LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8
CMD ["./CarCareTracker"]

View File

@ -9,6 +9,13 @@
public string Description { get; set; }
public string Notes { get; set; }
public ReminderMetric Metric { get; set; } = ReminderMetric.Date;
public ReminderRecord ToReminderRecord() { return new ReminderRecord { Id = Id, VehicleId = VehicleId, Date = DateTime.Parse(Date), Mileage = Mileage, Description = Description, Notes = Notes }; }
public ReminderRecord ToReminderRecord() { return new ReminderRecord {
Id = Id,
VehicleId = VehicleId,
Date = DateTime.Parse(Date),
Mileage = Mileage,
Description = Description,
Metric = Metric,
Notes = Notes }; }
}
}

View File

@ -3,6 +3,16 @@
@{
var useDarkMode = bool.Parse(Configuration["UseDarkMode"]);
var enableCsvImports = bool.Parse(Configuration["EnableCsvImports"]);
var shortDatePattern = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
shortDatePattern = shortDatePattern.ToLower();
if (!shortDatePattern.Contains("dd"))
{
shortDatePattern = shortDatePattern.Replace("d", "dd");
}
if (!shortDatePattern.Contains("mm"))
{
shortDatePattern = shortDatePattern.Replace("m", "mm");
}
}
<html lang="en" data-bs-theme="@(useDarkMode ? "dark" : "light")">
<head>
@ -28,6 +38,11 @@
enableCsvImport : "@enableCsvImports" == "True"
}
}
function getShortDatePattern() {
return {
pattern: "@shortDatePattern"
}
}
</script>
@await RenderSectionAsync("Scripts", required: false)
</head>

View File

@ -27,7 +27,7 @@
<span class="ms-2 badge bg-primary">@($"Max Fuel Economy: {Model.Max(x => x.MilesPerGallon).ToString("F") ?? "0"}")</span>
}
<span class="ms-2 badge bg-success">@($"Total Fuel Consumed: {Model.Sum(x=>x.Gallons).ToString("F")}")</span>
<span class="ms-2 badge bg-success">@($"Total Cost: {Model.Sum(x => x.Cost).ToString("C")}")</span>
<span class="ms-2 badge bg-success">@($"Total Cost: {Model.Sum(x => x.Cost).ToString("C3")}")</span>
</div>
@if (enableCsvImports)
{
@ -66,8 +66,8 @@
<td class="col-2">@gasRecord.Mileage</td>
<td class="col-2">@gasRecord.Gallons.ToString("F")</td>
<td class="col-4">@(gasRecord.MilesPerGallon == 0 ? "---" : gasRecord.MilesPerGallon.ToString("F"))</td>
<td class="col-1">@gasRecord.Cost.ToString("C")</td>
<td class="col-1">@gasRecord.CostPerGallon.ToString("C")</td>
<td class="col-1">@gasRecord.Cost.ToString("C3")</td>
<td class="col-1">@gasRecord.CostPerGallon.ToString("C3")</td>
</tr>
}
</tbody>

View File

@ -5,7 +5,7 @@
<span class="ms-2 badge bg-success">@($"# of Reminders: {Model.Count()}")</span>
</div>
<div>
<button onclick="showAddReminderModal()" class="btn btn-primary btn-md mt-1 mb-1"><i class="bi bi-pencil-square me-2"></i>Add Repair Record</button>
<button onclick="showAddReminderModal()" class="btn btn-primary btn-md mt-1 mb-1"><i class="bi bi-pencil-square me-2"></i>Add Reminder</button>
</div>
</div>
</div>
@ -16,25 +16,34 @@
<tr class="d-flex">
<th scope="col" class="col-1">Urgency</th>
<th scope="col" class="col-2">Metric</th>
<th scope="col" class="col-4">Description</th>
<th scope="col" class="col-2">Cost</th>
<th scope="col" class="col-3">Notes</th>
<th scope="col" class="col-5">Description</th>
<th scope="col" class="col-4">Notes</th>
</tr>
</thead>
<tbody>
@foreach (ReminderRecordViewModel reminderRecord in Model)
{
<tr class="d-flex" style="cursor:pointer;" onclick="showEditReminderRecordModal(@reminderRecord.Id)">
<td class="col-1">@reminderRecord.Urgency.ToString()</td>
@if (reminderRecord.Urgency == ReminderUrgency.VeryUrgent)
{
<td class="col-1"><span class="badge text-bg-danger">Very Urgent</span></td>
}
else if (reminderRecord.Urgency == ReminderUrgency.Urgent){
<td class="col-1"><span class="badge text-bg-warning">Urgent</span></td>
} else {
<td class="col-1"><span class="badge text-bg-success">Not Urgent</span></td>
}
@if (reminderRecord.Metric == ReminderMetric.Date)
{
<td class="col-1">@reminderRecord.Date.ToShortDateString()</td>
<td class="col-2">@reminderRecord.Date.ToShortDateString()</td>
} else if (reminderRecord.Metric == ReminderMetric.Odometer)
{
<td class="col-1">@reminderRecord.Mileage</td>
<td class="col-2">@reminderRecord.Mileage</td>
} else {
<td class="col-2">@reminderRecord.Metric</td>
}
<td class="col-4">@reminderRecord.Description</td>
<td class="col-3 text-truncate">@reminderRecord.Notes</td>
<td class="col-5">@reminderRecord.Description</td>
<td class="col-4 text-truncate">@reminderRecord.Notes</td>
</tr>
}
</tbody>

View File

@ -3,7 +3,7 @@ version: "3.4"
services:
app:
image: hargata/lubelog:latest
image: ghcr.io/hargata/lubelogger:latest
build: .
restart: unless-stopped
# volumes used to keep data persistent
@ -16,6 +16,8 @@ services:
# expose port and/or use serving via traefik
ports:
- 8080:8080
env_file:
- .env
# traefik configurations, including networks can be commented out if not needed
networks:
- traefik-ingress

View File

@ -3,7 +3,7 @@ version: "3.4"
services:
app:
image: hargata/lubelog:latest
image: ghcr.io/hargata/lubelogger:latest
build: .
restart: unless-stopped
# volumes used to keep data persistent
@ -16,6 +16,8 @@ services:
# expose port and/or use serving via traefik
ports:
- 8080:8080
env_file:
- .env
volumes:
config:

View File

@ -4,7 +4,8 @@
$("#collisionRecordModalContent").html(data);
//initiate datepicker
$('#collisionRecordDate').datepicker({
endDate: "+0d"
endDate: "+0d",
format: getShortDatePattern().pattern
});
$('#collisionRecordModal').modal('show');
}
@ -16,7 +17,8 @@ function showEditCollisionRecordModal(collisionRecordId) {
$("#collisionRecordModalContent").html(data);
//initiate datepicker
$('#collisionRecordDate').datepicker({
endDate: "+0d"
endDate: "+0d",
format: getShortDatePattern().pattern
});
$('#collisionRecordModal').modal('show');
}

View File

@ -4,7 +4,8 @@
$("#gasRecordModalContent").html(data);
//initiate datepicker
$('#gasRecordDate').datepicker({
endDate: "+0d"
endDate: "+0d",
format: getShortDatePattern().pattern
});
$('#gasRecordModal').modal('show');
}
@ -16,7 +17,8 @@ function showEditGasRecordModal(gasRecordId) {
$("#gasRecordModalContent").html(data);
//initiate datepicker
$('#gasRecordDate').datepicker({
endDate: "+0d"
endDate: "+0d",
format: getShortDatePattern().pattern
});
$('#gasRecordModal').modal('show');
}

View File

@ -4,7 +4,8 @@
$("#serviceRecordModalContent").html(data);
//initiate datepicker
$('#serviceRecordDate').datepicker({
endDate: "+0d"
endDate: "+0d",
format: getShortDatePattern().pattern
});
$('#serviceRecordModal').modal('show');
}
@ -16,7 +17,8 @@ function showEditServiceRecordModal(serviceRecordId) {
$("#serviceRecordModalContent").html(data);
//initiate datepicker
$('#serviceRecordDate').datepicker({
endDate: "+0d"
endDate: "+0d",
format: getShortDatePattern().pattern
});
$('#serviceRecordModal').modal('show');
}

View File

@ -4,7 +4,8 @@
$("#taxRecordModalContent").html(data);
//initiate datepicker
$('#taxRecordDate').datepicker({
endDate: "+0d"
endDate: "+0d",
format: getShortDatePattern().pattern
});
$('#taxRecordModal').modal('show');
}
@ -16,7 +17,8 @@ function showEditTaxRecordModal(taxRecordId) {
$("#taxRecordModalContent").html(data);
//initiate datepicker
$('#taxRecordDate').datepicker({
endDate: "+0d"
endDate: "+0d",
format: getShortDatePattern().pattern
});
$('#taxRecordModal').modal('show');
}