chore: format with Prettier

This commit is contained in:
Julien Fontanet 2018-08-19 16:46:34 +02:00
parent ec869ffdd3
commit 2236bd71c4
64 changed files with 313 additions and 242 deletions

View File

@ -44,7 +44,9 @@ class Schedule {
this._createDate = this._createDate =
zone.toLowerCase() === 'utc' zone.toLowerCase() === 'utc'
? moment.utc ? moment.utc
: zone === 'local' ? moment : () => moment.tz(zone) : zone === 'local'
? moment
: () => moment.tz(zone)
} }
createJob (fn) { createJob (fn) {

View File

@ -85,8 +85,8 @@ export const validChecksumOfReadStream = (
callback( callback(
checksum !== expectedChecksum checksum !== expectedChecksum
? new Error( ? new Error(
`Bad checksum (${checksum}), expected: ${expectedChecksum}` `Bad checksum (${checksum}), expected: ${expectedChecksum}`
) )
: null : null
) )
} }

View File

@ -14,7 +14,8 @@ export default async function main (args) {
onProgress ({ done, total }) { onProgress ({ done, total }) {
if (bar === undefined) { if (bar === undefined) {
bar = new Bar({ bar = new Bar({
format: 'merging [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}', format:
'merging [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}',
}) })
bar.start(total, done) bar.start(total, done)
} else { } else {

View File

@ -58,7 +58,7 @@ export default asyncIteratorToStream(async function * (
const maxTableEntries = Math.ceil(diskSize / VHD_BLOCK_SIZE_BYTES) + 1 const maxTableEntries = Math.ceil(diskSize / VHD_BLOCK_SIZE_BYTES) + 1
const tablePhysicalSizeBytes = const tablePhysicalSizeBytes =
Math.ceil(maxTableEntries * 4 / SECTOR_SIZE) * SECTOR_SIZE Math.ceil((maxTableEntries * 4) / SECTOR_SIZE) * SECTOR_SIZE
const batPosition = FOOTER_SIZE + HEADER_SIZE const batPosition = FOOTER_SIZE + HEADER_SIZE
const firstBlockPosition = batPosition + tablePhysicalSizeBytes const firstBlockPosition = batPosition + tablePhysicalSizeBytes
@ -115,7 +115,7 @@ export default asyncIteratorToStream(async function * (
} }
next.data.copy( next.data.copy(
currentBlockWithBitmap, currentBlockWithBitmap,
bitmapSize + next.offsetBytes % VHD_BLOCK_SIZE_BYTES bitmapSize + (next.offsetBytes % VHD_BLOCK_SIZE_BYTES)
) )
} }
yield * yieldAndTrack(currentBlockWithBitmap) yield * yieldAndTrack(currentBlockWithBitmap)

View File

@ -51,7 +51,10 @@ export default concurrency(2)(async function merge (
// finds first allocated block for the 2 following loops // finds first allocated block for the 2 following loops
let firstBlock = 0 let firstBlock = 0
while (firstBlock < maxTableEntries && !childVhd.containsBlock(firstBlock)) { while (
firstBlock < maxTableEntries &&
!childVhd.containsBlock(firstBlock)
) {
++firstBlock ++firstBlock
} }

View File

@ -30,14 +30,14 @@ exports.resolveRef = (xapi, type, refOrUuidOrNameLabel) =>
isOpaqueRef(refOrUuidOrNameLabel) isOpaqueRef(refOrUuidOrNameLabel)
? refOrUuidOrNameLabel ? refOrUuidOrNameLabel
: xapi.call(`${type}.get_by_uuid`, refOrUuidOrNameLabel).catch(() => : xapi.call(`${type}.get_by_uuid`, refOrUuidOrNameLabel).catch(() =>
xapi xapi
.call(`${type}.get_by_name_label`, refOrUuidOrNameLabel) .call(`${type}.get_by_name_label`, refOrUuidOrNameLabel)
.then(refs => { .then(refs => {
if (refs.length === 1) { if (refs.length === 1) {
return refs[0] return refs[0]
} }
throw new Error( throw new Error(
`no single match for ${type} with name label ${refOrUuidOrNameLabel}` `no single match for ${type} with name label ${refOrUuidOrNameLabel}`
) )
}) })
) )

View File

@ -308,8 +308,8 @@ async function listObjects (args) {
const properties = getKeys(extractFlags(args)) const properties = getKeys(extractFlags(args))
const filterProperties = properties.length const filterProperties = properties.length
? function (object) { ? function (object) {
return pick(object, properties) return pick(object, properties)
} }
: identity : identity
const filter = args.length ? parseParameters(args) : undefined const filter = args.length ? parseParameters(args) : undefined

View File

@ -8,7 +8,10 @@ import isObject from './is-object'
// =================================================================== // ===================================================================
const { create: createObject, prototype: { hasOwnProperty } } = Object const {
create: createObject,
prototype: { hasOwnProperty },
} = Object
export const ACTION_ADD = 'add' export const ACTION_ADD = 'add'
export const ACTION_UPDATE = 'update' export const ACTION_UPDATE = 'update'

View File

@ -10,8 +10,7 @@ const xo = new Xo({
url: 'localhost:9000', url: 'localhost:9000',
}) })
xo xo.open()
.open()
.then(function () { .then(function () {
return xo return xo
.call('acl.get', {}) .call('acl.get', {})

View File

@ -8,13 +8,10 @@ import { debug } from './utils'
export default class DensityPlan extends Plan { export default class DensityPlan extends Plan {
_checkRessourcesThresholds (objects, averages) { _checkRessourcesThresholds (objects, averages) {
const { low } = this._thresholds.memoryFree const { low } = this._thresholds.memoryFree
return filter( return filter(objects, object => {
objects, const { memory, memoryFree = memory } = averages[object.id]
object => { return memoryFree > low
const { memory, memoryFree = memory } = averages[object.id] })
return memoryFree > low
}
)
} }
async execute () { async execute () {

View File

@ -124,7 +124,7 @@ const SR_FUNCTIONS = {
comparator: '>', comparator: '>',
createGetter: threshold => sr => { createGetter: threshold => sr => {
const getDisplayableValue = () => const getDisplayableValue = () =>
sr.physical_utilisation * 100 / sr.physical_size (sr.physical_utilisation * 100) / sr.physical_size
return { return {
getDisplayableValue, getDisplayableValue,
shouldAlarm: () => getDisplayableValue() > threshold, shouldAlarm: () => getDisplayableValue() > threshold,

View File

@ -120,9 +120,13 @@ class XoServerNagios {
const client = new net.Socket() const client = new net.Socket()
client.connect(this._conf.port, this._conf.server, () => { client.connect(
console.log('Successful connection') this._conf.port,
}) this._conf.server,
() => {
console.log('Successful connection')
}
)
client.on('data', data => { client.on('data', data => {
const timestamp = data.readInt32BE(128) const timestamp = data.readInt32BE(128)

View File

@ -201,7 +201,7 @@ function computePercentage (curr, prev, options) {
opt => opt =>
prev[opt] === 0 || prev[opt] === null prev[opt] === 0 || prev[opt] === null
? 'NONE' ? 'NONE'
: `${(curr[opt] - prev[opt]) * 100 / prev[opt]}` : `${((curr[opt] - prev[opt]) * 100) / prev[opt]}`
) )
) )
} }

View File

@ -83,14 +83,14 @@ export default class Redis extends Collection {
values == null values == null
? redis.srem(idsIndex, id) // entry no longer exists ? redis.srem(idsIndex, id) // entry no longer exists
: asyncMap(indexes, index => { : asyncMap(indexes, index => {
const value = values[index] const value = values[index]
if (value !== undefined) { if (value !== undefined) {
return redis.sadd( return redis.sadd(
`${prefix}_${index}:${String(value).toLowerCase()}`, `${prefix}_${index}:${String(value).toLowerCase()}`,
id id
) )
} }
}) })
) )
) )
) )

View File

@ -58,16 +58,15 @@ export default function proxyConsole (ws, vmConsole, sessionId) {
ws.close() ws.close()
}) })
ws ws.on('error', error => {
.on('error', error => { closed = true
closed = true debug(
debug( 'error from the XO client: %s',
'error from the XO client: %s', error.stack || error.message || error
error.stack || error.message || error )
)
socket.end() socket.end()
}) })
.on('message', data => { .on('message', data => {
if (!closed) { if (!closed) {
socket.write(data) socket.write(data)

View File

@ -100,7 +100,7 @@ describe('formatXml()', function () {
describe('generateToken()', () => { describe('generateToken()', () => {
it('generates a string', async () => { it('generates a string', async () => {
expect(typeof await generateToken()).toBe('string') expect(typeof (await generateToken())).toBe('string')
}) })
}) })

View File

@ -165,7 +165,7 @@ export default class {
} }
async deleteAuthenticationToken (id) { async deleteAuthenticationToken (id) {
if (!await this._tokens.remove(id)) { if (!(await this._tokens.remove(id))) {
throw noSuchAuthenticationToken(id) throw noSuchAuthenticationToken(id)
} }
} }

View File

@ -175,8 +175,8 @@ export default class IpPools {
Promise.all(mapToArray(updatedIpPools, ipPool => this._save(ipPool))) Promise.all(mapToArray(updatedIpPools, ipPool => this._save(ipPool)))
return resourseSetId return resourseSetId
? this._xo ? this._xo
.allocateLimitsInResourceSet(limits, resourseSetId) .allocateLimitsInResourceSet(limits, resourseSetId)
.then(saveIpPools) .then(saveIpPools)
: saveIpPools() : saveIpPools()
} }
})() })()

View File

@ -61,15 +61,15 @@ const normalize = set => ({
ipPools: set.ipPools || [], ipPools: set.ipPools || [],
limits: set.limits limits: set.limits
? map( ? map(
set.limits, set.limits,
limit => limit =>
isObject(limit) isObject(limit)
? limit ? limit
: { : {
available: limit, available: limit,
total: limit, total: limit,
} }
) )
: {}, : {},
name: set.name || '', name: set.name || '',
objects: set.objects || [], objects: set.objects || [],

View File

@ -64,7 +64,7 @@ export default class {
) )
) )
if (!await usersDb.exists()) { if (!(await usersDb.exists())) {
const email = 'admin@admin.net' const email = 'admin@admin.net'
const password = 'admin' const password = 'admin'
@ -229,7 +229,7 @@ export default class {
} }
async changeUserPassword (userId, oldPassword, newPassword) { async changeUserPassword (userId, oldPassword, newPassword) {
if (!await this.checkUserPassword(userId, oldPassword, false)) { if (!(await this.checkUserPassword(userId, oldPassword, false))) {
throw invalidCredentials() throw invalidCredentials()
} }

View File

@ -81,7 +81,7 @@ export default class {
async unregisterXenServer (id) { async unregisterXenServer (id) {
;this.disconnectXenServer(id)::ignoreErrors() ;this.disconnectXenServer(id)::ignoreErrors()
if (!await this._servers.remove(id)) { if (!(await this._servers.remove(id))) {
throw noSuchObject(id, 'xenServer') throw noSuchObject(id, 'xenServer')
} }
} }
@ -406,9 +406,10 @@ export default class {
async mergeXenPools (sourceId, targetId, force = false) { async mergeXenPools (sourceId, targetId, force = false) {
const sourceXapi = this.getXapi(sourceId) const sourceXapi = this.getXapi(sourceId)
const { _auth: { user, password }, _url: { hostname } } = this.getXapi( const {
targetId _auth: { user, password },
) _url: { hostname },
} = this.getXapi(targetId)
// We don't want the events of the source XAPI to interfere with // We don't want the events of the source XAPI to interfere with
// the events of the new XAPI. // the events of the new XAPI.

View File

@ -58,7 +58,10 @@ export default class Xo extends EventEmitter {
// Returns an object from its key or UUID. // Returns an object from its key or UUID.
getObject (key, type) { getObject (key, type) {
const { all, indexes: { byRef } } = this._objects const {
all,
indexes: { byRef },
} = this._objects
const obj = all[key] || byRef[key] const obj = all[key] || byRef[key]
if (!obj) { if (!obj) {

View File

@ -94,32 +94,32 @@ const src = lazyFn(function () {
return PRODUCTION return PRODUCTION
? function src (pattern, opts) { ? function src (pattern, opts) {
const base = resolve(opts && opts.base) const base = resolve(opts && opts.base)
return gulp.src(pattern, { return gulp.src(pattern, {
base: base,
cwd: base,
passthrough: opts && opts.passthrough,
sourcemaps: opts && opts.sourcemaps,
})
}
: function src (pattern, opts) {
const base = resolve(opts && opts.base)
return pipe(
gulp.src(pattern, {
base: base, base: base,
cwd: base, cwd: base,
passthrough: opts && opts.passthrough, passthrough: opts && opts.passthrough,
sourcemaps: opts && opts.sourcemaps, sourcemaps: opts && opts.sourcemaps,
}), })
require('gulp-watch')(pattern, { }
base: base, : function src (pattern, opts) {
cwd: base, const base = resolve(opts && opts.base)
}),
require('gulp-plumber')() return pipe(
) gulp.src(pattern, {
} base: base,
cwd: base,
passthrough: opts && opts.passthrough,
sourcemaps: opts && opts.sourcemaps,
}),
require('gulp-watch')(pattern, {
base: base,
cwd: base,
}),
require('gulp-plumber')()
)
}
}) })
// Similar to `gulp.dest()` but the output directory is relative to // Similar to `gulp.dest()` but the output directory is relative to
@ -136,13 +136,13 @@ const dest = lazyFn(function () {
return PRODUCTION return PRODUCTION
? function dest (path) { ? function dest (path) {
return gulp.dest(resolve(path), opts) return gulp.dest(resolve(path), opts)
} }
: function dest (path) { : function dest (path) {
const stream = gulp.dest(resolve(path), opts) const stream = gulp.dest(resolve(path), opts)
stream.pipe(livereload()) stream.pipe(livereload())
return stream return stream
} }
}) })
// =================================================================== // ===================================================================

View File

@ -43,7 +43,9 @@ export default class EnumInput extends Component {
required={required} required={required}
value={this._getSelectedIndex()} value={this._getSelectedIndex()}
> >
{_('noSelectedValue', message => <option value=''>{message}</option>)} {_('noSelectedValue', message => (
<option value=''>{message}</option>
))}
{map(enumNames, (name, index) => ( {map(enumNames, (name, index) => (
<option value={index} key={index}> <option value={index} key={index}>
{name} {name}

View File

@ -233,24 +233,24 @@ const CONFIRM_BUTTONS = [{ btnStyle: 'primary', label: _('confirmOk') }]
export const confirm = ({ body, icon = 'alarm', title, strongConfirm }) => export const confirm = ({ body, icon = 'alarm', title, strongConfirm }) =>
strongConfirm strongConfirm
? new Promise((resolve, reject) => { ? new Promise((resolve, reject) => {
modal( modal(
<StrongConfirm <StrongConfirm
body={body} body={body}
icon={icon} icon={icon}
reject={reject} reject={reject}
resolve={resolve} resolve={resolve}
strongConfirm={strongConfirm} strongConfirm={strongConfirm}
title={title} title={title}
/>, />,
reject reject
) )
}) })
: chooseAction({ : chooseAction({
body, body,
buttons: CONFIRM_BUTTONS, buttons: CONFIRM_BUTTONS,
icon, icon,
title, title,
}) })
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -109,7 +109,12 @@ export default class NoVnc extends Component {
// if not available from the URL, use the default ones // if not available from the URL, use the default ones
const port = url.port || (isSecure ? 443 : 80) const port = url.port || (isSecure ? 443 : 80)
rfb.connect(url.hostname, port, null, clippedPath) rfb.connect(
url.hostname,
port,
null,
clippedPath
)
disableShortcuts() disableShortcuts()
} }

View File

@ -45,7 +45,9 @@ export default class ResourceSetQuotas extends Component {
) )
render () { render () {
const { intl: { formatMessage } } = this.props const {
intl: { formatMessage },
} = this.props
const labels = [ const labels = [
formatMessage(messages.availableResourceLabel), formatMessage(messages.availableResourceLabel),
formatMessage(messages.usedResourceLabel), formatMessage(messages.usedResourceLabel),

View File

@ -5,17 +5,17 @@ const createAction = (() => {
defineProperty( defineProperty(
payloadCreator payloadCreator
? (...args) => ({ ? (...args) => ({
type, type,
payload: payloadCreator(...args), payload: payloadCreator(...args),
}) })
: (action => : (action =>
function () { function () {
if (arguments.length) { if (arguments.length) {
throw new Error('this action expects no payload!') throw new Error('this action expects no payload!')
} }
return action return action
})({ type }), })({ type }),
'toString', 'toString',
{ value: () => type } { value: () => type }
) )

View File

@ -38,7 +38,7 @@ const Element = ({ highlight, href, others, tooltip, total, value }) => (
highlight && 'usage-element-highlight', highlight && 'usage-element-highlight',
others && 'usage-element-others' others && 'usage-element-others'
)} )}
style={{ width: value / total * 100 + '%' }} style={{ width: (value / total) * 100 + '%' }}
/> />
</Tooltip> </Tooltip>
) )
@ -58,14 +58,14 @@ export const Limits = ({ used, toBeUsed, limit }) => {
<span className='limits'> <span className='limits'>
<span <span
className='limits-used' className='limits-used'
style={{ width: (used || 0) / limit * 100 + '%' }} style={{ width: ((used || 0) / limit) * 100 + '%' }}
/> />
<span <span
className={ className={
toBeUsed > available ? 'limits-over-used' : 'limits-to-be-used' toBeUsed > available ? 'limits-over-used' : 'limits-to-be-used'
} }
style={{ style={{
width: Math.min(toBeUsed || 0, available) / limit * 100 + '%', width: (Math.min(toBeUsed || 0, available) / limit) * 100 + '%',
}} }}
/> />
</span> </span>

View File

@ -23,7 +23,7 @@ const TOOLTIP_PADDING = 10
const DEFAULT_STROKE_WIDTH_FACTOR = 500 const DEFAULT_STROKE_WIDTH_FACTOR = 500
const HIGHLIGHT_STROKE_WIDTH_FACTOR = 200 const HIGHLIGHT_STROKE_WIDTH_FACTOR = 200
const BRUSH_SELECTION_WIDTH = 2 * CHART_WIDTH / 100 const BRUSH_SELECTION_WIDTH = (2 * CHART_WIDTH) / 100
// =================================================================== // ===================================================================

View File

@ -376,7 +376,10 @@ export default class XoWeekCharts extends Component {
} }
render () { render () {
const { props, state: { chartsWidth, maxValue, tooltipX } } = this const {
props,
state: { chartsWidth, maxValue, tooltipX },
} = this
return ( return (
<div> <div>

View File

@ -166,9 +166,9 @@ export default class XoWeekHeatmap extends Component {
content={ content={
hour hour
? _('weekHeatmapData', { ? _('weekHeatmapData', {
date: hour.date, date: hour.date,
value: this.props.cellRenderer(hour.value), value: this.props.cellRenderer(hour.value),
}) })
: _('weekHeatmapNoData') : _('weekHeatmapNoData')
} }
key={key} key={key}

View File

@ -64,7 +64,7 @@ export default class AddHostModal extends BaseComponent {
host, host,
nMissingPatches: host nMissingPatches: host
? differenceBy(this.props.poolMasterPatches, host.patches, 'name') ? differenceBy(this.props.poolMasterPatches, host.patches, 'name')
.length .length
: undefined, : undefined,
}) })
} }

View File

@ -32,12 +32,12 @@ class CopyVmsModalBody extends BaseComponent {
const names = namePattern const names = namePattern
? map( ? map(
vms, vms,
buildTemplate(namePattern, { buildTemplate(namePattern, {
'{name}': vm => vm.name_label, '{name}': vm => vm.name_label,
'{id}': vm => vm.id, '{id}': vm => vm.id,
}) })
) )
: map(vms, vm => vm.name_label) : map(vms, vm => vm.name_label)
return { return {
compress: state.compress, compress: state.compress,

View File

@ -31,7 +31,8 @@ const Upgrade = propTypes({
> >
<Icon icon='plan-upgrade' /> {_('upgradeNow')} <Icon icon='plan-upgrade' /> {_('upgradeNow')}
</a>{' '} </a>{' '}
{_('or')}&nbsp; {_('or')}
&nbsp;
<Link className='btn btn-success btn-lg' to='/xoa/update'> <Link className='btn btn-success btn-lg' to='/xoa/update'>
<Icon icon='plan-trial' /> {_('tryIt')} <Icon icon='plan-trial' /> {_('tryIt')}
</Link> </Link>

View File

@ -16,7 +16,8 @@ import { scanDisk, scanFiles } from 'xo'
const backupOptionRenderer = backup => ( const backupOptionRenderer = backup => (
<span> <span>
{backup.tag} - {backup.remoteName} (<FormattedDate {backup.tag} - {backup.remoteName} (
<FormattedDate
value={backup.datetime * 1e3} value={backup.datetime * 1e3}
month='long' month='long'
day='numeric' day='numeric'
@ -24,7 +25,8 @@ const backupOptionRenderer = backup => (
hour='2-digit' hour='2-digit'
minute='2-digit' minute='2-digit'
second='2-digit' second='2-digit'
/>) />
)
</span> </span>
) )

View File

@ -50,7 +50,8 @@ const backupOptionRenderer = backup => (
<span className='tag tag-info'>{_('delta')}</span>{' '} <span className='tag tag-info'>{_('delta')}</span>{' '}
</span> </span>
)} )}
{backup.tag} - {backup.remoteName} (<FormattedDate {backup.tag} - {backup.remoteName} (
<FormattedDate
value={new Date(backup.date)} value={new Date(backup.date)}
month='long' month='long'
day='numeric' day='numeric'
@ -58,7 +59,8 @@ const backupOptionRenderer = backup => (
hour='2-digit' hour='2-digit'
minute='2-digit' minute='2-digit'
second='2-digit' second='2-digit'
/>) />
)
</span> </span>
) )

View File

@ -467,7 +467,7 @@ class DefaultCard extends Component {
labels: map(topSrs, 'name_label'), labels: map(topSrs, 'name_label'),
series: map( series: map(
topSrs, topSrs,
sr => sr.physical_usage / sr.size * 100 sr => (sr.physical_usage / sr.size) * 100
), ),
}} }}
options={{ options={{

View File

@ -191,7 +191,7 @@ class SelectMetric extends Component {
objects, objects,
predicate: objects.length predicate: objects.length
? object => ? object =>
runningObjectsPredicate(object) && object.type === objects[0].type runningObjectsPredicate(object) && object.type === objects[0].type
: runningObjectsPredicate, : runningObjectsPredicate,
}) })
} }

View File

@ -180,7 +180,7 @@ export default class HostItem extends Component {
<Tooltip <Tooltip
content={_('memoryLeftTooltip', { content={_('memoryLeftTooltip', {
used: Math.round( used: Math.round(
host.memory.usage / host.memory.size * 100 (host.memory.usage / host.memory.size) * 100
), ),
free: formatSizeShort(host.memory.size - host.memory.usage), free: formatSizeShort(host.memory.size - host.memory.usage),
})} })}
@ -188,7 +188,7 @@ export default class HostItem extends Component {
<progress <progress
style={{ margin: 0 }} style={{ margin: 0 }}
className='progress' className='progress'
value={host.memory.usage / host.memory.size * 100} value={(host.memory.usage / host.memory.size) * 100}
max='100' max='100'
/> />
</Tooltip> </Tooltip>
@ -213,7 +213,8 @@ export default class HostItem extends Component {
className={styles.itemExpandButton} className={styles.itemExpandButton}
onClick={this._toggleExpanded} onClick={this._toggleExpanded}
> >
<Icon icon='nav' fixedWidth />&nbsp;&nbsp;&nbsp; <Icon icon='nav' fixedWidth />
&nbsp;&nbsp;&nbsp;
</a> </a>
</Col> </Col>
</SingleLineRow> </SingleLineRow>

View File

@ -200,7 +200,7 @@ export default class PoolItem extends Component {
<Tooltip <Tooltip
content={_('memoryLeftTooltip', { content={_('memoryLeftTooltip', {
used: Math.round( used: Math.round(
hostMetrics.memoryUsage / hostMetrics.memoryTotal * 100 (hostMetrics.memoryUsage / hostMetrics.memoryTotal) * 100
), ),
free: formatSizeShort( free: formatSizeShort(
hostMetrics.memoryTotal - hostMetrics.memoryUsage hostMetrics.memoryTotal - hostMetrics.memoryUsage
@ -211,7 +211,7 @@ export default class PoolItem extends Component {
style={{ margin: 0 }} style={{ margin: 0 }}
className='progress' className='progress'
value={ value={
hostMetrics.memoryUsage / hostMetrics.memoryTotal * 100 (hostMetrics.memoryUsage / hostMetrics.memoryTotal) * 100
} }
max='100' max='100'
/> />
@ -223,7 +223,8 @@ export default class PoolItem extends Component {
className={styles.itemExpandButton} className={styles.itemExpandButton}
onClick={this._toggleExpanded} onClick={this._toggleExpanded}
> >
<Icon icon='nav' fixedWidth />&nbsp;&nbsp;&nbsp; <Icon icon='nav' fixedWidth />
&nbsp;&nbsp;&nbsp;
</a> </a>
</Col> </Col>
</SingleLineRow> </SingleLineRow>
@ -233,8 +234,8 @@ export default class PoolItem extends Component {
<Col mediumSize={3} className={styles.itemExpanded}> <Col mediumSize={3} className={styles.itemExpanded}>
<span> <span>
{hostMetrics.count}x <Icon icon='host' /> {nVms}x{' '} {hostMetrics.count}x <Icon icon='host' /> {nVms}x{' '}
<Icon icon='vm' /> {nSrs}x <Icon icon='sr' /> {hostMetrics.cpus}x{' '} <Icon icon='vm' /> {nSrs}x <Icon icon='sr' /> {hostMetrics.cpus}
<Icon icon='cpu' /> {formatSizeShort(hostMetrics.memoryTotal)} x <Icon icon='cpu' /> {formatSizeShort(hostMetrics.memoryTotal)}
</span> </span>
</Col> </Col>
<Col mediumSize={4} className={styles.itemExpanded}> <Col mediumSize={4} className={styles.itemExpanded}>

View File

@ -164,14 +164,16 @@ export default class SrItem extends Component {
{sr.size > 0 && ( {sr.size > 0 && (
<Tooltip <Tooltip
content={_('spaceLeftTooltip', { content={_('spaceLeftTooltip', {
used: String(Math.round(sr.physical_usage / sr.size * 100)), used: String(
Math.round((sr.physical_usage / sr.size) * 100)
),
free: formatSizeShort(sr.size - sr.physical_usage), free: formatSizeShort(sr.size - sr.physical_usage),
})} })}
> >
<progress <progress
style={{ margin: 0 }} style={{ margin: 0 }}
className='progress' className='progress'
value={sr.physical_usage / sr.size * 100} value={(sr.physical_usage / sr.size) * 100}
max='100' max='100'
/> />
</Tooltip> </Tooltip>
@ -189,7 +191,8 @@ export default class SrItem extends Component {
className={styles.itemExpandButton} className={styles.itemExpandButton}
onClick={this._toggleExpanded} onClick={this._toggleExpanded}
> >
<Icon icon='nav' fixedWidth />&nbsp;&nbsp;&nbsp; <Icon icon='nav' fixedWidth />
&nbsp;&nbsp;&nbsp;
</a> </a>
</Col> </Col>
</SingleLineRow> </SingleLineRow>

View File

@ -88,7 +88,8 @@ export default class TemplateItem extends Component {
className={styles.itemExpandButton} className={styles.itemExpandButton}
onClick={this.toggleState('expanded')} onClick={this.toggleState('expanded')}
> >
<Icon icon='nav' fixedWidth />&nbsp;&nbsp;&nbsp; <Icon icon='nav' fixedWidth />
&nbsp;&nbsp;&nbsp;
</a> </a>
</Col> </Col>
</SingleLineRow> </SingleLineRow>

View File

@ -197,7 +197,8 @@ export default class VmItem extends Component {
className={styles.itemExpandButton} className={styles.itemExpandButton}
onClick={this._toggleExpanded} onClick={this._toggleExpanded}
> >
<Icon icon='nav' fixedWidth />&nbsp;&nbsp;&nbsp; <Icon icon='nav' fixedWidth />
&nbsp;&nbsp;&nbsp;
</a> </a>
</Col> </Col>
</SingleLineRow> </SingleLineRow>

View File

@ -172,9 +172,8 @@ export default class extends Component {
<tr> <tr>
<th>{_('hostXenServerVersion')}</th> <th>{_('hostXenServerVersion')}</th>
<Copiable tagName='td' data={host.version}> <Copiable tagName='td' data={host.version}>
{host.license_params.sku_marketing_name} {host.version} ({ {host.license_params.sku_marketing_name} {host.version} (
host.license_params.sku_type {host.license_params.sku_type})
})
</Copiable> </Copiable>
</tr> </tr>
<tr> <tr>
@ -219,17 +218,15 @@ export default class extends Component {
<tr> <tr>
<th>{_('hostManufacturerinfo')}</th> <th>{_('hostManufacturerinfo')}</th>
<Copiable tagName='td'> <Copiable tagName='td'>
{host.bios_strings['system-manufacturer']} ({ {host.bios_strings['system-manufacturer']} (
host.bios_strings['system-product-name'] {host.bios_strings['system-product-name']})
})
</Copiable> </Copiable>
</tr> </tr>
<tr> <tr>
<th>{_('hostBiosinfo')}</th> <th>{_('hostBiosinfo')}</th>
<td> <td>
{host.bios_strings['bios-vendor']} ({ {host.bios_strings['bios-vendor']} (
host.bios_strings['bios-version'] {host.bios_strings['bios-version']})
})
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@ -85,9 +85,11 @@ export default ({
</Col> </Col>
<Col mediumSize={3}> <Col mediumSize={3}>
<p> <p>
{host.productBrand} {host.version} ({host.productBrand !== 'XCP-ng' {host.productBrand} {host.version} (
{host.productBrand !== 'XCP-ng'
? host.license_params.sku_type ? host.license_params.sku_type
: 'GPLv2'}) : 'GPLv2'}
)
</p> </p>
</Col> </Col>
<Col mediumSize={3}> <Col mediumSize={3}>

View File

@ -120,7 +120,7 @@ export default connectStore(() => {
pbdId: pbd.id, pbdId: pbd.id,
shared: isSrShared(sr), shared: isSrShared(sr),
size: size > 0 ? size : 0, size: size > 0 ? size : 0,
usagePercentage: size > 0 && Math.round(100 * usage / size), usagePercentage: size > 0 && Math.round((100 * usage) / size),
} }
}) })
) )

View File

@ -166,10 +166,9 @@ export default [
let globalIsFull let globalIsFull
return ( return (
<li key={taskLog.data.id} className='list-group-item'> <li key={taskLog.data.id} className='list-group-item'>
<VmItem id={taskLog.data.id} link /> ({taskLog.data.id.slice( <VmItem id={taskLog.data.id} link /> (
4, {taskLog.data.id.slice(4, 8)}){' '}
8 <TaskStateInfos status={taskLog.status} />{' '}
)}) <TaskStateInfos status={taskLog.status} />{' '}
{scheduleId !== undefined && {scheduleId !== undefined &&
taskLog.status !== 'success' && taskLog.status !== 'success' &&
taskLog.status !== 'pending' && ( taskLog.status !== 'pending' && (
@ -202,17 +201,13 @@ export default [
</span> </span>
) : subTaskLog.data.type === 'remote' ? ( ) : subTaskLog.data.type === 'remote' ? (
<span> <span>
<RemoteItem id={subTaskLog.data.id} link /> ({subTaskLog.data.id.slice( <RemoteItem id={subTaskLog.data.id} link /> (
4, {subTaskLog.data.id.slice(4, 8)})
8
)})
</span> </span>
) : ( ) : (
<span> <span>
<SrItem id={subTaskLog.data.id} link /> ({subTaskLog.data.id.slice( <SrItem id={subTaskLog.data.id} link /> (
4, {subTaskLog.data.id.slice(4, 8)})
8
)})
</span> </span>
)}{' '} )}{' '}
<TaskStateInfos status={subTaskLog.status} /> <TaskStateInfos status={subTaskLog.status} />

View File

@ -506,7 +506,8 @@ const MenuLinkItem = props => {
/> />
<span className={styles.hiddenCollapsed}> <span className={styles.hiddenCollapsed}>
{' '} {' '}
{typeof label === 'string' ? _(label) : label}&nbsp; {typeof label === 'string' ? _(label) : label}
&nbsp;
</span> </span>
{pill > 0 && <span className='tag tag-pill tag-primary'>{pill}</span>} {pill > 0 && <span className='tag tag-pill tag-primary'>{pill}</span>}
{extra} {extra}

View File

@ -117,7 +117,12 @@ const LineItem = ({ children }) => (
const Item = ({ label, children, className }) => ( const Item = ({ label, children, className }) => (
<span className={styles.item}> <span className={styles.item}>
{label && <span>{label}&nbsp;</span>} {label && (
<span>
{label}
&nbsp;
</span>
)}
<span className={classNames(styles.input, className)}>{children}</span> <span className={classNames(styles.input, className)}>{children}</span>
</span> </span>
) )
@ -221,10 +226,13 @@ class Vif extends BaseComponent {
pool: createGetObject((_, props) => props.location.query.pool), pool: createGetObject((_, props) => props.location.query.pool),
pools: createGetObjectsOfType('pool'), pools: createGetObjectsOfType('pool'),
templates: createGetObjectsOfType('VM-template').sort(), templates: createGetObjectsOfType('VM-template').sort(),
userSshKeys: createSelector((_, props) => { userSshKeys: createSelector(
const user = props.user (_, props) => {
return user && user.preferences && user.preferences.sshKeys const user = props.user
}, keys => keys), return user && user.preferences && user.preferences.sshKeys
},
keys => keys
),
srs: createGetObjectsOfType('SR'), srs: createGetObjectsOfType('SR'),
})) }))
@injectIntl @injectIntl

View File

@ -726,7 +726,8 @@ export default class New extends Component {
onChange={event => { onChange={event => {
this._handleAuthChoice() this._handleAuthChoice()
}} }}
/>) />
)
</label> </label>
<div className='form-inline'> <div className='form-inline'>
<input <input

View File

@ -248,7 +248,9 @@ class PifsItem extends BaseComponent {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{map(network.PIFs, pifId => <PifItem key={pifId} id={pifId} />)} {map(network.PIFs, pifId => (
<PifItem key={pifId} id={pifId} />
))}
</tbody> </tbody>
</table> </table>
)} )}

View File

@ -43,7 +43,11 @@ class UserDisplay extends Component {
return ( return (
<span> <span>
{(id && users && users[id] && users[id].email) || ( {(id && users && users[id] && users[id].email) || (
<em>&lt;{_('unknownUser')}&gt;</em> <em>
&lt;
{_('unknownUser')}
&gt;
</em>
)}{' '} )}{' '}
<ActionButton <ActionButton
className='pull-right' className='pull-right'

View File

@ -189,7 +189,13 @@ export default class Servers extends Component {
} }
render () { render () {
const { props: { intl: { formatMessage }, servers }, state } = this const {
props: {
intl: { formatMessage },
servers,
},
state,
} = this
return ( return (
<Container> <Container>

View File

@ -61,10 +61,8 @@ export default class TabGeneral extends Component {
<Row> <Row>
<Col className='text-xs-center'> <Col className='text-xs-center'>
<h5> <h5>
{formatSize(sr.physical_usage)} {_('srUsed')} ({formatSize( {formatSize(sr.physical_usage)} {_('srUsed')} (
sr.size - sr.physical_usage {formatSize(sr.size - sr.physical_usage)} {_('srFree')})
)}{' '}
{_('srFree')})
</h5> </h5>
</Col> </Col>
</Row> </Row>

View File

@ -110,7 +110,9 @@ class Node extends Component {
() => this.props.node.statusDetail, () => this.props.node.statusDetail,
statusDetail => ({ statusDetail => ({
used: String( used: String(
Math.round(100 - +statusDetail.sizeFree / +statusDetail.sizeTotal * 100) Math.round(
100 - (+statusDetail.sizeFree / +statusDetail.sizeTotal) * 100
)
), ),
free: formatSize(+statusDetail.sizeFree), free: formatSize(+statusDetail.sizeFree),
}) })
@ -121,7 +123,7 @@ class Node extends Component {
statusDetail => ({ statusDetail => ({
used: String( used: String(
Math.round( Math.round(
100 - +statusDetail.inodesFree / +statusDetail.inodesTotal * 100 100 - (+statusDetail.inodesFree / +statusDetail.inodesTotal) * 100
) )
), ),
free: formatSize(+statusDetail.inodesFree), free: formatSize(+statusDetail.inodesFree),
@ -215,7 +217,7 @@ class Node extends Component {
max='100' max='100'
value={ value={
100 - 100 -
+statusDetail.sizeFree / +statusDetail.sizeTotal * 100 (+statusDetail.sizeFree / +statusDetail.sizeTotal) * 100
} }
/> />
</Tooltip> </Tooltip>
@ -272,8 +274,8 @@ class Node extends Component {
max='100' max='100'
value={ value={
100 - 100 -
+statusDetail.inodesFree / (+statusDetail.inodesFree /
+statusDetail.inodesTotal * +statusDetail.inodesTotal) *
100 100
} }
/> />
@ -689,7 +691,9 @@ export default class TabXosan extends Component {
size='lg' size='lg'
color={ color={
status_ status_
? status_.commandStatus ? 'text-success' : status_.error ? status_.commandStatus
? 'text-success'
: status_.error
: 'text-info' : 'text-info'
} }
/> />
@ -702,7 +706,9 @@ export default class TabXosan extends Component {
size='lg' size='lg'
color={ color={
heal_ heal_
? heal_.commandStatus ? 'text-success' : heal_.error ? heal_.commandStatus
? 'text-success'
: heal_.error
: 'text-info' : 'text-info'
} }
/> />
@ -730,7 +736,9 @@ export default class TabXosan extends Component {
size='lg' size='lg'
color={ color={
info_ info_
? info_.commandStatus ? 'text-success' : info_.error ? info_.commandStatus
? 'text-success'
: info_.error
: 'text-info' : 'text-info'
} }
/> />

View File

@ -553,7 +553,8 @@ export default class TabAdvanced extends Component {
<th>{_('vmMemoryLimitsLabel')}</th> <th>{_('vmMemoryLimitsLabel')}</th>
<td> <td>
<p> <p>
Static: {formatSize(vm.memory.static[0])}/<Size Static: {formatSize(vm.memory.static[0])}/
<Size
value={defined(vm.memory.static[1], null)} value={defined(vm.memory.static[1], null)}
onChange={memoryStaticMax => onChange={memoryStaticMax =>
editVm(vm, { memoryStaticMax }) editVm(vm, { memoryStaticMax })
@ -565,7 +566,9 @@ export default class TabAdvanced extends Component {
<Size <Size
value={defined(vm.memory.dynamic[0], null)} value={defined(vm.memory.dynamic[0], null)}
onChange={memoryMin => editVm(vm, { memoryMin })} onChange={memoryMin => editVm(vm, { memoryMin })}
/>/<Size />
/
<Size
value={defined(vm.memory.dynamic[1], null)} value={defined(vm.memory.dynamic[1], null)}
onChange={memoryMax => editVm(vm, { memoryMax })} onChange={memoryMax => editVm(vm, { memoryMax })}
/> />
@ -596,7 +599,9 @@ export default class TabAdvanced extends Component {
<Icon <Icon
className='text-info' className='text-info'
icon={osFamily(vm.os_version.distro)} icon={osFamily(vm.os_version.distro)}
/>&nbsp;{vm.os_version.name} />
&nbsp;
{vm.os_version.name}
</span> </span>
)} )}
</td> </td>

View File

@ -61,7 +61,8 @@ export default connectStore(() => {
<Number <Number
value={vm.CPUs.number} value={vm.CPUs.number}
onChange={vcpus => editVm(vm, { CPUs: vcpus })} onChange={vcpus => editVm(vm, { CPUs: vcpus })}
/>x <Icon icon='cpu' size='lg' /> />
x <Icon icon='cpu' size='lg' />
</h2> </h2>
<BlockLink to={`/vms/${vm.id}/stats`}> <BlockLink to={`/vms/${vm.id}/stats`}>
{statsOverview && <CpuSparkLines data={statsOverview} />} {statsOverview && <CpuSparkLines data={statsOverview} />}
@ -73,7 +74,8 @@ export default connectStore(() => {
value={defined(vm.memory.dynamic[1], null)} value={defined(vm.memory.dynamic[1], null)}
onChange={memory => editVm(vm, { memory })} onChange={memory => editVm(vm, { memory })}
/> />
&nbsp;<span> &nbsp;
<span>
<Icon icon='memory' size='lg' /> <Icon icon='memory' size='lg' />
</span> </span>
</h2> </h2>

View File

@ -242,7 +242,8 @@ export default class XoaUpdates extends Component {
<div> <div>
{map(log, (log, key) => ( {map(log, (log, key) => (
<p key={key}> <p key={key}>
<span className={textClasses[log.level]}>{log.date}</span>:{' '} <span className={textClasses[log.level]}>{log.date}</span>
:{' '}
<span <span
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
__html: ansiUp.ansi_to_html(log.message), __html: ansiUp.ansi_to_html(log.message),

View File

@ -47,9 +47,9 @@ const fork = (n, x, y, w, h, nDisksLoss) => [
stroke(w / (2 * n), 0, w - w / (2 * n), 0, x, y), stroke(w / (2 * n), 0, w - w / (2 * n), 0, x, y),
// vertical lines (and disks icons) // vertical lines (and disks icons)
map(new Array(n), (_, i) => [ map(new Array(n), (_, i) => [
stroke(i * w / n + w / (2 * n), 0, i * w / n + w / (2 * n), h, x, y), stroke((i * w) / n + w / (2 * n), 0, (i * w) / n + w / (2 * n), h, x, y),
nDisksLoss !== undefined && nDisksLoss !== undefined &&
disk(x + i * w / n + w / (2 * n), y + h, i >= n - nDisksLoss), disk(x + (i * w) / n + w / (2 * n), y + h, i >= n - nDisksLoss),
]), ]),
] ]
@ -63,18 +63,18 @@ const graph = (nGroups, nPerGroup, w, h, disksLoss) => {
{nGroups === 1 {nGroups === 1
? fork(nPerGroup, 0, 2 * hUnit, w, hUnit, disksLoss) ? fork(nPerGroup, 0, 2 * hUnit, w, hUnit, disksLoss)
: [ : [
fork(nGroups, 0, 2 * hUnit, w, hUnit), fork(nGroups, 0, 2 * hUnit, w, hUnit),
map(new Array(nGroups), (_, i) => map(new Array(nGroups), (_, i) =>
fork( fork(
nPerGroup, nPerGroup,
i * w / nGroups, (i * w) / nGroups,
3 * hUnit, 3 * hUnit,
w / nGroups, w / nGroups,
hUnit, hUnit,
disksLoss disksLoss
) )
), ),
]} ]}
</svg> </svg>
) )
} }
@ -109,11 +109,11 @@ export default class Graph extends Component {
{layout === 'disperse' {layout === 'disperse'
? disperseGraph(nSrs, redundancy, width, height) ? disperseGraph(nSrs, redundancy, width, height)
: replicationGraph( : replicationGraph(
nSrs, nSrs,
redundancy - (layout === 'replica_arbiter' ? 1 : 0), redundancy - (layout === 'replica_arbiter' ? 1 : 0),
width, width,
height height
)} )}
</div> </div>
</div> </div>
<div> <div>

View File

@ -62,7 +62,9 @@ const XOSAN_COLUMNS = [
: _('xosanBadStatus', { : _('xosanBadStatus', {
badStatuses: ( badStatuses: (
<ul> <ul>
{map(status, (_, status) => <li key={status}>{status}</li>)} {map(status, (_, status) => (
<li key={status}>{status}</li>
))}
</ul> </ul>
), ),
}) })
@ -117,18 +119,18 @@ const XOSAN_COLUMNS = [
sr.size > 0 ? ( sr.size > 0 ? (
<Tooltip <Tooltip
content={_('spaceLeftTooltip', { content={_('spaceLeftTooltip', {
used: String(Math.round(sr.physical_usage * 100 / sr.size)), used: String(Math.round((sr.physical_usage * 100) / sr.size)),
free: formatSize(sr.size - sr.physical_usage), free: formatSize(sr.size - sr.physical_usage),
})} })}
> >
<progress <progress
className='progress' className='progress'
max='100' max='100'
value={sr.physical_usage * 100 / sr.size} value={(sr.physical_usage * 100) / sr.size}
/> />
</Tooltip> </Tooltip>
) : null, ) : null,
sortCriteria: sr => sr.physical_usage * 100 / sr.size, sortCriteria: sr => (sr.physical_usage * 100) / sr.size,
}, },
{ {
name: _('xosanLicense'), name: _('xosanLicense'),

View File

@ -416,7 +416,7 @@ export default class NewXosan extends Component {
content={_('spaceLeftTooltip', { content={_('spaceLeftTooltip', {
used: String( used: String(
Math.round( Math.round(
sr.physical_usage / sr.size * 100 (sr.physical_usage / sr.size) * 100
) )
), ),
free: formatSize( free: formatSize(
@ -427,7 +427,7 @@ export default class NewXosan extends Component {
<progress <progress
className='progress' className='progress'
max='100' max='100'
value={sr.physical_usage / sr.size * 100} value={(sr.physical_usage / sr.size) * 100}
/> />
</Tooltip> </Tooltip>
)} )}

View File

@ -10,7 +10,11 @@ const formatFiles = files => {
const testFiles = files => const testFiles = files =>
run( run(
'./node_modules/.bin/jest', './node_modules/.bin/jest',
['--testRegex=^(?!.*.integ.spec.js$).*.spec.js$', '--findRelatedTests', '--passWithNoTests'].concat(files) [
'--testRegex=^(?!.*.integ.spec.js$).*.spec.js$',
'--findRelatedTests',
'--passWithNoTests',
].concat(files)
) )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -17,7 +17,6 @@ const deleteProperties = (object, property, properties) => {
} }
} }
require('exec-promise')(() => require('exec-promise')(() =>
getPackages(true).map(({ dir, name, package: pkg, relativeDir }) => { getPackages(true).map(({ dir, name, package: pkg, relativeDir }) => {
pkg.name = name pkg.name = name