DISPATCH-1017 Added console build.
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/0310ac22 Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/0310ac22 Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/0310ac22 Branch: refs/heads/master Commit: 0310ac224a61e9ee2aca447fe6fdf9d75ec5de11 Parents: 43b3b2e Author: Ernest Allen <[email protected]> Authored: Mon Jun 4 18:00:00 2018 -0400 Committer: Ernest Allen <[email protected]> Committed: Mon Jun 4 18:00:00 2018 -0400 ---------------------------------------------------------------------- .gitignore | 2 + console/CMakeLists.txt | 105 +- console/hawtio/pom.xml | 37 +- console/stand-alone/gulpfile.js | 190 + console/stand-alone/index.html | 102 +- console/stand-alone/package-lock.json | 7570 +++++++++++++++++- console/stand-alone/package.json | 22 +- console/stand-alone/plugin/css/dispatch.css | 2 +- console/stand-alone/plugin/js/dispatchPlugin.js | 10 +- .../plugin/js/topology/qdrTopology.js | 4 +- .../stand-alone/plugin/js/topology/traffic.js | 440 - .../stand-alone/plugin/js/topology/traffic.ts | 443 + console/stand-alone/tsconfig.json | 31 + console/stand-alone/tslint.json | 64 + console/stand-alone/vendor-css.txt | 25 + console/stand-alone/vendor-js.txt | 43 + 16 files changed, 8524 insertions(+), 566 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0310ac22/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index 0b06144..49a9c44 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ console/test/topolgies/config-* .history .tox .vscode +console/stand-alone/node_modules/ +console/stand-alone/dist/ http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0310ac22/console/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/console/CMakeLists.txt b/console/CMakeLists.txt index 8918936..38b2de3 100644 --- a/console/CMakeLists.txt +++ b/console/CMakeLists.txt @@ -17,20 +17,105 @@ ## under the License. ## -set(CONSOLE_BASE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/console/stand-alone/") - ## -## Add option to not install the stand-alone console +## Add cmake option to choose whether to install stand-alone console ## -option(CONSOLE_INSTALL "Install stand-alone console" ON) +option(CONSOLE_INSTALL "Build and install console (requires npm)" ON) + if(CONSOLE_INSTALL) + find_program(NPM_EXE npm DOC "Location of the npm package manager") + if (NPM_EXE) - # Static console files - install( - DIRECTORY ${CONSOLE_BASE_SOURCE_DIR} - DESTINATION ${CONSOLE_STAND_ALONE_INSTALL_DIR} - ) + set(CONSOLE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/console/stand-alone") + set(CONSOLE_BUILD_DIR "${CMAKE_BINARY_DIR}/console") + + ## Files needed to create the ${CONSOLE_ARTIFACTS} + file (GLOB_RECURSE CONSOLE_JS_SOURCES ${CONSOLE_SOURCE_DIR}/plugin/js/*.js) + file (GLOB_RECURSE CONSOLE_TS_SOURCES ${CONSOLE_SOURCE_DIR}/plugin/js/*.ts) + set(CONSOLE_CSS_SOURCE ${CONSOLE_SOURCE_DIR}/plugin/css/dispatch.css) + set(ALL_CONSOLE_SOURCES ${CONSOLE_JS_SOURCES} ${CONSOLE_TS_SOURCES} ${CONSOLE_CSS_SOURCE}) + + ## Files created during the console build + set(CONSOLE_ARTIFACTS + ${CONSOLE_BUILD_DIR}/dist/js/dispatch.min.js + ${CONSOLE_BUILD_DIR}/dist/js/vendor.min.js + ${CONSOLE_BUILD_DIR}/dist/css/dispatch.min.css + ${CONSOLE_BUILD_DIR}/dist/css/vendor.min.css + ) + + ## copy the build config files + configure_file( ${CONSOLE_SOURCE_DIR}/package.json ${CONSOLE_BUILD_DIR}/ COPYONLY) + configure_file( ${CONSOLE_SOURCE_DIR}/package-lock.json ${CONSOLE_BUILD_DIR}/ COPYONLY) + configure_file( ${CONSOLE_SOURCE_DIR}/tslint.json ${CONSOLE_BUILD_DIR}/ COPYONLY) + configure_file( ${CONSOLE_SOURCE_DIR}/gulpfile.js ${CONSOLE_BUILD_DIR}/ COPYONLY) + configure_file( ${CONSOLE_SOURCE_DIR}/vendor-js.txt ${CONSOLE_BUILD_DIR}/ COPYONLY) + configure_file( ${CONSOLE_SOURCE_DIR}/vendor-css.txt ${CONSOLE_BUILD_DIR}/ COPYONLY) + + ## Tell cmake how and when to build ${CONSOLE_ARTIFACTS} + add_custom_command ( + OUTPUT ${CONSOLE_ARTIFACTS} + COMMENT "Running console build" + COMMAND npm install --loglevel=error + COMMAND npx gulp --src ${CONSOLE_SOURCE_DIR} + DEPENDS ${ALL_CONSOLE_SOURCES} + WORKING_DIRECTORY ${CONSOLE_BUILD_DIR}/ + ) + + ## Ensure ${CONSOLE_ARTIFACTS} is built on a make when needed + add_custom_target(console ALL + DEPENDS ${CONSOLE_ARTIFACTS} + ) + + ## + ## Install the static and built console files + ## + + ## Files copied to the root of the console's install dir + set(BASE_FILES + ${CONSOLE_SOURCE_DIR}/index.html + ${CONSOLE_SOURCE_DIR}/favicon-32x32.png + ) + ## Files copied to the css/ dir + set(CSS_FONTS + ${CONSOLE_SOURCE_DIR}/plugin/css/brokers.ttf + ${CONSOLE_BUILD_DIR}/node_modules/angular-ui-grid/ui-grid.woff + ${CONSOLE_BUILD_DIR}/node_modules/angular-ui-grid/ui-grid.ttf + ) + ## Files copied to the fonts/ dir + set(VENDOR_FONTS + ${CONSOLE_BUILD_DIR}/node_modules/patternfly/dist/fonts/OpenSans-Regular-webfont.woff2 + ${CONSOLE_BUILD_DIR}/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.woff2 + ${CONSOLE_BUILD_DIR}/node_modules/patternfly/dist/fonts/OpenSans-Light-webfont.woff2 + ${CONSOLE_BUILD_DIR}/node_modules/patternfly/dist/fonts/OpenSans-Semibold-webfont.woff2 + ${CONSOLE_BUILD_DIR}/node_modules/patternfly/dist/fonts/OpenSans-BoldItalic-webfont.woff2 + ${CONSOLE_BUILD_DIR}/node_modules/patternfly/dist/fonts/OpenSans-Italic-webfont.woff2 + ${CONSOLE_BUILD_DIR}/node_modules/patternfly/dist/fonts/fontawesome-webfont.woff2 + ${CONSOLE_BUILD_DIR}/node_modules/patternfly/dist/fonts/fontawesome-webfont.eot + ${CONSOLE_BUILD_DIR}/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.ttf + ${CONSOLE_BUILD_DIR}/node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 + ) + + install(DIRECTORY ${CONSOLE_BUILD_DIR}/dist/ + DESTINATION ${CONSOLE_STAND_ALONE_INSTALL_DIR} + PATTERN "*.map" EXCLUDE + ) + install(DIRECTORY ${CONSOLE_SOURCE_DIR}/plugin/html/ + DESTINATION ${CONSOLE_STAND_ALONE_INSTALL_DIR}/html + FILES_MATCHING PATTERN "*.html" + ) + install(FILES ${BASE_FILES} + DESTINATION ${CONSOLE_STAND_ALONE_INSTALL_DIR} + ) + install(FILES ${CSS_FONTS} + DESTINATION ${CONSOLE_STAND_ALONE_INSTALL_DIR}/css/ + ) + install(FILES ${VENDOR_FONTS} + DESTINATION ${CONSOLE_STAND_ALONE_INSTALL_DIR}/fonts/ + ) + else(NPM_EXE) + message(WARNING "Cannot build console, npm not found") + endif(NPM_EXE) endif(CONSOLE_INSTALL) ## @@ -50,7 +135,7 @@ if (MAVEN_EXE) # install the built war file into the console dir install( # We don't know in advance what the name of the final .war will be because - # the war file name depends on the version in the pom.xml. The version will change each release + # the war file name depends on the version in the pom.xml. The version will change each release CODE "file( GLOB builtwar \"${HAWTIO_BUILD_DIR}/dispatch-hawtio-console*.war\" )" CODE "file( INSTALL \${builtwar} DESTINATION \"${CONSOLE_INSTALL_DIR}/hawtio\" )" ) http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0310ac22/console/hawtio/pom.xml ---------------------------------------------------------------------- diff --git a/console/hawtio/pom.xml b/console/hawtio/pom.xml index 7dcb70c..6bf687f 100644 --- a/console/hawtio/pom.xml +++ b/console/hawtio/pom.xml @@ -44,16 +44,12 @@ <url>https://git-wip-us.apache.org/repos/asf?p=qpid-dispatch.git</url> </scm> - <prerequisites> - <maven>3.0.4</maven> - </prerequisites> - <properties> <!-- filtered plugin properties, we don't define plugin-scripts here as we build that dynamically using maven-antrun-plugin below. --> <!-- plugin-context is what context this plugin will handle requests on in the application server --> - <plugin-context>/${artifactId}</plugin-context> + <plugin-context>/${project.artifactId}</plugin-context> <!-- plugin-name is the name of our plugin, affects the name used for the plugin's mbean --> @@ -207,7 +203,14 @@ <!-- maven-bundle-plugin config, needed to make this war deployable in karaf, defines the context that this bundle - should handle requests on --> + should handle requests on + + commented out because of: + [WARNING] Manifest org.apache.qpid:dispatch-hawtio-console:war:1.2.0-SNAPSHOT : None of Export-Package, Provide-Package, Private-Package, -testpackages, or -exportcontents is set, therefore no packages will be included + [WARNING] Manifest org.apache.qpid:dispatch-hawtio-console:war:1.2.0-SNAPSHOT : No sub JAR or directory WEB-INF/classes + --> + + <!-- <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> @@ -249,6 +252,28 @@ <Implementation-Version>${project.version}</Implementation-Version> </instructions> </configuration> + </plugin>--> + + <!-- maven-enforcer-plugin is now used instead of prerequisites for non maven-plugin projects --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-enforcer-plugin</artifactId> + <version>3.0.0-M1</version> + <executions> + <execution> + <id>enforce-maven</id> + <goals> + <goal>enforce</goal> + </goals> + <configuration> + <rules> + <requireMavenVersion> + <version>3.0.4</version> + </requireMavenVersion> + </rules> + </configuration> + </execution> + </executions> </plugin> <!-- We define the maven-war-plugin here and make sure it uses http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0310ac22/console/stand-alone/gulpfile.js ---------------------------------------------------------------------- diff --git a/console/stand-alone/gulpfile.js b/console/stand-alone/gulpfile.js new file mode 100644 index 0000000..46531c3 --- /dev/null +++ b/console/stand-alone/gulpfile.js @@ -0,0 +1,190 @@ +var license = `/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ +`; + +const gulp = require('gulp'), + babel = require('gulp-babel'), + concat = require('gulp-concat'), + uglify = require('gulp-uglify'), + ngAnnotate = require('gulp-ng-annotate'), + rename = require('gulp-rename'), + cleanCSS = require('gulp-clean-css'), + del = require('del'), + eslint = require('gulp-eslint'), + maps = require('gulp-sourcemaps'), + insert = require('gulp-insert'), + fs = require('fs'), + tsc = require('gulp-typescript'), + tslint = require('gulp-tslint'); + //tsProject = tsc.createProject('tsconfig.json'); + + // temp directory for converted typescript files +const built_ts = 'built_ts'; + +// fetch command line arguments +const arg = (argList => { + let arg = {}, a, opt, thisOpt, curOpt; + for (a = 0; a < argList.length; a++) { + thisOpt = argList[a].trim(); + opt = thisOpt.replace(/^-+/, ''); + + if (opt === thisOpt) { + // argument value + if (curOpt) arg[curOpt] = opt; + curOpt = null; + } + else { + // argument name + curOpt = opt; + arg[curOpt] = true; + } + } + return arg; +})(process.argv); + +var src = arg.src ? arg.src + '/' : ''; + +const paths = { + typescript: { + src: src + 'plugin/**/*.ts', + dest: built_ts + }, + styles: { + src: src + 'plugin/css/**/*.css', + dest: 'dist/css/' + }, + scripts: { + src: [src + 'plugin/js/**/*.js', built_ts + '/**/*.js'], + dest: 'dist/js/' + } +}; + +function clean() { + return del(['dist',built_ts ]); +} +function cleanup() { + return del([built_ts]); +} +function styles() { + return gulp.src(paths.styles.src) + .pipe(maps.init()) + .pipe(cleanCSS()) + .pipe(rename({ + basename: 'dispatch', + suffix: '.min' + })) + .pipe(insert.prepend(license)) + .pipe(maps.write('./')) + .pipe(gulp.dest(paths.styles.dest)); +} +function vendor_styles() { + var vendor_lines = fs.readFileSync('vendor-css.txt').toString().split('\n'); + var vendor_files = vendor_lines.filter( function (line) { + return (!line.startsWith('-') && line.length > 0); + }); + return gulp.src(vendor_files) + .pipe(maps.init()) + .pipe(concat('vendor.css')) + .pipe(cleanCSS()) + .pipe(rename({ + basename: 'vendor', + suffix: '.min' + })) + .pipe(maps.write('./')) + .pipe(gulp.dest(paths.styles.dest)); +} + +function scripts() { + return gulp.src(paths.scripts.src, { sourcemaps: true }) + .pipe(babel({ + presets: [require.resolve('babel-preset-env')] + })) + .pipe(ngAnnotate()) + .pipe(maps.init()) + .pipe(uglify()) + .pipe(concat('dispatch.min.js')) + .pipe(insert.prepend(license)) + .pipe(maps.write('./')) + .pipe(gulp.dest(paths.scripts.dest)); +} + +function vendor_scripts() { + var vendor_lines = fs.readFileSync('vendor-js.txt').toString().split('\n'); + var vendor_files = vendor_lines.filter( function (line) { + return (!line.startsWith('-') && line.length > 0); + }); + return gulp.src(vendor_files) + .pipe(maps.init()) + .pipe(uglify()) + .pipe(concat('vendor.min.js')) + .pipe(maps.write('./')) + .pipe(gulp.dest(paths.scripts.dest)); +} +function watch() { + gulp.watch(paths.scripts.src, scripts); + gulp.watch(paths.styles.src, styles); +} +function lint() { + return gulp.src('plugin/**/*.js') + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failAfterError()); +} + +//function _typescript() { +// return tsProject.src({files: src + 'plugin/**/*.ts'}) +// .pipe(tsProject()) +// .js.pipe(gulp.dest('build/dist')); +//} + +function typescript() { + var tsResult = gulp.src(paths.typescript.src) + .pipe(tsc()); + return tsResult.js.pipe(gulp.dest(paths.typescript.dest)); +} + +function ts_lint() { + return gulp.src('plugin/js/**/*.ts') + .pipe(tslint({ + formatter: 'verbose' + })) + .pipe(tslint.report()); +} + +var build = gulp.series( + clean, // removes the dist/ dir + gulp.parallel(lint, ts_lint), // lints the .js, .ts files + typescript, // converts .ts to .js + gulp.parallel(vendor_styles, vendor_scripts, styles, scripts), // uglify and concat + cleanup // remove .js that were converted from .ts +); + +var vendor = gulp.parallel(vendor_styles, vendor_scripts); + +exports.clean = clean; +exports.watch = watch; +exports.build = build; +exports.lint = lint; +exports.tslint = ts_lint; +exports.tsc = typescript; +exports.scripts = scripts; +exports.styles = styles; +exports.vendor = vendor; + +gulp.task('default', build); http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0310ac22/console/stand-alone/index.html ---------------------------------------------------------------------- diff --git a/console/stand-alone/index.html b/console/stand-alone/index.html index 734fcd5..68070a3 100644 --- a/console/stand-alone/index.html +++ b/console/stand-alone/index.html @@ -28,24 +28,14 @@ under the License. <link rel="shortcut icon" type="image/png" href="favicon-32x32.png" sizes="32x32" /> - <link rel="stylesheet" href="node_modules/jquery-ui-dist/jquery-ui.css"> - - <!-- PatternFly Styles --> - <link rel="stylesheet" href="node_modules/patternfly/dist/css/patternfly.min.css" > - <link rel="stylesheet" href="node_modules/patternfly/dist/css/patternfly-additions.min.css" > - - <!-- jquery Styles --> - <link rel="stylesheet" href="node_modules/jquery.fancytree/dist/skin-bootstrap-n/ui.fancytree.css" type="text/css"/> - - <!-- charting styles --> - <link rel="stylesheet" href="node_modules/c3/c3.css" type="text/css"/> - - <!-- angular Styles --> - <link rel="stylesheet" href="node_modules/angular-ui-grid/ui-grid.css" type="text/css"/> - - <!-- local Styles --> - <link rel="stylesheet" href="plugin/css/dispatch.css" type="text/css"/> - + <link rel="stylesheet" href="css/vendor.min.css" type="text/css"/> + <link rel="stylesheet" href="css/dispatch.min.css" type="text/css"/> + + <style> + #installError { + display: none; + } + </style> </head> <body ng-app="QDR" ng-controller="QDR.Core"> @@ -81,84 +71,22 @@ under the License. <div class="container-fluid"> <div class="row"> <div id="main_container" class="col-md-12"> - <div ng-view><div id="no-npm">Please run 'npm install' in the console/stand-alone/ directory.</div> + <div ng-view><div id="installError">There was an error when installing the console. Please run make install for the router and check for errors.</div></div> </div> </div> </div> -<style> - #no-npm { - display: none; - } -</style> - -<!-- Only needed for IE --> -<script src="node_modules/bluebird/js/browser/bluebird.js"></script> +<script type="text/javascript" src="js/vendor.min.js"></script> +<script type="text/javascript" src="js/dispatch.min.js"></script> -<!-- jQuery --> -<script src="node_modules/jquery/dist/jquery.js"></script> -<script src="node_modules/jquery-ui-dist/jquery-ui.js"></script> -<script src="node_modules/jquery.fancytree/dist/jquery.fancytree-all.js"></script> -<!-- Angular --> -<script src="node_modules/angular/angular.js"></script> -<script src="node_modules/angular-animate/angular-animate.min.js"></script> -<script src="node_modules/angular-sanitize/angular-sanitize.min.js"></script> -<script src="node_modules/angular-route/angular-route.min.js"></script> -<script src="node_modules/angular-resource/angular-resource.min.js"></script> - -<!-- Bootstrap --> -<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> -<script src="node_modules/angular-ui-bootstrap/dist/ui-bootstrap.js"></script> -<script src="node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js"></script> - -<!-- d3 --> -<script src='node_modules/d3/d3.min.js'></script> -<script src='node_modules/d3-queue/build/d3-queue.min.js'></script> -<script src='node_modules/d3-time/build/d3-time.min.js'></script> -<script src='node_modules/d3-time-format/build/d3-time-format.min.js'></script> -<script src='node_modules/d3-path/build/d3-path.min.js'></script> - -<!-- c3 for charts --> -<script src="node_modules/c3/c3.js"></script> - -<script src="node_modules/angular-ui-slider/src/slider.js"></script> -<script src="node_modules/angular-ui-grid/ui-grid.js"></script> -<script src="node_modules/angular-bootstrap-checkbox/angular-bootstrap-checkbox.js"></script> -<script src="node_modules/notifyjs-browser/dist/notify.js"></script> -<script src="node_modules/patternfly/dist/js/patternfly.min.js"></script> - -<script type="text/javascript" src="node_modules/dispatch-management/dist/dispatch-management.js"></script> -<script type="text/javascript" src="plugin/js/dispatchPlugin.js"></script> -<script type="text/javascript" src="plugin/js/navbar.js"></script> -<script type="text/javascript" src="plugin/js/qdrGlobals.js"></script> -<script type="text/javascript" src="plugin/js/qdrOverview.js"></script> -<script type="text/javascript" src="plugin/js/qdrOverviewLogsController.js"></script> -<script type="text/javascript" src="plugin/js/qdrOverviewChartsController.js"></script> -<script type="text/javascript" src="plugin/js/qdrTopAddressesController.js"></script> -<script type="text/javascript" src="plugin/js/dlgChartController.js"></script> -<script type="text/javascript" src="plugin/js/qdrList.js"></script> -<script type="text/javascript" src="plugin/js/qdrListChart.js"></script> -<script type="text/javascript" src="plugin/js/qdrCharts.js"></script> -<script type="text/javascript" src="plugin/js/qdrSchema.js"></script> -<script type="text/javascript" src="plugin/js/qdrService.js"></script> -<script type="text/javascript" src="plugin/js/qdrChartService.js"></script> -<script type="text/javascript" src="plugin/js/topology/qdrTopology.js"></script> -<script type="text/javascript" src="plugin/js/topology/traffic.js"></script> -<script type="text/javascript" src="plugin/js/qdrSettings.js"></script> -<script type="text/javascript" src="plugin/js/chord/ribbon/ribbon.js"></script> -<script type="text/javascript" src="plugin/js/chord/matrix.js"></script> -<script type="text/javascript" src="plugin/js/chord/filters.js"></script> -<script type="text/javascript" src="plugin/js/chord/data.js"></script> -<script type="text/javascript" src="plugin/js/chord/layout/layout.js"></script> -<script type="text/javascript" src="plugin/js/chord/qdrChord.js"></script> <script> + // If angular hasn't loaded a page after 1 second, display the error message setTimeout(function () { - var no_npm = document.getElementById('no-npm'); - if (no_npm) - no_npm.style.display = "block"; + var installError = document.getElementById('installError'); + if (installError) + installError.style.display = "block"; }, 1000); - $(function(){ $('.nav a').on('click', function(){ $('.navbar-collapse').collapse('hide'); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
