From 1aae507cd7cb8efc512e93e3f899ae882ba109c8 Mon Sep 17 00:00:00 2001 From: David Alexa Date: Tue, 23 Aug 2016 11:35:22 +0200 Subject: [PATCH 01/24] add missing bower dependencies --- .../angular-history/history.js | 1525 +++++++++++++++++ .../angular-route/angular-route.min.js | 15 + 2 files changed, 1540 insertions(+) create mode 100644 src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/bower_components/angular-history/history.js create mode 100644 src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/bower_components/angular-route/angular-route.min.js diff --git a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/bower_components/angular-history/history.js b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/bower_components/angular-history/history.js new file mode 100644 index 00000000..82440ca4 --- /dev/null +++ b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/bower_components/angular-history/history.js @@ -0,0 +1,1525 @@ +/*global angular*/ + +/** + * @ngdoc overview + * @name decipher.history + * @description + * A history service for AngularJS. Undo/redo, that sort of thing. Has nothing to do with the "back" button, unless you want it to. + * + */ +(function () { + 'use strict'; + + var DEEPWATCH_EXP = /^\s*(.*?)\s+for\s+(?:([\$\w][\$\w\d]*)|(?:\(\s*([\$\w][\$\w\d]*)\s*,\s*([\$\w][\$\w\d]*)\s*\)))\s+in\s+(.*?)$/, + DEFAULT_TIMEOUT = 1000, + lazyBindFound = false, + isDefined = angular.isDefined, + isUndefined = angular.isUndefined, + isFunction = angular.isFunction, + isArray = angular.isArray, + isString = angular.isString, + isObject = angular.isObject, + forEach = angular.forEach, + copy = angular.copy, + bind = angular.bind; + + /** + * Polyfill for Object.keys + * + * @see: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys + */ + if (!Object.keys) { + Object.keys = (function () { + var hasOwnProperty = Object.prototype.hasOwnProperty, + hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'), + dontEnums = [ + 'toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'constructor' + ], + dontEnumsLength = dontEnums.length; + + return function (obj) { + if (typeof obj !== 'object' && typeof obj !== 'function' || + obj === null) { + throw new TypeError('Object.keys called on non-object'); + } + + var result = []; + + for (var prop in obj) { + if (hasOwnProperty.call(obj, prop)) { + result.push(prop); + } + } + + if (hasDontEnumBug) { + for (var i = 0; i < dontEnumsLength; i++) { + if (hasOwnProperty.call(obj, + dontEnums[i])) { + result.push(dontEnums[i]); + } + } + } + return result; + }; + })(); + } + + // stub out lazyBind if we don't have it. + try { + angular.module('lazyBind'); + lazyBindFound = true; + } + catch (e) { + angular.module('lazyBind', []).factory('$lazyBind', function() {return angular.noop}); + } + + /** + * @ngdoc service + * @name decipher.history.service:History + * @description + * Provides an API for keeping a history of model values. + */ + angular.module('decipher.history', ['lazyBind']).service('History', + [ + '$parse', + '$rootScope', + '$interpolate', + '$lazyBind', + '$timeout', + '$log', + '$injector', + function ($parse, $rootScope, $interpolate, $lazyBind, $timeout, $log, + $injector) { + var service = this, + history = {}, + pointers = {}, + watches = {}, + watchObjs = {}, + lazyWatches = {}, + descriptions = {}, + // TODO: async safe? + batching = false, // whether or not we are currently in a batch + deepWatchId = 0; // incrementing ID of deep {@link decipher.history.object:Watch Watch instance}s + + /** + * @ngdoc object + * @name decipher.history.object:Watch + * @overview + * @constructor + * @description + * An object instance that provides several methods for executing handlers after + * certain changes have been made. + * + * Each function return the `Watch` instance, so you can chain the calls. + * + * See the docs for {@link decipher.history.service:History#deepWatch History.deepWatch()} for an example of using these functions. + * + * @todo ability to remove all handlers at once, or all handlers of a certain type + */ + var Watch = function Watch(exp, scope) { + this.exp = exp; + this.scope = scope || $rootScope; + + this.$handlers = { + $change : {}, + $undo : {}, + $rollback : {}, + $redo : {}, + $revert : {}, + }; + + this.$ignores = {}; + }; + + /** + * @description + * Helper method for the add*Handler functions. + * @param {string} where Type of handler, corresponds to object defined in constructor + * @param {string} name Name of handler to be supplied by user + * @param {Function} fn Handler function to execute + * @param {Object} resolve Mapping of function parameters to values + * @private + * @returns {Watch} This {@link decipher.history.object:Watch Watch instance} + */ + Watch.prototype._addHandler = + function _addHandler(where, name, fn, resolve) { + if (!where || !name || !fn) { + throw new Error('invalid parameters to _addHandler()'); + } + this.$handlers[where][name] = { + fn: fn, + resolve: resolve || {} + }; + return this; + }; + + /** + * @description + * Helper method for remove*Handler functions. + * @param {string} where Type of handler, corresponds to object defined in constructor + * @param {string} name Name of handler to be supplied by user + * @private + * @returns {Watch} This {@link decipher.history.object:Watch Watch instance} + */ + Watch.prototype._removeHandler = function (where, name) { + if (!name) { + throw new Error('invalid parameters to _removeHandler()'); + } + delete this.$handlers[where][name]; + return this; + }; + + /** + * @ngdoc function + * @name decipher.history.object:Watch#addChangeHandler + * @methodOf decipher.history.object:Watch + * @method + * @param {string} name Unique name of handler + * @param {Function} fn Function to execute upon change + * @param {object} resolve Mapping of function parameters to values + * @description + * Adds a change handler function with name `name` to be executed + * whenever a value matching this watch's expression changes (is archived). + * @returns {Watch} This {@link decipher.history.object:Watch Watch instance} + */ + Watch.prototype.addChangeHandler = + function addChangeHandler(name, fn, resolve) { + if (!name || !fn) { + throw new Error('invalid parameters'); + } + return this._addHandler('$change', name, fn, resolve); + }; + /** + * @ngdoc function + * @name decipher.history.object:Watch#addUndoHandler + * @methodOf decipher.history.object:Watch + * @method + * @param {string} name Unique name of handler + * @param {Function} fn Function to execute upon change + * @param {object} resolve Mapping of function parameters to values + * @description + * Adds an undo handler function with name `name` to be executed + * whenever a value matching this watch's expression is undone. + * @returns {Watch} This {@link decipher.history.object:Watch Watch instance} + */ + Watch.prototype.addUndoHandler = + function addUndoHandler(name, fn, resolve) { + if (!name || !fn) { + throw new Error('invalid parameters'); + } + return this._addHandler('$undo', name, fn, resolve); + }; + /** + * @ngdoc function + * @name decipher.history.object:Watch#addRedoHandler + * @methodOf decipher.history.object:Watch + * @method + * @param {string} name Unique name of handler + * @param {Function} fn Function to execute upon change + * @param {object} resolve Mapping of function parameters to values + * @description + * Adds a redo handler function with name `name` to be executed + * whenever a value matching this watch's expression is redone. + * @returns {Watch} This {@link decipher.history.object:Watch Watch instance} + */ + Watch.prototype.addRedoHandler = + function addRedoHandler(name, fn, resolve) { + if (!name || !fn) { + throw new Error('invalid parameters'); + } + return this._addHandler('$redo', name, fn, resolve); + }; + /** + * @ngdoc function + * @name decipher.history.object:Watch#addRevertHandler + * @methodOf decipher.history.object:Watch + * @method + * @param {string} name Unique name of handler + * @param {Function} fn Function to execute upon change + * @param {object} resolve Mapping of function parameters to values + * @description + * Adds a revert handler function with name `name` to be executed + * whenever a value matching this watch's expression is reverted. + * @returns {Watch} This {@link decipher.history.object:Watch Watch instance} + */ + Watch.prototype.addRevertHandler = + function addRevertHandler(name, fn, resolve) { + if (!name || !fn) { + throw new Error('invalid parameters'); + } + return this._addHandler('$revert', name, fn, resolve); + }; + /** + * @ngdoc function + * @name decipher.history.object:Watch#addRollbackHandler + * @methodOf decipher.history.object:Watch + * @method + * @param {string} name Unique name of handler + * @param {Function} fn Function to execute upon change + * @param {object} resolve Mapping of function parameters to values + * @description + * Adds a rollback handler function with name `name` to be executed + * whenever the batch tied to this watch is rolled back. + * @returns {Watch} This {@link decipher.history.object:Watch Watch instance} + */ + Watch.prototype.addRollbackHandler = + function addRollbackHandler(name, fn, resolve) { + if (!name || !fn) { + throw new Error('invalid parameters'); + } + return this._addHandler('$rollback', name, fn, resolve); + }; + + /** + * @ngdoc function + * @name decipher.history.object:Watch#removeRevertHandler + * @methodOf decipher.history.object:Watch + * @method + * @param {string} name Name of handler to remove + * @returns {Watch} This {@link decipher.history.object:Watch Watch instance} + * @description + * Removes a revert handler with name `name`. + */ + Watch.prototype.removeRevertHandler = function removeRevertHandler(name) { + if (!name) { + throw new Error('invalid parameters'); + } + return this._removeHandler('$revert', name); + }; + /** + * @ngdoc function + * @name decipher.history.object:Watch#removeChangeHandler + * @methodOf decipher.history.object:Watch + * @method + * @param {string} name Name of handler to remove + * @returns {Watch} This {@link decipher.history.object:Watch Watch instance} + * @description + * Removes a change handler with name `name`. + */ + Watch.prototype.removeChangeHandler = function removeChangeHandler(name) { + if (!name) { + throw new Error('invalid parameters'); + } + return this._removeHandler('$change', name); + }; + /** + * @ngdoc function + * @name decipher.history.object:Watch#removeUndoHandler + * @methodOf decipher.history.object:Watch + * @method + * @param {string} name Name of handler to remove + * @returns {Watch} This {@link decipher.history.object:Watch Watch instance} + * @description + * Removes a undo handler with name `name`. + */ + Watch.prototype.removeUndoHandler = function removeUndoHandler(name) { + if (!name) { + throw new Error('invalid parameters'); + } + return this._removeHandler('$undo', name); + }; + + /** + * @ngdoc function + * @name decipher.history.object:Watch#removeRollbackHandler + * @methodOf decipher.history.object:Watch + * @method + * @param {string} name Name of handler to remove + * @returns {Watch} This {@link decipher.history.object:Watch Watch instance} + * @description + * Removes a rollback handler with name `name`. + */ + Watch.prototype.removeRollbackHandler = + function removeRollbackHandler(name) { + return this._removeHandler('$rollback', name); + }; + + /** + * @ngdoc function + * @name decipher.history.object:Watch#removeRedoHandler + * @methodOf decipher.history.object:Watch + * @method + * @param {string} name Name of handler to remove + * @returns {Watch} This {@link decipher.history.object:Watch Watch instance} + * @description + * Removes a redo handler with name `name`. + */ + Watch.prototype.removeRedoHandler = + function removeRedoHandler(name) { + if (!name) { + throw new Error('invalid parameters'); + } + return this._removeHandler('$redo', name); + }; + + /** + * Fires all handlers for a particular type, optionally w/ a scope. + * @param {string} where Watch type + * @param {string} exp Expression + * @param {Scope} [scope] Optional Scope + * @private + */ + Watch.prototype._fireHandlers = + function _fireHandlers(where, exp, scope) { + var hasScope = isDefined(scope), + localScope = this.scope, that = this; + forEach(this.$handlers[where], function (handler) { + var locals = { + $locals: localScope + }; + if (isDefined(scope)) { + locals.$locals = scope; + } + if (isDefined(exp)) { + locals.$expression = exp; + } + forEach(handler.resolve, function (value, key) { + if (hasScope) { + locals[key] = $parse(value)(scope); + } else { + locals[key] = value; + } + }); + $injector.invoke(handler.fn, scope || that, locals); + }); + }; + + /** + * Fires the change handlers + * @param {Scope} scope Scope + * @param {string} exp Expression + * @private + */ + Watch.prototype._fireChangeHandlers = + function _fireChangeHandlers(exp, scope) { + this._fireHandlers('$change', exp, scope); + }; + + /** + * Fires the undo handlers + * @param {Scope} scope Scope + * @param {string} exp Expression + * @private + */ + Watch.prototype._fireUndoHandlers = + function _fireUndoHandlers(exp, scope) { + this._fireHandlers('$undo', exp, scope); + }; + + /** + * Fires the redo handlers + * @param {Scope} scope Scope + * @param {string} exp Expression + * @private + */ + Watch.prototype._fireRedoHandlers = + function _fireRedoHandlers(exp, scope) { + this._fireHandlers('$redo', exp, scope); + }; + + /** + * Fires the revert handlers + * @param {Scope} scope Scope + * @param {string} exp Expression + * @private + */ + Watch.prototype._fireRevertHandlers = + function _fireRevertHandlers(exp, scope) { + this._fireHandlers('$revert', exp, scope); + }; + + /** + * Fires the rollback handlers (note lack of scope and expression) + * @private + */ + Watch.prototype._fireRollbackHandlers = + function _fireRollbackHandlers() { + this._fireHandlers('$rollback'); + }; + + /** + * Decline to broadcast an event for this Watch. + * @param {string} eventName Name of event to avoid. i.e. "History.archived" + * @param {Function=} callback Optional callback + * @param {Object=} resolve Optional mapping of parameters to invoke + * the callback with. + * @returns {Watch} this Watch object + */ + Watch.prototype.ignoreEvent = + function ignoreEvent(eventName, callback, resolve) { + // special case; we cannot ignore History.archived within a Watch obj + // created from a batch. there may be a way around this. + if (this.exp === null && eventName === 'History.archived') { + $log.warn('cannot ignore History.archived event for batch'); + return this; + } + resolve = resolve || {}; + if (isFunction(callback)) { + this.$ignores[eventName] = { + callback: callback, + resolve: resolve + }; + } else if (isDefined(callback)) { + this.$ignores[eventName] = { + callback: function cb() { + return callback; + }, + resolve: resolve + }; + } + return this; + }; + + /** + * Broadcasts an event, taking ignored events into account. + * @param {string} eventName Event to broadcast + * @param {*} data Some data to pass + * @private + */ + Watch.prototype._broadcast = function _broadcast(eventName, data) { + var ignore = this.$ignores[eventName]; + if (!ignore || + (isFunction(ignore.callback) && + !$injector.invoke(ignore.callback, this.scope, angular.extend(ignore.resolve, {$data: data})))) { + $rootScope.$broadcast(eventName, data); + } + }; + + /** + * Undoes last change against this watch object's target. + */ + Watch.prototype.undo = function undo() { + if (this.exp === null) { + $log.warn("attempt to undo a batch; use rollback() instead"); + return; + } + service.undo(this.exp, this.scope); + }; + + /** + * Redoes last undo against this watch object's target. + */ + Watch.prototype.redo = function redo() { + if (this.exp === null) { + $log.warn("attempt to redo a batch; just execute the batch callback again"); + } + service.redo(this.exp, this.scope); + }; + + /** + * Reverts this target's watch object. + * @param {number=0} pointer Pointer to revert to + */ + Watch.prototype.revert = function revert(pointer) { + if (this.exp === null) { + $log.warn("attempt to revert a batch; use rollback() instead"); + } + service.revert(this.exp, this.scope, pointer); + }; + + /** + * Whether or not you may undo this watch object's target + * @returns {boolean} + */ + Watch.prototype.canUndo = function canUndo() { + return this.exp === null ? false : + service.canUndo(this.exp, this.scope); + }; + + /** + * Whether or not you may redo this watch object's target + * @returns {boolean} + */ + Watch.prototype.canRedo = function canRedo() { + return this.exp === null ? false : + service.canRedo(this.exp, this.scope); + }; + + /** + * Evaluates an expression on the scope lazily. That means it will return + * a new value every DEFAULT_TIMEOUT ms at maximum, even if you change it between + * now and then. This allows us to $broadcast at an interval instead of after + * every scope change. + * @param {Object} scope AngularJS Scope + * @param {string} exp AngularJS expression to evaluate + * @param {number} [timeout=DEFAULT_TIMEOUT] How often to change the value + * @returns {Function} + */ + var lazyWatch = function lazyWatch(scope, exp, timeout) { + var bind = $lazyBind(scope); + bind.cacheTime(timeout || DEFAULT_TIMEOUT); + + /** + * This is the "expression function" we use to $watch with. You normally + * $watch a string, but you can also watch a function, and this is one of + * those functions. This is where the actual lazy evaluation happens. + */ + return function () { + return bind.call(scope, exp); + }; + }; + + /** + * Initializes object stores for a Scope id + * @param {string} id Sccope id + * @private + */ + this._initStores = function _initStores(id) { + if (isUndefined(watches[id])) { + watches[id] = {}; + } + if (isUndefined(lazyWatches[id])) { + lazyWatches[id] = {}; + } + if (isUndefined(descriptions[id])) { + descriptions[id] = {}; + } + if (isUndefined(history[id])) { + history[id] = {}; + } + if (isUndefined(watchObjs[id])) { + watchObjs[id] = {}; + } + if (isUndefined(pointers[id])) { + pointers[id] = {}; + } + }; + + /** + * When an expression changes, store the information about it + * and increment a pointer. + * @param {string|Function} exp Expression + * @param {string} id Scope $id + * @param {Scope} locals AngularJS scope + * @param {boolean} pass Whether or not to pass on the first call + * @param {string} description AngularJS string to interpolate + * @return {Function} Watch function + * @private + */ + this._archive = function (exp, id, locals, pass, description) { + var _initStores = this._initStores; + return function (newVal, oldVal) { + var watchObj; + _initStores(id); + if (description) { + descriptions[id][exp] = $interpolate(description)(locals); + } + if (pass) { + pass = false; + return; + } + if (isUndefined(history[id][exp])) { + history[id][exp] = []; + } + if (isUndefined(pointers[id][exp])) { + pointers[id][exp] = 0; + } + history[id][exp].splice(pointers[id][exp] + 1); + history[id][exp].push(copy(newVal)); + pointers[id][exp] = history[id][exp].length - 1; + if (pointers[id][exp] > 0 && isDefined(watchObjs[id]) && + isDefined(watchObj = watchObjs[id][exp])) { + if (!batching) { + watchObj._fireChangeHandlers(exp, locals); + } + watchObj._broadcast('History.archived', { + expression: exp, + newValue: newVal, + oldValue: oldVal, + description: descriptions[id][exp], + locals: locals + }); + } + }; + }; + + /** + * @ngdoc function + * @name decipher.history.service:History#watch + * @method + * @methodOf decipher.history.service:History + * @description + * Register some expression(s) for watching. + * @param {string|string[]} exps Array of expressions or one expression as a string + * @param {Scope=} scope Scope; defaults to `$rootScope` + * @param {string=} description Description of this change + * @param {Object=} lazyOptions Options for lazy loading. Only valid + * property is `timeout` at this point + * @returns {Watch|Array} {@link decipher.history.object:Watch Watch instance} or array of them + * + * @example + * + + + angular.module('decipher.history') + .run(function(History, $rootScope) { + $rootScope.foo = 'foo'; + + $rootScope.$on('History.archived', function(evt, data) { + $rootScope.message = data.description; + }); + + History.watch('foo', $rootScope, 'you changed the foo'); + }); + + + {{foo}}
+ {{message}}
+
+
+ */ + this.watch = function watch(exps, scope, description, lazyOptions) { + if (isUndefined(exps)) { + throw new Error('expression required'); + } + scope = scope || $rootScope; + description = description || ''; + var i, + id = scope.$id, + exp, + objs = [], + watchObj, + model; + + if (!isArray(exps)) { + exps = [exps]; + } + + this._initStores(id); + + i = exps.length; + while (i--) { + exp = exps[i]; + + // assert we have an assignable model + model = $parse(exp); + if (isUndefined(model.assign)) { + throw 'expression "' + exp + + '" is not an assignable expression'; + } + + // blast any old watches + if (isFunction(watches[id][exp])) { + watches[id][exp](); + } + + descriptions[id][exp] = $interpolate(description)(scope); + + this._watch(exp, scope, false, lazyOptions); + watchObjs[id][exp] = watchObj = new Watch(exp, scope); + objs.push(watchObj); + } + + return objs.length > 1 ? objs : objs[0]; + }; + + /** + * @ngdoc function + * @name decipher.history.service:History#deepWatch + * @method + * @methodOf decipher.history.service:History + * @description + * Allows you to watch an entire array/object full of objects, but only watch + * a certain property of each object. + * + * @example + * + + angular.module('decipher.history') + .run(function(History, $rootScope) { + var exp, locals; + + $rootScope.foos = [ + {id: 1, name: 'herp'}, + {id: 2, name: 'derp'} + ]; + + $rootScope.$on('History.archived', function(evt, data) { + $rootScope.message = data.description; + exp = data.expression; + locals = data.locals; + }) + + History.deepWatch('foo.name for foo in foos', $rootScope, + 'Changed {{foo.id}} to name "{{foo.name}}"') + .addChangeHandler('myChangeHandler', function($expression, + $locals, foo) { + console.log(foo); + console.log("(totally hit the server and update the model)"); + $rootScope.undo = function() { + History.undo($expression, $locals); + }; + $rootScope.canUndo = function() { + return History.canUndo($expression, $locals); + }; + }, {foo: 'foo'}); + }); + + + {{foos[0].name}}
+ {{message}}
+ +
+
+ * @param {(string|string[])} exp Expression or array of expressions to watch + * @param {Scope=} scope Scope; defaults to `$rootScope` + * @param {string=} description Description of this change + * @param {Object=} lazyOptions Options for lazy loading. Only valid + * property is `timeout` at this point + * @return {Watch} {@link decipher.history.object:Watch Watch instance} + */ + this.deepWatch = + function deepWatch(exp, scope, description, lazyOptions) { + var match, + targetName, + valueFn, + keyName, + value, + valueName, + valuesName, + watchObj, + id = scope.$id, + _clear = bind(this, this._clear), + _initStores = this._initStores, + _archive = bind(this, this._archive), + createDeepWatch = function createDeepWatch(targetName, valueName, + keyName, watchObj) { + return function (values) { + forEach(values, function (v, k) { + + var locals = scope.$new(), + id = locals.$id; + locals.$$deepWatchId = scope.$$deepWatch[targetName]; + locals.$$deepWatchTargetName = targetName; + locals[valueName] = v; + if (keyName) { + locals[keyName] = k; + } + value = valueFn(scope, locals); + + _initStores(id); + + descriptions[id][exp] = $interpolate(description)(locals); + + if (isFunction(watches[id][targetName])) { + watches[id][targetName](); + } + + if (lazyBindFound && isObject(lazyOptions)) { + watches[id][targetName] = + locals.$watch(lazyWatch(locals, targetName, + lazyOptions.timeout || 500), + _archive(targetName, id, locals, false, description), + true); + lazyWatches[id][targetName] = true; + } + else { + watches[id][targetName] = locals.$watch(targetName, + _archive(targetName, id, locals, false, description), + true); + lazyWatches[id][targetName] = false; + } + + watchObjs[id][targetName] = watchObj; + + locals.$on('$destroy', function () { + _clear(scope); + }); + + }); + + }; + }; + + description = description || ''; + if (!(match = exp.match(DEEPWATCH_EXP))) { + throw 'expected expression in form of "_select_ for (_key_,)? _value_ in _collection_" but got "' + + exp + '"'; + } + targetName = match[1]; + valueName = match[4] || match[2]; + valueFn = $parse(valueName); + keyName = match[3]; + valuesName = match[5]; + + if (isUndefined(scope.$$deepWatch)) { + scope.$$deepWatch = {}; + } + + // if we already have a deepWatch on this value, we + // need to kill all the child scopes. because reasons + if (isDefined(scope.$$deepWatch[targetName])) { + _clear(scope, targetName); + } + scope.$$deepWatch[targetName] = ++deepWatchId; + + _initStores(id); + watchObjs[id][targetName] = watchObj = new Watch(targetName, scope); + + // TODO: assert this doesn't leak memory like crazy. it might if + // we remove things from the values context. + watches[id][targetName] = scope.$watchCollection(valuesName, + createDeepWatch(targetName, valueName, keyName, + watchObj)); + + return watchObj; + }; + + /** + * Clears a bunch of information for a scope and optionally an array of expressions. + * Lacking an expression, this will eliminate an entire scopesworth of data. + * It will recognize deep watches and clear them out completely. + * @param {Scope} scope Scope obj + * @param {(string|string[])} exps Expression or array of expressions + * @private + */ + this._clear = function _clear(scope, exps) { + var id = scope.$id, + i, + nextSibling, + exp, + clear = function clear(id, key) { + var zap = function zap(what) { + if (isDefined(what[id][key])) { + delete what[id][key]; + if (Object.keys(what[id]).length === 0) { + delete what[id]; + } + } + }; + + if (isDefined(watches[id]) && + isFunction(watches[id][key])) { + watches[id][key](); + } + if (isDefined(watches[id])) { + zap(watches); + } + if (isDefined(watchObjs[id])) { + zap(watchObjs); + } + if (isDefined(history[id])) { + zap(history); + } + if (isDefined(pointers[id])) { + zap(pointers); + } + if (isDefined(lazyWatches[id])) { + zap(lazyWatches); + } + }, + + clearAll = function clearAll(id) { + forEach(watches[id], function (watch) { + return isFunction(watch) && watch(); + }); + delete watches[id]; + delete history[id]; + delete pointers[id]; + delete lazyWatches[id]; + delete watchObjs[id]; + }; + + if (isString(exps)) { + exps = [exps]; + } + else if (isUndefined(exps) && isDefined(watches[id])) { + exps = Object.keys(watches[id]); + } + + if (isDefined(exps)) { + i = exps.length; + while (i--) { + exp = exps[i]; + clear(id, exp); + } + } else { + clearAll(id); + } + nextSibling = scope.$$childHead; + while (nextSibling) { + this._clear(nextSibling, exp); + nextSibling = nextSibling.$$nextSibling; + } + }; + + + /** + * @ngdoc function + * @name decipher.history.service:History#forget + * @method + * @methodOf decipher.history.service:History + * @description + * Unregister some watched expression(s). + * @param {(string|string[])} exps Array of expressions or one expression as a string + * @param {Scope=} scope Scope object; defaults to $rootScope + */ + this.forget = function forget(scope, exps) { + scope = scope || $rootScope; + if (isDefined(exps) && isString(exps)) { + exps = [exps]; + } + this._clear(scope, exps); + }; + + /** + * Internal function to change some value in the stack to another. + * Kills the watch and then calls `_watch()` to restore it. + * @param {Scope} scope Scope object + * @param {string} exp AngularJS expression + * @param {array} stack History stack; see `History.history` + * @param {number} pointer Pointer + * @returns {{oldValue: {*}, newValue: {*}}} The old value and the new value + * @private + */ + this._do = function _do(scope, exp, stack, pointer) { + var model, + oldValue, + id = scope.$id; + if (isFunction(watches[id][exp])) { + watches[id][exp](); + delete watches[id][exp]; + } + model = $parse(exp); + oldValue = model(scope); + // todo: assert there's no bug here with unassignable expressions + model.assign(scope, copy(stack[pointer])); + this._watch(exp, scope, true); + return { + oldValue: oldValue, + newValue: model(scope) + }; + }; + + /** + * @ngdoc function + * @name decipher.history.service:History#undo + * @method + * @methodOf decipher.history.service:History + * @description + * Undos an expression to last known value. + * @param {string} exp Expression to undo + * @param {Scope=} scope Scope; defaults to `$rootScope` + */ + this.undo = function undo(exp, scope) { + scope = scope || $rootScope; + if (isUndefined(exp)) { + throw new Error('expression required'); + } + var id = scope.$id, + scopeHistory = history[id], + stack, + values, + pointer, + watchObj; + + if (isUndefined(scopeHistory)) { + throw 'could not find history for scope ' + id; + } + + stack = scopeHistory[exp]; + if (isUndefined(stack)) { + throw 'could not find history in scope "' + id + + ' against expression "' + exp + '"'; + } + pointer = --pointers[id][exp]; + if (pointer < 0) { + $log.warn('attempt to undo past history'); + pointers[id][exp]++; + return; + } + values = this._do(scope, exp, stack, pointer); + if (isDefined(watchObjs[id]) && + isDefined(watchObjs[id][exp])) { + watchObj = watchObjs[id][exp]; + watchObj._fireUndoHandlers(exp, scope); + watchObj._broadcast('History.undone', { + expression: exp, + newValue: values.newValue, + oldValue: values.oldValue, + description: descriptions[id][exp], + scope: scope + }); + } + }; + + /** + * Actually issues the appropriate scope.$watch + * @param {string} exp Expression + * @param {Scope=} scope Scope; defaults to $rootScope + * @param {boolean=} pass Whether or not to skip the first watch execution. Defaults to false + * @param {Object} lazyOptions Options to send the lazy module + * @private + */ + this._watch = function _watch(exp, scope, pass, lazyOptions) { + var id; + scope = scope || $rootScope; + pass = pass || false; + id = scope.$id; + + // do we have an array or object? + if (lazyBindFound && (isObject(lazyOptions) || + (lazyWatches[id] && !!lazyWatches[id][exp]))) { + watches[id][exp] = + scope.$watch(lazyWatch(scope, exp, lazyOptions.timeout), + bind(this, this._archive(exp, id, scope, pass)), true); + lazyWatches[id][exp] = true; + } + else { + watches[id][exp] = + scope.$watch(exp, bind(this, this._archive(exp, id, scope, pass)), + true); + lazyWatches[id][exp] = false; + } + + }; + + /** + * @ngdoc function + * @name decipher.history.service:History#redo + * @method + * @methodOf decipher.history.service:History + * @description + * Redoes (?) the last undo. + * @param {string} exp Expression to redo + * @param {Scope=} scope Scope; defaults to `$rootScope` + */ + this.redo = function redo(exp, scope) { + scope = scope || $rootScope; + var id = scope.$id, + stack = history[id][exp], + values, + pointer, + watchObj; + + if (isUndefined(stack)) { + throw 'could not find history in scope "' + id + + ' against expression "' + exp + '"'; + } + pointer = ++pointers[id][exp]; + if (pointer === stack.length) { + $log.warn('attempt to redo past history'); + pointers[id][exp]--; + return; + } + + values = this._do(scope, exp, stack, pointer); + + if (isDefined(watchObjs[id]) && + isDefined(watchObjs[id][exp])) { + watchObj = watchObjs[id][exp]; + watchObj._fireRedoHandlers(exp, scope); + watchObj._broadcast('History.redone', { + expression: exp, + oldValue: copy(values.newValue), + newValue: copy(values.oldValue), + description: descriptions[id][exp], + scope: scope + }); + } + }; + + /** + * @ngdoc function + * @name decipher.history.service:History#canUndo + * @method + * @methodOf decipher.history.service:History + * @description + * Whether or not we have accumulated any history for a particular expression. + * @param {string} exp Expression + * @param {Scope=} scope Scope; defaults to $rootScope + * @return {boolean} Whether or not you can issue an `undo()` + * @example + * + + angular.module('decipher.history').run(function(History, $rootScope) { + $rootScope.foo = 'bar'; + History.watch('foo'); + $rootScope.canUndo = History.canUndo; + }); + + + Can undo? {{canUndo('foo')}} + + + */ + this.canUndo = function canUndo(exp, scope) { + var id; + scope = scope || $rootScope; + id = scope.$id; + return isDefined(pointers[id]) && + isDefined(pointers[id][exp]) && + pointers[id][exp] > 0; + }; + + /** + * @ngdoc function + * @name decipher.history.service:History#canRedo + * @method + * @methodOf decipher.history.service:History + * @description + * Whether or not we can redo an expression's value. + * @param {string} exp Expression + * @param {Scope=} scope Scope; defaults to $rootScope + * @return {Boolean} Whether or not you can issue a `redo()` + * @example + * + + angular.module('decipher.history').run(function(History, $rootScope) { + $rootScope.foo = 'bar'; + History.watch('foo'); + $rootScope.canRedo = History.canRedo; + $rootScope.canUndo = History.canUndo; + $rootScope.undo = History.undo; + }); + + +
+
+ Can redo? {{canRedo('foo')}} +
+
+ */ + this.canRedo = function canRedo(exp, scope) { + var id; + scope = scope || $rootScope; + id = scope.$id; + return isDefined(pointers[id]) && + isDefined(pointers[id][exp]) && + pointers[id][exp] < history[id][exp].length - 1; + }; + + /** + * @ngdoc function + * @method + * @methodOf decipher.history.service:History + * @name decipher.history.service:History#revert + * @description + * Reverts to earliest known value of some expression, or at a particular + * pointer if you please. + * @param {string} exp Expression + * @param {Scope=} scope Scope; defaults to $rootScope + * @param {number=} pointer Optional; defaults to 0 + */ + this.revert = function (exp, scope, pointer) { + scope = scope || $rootScope; + pointer = pointer || 0; + var id = scope.$id, + stack = history[id][exp], + values, + watchObj; + + if (isUndefined(stack)) { + $log.warn('nothing to revert'); + return; + } + values = this._do(scope, exp, stack, pointer); + + // wait; what is this? + history[id][exp].splice(); + pointers[id][exp] = pointer; + + if (isDefined(watchObjs[id]) && + isDefined(watchObjs[id][exp])) { + watchObj = watchObjs[id][exp]; + watchObj._fireRevertHandlers(exp, scope); + watchObj._broadcast('History.reverted', { + expression: exp, + oldValue: copy(values.newValue), + newValue: copy(values.oldValue), + description: descriptions[id][exp], + scope: scope, + pointer: pointer + }); + } + }; + + /** + * @ngdoc function + * @name decipher.history.service:History#batch + * @method + * @methodOf decipher.history.service:History + * @description + * Executes a function within a batch context which can then be rolled back. + * @param {function} fn Function to execute + * @param {Scope=} scope Scope object; defaults to `$rootScope` + * @param {string=} description Description of this change + * @returns {Watch} {@link decipher.history.object:Watch Watch instance} + * @example + + + angular.module('decipher.history').run(function(History, $rootScope) { + var t; + + $rootScope.herp = 'derp'; + $rootScope.bar = 'baz'; + $rootScope.frick = 'frack'; + + $rootScope.$on('History.batchEnded', function(evt, data) { + t = data.transaction; + }); + + History.watch('herp'); + History.watch('bar'); + History.watch('frick'); + + $rootScope.batch = function() { + History.batch(function() { + $rootScope.herp = 'derp2'; + $rootScope.bar = 'baz2'; + $rootScope.frick = 'frack2'; + }) + .addRollbackHandler('myRollbackHandler', function() { + $rootScope.message = 'rolled a bunch of stuff back'; + }); + $rootScope.message = "batch complete"; + }; + + $rootScope.rollback = function() { + if (isDefined(t)) { + History.rollback(t); + } + }; + }); + + +
    +
  • herp: {{herp}}
  • +
  • bar: {{bar}}
  • +
  • frick: {{frick}}
  • +
+ +
+ {{message}} +
+
+ */ + this.batch = function batch(fn, scope, description) { + var _clear = bind(this, this._clear), + _initStores = this._initStores, + listener, + watchObj, + child; + scope = scope || $rootScope; + if (!isFunction(fn)) { + throw new Error('transaction requires a function'); + } + + child = scope.$new(); + child.$on('$destroy', function () { + _clear(child); + }); + + listener = scope.$on('History.archived', function (evt, data) { + var deepChild, + exp = data.expression, + id; + if (data.locals.$id !== child.$id) { + deepChild = child.$new(); + deepChild.$on('$destroy', function () { + _clear(deepChild); + }); + deepChild.$$locals = data.locals; + id = deepChild.$id; + _initStores(id); + history[id][exp] = + copy(history[data.locals.$id][exp]); + pointers[id][exp] = pointers[data.locals.$id][exp] - 1; + } + }); + + watchObjs[child.$id] = watchObj = new Watch(null, child); + watchObj._broadcast('History.batchBegan', { + transaction: child, + description: description + }); + + // we need to put this into a timeout and apply manually + // since it's not clear when the watchers will get fired, + // and we must ensure that any existing watchers on the archived + // event can be skipped before the batchEnd occurs. + batching = true; + $timeout(function () { + fn(child); + scope.$apply(); + }) + .then(function () { + listener(); + batching = false; + watchObj._broadcast('History.batchEnded', { + transaction: child, + description: description + }); + }); + + + return watchObj; + }; + + /** + * @ngdoc function + * @name decipher.history.service:History#rollback + * @method + * @methodOf decipher.history.service:History + * @description + * Rolls a transaction back that was executed via {@link decipher.history.service:History#batch batch()}. + * + * For an example, see {@link decipher.history.service:History#batch batch()}. + * @param {Scope} t Scope object in which the transaction was executed. + */ + this.rollback = function rollback(t) { + + var _do = bind(this, this._do), + parent = t.$parent, + packets = {}, + nextSibling, + watchObj, + nextSiblingLocals; + if (!t || !isObject(t)) { + throw new Error('must pass a scope to rollback'); + } + + function _rollback(scope, comparisonScope) { + var id = scope.$id, + comparisonScopeId = comparisonScope.$id, + stack = history[id], + pointer, + descs, + exp, + values, + exps, + rolledback, + i; + if (stack) { + exps = Object.keys(stack); + i = exps.length; + } else { + // might not actually have history, it's ok + return; + } + while (i--) { + exp = exps[i]; + values = []; + descs = []; + pointer = pointers[comparisonScopeId][exp]; + rolledback = false; + while (pointer > pointers[id][exp]) { + pointer--; + values.push(_do(comparisonScope, + exp, history[comparisonScopeId][exp], pointer)); + pointers[comparisonScopeId][exp] = pointer; + descs.push(descriptions[comparisonScopeId][exp]); + // throw this off the history stack so + // we don't end up with it in the stack while we + // do normal undo() calls later against the same + // expression and scope + history[comparisonScopeId][exp].pop(); + rolledback = true; + } + if (rolledback) { + packets[exp] = { + values: values, + scope: scope, + comparisonScope: comparisonScope, + descriptions: descs + }; + } + } + } + + watchObj = watchObjs[t.$id]; + + if (isDefined(parent) && + isDefined(history[parent.$id])) { + _rollback(t, parent); + } + nextSibling = t.$$childHead; + while (nextSibling) { + nextSiblingLocals = nextSibling.$$locals; + if (nextSiblingLocals) { + _rollback(nextSibling, nextSiblingLocals); + } + nextSibling = nextSibling.$$nextSibling; + } + watchObj._fireRollbackHandlers(); + watchObj._broadcast('History.rolledback', packets); + + }; + + /** + * @ngdoc property + * @name decipher.history.service:History#history + * @propertyOf decipher.history.service:History + * @description + * The complete history stack, keyed by Scope `$id` and then expression. + * @type {{}} + */ + this.history = history; + + /** + * @ngdoc property + * @name decipher.history.service:History#descriptions + * @propertyOf decipher.history.service:History + * @description + * The complete map of change descriptions, keyed by Scope `$id` and then expression. + * @type {{}} + */ + this.descriptions = descriptions; + + /** + * @ngdoc property + * @name decipher.history.service:History#pointers + * @propertyOf decipher.history.service:History + * @description + * The complete pointer map, keyed by Scope `$id` and then expression. + * @type {{}} + */ + this.pointers = pointers; + + /** + * @ngdoc property + * @name decipher.history.service:History#watches + * @propertyOf decipher.history.service:History + * @description + * The complete index of all AngularJS `$watch`es, keyed by Scope `$id` and then expression. + * @type {{}} + */ + this.watches = watches; + + /** + * @ngdoc property + * @name decipher.history.service:History#lazyWatches + * @propertyOf decipher.history.service:History + * @description + * The complete index of all AngularJS `$watch`es designated to be "lazy", keyed by Scope `$id` and then expression. + * @type {{}} + */ + this.lazyWatches = lazyWatches; + + /** + * @ngdoc property + * @name decipher.history.service:History#watchObjs + * @propertyOf decipher.history.service:History + * @description + * The complete index of all {@link decipher.history.object:Watch Watch} objects registered, keyed by Scope `$id` and then (optionally) expression. + * @type {{}} + */ + this.watchObjs = watchObjs; + + /** + * @ngdoc property + * @name decipher.history.service:History#Watch + * @propertyOf decipher.history.service:History + * @description + * Here's the Watch prototype for you to play with. + * @type {Watch} + */ + this.Watch = Watch; + }]); +})(); diff --git a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/bower_components/angular-route/angular-route.min.js b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/bower_components/angular-route/angular-route.min.js new file mode 100644 index 00000000..7bacd21a --- /dev/null +++ b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/bower_components/angular-route/angular-route.min.js @@ -0,0 +1,15 @@ +/* + AngularJS v1.5.6 + (c) 2010-2016 Google, Inc. http://angularjs.org + License: MIT +*/ +(function(C,d){'use strict';function w(s,h,f){return{restrict:"ECA",terminal:!0,priority:400,transclude:"element",link:function(a,e,b,g,y){function k(){n&&(f.cancel(n),n=null);l&&(l.$destroy(),l=null);m&&(n=f.leave(m),n.then(function(){n=null}),m=null)}function z(){var b=s.current&&s.current.locals;if(d.isDefined(b&&b.$template)){var b=a.$new(),g=s.current;m=y(b,function(b){f.enter(b,null,m||e).then(function(){!d.isDefined(u)||u&&!a.$eval(u)||h()});k()});l=g.scope=b;l.$emit("$viewContentLoaded"); +l.$eval(r)}else k()}var l,m,n,u=b.autoscroll,r=b.onload||"";a.$on("$routeChangeSuccess",z);z()}}}function v(d,h,f){return{restrict:"ECA",priority:-400,link:function(a,e){var b=f.current,g=b.locals;e.html(g.$template);var y=d(e.contents());if(b.controller){g.$scope=a;var k=h(b.controller,g);b.controllerAs&&(a[b.controllerAs]=k);e.data("$ngControllerController",k);e.children().data("$ngControllerController",k)}a[b.resolveAs||"$resolve"]=g;y(a)}}}var r=d.module("ngRoute",["ng"]).provider("$route",function(){function s(a, +e){return d.extend(Object.create(a),e)}function h(a,d){var b=d.caseInsensitiveMatch,g={originalPath:a,regexp:a},f=g.keys=[];a=a.replace(/([().])/g,"\\$1").replace(/(\/)?:(\w+)(\*\?|[\?\*])?/g,function(a,d,b,e){a="?"===e||"*?"===e?"?":null;e="*"===e||"*?"===e?"*":null;f.push({name:b,optional:!!a});d=d||"";return""+(a?"":d)+"(?:"+(a?d:"")+(e&&"(.+?)"||"([^/]+)")+(a||"")+")"+(a||"")}).replace(/([\/$\*])/g,"\\$1");g.regexp=new RegExp("^"+a+"$",b?"i":"");return g}var f={};this.when=function(a,e){var b= +d.copy(e);d.isUndefined(b.reloadOnSearch)&&(b.reloadOnSearch=!0);d.isUndefined(b.caseInsensitiveMatch)&&(b.caseInsensitiveMatch=this.caseInsensitiveMatch);f[a]=d.extend(b,a&&h(a,b));if(a){var g="/"==a[a.length-1]?a.substr(0,a.length-1):a+"/";f[g]=d.extend({redirectTo:a},h(g,b))}return this};this.caseInsensitiveMatch=!1;this.otherwise=function(a){"string"===typeof a&&(a={redirectTo:a});this.when(null,a);return this};this.$get=["$rootScope","$location","$routeParams","$q","$injector","$templateRequest", +"$sce",function(a,e,b,g,h,k,r){function l(q){var c=t.current;(A=(p=w())&&c&&p.$$route===c.$$route&&d.equals(p.pathParams,c.pathParams)&&!p.reloadOnSearch&&!x)||!c&&!p||a.$broadcast("$routeChangeStart",p,c).defaultPrevented&&q&&q.preventDefault()}function m(){var q=t.current,c=p;if(A)q.params=c.params,d.copy(q.params,b),a.$broadcast("$routeUpdate",q);else if(c||q)x=!1,(t.current=c)&&c.redirectTo&&(d.isString(c.redirectTo)?e.path(v(c.redirectTo,c.params)).search(c.params).replace():e.url(c.redirectTo(c.pathParams, +e.path(),e.search())).replace()),g.when(c).then(n).then(function(e){c==t.current&&(c&&(c.locals=e,d.copy(c.params,b)),a.$broadcast("$routeChangeSuccess",c,q))},function(d){c==t.current&&a.$broadcast("$routeChangeError",c,q,d)})}function n(a){if(a){var c=d.extend({},a.resolve);d.forEach(c,function(a,b){c[b]=d.isString(a)?h.get(a):h.invoke(a,null,null,b)});a=u(a);d.isDefined(a)&&(c.$template=a);return g.all(c)}}function u(a){var c,b;d.isDefined(c=a.template)?d.isFunction(c)&&(c=c(a.params)):d.isDefined(b= +a.templateUrl)&&(d.isFunction(b)&&(b=b(a.params)),d.isDefined(b)&&(a.loadedTemplateUrl=r.valueOf(b),c=k(b)));return c}function w(){var a,c;d.forEach(f,function(b,g){var f;if(f=!c){var h=e.path();f=b.keys;var l={};if(b.regexp)if(h=b.regexp.exec(h)){for(var k=1,n=h.length;k Date: Tue, 30 Aug 2016 08:02:27 +0200 Subject: [PATCH 02/24] netopeerangular: connections link does not use ajax loading --- .../Resources/views/Module/section.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FIT/Bundle/ModuleDefaultBundle/Resources/views/Module/section.html.twig b/src/FIT/Bundle/ModuleDefaultBundle/Resources/views/Module/section.html.twig index 6c9569f9..b2ff8b41 100644 --- a/src/FIT/Bundle/ModuleDefaultBundle/Resources/views/Module/section.html.twig +++ b/src/FIT/Bundle/ModuleDefaultBundle/Resources/views/Module/section.html.twig @@ -46,7 +46,7 @@ if advised of the possibility of such damage. {% block topMenu %} {% if not isSingleInstance %} - Connections + Connections {% endif %} {% if app.request.get('key') is defined and not (app.request.get('key') is empty) and lockedConn is defined %} {% if lockedConn == false %} From ad6fd4cd9a8f26c2187ce9bcdd6221a7c1a0bf3c Mon Sep 17 00:00:00 2001 From: David Alexa Date: Tue, 30 Aug 2016 10:20:48 +0200 Subject: [PATCH 03/24] adds support for action --- .../Controller/ModuleController.php | 18 ++++++++---- .../public/netopeerangular/js/JSONedit.js | 23 +++++++++++++++ .../js/services/ajaxService.js | 8 ++++++ .../netopeerangular/templates/main/view.html | 2 ++ .../Controller/ModuleController.php | 6 ++-- .../Functionality/NetconfFunctionality.php | 28 +++++++++++++++++++ 6 files changed, 77 insertions(+), 8 deletions(-) diff --git a/src/FIT/Bundle/ModuleDefaultBundle/Controller/ModuleController.php b/src/FIT/Bundle/ModuleDefaultBundle/Controller/ModuleController.php index cd2da3d2..85f273fd 100644 --- a/src/FIT/Bundle/ModuleDefaultBundle/Controller/ModuleController.php +++ b/src/FIT/Bundle/ModuleDefaultBundle/Controller/ModuleController.php @@ -34,7 +34,17 @@ public function moduleAction($key, $module = null, $subsection = null) $configParams = $this->getConfigParams(); $postData = $this->getRequest()->getContent(); - if (strpos($postData, 'form') !== 0) { + $postArr = json_decode($postData, true); + + if (isset($postArr['action']) && $postArr['action'] == "commit") { + $params = array( + 'connIds' => array($key) + ); + $res = $netconfFunc->handle('commit', $params, true, $result); + + $this->get('session')->set('isAjax', true); + return $this->getTwigArr(); + } elseif (strpos($postData, 'form') !== 0) { $params = array( 'connIds' => array($key), 'target' => $configParams['source'], @@ -43,9 +53,6 @@ public function moduleAction($key, $module = null, $subsection = null) $res = $netconfFunc->handle('editconfig', $params, true, $result); $this->get('session')->set('isAjax', true); -// $this->removeAjaxBlock('moduleJavascripts'); -// $this->removeAjaxBlock('moduleStylesheet'); -// $this->removeAjaxBlock('state'); return $this->getTwigArr(); } } @@ -65,10 +72,11 @@ public function moduleAction($key, $module = null, $subsection = null) $this->removeAjaxBlock('topMenu'); $content = json_decode($this->getTwigArr()->getContent(), true); - + $conn = $connectionFunc->getConnectionSessionForKey($key); $res = array( 'variables' => array( 'jsonEditable' => true, + 'datastore' => $conn->getCurrentDatastore(), ), 'configuration' => json_decode($resData), 'snippets' => $content['snippets'], diff --git a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/js/JSONedit.js b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/js/JSONedit.js index 15ad8b57..6dfa0f11 100644 --- a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/js/JSONedit.js +++ b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/js/JSONedit.js @@ -55,6 +55,7 @@ var app = angular.module('NetopeerGUIApp', ['JSONedit', 'ngRoute', 'ngTraverse', AjaxService.reloadData(targetUrl) .then(function successCallback(data) { $scope.jsonEditable = jsonEditable = data.data.variables.jsonEditable; + $scope.datastore = datastore = data.data.variables.datastore; //$scope.jsonString = JSON.stringify(data.data.configuration); $scope.jsonData = data.data.configuration; @@ -210,6 +211,28 @@ var app = angular.module('NetopeerGUIApp', ['JSONedit', 'ngRoute', 'ngTraverse', $.netopeergui.hideSpinner(); }); }; + + $scope.commitConfiguration = function() { + $.netopeergui.createSpinner(); + $.netopeergui.showSpinner(); + + AjaxService.commitConfiguration(window.location.href) + .then(function successCallback(data) { + var tmpData = data.data; + //console.log(tmpData); + if (typeof tmpData.snippets['block--state'] !== "undefined") { + delete(tmpData.snippets['block--state']); + } + $.netopeergui.processResponseData(tmpData, function() { + //$scope.reload(); + $.netopeergui.hideSpinner(); + }); + }, function errorCallback(data) { + //console.log(data); + //alert('error2'); + $.netopeergui.hideSpinner(); + }); + }; }) .config(['$rootScopeProvider', '$routeProvider', function ($rootScopeProvider, $routeProvider) { diff --git a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/js/services/ajaxService.js b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/js/services/ajaxService.js index dd2249be..8c3fcd9a 100644 --- a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/js/services/ajaxService.js +++ b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/js/services/ajaxService.js @@ -26,4 +26,12 @@ var services = angular.module('NetopeerGUIServices', []) data: cleanJson }); }; + + this.commitConfiguration = function(targetUrl) { + return $http({ + url: targetUrl || window.location.href, + method: 'POST', + data: {'angular': true, 'action': 'commit'} + }); + }; }); \ No newline at end of file diff --git a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/templates/main/view.html b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/templates/main/view.html index 40ae50f9..4cd652e6 100644 --- a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/templates/main/view.html +++ b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/templates/main/view.html @@ -6,6 +6,8 @@

Config & State data

+ + diff --git a/src/FIT/NetopeerBundle/Controller/ModuleController.php b/src/FIT/NetopeerBundle/Controller/ModuleController.php index bd243192..95a072a9 100644 --- a/src/FIT/NetopeerBundle/Controller/ModuleController.php +++ b/src/FIT/NetopeerBundle/Controller/ModuleController.php @@ -309,7 +309,7 @@ protected function redirectToFirstModule($key) { * @param int $key key of connected server * @param string $module = null module name * @param string $subsection = null subsection name - * @return RedirectResponse redirect to page, which was this method called from + * @return int */ protected function processSectionForms($key, $module = null, $subsection = null) { $post_vals = $this->getRequest()->get("form"); @@ -320,12 +320,12 @@ protected function processSectionForms($key, $module = null, $subsection = null) // processing filter on config part if ( isset($post_vals['formType']) && $post_vals['formType'] == "formConfig" ) { - $res = $this->handleFilterConfig($key); $this->addAjaxBlock('FITNetopeerBundle:Default:connections.html.twig', 'topMenu'); + return $this->handleFilterConfig($key); // processing form on config - edit Config } elseif ( isset($post_vals['formType']) && $post_vals['formType'] == "formCopyConfig" ) { - $res = $this->handleCopyConfig($key); + return $this->handleCopyConfig($key); } /* diff --git a/src/FIT/NetopeerBundle/Services/Functionality/NetconfFunctionality.php b/src/FIT/NetopeerBundle/Services/Functionality/NetconfFunctionality.php index 80db7538..6300d3d5 100644 --- a/src/FIT/NetopeerBundle/Services/Functionality/NetconfFunctionality.php +++ b/src/FIT/NetopeerBundle/Services/Functionality/NetconfFunctionality.php @@ -81,6 +81,7 @@ class NetconfFunctionality { const MSG_RELOADHELLO = 17; const MSG_NTF_GETHISTORY = 18; const MSG_VALIDATE = 19; + const MSG_COMMIT = 20; const SCH_QUERY = 100; const SCH_MERGE = 101; @@ -940,6 +941,30 @@ public function handle_validate(&$sock, &$params) { return $this->checkDecodedData($decoded); } + /** + * Commit datastore into datastore + * key: type (int), value: 20 + * key: sessions (array of ints), value: array of SIDs + * + * @param $sock + * @param $params + * + * @return int|mixed + */ + public function handle_commit(&$sock, &$params) { + if ( $this->getConnectionFunctionality()->checkLoggedKeys() != 0) { + return 1; + } + + $validateParams = array( + "type" => self::MSG_COMMIT, + "sessions" => $this->getConnectionFunctionality()->getHashFromKeys($params['connIds']), + ); + + $decoded = $this->execute_operation($sock, $validateParams); + return $this->checkDecodedData($decoded); + } + /** * Query schema node by XPATH * key: type (int), value: 100 @@ -1183,6 +1208,9 @@ public function handle($command, $params = array(), $merge = true, &$result = nu case "validate": $res = $this->handle_validate($sock, $params); break; + case "commit": + $res = $this->handle_commit($sock, $params); + break; case "query": $res = $this->handle_query($sock, $params); break; From debe39fb70bf5af1a17d654d1762d9cc597b4986 Mon Sep 17 00:00:00 2001 From: David Alexa Date: Tue, 30 Aug 2016 10:21:42 +0200 Subject: [PATCH 04/24] bugfix: angular content reload on jquery ajaxLink update --- .../public/netopeerangular/js/JSONedit.js | 22 +++++++++++++++--- .../js/services/ajaxService.js | 2 +- .../netopeerangular/public/templates.js | 6 ++--- .../netopeerangular/templates/main/view.html | 4 ++-- .../Resources/views/Module/section.html.twig | 6 +++++ .../Resources/public/js/jquery.netopeergui.js | 23 +++++++++---------- .../Resources/views/layout.html.twig | 4 +++- .../Functionality/ConnectionFunctionality.php | 7 +++++- 8 files changed, 51 insertions(+), 23 deletions(-) diff --git a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/js/JSONedit.js b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/js/JSONedit.js index 6dfa0f11..3125eadd 100644 --- a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/js/JSONedit.js +++ b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/js/JSONedit.js @@ -42,13 +42,20 @@ var app = angular.module('NetopeerGUIApp', ['JSONedit', 'ngRoute', 'ngTraverse', var isUndo = false, isRedo = false; - $scope.reloadData = function () { - //console.log('reload'); + $scope.reloadData = function (processResponseData) { var targetUrl; + + if (typeof processResponseData === "undefined") { + processResponseData = true; + } + if (typeof $routeParams.action !== "undefined") { targetUrl = window.location.origin + window.location.pathname.replace('sections', 'info-page') + $routeParams.action + '/'; } else { targetUrl = window.location.origin + window.location.pathname + $scope.moduleName + '/'; + if (!angular.isUndefined($routeParams.sectionName)) { + targetUrl += $routeParams.sectionName + '/'; + } } $.netopeergui.showSpinner(); @@ -57,13 +64,18 @@ var app = angular.module('NetopeerGUIApp', ['JSONedit', 'ngRoute', 'ngTraverse', $scope.jsonEditable = jsonEditable = data.data.variables.jsonEditable; $scope.datastore = datastore = data.data.variables.datastore; //$scope.jsonString = JSON.stringify(data.data.configuration); + $scope.jsonData = {}; $scope.jsonData = data.data.configuration; var tmpData = data.data; + if (!processResponseData) { + delete tmpData.snippets['block--singleContent']; + delete tmpData.snippets['block--state']; + } $.netopeergui.processResponseData(tmpData, function() { - //$scope.reload(); $.netopeergui.hideSpinner(); }); + //console.log('success reload'); }, function errorCallback(data) { //$scope.jsonData = {}; @@ -243,6 +255,10 @@ var app = angular.module('NetopeerGUIApp', ['JSONedit', 'ngRoute', 'ngTraverse', templateUrl: 'main/view.html', controller: 'ConfigurationController' }) + .when('/module/:moduleName/:sectionName', { + templateUrl: 'main/view.html', + controller: 'ConfigurationController' + }) .when('/action/:action', { templateUrl: 'main/view.html', controller: 'ConfigurationController' diff --git a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/js/services/ajaxService.js b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/js/services/ajaxService.js index 8c3fcd9a..d80df43d 100644 --- a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/js/services/ajaxService.js +++ b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/js/services/ajaxService.js @@ -1,7 +1,7 @@ var services = angular.module('NetopeerGUIServices', []) .service('AjaxService', function ($http) { - $http.defaults.cache = true; + $http.defaults.cache = false; this.reloadData = function(targetUrl) { var url = targetUrl || window.location.href; diff --git a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/public/templates.js b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/public/templates.js index 58d7bae5..9bdacd7b 100644 --- a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/public/templates.js +++ b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/public/templates.js @@ -1,6 +1,6 @@ -angular.module("configurationTemplates", []).run(["$templateCache", function($templateCache) {$templateCache.put("main/view.html","

Config & State data

\n\n
\n
\n \n \n\n \n \n \n\n
\n \n
\n\n \n \n \n \n \n
"); +angular.module("configurationTemplates", []).run(["$templateCache", function($templateCache) {$templateCache.put("directives/addItem.html","\n\n \n :\n \n\n \n\n \n \n \n\n \n\n \n \n \n\n \n \n \n\n \n \n \n\n\n \n \n\n\n \n"); +$templateCache.put("directives/switchItem.html","\n \n \n \n\n \n \n {{ val }}\n \n \n \n {{ val }}\n \n \n \n {{ val }}\n \n \n \n {{ val }}\n \n\n \n"); $templateCache.put("types/Array.html","\n
\n \n
    \n
  1. \n \n
  2. \n
\n \n
"); $templateCache.put("types/List.html","\n
\n \n
    \n
  1. \n \n
  2. \n
\n \n
"); $templateCache.put("types/Object.html","\n
\n \n \n \n {{ key }}\n \n \n \n \n \n \n \n \n \n \n \n \n \n
"); -$templateCache.put("directives/addItem.html","\n\n \n :\n \n\n \n\n \n \n \n\n \n\n \n \n \n\n \n \n \n\n \n \n \n\n\n \n \n\n\n \n"); -$templateCache.put("directives/switchItem.html","\n \n \n \n\n \n \n {{ val }}\n \n \n \n {{ val }}\n \n \n \n {{ val }}\n \n \n \n {{ val }}\n \n\n \n");}]); \ No newline at end of file +$templateCache.put("main/view.html","

Config & State data

\n\n
\n
\n \n \n\n \n \n\n \n \n\n
\n \n
\n\n \n \n \n \n \n
");}]); \ No newline at end of file diff --git a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/templates/main/view.html b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/templates/main/view.html index 4cd652e6..4c2a1593 100644 --- a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/templates/main/view.html +++ b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/templates/main/view.html @@ -1,8 +1,8 @@

Config & State data


-
- +
+ diff --git a/src/FIT/Bundle/ModuleDefaultBundle/Resources/views/Module/section.html.twig b/src/FIT/Bundle/ModuleDefaultBundle/Resources/views/Module/section.html.twig index b2ff8b41..af4471b3 100644 --- a/src/FIT/Bundle/ModuleDefaultBundle/Resources/views/Module/section.html.twig +++ b/src/FIT/Bundle/ModuleDefaultBundle/Resources/views/Module/section.html.twig @@ -97,6 +97,12 @@ if advised of the possibility of such damage.
{% endblock topMenu %} +{% block leftSubsection %} + {% for subsection in submenu %} + {{subsection.name}} + {% endfor %} +{% endblock leftSubsection %} + {% block state %} {% block singleContent %} - -{% endblock singleContent %} -{% endblock state %} \ No newline at end of file diff --git a/src/FIT/NetopeerBundle/Resources/views/layout.html.twig b/src/FIT/NetopeerBundle/Resources/views/layout.html.twig index bdd5327b..8809c4b0 100644 --- a/src/FIT/NetopeerBundle/Resources/views/layout.html.twig +++ b/src/FIT/NetopeerBundle/Resources/views/layout.html.twig @@ -99,7 +99,6 @@ if advised of the possibility of such damage. {% set i = i + 1 %} {% endfor %} All - + {% endif %} {% endif %} From 34aedc80b371ca3e58d8e68a329f0be4bcc7fa9b Mon Sep 17 00:00:00 2001 From: David Alexa Date: Tue, 4 Oct 2016 13:44:19 +0200 Subject: [PATCH 23/24] close notification socket before unload correctly --- .../Resources/views/Module/section.html.twig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/FIT/Bundle/ModuleDefaultBundle/Resources/views/Module/section.html.twig b/src/FIT/Bundle/ModuleDefaultBundle/Resources/views/Module/section.html.twig index 9184ebc6..f9af7211 100644 --- a/src/FIT/Bundle/ModuleDefaultBundle/Resources/views/Module/section.html.twig +++ b/src/FIT/Bundle/ModuleDefaultBundle/Resources/views/Module/section.html.twig @@ -118,8 +118,7 @@ if advised of the possibility of such damage. var socket = getNotifWebSocket({{ app.request.get('key') }}, "{% if sessionHash is defined %}{{sessionHash}}{% endif %}", "wss://{{ app.request.host }}:8080/"); window.onbeforeunload = function() { - var socket = getNotifWebSocket({{ app.request.get('key') }}, "{% if sessionHash is defined %}{{sessionHash}}{% endif %}", "wss://{{ app.request.host }}:8080/"); - socket.close(); + socket.websocket.close(); }; if ($(notifOutput).hasClass('hidden')) { $(notifOutput).removeClass('hidden'); From d8a2f434c6f067ef2240d99e498b51b6fa34ecc2 Mon Sep 17 00:00:00 2001 From: David Alexa Date: Fri, 7 Oct 2016 15:40:30 +0200 Subject: [PATCH 24/24] bugfix: adding empty rpc form --- .../Resources/public/netopeerangular/public/templates.js | 8 ++++---- .../netopeerangular/templates/directives/addItem.html | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/public/templates.js b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/public/templates.js index 8206fd73..1cc42bb7 100644 --- a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/public/templates.js +++ b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/public/templates.js @@ -1,6 +1,6 @@ -angular.module("configurationTemplates", []).run(["$templateCache", function($templateCache) {$templateCache.put("types/Array.html","\n
\n \n
    \n
  1. \n \n
  2. \n
\n \n
"); +angular.module("configurationTemplates", []).run(["$templateCache", function($templateCache) {$templateCache.put("main/view.html","

{{ rpcName || \'Config & State data\' }}

\n\n
\n
\n \n \n\n \n \n \n\n \n \n\n
\n \n
\n\n \n \n \n \n \n
"); +$templateCache.put("types/Array.html","\n
\n \n
    \n
  1. \n \n
  2. \n
\n \n
"); $templateCache.put("types/List.html","\n
\n \n
    \n
  1. \n \n
  2. \n
\n \n
"); $templateCache.put("types/Object.html","\n
\n \n \n \n {{ key }}\n \n \n \n \n \n \n \n \n \n \n \n \n \n
"); -$templateCache.put("directives/addItem.html","\n\n \n :\n \n\n \n\n \n \n \n \n\n\n \n \n\n\n \n"); -$templateCache.put("directives/switchItem.html","\n \n \n \n\n \n \n {{ val }}\n \n \n \n {{ val }}\n \n \n \n {{ val }}\n \n \n \n {{ val }}\n \n\n \n"); -$templateCache.put("main/view.html","

{{ rpcName || \'Config & State data\' }}

\n\n
\n
\n \n \n\n \n \n \n\n \n \n\n
\n \n
\n\n \n \n \n \n \n
");}]); \ No newline at end of file +$templateCache.put("directives/addItem.html","\n\n \n :\n \n\n \n\n \n \n \n \n\n\n \n \n\n\n \n"); +$templateCache.put("directives/switchItem.html","\n \n \n \n\n \n \n {{ val }}\n \n \n \n {{ val }}\n \n \n \n {{ val }}\n \n \n \n {{ val }}\n \n\n \n");}]); \ No newline at end of file diff --git a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/templates/directives/addItem.html b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/templates/directives/addItem.html index 68738bc1..343b5d02 100644 --- a/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/templates/directives/addItem.html +++ b/src/FIT/Bundle/ModuleDefaultBundle/Resources/public/netopeerangular/templates/directives/addItem.html @@ -2,8 +2,7 @@ :