mirror of
https://github.com/logos-blockchain/lez-explorer-ui.git
synced 2026-07-30 03:13:25 +00:00
feat!: adopt port-less indexer module; gate search on connection
This commit is contained in:
parent
952b174b2e
commit
f03f7bcaca
10795
flake.lock
generated
10795
flake.lock
generated
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@
|
||||
# NOTE: git+https (not github:) because the branch name contains a slash —
|
||||
# the github: fetcher mis-routes slashed refs through the commits API (404).
|
||||
# TODO: repoint to the merge target once this branch lands / goes public.
|
||||
lez_indexer_module.url = "git+https://github.com/logos-blockchain/lez-indexer-module?ref=erhant/migr-to-logos-module-builder";
|
||||
lez_indexer_module.url = "git+https://github.com/logos-blockchain/lez-indexer-module?ref=erhant/migr-to-logos-module-builder-update-LEZ";
|
||||
};
|
||||
|
||||
outputs =
|
||||
|
||||
@ -25,10 +25,9 @@ class LezExplorerUi
|
||||
PROP(QString defaultConfig READONLY)
|
||||
|
||||
// Persist `json` as the indexer config and (re)start ingestion from it, then
|
||||
// refresh the feed. `port` is the indexer RPC port (blank keeps the current
|
||||
// one). The backend writes the JSON to a file itself — the UI never deals
|
||||
// with paths. Returns true on success.
|
||||
SLOT(bool applyConfigJson(QString json, QString port))
|
||||
// refresh the feed. The backend writes the JSON to a file itself — the UI
|
||||
// never deals with paths. Returns true on success.
|
||||
SLOT(bool applyConfigJson(QString json))
|
||||
// Reload the latest page into recentBlocks and re-baseline the poller.
|
||||
SLOT(void refreshBlocks())
|
||||
// Append the next older page of blocks to recentBlocks.
|
||||
|
||||
@ -244,13 +244,8 @@ void LezExplorerUiBackend::onContextReady()
|
||||
pollTip();
|
||||
}
|
||||
|
||||
bool LezExplorerUiBackend::applyConfigJson(QString json, QString port)
|
||||
bool LezExplorerUiBackend::applyConfigJson(QString json)
|
||||
{
|
||||
const QString trimmedPort = port.trimmed();
|
||||
if (!trimmedPort.isEmpty()) {
|
||||
m_port = trimmedPort;
|
||||
}
|
||||
|
||||
const QString trimmed = json.trimmed();
|
||||
if (trimmed.isEmpty()) {
|
||||
emit error(QStringLiteral("Config is empty."));
|
||||
@ -539,7 +534,7 @@ QString LezExplorerUiBackend::readConfigFile() const
|
||||
|
||||
bool LezExplorerUiBackend::startIndexerFromFile()
|
||||
{
|
||||
const qlonglong code = modules().lez_indexer_module.start_indexer(configFilePath(), m_port);
|
||||
const qlonglong code = modules().lez_indexer_module.start_indexer(configFilePath());
|
||||
if (code != 0) {
|
||||
emit error(QStringLiteral("start_indexer failed (code %1)").arg(code));
|
||||
return false;
|
||||
|
||||
@ -39,7 +39,7 @@ public:
|
||||
void onContextReady() override;
|
||||
|
||||
// .rep SLOTs.
|
||||
bool applyConfigJson(QString json, QString port) override;
|
||||
bool applyConfigJson(QString json) override;
|
||||
void refreshBlocks() override;
|
||||
void loadMoreBlocks() override;
|
||||
QVariantMap getBlockById(QString id) override;
|
||||
@ -65,7 +65,6 @@ private:
|
||||
// start_indexer from configFilePath(); returns true on success.
|
||||
bool startIndexerFromFile();
|
||||
|
||||
QString m_port = QStringLiteral("8779");
|
||||
QString m_configFilePath;
|
||||
QVariantList m_recentBlocks;
|
||||
quint64 m_newestLoadedId = 0; // highest block id currently in m_recentBlocks
|
||||
|
||||
@ -109,6 +109,8 @@ Rectangle {
|
||||
|
||||
SearchBar {
|
||||
Layout.fillWidth: true
|
||||
// Only searchable once the indexer is actually answering.
|
||||
enabled: root.backend && root.backend.connectionStatus === "Connected"
|
||||
onSearchRequested: function (query) {
|
||||
if (!root.backend || query.trim().length === 0)
|
||||
return;
|
||||
|
||||
@ -5,12 +5,16 @@ import Logos.Controls
|
||||
import Logos.Theme
|
||||
|
||||
// Search input + button. Emits searchRequested(query) on Enter or button click.
|
||||
// Bind the built-in `enabled` (e.g. to the indexer connection state) to block
|
||||
// searching when there's nothing to query; it dims and goes non-interactive.
|
||||
RowLayout {
|
||||
id: root
|
||||
|
||||
signal searchRequested(string query)
|
||||
|
||||
spacing: Theme.spacing.small
|
||||
opacity: enabled ? 1.0 : 0.5
|
||||
Behavior on opacity { NumberAnimation { duration: 120 } }
|
||||
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
@ -40,7 +44,9 @@ RowLayout {
|
||||
id: field
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
placeholderText: "Search by block id / block hash / tx hash / account id…"
|
||||
placeholderText: root.enabled
|
||||
? "Search by block id / block hash / tx hash / account id…"
|
||||
: "Connect an indexer to search…"
|
||||
color: Theme.palette.text
|
||||
placeholderTextColor: Theme.palette.textMuted
|
||||
font.pixelSize: Theme.typography.secondaryText
|
||||
|
||||
@ -140,9 +140,7 @@ Item {
|
||||
return;
|
||||
}
|
||||
page.setStatus("Saving…", false);
|
||||
// Port is an internal detail of the indexer's own RPC listener; the
|
||||
// explorer reads over the Logos protocol, so we pass "" (keep default).
|
||||
logos.watch(page.backend.applyConfigJson(editor.text, ""),
|
||||
logos.watch(page.backend.applyConfigJson(editor.text),
|
||||
function (ok) {
|
||||
if (ok) {
|
||||
page.setStatus("Saved. Indexer starting…", false);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user