Browse Source

Merge "Replace embedded static files with XStatic-*"

Zuul 9 months ago
parent
commit
ed26baa828

+ 34
- 20
heat_dashboard/enabled/_1650_project_template_generator_panel.py View File

@@ -12,12 +12,10 @@
12 12
 
13 13
 import os
14 14
 
15
-from importlib import import_module
15
+from horizon.utils.file_discovery import discover_files
16 16
 
17 17
 import heat_dashboard
18 18
 
19
-from horizon.utils.file_discovery import discover_files
20
-
21 19
 # The slug of the panel to be added to HORIZON_CONFIG. Required.
22 20
 PANEL = 'template_generator'
23 21
 # The slug of the dashboard the PANEL associated with. Required.
@@ -39,32 +37,34 @@ TEMPLATE_GENERATOR_BASE = 'dashboard/project/heat_dashboard/template_generator'
39 37
 CSS_BASE = '%s/css' % TEMPLATE_GENERATOR_BASE
40 38
 JS_BASE = '%s/js' % TEMPLATE_GENERATOR_BASE
41 39
 
42
-ADD_SCSS_FILES = [
43
-    '%s/hotgen-main.scss' % CSS_BASE,
44
-    'horizon/lib/bootstrap_scss/scss/_bootstrap.scss',
45
-    'horizon/lib/font_awesome/scss/font-awesome.scss']
46
-
47
-XSTATIC_MODULES = [
40
+ADD_XSTATIC_MODULES = [
48 41
     ('xstatic.pkg.angular', [
49 42
         'angular-animate.js',
50 43
         'angular-aria.js',
51 44
         'angular-messages.js',
52 45
     ]),
53 46
     ('xstatic.pkg.angular_bootstrap', ['angular-bootstrap.js']),
47
+    # ('xstatic.pkg.angular_material', ['angular-material.js']),
48
+    ('xstatic.pkg.angular_uuid', ['angular-uuid.js']),
49
+    ('xstatic.pkg.angular_vis', ['angular-vis.js']),
50
+    ('xstatic.pkg.filesaver', ['FileSaver.js']),
51
+    ('xstatic.pkg.js_yaml', ['js-yaml.js']),
52
+    ('xstatic.pkg.json2yaml', ['json2yaml.js']),
54 53
 ]
54
+
55
+ADD_SCSS_FILES = [
56
+    'horizon/lib/bootstrap_scss/scss/_bootstrap.scss',
57
+    'horizon/lib/font_awesome/scss/font-awesome.scss',
58
+    '%s/hotgen-main.scss' % CSS_BASE
59
+    ]
60
+
55 61
 HEAT_DASHBOARD_ROOT = heat_dashboard.__path__[0]
56 62
 
63
+
57 64
 ADD_JS_FILES = discover_files(os.path.join(HEAT_DASHBOARD_ROOT, 'static'),
58 65
                               sub_path='%s/libs' % JS_BASE,
59 66
                               ext='.js', trim_base_path=True)
60 67
 
61
-for module_name, js_files in XSTATIC_MODULES:
62
-    module = import_module(module_name)
63
-    for js_file in js_files:
64
-        ADD_JS_FILES.append(
65
-            os.path.join('horizon/lib/', module.NAME, js_file)
66
-        )
67
-
68 68
 ADD_JS_FILES.extend([
69 69
     '%s/components/template-generator.module.js' % JS_BASE,
70 70
     '%s/components/utils.module.js' % JS_BASE,
@@ -72,18 +72,32 @@ ADD_JS_FILES.extend([
72 72
 ])
73 73
 
74 74
 ADD_JS_FILES.extend(
75
-    [file for file in discover_files(
75
+    [js_file for js_file in discover_files(
76 76
         os.path.join(HEAT_DASHBOARD_ROOT,
77 77
                      'static'),
78 78
         sub_path='%s/components' % JS_BASE,
79 79
         ext='.js',
80 80
         trim_base_path=True)
81
-        if file not in ADD_JS_FILES and 'spec.js' not in file
81
+        if js_file not in ADD_JS_FILES and not js_file.endswith('spec.js')
82 82
      ])
83 83
 
84 84
 ADD_JS_FILES.extend(
85
-    [file for file in discover_files(
85
+    [js_file for js_file in discover_files(
86
+        os.path.join(HEAT_DASHBOARD_ROOT, 'static'),
87
+        sub_path='%s/resources' % JS_BASE,
88
+        ext='.js', trim_base_path=True) if not js_file.endswith('spec.js')
89
+     ])
90
+
91
+ADD_JS_SPEC_FILES = [
92
+    js_file for js_file in discover_files(
93
+        os.path.join(HEAT_DASHBOARD_ROOT, 'static'),
94
+        sub_path='%s/components' % JS_BASE,
95
+        ext='.js',
96
+        trim_base_path=True) if js_file.endswith('spec.js')]
97
+
98
+ADD_JS_SPEC_FILES.extend(
99
+    [js_file for js_file in discover_files(
86 100
         os.path.join(HEAT_DASHBOARD_ROOT, 'static'),
87 101
         sub_path='%s/resources' % JS_BASE,
88
-        ext='.js', trim_base_path=True) if 'spec.js' not in file
102
+        ext='.js', trim_base_path=True) if js_file.endswith('spec.js')
89 103
      ])

+ 1
- 1
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/css/angular-notify.scss View File

@@ -80,4 +80,4 @@
80 80
     overflow: hidden;
81 81
     clip: rect(0,0,0,0);
82 82
     border: 0;
83
-}
83
+}

+ 1
- 3
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/css/hotgen-main.scss View File

@@ -2,6 +2,4 @@
2 2
 @import "/dashboard/project/heat_dashboard/template_generator/css/angular-material.scss";
3 3
 @import "/dashboard/project/heat_dashboard/template_generator/css/angular-notify.scss";
4 4
 @import "/dashboard/project/heat_dashboard/template_generator/css/hotgen.scss";
5
-@import "/dashboard/project/heat_dashboard/template_generator/css/vis.scss";
6
-
7
-
5
+@import "/dashboard/project/heat_dashboard/template_generator/css/vis.scss";

+ 0
- 188
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/libs/FileSaver.js View File

@@ -1,188 +0,0 @@
1
-/* FileSaver.js
2
- * A saveAs() FileSaver implementation.
3
- * 1.3.2
4
- * 2016-06-16 18:25:19
5
- *
6
- * By Eli Grey, http://eligrey.com
7
- * License: MIT
8
- *   See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md
9
- */
10
-
11
-/*global self */
12
-/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */
13
-
14
-/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
15
-
16
-var saveAs = saveAs || (function(view) {
17
-	"use strict";
18
-	// IE <10 is explicitly unsupported
19
-	if (typeof view === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) {
20
-		return;
21
-	}
22
-	var
23
-		  doc = view.document
24
-		  // only get URL when necessary in case Blob.js hasn't overridden it yet
25
-		, get_URL = function() {
26
-			return view.URL || view.webkitURL || view;
27
-		}
28
-		, save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
29
-		, can_use_save_link = "download" in save_link
30
-		, click = function(node) {
31
-			var event = new MouseEvent("click");
32
-			node.dispatchEvent(event);
33
-		}
34
-		, is_safari = /constructor/i.test(view.HTMLElement) || view.safari
35
-		, is_chrome_ios =/CriOS\/[\d]+/.test(navigator.userAgent)
36
-		, throw_outside = function(ex) {
37
-			(view.setImmediate || view.setTimeout)(function() {
38
-				throw ex;
39
-			}, 0);
40
-		}
41
-		, force_saveable_type = "application/octet-stream"
42
-		// the Blob API is fundamentally broken as there is no "downloadfinished" event to subscribe to
43
-		, arbitrary_revoke_timeout = 1000 * 40 // in ms
44
-		, revoke = function(file) {
45
-			var revoker = function() {
46
-				if (typeof file === "string") { // file is an object URL
47
-					get_URL().revokeObjectURL(file);
48
-				} else { // file is a File
49
-					file.remove();
50
-				}
51
-			};
52
-			setTimeout(revoker, arbitrary_revoke_timeout);
53
-		}
54
-		, dispatch = function(filesaver, event_types, event) {
55
-			event_types = [].concat(event_types);
56
-			var i = event_types.length;
57
-			while (i--) {
58
-				var listener = filesaver["on" + event_types[i]];
59
-				if (typeof listener === "function") {
60
-					try {
61
-						listener.call(filesaver, event || filesaver);
62
-					} catch (ex) {
63
-						throw_outside(ex);
64
-					}
65
-				}
66
-			}
67
-		}
68
-		, auto_bom = function(blob) {
69
-			// prepend BOM for UTF-8 XML and text/* types (including HTML)
70
-			// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
71
-			if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
72
-				return new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type});
73
-			}
74
-			return blob;
75
-		}
76
-		, FileSaver = function(blob, name, no_auto_bom) {
77
-			if (!no_auto_bom) {
78
-				blob = auto_bom(blob);
79
-			}
80
-			// First try a.download, then web filesystem, then object URLs
81
-			var
82
-				  filesaver = this
83
-				, type = blob.type
84
-				, force = type === force_saveable_type
85
-				, object_url
86
-				, dispatch_all = function() {
87
-					dispatch(filesaver, "writestart progress write writeend".split(" "));
88
-				}
89
-				// on any filesys errors revert to saving with object URLs
90
-				, fs_error = function() {
91
-					if ((is_chrome_ios || (force && is_safari)) && view.FileReader) {
92
-						// Safari doesn't allow downloading of blob urls
93
-						var reader = new FileReader();
94
-						reader.onloadend = function() {
95
-							var url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;');
96
-							var popup = view.open(url, '_blank');
97
-							if(!popup) view.location.href = url;
98
-							url=undefined; // release reference before dispatching
99
-							filesaver.readyState = filesaver.DONE;
100
-							dispatch_all();
101
-						};
102
-						reader.readAsDataURL(blob);
103
-						filesaver.readyState = filesaver.INIT;
104
-						return;
105
-					}
106
-					// don't create more object URLs than needed
107
-					if (!object_url) {
108
-						object_url = get_URL().createObjectURL(blob);
109
-					}
110
-					if (force) {
111
-						view.location.href = object_url;
112
-					} else {
113
-						var opened = view.open(object_url, "_blank");
114
-						if (!opened) {
115
-							// Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html
116
-							view.location.href = object_url;
117
-						}
118
-					}
119
-					filesaver.readyState = filesaver.DONE;
120
-					dispatch_all();
121
-					revoke(object_url);
122
-				}
123
-			;
124
-			filesaver.readyState = filesaver.INIT;
125
-
126
-			if (can_use_save_link) {
127
-				object_url = get_URL().createObjectURL(blob);
128
-				setTimeout(function() {
129
-					save_link.href = object_url;
130
-					save_link.download = name;
131
-					click(save_link);
132
-					dispatch_all();
133
-					revoke(object_url);
134
-					filesaver.readyState = filesaver.DONE;
135
-				});
136
-				return;
137
-			}
138
-
139
-			fs_error();
140
-		}
141
-		, FS_proto = FileSaver.prototype
142
-		, saveAs = function(blob, name, no_auto_bom) {
143
-			return new FileSaver(blob, name || blob.name || "download", no_auto_bom);
144
-		}
145
-	;
146
-	// IE 10+ (native saveAs)
147
-	if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) {
148
-		return function(blob, name, no_auto_bom) {
149
-			name = name || blob.name || "download";
150
-
151
-			if (!no_auto_bom) {
152
-				blob = auto_bom(blob);
153
-			}
154
-			return navigator.msSaveOrOpenBlob(blob, name);
155
-		};
156
-	}
157
-
158
-	FS_proto.abort = function(){};
159
-	FS_proto.readyState = FS_proto.INIT = 0;
160
-	FS_proto.WRITING = 1;
161
-	FS_proto.DONE = 2;
162
-
163
-	FS_proto.error =
164
-	FS_proto.onwritestart =
165
-	FS_proto.onprogress =
166
-	FS_proto.onwrite =
167
-	FS_proto.onabort =
168
-	FS_proto.onerror =
169
-	FS_proto.onwriteend =
170
-		null;
171
-
172
-	return saveAs;
173
-}(
174
-	   typeof self !== "undefined" && self
175
-	|| typeof window !== "undefined" && window
176
-	|| this.content
177
-));
178
-// `self` is undefined in Firefox for Android content script context
179
-// while `this` is nsIContentFrameMessageManager
180
-// with an attribute `content` that corresponds to the window
181
-
182
-if (typeof module !== "undefined" && module.exports) {
183
-  module.exports.saveAs = saveAs;
184
-} else if ((typeof define !== "undefined" && define !== null) && (define.amd !== null)) {
185
-  define("FileSaver.js", function() {
186
-    return saveAs;
187
-  });
188
-}

