Compare commits

...

21 Commits

Author SHA1 Message Date
Pierre Donias
15e96e0921 feat: add Visualization view 2019-07-17 10:54:15 +02:00
Julien Fontanet
9644cabbac feat(lint-staged): enable for jsx, ts and tsx files 2019-05-29 15:44:23 +02:00
Julien Fontanet
c4eeb2b77e connection to xo-server 2019-05-29 13:57:43 +02:00
Julien Fontanet
ee1e9ba7b7 typescript 2019-05-29 13:57:42 +02:00
Julien Fontanet
3655117a13 feat(xo-web-6): initial config 2019-05-29 13:57:41 +02:00
Julien Fontanet
cc2c71c076 chore(xo-server): remove unnecessary methods 2019-05-28 18:53:57 +02:00
Pierre Donias
9ca273b2c4 chore(CHANGELOG.unreleased): add some missing links (#4253) 2019-05-28 14:09:19 +02:00
Julien Fontanet
b85c2f35b6 fix(xo-server/vm.set): autoPoweronauto_poweron in XAPI
Related to 0e1e32d241
2019-05-28 11:48:00 +02:00
HamadaBrest
fdd79885f9 feat(xo-web/VM): display VDI size in migrate modal (#4250)
Fixes #2534
2019-05-27 16:56:45 +02:00
Julien Fontanet
b2eb970796 fix(xo-server/vm.set): cast weight to string
Follow-up of 49e1b0ba7
2019-05-27 16:23:38 +02:00
Julien Fontanet
3ee9c1b550 chore(xo-server/Xapi): remove unused setVcpuWeight 2019-05-27 16:23:37 +02:00
HamadaBrest
2566c24753 fix(xo-web/host): incorrect hypervisor name in RAM usage tooltip (#4248)
Fixes #4246
2019-05-27 15:44:59 +02:00
Julien Fontanet
49e1b0ba7e fix(xo-server/vm.set): cast logical numbers to XAPI string values 2019-05-27 11:10:19 +02:00
Julien Fontanet
453c329f14 fix(xo-server/vm.set): videoram is strictly a number 2019-05-27 11:04:44 +02:00
badrAZ
27193f38f3 feat(xo-web): 5.42.0 2019-05-24 15:32:16 +02:00
badrAZ
d3dc94e210 feat(xo-server): 5.42.0 2019-05-24 15:31:54 +02:00
Julien Fontanet
6dad860635 fix(xo-server/getRemoteHandler): only cache on success
Otherwise subsequent calls will use an invalid handler.

Related to xoa-support#1498
2019-05-23 18:13:58 +02:00
Julien Fontanet
0362ac8909 feat(xo-web/home): case-sensitive filtering 2019-05-23 17:34:19 +02:00
Pierre Donias
e7b79f83d1 fix(xo-web): cast XOA_PLAN for strict equality tests (#4241) 2019-05-23 17:17:48 +02:00
Pierre Donias
62379c1e41 feat(xo-web/settings/logs): suggest XCP-ng when LICENCE_RESTRICTION (#4238)
Fixes #3876
2019-05-23 17:16:39 +02:00
Pierre Donias
23b422e3df feat(xo-server,xo-web/user): forget all authentication tokens (#4224)
Fixes #4214
2019-05-23 17:13:27 +02:00
39 changed files with 252375 additions and 123 deletions

View File

@@ -23,14 +23,20 @@ const configs = {
shippedProposals: true,
targets: (() => {
const targets = {}
const browsers = pkg.browserslist
if (browsers !== undefined) {
targets.browsers = browsers
}
let node = (pkg.engines || {}).node
if (node !== undefined) {
const trimChars = '^=>~'
while (trimChars.includes(node[0])) {
node = node.slice(1)
}
targets.node = node
}
return { browsers: pkg.browserslist, node }
return targets
})(),
useBuiltIns: '@babel/polyfill' in (pkg.dependencies || {}) && 'usage',
}

View File

@@ -5,14 +5,19 @@
- [VM/general] Display 'Started... ago' instead of 'Halted... ago' for paused state [#3750](https://github.com/vatesfr/xen-orchestra/issues/3750) (PR [#4170](https://github.com/vatesfr/xen-orchestra/pull/4170))
- [Metadata backup] Ability to define when the backup report will be sent (PR [#4149](https://github.com/vatesfr/xen-orchestra/pull/4149))
- [XOA/Update] Ability to select release channel [#4200](https://github.com/vatesfr/xen-orchestra/issues/4200) (PR [#4202](https://github.com/vatesfr/xen-orchestra/pull/4202))
- [User] Forget connection tokens on password change or on demand [#4214](https://github.com/vatesfr/xen-orchestra/issues/4214) (PR [#4224](https://github.com/vatesfr/xen-orchestra/pull/4224))
- [Settings/Logs] LICENCE_RESTRICTION errors: suggest XCP-ng as an Open Source alternative [#3876](https://github.com/vatesfr/xen-orchestra/issues/3876) (PR [#4238](https://github.com/vatesfr/xen-orchestra/pull/4238))
- [VM/Migrate] Display VDI size on migrate modal [#2534](https://github.com/vatesfr/xen-orchestra/issues/2534) (PR [#4250](https://github.com/vatesfr/xen-orchestra/pull/4250))
### Bug fixes
- [Charts] Fixed the chart lines sometimes changing order/color (PR [#4221](https://github.com/vatesfr/xen-orchestra/pull/4221))
- Prevent non-admin users to access admin pages with URL
- [Upgrade] Fix alert before upgrade while running backup jobs (PR [#4235](https://github.com/vatesfr/xen-orchestra/pull/4235))
- Prevent non-admin users to access admin pages with URL (PR [#4220](https://github.com/vatesfr/xen-orchestra/pull/4220))
- [Upgrade] Fix alert before upgrade while running backup jobs [#4164](https://github.com/vatesfr/xen-orchestra/issues/4164) (PR [#4235](https://github.com/vatesfr/xen-orchestra/pull/4235))
- [Import] Fix import OVA files (PR [#4232](https://github.com/vatesfr/xen-orchestra/pull/4232))
- [VM/network] Fix duplicate IPv4 (PR [#4239](https://github.com/vatesfr/xen-orchestra/pull/4239))
- [Remotes] Fix disconnected remotes which may appear to work
- [Host] Fix incorrect hypervisor name [#4246](https://github.com/vatesfr/xen-orchestra/issues/4246) (PR [#4248](https://github.com/vatesfr/xen-orchestra/pull/4248))
### Released packages

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "xo-server",
"version": "5.41.0",
"version": "5.42.0",
"license": "AGPL-3.0",
"description": "Server part of Xen-Orchestra",
"keywords": [

View File

@@ -4,23 +4,19 @@ import { format, JsonRpcError } from 'json-rpc-peer'
export async function set({
host,
multipathing,
// TODO: use camel case.
multipathing,
name_label: nameLabel,
name_description: nameDescription,
}) {
const xapi = this.getXapi(host)
const hostId = host._xapiId
host = this.getXapiObject(host)
if (multipathing !== undefined) {
await xapi.setHostMultipathing(hostId, multipathing)
}
return xapi.setHostProperties(hostId, {
nameLabel,
nameDescription,
})
await Promise.all([
nameDescription !== undefined && host.set_name_description(nameDescription),
nameLabel !== undefined && host.set_name_label(nameLabel),
multipathing !== undefined &&
host.$xapi.setHostMultipathing(host.$id, multipathing),
])
}
set.description = 'changes the properties of an host'

View File

@@ -85,18 +85,26 @@ createBonded.description =
// ===================================================================
export async function set({
network,
automatic,
defaultIsLocked,
name_description: nameDescription,
name_label: nameLabel,
network,
}) {
await this.getXapi(network).setNetworkProperties(network._xapiId, {
automatic,
defaultIsLocked,
nameDescription,
nameLabel,
})
network = this.getXapiObject(network)
await Promise.all([
automatic !== undefined &&
network.update_other_config('automatic', automatic ? 'true' : null),
defaultIsLocked !== undefined &&
network.set_default_locking_mode(
defaultIsLocked ? 'disabled' : 'unlocked'
),
nameDescription !== undefined &&
network.set_name_description(nameDescription),
nameLabel !== undefined && network.set_name_label(nameLabel),
])
}
set.params = {

View File

@@ -5,14 +5,15 @@ import { format, JsonRPcError } from 'json-rpc-peer'
export async function set({
pool,
// TODO: use camel case.
name_description: nameDescription,
name_label: nameLabel,
}) {
await this.getXapi(pool).setPoolProperties({
nameDescription,
nameLabel,
})
pool = this.getXapiObject(pool)
await Promise.all([
nameDescription !== undefined && pool.set_name_description(nameDescription),
nameLabel !== undefined && pool.set_name_label(nameLabel),
])
}
set.params = {

View File

@@ -10,14 +10,15 @@ import { forEach, parseXml } from '../utils'
export async function set({
sr,
// TODO: use camel case.
name_description: nameDescription,
name_label: nameLabel,
}) {
await this.getXapi(sr).setSrProperties(sr._xapiId, {
nameDescription,
nameLabel,
})
sr = this.getXapiObject(sr)
await Promise.all([
nameDescription !== undefined && sr.set_name_description(nameDescription),
nameLabel !== undefined && sr.set_name_label(nameLabel),
])
}
set.params = {

View File

@@ -34,3 +34,25 @@ delete_.permission = 'admin'
delete_.params = {
token: { type: 'string' },
}
// -------------------------------------------------------------------
export async function deleteAll({ except }) {
await this.deleteAuthenticationTokens({
filter: {
user_id: this.session.get('user_id'),
id: {
__not: except,
},
},
})
}
deleteAll.description =
'delete all tokens of the current user except the current one'
deleteAll.permission = ''
deleteAll.params = {
except: { type: 'string', optional: true },
}

View File

@@ -603,7 +603,7 @@ set.params = {
// Switch from Cirrus video adaptor to VGA adaptor
vga: { type: 'string', optional: true },
videoram: { type: ['string', 'number'], optional: true },
videoram: { type: 'number', optional: true },
coresPerSocket: { type: ['string', 'number', 'null'], optional: true },

View File

@@ -887,10 +887,10 @@ async function createVDIOnLVMWithoutSizeLimit(xapi, lvmSr, diskSize) {
await xapi.callAsync('SR.scan', xapi.getObject(lvmSr).$ref)
const vdi = find(xapi.getObject(lvmSr).$VDIs, vdi => vdi.uuid === uuid)
if (vdi != null) {
await xapi.setSrProperties(vdi.$ref, {
nameLabel: 'xosan_data',
nameDescription: 'Created by XO',
})
await Promise.all([
vdi.set_name_description('Created by XO'),
vdi.set_name_label('xosan_data'),
])
return vdi
}
}

View File

@@ -247,55 +247,6 @@ export default class Xapi extends XapiBase {
)::ignoreErrors()
}
async setHostProperties(id, { nameLabel, nameDescription }) {
const host = this.getObject(id)
await Promise.all([
nameDescription !== undefined &&
host.set_name_description(nameDescription),
nameLabel !== undefined && host.set_name_label(nameLabel),
])
}
async setPoolProperties({ autoPoweron, nameLabel, nameDescription }) {
const { pool } = this
await Promise.all([
nameDescription !== undefined &&
pool.set_name_description(nameDescription),
nameLabel !== undefined && pool.set_name_label(nameLabel),
autoPoweron != null &&
pool.update_other_config('autoPoweron', autoPoweron ? 'true' : null),
])
}
async setSrProperties(id, { nameLabel, nameDescription }) {
const sr = this.getObject(id)
await Promise.all([
nameDescription !== undefined && sr.set_name_description(nameDescription),
nameLabel !== undefined && sr.set_name_label(nameLabel),
])
}
async setNetworkProperties(
id,
{ automatic, defaultIsLocked, nameDescription, nameLabel }
) {
let defaultLockingMode
if (defaultIsLocked != null) {
defaultLockingMode = defaultIsLocked ? 'disabled' : 'unlocked'
}
const network = this.getObject(id)
await Promise.all([
defaultLockingMode !== undefined &&
network.set_default_locking_mode(defaultLockingMode),
nameDescription !== undefined &&
network.set_name_description(nameDescription),
nameLabel !== undefined && network.set_name_label(nameLabel),
automatic !== undefined &&
network.update_other_config('automatic', automatic ? 'true' : null),
])
}
// =================================================================
async addTag(id, tag) {
@@ -1574,13 +1525,6 @@ export default class Xapi extends XapiBase {
return /* await */ this._snapshotVm(this.getObject(vmId), nameLabel)
}
async setVcpuWeight(vmId, weight) {
await this.getObject(vmId).update_VCPUs_params(
'weight',
weight || null // Take all falsy values as a removal (0 included)
)
}
async _startVm(vm, host, force) {
log.debug(`Starting VM ${vm.name_label}`)

View File

@@ -268,11 +268,8 @@ export default {
autoPoweron: {
set(value, vm) {
return Promise.all([
vm.update_other_config('autoPoweron', value ? 'true' : null),
value &&
this.setPoolProperties({
autoPoweron: true,
}),
vm.update_other_config('auto_poweron', value ? 'true' : null),
value && vm.$pool.update_other_config('auto_poweron', 'true'),
])
},
},
@@ -294,7 +291,7 @@ export default {
coresPerSocket: {
set: (coresPerSocket, vm) =>
vm.update_platform('cores-per-socket', coresPerSocket),
vm.update_platform('cores-per-socket', String(coresPerSocket)),
},
CPUs: 'cpus',
@@ -318,7 +315,7 @@ export default {
cpuCap: {
get: vm => vm.VCPUs_params.cap && +vm.VCPUs_params.cap,
set: (cap, vm) => vm.update_VCPUs_params('cap', cap),
set: (cap, vm) => vm.update_VCPUs_params('cap', String(cap)),
},
cpuMask: {
@@ -341,7 +338,11 @@ export default {
cpuWeight: {
get: vm => vm.VCPUs_params.weight && +vm.VCPUs_params.weight,
set: (weight, vm) => vm.update_VCPUs_params('weight', weight),
set: (weight, vm) =>
vm.update_VCPUs_params(
'weight',
weight === null ? null : String(weight)
),
},
highAvailability: {
@@ -443,7 +444,7 @@ export default {
`The different values that the video RAM can take are: ${XEN_VIDEORAM_VALUES}`
)
}
return vm.update_platform('videoram', videoram)
return vm.update_platform('videoram', String(videoram))
},
},

View File

@@ -1,4 +1,5 @@
import createLogger from '@xen-orchestra/log'
import { createPredicate } from 'value-matcher'
import { ignoreErrors } from 'promise-toolbox'
import { invalidCredentials, noSuchObject } from 'xo-common/api-errors'
@@ -193,6 +194,14 @@ export default class {
}
}
async deleteAuthenticationTokens({ filter }) {
return Promise.all(
(await this._tokens.get())
.filter(createPredicate(filter))
.map(({ id }) => this.deleteAuthenticationToken(id))
)
}
async getAuthenticationToken(id) {
let token = await this._tokens.first(id)
if (token === undefined) {

View File

@@ -67,7 +67,7 @@ export default class {
const handlers = this._handlers
let handler = handlers[id]
if (handler === undefined) {
handler = handlers[id] = getHandler(remote, this._remoteOptions)
handler = getHandler(remote, this._remoteOptions)
try {
await handler.sync()
@@ -76,6 +76,8 @@ export default class {
ignoreErrors.call(this._updateRemote(id, { error: error.message }))
throw error
}
handlers[id] = handler
}
return handler

View File

@@ -0,0 +1,6 @@
const config = (module.exports = require('../../@xen-orchestra/babel-config')(
require('./package.json')
))
// https://webpack.js.org/guides/tree-shaking/
config.presets.find(_ => _[0] === '@babel/preset-env')[1].modules = false

View File

@@ -0,0 +1,47 @@
{
"name": "xo-web-6",
"version": "0.0.0",
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/packages/xo-web-6",
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
"repository": {
"directory": "packages/xo-web-6",
"type": "git",
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"devDependencies": {
"@babel/core": "^7.3.4",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.2.0",
"@babel/plugin-proposal-optional-chaining": "^7.2.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/preset-env": "^7.3.4",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
"@emotion/core": "^10.0.10",
"@emotion/styled": "^10.0.10",
"@types/react": "^16.8.13",
"@types/react-dom": "^16.8.4",
"@types/react-helmet": "^5.0.8",
"@types/react-router-dom": "^4.3.2",
"@types/webpack-env": "^1.13.9",
"babel-loader": "^8.0.5",
"clean-webpack-plugin": "^2.0.0",
"cross-env": "^5.2.0",
"html-webpack-plugin": "^3.2.0",
"json-rpc-protocol": "^0.13.1",
"reaclette": "^0.9.0-0",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-helmet-async": "^1.0.2",
"react-router-dom": "^5.0.0",
"typescript": "^3.4.4",
"webpack": "^4.29.6",
"webpack-cli": "^3.2.3",
"webpack-dev-server": "^3.2.1"
},
"browserslist": "> 0.5%, last 2 versions, Firefox ESR, not dead",
"scripts": {
"build": "cross-env NODE_ENV=production webpack",
"start": "cross-env NODE_ENV=development webpack-dev-server --hot",
"start:open": "npm run start -- --open"
}
}

View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="theme-color" content="#000000" />
<title>Xen Orchestra</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root">The application is loading…</div>
</body>
</html>

View File

@@ -0,0 +1,11 @@
import React from 'react'
import { Helmet } from 'react-helmet-async'
export default () => (
<>
<Helmet>
<title>Bar</title>
</Helmet>
Welcome in Bar
</>
)

View File

@@ -0,0 +1 @@
export default () => 'Foo'

View File

@@ -0,0 +1,8 @@
import React, { Component } from 'react'
import data from './rrd_host_11.json'
export default class Visualization extends Component {
render() {
return <pre>{JSON.stringify(data, null, 2)}</pre>
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,65 @@
import * as React from 'react'
import styled from '@emotion/styled'
import { HashRouter as Router, Route, Link } from 'react-router-dom'
import { Helmet, HelmetProvider } from 'react-helmet-async'
import { withStore } from 'reaclette'
const Bar = React.lazy(() => import('./Bar'))
const Foo = React.lazy(() => import('./Foo'))
const Visualization = React.lazy(() => import('./Visualization'))
const Title = styled.h1`
color: red;
text-align: center;
`
export default withStore(
{
initialState: () => ({
objects: new Map(),
onNotification: undefined,
}),
effects: {
initialize() {
const onNotification = notification => {
if (notification.message === 'objects') {
// TODO: update `objects`
}
}
this.props.connection.on('notification', onNotification)
this.state.onNotification = onNotification
},
finalize() {
this.props.connection.off('notification', this.state.onNotification)
this.state.onNotification = undefined
},
},
},
(store, props) => (
<Router>
<HelmetProvider>
<Helmet>
<title>Xen Orchestra</title>
</Helmet>
<Title>Xen Orchestra</Title>
<nav>
<ul>
<li>
<Link to='/'>Bar</Link>
</li>
<li>
<Link to='/foo/'>Foo</Link>
</li>
</ul>
</nav>
<React.Suspense fallback='loading'>
<Route path='/' exact component={Bar} />
<Route path='/foo' component={Foo} />
<Route path='/visualization' component={Visualization} />
</React.Suspense>
</HelmetProvider>
</Router>
)

View File

@@ -0,0 +1,11 @@
import React from 'react'
const Button = ({ ...props }) => {
if (props.type === undefined && props.form === undefined) {
props.type = 'button'
}
return <button {...props} />
}
export { Button as default }

View File

@@ -0,0 +1,16 @@
import React, { StrictMode } from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import Connection from './libs/Connection'
ReactDOM.render(
<StrictMode>
<App connection={new Connection()} />
</StrictMode>,
document.getElementById('root')
)
if (module.hot) {
module.hot.accept()
}

View File

@@ -0,0 +1,141 @@
import * as JsonRpc from 'json-rpc-protocol'
import assert from 'assert'
const CONNECTED = 'connected'
const CONNECTING = 'connecting'
const DISCONNECTED = 'disconnected'
function onMessage({ data }) {
const message = JsonRpc.parse(data)
const { type } = message
if (type === 'notification') {
this.emit('notification', message)
} else if (type === 'request') {
this.send(
JsonRpc.format.error(
message.id,
new JsonRpc.MethodNotFound(message.method)
)
)
} else {
const { id } = message
const deferred = this._deferreds[id]
delete this._deferreds[id]
if (type === 'response') {
deferred(message.result)
} else {
assert.strictEqual(type, 'error')
deferred(Promise.reject(message.error))
}
}
}
export default class Connection {
constructor() {
this._deferreds = { __proto__: null }
this._onMessage = onMessage.bind(this)
const url = new URL('./api/')
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:'
this._url = url.href
this._connected = new Promise(resolve => {
this._resolveConnected = resolve
})
this._disconnected = Promise.resolve()
this._status = DISCONNECTED
}
get connected() {
return this._connected
}
get disconnected() {
return this._disconnected
}
get status() {
return this._status
}
async connect() {
const status = this._status
if (status === CONNECTED) {
return
}
assert.strictEqual(status, DISCONNECTED)
this._status = CONNECTING
try {
ws = this._ws = new WebSocket(this._url)
ws.addEventListener('message', this._onMessage)
await fromEvent(ws, 'open')
await this._call('session.signIn', { token: cookies.get('token') })
this._status = CONNECTED
this._resolveConnected()
this._resolveConnected = undefined
} catch (error) {
ignoreErrors.call(this.disconnect())
throw error
}
}
async disconnect() {
const status = this._status
if (status === DISCONNECTED) {
return
}
if (status === CONNECTED) {
this._connected = new Promise(resolve => {
this._resolveConnected = resolve
})
} else {
assert(status === CONNECTING)
}
const ws = this._ws
this._ws = undefined
ws.close()
this._status = DISCONNECTED
this._resolveDisconnected()
this._resolveDisconnected = undefined
const deferreds = this._deferreds
const ids = Object.keys(deferreds)
if (ids.length !== undefined) {
this._deferreds = { __proto__: null }
const error = Promise.reject(new Error('disconnected'))
ids.forEach(id => {
deferreds[id](error)
})
}
}
call(method, args) {
return method.startsWith('session.')
? Promise.reject(
new Error('session.*() methods are disabled from this interface')
)
: this._call(method, args)
}
_call(method, args) {
const id = Math.random()
.toString(36)
.slice(2)
return new Promise(resolve => {
this._ws.send(JsonRpc.format.request(id, method, args))
this._deferreds[id] = resolve
})
}
}

View File

@@ -0,0 +1,62 @@
{
"compilerOptions": {
/* Basic Options */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./dist", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "incremental": true, /* Enable incremental compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
"noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
"strictNullChecks": true, /* Enable strict null checks. */
"strictFunctionTypes": true, /* Enable strict checking of function types. */
"strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
"strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
"noUnusedLocals": true, /* Report errors on unused locals. */
"noUnusedParameters": true, /* Report errors on unused parameters. */
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
"noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
}
}

View File

@@ -0,0 +1,47 @@
const path = require('path')
const resolveApp = relative => path.resolve(__dirname, relative)
const { NODE_ENV = 'production' } = process.env
const __PROD__ = NODE_ENV === 'production'
// https://webpack.js.org/configuration/
module.exports = {
mode: NODE_ENV,
entry: resolveApp('src/index.tsx'),
output: {
filename: __PROD__ ? '[name].[contenthash:8].js' : '[name].js',
path: resolveApp('dist'),
},
optimization: {
runtimeChunk: true,
splitChunks: {
chunks: 'all',
},
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
},
},
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
devtool: __PROD__ ? 'source-map' : 'cheap-module-eval-source-map',
plugins: [
new (require('clean-webpack-plugin'))(),
new (require('html-webpack-plugin'))({
template: resolveApp('public/index.html'),
}),
__PROD__ && new (require('webpack')).HashedModuleIdsPlugin(),
].filter(Boolean),
}

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "xo-web",
"version": "5.41.0",
"version": "5.42.0",
"license": "AGPL-3.0",
"description": "Web interface client for Xen-Orchestra",
"keywords": [

View File

@@ -1839,6 +1839,11 @@ const messages = {
pwdChangeErrorBody:
'The old password provided is incorrect. Your password has not been changed.',
changePasswordOk: 'OK',
forgetTokens: 'Forget all connection tokens',
forgetTokensExplained:
'This will prevent other clients from authenticating with existing tokens but will not kill active sessions',
forgetTokensSuccess: 'Successfully forgot connection tokens',
forgetTokensError: 'Error while forgetting connection tokens',
sshKeys: 'SSH keys',
newSshKey: 'New SSH key',
deleteSshKey: 'Delete',
@@ -1867,6 +1872,7 @@ const messages = {
// ----- Logs -----
logUser: 'User',
logMessage: 'Message',
logSuggestXcpNg: 'Use XCP-ng to get rid of restrictions',
logError: 'Error',
logTitle: 'Logs',
logDisplayDetails: 'Display details',

View File

@@ -283,7 +283,7 @@ export const Vdi = decorate([
sr: getSr(state, props),
})
}),
({ id, sr, vdi }) => {
({ id, showSize, showSr, sr, vdi }) => {
if (vdi === undefined) {
return unknowItem(id, 'VDI')
}
@@ -291,9 +291,12 @@ export const Vdi = decorate([
return (
<span>
<Icon icon='disk' /> {vdi.name_label}
{sr !== undefined && (
{sr !== undefined && showSr && (
<span className='text-muted'> - {sr.name_label}</span>
)}
{showSize && (
<span className='text-muted'> ({formatSize(vdi.size)})</span>
)}
</span>
)
},
@@ -302,10 +305,13 @@ export const Vdi = decorate([
Vdi.propTypes = {
id: PropTypes.string.isRequired,
self: PropTypes.bool,
showSize: PropTypes.bool,
}
Vdi.defaultProps = {
self: false,
showSize: false,
showSr: false,
}
// ===================================================================
@@ -432,8 +438,8 @@ const xoItemToRender = {
// XO objects.
pool: ({ id }) => <Pool id={id} />,
VDI: ({ id }) => <Vdi id={id} />,
'VDI-resourceSet': ({ id }) => <Vdi id={id} self />,
VDI: ({ id }) => <Vdi id={id} showSr />,
'VDI-resourceSet': ({ id }) => <Vdi id={id} self showSr />,
// Pool objects.
'VM-template': ({ id }) => <VmTemplate id={id} />,

View File

@@ -59,7 +59,7 @@ export const constructSmartPattern = (
const valueToComplexMatcher = pattern => {
if (typeof pattern === 'string') {
return new CM.RegExpNode(`^${escapeRegExp(pattern)}$`)
return new CM.RegExpNode(`^${escapeRegExp(pattern)}$`, 'i')
}
if (Array.isArray(pattern)) {

View File

@@ -3,6 +3,7 @@ import Component from 'base-component'
import PropTypes from 'prop-types'
import React from 'react'
import { map } from 'lodash'
import { Vdi } from 'render-xo-item'
import _ from '../../intl'
import SingleLineRow from '../../single-line-row'
@@ -85,7 +86,9 @@ export default class ChooseSrForEachVdisModal extends Component {
</SingleLineRow>
{map(props.vdis, vdi => (
<SingleLineRow key={vdi.uuid}>
<Col size={6}>{vdi.name_label || vdi.name}</Col>
<Col size={6}>
<Vdi id={vdi.id} showSize />
</Col>
<Col size={6}>
<SelectSr
onChange={sr =>

View File

@@ -376,7 +376,7 @@ export const dismissNotification = id => {
export const subscribeNotifications = createSubscription(async () => {
const { user, xoaUpdaterState } = store.getState()
if (
process.env.XOA_PLAN === 5 ||
+process.env.XOA_PLAN === 5 ||
xoaUpdaterState === 'disconnected' ||
xoaUpdaterState === 'error'
) {
@@ -2508,14 +2508,25 @@ export const editUser = (user, { email, password, permission }) =>
subscribeUsers.forceRefresh
)
const _signOutFromEverywhereElse = () =>
_call('token.deleteAll', { except: cookies.get('token') })
export const signOutFromEverywhereElse = () =>
_signOutFromEverywhereElse().then(
() => success(_('forgetTokens'), _('forgetTokensSuccess')),
() => error(_('forgetTokens'), _('forgetTokensError'))
)
export const changePassword = (oldPassword, newPassword) =>
_call('user.changePassword', {
oldPassword,
newPassword,
}).then(
() => success(_('pwdChangeSuccess'), _('pwdChangeSuccessBody')),
() => error(_('pwdChangeError'), _('pwdChangeErrorBody'))
)
})
.then(_signOutFromEverywhereElse)
.then(
() => success(_('pwdChangeSuccess'), _('pwdChangeSuccessBody')),
() => error(_('pwdChangeError'), _('pwdChangeErrorBody'))
)
const _setUserPreferences = preferences =>
_call('user.set', {

View File

@@ -750,7 +750,8 @@ export default class Home extends Component {
new ComplexMatcher.Or(
map(
tags,
tag => new ComplexMatcher.RegExp(`^${escapeRegExp(tag.id)}$`)
tag =>
new ComplexMatcher.RegExp(`^${escapeRegExp(tag.id)}$`, 'i')
)
)
)

View File

@@ -118,7 +118,9 @@ export default ({ statsOverview, host, nVms, vmController, vms }) => {
<Usage total={host.memory.size}>
<UsageElement
highlight
tooltip={`XenServer (${formatSize(vmController.memory.size)})`}
tooltip={`${host.productBrand} (${formatSize(
vmController.memory.size
)})`}
value={vmController.memory.size}
/>
{map(vms, vm => (

View File

@@ -51,9 +51,20 @@ const COLUMNS = [
{
name: _('logMessage'),
itemRenderer: log => (
<pre className={styles.widthLimit}>
{log.data.error && log.data.error.message}
</pre>
<span>
<pre className={styles.widthLimit}>
{log.data.error && log.data.error.message}
</pre>
{log.data.error && log.data.error.code === 'LICENCE_RESTRICTION' && (
<a
href='https://xcp-ng.org/'
rel='noopener noreferrer'
target='_blank'
>
{_('logSuggestXcpNg')}
</a>
)}
</span>
),
sortCriteria: log => log.data.error && log.data.error.message,
},

View File

@@ -7,6 +7,7 @@ import Icon from 'icon'
import PropTypes from 'prop-types'
import React from 'react'
import SortedTable from 'sorted-table'
import Tooltip from 'tooltip'
import { Text } from 'editable'
import { alert } from 'modal'
import { Container, Row, Col } from 'grid'
@@ -24,6 +25,7 @@ import {
editCustomFilter,
removeCustomFilter,
setDefaultHomeFilter,
signOutFromEverywhereElse,
subscribeCurrentUser,
} from 'xo'
@@ -400,6 +402,20 @@ export default class User extends Component {
</Col>
</Row>
<br />
<Row>
<Col smallSize={10} offset={2}>
<Tooltip content={_('forgetTokensExplained')}>
<ActionButton
btnStyle='danger'
handler={signOutFromEverywhereElse}
icon='disconnect'
>
{_('forgetTokens')}
</ActionButton>
</Tooltip>
</Col>
</Row>
<br />
<Row>
<Col smallSize={2}>
<strong>{_('language')}</strong>

View File

@@ -301,7 +301,7 @@ export default class NewXosan extends Component {
}
render() {
if (process.env.XOA_PLAN === 5) {
if (+process.env.XOA_PLAN === 5) {
return (
<em>
{_('xosanSourcesDisclaimer', {

View File

@@ -48,7 +48,7 @@ const gitDiffIndex = () => gitDiff('index', ['--cached', 'HEAD'])
// -----------------------------------------------------------------------------
const files = gitDiffIndex().filter(_ => _.endsWith('.js'))
const files = gitDiffIndex().filter(RegExp.prototype.test.bind(/.[jt]sx?$/))
if (files.length === 0) {
return
}