Skip to content

Commit

Permalink
[CE-143] Initial vue theme template
Browse files Browse the repository at this point in the history
Add system overview page view

Change-Id: Ifa10eef40da578f874cfd5da53aeaeb5a0097149
Signed-off-by: Haitao Yue <hightall@me.com>
  • Loading branch information
hightall committed Sep 20, 2017
1 parent ac545cb commit 081641f
Show file tree
Hide file tree
Showing 45 changed files with 1,813 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ setup-master: ##@Environment Setup dependency for master node
setup-worker: ##@Environment Setup dependency for worker node
cd scripts/worker_node && bash setup.sh

build-js: ##@Nodejs Build js files for react
bash scripts/master_node/build_reactjs.sh
build-js: ##@Nodejs Build js files for vue
bash scripts/master_node/build_vuejs.sh

watch-mode: ##@Nodejs Run watch mode with js files for react
bash scripts/master_node/watch_mode.sh
Expand Down
5 changes: 3 additions & 2 deletions docker-compose-build-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ services:
image: node
container_name: build-js
volumes: # This should be removed in product env
- ./src/themes/react/static:/app
command: bash -c "cd /app && npm run build && rm -rf *.json.gz"
- ./src/themes/vue/static:/app
- ./src/themes/vue/templates:/app/templates
command: bash -c "cd /app && npm run build"
2 changes: 1 addition & 1 deletion docker-compose-npm-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
image: node
container_name: npm-install
volumes: # This should be removed in product env
- ./src/themes/react/static:/app
- ./src/themes/vue/static:/app
environment:
- NPM_REGISTRY=$NPM_REGISTRY
command: bash -c "cd /app && npm install --loglevel http --registry https://$NPM_REGISTRY"
File renamed without changes.
2 changes: 1 addition & 1 deletion src/themes/basic/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
background-position: 50% 50%;
}

/* ---- stats.js ---- */
/* ---- status.js ---- */

.count-particles{
background: #000022;
Expand Down
4 changes: 2 additions & 2 deletions src/themes/react/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
background-position: 50% 50%;
}

/* ---- stats.js ---- */
/* ---- status.js ---- */

.count-particles{
background: #000022;
Expand Down Expand Up @@ -200,7 +200,7 @@
});


/* ---- stats.js config ---- */
/* ---- status.js config ---- */

