This commit is contained in:
Flatlogic Bot 2026-02-06 12:46:15 +00:00
parent bee008077f
commit 1dad47dada
24 changed files with 736 additions and 169 deletions

View File

@ -151,7 +151,6 @@ STATIC_ROOT = BASE_DIR / 'staticfiles'
STATICFILES_DIRS = [
BASE_DIR / 'static',
BASE_DIR / 'assets',
BASE_DIR / 'node_modules',
]
@ -179,4 +178,4 @@ if EMAIL_USE_SSL:
# Default primary key field type
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +1,7 @@
from django.contrib import admin
from .models import ServiceSetting
# Register your models here.
@admin.register(ServiceSetting)
class ServiceSettingAdmin(admin.ModelAdmin):
list_display = ('name', 'url', 'is_active')
list_editable = ('is_active',)

121
core/api_clients.py Normal file
View File

@ -0,0 +1,121 @@
import requests
from .models import ServiceSetting
class BaseClient:
def __init__(self, name):
try:
self.setting = ServiceSetting.objects.get(name=name, is_active=True)
self.url = self.setting.url.rstrip('/')
self.api_key = self.setting.api_key
except ServiceSetting.DoesNotExist:
self.setting = None
self.url = None
self.api_key = None
def is_configured(self):
return self.url and self.api_key
class JellyfinClient(BaseClient):
def __init__(self):
super().__init__('jellyfin')
def get_info(self):
if not self.is_configured(): return None
try:
headers = {'X-Emby-Token': self.api_key}
resp = requests.get(f"{self.url}/System/Info", headers=headers, timeout=5)
if resp.status_code == 200:
return resp.json()
except:
pass
return None
def get_recent_items(self, limit=5):
if not self.is_configured(): return []
try:
headers = {'X-Emby-Token': self.api_key}
# Get latest media
resp = requests.get(f"{self.url}/Users/Public/Items/Latest?Limit={limit}", headers=headers, timeout=5)
if resp.status_code == 200:
return resp.json()
except:
pass
return []
class RadarrClient(BaseClient):
def __init__(self):
super().__init__('radarr')
def get_status(self):
if not self.is_configured(): return None
try:
params = {'apikey': self.api_key}
resp = requests.get(f"{self.url}/api/v3/system/status", params=params, timeout=5)
if resp.status_code == 200:
return resp.json()
except:
pass
return None
def get_queue(self):
if not self.is_configured(): return []
try:
params = {'apikey': self.api_key}
resp = requests.get(f"{self.url}/api/v3/queue", params=params, timeout=5)
if resp.status_code == 200:
return resp.json().get('records', [])
except:
pass
return []
class SonarrClient(BaseClient):
def __init__(self):
super().__init__('sonarr')
def get_status(self):
if not self.is_configured(): return None
try:
params = {'apikey': self.api_key}
resp = requests.get(f"{self.url}/api/v3/system/status", params=params, timeout=5)
if resp.status_code == 200:
return resp.json()
except:
pass
return None
def get_queue(self):
if not self.is_configured(): return []
try:
params = {'apikey': self.api_key}
resp = requests.get(f"{self.url}/api/v3/queue", params=params, timeout=5)
if resp.status_code == 200:
return resp.json().get('records', [])
except:
pass
return []
class JellyseerrClient(BaseClient):
def __init__(self):
super().__init__('jellyseerr')
def get_status(self):
if not self.is_configured(): return None
try:
headers = {'X-Api-Key': self.api_key}
resp = requests.get(f"{self.url}/api/v1/status", headers=headers, timeout=5)
if resp.status_code == 200:
return resp.json()
except:
pass
return None
def get_requests(self, count=5):
if not self.is_configured(): return []
try:
headers = {'X-Api-Key': self.api_key}
resp = requests.get(f"{self.url}/api/v1/request?take={count}&skip=0&filter=all", headers=headers, timeout=5)
if resp.status_code == 200:
return resp.json().get('results', [])
except:
pass
return []

View File

@ -0,0 +1,24 @@
# Generated by Django 5.2.7 on 2026-02-06 12:34
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='ServiceSetting',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(choices=[('jellyfin', 'Jellyfin'), ('radarr', 'Radarr'), ('sonarr', 'Sonarr'), ('jellyseerr', 'Jellyseerr')], max_length=50, unique=True)),
('url', models.URLField(help_text='Base URL of the service (e.g., http://192.168.1.100:8096)')),
('api_key', models.CharField(blank=True, help_text='API Key or Token for the service', max_length=255, null=True)),
('is_active', models.BooleanField(default=True)),
],
),
]