+ 0
- 251
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/libs/angular-uuid.js View File

@@ -1,251 +0,0 @@
1
-//    angular-uuid created by Ivan Hayes @munkychop
2
-//    MIT License - http://opensource.org/licenses/mit-license.php
3
-//    --------------------------------------------------------------
4
-//    This is an AngularJS wrapper for the original node-uuid library
5
-//    written by Robert Kieffer – https://github.com/broofa/node-uuid
6
-//    MIT License - http://opensource.org/licenses/mit-license.php
7
-//    The wrapped node-uuid library is at version 1.4.7
8
-
9
-function AngularUUID () {
10
-  'use strict';
11
-
12
-  angular.module('angular-uuid',[]).factory('uuid', ['$window', nodeUUID]);
13
-
14
-  function nodeUUID ($window) {
15
-    // Unique ID creation requires a high quality random # generator.  We feature
16
-    // detect to determine the best RNG source, normalizing to a function that
17
-    // returns 128-bits of randomness, since that's what's usually required
18
-    var _rng, _mathRNG, _whatwgRNG;
19
-
20
-    // Allow for MSIE11 msCrypto
21
-    var _crypto = $window.crypto || $window.msCrypto;
22
-
23
-    if (!_rng && _crypto && _crypto.getRandomValues) {
24
-      // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto
25
-      //
26
-      // Moderately fast, high quality
27
-      try {
28
-        var _rnds8 = new Uint8Array(16);
29
-        _whatwgRNG = _rng = function whatwgRNG() {
30
-          _crypto.getRandomValues(_rnds8);
31
-          return _rnds8;
32
-        };
33
-        _rng();
34
-      } catch(e) {}
35
-    }
36
-
37
-    if (!_rng) {
38
-      // Math.random()-based (RNG)
39
-      //
40
-      // If all else fails, use Math.random().  It's fast, but is of unspecified
41
-      // quality.
42
-      var  _rnds = new Array(16);
43
-      _mathRNG = _rng = function() {
44
-        for (var i = 0, r; i < 16; i++) {
45
-          if ((i & 0x03) === 0) { r = Math.random() * 0x100000000; }
46
-          _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
47
-        }
48
-
49
-        return _rnds;
50
-      };
51
-      if ('undefined' !== typeof console && console.warn) {
52
-        console.warn('[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()');
53
-      }
54
-    }
55
-
56
-    // Buffer class to use
57
-    var BufferClass = ('function' === typeof Buffer) ? Buffer : Array;
58
-
59
-    // Maps for number <-> hex string conversion
60
-    var _byteToHex = [];
61
-    var _hexToByte = {};
62
-    for (var i = 0; i < 256; i++) {
63
-      _byteToHex[i] = (i + 0x100).toString(16).substr(1);
64
-      _hexToByte[_byteToHex[i]] = i;
65
-    }
66
-
67
-    // **`parse()` - Parse a UUID into it's component bytes**
68
-    function parse(s, buf, offset) {
69
-      var i = (buf && offset) || 0, ii = 0;
70
-
71
-      buf = buf || [];
72
-      s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) {
73
-        if (ii < 16) { // Don't overflow!
74
-          buf[i + ii++] = _hexToByte[oct];
75
-        }
76
-      });
77
-
78
-      // Zero out remaining bytes if string was short
79
-      while (ii < 16) {
80
-        buf[i + ii++] = 0;
81
-      }
82
-
83
-      return buf;
84
-    }
85
-
86
-    // **`unparse()` - Convert UUID byte array (ala parse()) into a string**
87
-    function unparse(buf, offset) {
88
-      var i = offset || 0, bth = _byteToHex;
89
-      return  bth[buf[i++]] + bth[buf[i++]] +
90
-              bth[buf[i++]] + bth[buf[i++]] + '-' +
91
-              bth[buf[i++]] + bth[buf[i++]] + '-' +
92
-              bth[buf[i++]] + bth[buf[i++]] + '-' +
93
-              bth[buf[i++]] + bth[buf[i++]] + '-' +
94
-              bth[buf[i++]] + bth[buf[i++]] +
95
-              bth[buf[i++]] + bth[buf[i++]] +
96
-              bth[buf[i++]] + bth[buf[i++]];
97
-    }
98
-
99
-    // **`v1()` - Generate time-based UUID**
100
-    //
101
-    // Inspired by https://github.com/LiosK/UUID.js
102
-    // and http://docs.python.org/library/uuid.html
103
-
104
-    // random #'s we need to init node and clockseq
105
-    var _seedBytes = _rng();
106
-
107
-    // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
108
-    var _nodeId = [
109
-      _seedBytes[0] | 0x01,
110
-      _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5]
111
-    ];
112
-
113
-    // Per 4.2.2, randomize (14 bit) clockseq
114
-    var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff;
115
-
116
-    // Previous uuid creation time
117
-    var _lastMSecs = 0, _lastNSecs = 0;
118
-
119
-    // See https://github.com/broofa/node-uuid for API details
120
-    function v1(options, buf, offset) {
121
-      var i = buf && offset || 0;
122
-      var b = buf || [];
123
-
124
-      options = options || {};
125
-
126
-      var clockseq = (options.clockseq != null) ? options.clockseq : _clockseq;
127
-
128
-      // UUID timestamps are 100 nano-second units since the Gregorian epoch,
129
-      // (1582-10-15 00:00).  JSNumbers aren't precise enough for this, so
130
-      // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
131
-      // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
132
-      var msecs = (options.msecs != null) ? options.msecs : new Date().getTime();
133
-
134
-      // Per 4.2.1.2, use count of uuid's generated during the current clock
135
-      // cycle to simulate higher resolution clock
136
-      var nsecs = (options.nsecs != null) ? options.nsecs : _lastNSecs + 1;
137
-
138
-      // Time since last uuid creation (in msecs)
139
-      var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;
140
-
141
-      // Per 4.2.1.2, Bump clockseq on clock regression
142
-      if (dt < 0 && options.clockseq == null) {
143
-        clockseq = clockseq + 1 & 0x3fff;
144
-      }
145
-
146
-      // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
147
-      // time interval
148
-      if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) {
149
-        nsecs = 0;
150
-      }
151
-
152
-      // Per 4.2.1.2 Throw error if too many uuids are requested
153
-      if (nsecs >= 10000) {
154
-        throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec');
155
-      }
156
-
157
-      _lastMSecs = msecs;
158
-      _lastNSecs = nsecs;
159
-      _clockseq = clockseq;
160
-
161
-      // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
162
-      msecs += 12219292800000;
163
-
164
-      // `time_low`
165
-      var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
166
-      b[i++] = tl >>> 24 & 0xff;
167
-      b[i++] = tl >>> 16 & 0xff;
168
-      b[i++] = tl >>> 8 & 0xff;
169
-      b[i++] = tl & 0xff;
170
-
171
-      // `time_mid`
172
-      var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;
173
-      b[i++] = tmh >>> 8 & 0xff;
174
-      b[i++] = tmh & 0xff;
175
-
176
-      // `time_high_and_version`
177
-      b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
178
-      b[i++] = tmh >>> 16 & 0xff;
179
-
180
-      // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
181
-      b[i++] = clockseq >>> 8 | 0x80;
182
-
183
-      // `clock_seq_low`
184
-      b[i++] = clockseq & 0xff;
185
-
186
-      // `node`
187
-      var node = options.node || _nodeId;
188
-      for (var n = 0; n < 6; n++) {
189
-        b[i + n] = node[n];
190
-      }
191
-
192
-      return buf ? buf : unparse(b);
193
-    }
194
-
195
-    // **`v4()` - Generate random UUID**
196
-
197
-    // See https://github.com/broofa/node-uuid for API details
198
-    function v4(options, buf, offset) {
199
-      // Deprecated - 'format' argument, as supported in v1.2
200
-      var i = buf && offset || 0;
201
-
202
-      if (typeof(options) === 'string') {
203
-        buf = (options === 'binary') ? new BufferClass(16) : null;
204
-        options = null;
205
-      }
206
-      options = options || {};
207
-
208
-      var rnds = options.random || (options.rng || _rng)();
209
-
210
-      // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
211
-      rnds[6] = (rnds[6] & 0x0f) | 0x40;
212
-      rnds[8] = (rnds[8] & 0x3f) | 0x80;
213
-
214
-      // Copy bytes to buffer, if provided
215
-      if (buf) {
216
-        for (var ii = 0; ii < 16; ii++) {
217
-          buf[i + ii] = rnds[ii];
218
-        }
219
-      }
220
-
221
-      return buf || unparse(rnds);
222
-    }
223
-
224
-    // Export public API
225
-    var uuid = v4;
226
-    uuid.v1 = v1;
227
-    uuid.v4 = v4;
228
-    uuid.parse = parse;
229
-    uuid.unparse = unparse;
230
-    uuid.BufferClass = BufferClass;
231
-    uuid._rng = _rng;
232
-    uuid._mathRNG = _mathRNG;
233
-    uuid._whatwgRNG = _whatwgRNG;
234
-
235
-    return uuid;
236
-  }
237
-}
238
-
239
-// check for Module/AMD support, otherwise call the uuid function to setup the angular module.
240
-if (typeof module !== 'undefined' && module.exports) {
241
-  module.exports = new AngularUUID();
242
-
243
-} else if (typeof define !== 'undefined' && define.amd) {
244
-  // AMD. Register as an anonymous module.
245
-  define (function() {
246
-    return new AngularUUID();
247
-  });
248
-  
249
-} else {
250
-  AngularUUID();
251
-}

