Skip to content

Commit 7fa735d

Browse files
committed
Adjustments to the UI in the starr app pages
Add the themes that dockwatch uses
1 parent 6c6f305 commit 7fa735d

15 files changed

Lines changed: 1568 additions & 211 deletions

File tree

root/app/www/public/ajax/settings.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@
4343
if ($_POST['m'] == 'bustCache') {
4444
$cache->bust($_POST['key']);
4545
}
46+
47+
if ($_POST['m'] == 'updateSetting') {
48+
$proxyDb->setSetting($_POST['setting'], $_POST['value']);
49+
}

root/app/www/public/css/style.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
font-size: small;
33
}
44

5+
body {
6+
padding-top: 4.75rem;
7+
padding-bottom: 4.75rem;
8+
}
9+
10+
#footer {
11+
background-color: var(--background-50) !important;
12+
}
13+
514
pre {
615
padding: 1em;
716
width: 100%;

root/app/www/public/functions/common.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,24 @@ function extractCookies($string) {
8989

9090
return $cookies ?: [];
9191
}
92+
93+
function getThemes()
94+
{
95+
$themes = [];
96+
$themesPath = ABSOLUTE_PATH . 'themes/';
97+
98+
if (!is_dir($themesPath)) {
99+
return $themes;
100+
}
101+
102+
$dir = opendir($themesPath);
103+
while ($file = readdir($dir)) {
104+
if (str_contains($file, '.min.css')) {
105+
$themes[] = str_replace('.min.css', '', $file);
106+
}
107+
}
108+
closedir($dir);
109+
sort($themes);
110+
111+
return $themes;
112+
}

root/app/www/public/includes/footer.php

Lines changed: 75 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,65 +16,90 @@
1616
}
1717

1818
?>
19-
</div> <!-- content -->
19+
</div>
20+
<footer id="footer" class="footer fixed-bottom bg-dark pb-3" style="height: 3.5rem !important;">
21+
<div class="container bg-dark">
22+
<div id="footer-content" class="row bg-dark">
23+
<div id="footer-branch" class="col-4 text-center mt-2">
24+
Version: <?= gitVersion() ?><br>
25+
</div>
26+
<div id="footer-themes" class="col-4 text-center mt-2">
27+
<select id="theme-select" class="form-select" onchange="updateSetting('defaultTheme', $(this).val());">
28+
<?php
29+
foreach ($themes as $theme) {
30+
?>
31+
<option <?= $theme == USER_THEME ? 'selected' : '' ?> value="<?= $theme ?>"><?= $theme ?></option>
32+
<?php
33+
}
34+
?>
35+
</select>
36+
</div>
37+
<div id="footer-icons" class="col-4 text-end mt-2">
38+
<a href="https://github.com/Notifiarr/starrproxy" title="Visit the <?= APP_NAME ?> github" target="_blank"><i class="fab fa-github fa-lg"></i></a>
39+
</div>
40+
</div>
41+
</div>
42+
</footer>
2043

21-
<!-- Toast container -->
22-
<div class="toast-container bottom-0 end-0 p-3" style="z-index: 10001 !important; position: fixed;"></div>
44+
<!-- Toast container -->
45+
<div class="toast-container bottom-0 end-0 p-3" style="z-index: 10001 !important; position: fixed;"></div>
2346

24-
<!-- Generic modal -->
25-
<div id="dialog-modal-container">
26-
<div class="modal fade" id="dialog-modal" style="z-index: 9999 !important;" data-bs-backdrop="static">
27-
<div class="modal-dialog modal-dialog-scrollable">
28-
<div class="modal-content bg-dark" style="border: grey solid 1px;">
29-
<div class="modal-header" style="border: grey solid 1px;">
30-
<h5 class="modal-title w-100"></h5>
31-
<div class="d-flex text-end">
32-
<i class="far fa-window-close fa-2x" data-bs-dismiss="modal" style="cursor: pointer;"></i>
33-
</div>
34-
</div>
35-
<div class="modal-body" data-scrollbar=”true” data-wheel-propagation=”true”></div>
36-
<div class="modal-footer"></div>
47+
<!-- Generic modal -->
48+
<div id="dialog-modal-container">
49+
<div class="modal fade" id="dialog-modal" style="z-index: 9999 !important;" data-bs-backdrop="static">
50+
<div class="modal-dialog modal-dialog-scrollable">
51+
<div class="modal-content bg-dark" style="border: grey solid 1px;">
52+
<div class="modal-header" style="border: grey solid 1px;">
53+
<h5 class="modal-title w-100"></h5>
54+
<div class="d-flex text-end">
55+
<i class="far fa-window-close fa-2x" data-bs-dismiss="modal" style="cursor: pointer;"></i>
3756
</div>
3857
</div>
58+
<div class="modal-body" data-scrollbar=”true” data-wheel-propagation=”true”></div>
59+
<div class="modal-footer"></div>
3960
</div>
4061
</div>
62+
</div>
63+
</div>
4164