View File

@ -1,3 +1,17 @@
from django.db import models
# Create your models here.
class ServiceSetting(models.Model):
SERVICE_CHOICES = [
('jellyfin', 'Jellyfin'),
('radarr', 'Radarr'),
('sonarr', 'Sonarr'),
('jellyseerr', 'Jellyseerr'),
]
name = models.CharField(max_length=50, choices=SERVICE_CHOICES, unique=True)
url = models.URLField(help_text="Base URL of the service (e.g., http://192.168.1.100:8096)")
api_key = models.CharField(max_length=255, blank=True, null=True, help_text="API Key or Token for the service")
is_active = models.BooleanField(default=True)
def __str__(self):
return self.get_name_display()

View File

@ -1,25 +1,130 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" data-bs-theme="dark">
<head>
<meta charset="UTF-8">
<title>{% block title %}Knowledge Base{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}Matzeflix Dashboard{% endblock %}</title>
<link rel="manifest" href="{% static 'manifest.json' %}">
<meta name="theme-color" content="#e50914">
{% if project_description %}
<meta name="description" content="{{ project_description }}">
<meta property="og:description" content="{{ project_description }}">
<meta property="twitter:description" content="{{ project_description }}">
{% endif %}
{% if project_image_url %}
<meta property="og:image" content="{{ project_image_url }}">
<meta property="twitter:image" content="{{ project_image_url }}">
{% endif %}
{% load static %}
<link rel="stylesheet" href="{% static 'css/custom.css' %}?v={{ deployment_timestamp }}">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<style>
:root {
--primary-red: #e50914;
--bg-dark: #141414;
--card-bg: #1f1f1f;
}
body {
background-color: var(--bg-dark);
color: #fff;
font-family: 'Inter', sans-serif;
-webkit-font-smoothing: antialiased;
}
.navbar {
background-color: rgba(0, 0, 0, 0.8);
backdrop-filter: blur(10px);
border-bottom: 1px solid #333;
padding: 1rem 0;
}
.navbar-brand {
letter-spacing: 2px;
font-weight: 800;
color: var(--primary-red) !important;
}
.nav-link {
font-weight: 600;
text-transform: uppercase;
font-size: 0.85rem;
letter-spacing: 1px;
}
.card {
background-color: var(--card-bg);
border: 1px solid #333;
}
.btn-primary {
background-color: var(--primary-red);
border-color: var(--primary-red);
font-weight: 600;
}
.btn-primary:hover {
background-color: #b20710;
border-color: #b20710;
}
.footer {
padding: 3rem 0;
margin-top: 5rem;
border-top: 1px solid #333;
color: #666;
}
::-webkit-scrollbar {
width: 10px;
}
::-webkit-scrollbar-track {
background: #141414;
}
::-webkit-scrollbar-thumb {
background: #333;
border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
background: #444;
}
</style>
{% block head %}{% endblock %}
</head>
<body>
{% block content %}{% endblock %}
<nav class="navbar navbar-expand-lg navbar-dark sticky-top">
<div class="container">
<a class="navbar-brand" href="{% url 'home' %}">
MATZEFLIX
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link" href="{% url 'home' %}">Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'settings' %}">Settings</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/admin/">Admin Portal</a>
</li>
</ul>
</div>
</div>
</nav>
<main class="container py-4">
{% block content %}{% endblock %}
</main>
<footer class="footer">
<div class="container text-center">
<p class="mb-0">&copy; 2026 Matzeflix Dashboard. All rights reserved.</p>
<small>Powered by Django & Matzeflix Media Engine</small>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('{% static "js/sw.js" %}');
});
}
</script>
</body>
</html>
</html>

View File