+ 0
- 227
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/libs/angular-vis.js View File

@@ -1,227 +0,0 @@
1
-angular.module('ngVis', [])
2
-
3
-    .factory('VisDataSet', function () {
4
-        'use strict';
5
-        return function (data, options) {
6
-            // Create the new dataSets
7
-            return new vis.DataSet(data, options);
8
-        };
9
-    })
10
-
11
-/**
12
- * TimeLine directive
13
- */
14
-    .directive('visTimeline', function () {
15
-        'use strict';
16
-        return {
17
-            restrict: 'EA',
18
-            transclude: false,
19
-            scope: {
20
-                data: '=',
21
-                options: '=',
22
-                events: '='
23
-            },
24
-            link: function (scope, element, attr) {
25
-                var timelineEvents = [
26
-                    'rangechange',
27
-                    'rangechanged',
28
-                    'timechange',
29
-                    'timechanged',
30
-                    'select',
31
-                    'doubleClick',
32
-                    'click',
33
-                    'contextmenu'
34
-                ];
35
-
36
-                // Declare the timeline
37
-                var timeline = null;
38
-
39
-                scope.$watch('data', function () {
40
-                    // Sanity check
41
-                    if (scope.data == null) {
42
-                        return;
43
-                    }
44
-
45
-                    // If we've actually changed the data set, then recreate the graph
46
-                    // We can always update the data by adding more data to the existing data set
47
-                    if (timeline != null) {
48
-                        timeline.destroy();
49
-                    }
50
-
51
-                    // Create the timeline object
52
-                    timeline = new vis.Timeline(element[0], scope.data.items, scope.data.groups, scope.options);
53
-
54
-                    // Attach an event handler if defined
55
-                    angular.forEach(scope.events, function (callback, event) {
56
-                        if (timelineEvents.indexOf(String(event)) >= 0) {
57
-                            timeline.on(event, callback);
58
-                        }
59
-                    });
60
-
61
-                    // onLoad callback
62
-                    if (scope.events != null && scope.events.onload != null &&
63
-                        angular.isFunction(scope.events.onload)) {
64
-                        scope.events.onload(timeline);
65
-                    }
66
-                });
67
-
68
-                scope.$watchCollection('options', function (options) {
69
-                    if (timeline == null) {
70
-                        return;
71
-                    }
72
-                    timeline.setOptions(options);
73
-                });
74
-            }
75
-        };
76
-    })
77
-
78
-/**
79
- * Directive for network chart.
80
- */
81
-    .directive('visNetwork', function () {
82
-        return {
83
-            restrict: 'EA',
84
-            transclude: false,
85
-            scope: {
86
-                data: '=',
87
-                options: '=',
88
-                events: '='
89
-            },
90
-            link: function (scope, element, attr) {
91
-                var networkEvents = [
92
-                    'click',
93
-                    'doubleClick',
94
-                    'oncontext',
95
-                    'hold',
96
-                    'release',
97
-                    'selectNode',
98
-                    'selectEdge',
99
-                    'deselectNode',
100
-                    'deselectEdge',
101
-                    'dragStart',
102
-                    'dragging',
103
-                    'dragEnd',
104
-                    'hoverNode',
105
-                    'hoverEdge',
106
-                    'blurNode',
107
-                    'blurEdge',
108
-                    'zoom',
109
-                    'showPopup',
110
-                    'hidePopup',
111
-                    'startStabilizing',
112
-                    'stabilizationProgress',
113
-                    'stabilizationIterationsDone',
114
-                    'stabilized',
115
-                    'resize',
116
-                    'initRedraw',
117
-                    'beforeDrawing',
118
-                    'afterDrawing',
119
-                    'animationFinished'
120
-
121
-                ];
122
-
123
-                var network = null;
124
-
125
-                scope.$watch('data', function () {
126
-                    // Sanity check
127
-                    if (scope.data == null) {
128
-                        return;
129
-                    }
130
-
131
-                    // If we've actually changed the data set, then recreate the graph
132
-                    // We can always update the data by adding more data to the existing data set
133
-                    if (network != null) {
134
-                        network.destroy();
135
-                    }
136
-
137
-                    // Create the graph2d object
138
-                    network = new vis.Network(element[0], scope.data, scope.options);
139
-
140
-                    // Attach an event handler if defined
141
-                    angular.forEach(scope.events, function (callback, event) {
142
-                        if (networkEvents.indexOf(String(event)) >= 0) {
143
-                            network.on(event, callback);
144
-                        }
145
-                    });
146
-
147
-                    // onLoad callback
148
-                    if (scope.events != null && scope.events.onload != null &&
149
-                        angular.isFunction(scope.events.onload)) {
150
-                        scope.events.onload(network);
151
-                    }
152
-                });
153
-
154
-                scope.$watchCollection('options', function (options) {
155
-                    if (network == null) {
156
-                        return;
157
-                    }
158
-                    network.setOptions(options);
159
-                });
160
-            }
161
-        };
162
-    })
163
-
164
-/**
165
- * Directive for graph2d.
166
- */
167
-    .directive('visGraph2d', function () {
168
-        'use strict';
169
-        return {
170
-            restrict: 'EA',
171
-            transclude: false,
172
-            scope: {
173
-                data: '=',
174
-                options: '=',
175
-                events: '='
176
-            },
177
-            link: function (scope, element, attr) {
178
-                var graphEvents = [
179
-                    'rangechange',
180
-                    'rangechanged',
181
-                    'timechange',
182
-                    'timechanged',
183
-                    'finishedRedraw'
184
-                ];
185
-
186
-                // Create the chart
187
-                var graph = null;
188
-
189
-                scope.$watch('data', function () {
190
-                    // Sanity check
191
-                    if (scope.data == null) {
192
-                        return;
193
-                    }
194
-
195
-                    // If we've actually changed the data set, then recreate the graph
196
-                    // We can always update the data by adding more data to the existing data set
197
-                    if (graph != null) {
198
-                        graph.destroy();
199
-                    }
200
-
201
-                    // Create the graph2d object
202
-                    graph = new vis.Graph2d(element[0], scope.data.items, scope.data.groups, scope.options);
203
-
204
-                    // Attach an event handler if defined
205
-                    angular.forEach(scope.events, function (callback, event) {
206
-                        if (graphEvents.indexOf(String(event)) >= 0) {
207
-                            graph.on(event, callback);
208
-                        }
209
-                    });
210
-
211
-                    // onLoad callback
212
-                    if (scope.events != null && scope.events.onload != null &&
213
-                        angular.isFunction(scope.events.onload)) {
214
-                        scope.events.onload(graph);
215
-                    }
216
-                });
217
-
218
-                scope.$watchCollection('options', function (options) {
219
-                    if (graph == null) {
220
-                        return;
221
-                    }
222
-                    graph.setOptions(options);
223
-                });
224
-            }
225
-        };
226
-    })
227
-;