42-
<!-- Loading modal -->
43-
<div class="modal fade" id="loading-modal" style="z-index: 9999 !important;" data-bs-backdrop="static">
44-
<div class="modal-dialog">
45-
<div class="modal-content">
46-
<div class="modal-header">
47-
<h5 class="modal-title">Loading</h5>
48-
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
49-
</div>
50-
<div class="modal-body">
51-
<p>
52-
<div class="spinner-border text-primary" style="margin-right: 1em;"></div>
53-
I'm gathering everything needed to complete the request, give me just a moment...
54-
</p>
55-
</div>
56-
<div class="modal-footer">&nbsp;</div>
57-
</div>
65+
<!-- Loading modal -->
66+
<div class="modal fade" id="loading-modal" style="z-index: 9999 !important;" data-bs-backdrop="static">
67+
<div class="modal-dialog">
68+
<div class="modal-content">
69+
<div class="modal-header">
70+
<h5 class="modal-title">Loading</h5>
71+
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
72+
</div>
73+
<div class="modal-body">
74+
<p>
75+
<div class="spinner-border text-primary" style="margin-right: 1em;"></div>
76+
I'm gathering everything needed to complete the request, give me just a moment...
77+
</p>
5878
</div>
79+
<div class="modal-footer">&nbsp;</div>
5980
</div>
81+
</div>
82+
</div>
83+
84+
<!-- Javascript Libraries -->
85+
<script src="libraries/jquery/jquery-3.4.1.min.js"></script>
86+
<script src="libraries/jquery/jquery-ui-1.13.2.min.js"></script>
87+
<script src="libraries/bootstrap/bootstrap.bundle.min.js"></script>
88+
<script src="libraries/select2/select2.min.js"></script>
6089

61-
<!-- Javascript Libraries -->
62-
<script src="libraries/jquery/jquery-3.4.1.min.js"></script>
63-
<script src="libraries/jquery/jquery-ui-1.13.2.min.js"></script>
64-
<script src="libraries/bootstrap/bootstrap.bundle.min.js"></script>
65-
<script src="libraries/select2/select2.min.js"></script>
90+
<!-- Internal functions -->
91+
<?php
92+
$dir = opendir('js');
93+
while ($file = readdir($dir)) {
94+
if (!str_contains($file, '.js')) {
95+
continue;
96+
}
6697

67-
<!-- Internal functions -->
68-
<?php
69-
$dir = opendir('js');
70-
while ($file = readdir($dir)) {
71-
if (!str_contains($file, '.js')) {
72-
continue;
73-
}
98+
?>
99+
<script src="js/<?= $file ?>?t=<?= filemtime('js/' . $file) ?>"></script><?php
100+
}
101+
closedir($dir);
102+
?>
103+
</body>
74104

75-
?><script src="js/<?= $file ?>?t=<?= filemtime('js/' . $file) ?>"></script><?php
76-
}
77-
closedir($dir);
78-
?>
79-
</body>
80-
</html>
105+
</html>

root/app/www/public/includes/header.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737

3838
<!-- Customized Bootstrap Stylesheet -->
3939
<link href="libraries/bootstrap/bootstrap.min.css" rel="stylesheet">
40+
<link href="themes/base.css?t=<?= filemtime('themes/base.css') ?>" rel="stylesheet">
41+
<link href="themes/<?= USER_THEME ?>.min.css?t=<?= filemtime('themes/' . USER_THEME . '.min.css') ?>" rel="stylesheet">
4042

4143
<!-- Select2 Stylesheet -->
4244
<link href="libraries/select2/select2.min.css" rel="stylesheet">
@@ -45,12 +47,11 @@
4547
<!-- Internal Stylesheet -->
4648
<link href="css/style.css" rel="stylesheet">
4749
</head>
48-
<body>
49-
<nav class="navbar navbar-expand-lg bg-dark" data-bs-theme="dark">
50+
<body data-bs-theme="<?= USER_THEME_MODE ?>">
51+
<nav class="navbar navbar-expand-lg bg-dark fixed-top" data-bs-theme="dark">
5052
<div class="container-fluid">
5153
<a class="navbar-brand" href="?page=home">
5254
<img src="images/logo-32.png"> <?= APP_NAME ?>
53-
<?= gitVersion() ?>
5455
</a>
5556
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor02" aria-controls="navbarColor02" aria-expanded="false" aria-label="Toggle navigation">
5657
<span class="navbar-toggler-icon"></span>
@@ -91,9 +92,6 @@
9192
<li class="nav-item <?= !$settingsTable['uiHeaderHelp'] ? 'd-none' : '' ?>">
9293
<a class="nav-link <?= $page == 'help' ? 'active' : '' ?>" href="/?page=help"><i class="far fa-question-circle"></i> <span class="me-3">Help</span></a>
9394
</li>
94-
<li class="nav-item">
95-
<a class="nav-link" href="https://github.com/Notifiarr/starrproxy" target="_blank"><i class="fab fa-github"></i> <span class="me-3">Github</span></a>
96-
</li>
9795
</ul>
9896
</div>
9997
</div>

