secubox-openwrt/package/secubox/luci-app-secubox-p2p/htdocs/luci-static/resources/view/secubox-p2p/services.js
CyberMind-FR 2b913d5005 feat(p2p): Add SecuBox P2P Hub packages and Services Registry
- Add secubox-p2p backend package:
  - UCI configuration for P2P settings, DNS federation, WireGuard mesh, HAProxy
  - RPCD handler for peer management, service discovery, mesh configuration
  - Init script and main P2P manager daemon

- Add luci-app-secubox-p2p frontend package:
  - Main hub view with master control, network matrix visualization
  - Peers management with discovery and manual add
  - Services view showing local and shared services
  - Mesh network configuration (DNS, WireGuard, HAProxy)
  - Settings for P2P and registry configuration

- Add Services Registry view to luci-app-secubox
- Add listProfiles/applyProfile to secubox-admin API
- Fix P2P ACL permissions
- Remove old hub.js from luci-app-secubox (moved to dedicated package)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 19:46:28 +01:00

71 lines
2.0 KiB
JavaScript

'use strict';
'require view';
'require ui';
'require secubox-p2p/api as P2PAPI';
return view.extend({
services: [],
sharedServices: [],
load: function() {
var self = this;
return Promise.all([
P2PAPI.getServices(),
P2PAPI.getSharedServices()
]).then(function(results) {
self.services = results[0].services || [];
self.sharedServices = results[1].shared_services || [];
return {};
}).catch(function() { return {}; });
},
render: function() {
var self = this;
return E('div', { 'class': 'cbi-map' }, [
E('h2', {}, 'P2P Services'),
E('div', { 'class': 'cbi-section' }, [
E('h3', {}, 'Local Services'),
E('table', { 'class': 'table' }, [
E('tr', { 'class': 'tr table-titles' }, [
E('th', { 'class': 'th' }, 'Service'),
E('th', { 'class': 'th' }, 'Port'),
E('th', { 'class': 'th' }, 'Protocol'),
E('th', { 'class': 'th' }, 'Status')
])
].concat(this.services.map(function(svc) {
return E('tr', { 'class': 'tr' }, [
E('td', { 'class': 'td' }, svc.name),
E('td', { 'class': 'td' }, svc.port || '-'),
E('td', { 'class': 'td' }, svc.protocol || 'tcp'),
E('td', { 'class': 'td' }, E('span', { 'style': 'color: ' + (svc.status === 'running' ? 'green' : 'red') }, svc.status))
]);
})))
]),
E('div', { 'class': 'cbi-section' }, [
E('h3', {}, 'Shared Services from Peers'),
this.sharedServices.length > 0 ?
E('table', { 'class': 'table' }, [
E('tr', { 'class': 'tr table-titles' }, [
E('th', { 'class': 'th' }, 'Service'),
E('th', { 'class': 'th' }, 'Peer'),
E('th', { 'class': 'th' }, 'Address')
])
].concat(this.sharedServices.map(function(svc) {
return E('tr', { 'class': 'tr' }, [
E('td', { 'class': 'td' }, svc.name),
E('td', { 'class': 'td' }, svc.peer || 'Unknown'),
E('td', { 'class': 'td' }, svc.address || '-')
]);
}))) :
E('p', {}, 'No shared services from peers.')
])
]);
},
handleSaveApply: null,
handleSave: null,
handleReset: null
});