diff --git a/frontend/src/api/snapshots.js b/frontend/src/api/snapshots.js new file mode 100644 index 0000000000..b0c9d4359b --- /dev/null +++ b/frontend/src/api/snapshots.js @@ -0,0 +1,61 @@ +import product from '../services/product.js' +import daysSince from '../utils/daysSince.js' + +import client from './client.js' + +/** + * Get summary of a snapshot + */ +const getSummary = (snapshotId) => { + return client.get(`/api/v1/snapshots/${snapshotId}`).then(res => { + res.data.createdSince = daysSince(res.data.createdAt) + res.data.updatedSince = daysSince(res.data.updatedAt) + return res.data + }) +} + +/** + * Get full snapshot + */ +const getFullSnapshot = (snapshotId) => { + return client.get(`/api/v1/snapshots/${snapshotId}/full`).then(res => { + res.data.createdSince = daysSince(res.data.createdAt) + res.data.updatedSince = daysSince(res.data.updatedAt) + return res.data + }) +} + +/** + * Export a snapshot for later import in another project or platform + */ +const exportSnapshot = (snapshotId, options) => { + return client.post(`/api/v1/snapshots/${snapshotId}/export`, options).then(res => { + const props = { + 'snapshot-id': res.data.id + } + product.capture('$ff-snapshot-export', props, {}) + return res.data + }) +} + +/** + * Delete a snapshot + * @param {String} snapshotId - id of the snapshot + */ +const deleteSnapshot = async (snapshotId) => { + return client.delete(`/api/v1/snapshots/${snapshotId}`).then(res => { + const props = { + 'snapshot-id': snapshotId, + 'deleted-at': (new Date()).toISOString() + } + product.capture('$ff-snapshot-deleted', props, {}) + return res.data + }) +} + +export default { + deleteSnapshot, + getFullSnapshot, + exportSnapshot, + getSummary +} diff --git a/frontend/src/components/dialogs/SnapshotViewerDialog.vue b/frontend/src/components/dialogs/SnapshotViewerDialog.vue new file mode 100644 index 0000000000..e14ef74858 --- /dev/null +++ b/frontend/src/components/dialogs/SnapshotViewerDialog.vue @@ -0,0 +1,68 @@ + + + + diff --git a/frontend/src/pages/application/Snapshots.vue b/frontend/src/pages/application/Snapshots.vue index c99e6f64c4..1110e77c9c 100644 --- a/frontend/src/pages/application/Snapshots.vue +++ b/frontend/src/pages/application/Snapshots.vue @@ -11,7 +11,11 @@ +