diff --git a/glances/main.py b/glances/main.py index 3ecd1c74..9322a16c 100644 --- a/glances/main.py +++ b/glances/main.py @@ -296,8 +296,9 @@ Examples of use: if WINDOWS: args.webserver = True - # In web server mode + # In web server mode, defaul refresh time: 5 sec if args.webserver: + args.time = 5 args.process_short_name = True # Server or client login/password diff --git a/glances/outputs/glances_bottle.py b/glances/outputs/glances_bottle.py index 3afd2526..ee3cacf7 100644 --- a/glances/outputs/glances_bottle.py +++ b/glances/outputs/glances_bottle.py @@ -30,7 +30,7 @@ from glances.timer import Timer from glances.logger import logger try: - from bottle import Bottle, static_file, abort, response, request, auth_basic + from bottle import Bottle, static_file, abort, response, request, auth_basic, template, TEMPLATE_PATH except ImportError: logger.critical('Bottle module not found. Glances cannot start in web server mode.') sys.exit(2) @@ -72,6 +72,9 @@ class GlancesBottle(object): # Path where the statics files are stored self.STATIC_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'static/public') + # Paths for templates + TEMPLATE_PATH.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), 'static/templates')) + def load_config(self, config): """Load the outputs section of the configuration file.""" # Limit the number of processes to display in the WebUI @@ -153,11 +156,15 @@ class GlancesBottle(object): def _index(self, refresh_time=None): """Bottle callback for index.html (/) file.""" + + if refresh_time is None: + refresh_time = self.args.time + # Update the stat self.__update__() # Display - return static_file("index.html", root=self.STATIC_PATH) + return template("index.html", refresh_time=refresh_time) def _resource(self, filepath): """Bottle callback for resources files.""" diff --git a/glances/outputs/static/README.md b/glances/outputs/static/README.md index 32c3950e..8bfb845c 100644 --- a/glances/outputs/static/README.md +++ b/glances/outputs/static/README.md @@ -31,11 +31,22 @@ static | |--- css | -|--- html -| |--- images | |--- js | |--- public # path where builds are put +| +|--- templates (bottle) ``` + +## Data + +Each plugin receives the data in the following format: + +* stats +* views +* isBsd +* isLinux +* isMac +* isWindows diff --git a/glances/outputs/static/bower.json b/glances/outputs/static/bower.json index 93c7c550..451aa73f 100644 --- a/glances/outputs/static/bower.json +++ b/glances/outputs/static/bower.json @@ -3,8 +3,15 @@ "private": true, "dependencies": { "angular": "^1.5.8", - "angular-route": "^1.5.8", "lodash": "^4.13.1", - "favico.js": "^0.3.10" + "favico.js": "^0.3.10", + "angular-hotkeys": "chieffancypants/angular-hotkeys#^1.7.0" + }, + "overrides": { + "angular-hotkeys": { + "main": [ + "build/hotkeys.js" + ] + } } } diff --git a/glances/outputs/static/css/style.css b/glances/outputs/static/css/style.css index 16dda3de..92494a45 100644 --- a/glances/outputs/static/css/style.css +++ b/glances/outputs/static/css/style.css @@ -106,16 +106,16 @@ body { } /* Plugins */ -#processlist .table-cell { +#processlist-plugin .table-cell { padding: 0px 5px 0px 5px; white-space: nowrap; } -#containers .table-cell { +#containers-plugin .table-cell { padding: 0px 10px 0px 10px; white-space: nowrap; } -#quicklook .progress { +#quicklook-plugin .progress { margin-bottom: 0px; min-width: 100px; background-color: #000; @@ -123,25 +123,25 @@ body { border-radius: 0px; text-align: right; } -#quicklook .progress-bar-ok { +#quicklook-plugin .progress-bar-ok { background-color: #3E7B04; } -#quicklook .progress-bar-careful { +#quicklook-plugin .progress-bar-careful { background-color: #295183; } -#quicklook .progress-bar-warning { +#quicklook-plugin .progress-bar-warning { background-color: #5D4062; } -#quicklook .progress-bar-critical { +#quicklook-plugin .progress-bar-critical { background-color: #A30000; } -#quicklook .cpu-name { +#quicklook-plugin .cpu-name { white-space: nowrap; overflow: hidden; width: 100%; text-overflow: ellipsis; } -#amps .process-result { +#amps-plugin .process-result { max-width: 300px; overflow: hidden; white-space: pre-wrap; @@ -149,7 +149,7 @@ body { text-overflow: ellipsis; } -#gpu .gpu-name { +#gpu-plugin .gpu-name { white-space: nowrap; overflow: hidden; width: 100%; diff --git a/glances/outputs/static/gulpfile.js b/glances/outputs/static/gulpfile.js index 615a9c8c..ec342736 100644 --- a/glances/outputs/static/gulpfile.js +++ b/glances/outputs/static/gulpfile.js @@ -21,7 +21,7 @@ gulp.task('copy', function() { gulp.src('./images/*.png') .pipe(gulp.dest('./public/images')); - gulp.src('favicon.ico') + gulp.src('./images/favicon.ico') .pipe(gulp.dest('./public')); }); @@ -41,8 +41,8 @@ gulp.task('build-js', function() { }); gulp.task('template', function () { - return gulp.src('./html/plugins/*.html') - .pipe(templateCache('templates.js', {'root': 'plugins/', 'module': 'glancesApp'})) + return gulp.src('./js/components/**/*.html') + .pipe(templateCache('templates.js', {'root': 'components/', 'module': 'glancesApp'})) .pipe(rename({suffix: '.min'})) .pipe(gulp.dest('./public/js')); }); diff --git a/glances/outputs/static/html/help.html b/glances/outputs/static/html/help.html deleted file mode 100644 index f42a36ed..00000000 --- a/glances/outputs/static/html/help.html +++ /dev/null @@ -1,76 +0,0 @@ -
+ * Follow {@link ng.$sce#resourceUrlPatternItem this link} for a description of the items + * allowed in this array.
+ * The typical usage for the blacklist is to **block + * [open redirects](http://cwe.mitre.org/data/definitions/601.html)** served by your domain as + * these would otherwise be trusted but actually return content from the redirected domain. + *
+ * Finally, **the blacklist overrides the whitelist** and has the final say. * - * Follow {@link ng.$sce#resourceUrlPatternItem this link} for a description of the items - * allowed in this array. - * - * The typical usage for the blacklist is to **block - * [open redirects](http://cwe.mitre.org/data/definitions/601.html)** served by your domain as - * these would otherwise be trusted but actually return content from the redirected domain. - * - * Finally, **the blacklist overrides the whitelist** and has the final say. - * - * @return {Array} the currently set blacklist array. - * - * The **default value** when no whitelist has been explicitly set is the empty array (i.e. there - * is no blacklist.) + * @return {Array} The currently set blacklist array. * * @description * Sets/Gets the blacklist of trusted resource URLs. + * + * The **default value** when no whitelist has been explicitly set is the empty array (i.e. there + * is no blacklist.) */ this.resourceUrlBlacklist = function(value) { @@ -18759,17 +18976,24 @@ function $SceDelegateProvider() { * @name $sceDelegate#trustAs * * @description - * Returns an object that is trusted by angular for use in specified strict - * contextual escaping contexts (such as ng-bind-html, ng-include, any src - * attribute interpolation, any dom event binding attribute interpolation - * such as for onclick, etc.) that uses the provided value. - * See {@link ng.$sce $sce} for enabling strict contextual escaping. + * Returns a trusted representation of the parameter for the specified context. This trusted + * object will later on be used as-is, without any security check, by bindings or directives + * that require this security context. + * For instance, marking a string as trusted for the `$sce.HTML` context will entirely bypass + * the potential `$sanitize` call in corresponding `$sce.HTML` bindings or directives, such as + * `ng-bind-html`. Note that in most cases you won't need to call this function: if you have the + * sanitizer loaded, passing the value itself will render all the HTML that does not pose a + * security risk. * - * @param {string} type The kind of context in which this value is safe for use. e.g. url, - * resourceUrl, html, js and css. - * @param {*} value The value that that should be considered trusted/safe. - * @returns {*} A value that can be used to stand in for the provided `value` in places - * where Angular expects a $sce.trustAs() return value. + * See {@link ng.$sceDelegate#getTrusted getTrusted} for the function that will consume those + * trusted values, and {@link ng.$sce $sce} for general documentation about strict contextual + * escaping. + * + * @param {string} type The context in which this value is safe for use, e.g. `$sce.URL`, + * `$sce.RESOURCE_URL`, `$sce.HTML`, `$sce.JS` or `$sce.CSS`. + * + * @param {*} value The value that should be considered trusted. + * @return {*} A trusted representation of value, that can be used in the given context. */ function trustAs(type, trustedValue) { var Constructor = (byType.hasOwnProperty(type) ? byType[type] : null); @@ -18801,11 +19025,11 @@ function $SceDelegateProvider() { * ng.$sceDelegate#trustAs `$sceDelegate.trustAs`}. * * If the passed parameter is not a value that had been returned by {@link - * ng.$sceDelegate#trustAs `$sceDelegate.trustAs`}, returns it as-is. + * ng.$sceDelegate#trustAs `$sceDelegate.trustAs`}, it must be returned as-is. * * @param {*} value The result of a prior {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs`} - * call or anything else. - * @returns {*} The `value` that was originally provided to {@link ng.$sceDelegate#trustAs + * call or anything else. + * @return {*} The `value` that was originally provided to {@link ng.$sceDelegate#trustAs * `$sceDelegate.trustAs`} if `value` is the result of such a call. Otherwise, returns * `value` unchanged. */ @@ -18822,33 +19046,38 @@ function $SceDelegateProvider() { * @name $sceDelegate#getTrusted * * @description - * Takes the result of a {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs`} call and - * returns the originally supplied value if the queried context type is a supertype of the - * created type. If this condition isn't satisfied, throws an exception. + * Takes any input, and either returns a value that's safe to use in the specified context, or + * throws an exception. * - *