+ 0
- 3862
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/libs/js-yaml.js
File diff suppressed because it is too large
View File


+ 0
- 103
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/libs/json2yaml.js View File

@@ -1,103 +0,0 @@
1
-(function (self) {
2
-  /*
3
-   * TODO, lots of concatenation (slow in js)
4
-   */
5
-  var spacing = "  ";
6
-
7
-  function getType(obj) {
8
-    var type = typeof obj;
9
-    if (obj instanceof Array) {
10
-      return 'array';
11
-    } else if (type == 'string') {
12
-      return 'string';
13
-    } else if (type == 'boolean') {
14
-      return 'boolean';
15
-    } else if (type == 'number') {
16
-      return 'number';
17
-    } else if (type == 'undefined' || obj === null) {
18
-      return 'null';
19
-    } else {
20
-      return 'hash';
21
-    }
22
-  }
23
-
24
-  function convert(obj, ret) {
25
-    var type = getType(obj);
26
-
27
-    switch(type) {
28
-      case 'array':
29
-        convertArray(obj, ret);
30
-        break;
31
-      case 'hash':
32
-        convertHash(obj, ret);
33
-        break;
34
-      case 'string':
35
-        convertString(obj, ret);
36
-        break;
37
-      case 'null':
38
-        ret.push('null');
39
-        break;
40
-      case 'number':
41
-        ret.push(obj.toString());
42
-        break;
43
-      case 'boolean':
44
-        ret.push(obj ? 'true' : 'false');
45
-        break;
46
-    }
47
-  }
48
-
49
-  function convertArray(obj, ret) {
50
-    for (var i=0; i<obj.length; i++) {
51
-      var ele     = obj[i];
52
-      var recurse = [];
53
-      convert(ele, recurse);
54
-
55
-      for (var j=0; j<recurse.length; j++) {
56
-        ret.push((j == 0 ? "- " : spacing) + recurse[j]);
57
-      }
58
-    }
59
-  }
60
-
61
-  function convertHash(obj, ret) {
62
-    for (var k in obj) {
63
-      var recurse = [];
64
-      if (obj.hasOwnProperty(k)) {
65
-        var ele = obj[k];
66
-        convert(ele, recurse);
67
-        var type = getType(ele);
68
-        if (type == 'string' || type == 'null' || type == 'number' || type == 'boolean') {
69
-          ret.push(normalizeString(k) + ': ' +  recurse[0]);
70
-        } else {
71
-          ret.push(normalizeString(k) + ': ');
72
-          for (var i=0; i<recurse.length; i++) {
73
-            ret.push(spacing + recurse[i]);
74
-          }
75
-        }
76
-      }
77
-    }
78
-  }
79
-
80
-  function normalizeString(str) {
81
-    return str;
82
-// original logic is as follows.
83
-//    if (str.match(/^[\w]+$/)) {
84
-//      return str;
85
-//    } else {
86
-//      return '"'+escape(str).replace(/%u/g,'\\u').replace(/%U/g,'\\U').replace(/%/g,'\\x')+'"';
87
-//    }
88
-  }
89
-
90
-  function convertString(obj, ret) {
91
-    ret.push(normalizeString(obj));
92
-  }
93
-
94
-  self.json2yaml = function(obj) {
95
-    if (typeof obj == 'string') {
96
-      obj = JSON.parse(obj);
97
-    }
98
-
99
-    var ret = [];
100
-    convert(obj, ret);
101
-    return ret.join("\n");
102
-  };
103
-})(this);

