Skip to content

Commit

Permalink
change images
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziedelth committed Dec 13, 2024
1 parent 88d76eb commit 2baf785
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 106 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="src/main/resources/assets/img/dark_logo.png" alt="Shikkanime dark logo">
<img src="src/main/resources/assets/img/dark_icon.webp" width="128" height="128" alt="Shikkanime dark logo">
<br>
<a href="#getting-started">Getting Started</a> •
<a href="https://www.shikkanime.fr">Website</a> •
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ package fr.shikkanime.converters.metric
import fr.shikkanime.converters.AbstractConverter
import fr.shikkanime.dtos.MetricDto
import fr.shikkanime.entities.Metric
import fr.shikkanime.utils.withUTC
import java.time.format.DateTimeFormatter
import fr.shikkanime.utils.withUTCString

class MetricToMetricDtoConverter : AbstractConverter<Metric, MetricDto>() {
private val dateFormatter = DateTimeFormatter.ofPattern("HH:mm:ssZ")

@Converter
fun convert(from: Metric): MetricDto {
return MetricDto(
uuid = from.uuid,
cpuLoad = (from.cpuLoad * 100).toString().replace(',', '.'),
memoryUsage = (from.memoryUsage / 1024.0 / 1024.0).toString().replace(',', '.'),
date = from.date.withUTC().format(dateFormatter)
date = from.date.withUTCString()
)
}
}
Binary file removed src/main/resources/assets/img/dark_banner.png
Binary file not shown.
Binary file added src/main/resources/assets/img/dark_banner.webp
Binary file not shown.
Binary file added src/main/resources/assets/img/dark_icon.webp
Binary file not shown.
Binary file removed src/main/resources/assets/img/dark_logo.png
Binary file not shown.
Binary file modified src/main/resources/assets/img/light_banner.webp
Binary file not shown.
Binary file added src/main/resources/assets/img/light_icon.webp
Binary file not shown.
103 changes: 25 additions & 78 deletions src/main/resources/assets/js/home_chart.js
Original file line number Diff line number Diff line change
@@ -1,102 +1,49 @@
const hoursElement = document.getElementById('hours');
const datemenuElement = document.getElementById('datemenu');
const cpuChartElement = document.getElementById('cpuLoadChart').getContext('2d');
const memoryChartElement = document.getElementById('memoryUsageChart').getContext('2d');

const cpuChart = new Chart(cpuChartElement, {
const chartConfig = (label, unit) => ({
type: 'line',
data: {
labels: [],
datasets: [
{
label: '% CPU',
data: [],
fill: false,
borderColor: ['rgba(33,37,41, 1)'],
tension: 0.1
}
]
},
data: { labels: [], datasets: [{ label, data: [], fill: false, borderColor: 'rgba(33,37,41, 1)', tension: 0.1 }] },
options: {
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true
}
},
elements: {
point: {
radius: 0
}
},
animation: {
duration: 0
},
plugins: {
legend: {
display: false
}
}
scales: { x: { type: 'time', time: { unit } }, y: { beginAtZero: true } },
elements: { point: { radius: 0 } },
animation: { duration: 0 },
plugins: { legend: { display: false } }
}
});

const memoryChart = new Chart(memoryChartElement, {
type: 'line',
data: {
labels: [],
datasets: [
{
label: 'RAM in MB',
data: [],
fill: false,
borderColor: ['rgba(33,37,41, 1)'],
tension: 0.1
}
]
},
options: {
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true
}
},
elements: {
point: {
radius: 0
}
},
animation: {
duration: 0
},
plugins: {
legend: {
display: false
}
}
}
});
const cpuChart = new Chart(cpuChartElement, chartConfig('% CPU', 'hour'));
const memoryChart = new Chart(memoryChartElement, chartConfig('RAM in MB', 'hour'));

document.addEventListener('DOMContentLoaded', async () => {
await setChartData();

setInterval(async () => {
datemenuElement.addEventListener('change', async () => {
await setChartData();
}, 10000);
});
});

async function getMetrics() {
return await axios.get('/api/metrics?hours=' + hoursElement.value)
.then(response => response.data);
return (await axios.get('/api/metrics?hours=' + datemenuElement.value)).data;
}

async function setChartData() {
const data = await getMetrics();

cpuChart.data.labels = data.map(metric => metric.date);
cpuChart.data.datasets[0].data = data.map(metric => metric.cpuLoad);
cpuChart.update();
const updateChart = (chart, dataKey) => {
if (datemenuElement.value > 24) {
chart.options.scales.x.time.unit = 'day';
} else {
chart.options.scales.x.time.unit = 'hour';
}

chart.data.labels = data.map(metric => metric.date);
chart.data.datasets[0].data = data.map(metric => metric[dataKey]);
chart.update();
};

memoryChart.data.labels = data.map(metric => metric.date);
memoryChart.data.datasets[0].data = data.map(metric => metric.memoryUsage);
memoryChart.update();
updateChart(cpuChart, 'cpuLoad');
updateChart(memoryChart, 'memoryUsage');
}
4 changes: 2 additions & 2 deletions src/main/resources/templates/admin/_navigation.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<div class="d-flex flex-column flex-shrink-0 p-3 bg-light shadow">
<a href="/admin/dashboard"
class="d-flex align-items-center mb-md-0 me-md-auto link-dark text-decoration-none">
<img src="/assets/img/dark_banner.png" width="200" height="44" crossorigin="anonymous"
<img src="/assets/img/dark_banner.webp" width="200" height="44" crossorigin="anonymous"
class="img-fluid d-none d-md-inline-block" alt="Shikkanime dark banner">