@ -1,145 +1,193 @@
{% extends "base.html" %}
{% extends 'base.html' %}
{% block title %}{{ project_name }}{% endblock %}
{% block title %}Dashboard - Matzeflix{% endblock %}
{% block head %}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<!-- Google Cast SDK -->
<script type="text/javascript" src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>
<style>
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
inset: 0;
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'><path d='M-10 10L110 10M10 -10L10 110' stroke-width='1' stroke='rgba(255,255,255,0.05)'/></svg>");
animation: bg-pan 20s linear infinite;
z-index: -1;
}
@keyframes bg-pan {
0% {
background-position: 0% 0%;
.media-card {
transition: all 0.3s ease;
border: none;
background: #1f1f1f;
overflow: hidden;
}
100% {
background-position: 100% 100%;
.media-card:hover {
transform: scale(1.05);
z-index: 10;
box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2.5rem 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
}
h1 {
font-size: clamp(2.2rem, 3vw + 1.2rem, 3.2rem);
font-weight: 700;
margin: 0 0 1.2rem;
letter-spacing: -0.02em;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
opacity: 0.92;
}
.loader {
margin: 1.5rem auto;
width: 56px;
height: 56px;
border: 4px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
.media-img {
aspect-ratio: 2/3;
object-fit: cover;
}
.status-badge {
font-size: 0.7rem;
padding: 0.3em 0.6em;
}
.cast-button {
--connected-color: #e50914;
--disconnected-color: #ffffff;
}
}
.runtime code {
background: rgba(0, 0, 0, 0.25);
padding: 0.15rem 0.45rem;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}
footer {
position: absolute;
bottom: 1rem;
width: 100%;
text-align: center;
font-size: 0.85rem;
opacity: 0.75;
}
</style>
{% endblock %}
{% block content %}
<main>
<div class="card">
<h1>Analyzing your requirements and generating your app…</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
<span class="sr-only">Loading…</span>
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h2 class="fw-bold mb-0">Dashboard</h2>
<p class="text-muted">Welcome to your Matzeflix control center.</p>
</div>
<p class="hint">AppWizzy AI is collecting your requirements and applying the first changes.</p>
<p class="hint">This page will refresh automatically as the plan is implemented.</p>
<p class="runtime">
Runtime: Django <code>{{ django_version }}</code> · Python <code>{{ python_version }}</code>
— UTC <code>{{ current_time|date:"Y-m-d H:i:s" }}</code>
</p>
</div>
</main>
<footer>
Page updated: {{ current_time|date:"Y-m-d H:i:s" }} (UTC)
</footer>
{% endblock %}
<div class="d-flex gap-2">
<google-cast-launcher class="cast-button"></google-cast-launcher>
<button class="btn btn-outline-light btn-sm" onclick="location.reload()">
<i class="bi bi-arrow-clockwise"></i>
</button>
</div>
</div>
<!-- Service Status Row -->
<div class="row g-4 mb-5">
{% for service, data in service_status.items %}
<div class="col-md-6 col-lg-3">
<div class="card h-100 border-0 shadow-sm">
<div class="card-body p-4">
<div class="d-flex justify-content-between align-items-start mb-3">
<div class="p-2 rounded bg-dark">
{% if service == 'jellyfin' %}
<i class="bi bi-play-btn fs-4 text-primary"></i>
{% elif service == 'radarr' %}
<i class="bi bi-film fs-4 text-info"></i>
{% elif service == 'sonarr' %}
<i class="bi bi-tv fs-4 text-success"></i>
{% elif service == 'jellyseerr' %}
<i class="bi bi-plus-circle fs-4 text-warning"></i>
{% endif %}
</div>
{% if data.status == 'Online' %}
<span class="badge bg-success status-badge">ONLINE</span>
{% elif data.status == 'Not Configured' %}
<span class="badge bg-secondary status-badge">UNCONFIGURED</span>
{% else %}
<span class="badge bg-danger status-badge">OFFLINE</span>
{% endif %}
</div>
<h6 class="card-subtitle text-muted text-uppercase small fw-bold mb-1">{{ service }}</h6>
<h5 class="card-title mb-0">
{% if service == 'radarr' %}
{{ radarr_queue_count }} in Queue
{% elif service == 'sonarr' %}
{{ sonarr_queue_count }} in Queue
{% else %}
{{ data.status }}
{% endif %}
</h5>
<p class="small text-muted mt-2 mb-0 text-truncate">{{ data.details|default:"No additional info" }}</p>
</div>
{% if data.url %}
<div class="card-footer bg-transparent border-0 p-0">
<a href="{{ data.url }}" target="_blank" class="btn btn-dark w-100 rounded-0 rounded-bottom py-2 small">
Open <i class="bi bi-box-arrow-up-right ms-1"></i>
</a>
</div>
{% endif %}
</div>
</div>
{% endfor %}
</div>
<!-- Recent Media Row -->
{% if recent_media %}
<div class="mb-5">
<div class="d-flex justify-content-between align-items-center mb-3">
<h4 class="fw-bold mb-0">Recently Added</h4>
<a href="{{ jellyfin_url }}" target="_blank" class="text-danger text-decoration-none small">View All <i class="bi bi-chevron-right"></i></a>
</div>
<div class="row row-cols-2 row-cols-md-3 row-cols-lg-6 g-3">
{% for item in recent_media %}
<div class="col">
<div class="card media-card h-100">
{% if item.ImageTags.Primary %}
<img src="{{ jellyfin_url }}/Items/{{ item.Id }}/Images/Primary?maxWidth=400&tag={{ item.ImageTags.Primary }}" class="card-img-top media-img" alt="{{ item.Name }}">
{% else %}
<div class="bg-dark d-flex align-items-center justify-content-center media-img">
<i class="bi bi-film fs-1 text-secondary"></i>
</div>
{% endif %}
<div class="card-body p-2">
<p class="card-text small fw-bold text-truncate mb-0">{{ item.Name }}</p>
<p class="card-text text-muted" style="font-size: 0.7rem;">{{ item.ProductionYear|default:"" }}</p>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
<div class="row g-4 mb-5">
<!-- Jellyseerr Requests -->
<div class="col-lg-6">
<div class="card h-100 border-0">
<div class="card-header bg-transparent border-0 pt-4 px-4">
<h5 class="fw-bold mb-0">Pending Requests</h5>
</div>
<div class="card-body p-4">
{% if pending_requests %}
<ul class="list-group list-group-flush bg-transparent">
{% for req in pending_requests %}
<li class="list-group-item bg-transparent border-secondary px-0 py-3">
<div class="d-flex align-items-center">
<div class="flex-grow-1">
<h6 class="mb-1 fw-bold">{{ req.media.title|default:req.media.name }}</h6>
<p class="small text-muted mb-0">Requested by {{ req.requestedBy.displayName }}</p>
</div>
<span class="badge {% if req.status == 1 %}bg-warning text-dark{% elif req.status == 2 %}bg-success{% else %}bg-secondary{% endif %} rounded-pill">
{% if req.status == 1 %}Pending{% elif req.status == 2 %}Approved{% else %}Processing{% endif %}
</span>
</div>
</li>
{% endfor %}
</ul>
{% else %}
<div class="text-center py-4">
<i class="bi bi-inbox fs-1 text-muted d-block mb-2"></i>
<p class="text-muted">No pending requests</p>
</div>
{% endif %}
</div>
</div>
</div>
<!-- Streaming Info -->
<div class="col-lg-6">
<div class="card h-100 border-0 bg-danger bg-opacity-10">
<div class="card-body p-4 d-flex flex-column justify-content-center align-items-center text-center">
<i class="bi bi-cast fs-1 text-danger mb-3"></i>
<h4 class="fw-bold">Ready to Stream?</h4>
<p class="mb-4">Use the cast button in the header or your mobile app to send media directly to your TV.</p>
<div class="bg-dark bg-opacity-50 p-3 rounded text-start w-100">
<small class="d-block mb-1 text-danger fw-bold"><i class="bi bi-info-circle-fill me-1"></i> Pro Tip:</small>
<small class="text-muted">For the best experience, ensure your server is connected via Ethernet and your playback device is on a 5GHz Wi-Fi band.</small>
</div>
</div>
</div>
</div>
</div>
<script>
// Initialize Chromecast
window.__onGCastApiAvailable = function(isAvailable) {
if (isAvailable) {
initializeCastApi();
}
};
function initializeCastApi() {
cast.framework.CastContext.getInstance().setOptions({
receiverApplicationId: chrome.cast.media.DEFAULT_RECEIVER_APP_ID,
autoJoinPolicy: chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED
});
}
</script>
{% endblock %}

View File

@ -0,0 +1,91 @@
{% extends 'base.html' %}
{% block title %}Settings - Matzeflix{% endblock %}
{% block content %}
<div class="row mb-4">
<div class="col">
<h2 class="fw-bold">Settings</h2>
<p class="text-muted">Configure your service connections and API keys.</p>
</div>
</div>
<div class="row justify-content-center">
<div class="col-lg-8">
<div class="card border-0 shadow">
<div class="card-body p-4 p-md-5">
<form method="post">
{% csrf_token %}
{% for config in service_configs %}
<div class="mb-5 p-4 rounded bg-dark bg-opacity-25 border border-secondary border-opacity-25">
<div class="d-flex align-items-center mb-4">
<div class="p-3 rounded bg-danger bg-opacity-10 me-3">
{% if config.name == 'jellyfin' %}<i class="bi bi-play-btn fs-3 text-danger"></i>
{% elif config.name == 'radarr' %}<i class="bi bi-film fs-3 text-danger"></i>
{% elif config.name == 'sonarr' %}<i class="bi bi-tv fs-3 text-danger"></i>
{% elif config.name == 'jellyseerr' %}<i class="bi bi-plus-circle fs-3 text-danger"></i>
{% endif %}
</div>
<div>
<h4 class="text-capitalize mb-0 fw-bold">{{ config.name }}</h4>
<small class="text-muted">Configuration for {{ config.name|capfirst }}</small>
</div>
</div>
<div class="row g-3">
<div class="col-12">
<label for="{{ config.name }}_url" class="form-label small text-muted text-uppercase fw-bold">Server URL</label>
<input type="url" class="form-control form-control-lg bg-dark border-secondary border-opacity-50 text-white"
id="{{ config.name }}_url" name="{{ config.name }}_url"
placeholder="http://192.168.1.100:8096" value="{{ config.url }}">
</div>
<div class="col-12">
<label for="{{ config.name }}_api_key" class="form-label small text-muted text-uppercase fw-bold">API Key / Token</label>
<div class="input-group">
<input type="password" class="form-control form-control-lg bg-dark border-secondary border-opacity-50 text-white"
id="{{ config.name }}_api_key" name="{{ config.name }}_api_key"
value="{{ config.api_key }}">
<button class="btn btn-outline-secondary" type="button" onclick="togglePassword('{{ config.name }}_api_key')">
<i class="bi bi-eye"></i>
</button>
</div>
</div>
<div class="col-12">
<div class="form-check form-switch mt-2">
<input class="form-check-input" type="checkbox" id="{{ config.name }}_active" name="{{ config.name }}_active"
{% if config.is_active %}checked{% endif %}>
<label class="form-check-label text-muted" for="{{ config.name }}_active">Enable this service</label>
</div>
</div>
</div>
</div>
{% endfor %}
<div class="d-grid gap-3 mt-5">
<button type="submit" class="btn btn-primary btn-lg py-3 fw-bold">
<i class="bi bi-check2-circle me-2"></i>SAVE ALL CONFIGURATIONS
</button>
<a href="{% url 'home' %}" class="btn btn-link text-decoration-none text-muted text-center">
Return to Dashboard
</a>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
function togglePassword(id) {
const input = document.getElementById(id);
if (input.type === "password") {
input.type = "text";
} else {
input.type = "password";
}
}
</script>
{% endblock %}

View File

@ -1,7 +1,7 @@
from django.urls import path
from .views import home
from . import views
urlpatterns = [
path("", home, name="home"),
]
path('', views.home, name='home'),
path('settings/', views.settings_view, name='settings'),
]

50
core/utils.py Normal file
View File

@ -0,0 +1,50 @@
import requests
from .models import ServiceSetting
from .api_clients import JellyfinClient, RadarrClient, SonarrClient, JellyseerrClient
def check_service_status(service_name):
try:
setting = ServiceSetting.objects.get(name=service_name, is_active=True)
if not setting.url:
return {"status": "Not Configured", "details": None}
# Detailed check
if service_name == 'jellyfin':
client = JellyfinClient()
info = client.get_info()
if info:
return {"status": "Online", "details": f"Version: {info.get('Version')}"}
elif service_name == 'radarr':
client = RadarrClient()
info = client.get_status()
if info:
return {"status": "Online", "details": f"Version: {info.get('version')}"}
elif service_name == 'sonarr':
client = SonarrClient()
info = client.get_status()
if info:
return {"status": "Online", "details": f"Version: {info.get('version')}"}
elif service_name == 'jellyseerr':
client = JellyseerrClient()
info = client.get_status()
if info:
return {"status": "Online", "details": f"Version: {info.get('version')}"}
# Fallback to simple ping
response = requests.get(setting.url, timeout=5)
if response.status_code < 400:
return {"status": "Online", "details": "Reachable (No API details)"}
else:
return {"status": "Error", "details": f"Status: {response.status_code}"}
except ServiceSetting.DoesNotExist:
return {"status": "Not Configured", "details": None}
except Exception as e:
return {"status": "Offline", "details": str(e)}
def get_all_services_status():
services = ['jellyfin', 'radarr', 'sonarr', 'jellyseerr']
status_map = {}
for service in services:
status_map[service] = check_service_status(service)
return status_map

View File

@ -1,25 +1,73 @@
import os
import platform
from django import get_version as django_version
from django.shortcuts import render
from django.shortcuts import render, redirect
from django.utils import timezone
from .utils import get_all_services_status
from .models import ServiceSetting
from .api_clients import JellyfinClient, RadarrClient, SonarrClient, JellyseerrClient
def home(request):
"""Render the landing screen with loader and environment details."""
host_name = request.get_host().lower()
agent_brand = "AppWizzy" if host_name == "appwizzy.com" else "Flatlogic"
now = timezone.now()
"""Render the dashboard with service statuses and detailed info."""
service_status = get_all_services_status()
# Fetch additional data for the dashboard
jellyfin = JellyfinClient()
recent_media = jellyfin.get_recent_items(6)
radarr = RadarrClient()
radarr_queue = radarr.get_queue()
sonarr = SonarrClient()
sonarr_queue = sonarr.get_queue()
jellyseerr = JellyseerrClient()
pending_requests = jellyseerr.get_requests(5)
# Add URLs to the context for links
settings = {s.name: s.url for s in ServiceSetting.objects.all()}
for service in service_status:
service_status[service]['url'] = settings.get(service, '')
context = {
"project_name": "New Style",
"agent_brand": agent_brand,
"django_version": django_version(),
"python_version": platform.python_version(),
"current_time": now,
"host_name": host_name,
"project_description": os.getenv("PROJECT_DESCRIPTION", ""),
"project_image_url": os.getenv("PROJECT_IMAGE_URL", ""),
"project_name": "Matzeflix Dashboard",
"service_status": service_status,
"recent_media": recent_media,
"radarr_queue_count": len(radarr_queue),
"sonarr_queue_count": len(sonarr_queue),
"pending_requests": pending_requests,
"current_time": timezone.now(),
"jellyfin_url": settings.get('jellyfin', ''),
}
return render(request, "core/index.html", context)
def settings_view(request):
"""View to manage service settings."""
services = ['jellyfin', 'radarr', 'sonarr', 'jellyseerr']
if request.method == "POST":
for service in services:
url = request.POST.get(f"{service}_url")
api_key = request.POST.get(f"{service}_api_key")
is_active = request.POST.get(f"{service}_active") == "on"
setting, created = ServiceSetting.objects.get_or_create(name=service)
setting.url = url or ""
setting.api_key = api_key or ""
setting.is_active = is_active
setting.save()
return redirect('home')
settings_query = ServiceSetting.objects.all()
settings_dict = {s.name: s for s in settings_query}
service_configs = []
for service in services:
config = settings_dict.get(service)
if not config:
config = {'name': service, 'url': '', 'api_key': '', 'is_active': False}
service_configs.append(config)
context = {
"service_configs": service_configs,
}
return render(request, "core/settings.html", context)

View File

@ -1,3 +1,4 @@
Django==5.2.7
mysqlclient==2.2.7
python-dotenv==1.1.1
requests

14
static/js/sw.js Normal file
View File

@ -0,0 +1,14 @@
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open('matzeflix-v1').then((cache) => cache.addAll([
'/',
'/settings/',
])),
);
});
self.addEventListener('fetch', (e) => {
e.respondWith(
caches.match(e.request).then((response) => response || fetch(e.request)),
);
});