+ 8
- 1
karma.conf.js View File

@@ -21,9 +21,16 @@ module.exports = function(config) {
21 21
         'node_modules/angular-messages/angular-messages.js',
22 22
         'node_modules/angular-animate/angular-animate.js',
23 23
         'node_modules/angular-sanitize/angular-sanitize.js',
24
+        'node_modules/angular-material/angular-material.js',
25
+        'node_modules/@cgross/angular-notify/dist/angular-notify.js',
26
+        'node_modules/angular-visjs/angular-vis.js',
27
+        'node_modules/angular-uuid/angular-uuid.js',
28
+        'node_modules/file-saver/FileSaver.js',
29
+        'node_modules/vis/dist/vis.js',
30
+        'node_modules/js-yaml/dist/js-yaml.js',
31
+        'node_modules/@appscode/json2yaml/src/json2yaml.js',
24 32
         'node_modules/angular-ui-router/release/angular-ui-router.js',
25 33
         'node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js',
26
-        'heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/libs/*.js',
27 34
         'heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/*.module.js',
28 35
         'heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/!(*.spec|*.module).js',
29 36
         'heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/*.spec.js',

+ 5
- 0
lower-constraints.txt View File

@@ -153,3 +153,8 @@ XStatic-smart-table==1.4.13.2
153 153
 XStatic-Spin==1.2.5.2
154 154
 XStatic-term.js==0.0.7.0
155 155
 XStatic-tv4==1.2.7.0
156
+xstatic-angular-uuid===0.0.4.0
157
+xstatic-angular-vis===4.16.0.0
158
+xstatic-filesaver===1.3.2.0
159
+xstatic-js-yaml===3.8.1.0
160
+xstatic-json2yaml===0.1.1.0

+ 18
- 8
package.json View File

@@ -7,25 +7,35 @@
7 7
     "doc": "doc"
8 8
   },