root/app/www/public/index.php

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,20 @@
1919
require ABSOLUTE_PATH . 'includes/header.php';
2020

2121
?>
22-
<div class="row w-100 m-5">
23-
<ol class="breadcrumb">
24-
<li class="breadcrumb-item <?= !$page || $page == 'home' ? 'active' : '' ?>"><?= $page != 'home' ? '<a href="?page=home">Home</a>' : 'Home' ?></li>
25-
<?php
26-
switch (true) {
27-
case in_array($app, StarrApps::LIST):
28-
$requiredPage = 'starr';
29-
?><li class="breadcrumb-item active"><?= ucfirst($app) ?></li><?php
30-
break;
31-
case $page:
32-
$requiredPage = $page;
33-
if ($page != 'home') {
34-
?><li class="breadcrumb-item active"><?= ucfirst($page) ?></li><?php
35-
}
36-
break;
37-
default:
38-
$requiredPage = 'home';
39-
break;
40-
}
41-
?>
42-
</ol>
22+
<div class="row w-100" style="margin: 5rem 1rem;">
23+
<?php
24+
switch (true) {
25+
case in_array($app, StarrApps::LIST):
26+
$requiredPage = 'starr';
27+
break;
28+
case $page:
29+
$requiredPage = $page;
30+
break;
31+
default:
32+
$requiredPage = 'home';
33+
break;
34+
}
35+
?>
4336
<?php require ABSOLUTE_PATH . 'pages/' . $requiredPage . '.php'; ?>
4437
</div>
4538
<?php

root/app/www/public/js/settings.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,20 @@ function bustCache(key)
3737
}
3838
});
3939
}
40-
// -------------------------------------------------------------------------------------------
40+
// -------------------------------------------------------------------------------------------
41+
function updateSetting(setting, value)
42+
{
43+
$.ajax({
44+
type: 'POST',
45+
url: 'ajax/settings.php',
46+
data: '&m=updateSetting&setting=' + setting + '&value=' + value,
47+
success: function () {
48+
if (setting == 'defaultTheme') {
49+
reload();
50+
} else {
51+
toast('Settings', 'The setting has been updated', 'success');
52+
}
53+
}
54+
});
55+
}
56+
// -------------------------------------------------------------------------------------------

root/app/www/public/loader.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,8 @@
9494
define('LOG_ROTATE_SIZE', $settingsTable['logRotationSize'] ?: $LOG_ROTATE_SIZE);
9595
define('LOG_AGE', $settingsTable['logRetentionLength'] ?: $LOG_AGE);
9696
define('BACKUP_AGE', $settingsTable['backupRetentionLength'] ?: $BACKUP_AGE);
97+
define('USER_THEME', $settingsTable['defaultTheme'] && file_exists('themes/' . $settingsTable['defaultTheme'] . '.min.css') ? $settingsTable['defaultTheme'] : 'nzblack');
98+
define('USER_THEME_MODE', $settingsTable['defaultThemeMode'] ?: 'dark');
9799

98100
define('TEMPLATE_ORDER', $settingsTable['templateOrder'] ?: 1);
101+
$themes = getThemes();
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/*
4+
----------------------------------
5+
------ Created: 022826 ------
6+
------ Austin Best ------
7+
----------------------------------
8+
*/
9+
10+
//-- RESET THE LIST
11+
$q = [];
12+
13+
$settings = [
14+
'defaultTheme' => 'nzblack'
15+
];
16+
17+
$settingRows = [];
18+
foreach ($settings as $key => $val) {
19+
$settingRows[] = "('" . $key . "', '" . $val . "')";
20+
}
21+
22+
$q[] = "INSERT INTO " . SETTINGS_TABLE . "
23+
(`name`, `value`)
24+
VALUES " . implode(', ', $settingRows);
25+
26+
//-- ALWAYS NEED TO BUMP THE MIGRATION ID
27+
$q[] = "UPDATE " . SETTINGS_TABLE . "
28+
SET value = '008'
29+
WHERE name = 'migration'";
30+
31+
foreach ($q as $query) {
32+
logger(MIGRATION_LOG, ['text' => '<span class="text-success">[Q]</span> ' . preg_replace('!\s+!', ' ', $query)]);
33+
34+
$proxyDb->query($query);
35+
36+
if ($proxyDb->error() != 'not an error') {
37+
logger(MIGRATION_LOG, ['text' => '<span class="text-info">[R]</span> ' . $proxyDb->error()]);
38+
} else {
39+
logger(MIGRATION_LOG, ['text' => '<span class="text-info">[R]</span> query applied!']);
40+
}
41+
}

0 commit comments

Comments
 (0)