fix(haproxy): Use module-level RPC declarations in api.js
Fix TypeError "haproxy.api factory yields invalid constructor" by refactoring api.js to use correct LuCI module pattern: - Define RPC calls at module level with rpc.declare() - Reference them in baseclass.extend() object - Add getDashboardData helper function at module level Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
f3fd676ad1
commit
22bd4bd445
@ -11,7 +11,7 @@ LUCI_PKGARCH:=all
|
|||||||
|
|
||||||
PKG_NAME:=luci-app-haproxy
|
PKG_NAME:=luci-app-haproxy
|
||||||
PKG_VERSION:=1.0.0
|
PKG_VERSION:=1.0.0
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
PKG_MAINTAINER:=CyberMind <contact@cybermind.fr>
|
PKG_MAINTAINER:=CyberMind <contact@cybermind.fr>
|
||||||
PKG_LICENSE:=MIT
|
PKG_LICENSE:=MIT
|
||||||
|
|||||||
@ -1,276 +1,367 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
'require baseclass';
|
||||||
'require rpc';
|
'require rpc';
|
||||||
|
|
||||||
var api = {
|
// ============================================
|
||||||
// Status
|
// Status
|
||||||
status: rpc.declare({
|
// ============================================
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'status',
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
getStats: rpc.declare({
|
var callStatus = rpc.declare({
|
||||||
object: 'luci.haproxy',
|
object: 'luci.haproxy',
|
||||||
method: 'get_stats',
|
method: 'status',
|
||||||
expect: { }
|
expect: {}
|
||||||
}),
|
});
|
||||||
|
|
||||||
|
var callGetStats = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'get_stats',
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Vhosts
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
var callListVhosts = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'list_vhosts',
|
||||||
|
expect: { vhosts: [] }
|
||||||
|
});
|
||||||
|
|
||||||
|
var callGetVhost = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'get_vhost',
|
||||||
|
params: ['id'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callCreateVhost = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'create_vhost',
|
||||||
|
params: ['domain', 'backend', 'ssl', 'ssl_redirect', 'acme', 'enabled'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callUpdateVhost = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'update_vhost',
|
||||||
|
params: ['id', 'domain', 'backend', 'ssl', 'ssl_redirect', 'acme', 'enabled'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callDeleteVhost = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'delete_vhost',
|
||||||
|
params: ['id'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Backends
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
var callListBackends = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'list_backends',
|
||||||
|
expect: { backends: [] }
|
||||||
|
});
|
||||||
|
|
||||||
|
var callGetBackend = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'get_backend',
|
||||||
|
params: ['id'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callCreateBackend = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'create_backend',
|
||||||
|
params: ['name', 'mode', 'balance', 'health_check', 'enabled'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callUpdateBackend = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'update_backend',
|
||||||
|
params: ['id', 'name', 'mode', 'balance', 'health_check', 'enabled'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callDeleteBackend = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'delete_backend',
|
||||||
|
params: ['id'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Servers
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
var callListServers = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'list_servers',
|
||||||
|
params: ['backend'],
|
||||||
|
expect: { servers: [] }
|
||||||
|
});
|
||||||
|
|
||||||
|
var callCreateServer = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'create_server',
|
||||||
|
params: ['backend', 'name', 'address', 'port', 'weight', 'check', 'enabled'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callUpdateServer = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'update_server',
|
||||||
|
params: ['id', 'backend', 'name', 'address', 'port', 'weight', 'check', 'enabled'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callDeleteServer = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'delete_server',
|
||||||
|
params: ['id'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Certificates
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
var callListCertificates = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'list_certificates',
|
||||||
|
expect: { certificates: [] }
|
||||||
|
});
|
||||||
|
|
||||||
|
var callRequestCertificate = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'request_certificate',
|
||||||
|
params: ['domain'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callImportCertificate = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'import_certificate',
|
||||||
|
params: ['domain', 'cert', 'key'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callDeleteCertificate = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'delete_certificate',
|
||||||
|
params: ['id'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// ACLs
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
var callListAcls = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'list_acls',
|
||||||
|
expect: { acls: [] }
|
||||||
|
});
|
||||||
|
|
||||||
|
var callCreateAcl = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'create_acl',
|
||||||
|
params: ['name', 'type', 'pattern', 'backend', 'enabled'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callUpdateAcl = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'update_acl',
|
||||||
|
params: ['id', 'name', 'type', 'pattern', 'backend', 'enabled'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callDeleteAcl = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'delete_acl',
|
||||||
|
params: ['id'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Redirects
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
var callListRedirects = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'list_redirects',
|
||||||
|
expect: { redirects: [] }
|
||||||
|
});
|
||||||
|
|
||||||
|
var callCreateRedirect = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'create_redirect',
|
||||||
|
params: ['name', 'match_host', 'target_host', 'strip_www', 'code', 'enabled'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callDeleteRedirect = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'delete_redirect',
|
||||||
|
params: ['id'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Settings
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
var callGetSettings = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'get_settings',
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callSaveSettings = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'save_settings',
|
||||||
|
params: ['main', 'defaults', 'acme'],
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Service Control
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
var callInstall = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'install',
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callStart = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'start',
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callStop = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'stop',
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callRestart = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'restart',
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callReload = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'reload',
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callGenerate = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'generate',
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callValidate = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'validate',
|
||||||
|
expect: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callGetLogs = rpc.declare({
|
||||||
|
object: 'luci.haproxy',
|
||||||
|
method: 'get_logs',
|
||||||
|
params: ['lines'],
|
||||||
|
expect: { logs: '' }
|
||||||
|
});
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Helper Functions
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
function getDashboardData() {
|
||||||
|
return Promise.all([
|
||||||
|
callStatus(),
|
||||||
|
callListVhosts(),
|
||||||
|
callListBackends(),
|
||||||
|
callListCertificates()
|
||||||
|
]).then(function(results) {
|
||||||
|
return {
|
||||||
|
status: results[0],
|
||||||
|
vhosts: results[1].vhosts || [],
|
||||||
|
backends: results[2].backends || [],
|
||||||
|
certificates: results[3].certificates || []
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Module Export
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
return baseclass.extend({
|
||||||
|
// Status
|
||||||
|
status: callStatus,
|
||||||
|
getStats: callGetStats,
|
||||||
|
|
||||||
// Vhosts
|
// Vhosts
|
||||||
listVhosts: rpc.declare({
|
listVhosts: callListVhosts,
|
||||||
object: 'luci.haproxy',
|
getVhost: callGetVhost,
|
||||||
method: 'list_vhosts',
|
createVhost: callCreateVhost,
|
||||||
expect: { vhosts: [] }
|
updateVhost: callUpdateVhost,
|
||||||
}),
|
deleteVhost: callDeleteVhost,
|
||||||
|
|
||||||
getVhost: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'get_vhost',
|
|
||||||
params: ['id'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
createVhost: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'create_vhost',
|
|
||||||
params: ['domain', 'backend', 'ssl', 'ssl_redirect', 'acme', 'enabled'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
updateVhost: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'update_vhost',
|
|
||||||
params: ['id', 'domain', 'backend', 'ssl', 'ssl_redirect', 'acme', 'enabled'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
deleteVhost: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'delete_vhost',
|
|
||||||
params: ['id'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
// Backends
|
// Backends
|
||||||
listBackends: rpc.declare({
|
listBackends: callListBackends,
|
||||||
object: 'luci.haproxy',
|
getBackend: callGetBackend,
|
||||||
method: 'list_backends',
|
createBackend: callCreateBackend,
|
||||||
expect: { backends: [] }
|
updateBackend: callUpdateBackend,
|
||||||
}),
|
deleteBackend: callDeleteBackend,
|
||||||
|
|
||||||
getBackend: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'get_backend',
|
|
||||||
params: ['id'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
createBackend: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'create_backend',
|
|
||||||
params: ['name', 'mode', 'balance', 'health_check', 'enabled'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
updateBackend: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'update_backend',
|
|
||||||
params: ['id', 'name', 'mode', 'balance', 'health_check', 'enabled'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
deleteBackend: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'delete_backend',
|
|
||||||
params: ['id'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
// Servers
|
// Servers
|
||||||
listServers: rpc.declare({
|
listServers: callListServers,
|
||||||
object: 'luci.haproxy',
|
createServer: callCreateServer,
|
||||||
method: 'list_servers',
|
updateServer: callUpdateServer,
|
||||||
params: ['backend'],
|
deleteServer: callDeleteServer,
|
||||||
expect: { servers: [] }
|
|
||||||
}),
|
|
||||||
|
|
||||||
createServer: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'create_server',
|
|
||||||
params: ['backend', 'name', 'address', 'port', 'weight', 'check', 'enabled'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
updateServer: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'update_server',
|
|
||||||
params: ['id', 'backend', 'name', 'address', 'port', 'weight', 'check', 'enabled'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
deleteServer: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'delete_server',
|
|
||||||
params: ['id'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
// Certificates
|
// Certificates
|
||||||
listCertificates: rpc.declare({
|
listCertificates: callListCertificates,
|
||||||
object: 'luci.haproxy',
|
requestCertificate: callRequestCertificate,
|
||||||
method: 'list_certificates',
|
importCertificate: callImportCertificate,
|
||||||
expect: { certificates: [] }
|
deleteCertificate: callDeleteCertificate,
|
||||||
}),
|
|
||||||
|
|
||||||
requestCertificate: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'request_certificate',
|
|
||||||
params: ['domain'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
importCertificate: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'import_certificate',
|
|
||||||
params: ['domain', 'cert', 'key'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
deleteCertificate: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'delete_certificate',
|
|
||||||
params: ['id'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
// ACLs
|
// ACLs
|
||||||
listAcls: rpc.declare({
|
listAcls: callListAcls,
|
||||||
object: 'luci.haproxy',
|
createAcl: callCreateAcl,
|
||||||
method: 'list_acls',
|
updateAcl: callUpdateAcl,
|
||||||
expect: { acls: [] }
|
deleteAcl: callDeleteAcl,
|
||||||
}),
|
|
||||||
|
|
||||||
createAcl: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'create_acl',
|
|
||||||
params: ['name', 'type', 'pattern', 'backend', 'enabled'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
updateAcl: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'update_acl',
|
|
||||||
params: ['id', 'name', 'type', 'pattern', 'backend', 'enabled'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
deleteAcl: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'delete_acl',
|
|
||||||
params: ['id'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
// Redirects
|
// Redirects
|
||||||
listRedirects: rpc.declare({
|
listRedirects: callListRedirects,
|
||||||
object: 'luci.haproxy',
|
createRedirect: callCreateRedirect,
|
||||||
method: 'list_redirects',
|
deleteRedirect: callDeleteRedirect,
|
||||||
expect: { redirects: [] }
|
|
||||||
}),
|
|
||||||
|
|
||||||
createRedirect: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'create_redirect',
|
|
||||||
params: ['name', 'match_host', 'target_host', 'strip_www', 'code', 'enabled'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
deleteRedirect: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'delete_redirect',
|
|
||||||
params: ['id'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
getSettings: rpc.declare({
|
getSettings: callGetSettings,
|
||||||
object: 'luci.haproxy',
|
saveSettings: callSaveSettings,
|
||||||
method: 'get_settings',
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
saveSettings: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'save_settings',
|
|
||||||
params: ['main', 'defaults', 'acme'],
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
// Service control
|
// Service control
|
||||||
install: rpc.declare({
|
install: callInstall,
|
||||||
object: 'luci.haproxy',
|
start: callStart,
|
||||||
method: 'install',
|
stop: callStop,
|
||||||
expect: { }
|
restart: callRestart,
|
||||||
}),
|
reload: callReload,
|
||||||
|
generate: callGenerate,
|
||||||
|
validate: callValidate,
|
||||||
|
getLogs: callGetLogs,
|
||||||
|
|
||||||
start: rpc.declare({
|
// Helpers
|
||||||
object: 'luci.haproxy',
|
getDashboardData: getDashboardData
|
||||||
method: 'start',
|
});
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
stop: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'stop',
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
restart: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'restart',
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
reload: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'reload',
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
generate: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'generate',
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
validate: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'validate',
|
|
||||||
expect: { }
|
|
||||||
}),
|
|
||||||
|
|
||||||
getLogs: rpc.declare({
|
|
||||||
object: 'luci.haproxy',
|
|
||||||
method: 'get_logs',
|
|
||||||
params: ['lines'],
|
|
||||||
expect: { logs: '' }
|
|
||||||
}),
|
|
||||||
|
|
||||||
// Fetch all data for dashboard
|
|
||||||
getDashboardData: function() {
|
|
||||||
return Promise.all([
|
|
||||||
this.status(),
|
|
||||||
this.listVhosts(),
|
|
||||||
this.listBackends(),
|
|
||||||
this.listCertificates()
|
|
||||||
]).then(function(results) {
|
|
||||||
return {
|
|
||||||
status: results[0],
|
|
||||||
vhosts: results[1],
|
|
||||||
backends: results[2],
|
|
||||||
certificates: results[3]
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return api;
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user