You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sirona.apache.org by rm...@apache.org on 2015/12/02 22:29:54 UTC
svn commit: r1717687 [5/5] - in /incubator/sirona/dashboard: ./ trunk/
trunk/sirona-dashboard-plugin/ trunk/sirona-dashboard-plugin/src/
trunk/sirona-dashboard-plugin/src/main/
trunk/sirona-dashboard-plugin/src/main/java/
trunk/sirona-dashboard-plugin/...
Added: incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/gridstack/gridstack.js
URL: http://svn.apache.org/viewvc/incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/gridstack/gridstack.js?rev=1717687&view=auto
==============================================================================
--- incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/gridstack/gridstack.js (added)
+++ incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/gridstack/gridstack.js Wed Dec 2 21:29:53 2015
@@ -0,0 +1,988 @@
+// gridstack.js 0.2.4-dev
+// http://troolee.github.io/gridstack.js/
+// (c) 2014-2015 Pavel Reznikov
+// gridstack.js may be freely distributed under the MIT license.
+
+(function(factory) {
+ if (typeof define === 'function' && define.amd) {
+ define(['jquery', 'lodash', 'jquery-ui/core', 'jquery-ui/widget', 'jquery-ui/mouse', 'jquery-ui/draggable',
+ 'jquery-ui/resizable'], factory);
+ }
+ else if (typeof exports !== 'undefined') {
+ try { jQuery = require('jquery'); } catch(e) {}
+ try { _ = require('lodash'); } catch(e) {}
+ factory(jQuery, _);
+ }
+ else {
+ factory(jQuery, _);
+ }
+})(function($, _) {
+
+ var scope = window;
+
+ var Utils = {
+ is_intercepted: function(a, b) {
+ return !(a.x + a.width <= b.x || b.x + b.width <= a.x || a.y + a.height <= b.y || b.y + b.height <= a.y);
+ },
+
+ sort: function(nodes, dir, width) {
+ width = width || _.chain(nodes).map(function(node) { return node.x + node.width; }).max().value();
+ dir = dir != -1 ? 1 : -1;
+ return _.sortBy(nodes, function(n) { return dir * (n.x + n.y * width); });
+ },
+
+ create_stylesheet: function(id) {
+ var style = document.createElement('style');
+ style.setAttribute('type', 'text/css');
+ style.setAttribute('data-gs-id', id);
+ if (style.styleSheet) {
+ style.styleSheet.cssText = '';
+ }
+ else {
+ style.appendChild(document.createTextNode(''));
+ }
+ document.getElementsByTagName('head')[0].appendChild(style);
+ return style.sheet;
+ },
+ remove_stylesheet: function(id) {
+ $("STYLE[data-gs-id=" + id +"]").remove();
+ },
+ insert_css_rule: function(sheet, selector, rules, index) {
+ if (typeof sheet.insertRule === 'function') {
+ sheet.insertRule(selector + '{' + rules + '}', index);
+ }
+ else if (typeof sheet.addRule === 'function') {
+ sheet.addRule(selector, rules, index);
+ }
+ },
+
+ toBool: function(v) {
+ if (typeof v == 'boolean')
+ return v;
+ if (typeof v == 'string') {
+ v = v.toLowerCase();
+ return !(v == '' || v == 'no' || v == 'false' || v == '0');
+ }
+ return Boolean(v);
+ }
+ };
+
+ var id_seq = 0;
+
+ var GridStackEngine = function(width, onchange, float_mode, height, items) {
+ this.width = width;
+ this['float'] = float_mode || false;
+ this.height = height || 0;
+
+ this.nodes = items || [];
+ this.onchange = onchange || function() {};
+
+ this._update_counter = 0;
+ this._float = this['float'];
+ };
+
+ GridStackEngine.prototype.batch_update = function() {
+ this._update_counter = 1;
+ this.float = true;
+ };
+
+ GridStackEngine.prototype.commit = function() {
+ this._update_counter = 0;
+ if (this._update_counter == 0) {
+ this.float = this._float;
+ this._pack_nodes();
+ this._notify();
+ }
+ };
+
+ GridStackEngine.prototype._fix_collisions = function(node) {
+ this._sort_nodes(-1);
+
+ var nn = node, has_locked = Boolean(_.find(this.nodes, function(n) { return n.locked }));
+ if (!this.float && !has_locked) {
+ nn = {x: 0, y: node.y, width: this.width, height: node.height};
+ }
+
+ while (true) {
+ var collision_node = _.find(this.nodes, function(n) {
+ return n != node && Utils.is_intercepted(n, nn);
+ }, this);
+ if (typeof collision_node == 'undefined') {
+ return;
+ }
+ this.move_node(collision_node, collision_node.x, node.y + node.height,
+ collision_node.width, collision_node.height, true);
+ }
+ };
+
+ GridStackEngine.prototype.is_area_empty = function(x, y, width, height) {
+ var nn = {x: x || 0, y: y || 0, width: width || 1, height: height || 1};
+ var collision_node = _.find(this.nodes, function(n) {
+ return Utils.is_intercepted(n, nn);
+ }, this);
+ return collision_node == null;
+ };
+
+ GridStackEngine.prototype._sort_nodes = function(dir) {
+ this.nodes = Utils.sort(this.nodes, dir, this.width);
+ };
+
+ GridStackEngine.prototype._pack_nodes = function() {
+ this._sort_nodes();
+
+ if (this.float) {
+ _.each(this.nodes, function(n, i) {
+ if (n._updating || typeof n._orig_y == 'undefined' || n.y == n._orig_y)
+ return;
+
+ var new_y = n.y;
+ while (new_y >= n._orig_y) {
+ var collision_node = _.chain(this.nodes)
+ .find(function(bn) {
+ return n != bn &&
+ Utils.is_intercepted({x: n.x, y: new_y, width: n.width, height: n.height}, bn);
+ })
+ .value();
+
+ if (!collision_node) {
+ n._dirty = true;
+ n.y = new_y;
+ }
+ --new_y;
+ }
+ }, this);
+ }
+ else {
+ _.each(this.nodes, function(n, i) {
+ if (n.locked)
+ return;
+ while (n.y > 0) {
+ var new_y = n.y - 1;
+ var can_be_moved = i == 0;
+
+ if (i > 0) {
+ var collision_node = _.chain(this.nodes)
+ .take(i)
+ .find(function(bn) {
+ return Utils.is_intercepted({x: n.x, y: new_y, width: n.width, height: n.height}, bn);
+ })
+ .value();
+ can_be_moved = typeof collision_node == 'undefined';
+ }
+
+ if (!can_be_moved) {
+ break;
+ }
+ n._dirty = n.y != new_y;
+ n.y = new_y;
+ }
+ }, this);
+ }
+ };
+
+ GridStackEngine.prototype._prepare_node = function(node, resizing) {
+ node = _.defaults(node || {}, {width: 1, height: 1, x: 0, y: 0 });
+
+ node.x = parseInt('' + node.x);
+ node.y = parseInt('' + node.y);
+ node.width = parseInt('' + node.width);
+ node.height = parseInt('' + node.height);
+ node.auto_position = node.auto_position || false;
+ node.no_resize = node.no_resize || false;
+ node.no_move = node.no_move || false;
+
+ if (node.width > this.width) {
+ node.width = this.width;
+ }
+ else if (node.width < 1) {
+ node.width = 1;
+ }
+
+ if (node.height < 1) {
+ node.height = 1;
+ }
+
+ if (node.x < 0) {
+ node.x = 0;
+ }
+
+ if (node.x + node.width > this.width) {
+ if (resizing) {
+ node.width = this.width - node.x;
+ }
+ else {
+ node.x = this.width - node.width;
+ }
+ }
+
+ if (node.y < 0) {
+ node.y = 0;
+ }
+
+ return node;
+ };
+
+ GridStackEngine.prototype._notify = function() {
+ if (this._update_counter) {
+ return;
+ }
+ var deleted_nodes = Array.prototype.slice.call(arguments, 1).concat(this.get_dirty_nodes());
+ deleted_nodes = deleted_nodes.concat(this.get_dirty_nodes());
+ this.onchange(deleted_nodes);
+ };
+
+ GridStackEngine.prototype.clean_nodes = function() {
+ _.each(this.nodes, function(n) {n._dirty = false });
+ };
+
+ GridStackEngine.prototype.get_dirty_nodes = function() {
+ return _.filter(this.nodes, function(n) { return n._dirty; });
+ };
+
+ GridStackEngine.prototype.add_node = function(node) {
+ node = this._prepare_node(node);
+
+ if (typeof node.max_width != 'undefined') node.width = Math.min(node.width, node.max_width);
+ if (typeof node.max_height != 'undefined') node.height = Math.min(node.height, node.max_height);
+ if (typeof node.min_width != 'undefined') node.width = Math.max(node.width, node.min_width);
+ if (typeof node.min_height != 'undefined') node.height = Math.max(node.height, node.min_height);
+
+ node._id = ++id_seq;
+ node._dirty = true;
+
+ if (node.auto_position) {
+ this._sort_nodes();
+
+ for (var i = 0;; ++i) {
+ var x = i % this.width, y = Math.floor(i / this.width);
+ if (x + node.width > this.width) {
+ continue;
+ }
+ if (!_.find(this.nodes, function(n) {
+ return Utils.is_intercepted({x: x, y: y, width: node.width, height: node.height}, n);
+ })) {
+ node.x = x;
+ node.y = y;
+ break;
+ }
+ }
+ }
+
+ this.nodes.push(node);
+
+ this._fix_collisions(node);
+ this._pack_nodes();
+ this._notify();
+ return node;
+ };
+
+ GridStackEngine.prototype.remove_node = function(node) {
+ node._id = null;
+ this.nodes = _.without(this.nodes, node);
+ this._pack_nodes();
+ this._notify(node);
+ };
+
+ GridStackEngine.prototype.can_move_node = function(node, x, y, width, height) {
+ var has_locked = Boolean(_.find(this.nodes, function(n) { return n.locked }));
+
+ if (!this.height && !has_locked)
+ return true;
+
+ var cloned_node;
+ var clone = new GridStackEngine(
+ this.width,
+ null,
+ this.float,
+ 0,
+ _.map(this.nodes, function(n) {
+ if (n == node) {
+ cloned_node = $.extend({}, n);
+ return cloned_node;
+ }
+ return $.extend({}, n);
+ }));
+
+ clone.move_node(cloned_node, x, y, width, height);
+
+ var res = true;
+
+ if (has_locked)
+ res &= !Boolean(_.find(clone.nodes, function(n) {
+ return n != cloned_node && Boolean(n.locked) && Boolean(n._dirty);
+ }));
+ if (this.height)
+ res &= clone.get_grid_height() <= this.height;
+
+ return res;
+ };
+
+ GridStackEngine.prototype.can_be_placed_with_respect_to_height = function(node) {
+ if (!this.height)
+ return true;
+
+ var clone = new GridStackEngine(
+ this.width,
+ null,
+ this.float,
+ 0,
+ _.map(this.nodes, function(n) { return $.extend({}, n) }));
+ clone.add_node(node);
+ return clone.get_grid_height() <= this.height;
+ };
+
+ GridStackEngine.prototype.move_node = function(node, x, y, width, height, no_pack) {
+ if (typeof x != 'number') x = node.x;
+ if (typeof y != 'number') y = node.y;
+ if (typeof width != 'number') width = node.width;
+ if (typeof height != 'number') height = node.height;
+
+ if (typeof node.max_width != 'undefined') width = Math.min(width, node.max_width);
+ if (typeof node.max_height != 'undefined') height = Math.min(height, node.max_height);
+ if (typeof node.min_width != 'undefined') width = Math.max(width, node.min_width);
+ if (typeof node.min_height != 'undefined') height = Math.max(height, node.min_height);
+
+ if (node.x == x && node.y == y && node.width == width && node.height == height) {
+ return node;
+ }
+
+ var resizing = node.width != width;
+ node._dirty = true;
+
+ node.x = x;
+ node.y = y;
+ node.width = width;
+ node.height = height;
+
+ node = this._prepare_node(node, resizing);
+
+ this._fix_collisions(node);
+ if (!no_pack) {
+ this._pack_nodes();
+ this._notify();
+ }
+ return node;
+ };
+
+ GridStackEngine.prototype.get_grid_height = function() {
+ return _.reduce(this.nodes, function(memo, n) { return Math.max(memo, n.y + n.height); }, 0);
+ };
+
+ GridStackEngine.prototype.begin_update = function(node) {
+ _.each(this.nodes, function(n) {
+ n._orig_y = n.y;
+ });
+ node._updating = true;
+ };
+
+ GridStackEngine.prototype.end_update = function() {
+ _.each(this.nodes, function(n) {
+ n._orig_y = n.y;
+ });
+ var n = _.find(this.nodes, function(n) { return n._updating; });
+ if (n) {
+ n._updating = false;
+ }
+ };
+
+ var GridStack = function(el, opts) {
+ var self = this, one_column_mode;
+
+ opts = opts || {};
+
+ this.container = $(el);
+
+ opts.item_class = opts.item_class || 'grid-stack-item';
+ var is_nested = this.container.closest('.' + opts.item_class).size() > 0;
+
+ this.opts = _.defaults(opts || {}, {
+ width: parseInt(this.container.attr('data-gs-width')) || 12,
+ height: parseInt(this.container.attr('data-gs-height')) || 0,
+ item_class: 'grid-stack-item',
+ placeholder_class: 'grid-stack-placeholder',
+ handle: '.grid-stack-item-content',
+ handle_class: null,
+ cell_height: 60,
+ vertical_margin: 20,
+ auto: true,
+ min_width: 768,
+ float: false,
+ static_grid: false,
+ _class: 'grid-stack-' + (Math.random() * 10000).toFixed(0),
+ animate: Boolean(this.container.attr('data-gs-animate')) || false,
+ always_show_resize_handle: opts.always_show_resize_handle || false,
+ resizable: _.defaults(opts.resizable || {}, {
+ autoHide: !(opts.always_show_resize_handle || false),
+ handles: 'se'
+ }),
+ draggable: _.defaults(opts.draggable || {}, {
+ handle: (opts.handle_class ? '.' + opts.handle_class : (opts.handle ? opts.handle : '')) || '.grid-stack-item-content',
+ scroll: false,
+ appendTo: 'body'
+ })
+ });
+ this.opts.is_nested = is_nested;
+
+ this.container.addClass(this.opts._class);
+
+ this._set_static_class();
+
+ if (is_nested) {
+ this.container.addClass('grid-stack-nested');
+ }
+
+ this._init_styles();
+
+ this.grid = new GridStackEngine(this.opts.width, function(nodes) {
+ var max_height = 0;
+ _.each(nodes, function(n) {
+ if (n._id == null) {
+ n.el.remove();
+ }
+ else {
+ n.el
+ .attr('data-gs-x', n.x)
+ .attr('data-gs-y', n.y)
+ .attr('data-gs-width', n.width)
+ .attr('data-gs-height', n.height);
+ max_height = Math.max(max_height, n.y + n.height);
+ }
+ });
+ self._update_styles(max_height + 10);
+ }, this.opts.float, this.opts.height);
+
+ if (this.opts.auto) {
+ var elements = [];
+ var _this = this;
+ this.container.children('.' + this.opts.item_class + ':not(.' + this.opts.placeholder_class + ')').each(function(index, el) {
+ el = $(el);
+ elements.push({
+ el: el,
+ i: parseInt(el.attr('data-gs-x')) + parseInt(el.attr('data-gs-y')) * _this.opts.width
+ });
+ });
+ _.chain(elements).sortBy(function(x) { return x.i; }).each(function(i) {
+ self._prepare_element(i.el);
+ }).value();
+ }
+
+ this.set_animation(this.opts.animate);
+
+ this.placeholder = $(
+ '<div class="' + this.opts.placeholder_class + ' ' + this.opts.item_class + '">' +
+ '<div class="placeholder-content" /></div>').hide();
+
+ this.container.height(
+ this.grid.get_grid_height() * (this.opts.cell_height + this.opts.vertical_margin) -
+ this.opts.vertical_margin);
+
+ this.on_resize_handler = function() {
+ if (self._is_one_column_mode()) {
+ if (one_column_mode)
+ return;
+
+ one_column_mode = true;
+
+ self.grid._sort_nodes();
+ _.each(self.grid.nodes, function(node) {
+ self.container.append(node.el);
+
+ if (self.opts.static_grid) {
+ return;
+ }
+ if (!node.no_move) {
+ node.el.draggable('disable');
+ }
+ if (!node.no_resize) {
+ node.el.resizable('disable');
+ }
+ });
+ }
+ else {
+ if (!one_column_mode)
+ return;
+
+ one_column_mode = false;
+
+ if (self.opts.static_grid) {
+ return;
+ }
+
+ _.each(self.grid.nodes, function(node) {
+ if (!node.no_move) {
+ node.el.draggable('enable');
+ }
+ if (!node.no_resize) {
+ node.el.resizable('enable');
+ }
+ });
+ }
+ };
+
+ $(window).resize(this.on_resize_handler);
+ this.on_resize_handler();
+ };
+
+ GridStack.prototype._trigger_change_event = function(forceTrigger) {
+ var elements = this.grid.get_dirty_nodes();
+ var hasChanges = false;
+
+ var eventParams = [];
+ if (elements && elements.length) {
+ eventParams.push(elements);
+ hasChanges = true;
+ }
+
+ if (hasChanges || forceTrigger === true) {
+ this.container.trigger('change', eventParams);
+ }
+ };
+
+ GridStack.prototype._init_styles = function() {
+ if (this._styles_id) {
+ $('[data-gs-id="' + this._styles_id + '"]').remove();
+ }
+ this._styles_id = 'gridstack-style-' + (Math.random() * 100000).toFixed();
+ this._styles = Utils.create_stylesheet(this._styles_id);
+ if (this._styles != null)
+ this._styles._max = 0;
+ };
+
+ GridStack.prototype._update_styles = function(max_height) {
+ if (this._styles == null) {
+ return;
+ }
+
+ var prefix = '.' + this.opts._class + ' .' + this.opts.item_class;
+
+ if (typeof max_height == 'undefined') {
+ max_height = this._styles._max;
+ this._init_styles();
+ this._update_container_height();
+ }
+
+ if (this._styles._max == 0) {
+ Utils.insert_css_rule(this._styles, prefix, 'min-height: ' + (this.opts.cell_height) + 'px;', 0);
+ }
+
+ if (max_height > this._styles._max) {
+ for (var i = this._styles._max; i < max_height; ++i) {
+ Utils.insert_css_rule(this._styles,
+ prefix + '[data-gs-height="' + (i + 1) + '"]',
+ 'height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;',
+ i
+ );
+ Utils.insert_css_rule(this._styles,
+ prefix + '[data-gs-min-height="' + (i + 1) + '"]',
+ 'min-height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;',
+ i
+ );
+ Utils.insert_css_rule(this._styles,
+ prefix + '[data-gs-max-height="' + (i + 1) + '"]',
+ 'max-height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;',
+ i
+ );
+ Utils.insert_css_rule(this._styles,
+ prefix + '[data-gs-y="' + i + '"]',
+ 'top: ' + (this.opts.cell_height * i + this.opts.vertical_margin * i) + 'px;',
+ i
+ );
+ }
+ this._styles._max = max_height;
+ }
+ };
+
+ GridStack.prototype._update_container_height = function() {
+ if (this.grid._update_counter) {
+ return;
+ }
+ this.container.height(
+ this.grid.get_grid_height() * (this.opts.cell_height + this.opts.vertical_margin) -
+ this.opts.vertical_margin);
+ };
+
+ GridStack.prototype._is_one_column_mode = function() {
+ return (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) <=
+ this.opts.min_width;
+ };
+
+ GridStack.prototype._prepare_element = function(el) {
+ var self = this;
+ el = $(el);
+
+ el.addClass(this.opts.item_class);
+
+ var node = self.grid.add_node({
+ x: el.attr('data-gs-x'),
+ y: el.attr('data-gs-y'),
+ width: el.attr('data-gs-width'),
+ height: el.attr('data-gs-height'),
+ max_width: el.attr('data-gs-max-width'),
+ min_width: el.attr('data-gs-min-width'),
+ max_height: el.attr('data-gs-max-height'),
+ min_height: el.attr('data-gs-min-height'),
+ auto_position: Utils.toBool(el.attr('data-gs-auto-position')),
+ no_resize: Utils.toBool(el.attr('data-gs-no-resize')),
+ no_move: Utils.toBool(el.attr('data-gs-no-move')),
+ locked: Utils.toBool(el.attr('data-gs-locked')),
+ el: el
+ });
+ el.data('_gridstack_node', node);
+
+ if (self.opts.static_grid) {
+ return;
+ }
+
+ var cell_width, cell_height;
+
+ var on_start_moving = function(event, ui) {
+ self.container.append(self.placeholder);
+ var o = $(this);
+ self.grid.clean_nodes();
+ self.grid.begin_update(node);
+ cell_width = Math.ceil(o.outerWidth() / o.attr('data-gs-width'));
+ cell_height = self.opts.cell_height + self.opts.vertical_margin;
+ self.placeholder
+ .attr('data-gs-x', o.attr('data-gs-x'))
+ .attr('data-gs-y', o.attr('data-gs-y'))
+ .attr('data-gs-width', o.attr('data-gs-width'))
+ .attr('data-gs-height', o.attr('data-gs-height'))
+ .show();
+ node.el = self.placeholder;
+
+ el.resizable('option', 'minWidth', cell_width * (node.min_width || 1));
+ el.resizable('option', 'minHeight', self.opts.cell_height * (node.min_height || 1));
+ };
+
+ var on_end_moving = function(event, ui) {
+ self.placeholder.detach();
+ var o = $(this);
+ node.el = o;
+ self.placeholder.hide();
+ o
+ .attr('data-gs-x', node.x)
+ .attr('data-gs-y', node.y)
+ .attr('data-gs-width', node.width)
+ .attr('data-gs-height', node.height)
+ .removeAttr('style');
+ self._update_container_height();
+ self._trigger_change_event();
+
+ self.grid.end_update();
+ };
+
+ el.draggable(_.extend(this.opts.draggable, {
+ start: on_start_moving,
+ stop: on_end_moving,
+ drag: function(event, ui) {
+ var x = Math.round(ui.position.left / cell_width),
+ y = Math.floor((ui.position.top + cell_height / 2) / cell_height);
+ if (!self.grid.can_move_node(node, x, y, node.width, node.height)) {
+ return;
+ }
+ self.grid.move_node(node, x, y);
+ self._update_container_height();
+ },
+ containment: this.opts.is_nested ? this.container.parent() : null
+ })).resizable(_.extend(this.opts.resizable, {
+ start: on_start_moving,
+ stop: on_end_moving,
+ resize: function(event, ui) {
+ var x = Math.round(ui.position.left / cell_width),
+ y = Math.floor((ui.position.top + cell_height / 2) / cell_height),
+ width = Math.round(ui.size.width / cell_width),
+ height = Math.round(ui.size.height / cell_height);
+ if (!self.grid.can_move_node(node, x, y, width, height)) {
+ return;
+ }
+ self.grid.move_node(node, x, y, width, height);
+ self._update_container_height();
+ }
+ }));
+
+ if (node.no_move || this._is_one_column_mode()) {
+ el.draggable('disable');
+ }
+
+ if (node.no_resize || this._is_one_column_mode()) {
+ el.resizable('disable');
+ }
+
+ el.attr('data-gs-locked', node.locked ? 'yes' : null);
+ };
+
+ GridStack.prototype.set_animation = function(enable) {
+ if (enable) {
+ this.container.addClass('grid-stack-animate');
+ }
+ else {
+ this.container.removeClass('grid-stack-animate');
+ }
+ };
+
+ GridStack.prototype.add_widget = function(el, x, y, width, height, auto_position) {
+ el = $(el);
+ if (typeof x != 'undefined') el.attr('data-gs-x', x);
+ if (typeof y != 'undefined') el.attr('data-gs-y', y);
+ if (typeof width != 'undefined') el.attr('data-gs-width', width);
+ if (typeof height != 'undefined') el.attr('data-gs-height', height);
+ if (typeof auto_position != 'undefined') el.attr('data-gs-auto-position', auto_position ? 'yes' : null);
+ this.container.append(el);
+ this._prepare_element(el);
+ this._update_container_height();
+ this._trigger_change_event(true);
+
+ return el;
+ };
+
+ GridStack.prototype.will_it_fit = function(x, y, width, height, auto_position) {
+ var node = {x: x, y: y, width: width, height: height, auto_position: auto_position};
+ return this.grid.can_be_placed_with_respect_to_height(node);
+ };
+
+ GridStack.prototype.remove_widget = function(el, detach_node) {
+ detach_node = typeof detach_node === 'undefined' ? true : detach_node;
+ el = $(el);
+ var node = el.data('_gridstack_node');
+ this.grid.remove_node(node);
+ el.removeData('_gridstack_node');
+ this._update_container_height();
+ if (detach_node)
+ el.remove();
+ this._trigger_change_event(true);
+ };
+
+ GridStack.prototype.remove_all = function(detach_node) {
+ _.each(this.grid.nodes, function(node) {
+ this.remove_widget(node.el, detach_node);
+ }, this);
+ this.grid.nodes = [];
+ this._update_container_height();
+ };
+
+ GridStack.prototype.destroy = function() {
+ $(window).off("resize", this.on_resize_handler);
+ this.disable();
+ this.container.remove();
+ Utils.remove_stylesheet(this._styles_id);
+ if (this.grid)
+ this.grid = null;
+ };
+
+ GridStack.prototype.resizable = function(el, val) {
+ el = $(el);
+ el.each(function(index, el) {
+ el = $(el);
+ var node = el.data('_gridstack_node');
+ if (typeof node == 'undefined' || node == null) {
+ return;
+ }
+
+ node.no_resize = !(val || false);
+ if (node.no_resize) {
+ el.resizable('disable');
+ }
+ else {
+ el.resizable('enable');
+ }
+ });
+ return this;
+ };
+
+ GridStack.prototype.movable = function(el, val) {
+ el = $(el);
+ el.each(function(index, el) {
+ el = $(el);
+ var node = el.data('_gridstack_node');
+ if (typeof node == 'undefined' || node == null) {
+ return;
+ }
+
+ node.no_move = !(val || false);
+ if (node.no_move) {
+ el.draggable('disable');
+ }
+ else {
+ el.draggable('enable');
+ }
+ });
+ return this;
+ };
+
+ GridStack.prototype.disable = function() {
+ this.movable(this.container.children('.' + this.opts.item_class), false);
+ this.resizable(this.container.children('.' + this.opts.item_class), false);
+ };
+
+ GridStack.prototype.enable = function() {
+ this.movable(this.container.children('.' + this.opts.item_class), true);
+ this.resizable(this.container.children('.' + this.opts.item_class), true);
+ };
+
+ GridStack.prototype.locked = function(el, val) {
+ el = $(el);
+ el.each(function(index, el) {
+ el = $(el);
+ var node = el.data('_gridstack_node');
+ if (typeof node == 'undefined' || node == null) {
+ return;
+ }
+
+ node.locked = (val || false);
+ el.attr('data-gs-locked', node.locked ? 'yes' : null);
+ });
+ return this;
+ };
+
+ GridStack.prototype.min_height = function (el, val) {
+ el = $(el);
+ el.each(function (index, el) {
+ el = $(el);
+ var node = el.data('_gridstack_node');
+ if (typeof node == 'undefined' || node == null) {
+ return;
+ }
+
+ if(!isNaN(val)){
+ node.min_height = (val || false);
+ el.attr('data-gs-min-height', val);
+ }
+ });
+ return this;
+ };
+
+ GridStack.prototype.min_width = function (el, val) {
+ el = $(el);
+ el.each(function (index, el) {
+ el = $(el);
+ var node = el.data('_gridstack_node');
+ if (typeof node == 'undefined' || node == null) {
+ return;
+ }
+
+ if(!isNaN(val)){
+ node.min_width = (val || false);
+ el.attr('data-gs-min-width', val);
+ }
+ });
+ return this;
+ };
+
+ GridStack.prototype._update_element = function(el, callback) {
+ el = $(el).first();
+ var node = el.data('_gridstack_node');
+ if (typeof node == 'undefined' || node == null) {
+ return;
+ }
+
+ var self = this;
+
+ self.grid.clean_nodes();
+ self.grid.begin_update(node);
+
+ callback.call(this, el, node);
+
+ self._update_container_height();
+ self._trigger_change_event();
+
+ self.grid.end_update();
+ };
+
+ GridStack.prototype.resize = function(el, width, height) {
+ this._update_element(el, function(el, node) {
+ width = (width != null && typeof width != 'undefined') ? width : node.width;
+ height = (height != null && typeof height != 'undefined') ? height : node.height;
+
+ this.grid.move_node(node, node.x, node.y, width, height);
+ });
+ };
+
+ GridStack.prototype.move = function(el, x, y) {
+ this._update_element(el, function(el, node) {
+ x = (x != null && typeof x != 'undefined') ? x : node.x;
+ y = (y != null && typeof y != 'undefined') ? y : node.y;
+
+ this.grid.move_node(node, x, y, node.width, node.height);
+ });
+ };
+
+ GridStack.prototype.update = function(el, x, y, width, height) {
+ this._update_element(el, function(el, node) {
+ x = (x != null && typeof x != 'undefined') ? x : node.x;
+ y = (y != null && typeof y != 'undefined') ? y : node.y;
+ width = (width != null && typeof width != 'undefined') ? width : node.width;
+ height = (height != null && typeof height != 'undefined') ? height : node.height;
+
+ this.grid.move_node(node, x, y, width, height);
+ });
+ };
+
+ GridStack.prototype.cell_height = function(val) {
+ if (typeof val == 'undefined') {
+ return this.opts.cell_height;
+ }
+ val = parseInt(val);
+ if (val == this.opts.cell_height)
+ return;
+ this.opts.cell_height = val || this.opts.cell_height;
+ this._update_styles();
+ };
+
+ GridStack.prototype.cell_width = function() {
+ var o = this.container.children('.' + this.opts.item_class).first();
+ return Math.ceil(o.outerWidth() / o.attr('data-gs-width'));
+ };
+
+ GridStack.prototype.get_cell_from_pixel = function(position) {
+ var containerPos = this.container.position();
+ var relativeLeft = position.left - containerPos.left;
+ var relativeTop = position.top - containerPos.top;
+
+ var column_width = Math.floor(this.container.width() / this.opts.width);
+ var row_height = this.opts.cell_height + this.opts.vertical_margin;
+
+ return {x: Math.floor(relativeLeft / column_width), y: Math.floor(relativeTop / row_height)};
+ };
+
+ GridStack.prototype.batch_update = function() {
+ this.grid.batch_update();
+ };
+
+ GridStack.prototype.commit = function() {
+ this.grid.commit();
+ this._update_container_height();
+ };
+
+ GridStack.prototype.is_area_empty = function(x, y, width, height) {
+ return this.grid.is_area_empty(x, y, width, height);
+ };
+
+ GridStack.prototype.set_static = function(static_value) {
+ this.opts.static_grid = (static_value === true);
+ this._set_static_class();
+ };
+
+ GridStack.prototype._set_static_class = function() {
+ var static_class_name = 'grid-stack-static';
+
+ if (this.opts.static_grid === true) {
+ this.container.addClass(static_class_name);
+ } else {
+ this.container.removeClass(static_class_name);
+ }
+ };
+
+ scope.GridStackUI = GridStack;
+
+ scope.GridStackUI.Utils = Utils;
+
+ $.fn.gridstack = function(opts) {
+ return this.each(function() {
+ if (!$(this).data('gridstack')) {
+ $(this).data('gridstack', new GridStack(this, opts));
+ }
+ });
+ };
+
+ return scope.GridStackUI;
+});
Added: incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/html5shiv/html5shiv-printshiv.min.js
URL: http://svn.apache.org/viewvc/incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/html5shiv/html5shiv-printshiv.min.js?rev=1717687&view=auto
==============================================================================
--- incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/html5shiv/html5shiv-printshiv.min.js (added)
+++ incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/html5shiv/html5shiv-printshiv.min.js Wed Dec 2 21:29:53 2015
@@ -0,0 +1,4 @@
+/**
+* @preserve HTML5 Shiv 3.7.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
+*/
+!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=y.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=y.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),y.elements=c+" "+a,j(b)}function f(a){var b=x[a[v]];return b||(b={},w++,a[v]=w,x[w]=b),b}function g(a,c,d){if(c||(c=b),q)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():u.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||t.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),q)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag
()),a.createElement=function(c){return y.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(y,b.frag)}function j(a){a||(a=b);var d=f(a);return!y.shivCSS||p||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),q||i(a,d),a}function k(a){for(var b,c=a.getElementsByTagName("*"),e=c.length,f=RegExp("^(?:"+d().join("|")+")$","i"),g=[];e--;)b=c[e],f.test(b.nodeName)&&g.push(b.applyElement(l(b)));return g}function l(a){for(var b,c=a.attributes,d=c.length,e=a.ownerDocument.createElement(A+":"+a.nodeName);d--;)b=c[d],b.specified&&e.setAttribute(b.nodeName,b.nodeValue);return e.style.cssText=a.style.cssText,e}function m(a){for(var b,c=a.split("{"),e=c.le
ngth,f=RegExp("(^|[\\s,>+~])("+d().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),g="$1"+A+"\\:$2";e--;)b=c[e]=c[e].split("}"),b[b.length-1]=b[b.length-1].replace(f,g),c[e]=b.join("}");return c.join("{")}function n(a){for(var b=a.length;b--;)a[b].removeNode()}function o(a){function b(){clearTimeout(g._removeSheetTimer),d&&d.removeNode(!0),d=null}var d,e,g=f(a),h=a.namespaces,i=a.parentWindow;return!B||a.printShived?a:("undefined"==typeof h[A]&&h.add(A),i.attachEvent("onbeforeprint",function(){b();for(var f,g,h,i=a.styleSheets,j=[],l=i.length,n=Array(l);l--;)n[l]=i[l];for(;h=n.pop();)if(!h.disabled&&z.test(h.media)){try{f=h.imports,g=f.length}catch(o){g=0}for(l=0;g>l;l++)n.push(f[l]);try{j.push(h.cssText)}catch(o){}}j=m(j.reverse().join("")),e=k(a),d=c(a,j)}),i.attachEvent("onafterprint",function(){n(e),clearTimeout(g._removeSheetTimer),g._removeSheetTimer=setTimeout(b,500)}),a.printShived=!0,a)}var p,q,r="3.7.2",s=a.html5||{},t=/^<|^(?:button|map|select|textarea|object|iframe|option|optgrou
p)$/i,u=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,v="_html5shiv",w=0,x={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",p="hidden"in a,q=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){p=!0,q=!0}}();var y={elements:s.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:r,shivCSS:s.shivCSS!==!1,supportsUnknownElements:q,shivMethods:s.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=y,j(b);var z=/^$|\b(?:all|print)\b/,A="html5shiv",B=!q&&function(){var c=b.documentElement;return!("undefined"==typeof b.namespaces||"un
defined"==typeof b.parentWindow||"undefined"==typeof c.applyElement||"undefined"==typeof c.removeNode||"undefined"==typeof a.attachEvent)}();y.type+=" print",y.shivPrint=o,o(b)}(this,document);
\ No newline at end of file
Added: incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/html5shiv/html5shiv.min.js
URL: http://svn.apache.org/viewvc/incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/html5shiv/html5shiv.min.js?rev=1717687&view=auto
==============================================================================
--- incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/html5shiv/html5shiv.min.js (added)
+++ incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/html5shiv/html5shiv.min.js Wed Dec 2 21:29:53 2015
@@ -0,0 +1,4 @@
+/**
+* @preserve HTML5 Shiv 3.7.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
+*/
+!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag
()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.2",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"
==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b)}(this,document);
\ No newline at end of file
Added: incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/respond/respond.matchmedia.addListener.min.js
URL: http://svn.apache.org/viewvc/incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/respond/respond.matchmedia.addListener.min.js?rev=1717687&view=auto
==============================================================================
--- incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/respond/respond.matchmedia.addListener.min.js (added)
+++ incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/respond/respond.matchmedia.addListener.min.js Wed Dec 2 21:29:53 2015
@@ -0,0 +1,5 @@
+/*! Respond.js v1.4.2: min/max-width media query polyfill * Copyright 2013 Scott Jehl
+ * Licensed under https://github.com/scottjehl/Respond/blob/master/LICENSE-MIT
+ * */
+
+!function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='­<style media="'+a+'"> #mq-test-1 { width: 42px; }</style>',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";if(a.matchMedia&&a.matchMedia("all").addListener)return!1;var b=a.matchMedia,c=b("only all").matches,d=!1,e=0,f=[],g=function(){a.clearTimeout(e),e=a.setTimeout(function(){for(var c=0,d=f.length;d>c;c++){var e=f[c].mql,g=f[c].listeners||[],h=b(e.media).matches;if(h!==e.matches){e.matches=h;for(var i=0,j=g.length;j>i;i++)g[i].call(a,e)}}},30)};a.matchMedia=function(e){var h=b(e),i=[],j=0;return h.addListener=function(b){c&&(d||(d=!0,a.addEventListener("resize",g,!0)),0===j&&(j=f.pu
sh({mql:h,listeners:i})),i.push(b))},h.removeListener=function(a){for(var b=0,c=i.length;c>b;b++)i[b]===a&&i.splice(b,1)},h}}(this),function(a){"use strict";function b(){u(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))};if(c.ajax=f,c.queue=d,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,maxw:/\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/},c.mediaQueriesSupported=a.matchM
edia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var g,h,i,j=a.document,k=j.documentElement,l=[],m=[],n=[],o={},p=30,q=j.getElementsByTagName("head")[0]||k,r=j.getElementsByTagName("base")[0],s=q.getElementsByTagName("link"),t=function(){var a,b=j.createElement("div"),c=j.body,d=k.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=j.createElement("body"),c.style.background="none"),k.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&k.insertBefore(c,k.firstChild),a=b.offsetWidth,f?k.removeChild(c):c.removeChild(b),k.style.fontSize=d,e&&(c.style.fontSize=e),a=i=parseFloat(a)},u=function(b){var c="clientWidth",d=k[c],e="CSS1Compat"===j.compatMode&&d||j.body[c]||d,f={},o=s[s.length-1],r=(new Date).getTime();if(b&&g&&p>r-g)return a.clearTimeout(h),h=a.setTimeout(u,p),void 0;g=r;for(var v in l)if(l.hasOwnProperty(v)){var w=l[v],x=w.minw,y=w.maxw,z=null===x,A=n
ull===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?i||t():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?i||t():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(m[w.rules]))}for(var C in n)n.hasOwnProperty(C)&&n[C]&&n[C].parentNode===q&&q.removeChild(n[C]);n.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=j.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,q.insertBefore(E,o.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(j.createTextNode(F)),n.push(E)}},v=function(a,b,d){var e=a.replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var g=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},h=!f&&d;b.length&&(b+="/"),h&&(f=1);for(var i=0;f>i;i++){var j,k,n,o;h?(j=d,m.push(g(a))):(j=e[i].match(c.regex.findStyles)&&RegExp.$1,m.push(RegExp.$2&&g(RegExp.$2))),n=j.split(","),o=n.length;for(var p=0;o>p;p++)k=n[p],l.push({media:k.split("(")[0].match(c.regex.
only)&&RegExp.$2||"all",rules:m.length-1,hasquery:k.indexOf("(")>-1,minw:k.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:k.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}u()},w=function(){if(d.length){var b=d.shift();f(b.href,function(c){v(c,b.href,b.media),o[b.href]=!0,a.setTimeout(function(){w()},0)})}},x=function(){for(var b=0;b<s.length;b++){var c=s[b],e=c.href,f=c.media,g=c.rel&&"stylesheet"===c.rel.toLowerCase();e&&g&&!o[e]&&(c.styleSheet&&c.styleSheet.rawCssText?(v(c.styleSheet.rawCssText,e,f),o[e]=!0):(!/^([a-zA-Z:]*\/\/)/.test(e)&&!r||e.replace(RegExp.$1,"").split("/")[0]===a.location.host)&&("//"===e.substring(0,2)&&(e=a.location.protocol+e),d.push({href:e,media:f})))}w()};x(),c.update=x,c.getEmValue=t,a.addEventListener?a.addEventListener("resize",b,!1):a.attachEvent&&a.attachEvent("onresize",b)}}(this);
\ No newline at end of file
Added: incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/respond/respond.min.js
URL: http://svn.apache.org/viewvc/incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/respond/respond.min.js?rev=1717687&view=auto
==============================================================================
--- incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/respond/respond.min.js (added)
+++ incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/respond/respond.min.js Wed Dec 2 21:29:53 2015
@@ -0,0 +1,5 @@
+/*! Respond.js v1.4.2: min/max-width media query polyfill * Copyright 2013 Scott Jehl
+ * Licensed under https://github.com/scottjehl/Respond/blob/master/LICENSE-MIT
+ * */
+
+!function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='­<style media="'+a+'"> #mq-test-1 { width: 42px; }</style>',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){u(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))};if(c.ajax=f,c.queue=d,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:
o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,maxw:/\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var g,h,i,j=a.document,k=j.documentElement,l=[],m=[],n=[],o={},p=30,q=j.getElementsByTagName("head")[0]||k,r=j.getElementsByTagName("base")[0],s=q.getElementsByTagName("link"),t=function(){var a,b=j.createElement("div"),c=j.body,d=k.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=j.createElement("body"),c.style.background="none"),k.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&k.insertBefore(c,k.firstChild),a=b.offsetWidth,f?k.removeChild(c):c.removeC
hild(b),k.style.fontSize=d,e&&(c.style.fontSize=e),a=i=parseFloat(a)},u=function(b){var c="clientWidth",d=k[c],e="CSS1Compat"===j.compatMode&&d||j.body[c]||d,f={},o=s[s.length-1],r=(new Date).getTime();if(b&&g&&p>r-g)return a.clearTimeout(h),h=a.setTimeout(u,p),void 0;g=r;for(var v in l)if(l.hasOwnProperty(v)){var w=l[v],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?i||t():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?i||t():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(m[w.rules]))}for(var C in n)n.hasOwnProperty(C)&&n[C]&&n[C].parentNode===q&&q.removeChild(n[C]);n.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=j.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,q.insertBefore(E,o.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(j.createTextNode(F)),n.push(E)}},v=function(a,b,d){var e=a.replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substr
ing(0,b.lastIndexOf("/"));var g=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},h=!f&&d;b.length&&(b+="/"),h&&(f=1);for(var i=0;f>i;i++){var j,k,n,o;h?(j=d,m.push(g(a))):(j=e[i].match(c.regex.findStyles)&&RegExp.$1,m.push(RegExp.$2&&g(RegExp.$2))),n=j.split(","),o=n.length;for(var p=0;o>p;p++)k=n[p],l.push({media:k.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:m.length-1,hasquery:k.indexOf("(")>-1,minw:k.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:k.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}u()},w=function(){if(d.length){var b=d.shift();f(b.href,function(c){v(c,b.href,b.media),o[b.href]=!0,a.setTimeout(function(){w()},0)})}},x=function(){for(var b=0;b<s.length;b++){var c=s[b],e=c.href,f=c.media,g=c.rel&&"stylesheet"===c.rel.toLowerCase();e&&g&&!o[e]&&(c.styleSheet&&c.styleSheet.rawCssText?(v(c.styleSheet.rawCssText,e,f),o[e]=!0):(!/^([a-zA-Z:]*\/\/)/.test(e)&&!r||e.replace(RegExp.$1,"").split("/")[0]===a.location.host)&&("
//"===e.substring(0,2)&&(e=a.location.protocol+e),d.push({href:e,media:f})))}w()};x(),c.update=x,c.getEmValue=t,a.addEventListener?a.addEventListener("resize",b,!1):a.attachEvent&&a.attachEvent("onresize",b)}}(this);
\ No newline at end of file
Added: incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/slate/bootstrap.min.css
URL: http://svn.apache.org/viewvc/incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/slate/bootstrap.min.css?rev=1717687&view=auto
==============================================================================
--- incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/slate/bootstrap.min.css (added)
+++ incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/resources/META-INF/resources/dashboard/lib/slate/bootstrap.min.css Wed Dec 2 21:29:53 2015
@@ -0,0 +1,11 @@
+/*!
+ * bootswatch v3.3.5
+ * Homepage: http://bootswatch.com
+ * Copyright 2012-2015 Thomas Park
+ * Licensed under MIT
+ * Based on Bootstrap
+*//*!
+ * Bootstrap v3.3.5 (http://getbootstrap.com)
+ * Copyright 2011-2015 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
[... 3 lines stripped ...]
Added: incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/tomee/conf/tomee.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/tomee/conf/tomee.xml?rev=1717687&view=auto
==============================================================================
--- incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/tomee/conf/tomee.xml (added)
+++ incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/main/tomee/conf/tomee.xml Wed Dec 2 21:29:53 2015
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<tomee>
+ <Resource id="schedule" type="DataSource">
+ JdbcDriver = oracle.jdbc.OracleDriver
+ JdbcUrl = jdbc:oracle:thin:@gls-cert-wfc-db:15025:sbc02
+ UserName = glsscripts
+ Password = ndin6ildes
+ InitialSize = 2
+ MaxActive = 10
+ MaxIdle = 10
+ TestOnBorrow = false
+ ValidationQuery = SELECT 1 FROM DUAL
+ TimeBetweenEvictionRuns = 1 minutes
+ </Resource>
+</tomee>
Added: incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/test/java/org/apache/sirona/dashboard/lang/ExceptionsTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/test/java/org/apache/sirona/dashboard/lang/ExceptionsTest.java?rev=1717687&view=auto
==============================================================================
--- incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/test/java/org/apache/sirona/dashboard/lang/ExceptionsTest.java (added)
+++ incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/test/java/org/apache/sirona/dashboard/lang/ExceptionsTest.java Wed Dec 2 21:29:53 2015
@@ -0,0 +1,44 @@
+package org.apache.sirona.dashboard.lang;
+
+import org.junit.Test;
+
+import static org.apache.sirona.dashboard.lang.Exceptions.e;
+import static org.junit.Assert.assertEquals;
+
+public class ExceptionsTest {
+ @Test
+ public void ok() {
+ assertEquals("ok", e(() -> "ok").get().get());
+ }
+
+ @Test
+ public void okWithMapping() {
+ assertEquals("ok", e(() -> "ok").on(RuntimeException.class, () -> "fail").get().get());
+ }
+
+ @Test
+ public void okWithExceptionMapping() {
+ assertEquals("ok", e(() -> "ok").map(RuntimeException.class, () -> new IllegalStateException("oops")).get().get());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void rethrow() {
+ e(() -> {throw new IllegalArgumentException(); })
+ .map(RuntimeException.class, () -> new IllegalStateException("oops"))
+ .get().get();
+ }
+
+ @Test
+ public void koWithExceptionMappingHierarchy() {
+ assertEquals("caught",
+ e(() -> {throw new IllegalArgumentException(); })
+ .map(RuntimeException.class, () -> new IllegalStateException("oops"))
+ .on(IllegalArgumentException.class, () -> "caught")
+ .get().get());
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void ko() {
+ e(() -> {throw new IllegalArgumentException(); }).get().get();
+ }
+}
Added: incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/test/java/org/apache/sirona/dashboard/resource/DashboardResourceTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/test/java/org/apache/sirona/dashboard/resource/DashboardResourceTest.java?rev=1717687&view=auto
==============================================================================
--- incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/test/java/org/apache/sirona/dashboard/resource/DashboardResourceTest.java (added)
+++ incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/test/java/org/apache/sirona/dashboard/resource/DashboardResourceTest.java Wed Dec 2 21:29:53 2015
@@ -0,0 +1,373 @@
+package org.apache.sirona.dashboard.resource;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.johnzon.jaxrs.JohnzonProvider;
+import org.apache.openejb.jee.JaxbJavaee;
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.jee.jpa.unit.Persistence;
+import org.apache.openejb.junit.ApplicationComposerRule;
+import org.apache.openejb.loader.IO;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.JaxrsProviders;
+import org.apache.openejb.testing.Module;
+import org.apache.openejb.testing.RandomPort;
+import org.apache.openejb.testing.SimpleLog;
+import org.apache.sirona.dashboard.jpa.Dashboard;
+import org.apache.sirona.dashboard.jpa.DashboardItem;
+import org.apache.sirona.dashboard.plugin.api.Plugin;
+import org.apache.sirona.dashboard.plugin.api.PluginType;
+import org.apache.sirona.dashboard.plugin.api.Widget;
+import org.apache.sirona.dashboard.plugin.registry.DeclarativePluginRegistar;
+import org.apache.sirona.dashboard.plugin.registry.PluginRegistry;
+import org.apache.sirona.dashboard.provider.EJBExceptionUnwrapperExceptionMapper;
+import org.apache.sirona.dashboard.resource.domain.FullDashboard;
+import org.apache.sirona.dashboard.resource.service.DomainEntityConverter;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+import org.xml.sax.SAXException;
+
+import javax.annotation.Resource;
+import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
+import javax.persistence.PersistenceContext;
+import javax.transaction.UserTransaction;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.xml.bind.JAXBException;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import static java.util.Collections.singletonList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+@SimpleLog
+@EnableServices("jaxrs")
+public class DashboardResourceTest {
+ @Rule
+ public final TestRule container = new ApplicationComposerRule(this);
+
+ @RandomPort("http")
+ private URL base;
+
+ @Resource
+ private UserTransaction ut;
+
+ @PersistenceContext
+ private EntityManager em;
+
+ @Test
+ public void notFoundDashboard() throws IOException {
+ final Response response = WebClient.create(base.toExternalForm(), singletonList(new JohnzonProvider<>()))
+ .accept(MediaType.APPLICATION_JSON)
+ .path("dashboard/api/dashboard/my")
+ .get();
+ assertEquals(
+ IO.slurp(InputStream.class.cast(response.getEntity())),
+ Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void foundDashboard() throws Exception {
+ try {
+ inTx(() -> em.persist(createMy()));
+
+ final FullDashboard fullDashboard = WebClient.create(base.toExternalForm(), singletonList(new JohnzonProvider<>()))
+ .accept(MediaType.APPLICATION_JSON)
+ .path("dashboard/api/dashboard/my")
+ .get(FullDashboard.class);
+ assertNotNull(fullDashboard);
+ assertEquals("my", fullDashboard.getName());
+ assertNotNull(fullDashboard.getItems());
+ assertEquals(2, fullDashboard.getItems().size());
+
+ fullDashboard.getItems().forEach(item -> {
+ assertTrue(item.getId() > 0);
+ if (item.getX() == 1) {
+ assertEquals(item.getY(), 2);
+ assertEquals(item.getWidth(), 385);
+ assertEquals(item.getHeight(), 209);
+ } else if (item.getX() == 2) {
+ assertEquals(item.getY(), 4);
+ assertEquals(item.getWidth(), 102);
+ assertEquals(item.getHeight(), 654);
+ } else {
+ fail("Unknown " + item);
+ }
+ });
+ } finally {
+ inTx(() -> {
+ final Dashboard d = findMy();
+ d.getItems().forEach(i -> em.remove(i));
+ em.remove(d);
+ });
+ }
+ }
+
+ @Test
+ public void update() throws Exception {
+ final WebClient client = WebClient.create(base.toExternalForm(), singletonList(new JohnzonProvider<>()))
+ .accept(MediaType.APPLICATION_JSON)
+ .type(MediaType.APPLICATION_JSON)
+ .path("dashboard/api/dashboard/my");
+
+ try {
+ inTx(() -> em.persist(createMy()));
+ {
+ final FullDashboard fullDashboard = client.get(FullDashboard.class);
+
+ assertNotNull(fullDashboard);
+ assertEquals("my", fullDashboard.getName());
+ assertNotNull(fullDashboard.getItems());
+ assertEquals(2, fullDashboard.getItems().size());
+
+ fullDashboard.getItems().forEach(item -> {
+ assertTrue(item.getId() > 0);
+ if (item.getX() == 1) {
+ assertEquals(item.getY(), 2);
+ assertEquals(item.getWidth(), 385);
+ assertEquals(item.getHeight(), 209);
+ assertEquals("test", item.getType());
+ assertEquals("1 * 2 * 3 :)", item.getFormula());
+ } else if (item.getX() == 2) {
+ assertEquals(item.getY(), 4);
+ assertEquals(item.getWidth(), 102);
+ assertEquals(item.getHeight(), 654);
+ } else {
+ fail("Unknown " + item);
+ }
+ });
+ }
+
+ FullDashboard fullDashboard = new FullDashboard();
+ fullDashboard.setName("my");
+
+ // remove all items
+ {
+ client.put(fullDashboard, FullDashboard.class);
+ assertEquals(0, findMy().getItems().size());
+ }
+
+ // add item - part 1
+ long item1Id;
+ {
+ final FullDashboard.Item item = new FullDashboard.Item();
+ item.setX(1);
+ item.setY(2);
+ item.setWidth(3);
+ item.setHeight(4);
+ item.setType("type");
+ item.setFormula("form");
+
+ fullDashboard.setItems(new ArrayList<>(1));
+ fullDashboard.getItems().add(item);
+ fullDashboard = client.put(fullDashboard, FullDashboard.class);
+ assertEquals(">type(form)<", new ArrayList<>(fullDashboard.getItems()).get(0).getWidget().getHtml());
+ assertEquals("another javascript", new ArrayList<>(fullDashboard.getItems()).get(0).getWidget().getJs());
+
+ final Collection<DashboardItem> items = findMy().getItems();
+ assertEquals(1, items.size());
+ assertEquals(1, fullDashboard.getItems().size());
+
+ final DashboardItem di = items.iterator().next();
+ assertEquals(1, di.getX());
+ assertEquals(2, di.getY());
+ assertEquals(3, di.getWidth());
+ assertEquals(4, di.getHeight());
+ assertEquals("type", item.getType());
+ assertEquals("form", item.getFormula());
+
+ item1Id = di.getId();
+ assertTrue(item1Id > 0);
+ }
+
+ // add item - part 2 (half update, half new)
+ {
+ final FullDashboard.Item item = new FullDashboard.Item();
+ item.setX(21);
+ item.setY(22);
+ item.setWidth(23);
+ item.setHeight(24);
+ item.setFormula("1 * 2");
+ item.setType("t");
+ assertNull(item.getWidget());
+
+ fullDashboard.getItems().add(item);
+ fullDashboard = client.put(fullDashboard, FullDashboard.class);
+ assertEquals("t(1 * 2)", new ArrayList<>(fullDashboard.getItems()).get(1).getWidget().getHtml());
+
+ final Collection<DashboardItem> items = findMy().getItems();
+ assertEquals(2, items.size());
+ assertEquals(2, fullDashboard.getItems().size());
+
+ items.forEach(i -> {
+ if (i.getX() == 1) {
+ assertEquals(item1Id, i.getId());
+ assertEquals(2, i.getY());
+ assertEquals(3, i.getWidth());
+ assertEquals(4, i.getHeight());
+ assertEquals("type", i.getType());
+ assertEquals("form", i.getFormula());
+ } else if (i.getX() == 21) {
+ assertEquals(22, i.getY());
+ assertEquals(23, i.getWidth());
+ assertEquals(24, i.getHeight());
+ assertEquals("t", i.getType());
+ assertEquals("1 * 2", i.getFormula());
+ assertTrue(i.getId() > 0);
+ } else {
+ fail();
+ }
+ });
+ }
+
+ // update
+ {
+ final FullDashboard.Item next = fullDashboard.getItems().iterator().next();
+ next.setX(8);
+ client.put(fullDashboard, FullDashboard.class);
+ assertEquals(8, findMy().getItems().stream().filter(i -> i.getId() == next.getId()).findFirst().get().getX());
+ }
+ } finally {
+ inTx(() -> {
+ final Dashboard d = findMy();
+ d.getItems().forEach(i -> em.remove(i));
+ em.remove(d);
+ });
+ }
+ }
+
+ @Test
+ public void delete() throws Exception {
+
+ try {
+ inTx(() -> em.persist(createMy()));
+ assertEquals(
+ Response.Status.NO_CONTENT.getStatusCode(),
+ WebClient.create(base.toExternalForm(), singletonList(new JohnzonProvider<>()))
+ .accept(MediaType.APPLICATION_JSON)
+ .type(MediaType.APPLICATION_JSON)
+ .path("dashboard/api/dashboard/my").delete().getStatus());
+ try {
+ findMy();
+ fail();
+ } catch (final NoResultException nre) {
+ // ok
+ }
+ assertEquals(0, em.createQuery("select count(i) from DashboardItem i where i.dashboard.name = :name", Number.class).setParameter("name", "my").getSingleResult().intValue());
+ } finally {
+ inTx(() -> { // just in case something went wrong but shouldn't be needed
+ try {
+ final Dashboard d = findMy();
+ d.getItems().forEach(i -> em.remove(i));
+ em.remove(d);
+ } catch (final NoResultException nre) {
+ // ok
+ }
+ });
+ }
+ }
+
+ private Dashboard createMy() {
+ final Dashboard dashboard = new Dashboard();
+ dashboard.setName("my");
+ dashboard.setItems(new ArrayList<>());
+
+ {
+ final DashboardItem item = new DashboardItem();
+ item.setX(1);
+ item.setY(2);
+ item.setHeight(209);
+ item.setWidth(385);
+ item.setType("test");
+ item.setFormula("1 * 2 * 3 :)");
+ item.setDashboard(dashboard);
+ em.persist(item);
+ }
+
+ {
+ final DashboardItem item = new DashboardItem();
+ item.setX(2);
+ item.setY(4);
+ item.setHeight(654);
+ item.setWidth(102);
+ item.setDashboard(dashboard);
+ em.persist(item);
+ }
+ return dashboard;
+ }
+
+ private Dashboard findMy() {
+ return em.createNamedQuery(Dashboard.Queries.ByName.NAME, Dashboard.class)
+ .setParameter(Dashboard.Queries.ByName.Parameters.NAME, "my")
+ .getSingleResult();
+ }
+
+ private void inTx(final Runnable runnable) throws Exception {
+ ut.begin();
+ try {
+ runnable.run();
+ } finally {
+ ut.commit();
+ }
+ }
+
+ @Module
+ @JaxrsProviders({JohnzonProvider.class, EJBExceptionUnwrapperExceptionMapper.class})
+ @Classes(cdi = true, innerClassesAsBean = true, value = {
+ DasboardApplication.class, DashboardResource.class, DomainEntityConverter.class,
+ PluginRegistry.class, DeclarativePluginRegistar.class
+ })
+ public WebApp app() {
+ return new WebApp().contextRoot("dashboard");
+ }
+
+ @Module
+ public Persistence jpa() throws IOException, JAXBException, SAXException, ParserConfigurationException {
+ try (final InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/persistence.xml")) {
+ return Persistence.class.cast(JaxbJavaee.unmarshal(Persistence.class, in, false));
+ }
+ }
+
+ @PluginType("test")
+ public static class SimpleTestPlugin implements Plugin {
+ @Override
+ public Widget widgetFor(final String formula) {
+ final Widget w = new Widget();
+ w.setHtml("test(" + formula + ")");
+ w.setJs("js->test(" + formula + ")");
+ return w;
+ }
+ }
+
+ @PluginType("t")
+ public static class SimpleTPlugin implements Plugin {
+ @Override
+ public Widget widgetFor(final String formula) {
+ final Widget w = new Widget();
+ w.setHtml("t(" + formula + ")");
+ w.setJs("tjs");
+ return w;
+ }
+ }
+
+ @PluginType("type")
+ public static class SimpleTypePlugin implements Plugin {
+ @Override
+ public Widget widgetFor(final String formula) {
+ final Widget w = new Widget();
+ w.setHtml(">type(" + formula + ")<");
+ w.setJs("another javascript");
+ return w;
+ }
+ }
+}
Added: incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/test/java/org/apache/sirona/dashboard/resource/PluginResourceTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/test/java/org/apache/sirona/dashboard/resource/PluginResourceTest.java?rev=1717687&view=auto
==============================================================================
--- incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/test/java/org/apache/sirona/dashboard/resource/PluginResourceTest.java (added)
+++ incubator/sirona/dashboard/trunk/sirona-jquery-dashboard/src/test/java/org/apache/sirona/dashboard/resource/PluginResourceTest.java Wed Dec 2 21:29:53 2015
@@ -0,0 +1,105 @@
+package org.apache.sirona.dashboard.resource;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.johnzon.jaxrs.JohnzonProvider;
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposerRule;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.JaxrsProviders;
+import org.apache.openejb.testing.Module;
+import org.apache.openejb.testing.RandomPort;
+import org.apache.openejb.testing.SimpleLog;
+import org.apache.sirona.dashboard.plugin.api.DependsOnCss;
+import org.apache.sirona.dashboard.plugin.api.DependsOnJs;
+import org.apache.sirona.dashboard.plugin.api.Plugin;
+import org.apache.sirona.dashboard.plugin.api.PluginType;
+import org.apache.sirona.dashboard.plugin.api.Widget;
+import org.apache.sirona.dashboard.plugin.registry.DeclarativePluginRegistar;
+import org.apache.sirona.dashboard.plugin.registry.PluginRegistry;
+import org.apache.sirona.dashboard.resource.domain.Plugins;
+import org.apache.sirona.dashboard.resource.domain.Resources;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+
+import javax.ws.rs.core.MediaType;
+import java.net.URL;
+import java.util.HashSet;
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.singleton;
+import static java.util.Collections.singletonList;
+import static org.junit.Assert.assertEquals;
+
+@SimpleLog
+@EnableServices("jaxrs")
+public class PluginResourceTest {
+ @Rule
+ public final TestRule container = new ApplicationComposerRule(this);
+
+ @RandomPort("http")
+ private URL base;
+
+ @Module
+ @JaxrsProviders(JohnzonProvider.class)
+ @Classes(cdi = true, innerClassesAsBean = true, value = { PluginRegistry.class, PluginResource.class, DeclarativePluginRegistar.class })
+ public WebApp app() {
+ return new WebApp().contextRoot("dashboard");
+ }
+
+ @Test
+ public void types() {
+ assertEquals(
+ new HashSet<>(asList("type", "test")),
+ new HashSet<>(WebClient.create(base.toExternalForm(), singletonList(new JohnzonProvider<>()))
+ .path("dashboard/plugin/types")
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .get(Plugins.class).getTypes()));
+ }
+
+ @Test
+ public void css() {
+ assertEquals(
+ new HashSet<>(asList("mycss.css", "another.css")),
+ new HashSet<>(WebClient.create(base.toExternalForm(), singletonList(new JohnzonProvider<>()))
+ .path("dashboard/plugin/css")
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .get(Resources.class).getResources()));
+ }
+
+ @Test
+ public void js() {
+ assertEquals(
+ singleton("myJs.js"),
+ new HashSet<>(WebClient.create(base.toExternalForm(), singletonList(new JohnzonProvider<>()))
+ .path("dashboard/plugin/js")
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .get(Resources.class).getResources()));
+ }
+
+ @DependsOnCss("mycss.css")
+ @PluginType("test")
+ public static class SimpleTestPlugin implements Plugin {
+ @Override
+ public Widget widgetFor(final String formula) {
+ final Widget w = new Widget();
+ w.setHtml("test(" + formula + ")");
+ w.setJs("js->test(" + formula + ")");
+ return w;
+ }
+ }
+
+ @DependsOnCss("another.css")
+ @DependsOnJs("myJs.js")
+ @PluginType("type")
+ public static class SimpleTypePlugin implements Plugin {
+ @Override
+ public Widget widgetFor(final String formula) {
+ final Widget w = new Widget();
+ w.setHtml(">type(" + formula + ")<");
+ w.setJs("some js");
+ return w;
+ }
+ }
+}