Category fix and movie 0.1
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Elias Jansson
2025-07-24 10:59:33 +02:00
parent cc96802637
commit 4b8c54d38d
5 changed files with 94 additions and 11 deletions

View File

@@ -9,13 +9,6 @@
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Remove="Views\NewFolder\**" />
<Content Remove="Views\NewFolder\**" />
<EmbeddedResource Remove="Views\NewFolder\**" />
<None Remove="Views\NewFolder\**" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AngularJS.Core" Version="1.8.2" /> <PackageReference Include="AngularJS.Core" Version="1.8.2" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.67" /> <PackageReference Include="HtmlAgilityPack" Version="1.11.67" />

View File

@@ -0,0 +1,13 @@
using Microsoft.AspNetCore.Mvc;
namespace Aberwyn.Controllers
{
public class MovieController : Controller
{
[HttpGet("/movie/search")]
public IActionResult Search()
{
return View();
}
}
}

View File

@@ -0,0 +1,33 @@
namespace Aberwyn.Models
{
public class StreamingService
{
public int Id { get; set; }
public string Name { get; set; } // T.ex. "Netflix", "Plex"
}
public class MediaItem
{
public int Id { get; set; }
public string TmdbId { get; set; } // TMDb ID
public string Title { get; set; }
public string Overview { get; set; }
public string PosterPath { get; set; }
public string MediaType { get; set; } // "movie" eller "tv"
public double Rating { get; set; }
public DateTime? ReleaseDate { get; set; }
public List<MediaItemStreamingService> MediaItemStreamingServices { get; set; } = new();
}
public class MediaItemStreamingService
{
public int MediaItemId { get; set; }
public MediaItem MediaItem { get; set; }
public int StreamingServiceId { get; set; }
public StreamingService StreamingService { get; set; }
}
}

View File

@@ -0,0 +1,43 @@
@{
ViewData["Title"] = "Filmsök";
}
<div class="container mt-4">
<h2>🎬 Filmsök</h2>
<input type="text" class="form-control mb-3" id="searchInput" placeholder="Sök efter en film..." oninput="searchMovie()" />
<div class="results row" id="results"></div>
</div>
@section Scripts {
<script>
const API_KEY = 'aef2f49296b77b9b9c269678d04bdbc6';
const BASE_URL = 'https://api.themoviedb.org/3';
const IMG_BASE = 'https://image.tmdb.org/t/p/w300';
async function searchMovie() {
const query = document.getElementById('searchInput').value.trim();
const resultContainer = document.getElementById('results');
resultContainer.innerHTML = '';
if (query.length < 2) return;
const res = await fetch(`${BASE_URL}/search/movie?api_key=${API_KEY}&language=sv-SE&query=${encodeURIComponent(query)}`);
const data = await res.json();
data.results.forEach(movie => {
const col = document.createElement('div');
col.className = 'col-md-3 mb-4';
col.innerHTML = `
<div class="card h-100 bg-dark text-white border-0 shadow">
<img src="${movie.poster_path ? IMG_BASE + movie.poster_path : 'https://via.placeholder.com/300x450?text=Ingen+bild'}" class="card-img-top" alt="${movie.title}" />
<div class="card-body">
<h5 class="card-title">${movie.title}</h5>
<p class="card-text"><small>${movie.release_date || 'Okänt datum'}</small></p>
</div>
</div>
`;
resultContainer.appendChild(col);
});
}
</script>
}

View File

@@ -557,14 +557,13 @@ app.controller('BudgetController', function ($scope, $http) {
}; };
$scope.createNewCategory = function () { $scope.createNewCategory = function () {
const defaultName = "Ny kategori"; const defaultName = "Ny kategori";
const newOrder = $scope.budget.categories.length; // sist i listan const newOrder = $scope.budget.categories.length;
const newCategory = { const newCategory = {
name: defaultName, name: defaultName,
color: "#666666", color: "#666666",
year: $scope.selectedYear, order: newOrder,
month: $scope.selectedMonth, budgetPeriodId: $scope.budget.id // <- 💡 den viktiga raden
order: newOrder
}; };
$http.post("/api/budget/category", newCategory) $http.post("/api/budget/category", newCategory)
@@ -589,6 +588,8 @@ app.controller('BudgetController', function ($scope, $http) {
$scope.showToast("Fel vid skapande av kategori", true); $scope.showToast("Fel vid skapande av kategori", true);
}); });
}; };
$scope.addItem = function (category) { $scope.addItem = function (category) {
if (!category.newItemName || !category.newItemAmount) return; if (!category.newItemName || !category.newItemAmount) return;