Skip to content

Commit 378b81d

Browse files
VER cmd for web interface
1 parent af99401 commit 378b81d

4 files changed

Lines changed: 61 additions & 8 deletions

File tree

src/Commands/CommandRegistration.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,6 @@ private static void RegisterServiceCommands(CommandRouter router, ApplicationRun
751751
});
752752
}
753753

754-
755-
756754
private static void RegisterConnectionCommands(CommandRouter router, ApplicationRuntime runtime)
757755
{
758756
router.Register(new CommandMeta

src/Commands/CommandRouter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ private static Dictionary<string, string> ParseArgs(string[] parts)
129129
return dict;
130130
}
131131

132-
// В класс CommandRouter добавить:
133-
132+
134133
public string GetHelpJson()
135134
{
136135
var commands = _meta.Values

src/wwwroot/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,6 @@ <h3 id="settings-title" style="margin:0; color:#333;">⚙️ Settings</h3>
10051005
</div>
10061006
</div>
10071007

1008-
10091008
<script src="i18n.js"></script>
10101009
<script src="autocomplete.js"></script>
10111010
<script src="script.js"></script>

src/wwwroot/script.js

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ function init() {
261261
initTouchHandlers();
262262
connectWebSocket();
263263
requestSystemInfo();
264+
fetchVersion();
264265

265266
startAgeUpdateTimer();
266267

@@ -591,6 +592,17 @@ function handleCommandResponse(line) {
591592
if (status === 'OK') {
592593
showCommandStatus(`${cmdId}: OK`, 'success');
593594

595+
596+
if (cmdId === 'VER') {
597+
const verPart = parts.find(p => p.startsWith('version='));
598+
if (verPart) {
599+
appVersion = verPart.split('=')[1];
600+
console.log('[VER] Получена версия:', appVersion);
601+
updateFooterVersion();
602+
}
603+
return;
604+
}
605+
594606
if (cmdId === 'CNA?') {
595607
const active = parts.find(p => p.startsWith('active='))?.split('=')[1];
596608
if (!systemInfo) systemInfo = {};
@@ -813,7 +825,7 @@ function updateControlButtons() {
813825
// Кнопка соединения — всегда enabled
814826
if (btnConnection && connText) {
815827
btnConnection.disabled = false;
816-
if (systemInfo.connectionActive) {
828+
if (systemInfo && systemInfo.connectionActive) { // <-- проверка на null
817829
connText.textContent = i18n.t('close');
818830
btnConnection.className = 'ctrl-btn disconnect';
819831
btnConnection.querySelector('.btn-icon').textContent = '🔌';
@@ -826,8 +838,8 @@ function updateControlButtons() {
826838

827839
// Кнопка опроса — enabled только когда соединение активно
828840
if (btnInterrogation && interText) {
829-
btnInterrogation.disabled = !systemInfo.connectionActive;
830-
if (systemInfo.interrogationActive) {
841+
btnInterrogation.disabled = !(systemInfo && systemInfo.connectionActive); // <-- проверка
842+
if (systemInfo && systemInfo.interrogationActive) { // <-- проверка
831843
interText.textContent = i18n.t('pause');
832844
btnInterrogation.className = 'ctrl-btn stop';
833845
btnInterrogation.querySelector('.btn-icon').textContent = '⏸';
@@ -2626,6 +2638,51 @@ function applySuggestionText(input, text, isCommand) {
26262638
input.setSelectionRange(input.value.length, input.value.length);
26272639
}
26282640

2641+
// ========== ВЕРСИЯ ПРИЛОЖЕНИЯ ==========
2642+
2643+
let appVersion = '';
2644+
let versionFetched = false;
2645+
2646+
function fetchVersion() {
2647+
if (versionFetched) return;
2648+
2649+
if (!ws || ws.readyState === WebSocket.CONNECTING) {
2650+
console.log('[VER] WS в состоянии CONNECTING, ждём...');
2651+
setTimeout(fetchVersion, 500);
2652+
return;
2653+
}
2654+
2655+
if (ws.readyState !== WebSocket.OPEN) {
2656+
console.log('[VER] WS не открыт (state=' + ws.readyState + ')');
2657+
return;
2658+
}
2659+
2660+
versionFetched = true;
2661+
console.log('[VER] Отправляем VER');
2662+
ws.send('VER');
2663+
addLogEntry('>> VER');
2664+
}
2665+
2666+
function updateFooterVersion() {
2667+
const footer = document.getElementById('footer-panel');
2668+
if (!footer) return;
2669+
2670+
if (document.getElementById('app-version')) return;
2671+
2672+
const copyrightDiv = footer.querySelector('div:last-child');
2673+
if (!copyrightDiv) return;
2674+
2675+
const versionLink = document.createElement('a');
2676+
versionLink.id = 'app-version';
2677+
versionLink.href = 'https://github.com/ucnl/AzimuthConsole/blob/main/src/changelog.md';
2678+
versionLink.target = '_blank';
2679+
versionLink.rel = 'noopener';
2680+
versionLink.style.cssText = 'color: #4a90e2; text-decoration: none; font-weight: bold; margin-right: 6px;';
2681+
versionLink.title = 'История изменений';
2682+
versionLink.textContent = `${appVersion}`;
2683+
2684+
copyrightDiv.insertBefore(versionLink, copyrightDiv.firstChild);
2685+
}
26292686

26302687

26312688

0 commit comments

Comments
 (0)