Merge "Replace embedded static files with XStatic-*"
This commit is contained in:
commit
ed26baa828
@ -12,12 +12,10 @@
|
||||
|
||||
import os
|
||||
|
||||
from importlib import import_module
|
||||
from horizon.utils.file_discovery import discover_files
|
||||
|
||||
import heat_dashboard
|
||||
|
||||
from horizon.utils.file_discovery import discover_files
|
||||
|
||||
# The slug of the panel to be added to HORIZON_CONFIG. Required.
|
||||
PANEL = 'template_generator'
|
||||
# The slug of the dashboard the PANEL associated with. Required.
|
||||
@ -39,32 +37,34 @@ TEMPLATE_GENERATOR_BASE = 'dashboard/project/heat_dashboard/template_generator'
|
||||
CSS_BASE = '%s/css' % TEMPLATE_GENERATOR_BASE
|
||||
JS_BASE = '%s/js' % TEMPLATE_GENERATOR_BASE
|
||||
|
||||
ADD_SCSS_FILES = [
|
||||
'%s/hotgen-main.scss' % CSS_BASE,
|
||||
'horizon/lib/bootstrap_scss/scss/_bootstrap.scss',
|
||||
'horizon/lib/font_awesome/scss/font-awesome.scss']
|
||||
|
||||
XSTATIC_MODULES = [
|
||||
ADD_XSTATIC_MODULES = [
|
||||
('xstatic.pkg.angular', [
|
||||
'angular-animate.js',
|
||||
'angular-aria.js',
|
||||
'angular-messages.js',
|
||||
]),
|
||||
('xstatic.pkg.angular_bootstrap', ['angular-bootstrap.js']),
|
||||
# ('xstatic.pkg.angular_material', ['angular-material.js']),
|
||||
('xstatic.pkg.angular_uuid', ['angular-uuid.js']),
|
||||
('xstatic.pkg.angular_vis', ['angular-vis.js']),
|
||||
('xstatic.pkg.filesaver', ['FileSaver.js']),
|
||||
('xstatic.pkg.js_yaml', ['js-yaml.js']),
|
||||
('xstatic.pkg.json2yaml', ['json2yaml.js']),
|
||||
]
|
||||
|
||||
ADD_SCSS_FILES = [
|
||||
'horizon/lib/bootstrap_scss/scss/_bootstrap.scss',
|
||||
'horizon/lib/font_awesome/scss/font-awesome.scss',
|
||||
'%s/hotgen-main.scss' % CSS_BASE
|
||||
]
|
||||
|
||||
HEAT_DASHBOARD_ROOT = heat_dashboard.__path__[0]
|
||||
|
||||
|
||||
ADD_JS_FILES = discover_files(os.path.join(HEAT_DASHBOARD_ROOT, 'static'),
|
||||
sub_path='%s/libs' % JS_BASE,
|
||||
ext='.js', trim_base_path=True)
|
||||
|
||||
for module_name, js_files in XSTATIC_MODULES:
|
||||
module = import_module(module_name)
|
||||
for js_file in js_files:
|
||||
ADD_JS_FILES.append(
|
||||
os.path.join('horizon/lib/', module.NAME, js_file)
|
||||
)
|
||||
|
||||
ADD_JS_FILES.extend([
|
||||
'%s/components/template-generator.module.js' % JS_BASE,
|
||||
'%s/components/utils.module.js' % JS_BASE,
|
||||
@ -72,18 +72,32 @@ ADD_JS_FILES.extend([
|
||||
])
|
||||
|
||||
ADD_JS_FILES.extend(
|
||||
[file for file in discover_files(
|
||||
[js_file for js_file in discover_files(
|
||||
os.path.join(HEAT_DASHBOARD_ROOT,
|
||||
'static'),
|
||||
sub_path='%s/components' % JS_BASE,
|
||||
ext='.js',
|
||||
trim_base_path=True)
|
||||
if file not in ADD_JS_FILES and 'spec.js' not in file
|
||||
if js_file not in ADD_JS_FILES and not js_file.endswith('spec.js')
|
||||
])
|
||||
|
||||
ADD_JS_FILES.extend(
|
||||
[file for file in discover_files(
|
||||
[js_file for js_file in discover_files(
|
||||
os.path.join(HEAT_DASHBOARD_ROOT, 'static'),
|
||||
sub_path='%s/resources' % JS_BASE,
|
||||
ext='.js', trim_base_path=True) if 'spec.js' not in file
|
||||
ext='.js', trim_base_path=True) if not js_file.endswith('spec.js')
|
||||
])
|
||||
|
||||
ADD_JS_SPEC_FILES = [
|
||||
js_file for js_file in discover_files(
|
||||
os.path.join(HEAT_DASHBOARD_ROOT, 'static'),
|
||||
sub_path='%s/components' % JS_BASE,
|
||||
ext='.js',
|
||||
trim_base_path=True) if js_file.endswith('spec.js')]
|
||||
|
||||
ADD_JS_SPEC_FILES.extend(
|
||||
[js_file for js_file in discover_files(
|
||||
os.path.join(HEAT_DASHBOARD_ROOT, 'static'),
|
||||
sub_path='%s/resources' % JS_BASE,
|
||||
ext='.js', trim_base_path=True) if js_file.endswith('spec.js')
|
||||
])
|
||||
|
@ -80,4 +80,4 @@
|
||||
overflow: hidden;
|
||||
clip: rect(0,0,0,0);
|
||||
border: 0;
|
||||
}
|
||||
}
|
@ -2,6 +2,4 @@
|
||||
@import "/dashboard/project/heat_dashboard/template_generator/css/angular-material.scss";
|
||||
@import "/dashboard/project/heat_dashboard/template_generator/css/angular-notify.scss";
|
||||
@import "/dashboard/project/heat_dashboard/template_generator/css/hotgen.scss";
|
||||
@import "/dashboard/project/heat_dashboard/template_generator/css/vis.scss";
|
||||
|
||||
|
||||
@import "/dashboard/project/heat_dashboard/template_generator/css/vis.scss";
|
@ -1,188 +0,0 @@
|
||||
/* FileSaver.js
|
||||
* A saveAs() FileSaver implementation.
|
||||
* 1.3.2
|
||||
* 2016-06-16 18:25:19
|
||||
*
|
||||
* By Eli Grey, http://eligrey.com
|
||||
* License: MIT
|
||||
* See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
/*global self */
|
||||
/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */
|
||||
|
||||
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
|
||||
|
||||
var saveAs = saveAs || (function(view) {
|
||||
"use strict";
|
||||
// IE <10 is explicitly unsupported
|
||||
if (typeof view === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) {
|
||||
return;
|
||||
}
|
||||
var
|
||||
doc = view.document
|
||||
// only get URL when necessary in case Blob.js hasn't overridden it yet
|
||||
, get_URL = function() {
|
||||
return view.URL || view.webkitURL || view;
|
||||
}
|
||||
, save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
|
||||
, can_use_save_link = "download" in save_link
|
||||
, click = function(node) {
|
||||
var event = new MouseEvent("click");
|
||||
node.dispatchEvent(event);
|
||||
}
|
||||
, is_safari = /constructor/i.test(view.HTMLElement) || view.safari
|
||||
, is_chrome_ios =/CriOS\/[\d]+/.test(navigator.userAgent)
|
||||
, throw_outside = function(ex) {
|
||||
(view.setImmediate || view.setTimeout)(function() {
|
||||
throw ex;
|
||||
}, 0);
|
||||
}
|
||||
, force_saveable_type = "application/octet-stream"
|
||||
// the Blob API is fundamentally broken as there is no "downloadfinished" event to subscribe to
|
||||
, arbitrary_revoke_timeout = 1000 * 40 // in ms
|
||||
, revoke = function(file) {
|
||||
var revoker = function() {
|
||||
if (typeof file === "string") { // file is an object URL
|
||||
get_URL().revokeObjectURL(file);
|
||||
} else { // file is a File
|
||||
file.remove();
|
||||
}
|
||||
};
|
||||
setTimeout(revoker, arbitrary_revoke_timeout);
|
||||
}
|
||||
, dispatch = function(filesaver, event_types, event) {
|
||||
event_types = [].concat(event_types);
|
||||
var i = event_types.length;
|
||||
while (i--) {
|
||||
var listener = filesaver["on" + event_types[i]];
|
||||
if (typeof listener === "function") {
|
||||
try {
|
||||
listener.call(filesaver, event || filesaver);
|
||||
} catch (ex) {
|
||||
throw_outside(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
, auto_bom = function(blob) {
|
||||
// prepend BOM for UTF-8 XML and text/* types (including HTML)
|
||||
// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
|
||||
if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
|
||||
return new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type});
|
||||
}
|
||||
return blob;
|
||||
}
|
||||
, FileSaver = function(blob, name, no_auto_bom) {
|
||||
if (!no_auto_bom) {
|
||||
blob = auto_bom(blob);
|
||||
}
|
||||
// First try a.download, then web filesystem, then object URLs
|
||||
var
|
||||
filesaver = this
|
||||
, type = blob.type
|
||||
, force = type === force_saveable_type
|
||||
, object_url
|
||||
, dispatch_all = function() {
|
||||
dispatch(filesaver, "writestart progress write writeend".split(" "));
|
||||
}
|
||||
// on any filesys errors revert to saving with object URLs
|
||||
, fs_error = function() {
|
||||
if ((is_chrome_ios || (force && is_safari)) && view.FileReader) {
|
||||
// Safari doesn't allow downloading of blob urls
|
||||
var reader = new FileReader();
|
||||
reader.onloadend = function() {
|
||||
var url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;');
|
||||
var popup = view.open(url, '_blank');
|
||||
if(!popup) view.location.href = url;
|
||||
url=undefined; // release reference before dispatching
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
dispatch_all();
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
filesaver.readyState = filesaver.INIT;
|
||||
return;
|
||||
}
|
||||
// don't create more object URLs than needed
|
||||
if (!object_url) {
|
||||
object_url = get_URL().createObjectURL(blob);
|
||||
}
|
||||
if (force) {
|
||||
view.location.href = object_url;
|
||||
} else {
|
||||
var opened = view.open(object_url, "_blank");
|
||||
if (!opened) {
|
||||
// Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html
|
||||
view.location.href = object_url;
|
||||
}
|
||||
}
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
dispatch_all();
|
||||
revoke(object_url);
|
||||
}
|
||||
;
|
||||
filesaver.readyState = filesaver.INIT;
|
||||
|
||||
if (can_use_save_link) {
|
||||
object_url = get_URL().createObjectURL(blob);
|
||||
setTimeout(function() {
|
||||
save_link.href = object_url;
|
||||
save_link.download = name;
|
||||
click(save_link);
|
||||
dispatch_all();
|
||||
revoke(object_url);
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
fs_error();
|
||||
}
|
||||
, FS_proto = FileSaver.prototype
|
||||
, saveAs = function(blob, name, no_auto_bom) {
|
||||
return new FileSaver(blob, name || blob.name || "download", no_auto_bom);
|
||||
}
|
||||
;
|
||||
// IE 10+ (native saveAs)
|
||||
if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) {
|
||||
return function(blob, name, no_auto_bom) {
|
||||
name = name || blob.name || "download";
|
||||
|
||||
if (!no_auto_bom) {
|
||||
blob = auto_bom(blob);
|
||||
}
|
||||
return navigator.msSaveOrOpenBlob(blob, name);
|
||||
};
|
||||
}
|
||||
|
||||
FS_proto.abort = function(){};
|
||||
FS_proto.readyState = FS_proto.INIT = 0;
|
||||
FS_proto.WRITING = 1;
|
||||
FS_proto.DONE = 2;
|
||||
|
||||
FS_proto.error =
|
||||
FS_proto.onwritestart =
|
||||
FS_proto.onprogress =
|
||||
FS_proto.onwrite =
|
||||
FS_proto.onabort =
|
||||
FS_proto.onerror =
|
||||
FS_proto.onwriteend =
|
||||
null;
|
||||
|
||||
return saveAs;
|
||||
}(
|
||||
typeof self !== "undefined" && self
|
||||
|| typeof window !== "undefined" && window
|
||||
|| this.content
|
||||
));
|
||||
// `self` is undefined in Firefox for Android content script context
|
||||
// while `this` is nsIContentFrameMessageManager
|
||||
// with an attribute `content` that corresponds to the window
|
||||
|
||||
if (typeof module !== "undefined" && module.exports) {
|
||||
module.exports.saveAs = saveAs;
|
||||
} else if ((typeof define !== "undefined" && define !== null) && (define.amd !== null)) {
|
||||
define("FileSaver.js", function() {
|
||||
return saveAs;
|
||||
});
|
||||
}
|
@ -1,251 +0,0 @@
|
||||
// angular-uuid created by Ivan Hayes @munkychop
|
||||
// MIT License - http://opensource.org/licenses/mit-license.php
|
||||
// --------------------------------------------------------------
|
||||
// This is an AngularJS wrapper for the original node-uuid library
|
||||
// written by Robert Kieffer – https://github.com/broofa/node-uuid
|
||||
// MIT License - http://opensource.org/licenses/mit-license.php
|
||||
// The wrapped node-uuid library is at version 1.4.7
|
||||
|
||||
function AngularUUID () {
|
||||
'use strict';
|
||||
|
||||
angular.module('angular-uuid',[]).factory('uuid', ['$window', nodeUUID]);
|
||||
|
||||
function nodeUUID ($window) {
|
||||
// Unique ID creation requires a high quality random # generator. We feature
|
||||
// detect to determine the best RNG source, normalizing to a function that
|
||||
// returns 128-bits of randomness, since that's what's usually required
|
||||
var _rng, _mathRNG, _whatwgRNG;
|
||||
|
||||
// Allow for MSIE11 msCrypto
|
||||
var _crypto = $window.crypto || $window.msCrypto;
|
||||
|
||||
if (!_rng && _crypto && _crypto.getRandomValues) {
|
||||
// WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto
|
||||
//
|
||||
// Moderately fast, high quality
|
||||
try {
|
||||
var _rnds8 = new Uint8Array(16);
|
||||
_whatwgRNG = _rng = function whatwgRNG() {
|
||||
_crypto.getRandomValues(_rnds8);
|
||||
return _rnds8;
|
||||
};
|
||||
_rng();
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
if (!_rng) {
|
||||
// Math.random()-based (RNG)
|
||||
//
|
||||
// If all else fails, use Math.random(). It's fast, but is of unspecified
|
||||
// quality.
|
||||
var _rnds = new Array(16);
|
||||
_mathRNG = _rng = function() {
|
||||
for (var i = 0, r; i < 16; i++) {
|
||||
if ((i & 0x03) === 0) { r = Math.random() * 0x100000000; }
|
||||
_rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
|
||||
}
|
||||
|
||||
return _rnds;
|
||||
};
|
||||
if ('undefined' !== typeof console && console.warn) {
|
||||
console.warn('[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()');
|
||||
}
|
||||
}
|
||||
|
||||
// Buffer class to use
|
||||
var BufferClass = ('function' === typeof Buffer) ? Buffer : Array;
|
||||
|
||||
// Maps for number <-> hex string conversion
|
||||
var _byteToHex = [];
|
||||
var _hexToByte = {};
|
||||
for (var i = 0; i < 256; i++) {
|
||||
_byteToHex[i] = (i + 0x100).toString(16).substr(1);
|
||||
_hexToByte[_byteToHex[i]] = i;
|
||||
}
|
||||
|
||||
// **`parse()` - Parse a UUID into it's component bytes**
|
||||
function parse(s, buf, offset) {
|
||||
var i = (buf && offset) || 0, ii = 0;
|
||||
|
||||
buf = buf || [];
|
||||
s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) {
|
||||
if (ii < 16) { // Don't overflow!
|
||||
buf[i + ii++] = _hexToByte[oct];
|
||||
}
|
||||
});
|
||||
|
||||
// Zero out remaining bytes if string was short
|
||||
while (ii < 16) {
|
||||
buf[i + ii++] = 0;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
// **`unparse()` - Convert UUID byte array (ala parse()) into a string**
|
||||
function unparse(buf, offset) {
|
||||
var i = offset || 0, bth = _byteToHex;
|
||||
return bth[buf[i++]] + bth[buf[i++]] +
|
||||
bth[buf[i++]] + bth[buf[i++]] + '-' +
|
||||
bth[buf[i++]] + bth[buf[i++]] + '-' +
|
||||
bth[buf[i++]] + bth[buf[i++]] + '-' +
|
||||
bth[buf[i++]] + bth[buf[i++]] + '-' +
|
||||
bth[buf[i++]] + bth[buf[i++]] +
|
||||
bth[buf[i++]] + bth[buf[i++]] +
|
||||
bth[buf[i++]] + bth[buf[i++]];
|
||||
}
|
||||
|
||||
// **`v1()` - Generate time-based UUID**
|
||||
//
|
||||
// Inspired by https://github.com/LiosK/UUID.js
|
||||
// and http://docs.python.org/library/uuid.html
|
||||
|
||||
// random #'s we need to init node and clockseq
|
||||
var _seedBytes = _rng();
|
||||
|
||||
// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
|
||||
var _nodeId = [
|
||||
_seedBytes[0] | 0x01,
|
||||
_seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5]
|
||||
];
|
||||
|
||||
// Per 4.2.2, randomize (14 bit) clockseq
|
||||
var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff;
|
||||
|
||||
// Previous uuid creation time
|
||||
var _lastMSecs = 0, _lastNSecs = 0;
|
||||
|
||||
// See https://github.com/broofa/node-uuid for API details
|
||||
function v1(options, buf, offset) {
|
||||
var i = buf && offset || 0;
|
||||
var b = buf || [];
|
||||
|
||||
options = options || {};
|
||||
|
||||
var clockseq = (options.clockseq != null) ? options.clockseq : _clockseq;
|
||||
|
||||
// UUID timestamps are 100 nano-second units since the Gregorian epoch,
|
||||
// (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
|
||||
// time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
|
||||
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
|
||||
var msecs = (options.msecs != null) ? options.msecs : new Date().getTime();
|
||||
|
||||
// Per 4.2.1.2, use count of uuid's generated during the current clock
|
||||
// cycle to simulate higher resolution clock
|
||||
var nsecs = (options.nsecs != null) ? options.nsecs : _lastNSecs + 1;
|
||||
|
||||
// Time since last uuid creation (in msecs)
|
||||
var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;
|
||||
|
||||
// Per 4.2.1.2, Bump clockseq on clock regression
|
||||
if (dt < 0 && options.clockseq == null) {
|
||||
clockseq = clockseq + 1 & 0x3fff;
|
||||
}
|
||||
|
||||
// Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
|
||||
// time interval
|
||||
if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) {
|
||||
nsecs = 0;
|
||||
}
|
||||
|
||||
// Per 4.2.1.2 Throw error if too many uuids are requested
|
||||
if (nsecs >= 10000) {
|
||||
throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec');
|
||||
}
|
||||
|
||||
_lastMSecs = msecs;
|
||||
_lastNSecs = nsecs;
|
||||
_clockseq = clockseq;
|
||||
|
||||
// Per 4.1.4 - Convert from unix epoch to Gregorian epoch
|
||||
msecs += 12219292800000;
|
||||
|
||||
// `time_low`
|
||||
var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
|
||||
b[i++] = tl >>> 24 & 0xff;
|
||||
b[i++] = tl >>> 16 & 0xff;
|
||||
b[i++] = tl >>> 8 & 0xff;
|
||||
b[i++] = tl & 0xff;
|
||||
|
||||
// `time_mid`
|
||||
var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;
|
||||
b[i++] = tmh >>> 8 & 0xff;
|
||||
b[i++] = tmh & 0xff;
|
||||
|
||||
// `time_high_and_version`
|
||||
b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
|
||||
b[i++] = tmh >>> 16 & 0xff;
|
||||
|
||||
// `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
|
||||
b[i++] = clockseq >>> 8 | 0x80;
|
||||
|
||||
// `clock_seq_low`
|
||||
b[i++] = clockseq & 0xff;
|
||||
|
||||
// `node`
|
||||
var node = options.node || _nodeId;
|
||||
for (var n = 0; n < 6; n++) {
|
||||
b[i + n] = node[n];
|
||||
}
|
||||
|
||||
return buf ? buf : unparse(b);
|
||||
}
|
||||
|
||||
// **`v4()` - Generate random UUID**
|
||||
|
||||
// See https://github.com/broofa/node-uuid for API details
|
||||
function v4(options, buf, offset) {
|
||||
// Deprecated - 'format' argument, as supported in v1.2
|
||||
var i = buf && offset || 0;
|
||||
|
||||
if (typeof(options) === 'string') {
|
||||
buf = (options === 'binary') ? new BufferClass(16) : null;
|
||||
options = null;
|
||||
}
|
||||
options = options || {};
|
||||
|
||||
var rnds = options.random || (options.rng || _rng)();
|
||||
|
||||
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
||||
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
||||
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
||||
|
||||
// Copy bytes to buffer, if provided
|
||||
if (buf) {
|
||||
for (var ii = 0; ii < 16; ii++) {
|
||||
buf[i + ii] = rnds[ii];
|
||||
}
|
||||
}
|
||||
|
||||
return buf || unparse(rnds);
|
||||
}
|
||||
|
||||
// Export public API
|
||||
var uuid = v4;
|
||||
uuid.v1 = v1;
|
||||
uuid.v4 = v4;
|
||||
uuid.parse = parse;
|
||||
uuid.unparse = unparse;
|
||||
uuid.BufferClass = BufferClass;
|
||||
uuid._rng = _rng;
|
||||
uuid._mathRNG = _mathRNG;
|
||||
uuid._whatwgRNG = _whatwgRNG;
|
||||
|
||||
return uuid;
|
||||
}
|
||||
}
|
||||
|
||||
// check for Module/AMD support, otherwise call the uuid function to setup the angular module.
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = new AngularUUID();
|
||||
|
||||
} else if (typeof define !== 'undefined' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define (function() {
|
||||
return new AngularUUID();
|
||||
});
|
||||
|
||||
} else {
|
||||
AngularUUID();
|
||||
}
|
@ -1,227 +0,0 @@
|
||||
angular.module('ngVis', [])
|
||||
|
||||
.factory('VisDataSet', function () {
|
||||
'use strict';
|
||||
return function (data, options) {
|
||||
// Create the new dataSets
|
||||
return new vis.DataSet(data, options);
|
||||
};
|
||||
})
|
||||
|
||||
/**
|
||||
* TimeLine directive
|
||||
*/
|
||||
.directive('visTimeline', function () {
|
||||
'use strict';
|
||||
return {
|
||||
restrict: 'EA',
|
||||
transclude: false,
|
||||
scope: {
|
||||
data: '=',
|
||||
options: '=',
|
||||
events: '='
|
||||
},
|
||||
link: function (scope, element, attr) {
|
||||
var timelineEvents = [
|
||||
'rangechange',
|
||||
'rangechanged',
|
||||
'timechange',
|
||||
'timechanged',
|
||||
'select',
|
||||
'doubleClick',
|
||||
'click',
|
||||
'contextmenu'
|
||||
];
|
||||
|
||||
// Declare the timeline
|
||||
var timeline = null;
|
||||
|
||||
scope.$watch('data', function () {
|
||||
// Sanity check
|
||||
if (scope.data == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we've actually changed the data set, then recreate the graph
|
||||
// We can always update the data by adding more data to the existing data set
|
||||
if (timeline != null) {
|
||||
timeline.destroy();
|
||||
}
|
||||
|
||||
// Create the timeline object
|
||||
timeline = new vis.Timeline(element[0], scope.data.items, scope.data.groups, scope.options);
|
||||
|
||||
// Attach an event handler if defined
|
||||
angular.forEach(scope.events, function (callback, event) {
|
||||
if (timelineEvents.indexOf(String(event)) >= 0) {
|
||||
timeline.on(event, callback);
|
||||
}
|
||||
});
|
||||
|
||||
// onLoad callback
|
||||
if (scope.events != null && scope.events.onload != null &&
|
||||
angular.isFunction(scope.events.onload)) {
|
||||
scope.events.onload(timeline);
|
||||
}
|
||||
});
|
||||
|
||||
scope.$watchCollection('options', function (options) {
|
||||
if (timeline == null) {
|
||||
return;
|
||||
}
|
||||
timeline.setOptions(options);
|
||||
});
|
||||
}
|
||||
};
|
||||
})
|
||||
|
||||
/**
|
||||
* Directive for network chart.
|
||||
*/
|
||||
.directive('visNetwork', function () {
|
||||
return {
|
||||
restrict: 'EA',
|
||||
transclude: false,
|
||||
scope: {
|
||||
data: '=',
|
||||
options: '=',
|
||||
events: '='
|
||||
},
|
||||
link: function (scope, element, attr) {
|
||||
var networkEvents = [
|
||||
'click',
|
||||
'doubleClick',
|
||||
'oncontext',
|
||||
'hold',
|
||||
'release',
|
||||
'selectNode',
|
||||
'selectEdge',
|
||||
'deselectNode',
|
||||
'deselectEdge',
|
||||
'dragStart',
|
||||
'dragging',
|
||||
'dragEnd',
|
||||
'hoverNode',
|
||||
'hoverEdge',
|
||||
'blurNode',
|
||||
'blurEdge',
|
||||
'zoom',
|
||||
'showPopup',
|
||||
'hidePopup',
|
||||
'startStabilizing',
|
||||
'stabilizationProgress',
|
||||
'stabilizationIterationsDone',
|
||||
'stabilized',
|
||||
'resize',
|
||||
'initRedraw',
|
||||
'beforeDrawing',
|
||||
'afterDrawing',
|
||||
'animationFinished'
|
||||
|
||||
];
|
||||
|
||||
var network = null;
|
||||
|
||||
scope.$watch('data', function () {
|
||||
// Sanity check
|
||||
if (scope.data == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we've actually changed the data set, then recreate the graph
|
||||
// We can always update the data by adding more data to the existing data set
|
||||
if (network != null) {
|
||||
network.destroy();
|
||||
}
|
||||
|
||||
// Create the graph2d object
|
||||
network = new vis.Network(element[0], scope.data, scope.options);
|
||||
|
||||
// Attach an event handler if defined
|
||||
angular.forEach(scope.events, function (callback, event) {
|
||||
if (networkEvents.indexOf(String(event)) >= 0) {
|
||||
network.on(event, callback);
|
||||
}
|
||||
});
|
||||
|
||||
// onLoad callback
|
||||
if (scope.events != null && scope.events.onload != null &&
|
||||
angular.isFunction(scope.events.onload)) {
|
||||
scope.events.onload(network);
|
||||
}
|
||||
});
|
||||
|
||||
scope.$watchCollection('options', function (options) {
|
||||
if (network == null) {
|
||||
return;
|
||||
}
|
||||
network.setOptions(options);
|
||||
});
|
||||
}
|
||||
};
|
||||
})
|
||||
|
||||
/**
|
||||
* Directive for graph2d.
|
||||
*/
|
||||
.directive('visGraph2d', function () {
|
||||
'use strict';
|
||||
return {
|
||||
restrict: 'EA',
|
||||
transclude: false,
|
||||
scope: {
|
||||
data: '=',
|
||||
options: '=',
|
||||
events: '='
|
||||
},
|
||||
link: function (scope, element, attr) {
|
||||
var graphEvents = [
|
||||
'rangechange',
|
||||
'rangechanged',
|
||||
'timechange',
|
||||
'timechanged',
|
||||
'finishedRedraw'
|
||||
];
|
||||
|
||||
// Create the chart
|
||||
var graph = null;
|
||||
|
||||
scope.$watch('data', function () {
|
||||
// Sanity check
|
||||
if (scope.data == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we've actually changed the data set, then recreate the graph
|
||||
// We can always update the data by adding more data to the existing data set
|
||||
if (graph != null) {
|
||||
graph.destroy();
|
||||
}
|
||||
|
||||
// Create the graph2d object
|
||||
graph = new vis.Graph2d(element[0], scope.data.items, scope.data.groups, scope.options);
|
||||
|
||||
// Attach an event handler if defined
|
||||
angular.forEach(scope.events, function (callback, event) {
|
||||
if (graphEvents.indexOf(String(event)) >= 0) {
|
||||
graph.on(event, callback);
|
||||
}
|
||||
});
|
||||
|
||||
// onLoad callback
|
||||
if (scope.events != null && scope.events.onload != null &&
|
||||
angular.isFunction(scope.events.onload)) {
|
||||
scope.events.onload(graph);
|
||||
}
|
||||
});
|
||||
|
||||
scope.$watchCollection('options', function (options) {
|
||||
if (graph == null) {
|
||||
return;
|
||||
}
|
||||
graph.setOptions(options);
|
||||
});
|
||||
}
|
||||
};
|
||||
})
|
||||
;
|
File diff suppressed because it is too large
Load Diff
@ -1,103 +0,0 @@
|
||||
(function (self) {
|
||||
/*
|
||||
* TODO, lots of concatenation (slow in js)
|
||||
*/
|
||||
var spacing = " ";
|
||||
|
||||
function getType(obj) {
|
||||
var type = typeof obj;
|
||||
if (obj instanceof Array) {
|
||||
return 'array';
|
||||
} else if (type == 'string') {
|
||||
return 'string';
|
||||
} else if (type == 'boolean') {
|
||||
return 'boolean';
|
||||
} else if (type == 'number') {
|
||||
return 'number';
|
||||
} else if (type == 'undefined' || obj === null) {
|
||||
return 'null';
|
||||
} else {
|
||||
return 'hash';
|
||||
}
|
||||
}
|
||||
|
||||
function convert(obj, ret) {
|
||||
var type = getType(obj);
|
||||
|
||||
switch(type) {
|
||||
case 'array':
|
||||
convertArray(obj, ret);
|
||||
break;
|
||||
case 'hash':
|
||||
convertHash(obj, ret);
|
||||
break;
|
||||
case 'string':
|
||||
convertString(obj, ret);
|
||||
break;
|
||||
case 'null':
|
||||
ret.push('null');
|
||||
break;
|
||||
case 'number':
|
||||
ret.push(obj.toString());
|
||||
break;
|
||||
case 'boolean':
|
||||
ret.push(obj ? 'true' : 'false');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function convertArray(obj, ret) {
|
||||
for (var i=0; i<obj.length; i++) {
|
||||
var ele = obj[i];
|
||||
var recurse = [];
|
||||
convert(ele, recurse);
|
||||
|
||||
for (var j=0; j<recurse.length; j++) {
|
||||
ret.push((j == 0 ? "- " : spacing) + recurse[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function convertHash(obj, ret) {
|
||||
for (var k in obj) {
|
||||
var recurse = [];
|
||||
if (obj.hasOwnProperty(k)) {
|
||||
var ele = obj[k];
|
||||
convert(ele, recurse);
|
||||
var type = getType(ele);
|
||||
if (type == 'string' || type == 'null' || type == 'number' || type == 'boolean') {
|
||||
ret.push(normalizeString(k) + ': ' + recurse[0]);
|
||||
} else {
|
||||
ret.push(normalizeString(k) + ': ');
|
||||
for (var i=0; i<recurse.length; i++) {
|
||||
ret.push(spacing + recurse[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeString(str) {
|
||||
return str;
|
||||
// original logic is as follows.
|
||||
// if (str.match(/^[\w]+$/)) {
|
||||
// return str;
|
||||
// } else {
|
||||
// return '"'+escape(str).replace(/%u/g,'\\u').replace(/%U/g,'\\U').replace(/%/g,'\\x')+'"';
|
||||
// }
|
||||
}
|
||||
|
||||
function convertString(obj, ret) {
|
||||
ret.push(normalizeString(obj));
|
||||
}
|
||||
|
||||
self.json2yaml = function(obj) {
|
||||
if (typeof obj == 'string') {
|
||||
obj = JSON.parse(obj);
|
||||
}
|
||||
|
||||
var ret = [];
|
||||
convert(obj, ret);
|
||||
return ret.join("\n");
|
||||
};
|
||||
})(this);
|
@ -21,9 +21,16 @@ module.exports = function(config) {
|
||||
'node_modules/angular-messages/angular-messages.js',
|
||||
'node_modules/angular-animate/angular-animate.js',
|
||||
'node_modules/angular-sanitize/angular-sanitize.js',
|
||||
'node_modules/angular-material/angular-material.js',
|
||||
'node_modules/@cgross/angular-notify/dist/angular-notify.js',
|
||||
'node_modules/angular-visjs/angular-vis.js',
|
||||
'node_modules/angular-uuid/angular-uuid.js',
|
||||
'node_modules/file-saver/FileSaver.js',
|
||||
'node_modules/vis/dist/vis.js',
|
||||
'node_modules/js-yaml/dist/js-yaml.js',
|
||||
'node_modules/@appscode/json2yaml/src/json2yaml.js',
|
||||
'node_modules/angular-ui-router/release/angular-ui-router.js',
|
||||
'node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js',
|
||||
'heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/libs/*.js',
|
||||
'heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/*.module.js',
|
||||
'heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/!(*.spec|*.module).js',
|
||||
'heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/*.spec.js',
|
||||
|
@ -153,3 +153,8 @@ XStatic-smart-table==1.4.13.2
|
||||
XStatic-Spin==1.2.5.2
|
||||
XStatic-term.js==0.0.7.0
|
||||
XStatic-tv4==1.2.7.0
|
||||
xstatic-angular-uuid===0.0.4.0
|
||||
xstatic-angular-vis===4.16.0.0
|
||||
xstatic-filesaver===1.3.2.0
|
||||
xstatic-js-yaml===3.8.1.0
|
||||
xstatic-json2yaml===0.1.1.0
|
||||
|
32
package.json
32
package.json
@ -7,25 +7,35 @@
|
||||
"doc": "doc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"angular-ui-router": "0.4.3",
|
||||
"angular-mocks": "1.5.8",
|
||||
"@appscode/json2yaml": "0.1.0",
|
||||
"@cgross/angular-notify": "2.5.1",
|
||||
"angular": "1.5.8",
|
||||
"angular-animate": "1.5.8",
|
||||
"angular-aria": "1.5.8",
|
||||
"angular-material": "1.1.5",
|
||||
"angular-messages": "1.5.8",
|
||||
"angular-mocks": "1.5.8",
|
||||
"angular-notify": "1.0.0",
|
||||
"angular-sanitize": "1.5.8",
|
||||
"angular-ui-bootstrap": "2.5.0",
|
||||
"jasmine": "2.8.0",
|
||||
"jasmine-core": "2.8.0",
|
||||
"karma-coverage": "1.1.1",
|
||||
"karma-jasmine": "1.1.0",
|
||||
"karma-firefox-launcher": "1.0.1",
|
||||
"karma-chrome-launcher": "2.2.0",
|
||||
"karma-ng-html2js-preprocessor": "1.0.0",
|
||||
"karma": "1.7.1",
|
||||
"angular-ui-router": "0.4.3",
|
||||
"angular-uuid": "0.0.4",
|
||||
"angular-visjs": "4.16.0",
|
||||
"eslint": "4.9.0",
|
||||
"eslint-plugin-angular": "3.1.1",
|
||||
"eslint-plugin-jasmine": "2.9.1"
|
||||
"eslint-plugin-jasmine": "2.9.1",
|
||||
"file-saver": "1.3.2",
|
||||
"jasmine": "2.8.0",
|
||||
"jasmine-core": "2.8.0",
|
||||
"js-yaml": "3.8.1",
|
||||
"json2yaml": "1.1.0",
|
||||
"karma": "1.7.1",
|
||||
"karma-chrome-launcher": "2.2.0",
|
||||
"karma-coverage": "1.1.1",
|
||||
"karma-firefox-launcher": "1.0.1",
|
||||
"karma-jasmine": "1.1.0",
|
||||
"karma-ng-html2js-preprocessor": "1.0.0",
|
||||
"vis": "4.3.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "if [ -z $CHROME_BIN ];then export CHROME_BIN=/usr/bin/chromium-browser;fi && karma start karma.conf.js --single-run",
|
||||
|
@ -13,3 +13,9 @@ python-heatclient>=1.10.0 # Apache-2.0
|
||||
# This will be installed from git in OpenStack CI if the job setting
|
||||
# required-projects for horizon:
|
||||
horizon>=14.0.0.0b1 # Apache-2.0
|
||||
|
||||
xstatic-angular-uuid>=0.0.4.0 # MIT
|
||||
xstatic-angular-vis>=4.16.0.0 # MIT
|
||||
xstatic-filesaver>=1.3.2.0 # MIT
|
||||
xstatic-js-yaml>=3.8.1.0 # MIT
|
||||
xstatic-json2yaml>=0.1.1.0 # MIT
|
||||
|
5
tox.ini
5
tox.ini
@ -21,7 +21,9 @@ commands =
|
||||
py35: {[unit_tests]commands}
|
||||
|
||||
[unit_tests]
|
||||
commands = python manage.py test heat_dashboard.test --settings=heat_dashboard.test.settings
|
||||
commands =
|
||||
pip install -r requirements.txt
|
||||
python manage.py test heat_dashboard.test --settings=heat_dashboard.test.settings
|
||||
|
||||
[testenv:pep8]
|
||||
commands = flake8 {posargs}
|
||||
@ -68,6 +70,7 @@ import-order-style = pep8
|
||||
passenv =
|
||||
HOME
|
||||
DISPLAY
|
||||
CHROME_BIN
|
||||
commands =
|
||||
nodeenv -p
|
||||
npm install
|
||||
|
Loading…
Reference in New Issue
Block a user