9 9
   "devDependencies": {
10
-    "angular-ui-router": "0.4.3",
11
-    "angular-mocks": "1.5.8",
10
+    "@appscode/json2yaml": "0.1.0",
11
+    "@cgross/angular-notify": "2.5.1",
12 12
     "angular": "1.5.8",
13 13
     "angular-animate": "1.5.8",
14 14
     "angular-aria": "1.5.8",
15
+    "angular-material": "1.1.5",
15 16
     "angular-messages": "1.5.8",
17
+    "angular-mocks": "1.5.8",
18
+    "angular-notify": "1.0.0",
16 19
     "angular-sanitize": "1.5.8",
17 20
     "angular-ui-bootstrap": "2.5.0",
21
+    "angular-ui-router": "0.4.3",
22
+    "angular-uuid": "0.0.4",
23
+    "angular-visjs": "4.16.0",
24
+    "eslint": "4.9.0",
25
+    "eslint-plugin-angular": "3.1.1",
26
+    "eslint-plugin-jasmine": "2.9.1",
27
+    "file-saver": "1.3.2",
18 28
     "jasmine": "2.8.0",
19 29
     "jasmine-core": "2.8.0",
30
+    "js-yaml": "3.8.1",
31
+    "json2yaml": "1.1.0",
32
+    "karma": "1.7.1",
33
+    "karma-chrome-launcher": "2.2.0",
20 34
     "karma-coverage": "1.1.1",
21
-    "karma-jasmine": "1.1.0",
22 35
     "karma-firefox-launcher": "1.0.1",
23
-    "karma-chrome-launcher": "2.2.0",
36
+    "karma-jasmine": "1.1.0",
24 37
     "karma-ng-html2js-preprocessor": "1.0.0",
25
-    "karma": "1.7.1",
26
-    "eslint": "4.9.0",
27
-    "eslint-plugin-angular": "3.1.1",
28
-    "eslint-plugin-jasmine": "2.9.1"
38
+    "vis": "4.3.0"
29 39
   },
