Skip to content

Commit

Permalink
call replication/mode/status endpoint and add to cluster model
Browse files Browse the repository at this point in the history
  • Loading branch information
noelledaley committed Apr 30, 2020
1 parent 21a4d9b commit 08d5d42
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
15 changes: 15 additions & 0 deletions ui/app/adapters/replication-mode.js
Original file line number Diff line number Diff line change
@@ -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`;
},
});
38 changes: 38 additions & 0 deletions ui/app/models/replication-mode.js
Original file line number Diff line number Diff line change
@@ -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'),
});
12 changes: 12 additions & 0 deletions ui/app/serializers/replication-mode.js
Original file line number Diff line number Diff line change
@@ -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);
},
});
4 changes: 3 additions & 1 deletion ui/lib/replication/addon/routes/mode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@
{{#if (eq replicationAttrs.mode 'initializing')}}
The cluster is initializing replication. This may take some time.
{{else}}
<p>{{cluster.replicationModeStatus.cluster_id}}</p>
<div class="replication">
<ReplicationPage @model={{cluster}} as |Page|>
<Page.toggle />
Expand Down

0 comments on commit 08d5d42

Please sign in to comment.