Remove replication factor for OSS and simplify rf formatting
parent
84d3da7edd
commit
5528377de5
|
@ -4,6 +4,7 @@ import DatabaseTable from 'src/admin/components/DatabaseTable'
|
||||||
const DatabaseManager = ({
|
const DatabaseManager = ({
|
||||||
databases,
|
databases,
|
||||||
notify,
|
notify,
|
||||||
|
isRFDisplayed,
|
||||||
addDatabase,
|
addDatabase,
|
||||||
onEditDatabase,
|
onEditDatabase,
|
||||||
onKeyDownDatabase,
|
onKeyDownDatabase,
|
||||||
|
@ -31,6 +32,7 @@ const DatabaseManager = ({
|
||||||
key={db.links.self}
|
key={db.links.self}
|
||||||
database={db}
|
database={db}
|
||||||
notify={notify}
|
notify={notify}
|
||||||
|
isRFDisplayed={isRFDisplayed}
|
||||||
onEditDatabase={onEditDatabase}
|
onEditDatabase={onEditDatabase}
|
||||||
onKeyDownDatabase={onKeyDownDatabase}
|
onKeyDownDatabase={onKeyDownDatabase}
|
||||||
onCancelDatabase={onCancelDatabase}
|
onCancelDatabase={onCancelDatabase}
|
||||||
|
@ -53,6 +55,7 @@ const DatabaseManager = ({
|
||||||
|
|
||||||
const {
|
const {
|
||||||
arrayOf,
|
arrayOf,
|
||||||
|
bool,
|
||||||
func,
|
func,
|
||||||
shape,
|
shape,
|
||||||
} = PropTypes
|
} = PropTypes
|
||||||
|
@ -61,6 +64,7 @@ DatabaseManager.propTypes = {
|
||||||
databases: arrayOf(shape()),
|
databases: arrayOf(shape()),
|
||||||
notify: func,
|
notify: func,
|
||||||
addDatabase: func,
|
addDatabase: func,
|
||||||
|
isRFDisplayed: bool,
|
||||||
onEditDatabase: func,
|
onEditDatabase: func,
|
||||||
onKeyDownDatabase: func,
|
onKeyDownDatabase: func,
|
||||||
onCancelDatabase: func,
|
onCancelDatabase: func,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React, {PropTypes, Component} from 'react'
|
import React, {PropTypes, Component} from 'react'
|
||||||
import {formatRPDuration} from 'utils/formatting'
|
import {formatInfiniteDuration} from 'utils/formatting'
|
||||||
import YesNoButtons from 'src/shared/components/YesNoButtons'
|
import YesNoButtons from 'src/shared/components/YesNoButtons'
|
||||||
import onClickOutside from 'react-onclickoutside'
|
import onClickOutside from 'react-onclickoutside'
|
||||||
|
|
||||||
|
@ -30,8 +30,11 @@ class DatabaseRow extends Component {
|
||||||
retentionPolicy: {name, duration, replication, isDefault, isNew},
|
retentionPolicy: {name, duration, replication, isDefault, isNew},
|
||||||
retentionPolicy,
|
retentionPolicy,
|
||||||
database,
|
database,
|
||||||
|
isRFDisplayed,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
|
const formattedDuration = formatInfiniteDuration(duration)
|
||||||
|
|
||||||
if (this.state.isEditing) {
|
if (this.state.isEditing) {
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -55,27 +58,27 @@ class DatabaseRow extends Component {
|
||||||
className="form-control"
|
className="form-control"
|
||||||
name="name"
|
name="name"
|
||||||
type="text"
|
type="text"
|
||||||
defaultValue={duration}
|
defaultValue={formattedDuration}
|
||||||
placeholder="how long should data last"
|
placeholder="how long should data last"
|
||||||
onKeyDown={(e) => this.handleKeyDown(e, database)}
|
onKeyDown={(e) => this.handleKeyDown(e, database)}
|
||||||
ref={(r) => this.duration = r}
|
ref={(r) => this.duration = r}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td style={isRFDisplayed ? {} : {display: 'none'}}>
|
||||||
<div className="admin-table--edit-cell">
|
<div className="admin-table--edit-cell">
|
||||||
<input
|
<input
|
||||||
className="form-control"
|
className="form-control"
|
||||||
name="name"
|
name="name"
|
||||||
type="number"
|
type="number"
|
||||||
min="1"
|
min="1"
|
||||||
defaultValue={replication || 1}
|
defaultValue={replication}
|
||||||
placeholder="how many nodes do you have"
|
placeholder="how many nodes do you have"
|
||||||
onKeyDown={(e) => this.handleKeyDown(e, database)}
|
onKeyDown={(e) => this.handleKeyDown(e, database)}
|
||||||
ref={(r) => this.replication = r}
|
ref={(r) => this.replication = r}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td className="text-right">
|
<td className="text-right">
|
||||||
<YesNoButtons
|
<YesNoButtons
|
||||||
onConfirm={isNew ? this.handleCreate : this.handleUpdate}
|
onConfirm={isNew ? this.handleCreate : this.handleUpdate}
|
||||||
|
@ -88,12 +91,9 @@ class DatabaseRow extends Component {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
<td onClick={this.handleStartEdit}>
|
<td onClick={this.handleStartEdit}> {name} {isDefault ? <span className="default-source-label">default</span> : null}</td>
|
||||||
{name}
|
<td onClick={this.handleStartEdit}>{formattedDuration}</td>
|
||||||
{isDefault ? <span className="default-source-label">default</span> : null}
|
{isRFDisplayed ? <td onClick={this.handleStartEdit}>{replication}</td> : null}
|
||||||
</td>
|
|
||||||
<td onClick={this.handleStartEdit}>{formatRPDuration(duration)}</td>
|
|
||||||
<td onClick={this.handleStartEdit}>{replication}</td>
|
|
||||||
<td className="text-right">
|
<td className="text-right">
|
||||||
<button className="btn btn-xs btn-danger admin-table--delete">
|
<button className="btn btn-xs btn-danger admin-table--delete">
|
||||||
{`Delete ${name}`}
|
{`Delete ${name}`}
|
||||||
|
@ -163,14 +163,19 @@ class DatabaseRow extends Component {
|
||||||
|
|
||||||
getInputValues() {
|
getInputValues() {
|
||||||
const name = this.name.value.trim()
|
const name = this.name.value.trim()
|
||||||
const duration = this.duration.value.trim()
|
let duration = this.duration.value.trim()
|
||||||
const replication = +this.replication.value.trim()
|
const replication = +this.replication.value.trim()
|
||||||
|
const {notify} = this.props
|
||||||
|
|
||||||
if (!name || !duration || !replication) {
|
if (!name || !duration || !replication) {
|
||||||
this.props.notify('error', 'Fields cannot be empty')
|
notify('error', 'Fields cannot be empty')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (duration === '∞') {
|
||||||
|
duration = 'INF'
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
duration,
|
duration,
|
||||||
|
@ -201,6 +206,7 @@ DatabaseRow.propTypes = {
|
||||||
onCreate: func,
|
onCreate: func,
|
||||||
onUpdate: func,
|
onUpdate: func,
|
||||||
notify: func,
|
notify: func,
|
||||||
|
isRFDisplayed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default onClickOutside(DatabaseRow)
|
export default onClickOutside(DatabaseRow)
|
||||||
|
|
|
@ -5,11 +5,13 @@ import ConfirmButtons from 'src/admin/components/ConfirmButtons'
|
||||||
const {
|
const {
|
||||||
func,
|
func,
|
||||||
shape,
|
shape,
|
||||||
|
bool,
|
||||||
} = PropTypes
|
} = PropTypes
|
||||||
|
|
||||||
const DatabaseTable = ({
|
const DatabaseTable = ({
|
||||||
database,
|
database,
|
||||||
notify,
|
notify,
|
||||||
|
isRFDisplayed,
|
||||||
onEditDatabase,
|
onEditDatabase,
|
||||||
onKeyDownDatabase,
|
onKeyDownDatabase,
|
||||||
onCancelDatabase,
|
onCancelDatabase,
|
||||||
|
@ -39,7 +41,7 @@ const DatabaseTable = ({
|
||||||
<tr>
|
<tr>
|
||||||
<th>Retention Policy</th>
|
<th>Retention Policy</th>
|
||||||
<th>Duration</th>
|
<th>Duration</th>
|
||||||
<th>Replication Factor</th>
|
{isRFDisplayed ? <th>Replication Factor</th> : null}
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -55,6 +57,7 @@ const DatabaseTable = ({
|
||||||
onCreate={onCreateRetentionPolicy}
|
onCreate={onCreateRetentionPolicy}
|
||||||
onUpdate={onUpdateRetentionPolicy}
|
onUpdate={onUpdateRetentionPolicy}
|
||||||
onRemove={onRemoveRetentionPolicy}
|
onRemove={onRemoveRetentionPolicy}
|
||||||
|
isRFDisplayed={isRFDisplayed}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -70,6 +73,7 @@ DatabaseTable.propTypes = {
|
||||||
onEditDatabase: func,
|
onEditDatabase: func,
|
||||||
database: shape(),
|
database: shape(),
|
||||||
notify: func,
|
notify: func,
|
||||||
|
isRFDisplayed: bool,
|
||||||
onKeyDownDatabase: func,
|
onKeyDownDatabase: func,
|
||||||
onCancelDatabase: func,
|
onCancelDatabase: func,
|
||||||
onConfirmDatabase: func,
|
onConfirmDatabase: func,
|
||||||
|
@ -207,6 +211,7 @@ EditHeader.propTypes = {
|
||||||
onKeyDown: func,
|
onKeyDown: func,
|
||||||
onCancel: func,
|
onCancel: func,
|
||||||
onConfirm: func,
|
onConfirm: func,
|
||||||
|
isRFDisplayed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DatabaseTable
|
export default DatabaseTable
|
||||||
|
|
|
@ -21,12 +21,13 @@ class DatabaseManagerPage extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {databases, actions, notify} = this.props
|
const {source, databases, actions, notify} = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DatabaseManager
|
<DatabaseManager
|
||||||
databases={databases}
|
databases={databases}
|
||||||
notify={notify}
|
notify={notify}
|
||||||
|
isRFDisplayed={!!source.metaUrl}
|
||||||
onKeyDownDatabase={this.handleKeyDownDatabase}
|
onKeyDownDatabase={this.handleKeyDownDatabase}
|
||||||
onDatabaseDeleteConfirm={this.handleDatabaseDeleteConfirm}
|
onDatabaseDeleteConfirm={this.handleDatabaseDeleteConfirm}
|
||||||
addDatabase={actions.addDatabase}
|
addDatabase={actions.addDatabase}
|
||||||
|
|
|
@ -15,6 +15,8 @@ export const formatBytes = (bytes) => {
|
||||||
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Using InfluxDB 1.2+ we should no longer need this formatter.
|
||||||
|
// Times can now be submitted using multiple units i.e. 1d2h3m
|
||||||
export const formatRPDuration = (duration) => {
|
export const formatRPDuration = (duration) => {
|
||||||
if (duration === '0' || duration === '0s') {
|
if (duration === '0' || duration === '0s') {
|
||||||
return '∞';
|
return '∞';
|
||||||
|
@ -38,3 +40,11 @@ export const formatRPDuration = (duration) => {
|
||||||
|
|
||||||
return adjustedTime;
|
return adjustedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const formatInfiniteDuration = (duration) => {
|
||||||
|
if (duration === '0' || duration === '0s' || duration === 'INF') {
|
||||||
|
return '∞';
|
||||||
|
}
|
||||||
|
|
||||||
|
return duration
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue