Compare commits
15 Commits
xo-server-
...
visualizat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15e96e0921 | ||
|
|
9644cabbac | ||
|
|
c4eeb2b77e | ||
|
|
ee1e9ba7b7 | ||
|
|
3655117a13 | ||
|
|
cc2c71c076 | ||
|
|
9ca273b2c4 | ||
|
|
b85c2f35b6 | ||
|
|
fdd79885f9 | ||
|
|
b2eb970796 | ||
|
|
3ee9c1b550 | ||
|
|
2566c24753 | ||
|
|
49e1b0ba7e | ||
|
|
453c329f14 | ||
|
|
27193f38f3 |
@@ -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',
|
||||
}
|
||||
|
||||
@@ -7,15 +7,17 @@
|
||||
- [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
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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 },
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}`)
|
||||
|
||||
|
||||
@@ -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))
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
6
packages/xo-web-6/.babelrc.js
Normal file
6
packages/xo-web-6/.babelrc.js
Normal 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
|
||||
47
packages/xo-web-6/package.json
Normal file
47
packages/xo-web-6/package.json
Normal 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"
|
||||
}
|
||||
}
|
||||
16
packages/xo-web-6/public/index.html
Normal file
16
packages/xo-web-6/public/index.html
Normal 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>
|
||||
11
packages/xo-web-6/src/App/Bar/index.tsx
Normal file
11
packages/xo-web-6/src/App/Bar/index.tsx
Normal 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
|
||||
</>
|
||||
)
|
||||
1
packages/xo-web-6/src/App/Foo/index.tsx
Normal file
1
packages/xo-web-6/src/App/Foo/index.tsx
Normal file
@@ -0,0 +1 @@
|
||||
export default () => 'Foo'
|
||||
8
packages/xo-web-6/src/App/Visualization/index.tsx
Normal file
8
packages/xo-web-6/src/App/Visualization/index.tsx
Normal 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>
|
||||
}
|
||||
}
|
||||
251770
packages/xo-web-6/src/App/Visualization/rrd_host_11.json
Normal file
251770
packages/xo-web-6/src/App/Visualization/rrd_host_11.json
Normal file
File diff suppressed because it is too large
Load Diff
65
packages/xo-web-6/src/App/index.tsx
Normal file
65
packages/xo-web-6/src/App/index.tsx
Normal 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>
|
||||
)
|
||||
11
packages/xo-web-6/src/components/Button.tsx
Normal file
11
packages/xo-web-6/src/components/Button.tsx
Normal 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 }
|
||||
16
packages/xo-web-6/src/index.tsx
Normal file
16
packages/xo-web-6/src/index.tsx
Normal 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()
|
||||
}
|
||||
141
packages/xo-web-6/src/libs/Connection.ts
Normal file
141
packages/xo-web-6/src/libs/Connection.ts
Normal 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
|
||||
})
|
||||
}
|
||||
}
|
||||
62
packages/xo-web-6/tsconfig.json
Normal file
62
packages/xo-web-6/tsconfig.json
Normal 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. */
|
||||
}
|
||||
}
|
||||
47
packages/xo-web-6/webpack.config.js
Normal file
47
packages/xo-web-6/webpack.config.js
Normal 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),
|
||||
}
|
||||
@@ -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": [
|
||||
|
||||
@@ -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} />,
|
||||
|
||||
@@ -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 =>
|
||||
|
||||
@@ -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 => (
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user