var count_particles, stats, update;
stats = new Stats;
Expand Down
14 changes: 14 additions & 0 deletions src/themes/vue/static/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"presets": [
["env", { "modules": false }],
"stage-2"
],
"plugins": ["transform-runtime"],
"comments": false,
"env": {
"test": {
"presets": ["env", "stage-2"],
"plugins": [ "istanbul" ]
}
}
}
9 changes: 9 additions & 0 deletions src/themes/vue/static/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
2 changes: 2 additions & 0 deletions src/themes/vue/static/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
buildfiles/*.js
config/*.js
27 changes: 27 additions & 0 deletions src/themes/vue/static/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// http://eslint.org/docs/user-guide/configuring

module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
env: {
browser: true,
},
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
extends: 'standard',
// required to lint *.vue files
plugins: [
'html'
],
// add your custom rules here
'rules': {
// allow paren-less arrow functions
'arrow-parens': 0,
// allow async-await
'generator-star-spacing': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
}
}
8 changes: 8 additions & 0 deletions src/themes/vue/static/.postcssrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// https://github.com/michael-ciniawsky/postcss-load-config

module.exports = {
"plugins": {
// to edit target browsers: use "browserlist" field in package.json
"autoprefixer": {}
}
}
40 changes: 40 additions & 0 deletions src/themes/vue/static/buildfiles/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

/*Copyright IBM Corp, All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
require('./check-versions')()

process.env.NODE_ENV = 'production'

var ora = require('ora')
var rm = require('rimraf')
var path = require('path')
var chalk = require('chalk')
var webpack = require('webpack')
var config = require('../config')
var webpackConfig = require('./webpack.prod.conf')

var spinner = ora('building for production...')
spinner.start()

rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err
webpack(webpackConfig, function (err, stats) {
spinner.stop()
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + '\n\n')

console.log(chalk.cyan(' Build complete.\n'))
console.log(chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
))
})
})
53 changes: 53 additions & 0 deletions src/themes/vue/static/buildfiles/check-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

/*Copyright IBM Corp, All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
var chalk = require('chalk')
var semver = require('semver')
var packageConfig = require('../package.json')
var shell = require('shelljs')
function exec (cmd) {
return require('child_process').execSync(cmd).toString().trim()
}

var versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
versionRequirement: packageConfig.engines.node
},
]

if (shell.which('npm')) {
versionRequirements.push({
name: 'npm',
currentVersion: exec('npm --version'),
versionRequirement: packageConfig.engines.npm
})
}

module.exports = function () {
var warnings = []
for (var i = 0; i < versionRequirements.length; i++) {
var mod = versionRequirements[i]
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
chalk.green(mod.versionRequirement)
)
}
}

if (warnings.length) {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log()
for (var i = 0; i < warnings.length; i++) {
var warning = warnings[i]
console.log(' ' + warning)
}
console.log()
process.exit(1)
}
}
13 changes: 13 additions & 0 deletions src/themes/vue/static/buildfiles/dev-client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

/*Copyright IBM Corp, All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
require('eventsource-polyfill')
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')

hotClient.subscribe(function (event) {
if (event.action === 'reload') {
window.location.reload()
}
})
96 changes: 96 additions & 0 deletions src/themes/vue/static/buildfiles/dev-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@

/*Copyright IBM Corp, All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
require('./check-versions')()

var config = require('../config')
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
}

var opn = require('opn')
var path = require('path')
var express = require('express')
var webpack = require('webpack')
var proxyMiddleware = require('http-proxy-middleware')
var webpackConfig = process.env.NODE_ENV === 'testing'
? require('./webpack.prod.conf')
: require('./webpack.dev.conf')

// default port where dev server listens for incoming traffic
var port = process.env.PORT || config.dev.port
// automatically open browser, if not set will be false
var autoOpenBrowser = !!config.dev.autoOpenBrowser
// Define HTTP proxies to your custom API backend
// https://github.com/chimurai/http-proxy-middleware
var proxyTable = config.dev.proxyTable

var app = express()
var compiler = webpack(webpackConfig)

var devMiddleware = require('webpack-dev-middleware')(compiler, {
publicPath: webpackConfig.output.publicPath,
quiet: true
})

var hotMiddleware = require('webpack-hot-middleware')(compiler, {
log: () => {}
})
// force page reload when html-webpack-plugin template changes
compiler.plugin('compilation', function (compilation) {
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
hotMiddleware.publish({ action: 'reload' })
cb()
})
})

// proxy api requests
Object.keys(proxyTable).forEach(function (context) {
var options = proxyTable[context]
if (typeof options === 'string') {
options = { target: options }
}
app.use(proxyMiddleware(options.filter || context, options))
})

// handle fallback for HTML5 history API
app.use(require('connect-history-api-fallback')())

// serve webpack bundle output
app.use(devMiddleware)

// enable hot-reload and state-preserving
// compilation error display
app.use(hotMiddleware)

// serve pure static assets
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
app.use(staticPath, express.static('./static'))

var uri = 'http://localhost:' + port

var _resolve
var readyPromise = new Promise(resolve => {
_resolve = resolve
})

console.log('> Starting dev server...')
devMiddleware.waitUntilValid(() => {
console.log('> Listening at ' + uri + '\n')
// when env is testing, don't need open it
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
opn(uri)
}
_resolve()
})

var server = app.listen(port)

module.exports = {
ready: readyPromise,
close: () => {
server.close()
}
}
Loading

0 comments on commit 081641f

Please sign in to comment.