Files
constructdemo/ConstructorAppUI/Views/ProjectGallery/Index.cshtml
2025-05-01 15:18:30 +03:00

59 lines
2.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@model List<ResultProjectGalleryDto>
@using Microsoft.AspNetCore.Mvc.Rendering
@{
ViewData["Title"] = "Index";
Layout = "~/Views/AdminLayout/Index.cshtml";
var apiBaseUrl = ViewData["ApiBaseUrl"] as string;
}
<h3>Projeye Ait Galeri Görselleri</h3>
<a href="/ProjectGallery/CreateProjectGallery/" class="btn btn-outline-primary">Yeni Ekle</a>
<form asp-action="Index" method="get">
<div class="form-group mb-3">
<label>Proje Seçiniz:</label>
<select id="projectSelect" class="form-control">
<option value="">-- Proje Seçin --</option>
@foreach (SelectListItem project in ViewBag.ProjectList)
{
<option value="@project.Value">@project.Text</option>
}
</select>
</div>
</form>
<!-- Image List -->
<div id="imageListContainer" style="display: flex; flex-wrap: wrap; gap: 20px; margin-top: 20px;">
<!-- Görseller JavaScript ile burada yüklenecek -->
</div>
<script>
document.getElementById("projectSelect").addEventListener("change", function () {
var projectId = this.value;
if (projectId && '@apiBaseUrl') {
fetch(`@apiBaseUrl/api/ProjectGallery/GetByProjectId/${projectId}`)
.then(res => res.json())
.then(data => {
let container = document.getElementById("imageListContainer");
container.innerHTML = ""; // Mevcut içeriği temizle
if (data.length === 0) {
container.innerHTML = "<p>Bu projeye ait galeri bulunamadı.</p>";
return;
}
// Görselleri liste olarak ekle
data.forEach(item => {
let imageElement = document.createElement("img");
imageElement.src = item.imageUrl;
imageElement.alt = "Project Image";
imageElement.style = "width: 100%; max-width: 300px; height: auto; object-fit: cover;";
container.appendChild(imageElement); // Görseli listeye ekle
});
});
}
});
</script>