fix: Update Hub API returns full response object (v0.6.0-r6)
Fix hub update failing in wizard:
- Change updateHub API expect from {success: false} to {}
- Returns full response object {success: true, message: "..."}
- Wizard can now properly check result.success
- Enables getCollections() call after successful update
Issue: Hub update showed "Hub update failed" despite success
Cause: RPC expect field extracted only boolean value instead of full object
Solution: Remove expect field to return complete response
Frontend Changes:
- htdocs/luci-static/resources/crowdsec-dashboard/api.js
- callUpdateHub: Change expect: {success: false} to expect: {}
- htdocs/luci-static/resources/view/crowdsec-dashboard/wizard.js
- Add comprehensive error logging and catch handler
- Better error messages with error.message details
Backend Returns:
{"success": true, "message": "Hub index updated successfully"}
Version: 0.6.0-6
🤖 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
aefc6e5265
commit
be3a367e18
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-crowdsec-dashboard
|
||||
PKG_VERSION:=0.6.0
|
||||
PKG_RELEASE:=5
|
||||
PKG_RELEASE:=6
|
||||
PKG_ARCH:=all
|
||||
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
|
||||
@ -128,7 +128,7 @@ var callRemoveCollection = rpc.declare({
|
||||
var callUpdateHub = rpc.declare({
|
||||
object: 'luci.crowdsec-dashboard',
|
||||
method: 'update_hub',
|
||||
expect: { success: false }
|
||||
expect: { }
|
||||
});
|
||||
|
||||
var callRegisterBouncer = rpc.declare({
|
||||
|
||||
@ -137,9 +137,12 @@ return view.extend({
|
||||
},
|
||||
|
||||
renderStep1: function(data) {
|
||||
console.log('[Wizard] renderStep1 data:', data);
|
||||
var status = data ? data.status : {};
|
||||
console.log('[Wizard] status:', status);
|
||||
var crowdsecRunning = status && status.crowdsec === 'running';
|
||||
var lapiAvailable = status && status.lapi_status === 'available';
|
||||
console.log('[Wizard] crowdsecRunning:', crowdsecRunning, 'lapiAvailable:', lapiAvailable);
|
||||
|
||||
return E('div', { 'class': 'wizard-step' }, [
|
||||
E('h2', {}, _('Welcome to CrowdSec Setup')),
|
||||
@ -185,8 +188,13 @@ return view.extend({
|
||||
}, _('Cancel')),
|
||||
E('button', {
|
||||
'class': 'cbi-button cbi-button-positive',
|
||||
'disabled': !crowdsecRunning || !lapiAvailable,
|
||||
'click': L.bind(this.goToStep, this, 2)
|
||||
'disabled': (!crowdsecRunning || !lapiAvailable) ? true : null,
|
||||
'click': L.bind(function(ev) {
|
||||
console.log('[Wizard] Next button clicked!');
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
this.goToStep(2);
|
||||
}, this)
|
||||
}, _('Next →'))
|
||||
])
|
||||
]);
|
||||
@ -537,10 +545,12 @@ return view.extend({
|
||||
},
|
||||
|
||||
handleUpdateHub: function() {
|
||||
console.log('[Wizard] handleUpdateHub called');
|
||||
this.wizardData.hubUpdating = true;
|
||||
this.refreshView();
|
||||
|
||||
return API.updateHub().then(L.bind(function(result) {
|
||||
console.log('[Wizard] updateHub result:', result);
|
||||
this.wizardData.hubUpdating = false;
|
||||
this.wizardData.hubUpdated = result.success;
|
||||
|
||||
@ -549,12 +559,20 @@ return view.extend({
|
||||
return API.getCollections();
|
||||
} else {
|
||||
ui.addNotification(null, E('p', result.error || _('Hub update failed')), 'error');
|
||||
return null;
|
||||
}
|
||||
}, this)).then(L.bind(function(collections) {
|
||||
console.log('[Wizard] getCollections result:', collections);
|
||||
if (collections) {
|
||||
this.wizardData.collections = collections;
|
||||
}
|
||||
this.refreshView();
|
||||
}, this)).catch(L.bind(function(error) {
|
||||
console.error('[Wizard] Hub update error:', error);
|
||||
this.wizardData.hubUpdating = false;
|
||||
this.wizardData.hubUpdated = false;
|
||||
ui.addNotification(null, E('p', _('Hub update failed: ') + error.message), 'error');
|
||||
this.refreshView();
|
||||
}, this));
|
||||
},
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user