17
static/manifest.json Normal file
View File

@ -0,0 +1,17 @@
{
"name": "Matzeflix Dashboard",
"short_name": "Matzeflix",
"description": "Control center for Jellyfin, Radarr, Sonarr and Jellyseerr",
"start_url": "/",
"display": "standalone",
"background_color": "#141414",
"theme_color": "#e50914",
"icons": [
{
"src": "https://cdn-icons-png.flaticon.com/512/711/711245.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any maskable"
}
]
}

14
staticfiles/js/sw.js Normal file
View File

@ -0,0 +1,14 @@
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open('matzeflix-v1').then((cache) => cache.addAll([
'/',
'/settings/',
])),
);
});
self.addEventListener('fetch', (e) => {
e.respondWith(
caches.match(e.request).then((response) => response || fetch(e.request)),
);
});

17
staticfiles/manifest.json Normal file
View File

@ -0,0 +1,17 @@
{
"name": "Matzeflix Dashboard",
"short_name": "Matzeflix",
"description": "Control center for Jellyfin, Radarr, Sonarr and Jellyseerr",
"start_url": "/",
"display": "standalone",
"background_color": "#141414",
"theme_color": "#e50914",
"icons": [
{
"src": "https://cdn-icons-png.flaticon.com/512/711/711245.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any maskable"
}
]
}