diff --git a/pkg/sync/http.go b/pkg/sync/http.go index 68cbd06..ca9bdca 100644 --- a/pkg/sync/http.go +++ b/pkg/sync/http.go @@ -129,6 +129,7 @@ type syncStatus struct { type replicaStatus struct { Host string `json:"origin"` + URL string `json:"url"` Status string `json:"status"` - Error string `json:"error,omitempty"` + Error string `json:"error"` } diff --git a/pkg/sync/index.html b/pkg/sync/index.html index e8a0fa9..936bef2 100644 --- a/pkg/sync/index.html +++ b/pkg/sync/index.html @@ -21,11 +21,11 @@ $.get("api/v1/status", {}, function (status) { $('#origin').removeClass(function (index, className) { return (className.match(/(^|\s)btn-\S+/g) || []).join(' '); - }).addClass("btn-" + status.origin.status); + }).addClass("btn-" + status.origin.status).attr('title', status.origin.error); status.replicas.forEach(function (replica, i) { $('#replica_' + i).removeClass(function (index, className) { return (className.match(/(^|\s)btn-\S+/g) || []).join(' '); - }).addClass("btn-" + replica.status); + }).addClass("btn-" + replica.status).attr('title', replica.error); }); } ); @@ -57,11 +57,13 @@
- + Origin {{ .SyncStatus.Origin.Host }} {{ range $i, $r := .SyncStatus.Replicas }} - + Replica {{ $r.Host }} {{ end }}
@@ -73,4 +75,4 @@ - \ No newline at end of file + diff --git a/pkg/sync/sync.go b/pkg/sync/sync.go index 2c245a6..893c0d9 100644 --- a/pkg/sync/sync.go +++ b/pkg/sync/sync.go @@ -116,18 +116,18 @@ func (w *worker) getStatus(inst types.AdGuardInstance) replicaStatus { oc, err := w.createClient(inst) if err != nil { l.With("error", err, "url", w.cfg.Origin.URL).Error("Error creating origin client") - return replicaStatus{Host: oc.Host(), Error: err.Error(), Status: "danger"} + return replicaStatus{Host: oc.Host(), URL: inst.URL, Error: err.Error(), Status: "danger"} } sl := l.With("from", oc.Host()) _, err = oc.Status() if err != nil { if errors.Is(err, client.ErrSetupNeeded) { - return replicaStatus{Host: oc.Host(), Error: err.Error(), Status: "warning"} + return replicaStatus{Host: oc.Host(), URL: inst.URL, Error: err.Error(), Status: "warning"} } sl.With("error", err).Error("Error getting origin status") - return replicaStatus{Host: oc.Host(), Error: err.Error(), Status: "danger"} + return replicaStatus{Host: oc.Host(), URL: inst.URL, Error: err.Error(), Status: "danger"} } - st := replicaStatus{Host: oc.Host(), Status: "success"} + st := replicaStatus{Host: oc.Host(), URL: inst.URL, Status: "success"} return st }