diff --git a/ui/app/adapters/replication-mode.js b/ui/app/adapters/replication-mode.js new file mode 100644 index 000000000000..61ffdc8e6df5 --- /dev/null +++ b/ui/app/adapters/replication-mode.js @@ -0,0 +1,15 @@ +import ApplicationAdapter from './application'; + +export default ApplicationAdapter.extend({ + queryRecord() { + return this.ajax(this.urlForQuery(), 'GET', { unauthenticated: true }).then(resp => { + resp.id = resp.request_id; + return resp; + }); + }, + urlForQuery() { + // TODO + // return this.buildURL() + `/replication/${mode}/status`; + return this.buildURL() + `/replication/performance/status`; + }, +}); diff --git a/ui/app/models/replication-mode.js b/ui/app/models/replication-mode.js new file mode 100644 index 000000000000..df79d46ac94f --- /dev/null +++ b/ui/app/models/replication-mode.js @@ -0,0 +1,38 @@ +import DS from 'ember-data'; +const { attr } = DS; + +/* sample response + +{ + "request_id": "d81bba81-e8a1-0ee9-240e-a77d36e3e08f", + "lease_id": "", + "renewable": false, + "lease_duration": 0, + "data": { + "cluster_id": "ab7d4191-d1a3-b4d6-6297-5a41af6154ae", + "known_secondaries": [ + "test" + ], + "last_performance_wal": 72, + "last_reindex_epoch": "1588281113", + "last_wal": 73, + "merkle_root": "c8d258d376f01d98156f74e8d8f82ea2aca8dc4a", + "mode": "primary", + "primary_cluster_addr": "", + "reindex_building_progress": 26838, + "reindex_building_total": 305443, + "reindex_in_progress": true, + "reindex_stage": "building", + "state": "running" + }, + "wrap_info": null, + "warnings": null, + "auth": null +} + + +*/ + +export default DS.Model.extend({ + status: attr('object'), +}); diff --git a/ui/app/serializers/replication-mode.js b/ui/app/serializers/replication-mode.js new file mode 100644 index 000000000000..2e6e9210bf9f --- /dev/null +++ b/ui/app/serializers/replication-mode.js @@ -0,0 +1,12 @@ +import ApplicationSerializer from './application'; + +export default ApplicationSerializer.extend({ + normalizeResponse(store, primaryModelClass, payload, id, requestType) { + const normalizedPayload = { + id: payload.id, + status: payload.data, + }; + + return this._super(store, primaryModelClass, normalizedPayload, id, requestType); + }, +}); diff --git a/ui/lib/replication/addon/routes/mode/index.js b/ui/lib/replication/addon/routes/mode/index.js index e3eac5187b5a..da3b912c663c 100644 --- a/ui/lib/replication/addon/routes/mode/index.js +++ b/ui/lib/replication/addon/routes/mode/index.js @@ -16,10 +16,12 @@ export default Route.extend({ canRevokeSecondary: this.store .findRecord('capabilities', `sys/replication/${replicationMode}/primary/revoke-secondary`) .then(c => c.get('canUpdate')), - }).then(({ cluster, canAddSecondary, canRevokeSecondary }) => { + replicationModeStatus: this.store.queryRecord('replication-mode', {}).then(resp => resp.status), + }).then(({ cluster, canAddSecondary, canRevokeSecondary, replicationModeStatus }) => { setProperties(cluster, { canRevokeSecondary, canAddSecondary, + replicationModeStatus, }); return cluster; }); diff --git a/ui/lib/replication/addon/templates/components/replication-summary.hbs b/ui/lib/replication/addon/templates/components/replication-summary.hbs index 2fcc35c167e4..5554d1e79bbc 100644 --- a/ui/lib/replication/addon/templates/components/replication-summary.hbs +++ b/ui/lib/replication/addon/templates/components/replication-summary.hbs @@ -329,6 +329,7 @@ {{#if (eq replicationAttrs.mode 'initializing')}} The cluster is initializing replication. This may take some time. {{else}} +
{{cluster.replicationModeStatus.cluster_id}}