Category fix and movie 0.1
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -9,13 +9,6 @@
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Views\NewFolder\**" />
|
||||
<Content Remove="Views\NewFolder\**" />
|
||||
<EmbeddedResource Remove="Views\NewFolder\**" />
|
||||
<None Remove="Views\NewFolder\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AngularJS.Core" Version="1.8.2" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.67" />
|
||||
|
||||
13
Aberwyn/Controllers/MovieController.cs
Normal file
13
Aberwyn/Controllers/MovieController.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Aberwyn.Controllers
|
||||
{
|
||||
public class MovieController : Controller
|
||||
{
|
||||
[HttpGet("/movie/search")]
|
||||
public IActionResult Search()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Aberwyn/Models/MediaModels.cs
Normal file
33
Aberwyn/Models/MediaModels.cs
Normal 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; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
43
Aberwyn/Views/Movie/Search.cshtml
Normal file
43
Aberwyn/Views/Movie/Search.cshtml
Normal 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>
|
||||
}
|
||||
@@ -557,14 +557,13 @@ app.controller('BudgetController', function ($scope, $http) {
|
||||
};
|
||||
$scope.createNewCategory = function () {
|
||||
const defaultName = "Ny kategori";
|
||||
const newOrder = $scope.budget.categories.length; // sist i listan
|
||||
const newOrder = $scope.budget.categories.length;
|
||||
|
||||
const newCategory = {
|
||||
name: defaultName,
|
||||
color: "#666666",
|
||||
year: $scope.selectedYear,
|
||||
month: $scope.selectedMonth,
|
||||
order: newOrder
|
||||
order: newOrder,
|
||||
budgetPeriodId: $scope.budget.id // <- 💡 den viktiga raden
|
||||
};
|
||||
|
||||
$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.addItem = function (category) {
|
||||
if (!category.newItemName || !category.newItemAmount) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user