fix(client-guardian): correct API module imports in logs and alerts views
- Changed from L.require('client-guardian.api') to 'require client-guardian/api as API'
- Updated all api. references to API. in both files
- Resolves "api.getLogs is not a function" and "api.getAlerts is not a function" errors
The L.require() pattern doesn't work properly with async module loading in LuCI.
Using the proper 'require' directive ensures the module is loaded correctly.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
829aa1d399
commit
c8b261ea5a
@ -6,14 +6,13 @@
|
||||
'require uci';
|
||||
'require rpc';
|
||||
'require ui';
|
||||
|
||||
var api = L.require('client-guardian.api');
|
||||
'require client-guardian/api as API';
|
||||
|
||||
return view.extend({
|
||||
load: function() {
|
||||
return Promise.all([
|
||||
api.getAlerts(),
|
||||
api.getLogs(20, null)
|
||||
API.getAlerts(),
|
||||
API.getLogs(20, null)
|
||||
]);
|
||||
},
|
||||
|
||||
@ -216,7 +215,7 @@ return view.extend({
|
||||
E('div', { 'class': 'spinning' })
|
||||
]);
|
||||
|
||||
api.sendTestAlert('email').then(function(result) {
|
||||
API.sendTestAlert('email').then(function(result) {
|
||||
ui.hideModal();
|
||||
if (result.success) {
|
||||
ui.addNotification(null, E('p', {}, '✅ Email de test envoyé avec succès!'), 'success');
|
||||
@ -232,7 +231,7 @@ return view.extend({
|
||||
E('div', { 'class': 'spinning' })
|
||||
]);
|
||||
|
||||
api.sendTestAlert('sms').then(function(result) {
|
||||
API.sendTestAlert('sms').then(function(result) {
|
||||
ui.hideModal();
|
||||
if (result.success) {
|
||||
ui.addNotification(null, E('p', {}, '✅ SMS de test envoyé avec succès!'), 'success');
|
||||
|
||||
@ -4,14 +4,13 @@
|
||||
'require dom';
|
||||
'require poll';
|
||||
'require ui';
|
||||
|
||||
var api = L.require('client-guardian.api');
|
||||
'require client-guardian/api as API';
|
||||
|
||||
return view.extend({
|
||||
refreshInterval: 5000,
|
||||
|
||||
load: function() {
|
||||
return api.getLogs(100, null);
|
||||
return API.getLogs(100, null);
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
@ -170,7 +169,7 @@ return view.extend({
|
||||
E('div', { 'class': 'spinning' })
|
||||
]);
|
||||
|
||||
api.getLogs(limit, null).then(function(data) {
|
||||
API.getLogs(limit, null).then(function(data) {
|
||||
var container = document.getElementById('logs-container');
|
||||
var logs = data.logs || [];
|
||||
|
||||
@ -192,7 +191,7 @@ return view.extend({
|
||||
var self = this;
|
||||
var limit = parseInt(document.getElementById('filter-limit')?.value || 100);
|
||||
|
||||
return api.getLogs(limit, null).then(function(data) {
|
||||
return API.getLogs(limit, null).then(function(data) {
|
||||
var container = document.getElementById('logs-container');
|
||||
if (!container) return;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user