diff --git a/src/common/messages.js b/src/common/messages.js index 6c03c721f..bfcb3027f 100644 --- a/src/common/messages.js +++ b/src/common/messages.js @@ -358,6 +358,25 @@ export const messages = { defaultMessage: 'Select your backup type:' }, + // ------ New Remote ----- + remoteList: { + defaultMessage: 'Remote stores for backup' + }, + newRemote: { + defaultMessage: 'New File System Remote' + }, + remoteTypeLocal: { + defaultMessage: 'Local' + }, + remoteTypeNfs: { + defaultMessage: 'NFS' + }, + remoteTypeSmb: { + defaultMessage: 'SMB' + }, + remoteType: { + defaultMessage: 'Type' + }, // ----- Plugins ------ autoloadPlugin: { diff --git a/src/common/xo.js b/src/common/xo.js index 7904003ff..3850b3618 100644 --- a/src/common/xo.js +++ b/src/common/xo.js @@ -492,3 +492,21 @@ export const purgePluginConfiguration = async id => { throw error } } + +// ------------------------------------------------------------------- + +export const createRemote = (name, url) => ( + xo.call('remote.create', {name, url}) +) + +export const deleteRemote = id => ( + xo.call('remote.delete', {id}) +) + +export const enableRemote = id => ( + xo.call('remote.set', {id, enabled: true}) +) + +export const disableRemote = id => ( + xo.call('remote.set', {id, enabled: false}) +) diff --git a/src/icons.scss b/src/icons.scss index 50cc1e13d..975f48c02 100644 --- a/src/icons.scss +++ b/src/icons.scss @@ -111,6 +111,10 @@ @extend .fa; @extend .fa-database; } + &-delete { + @extend .fa; + @extend .fa-trash; + } // Backups &-backup { diff --git a/src/xo-app/index.js b/src/xo-app/index.js index ba9aaee64..2a329098d 100644 --- a/src/xo-app/index.js +++ b/src/xo-app/index.js @@ -28,8 +28,8 @@ import Vm from './vm' dashboard: Dashboard, home: Home, 'hosts/:id': Host, - 'pools/:id': Pool, new: New, + 'pools/:id': Pool, settings: Settings, 'srs/:id': Sr, user: User, diff --git a/src/xo-app/settings/index.js b/src/xo-app/settings/index.js index 028e86d23..11e7485c6 100644 --- a/src/xo-app/settings/index.js +++ b/src/xo-app/settings/index.js @@ -1,10 +1,12 @@ import { routes } from 'utils' import Plugins from './plugins' +import Remotes from './remotes' import Servers from './servers' const Settings = routes('servers', { plugins: Plugins, + remotes: Remotes, servers: Servers })( ({ children }) => children diff --git a/src/xo-app/settings/remotes/index.js b/src/xo-app/settings/remotes/index.js new file mode 100644 index 000000000..f58232c82 --- /dev/null +++ b/src/xo-app/settings/remotes/index.js @@ -0,0 +1,303 @@ +import _ from 'messages' +import ActionButton from 'action-button' +import filter from 'lodash/filter' +import Icon from 'icon' +import isEmpty from 'lodash/isEmpty' +import map from 'lodash/map' +import React, { Component } from 'react' +import { error } from 'notification' +import { + createRemote, + deleteRemote, + disableRemote, + enableRemote, + subscribeRemotes +} from 'xo' +import { format, parse } from 'xo-remote-parser' + +const remoteTypes = { + local: 'remoteTypeLocal', + nfs: 'remoteTypeNfs', + smb: 'remoteTypeSmb' +} + +class AbstractRemote extends Component { + _disable = id => disableRemote(id).then(subscribeRemotes.forceRefresh) + _enable = id => enableRemote(id).then(subscribeRemotes.forceRefresh) + _delete = id => deleteRemote(id).then(subscribeRemotes.forceRefresh) + render () { + const { + remote + } = this.props + + return
| Local | +Name | +Path | ++ | State | +Error | ++ |
|---|---|---|---|---|---|---|
| NFS | +Name | +Device | ++ | State | +Error | ++ |
| SMB | +Name | +Share | +Auth | +State | +Error | ++ |