Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| feb2d26c5b | |||
| 67b816cd61 | |||
| faaca310e9 | |||
| 0957f83411 | |||
| 6463c6b3d1 |
@@ -22,11 +22,18 @@ jobs:
|
|||||||
echo "release=${RELEASE_NAME}" >> $GITHUB_OUTPUT
|
echo "release=${RELEASE_NAME}" >> $GITHUB_OUTPUT
|
||||||
echo "Building version ${VERSION} from branch ${BRANCH}"
|
echo "Building version ${VERSION} from branch ${BRANCH}"
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
tags: |
|
tags: |
|
||||||
reg.i3omb.com/sofarr:${{ steps.version.outputs.version }}
|
reg.i3omb.com/sofarr:${{ steps.version.outputs.version }}
|
||||||
reg.i3omb.com/sofarr:${{ steps.version.outputs.release }}
|
reg.i3omb.com/sofarr:${{ steps.version.outputs.release }}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
sofarr:
|
||||||
|
image: docker.i3omb.com/sofarr:latest
|
||||||
|
container_name: sofarr
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "3001:3001"
|
||||||
|
environment:
|
||||||
|
- PORT=3001
|
||||||
|
- EMBY_URL=https://emby.example.com
|
||||||
|
- EMBY_API_KEY=your-emby-api-key
|
||||||
|
- SONARR_INSTANCES=[{"name":"main","url":"https://sonarr.example.com","apiKey":"your-sonarr-api-key"}]
|
||||||
|
- RADARR_INSTANCES=[{"name":"main","url":"https://radarr.example.com","apiKey":"your-radarr-api-key"}]
|
||||||
|
- SABNZBD_INSTANCES=[{"name":"main","url":"https://sabnzbd.example.com","apiKey":"your-sabnzbd-api-key"}]
|
||||||
|
- QBITTORRENT_INSTANCES=[{"name":"main","url":"https://qbittorrent.example.com","username":"admin","password":"your-password"}]
|
||||||
|
- LOG_LEVEL=info
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sofarr",
|
"name": "sofarr",
|
||||||
"version": "0.1.1",
|
"version": "0.1.2",
|
||||||
"description": "A personal media download dashboard that shows your downloads 'so far' while you relax on the sofa waiting for your *arr services to finish",
|
"description": "A personal media download dashboard that shows your downloads 'so far' while you relax on the sofa waiting for your *arr services to finish",
|
||||||
"main": "server/index.js",
|
"main": "server/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
+21
-1
@@ -2,6 +2,8 @@ let currentUser = null;
|
|||||||
let downloads = [];
|
let downloads = [];
|
||||||
let refreshInterval = null;
|
let refreshInterval = null;
|
||||||
let currentRefreshRate = 5000; // default 5 seconds
|
let currentRefreshRate = 5000; // default 5 seconds
|
||||||
|
let isAdmin = false;
|
||||||
|
let showAll = false;
|
||||||
|
|
||||||
// Apply saved theme immediately (before DOMContentLoaded to avoid flash)
|
// Apply saved theme immediately (before DOMContentLoaded to avoid flash)
|
||||||
(function() {
|
(function() {
|
||||||
@@ -17,6 +19,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
document.getElementById('login-form').addEventListener('submit', handleLogin);
|
document.getElementById('login-form').addEventListener('submit', handleLogin);
|
||||||
document.getElementById('logout-btn').addEventListener('click', handleLogout);
|
document.getElementById('logout-btn').addEventListener('click', handleLogout);
|
||||||
document.getElementById('refresh-rate').addEventListener('change', handleRefreshRateChange);
|
document.getElementById('refresh-rate').addEventListener('change', handleRefreshRateChange);
|
||||||
|
document.getElementById('show-all-toggle').addEventListener('change', handleShowAllToggle);
|
||||||
});
|
});
|
||||||
|
|
||||||
function initThemeSwitcher() {
|
function initThemeSwitcher() {
|
||||||
@@ -48,6 +51,11 @@ function handleRefreshRateChange(e) {
|
|||||||
startAutoRefresh();
|
startAutoRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleShowAllToggle(e) {
|
||||||
|
showAll = e.target.checked;
|
||||||
|
fetchUserDownloads(true);
|
||||||
|
}
|
||||||
|
|
||||||
function stopAutoRefresh() {
|
function stopAutoRefresh() {
|
||||||
if (refreshInterval) {
|
if (refreshInterval) {
|
||||||
clearInterval(refreshInterval);
|
clearInterval(refreshInterval);
|
||||||
@@ -62,6 +70,7 @@ async function checkAuthentication() {
|
|||||||
|
|
||||||
if (data.authenticated) {
|
if (data.authenticated) {
|
||||||
currentUser = data.user;
|
currentUser = data.user;
|
||||||
|
isAdmin = !!data.user.isAdmin;
|
||||||
showDashboard();
|
showDashboard();
|
||||||
fetchUserDownloads(true);
|
fetchUserDownloads(true);
|
||||||
startAutoRefresh();
|
startAutoRefresh();
|
||||||
@@ -93,6 +102,7 @@ async function handleLogin(e) {
|
|||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
currentUser = data.user;
|
currentUser = data.user;
|
||||||
|
isAdmin = !!data.user.isAdmin;
|
||||||
showDashboard();
|
showDashboard();
|
||||||
fetchUserDownloads(true);
|
fetchUserDownloads(true);
|
||||||
startAutoRefresh();
|
startAutoRefresh();
|
||||||
@@ -129,6 +139,7 @@ function showDashboard() {
|
|||||||
document.getElementById('login-container').style.display = 'none';
|
document.getElementById('login-container').style.display = 'none';
|
||||||
document.getElementById('dashboard-container').style.display = 'block';
|
document.getElementById('dashboard-container').style.display = 'block';
|
||||||
document.getElementById('currentUser').textContent = currentUser.name || '-';
|
document.getElementById('currentUser').textContent = currentUser.name || '-';
|
||||||
|
document.getElementById('admin-controls').style.display = isAdmin ? 'flex' : 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
function showLoginError(message) {
|
function showLoginError(message) {
|
||||||
@@ -149,10 +160,12 @@ async function fetchUserDownloads(isInitialLoad = false) {
|
|||||||
hideError();
|
hideError();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/dashboard/user-downloads');
|
const url = showAll ? '/api/dashboard/user-downloads?showAll=true' : '/api/dashboard/user-downloads';
|
||||||
|
const response = await fetch(url);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
currentUser = data.user;
|
currentUser = data.user;
|
||||||
|
isAdmin = !!data.isAdmin;
|
||||||
downloads = data.downloads;
|
downloads = data.downloads;
|
||||||
|
|
||||||
// Debug: log first download to see what fields are present
|
// Debug: log first download to see what fields are present
|
||||||
@@ -348,6 +361,13 @@ function createDownloadCard(download) {
|
|||||||
movie.textContent = `Movie: ${download.movieName}`;
|
movie.textContent = `Movie: ${download.movieName}`;
|
||||||
infoDiv.appendChild(movie);
|
infoDiv.appendChild(movie);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showAll && download.userTag) {
|
||||||
|
const userBadge = document.createElement('span');
|
||||||
|
userBadge.className = 'download-user-badge';
|
||||||
|
userBadge.textContent = download.userTag;
|
||||||
|
header.appendChild(userBadge);
|
||||||
|
}
|
||||||
|
|
||||||
const details = document.createElement('div');
|
const details = document.createElement('div');
|
||||||
details.className = 'download-details';
|
details.className = 'download-details';
|
||||||
|
|||||||
@@ -46,6 +46,12 @@
|
|||||||
<option value="0">Off</option>
|
<option value="0">Off</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="admin-controls" class="admin-controls" style="display: none;">
|
||||||
|
<label class="toggle-label">
|
||||||
|
<input type="checkbox" id="show-all-toggle">
|
||||||
|
<span>Show all users</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<span class="user-label">Current User:</span>
|
<span class="user-label">Current User:</span>
|
||||||
<span class="user-name" id="currentUser">-</span>
|
<span class="user-name" id="currentUser">-</span>
|
||||||
|
|||||||
@@ -577,6 +577,42 @@ body {
|
|||||||
background: var(--accent-hover);
|
background: var(--accent-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ===== Admin Controls ===== */
|
||||||
|
.admin-controls {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
background: var(--surface-alt);
|
||||||
|
padding: 4px 12px;
|
||||||
|
border-radius: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-label input[type="checkbox"] {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
cursor: pointer;
|
||||||
|
accent-color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.download-user-badge {
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 0.65rem;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: capitalize;
|
||||||
|
background: var(--accent-light);
|
||||||
|
color: var(--accent);
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
/* ===== Mobile ===== */
|
/* ===== Mobile ===== */
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.app-header {
|
.app-header {
|
||||||
|
|||||||
@@ -37,9 +37,11 @@ router.post('/login', async (req, res) => {
|
|||||||
console.log(`[Auth] Login successful for user: ${user.Name}`);
|
console.log(`[Auth] Login successful for user: ${user.Name}`);
|
||||||
|
|
||||||
// Set authentication cookie
|
// Set authentication cookie
|
||||||
|
const isAdmin = !!(user.Policy && user.Policy.IsAdministrator);
|
||||||
res.cookie('emby_user', JSON.stringify({
|
res.cookie('emby_user', JSON.stringify({
|
||||||
id: user.Id,
|
id: user.Id,
|
||||||
name: user.Name,
|
name: user.Name,
|
||||||
|
isAdmin: isAdmin,
|
||||||
token: authData.AccessToken
|
token: authData.AccessToken
|
||||||
}), {
|
}), {
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
@@ -50,7 +52,8 @@ router.post('/login', async (req, res) => {
|
|||||||
success: true,
|
success: true,
|
||||||
user: {
|
user: {
|
||||||
id: user.Id,
|
id: user.Id,
|
||||||
name: user.Name
|
name: user.Name,
|
||||||
|
isAdmin: isAdmin
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -76,7 +79,8 @@ router.get('/me', (req, res) => {
|
|||||||
authenticated: true,
|
authenticated: true,
|
||||||
user: {
|
user: {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
name: user.name
|
name: user.name,
|
||||||
|
isAdmin: !!user.isAdmin
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
+20
-13
@@ -53,7 +53,9 @@ router.get('/user-downloads', async (req, res) => {
|
|||||||
|
|
||||||
const user = JSON.parse(userCookie);
|
const user = JSON.parse(userCookie);
|
||||||
const username = user.name.toLowerCase();
|
const username = user.name.toLowerCase();
|
||||||
console.log(`[Dashboard] Fetching downloads for authenticated user: ${user.name} (${username})`);
|
const isAdmin = !!user.isAdmin;
|
||||||
|
const showAll = isAdmin && req.query.showAll === 'true';
|
||||||
|
console.log(`[Dashboard] Fetching downloads for authenticated user: ${user.name} (${username}), isAdmin: ${isAdmin}, showAll: ${showAll}`);
|
||||||
|
|
||||||
// Get all service instances
|
// Get all service instances
|
||||||
const sabInstances = getSABnzbdInstances();
|
const sabInstances = getSABnzbdInstances();
|
||||||
@@ -301,7 +303,7 @@ router.get('/user-downloads', async (req, res) => {
|
|||||||
const series = seriesMap.get(sonarrMatch.seriesId) || sonarrMatch.series;
|
const series = seriesMap.get(sonarrMatch.seriesId) || sonarrMatch.series;
|
||||||
if (series) {
|
if (series) {
|
||||||
const userTag = extractUserTag(series.tags, sonarrTagMap);
|
const userTag = extractUserTag(series.tags, sonarrTagMap);
|
||||||
if (userTag && userTag.toLowerCase() === username) {
|
if (userTag && (showAll || userTag.toLowerCase() === username)) {
|
||||||
userDownloads.push({
|
userDownloads.push({
|
||||||
type: 'series',
|
type: 'series',
|
||||||
title: nzbName,
|
title: nzbName,
|
||||||
@@ -314,7 +316,8 @@ router.get('/user-downloads', async (req, res) => {
|
|||||||
speed: slotState.speed,
|
speed: slotState.speed,
|
||||||
eta: slot.timeleft,
|
eta: slot.timeleft,
|
||||||
seriesName: series.title,
|
seriesName: series.title,
|
||||||
episodeInfo: sonarrMatch
|
episodeInfo: sonarrMatch,
|
||||||
|
userTag: userTag
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -330,7 +333,7 @@ router.get('/user-downloads', async (req, res) => {
|
|||||||
const movie = moviesMap.get(radarrMatch.movieId) || radarrMatch.movie;
|
const movie = moviesMap.get(radarrMatch.movieId) || radarrMatch.movie;
|
||||||
if (movie) {
|
if (movie) {
|
||||||
const userTag = extractUserTag(movie.tags, radarrTagMap);
|
const userTag = extractUserTag(movie.tags, radarrTagMap);
|
||||||
if (userTag && userTag.toLowerCase() === username) {
|
if (userTag && (showAll || userTag.toLowerCase() === username)) {
|
||||||
userDownloads.push({
|
userDownloads.push({
|
||||||
type: 'movie',
|
type: 'movie',
|
||||||
title: nzbName,
|
title: nzbName,
|
||||||
@@ -343,7 +346,8 @@ router.get('/user-downloads', async (req, res) => {
|
|||||||
speed: slotState.speed,
|
speed: slotState.speed,
|
||||||
eta: slot.timeleft,
|
eta: slot.timeleft,
|
||||||
movieName: movie.title,
|
movieName: movie.title,
|
||||||
movieInfo: radarrMatch
|
movieInfo: radarrMatch,
|
||||||
|
userTag: userTag
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -376,7 +380,7 @@ router.get('/user-downloads', async (req, res) => {
|
|||||||
const series = seriesMap.get(sonarrMatch.seriesId) || sonarrMatch.series;
|
const series = seriesMap.get(sonarrMatch.seriesId) || sonarrMatch.series;
|
||||||
if (series) {
|
if (series) {
|
||||||
const userTag = extractUserTag(series.tags, sonarrTagMap);
|
const userTag = extractUserTag(series.tags, sonarrTagMap);
|
||||||
if (userTag && userTag.toLowerCase() === username) {
|
if (userTag && (showAll || userTag.toLowerCase() === username)) {
|
||||||
userDownloads.push({
|
userDownloads.push({
|
||||||
type: 'series',
|
type: 'series',
|
||||||
title: nzbName,
|
title: nzbName,
|
||||||
@@ -385,7 +389,8 @@ router.get('/user-downloads', async (req, res) => {
|
|||||||
size: slot.size,
|
size: slot.size,
|
||||||
completedAt: slot.completed_time,
|
completedAt: slot.completed_time,
|
||||||
seriesName: series.title,
|
seriesName: series.title,
|
||||||
episodeInfo: sonarrMatch
|
episodeInfo: sonarrMatch,
|
||||||
|
userTag: userTag
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -401,7 +406,7 @@ router.get('/user-downloads', async (req, res) => {
|
|||||||
const movie = moviesMap.get(radarrMatch.movieId) || radarrMatch.movie;
|
const movie = moviesMap.get(radarrMatch.movieId) || radarrMatch.movie;
|
||||||
if (movie) {
|
if (movie) {
|
||||||
const userTag = extractUserTag(movie.tags, radarrTagMap);
|
const userTag = extractUserTag(movie.tags, radarrTagMap);
|
||||||
if (userTag && userTag.toLowerCase() === username) {
|
if (userTag && (showAll || userTag.toLowerCase() === username)) {
|
||||||
userDownloads.push({
|
userDownloads.push({
|
||||||
type: 'movie',
|
type: 'movie',
|
||||||
title: nzbName,
|
title: nzbName,
|
||||||
@@ -410,7 +415,8 @@ router.get('/user-downloads', async (req, res) => {
|
|||||||
size: slot.size,
|
size: slot.size,
|
||||||
completedAt: slot.completed_time,
|
completedAt: slot.completed_time,
|
||||||
movieName: movie.title,
|
movieName: movie.title,
|
||||||
movieInfo: radarrMatch
|
movieInfo: radarrMatch,
|
||||||
|
userTag: userTag
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -462,7 +468,7 @@ router.get('/user-downloads', async (req, res) => {
|
|||||||
const series = seriesMap.get(sonarrMatch.seriesId) || sonarrMatch.series;
|
const series = seriesMap.get(sonarrMatch.seriesId) || sonarrMatch.series;
|
||||||
if (series) {
|
if (series) {
|
||||||
const userTag = extractUserTag(series.tags, sonarrTagMap);
|
const userTag = extractUserTag(series.tags, sonarrTagMap);
|
||||||
if (userTag && userTag.toLowerCase() === username) {
|
if (userTag && (showAll || userTag.toLowerCase() === username)) {
|
||||||
console.log(`[Dashboard] Matched torrent "${torrentName}" to Sonarr series "${series.title}"`);
|
console.log(`[Dashboard] Matched torrent "${torrentName}" to Sonarr series "${series.title}"`);
|
||||||
const download = mapTorrentToDownload(torrent);
|
const download = mapTorrentToDownload(torrent);
|
||||||
download.type = 'series';
|
download.type = 'series';
|
||||||
@@ -486,7 +492,7 @@ router.get('/user-downloads', async (req, res) => {
|
|||||||
const movie = moviesMap.get(radarrMatch.movieId) || radarrMatch.movie;
|
const movie = moviesMap.get(radarrMatch.movieId) || radarrMatch.movie;
|
||||||
if (movie) {
|
if (movie) {
|
||||||
const userTag = extractUserTag(movie.tags, radarrTagMap);
|
const userTag = extractUserTag(movie.tags, radarrTagMap);
|
||||||
if (userTag && userTag.toLowerCase() === username) {
|
if (userTag && (showAll || userTag.toLowerCase() === username)) {
|
||||||
console.log(`[Dashboard] Matched torrent "${torrentName}" to Radarr movie "${movie.title}"`);
|
console.log(`[Dashboard] Matched torrent "${torrentName}" to Radarr movie "${movie.title}"`);
|
||||||
const download = mapTorrentToDownload(torrent);
|
const download = mapTorrentToDownload(torrent);
|
||||||
download.type = 'movie';
|
download.type = 'movie';
|
||||||
@@ -510,7 +516,7 @@ router.get('/user-downloads', async (req, res) => {
|
|||||||
const series = seriesMap.get(sonarrHistoryMatch.seriesId) || sonarrHistoryMatch.series;
|
const series = seriesMap.get(sonarrHistoryMatch.seriesId) || sonarrHistoryMatch.series;
|
||||||
if (series) {
|
if (series) {
|
||||||
const userTag = extractUserTag(series.tags, sonarrTagMap);
|
const userTag = extractUserTag(series.tags, sonarrTagMap);
|
||||||
if (userTag && userTag.toLowerCase() === username) {
|
if (userTag && (showAll || userTag.toLowerCase() === username)) {
|
||||||
console.log(`[Dashboard] Matched torrent "${torrentName}" to Sonarr history "${series.title}"`);
|
console.log(`[Dashboard] Matched torrent "${torrentName}" to Sonarr history "${series.title}"`);
|
||||||
const download = mapTorrentToDownload(torrent);
|
const download = mapTorrentToDownload(torrent);
|
||||||
download.type = 'series';
|
download.type = 'series';
|
||||||
@@ -534,7 +540,7 @@ router.get('/user-downloads', async (req, res) => {
|
|||||||
const movie = moviesMap.get(radarrHistoryMatch.movieId) || radarrHistoryMatch.movie;
|
const movie = moviesMap.get(radarrHistoryMatch.movieId) || radarrHistoryMatch.movie;
|
||||||
if (movie) {
|
if (movie) {
|
||||||
const userTag = extractUserTag(movie.tags, radarrTagMap);
|
const userTag = extractUserTag(movie.tags, radarrTagMap);
|
||||||
if (userTag && userTag.toLowerCase() === username) {
|
if (userTag && (showAll || userTag.toLowerCase() === username)) {
|
||||||
console.log(`[Dashboard] Matched torrent "${torrentName}" to Radarr history "${movie.title}"`);
|
console.log(`[Dashboard] Matched torrent "${torrentName}" to Radarr history "${movie.title}"`);
|
||||||
const download = mapTorrentToDownload(torrent);
|
const download = mapTorrentToDownload(torrent);
|
||||||
download.type = 'movie';
|
download.type = 'movie';
|
||||||
@@ -561,6 +567,7 @@ router.get('/user-downloads', async (req, res) => {
|
|||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
user: user.name,
|
user: user.name,
|
||||||
|
isAdmin: isAdmin,
|
||||||
downloads: userDownloads
|
downloads: userDownloads
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user