<img src="/assets/img/dark_logo.png" width="44" height="44" crossorigin="anonymous"
<img src="/assets/img/dark_icon.webp" width="44" height="44" crossorigin="anonymous"
class="img-fluid d-block d-md-none" alt="Shikkanime dark logo">
</a>
<hr>
Expand Down
37 changes: 20 additions & 17 deletions src/main/resources/templates/admin/dashboard.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@
<div class="container-fluid d-flex">
<div class="row g-3 align-items-center mb-3">
<div class="col-auto">
<label class="col-form-label" for="hours">Hours</label>
</div>
<div class="col-auto">
<select class="form-select" id="hours">
<option value="1" selected>1</option>
<option value="3">3</option>
<option value="6">6</option>
<option value="12">12</option>
<option value="24">24</option>
<option value="48">48</option>
<select class="form-select" id="datemenu">
<option value="1" selected>Last hour</option>
<option value="24">Last 24 hours</option>
<option value="168">Last 7 days</option>
</select>
</div>
</div>
Expand Down Expand Up @@ -44,10 +38,13 @@

<div class="col-md-6">
<div class="card p-3">
<div class="d-flex mb-4">
<div class="d-flex flex-column flex-md-row mb-3 mb-md-4 justify-content-center">
<h4 class="card-title">Simulcasts</h4>
<a id="simulcasts-invalidate" href="/admin/simulcasts-invalidate"
class="btn btn-danger ms-auto me-0">Invalidate</a>

<div class="ms-md-auto me-md-0">
<a id="simulcasts-invalidate" href="/admin/simulcasts-invalidate"
class="btn btn-danger">Invalidate</a>
</div>
</div>

<ul class="list-group list-group-numbered">
Expand Down Expand Up @@ -76,10 +73,13 @@

<div class="col-md-6">
<div class="card p-3">
<div class="d-flex mb-4">
<div class="d-flex flex-column flex-md-row mb-3 mb-md-4 justify-content-center">
<h4 class="card-title">Images</h4>
<a id="images-invalidate" href="/admin/images-invalidate" class="btn btn-danger ms-auto me-0">Invalidate</a>
<a href="/admin/images-save" class="btn btn-success ms-2 me-0">Save</a>

<div class="ms-md-auto me-md-0">
<a id="images-invalidate" href="/admin/images-invalidate" class="btn btn-danger">Invalidate</a>
<a href="/admin/images-save" class="btn btn-success">Save</a>
</div>
</div>

<div class="row g-3">
Expand All @@ -106,6 +106,9 @@
</div>
</div>

<script src="https://cdn.jsdelivr.net/npm/chart.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/moment@^2"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-moment@^1"></script>

<script src="/assets/js/home_chart.js" crossorigin="anonymous"></script>
</@navigation.display>
2 changes: 1 addition & 1 deletion src/main/resources/templates/admin/login.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="w-100 d-flex align-items-center justify-content-center">
<div class="d-block card p-5">
<div class="text-center mb-5">
<img src="/assets/img/dark_banner.png" width="400" height="88" crossorigin="anonymous"
<img src="/assets/img/dark_banner.webp" width="400" height="88" crossorigin="anonymous"
class="img-fluid">
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/mail/_layout.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<td style="vertical-align: top; text-align: center;">
<div style="display: inline-block; max-width: 800px; width: 100%; margin: 50px 10px; background-color: #ffffff; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); padding: 20px; box-sizing: border-box;">
<a href="${baseUrl}">
<img src="${baseUrl}/assets/img/dark_banner.png"
<img src="${baseUrl}/assets/img/dark_banner.webp"
alt="Illustration"
style="width: 100%; max-width: 400px; height: auto; margin-bottom: 20px;">
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/site/_navigation.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<div class="col-md-4 d-flex align-items-center">
<div>
<a href="/" class="mb-3 me-2 mb-md-0 text-muted text-decoration-none lh-1">
<img src="/assets/img/favicons/favicon-64x64.png" alt="Shikkanime" width="24" height="24">
<img src="/assets/img/light_icon.webp" alt="Shikkanime" width="24" height="24">
</a>

<#if seoDescription?? && seoDescription?length != 0>
Expand Down

0 comments on commit 2baf785

Please sign in to comment.