Files
SHiNE-server/shine-UI/js/pages/about-app-view.js

69 lines
2.7 KiB
JavaScript

import { t } from '../i18n/index.js';
import { createTopBar } from '../components/topbar.js';
import { createErrorState, createLoadingState } from '../components/feedback.js';
import { authService } from '../state.js';
import { appendAboutText } from '../services/about-app-text.js';
export const pageMeta = {
id: 'about-app-view',
get title() { return t('screens.settings_view.text_017'); },
shellMode: { scrollContainer: 'screen', scrollbar: 'auto' },
};
export function render({ navigate, chrome }) {
const screen = document.createElement('section');
screen.className = 'stack about-app-screen';
chrome?.setTopbar(createTopBar({
title: t('screens.settings_view.text_017'),
back: { label: '←', onClick: () => navigate('settings-view') },
}));
// Общая информация о ПО не зависит от доступности или владельца узла.
const software = document.createElement('div');
software.className = 'card about-app-text';
appendAboutText(software, t('screens.about_app_view.software_description'));
const server = document.createElement('section');
server.className = 'card stack';
const heading = document.createElement('h2');
heading.className = 'about-app-server-heading';
heading.textContent = t('screens.about_app_view.server_heading');
const network = document.createElement('p');
network.className = 'about-app-network';
network.textContent = t('screens.about_app_view.network_membership');
const ownerLabel = document.createElement('p');
ownerLabel.className = 'about-app-owner-label';
ownerLabel.textContent = t('screens.about_app_view.owner_label');
const description = document.createElement('div');
description.className = 'about-app-text about-app-owner';
server.append(heading, network, ownerLabel, description);
screen.append(software, server);
let disposed = false;
let requestSeq = 0;
async function load() {
const seq = ++requestSeq;
const active = () => !disposed && seq === requestSeq;
description.replaceChildren(createLoadingState());
try {
const result = await authService.ws.request('GetServerInfo', {}, 7000);
if (!active()) return;
const text = result?.payload?.aboutText;
if (typeof text !== 'string' || !text.trim()) {
description.replaceChildren(createErrorState({
title: t('screens.about_app_view.unavailable'),
text: t('screens.about_app_view.unavailable_hint'),
onRetry: load,
}));
return;
}
description.replaceChildren();
appendAboutText(description, text);
} catch {
if (active()) description.replaceChildren(createErrorState({ onRetry: load }));
}
}
screen.cleanup = () => { disposed = true; };
void load();
return screen;
}