fix(client-guardian): correct API method names in all views
Fixed inconsistency between API method declarations and their usage. The api.js exports methods with names like getClients, getStatus, etc. but views were calling them as callClients, callStatus, etc. Changes across 7 view files: - api.callStatus() → api.getStatus() - api.callClients() → api.getClients() - api.callZones() → api.getZones() - api.callGetAlerts() → api.getAlerts() - api.callGetLogs() → api.getLogs() - api.callParental() → api.getParental() - api.callPortal() → api.getPortal() - api.callApproveClient() → api.approveClient() - api.callUpdateClient() → api.updateClient() - api.callBanClient() → api.banClient() - api.callQuarantineClient() → api.quarantineClient() - api.callSendTestAlert() → api.sendTestAlert() - api.callUpdatePortal() → api.updatePortal() - api.callUpdateZone() → api.updateZone() This fixes TypeError: api.callClients is not a function errors. 🤖 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
9cee74064c
commit
9177bbbfdf
@ -12,8 +12,8 @@ var api = L.require('client-guardian.api');
|
||||
return view.extend({
|
||||
load: function() {
|
||||
return Promise.all([
|
||||
api.callGetAlerts(),
|
||||
api.callGetLogs(20, null)
|
||||
api.getAlerts(),
|
||||
api.getLogs(20, null)
|
||||
]);
|
||||
},
|
||||
|
||||
@ -216,7 +216,7 @@ return view.extend({
|
||||
E('div', { 'class': 'spinning' })
|
||||
]);
|
||||
|
||||
api.callSendTestAlert('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 +232,7 @@ return view.extend({
|
||||
E('div', { 'class': 'spinning' })
|
||||
]);
|
||||
|
||||
api.callSendTestAlert('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');
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
return view.extend({
|
||||
load: function() {
|
||||
return Promise.all([
|
||||
api.callClients(),
|
||||
api.callZones()
|
||||
api.getClients(),
|
||||
api.getZones()
|
||||
]);
|
||||
},
|
||||
|
||||
@ -192,7 +192,7 @@ return view.extend({
|
||||
var name = document.getElementById('approve-name').value;
|
||||
var zone = document.getElementById('approve-zone').value;
|
||||
var notes = document.getElementById('approve-notes').value;
|
||||
api.callApproveClient(mac, name, zone, notes).then(function() {
|
||||
api.approveClient(mac, name, zone, notes).then(function() {
|
||||
ui.hideModal();
|
||||
window.location.reload();
|
||||
});
|
||||
@ -230,7 +230,7 @@ return view.extend({
|
||||
E('div', { 'class': 'cg-btn-group', 'style': 'justify-content: flex-end' }, [
|
||||
E('button', { 'class': 'cg-btn', 'click': ui.hideModal }, _('Annuler')),
|
||||
E('button', { 'class': 'cg-btn cg-btn-primary', 'click': function() {
|
||||
api.callUpdateClient(
|
||||
api.updateClient(
|
||||
client.section,
|
||||
document.getElementById('edit-name').value,
|
||||
document.getElementById('edit-zone').value,
|
||||
@ -260,7 +260,7 @@ return view.extend({
|
||||
E('button', { 'class': 'cg-btn', 'click': ui.hideModal }, _('Annuler')),
|
||||
E('button', { 'class': 'cg-btn cg-btn-danger', 'click': function() {
|
||||
var reason = document.getElementById('ban-reason').value || 'Manual ban';
|
||||
api.callBanClient(mac, reason).then(function() {
|
||||
api.banClient(mac, reason).then(function() {
|
||||
ui.hideModal();
|
||||
window.location.reload();
|
||||
});
|
||||
@ -271,7 +271,7 @@ return view.extend({
|
||||
|
||||
handleUnban: function(ev) {
|
||||
var mac = ev.currentTarget.dataset.mac;
|
||||
api.callQuarantineClient(mac).then(function() {
|
||||
api.quarantineClient(mac).then(function() {
|
||||
window.location.reload();
|
||||
});
|
||||
},
|
||||
|
||||
@ -11,7 +11,7 @@ return view.extend({
|
||||
refreshInterval: 5000,
|
||||
|
||||
load: function() {
|
||||
return api.callGetLogs(100, null);
|
||||
return api.getLogs(100, null);
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
@ -170,7 +170,7 @@ return view.extend({
|
||||
E('div', { 'class': 'spinning' })
|
||||
]);
|
||||
|
||||
api.callGetLogs(limit, null).then(function(data) {
|
||||
api.getLogs(limit, null).then(function(data) {
|
||||
var container = document.getElementById('logs-container');
|
||||
var logs = data.logs || [];
|
||||
|
||||
@ -192,7 +192,7 @@ return view.extend({
|
||||
var self = this;
|
||||
var limit = parseInt(document.getElementById('filter-limit')?.value || 100);
|
||||
|
||||
return api.callGetLogs(limit, null).then(function(data) {
|
||||
return api.getLogs(limit, null).then(function(data) {
|
||||
var container = document.getElementById('logs-container');
|
||||
if (!container) return;
|
||||
|
||||
|
||||
@ -10,9 +10,9 @@
|
||||
return view.extend({
|
||||
load: function() {
|
||||
return Promise.all([
|
||||
api.callStatus(),
|
||||
api.callClients(),
|
||||
api.callZones()
|
||||
api.getStatus(),
|
||||
api.getClients(),
|
||||
api.getZones()
|
||||
]);
|
||||
},
|
||||
|
||||
@ -178,7 +178,7 @@ return view.extend({
|
||||
'class': 'cg-btn cg-btn-success',
|
||||
'click': function() {
|
||||
var zone = document.getElementById('approve-zone').value;
|
||||
api.callApproveClient(mac, '', zone, '').then(function() {
|
||||
api.approveClient(mac, '', zone, '').then(function() {
|
||||
ui.hideModal();
|
||||
window.location.reload();
|
||||
});
|
||||
@ -202,7 +202,7 @@ return view.extend({
|
||||
E('button', {
|
||||
'class': 'cg-btn cg-btn-danger',
|
||||
'click': function() {
|
||||
api.callBanClient(mac, 'Manual ban').then(function() {
|
||||
api.banClient(mac, 'Manual ban').then(function() {
|
||||
ui.hideModal();
|
||||
window.location.reload();
|
||||
});
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
return view.extend({
|
||||
load: function() {
|
||||
return api.callParental();
|
||||
return api.getParental();
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
return view.extend({
|
||||
load: function() {
|
||||
return api.callPortal();
|
||||
return api.getPortal();
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
@ -202,7 +202,7 @@ return view.extend({
|
||||
var password = document.getElementById('portal-password').value;
|
||||
var color = document.getElementById('portal-color').value;
|
||||
|
||||
api.callUpdatePortal(title, subtitle, color, auth, password).then(function(res) {
|
||||
api.updatePortal(title, subtitle, color, auth, password).then(function(res) {
|
||||
if (res.success) {
|
||||
ui.addNotification(null, E('p', {}, _('Configuration du portail enregistrée')), 'success');
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
return view.extend({
|
||||
load: function() {
|
||||
return api.callZones();
|
||||
return api.getZones();
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
@ -154,7 +154,7 @@ return view.extend({
|
||||
E('div', { 'class': 'cg-btn-group', 'style': 'justify-content: flex-end; margin-top: 20px' }, [
|
||||
E('button', { 'class': 'cg-btn', 'click': ui.hideModal }, _('Annuler')),
|
||||
E('button', { 'class': 'cg-btn cg-btn-primary', 'click': function() {
|
||||
api.callUpdateZone(
|
||||
api.updateZone(
|
||||
zone.id,
|
||||
zone.name,
|
||||
parseInt(document.getElementById('zone-bandwidth').value) || 0,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user