#19: add help tab, allow to set the help URL with the HELP_URL capability

This commit is contained in:
andreas 2022-03-02 11:23:31 +01:00
parent 785ece971e
commit a288959009
5 changed files with 17 additions and 2 deletions

View File

@ -129,4 +129,7 @@ class GwApi{
#ifndef DECLARE_CAPABILITY
#define DECLARE_CAPABILITY(name,value)
#endif
#ifndef DECLARE_STRING_CAPABILITY
#define DECLARE_STRING_CAPABILITY(name,value)
#endif
#endif

View File

@ -46,4 +46,6 @@ DECLARE_CAPABILITY(testboard2,true);
//hide some config value
//just set HIDE + the name of the config item to true
DECLARE_CAPABILITY(HIDEminXdrInterval,true);
DECLARE_STRING_CAPABILITY(HELP_URL,"https://www.wellenvogel.de");
#endif

View File

@ -41,7 +41,8 @@ class GwUserCapability{
#define DECLARE_USERTASK(task) GwUserTaskDef __##task##__(task,#task);
#define DECLARE_USERTASK_PARAM(task,...) GwUserTaskDef __##task##__(task,#task,__VA_ARGS__);
#define DECLARE_INITFUNCTION(task) GwInitTask __Init##task##__(task,#task);
#define DECLARE_CAPABILITY(name,value) GwUserCapability __CAP##name##__(#name,#value);
#define DECLARE_CAPABILITY(name,value) GwUserCapability __CAP##name##__(#name,#value);
#define DECLARE_STRING_CAPABILITY(name,value) GwUserCapability __CAP##name##__(#name,value);
#include "GwApi.h"
#include "GwUserTasks.h"
class TaskApi : public GwApi

View File

@ -21,6 +21,7 @@
<div class="tab" data-page="xdrPage">XDR</div>
<div class="tab" data-page="dashboardPage">Data</div>
<div class="tab" data-page="updatePage">Update</div>
<div class="tab" data-url="https://github.com/wellenvogel/esp32-nmea2000" data-window="help" id="helpButton">Help</div>
</div>
<div id="statusPage" class="tabPage">
<div id="statusPageContent">

View File

@ -1073,6 +1073,10 @@ function createConfigDefinitions(parent, capabilities, defs,includeXdr) {
function loadConfigDefinitions() {
getJson("api/capabilities")
.then(function (capabilities) {
if (capabilities.HELP_URL){
let el=document.getElementById('helpButton');
if (el) el.setAttribute('data-url',capabilities.HELP_URL);
}
getJson("config.json")
.then(function (defs) {
getJson("xdrconfig.json")
@ -1191,7 +1195,11 @@ function converterInfo() {
}
function handleTab(el) {
let activeName = el.getAttribute('data-page');
if (!activeName) return;
if (!activeName) {
let extUrl= el.getAttribute('data-url');
if (! extUrl) return;
window.open(extUrl,el.getAttribute('data-window')||'_');
}
let activeTab = document.getElementById(activeName);
if (!activeTab) return;
let all = document.querySelectorAll('.tabPage');