30 40
   "scripts": {
31 41
     "test": "if [ -z $CHROME_BIN ];then export CHROME_BIN=/usr/bin/chromium-browser;fi && karma start karma.conf.js --single-run",

+ 6
- 0
requirements.txt View File

@@ -13,3 +13,9 @@ python-heatclient>=1.10.0 # Apache-2.0
13 13
 # This will be installed from git in OpenStack CI if the job setting
14 14
 # required-projects for horizon:
15 15
 horizon>=14.0.0.0b1 # Apache-2.0
16
+
17
+xstatic-angular-uuid>=0.0.4.0 # MIT
18
+xstatic-angular-vis>=4.16.0.0 # MIT
19
+xstatic-filesaver>=1.3.2.0 # MIT
20
+xstatic-js-yaml>=3.8.1.0 # MIT
21
+xstatic-json2yaml>=0.1.1.0 # MIT

+ 4
- 1
tox.ini View File

@@ -21,7 +21,9 @@ commands =
21 21
   py35: {[unit_tests]commands}
22 22
 
23 23
 [unit_tests]
24
-commands = python manage.py test heat_dashboard.test --settings=heat_dashboard.test.settings
24
+commands =
25
+  pip install -r requirements.txt
26
+  python manage.py test heat_dashboard.test --settings=heat_dashboard.test.settings
25 27
 
26 28
 [testenv:pep8]
27 29
 commands = flake8 {posargs}
@@ -68,6 +70,7 @@ import-order-style = pep8
68 70
 passenv =
69 71
   HOME
70 72
   DISPLAY
73
+  CHROME_BIN
71 74
 commands =
72 75
   nodeenv -p
73 76
   npm install

Loading…
Cancel
Save