Merge pull request #60 from nextcloud/marionette-room-list

use backbone + marionette to render the list of rooms
This commit is contained in:
Lukas Reschke 2016-10-18 16:19:33 +02:00 коммит произвёл GitHub
Родитель ebbc33cbfe f1ec1f7e25
Коммит e76242bee9
29 изменённых файлов: 599 добавлений и 607 удалений

Просмотреть файл

@ -18,7 +18,7 @@
], ],
"dependencies": { "dependencies": {
"backbone": "1.2.3", "backbone": "1.2.3",
"backbone.marionette": "^3.1.0", "backbone.marionette": "3.0.0"
"jquery": "^2.0" "jquery": "^2.0"
} }
} }

Просмотреть файл

@ -26,20 +26,46 @@
OCA.SpreedMe = OCA.SpreedMe || {}; OCA.SpreedMe = OCA.SpreedMe || {};
var App = Marionette.Application.extend({ var App = Marionette.Application.extend({
/** @property {OCA.SpreedMe.Models.RoomCollection} _rooms */
_rooms: null,
/** @property {OCA.SpreedMe.Views.RoomListView} _roomsView */
_roomsView: null,
_registerPageEvents: function() { _registerPageEvents: function() {
var self = this;
$('#oca-spreedme-add-room').submit(function() { $('#oca-spreedme-add-room').submit(function() {
return false; return false;
}); });
// Create a new room // Create a new room
$('#oca-spreedme-add-room > button.icon-confirm').click(function() { $('#oca-spreedme-add-room > button.icon-confirm').click(function() {
var roomname = $('#oca-spreedme-add-room > input[type="text"]'). var roomname = $('#oca-spreedme-add-room > input[type="text"]').val();
val();
if (roomname === "") { if (roomname === "") {
return; return;
} }
OCA.SpreedMe.Rooms.create(roomname); self._rooms.create({
name: roomname
}, {
success: function(data) {
OCA.SpreedMe.Rooms.join(data.get('id'));
}, error: function(jqXHR, status, error) {
var message;
var editRoomname = $('#edit-roomname');
try {
message = JSON.parse(jqXHR.responseText).message;
} catch (e) {
// Ignore exception, received no/invalid JSON.
}
if (!message) {
message = jqXHR.responseText || error;
}
editRoomname.prop('title', message);
editRoomname.tooltip({placement: 'right', trigger: 'manual'});
editRoomname.tooltip('show');
editRoomname.addClass('error');
}
});
}); });
var videoHidden = false; var videoHidden = false;
@ -108,11 +134,17 @@
OCA.SpreedMe.Rooms.join(); OCA.SpreedMe.Rooms.join();
} }
}, },
_showRoomList: function() {
this._roomsView = new OCA.SpreedMe.Views.RoomListView({
el: '#app-navigation ul',
collection: this._rooms
});
},
_pollForRoomChanges: function() { _pollForRoomChanges: function() {
// Load the list of rooms all 10 seconds // Load the list of rooms all 10 seconds
OCA.SpreedMe.Rooms.list(); var self = this;
setInterval(function() { setInterval(function() {
OCA.SpreedMe.Rooms.list(); self.syncRooms();
}, 10000); }, 10000);
}, },
_startPing: function() { _startPing: function() {
@ -122,11 +154,25 @@
OCA.SpreedMe.Rooms.ping(); OCA.SpreedMe.Rooms.ping();
}, 5000); }, 5000);
}, },
syncRooms: function() {
this._rooms.fetch();
},
onStart: function() { onStart: function() {
console.log('Starting spreed …'); console.log('Starting spreed …');
var self = this;
this._registerPageEvents(); this._registerPageEvents();
this._onRegisterHashChange(); this._onRegisterHashChange();
this._rooms = new OCA.SpreedMe.Models.RoomCollection();
this._showRoomList();
this._rooms.fetch({
success: function() {
$('#app-navigation').removeClass('icon-loading');
self._roomsView.render();
}
});
this._pollForRoomChanges(); this._pollForRoomChanges();
this._startPing(); this._startPing();
} }

Просмотреть файл

@ -20,8 +20,8 @@
(function(OCA, $) { (function(OCA, $) {
$(function() { $(function() {
var app = new OCA.SpreedMe.App(); OCA.SpreedMe.app = new OCA.SpreedMe.App();
// Here we go! // Here we go!
app.start(); OCA.SpreedMe.app.start();
}); });
})(OCA, $); })(OCA, $);

37
js/models/room.js Normal file
Просмотреть файл

@ -0,0 +1,37 @@
/* global Backbone */
/**
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
(function(OCA, Backbone) {
'use strict';
OCA.SpreedMe = OCA.SpreedMe || {};
OCA.SpreedMe.Models = OCA.SpreedMe.Models || {};
var Room = Backbone.Model.extend({
defaults: {
name: '',
count: 0
}
});
OCA.SpreedMe.Models.Room = Room;
})(OCA, Backbone);

Просмотреть файл

@ -0,0 +1,35 @@
/* global Backbone */
/**
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
(function(OCA, Backbone) {
OCA.SpreedMe = OCA.SpreedMe || {};
OCA.SpreedMe.Models = OCA.SpreedMe.Models || {};
var RoomCollection = Backbone.Collection.extend({
model: OCA.SpreedMe.Models.Room,
comparator: 'name',
url: OC.generateUrl('/apps/spreed/api/room')
});
OCA.SpreedMe.Models.RoomCollection = RoomCollection;
})(OCA, Backbone);

Просмотреть файл

@ -13,44 +13,6 @@ $(document).ready(function() {
var currentRoomId = 0; var currentRoomId = 0;
OCA.SpreedMe.Rooms = { OCA.SpreedMe.Rooms = {
create: function(roomName) {
$.post(
OC.generateUrl('/apps/spreed/api/room'),
{
roomName: roomName
},
function(data) {
var roomId = data.roomId;
OCA.SpreedMe.Rooms.join(roomId);
}
).fail(function(jqXHR, status, error) {
var message;
try {
message = JSON.parse(jqXHR.responseText).message;
} catch (e) {
// Ignore exception, received no/invalid JSON.
}
if (!message) {
message = jqXHR.responseText || error;
}
editRoomname.prop('title', message);
editRoomname.tooltip({placement: 'right', trigger: 'manual'});
editRoomname.tooltip('show');
editRoomname.addClass('error');
});
},
list: function() {
$.ajax({
url: OC.generateUrl('/apps/spreed/api/room'),
success: function(data) {
$('#app-navigation ul').html('');
data.forEach(function(element) {
$('#app-navigation ul').append('<li><a href="#'+escapeHTML(element['id'])+'">'+escapeHTML(element['name'])+' <span class="utils">' + escapeHTML(element['count']) + '</span></a></li>');
});
$('#app-navigation').removeClass('icon-loading');
}
});
},
join: function(roomId) { join: function(roomId) {
$('#emptycontent').hide(); $('#emptycontent').hide();
$('.videoView').addClass('hidden'); $('.videoView').addClass('hidden');

15
js/vendor/backbone.marionette/.bower.json поставляемый
Просмотреть файл

@ -3,7 +3,7 @@
"description": "The Backbone Framework", "description": "The Backbone Framework",
"homepage": "http://marionettejs.org", "homepage": "http://marionettejs.org",
"main": "./lib/backbone.marionette.js", "main": "./lib/backbone.marionette.js",
"version": "3.1.0", "version": "3.0.0",
"keywords": [ "keywords": [
"backbone", "backbone",
"framework", "framework",
@ -36,16 +36,15 @@
"upgradeGuide.md" "upgradeGuide.md"
], ],
"dependencies": { "dependencies": {
"backbone.radio": "^2.0.0" "backbone.radio": "2.0.0-pre.1"
}, },
"_release": "3.1.0", "_release": "3.0.0",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v3.1.0", "tag": "v3.0.0",
"commit": "c1d41d73c60ad117b285fd7495b4c1801ca1873d" "commit": "d8bee8d66003f6935994f7f066235a8896f81d94"
}, },
"_source": "https://github.com/marionettejs/backbone.marionette.git", "_source": "https://github.com/marionettejs/backbone.marionette.git",
"_target": "^3.1.0", "_target": "3.0.0",
"_originalSource": "backbone.marionette", "_originalSource": "backbone.marionette"
"_direct": true
} }

Просмотреть файл

@ -12,7 +12,6 @@ Tell us what you think should happen.
### Actual behavior ### Actual behavior
If possible, please create a small demo that demonstrates the issue. If possible, please create a small demo that demonstrates the issue.
You can fork https://jsfiddle.net/marionettejs/adhv48ky/ for quick demo setup.
Please refrain from giving code examples in altJS languages like CoffeeScript, etc. Marionette is written in plain-old JavaScript and is generally easier for all members in the community to read. Please refrain from giving code examples in altJS languages like CoffeeScript, etc. Marionette is written in plain-old JavaScript and is generally easier for all members in the community to read.
### Environment ### Environment

4
js/vendor/backbone.marionette/bower.json поставляемый
Просмотреть файл

@ -3,7 +3,7 @@
"description": "The Backbone Framework", "description": "The Backbone Framework",
"homepage": "http://marionettejs.org", "homepage": "http://marionettejs.org",
"main": "./lib/backbone.marionette.js", "main": "./lib/backbone.marionette.js",
"version": "3.1.0", "version": "3.0.0",
"keywords": [ "keywords": [
"backbone", "backbone",
"framework", "framework",
@ -36,6 +36,6 @@
"upgradeGuide.md" "upgradeGuide.md"
], ],
"dependencies": { "dependencies": {
"backbone.radio": "^2.0.0" "backbone.radio": "2.0.0-pre.1"
} }
} }

25
js/vendor/backbone.marionette/changelog.md поставляемый
Просмотреть файл

@ -1,28 +1,3 @@
### v3.1.0 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v3.0.0...v3.1.0)
#### General
* Performance optimizations for `triggerMethod`, `mergeOptions` and other internal event handlers
* Significant render and removal optimizations for CollectionView utilizing Backbone's `update` event
#### Features
* `Region.detachView` and `View.detachChildView` were added for removing a view from a region without destroying it. This is preferred to the now deprecated `preventDestroy` region show/empty option
* `childViewEventPrefix: false` will disable auto-proxying of child events to the parent view
* `Application` will now accept a region definition object literal as an instantiation option
* Regions are now destroyed when removed from a View
#### Fixes
* Fixed an issue with Lodash 4 compatibility related to behavior events
#### Deprecations
* Region `empty`'s `preventDestroy` option was deprecated in favor of `detachView`
* A region definition object literal's `selector` key was deprecated due to redundacy in favor of the existing key `el`
#### Misc
* Many documentation fixes for v3
* Removed shouldReplace logic from `attachHtml` so overriding no longer breaks `replaceElement` functionality
* Exposed `View.normalizeUIString` for external libraries
* Improvements were made for Views initialized with existing DOM elements
### v3.0.0 ### v3.0.0
Version 3.0.0 of Marionette has arrived and contains many improvements over version Version 3.0.0 of Marionette has arrived and contains many improvements over version

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

7
js/vendor/backbone.marionette/package.json поставляемый
Просмотреть файл

@ -1,7 +1,7 @@
{ {
"name": "backbone.marionette", "name": "backbone.marionette",
"description": "The Backbone Framework", "description": "The Backbone Framework",
"version": "3.1.0", "version": "3.0.0",
"homepage": "https://github.com/marionettejs/backbone.marionette", "homepage": "https://github.com/marionettejs/backbone.marionette",
"main": "lib/backbone.marionette.js", "main": "lib/backbone.marionette.js",
"keywords": [ "keywords": [
@ -45,11 +45,10 @@
"underscore": "~1.8.3" "underscore": "~1.8.3"
}, },
"devDependencies": { "devDependencies": {
"babel-core": "6.17.0", "babel-core": "6.7.0",
"babel-eslint": "6.0.4", "babel-eslint": "6.0.4",
"babel-plugin-transform-regenerator": "6.16.1",
"babel-polyfill": "6.6.1", "babel-polyfill": "6.6.1",
"babel-preset-es2015": "6.16.0", "babel-preset-es2015": "6.3.13",
"babel-preset-es2015-rollup": "1.1.1", "babel-preset-es2015-rollup": "1.1.1",
"babel-register": "6.4.3", "babel-register": "6.4.3",
"backbone": "1.2.1 - 1.3.x", "backbone": "1.2.1 - 1.3.x",

10
js/vendor/backbone.radio/.bower.json поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
{ {
"name": "backbone.radio", "name": "backbone.radio",
"version": "2.0.0", "version": "2.0.0-pre.1",
"homepage": "https://github.com/marionettejs/backbone.radio", "homepage": "https://github.com/marionettejs/backbone.radio",
"authors": [ "authors": [
"Jmeas <jellyes2@gmail.com>" "Jmeas <jellyes2@gmail.com>"
@ -26,13 +26,13 @@
"test", "test",
"tests" "tests"
], ],
"_release": "2.0.0", "_release": "2.0.0-pre.1",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v2.0.0", "tag": "v2.0.0-pre.1",
"commit": "8d3c7deec61205daddbd49ce86dbac27afb1aaad" "commit": "ae556624bd509fd96ab67fb92599655fc83b1ec8"
}, },
"_source": "https://github.com/marionettejs/backbone.radio.git", "_source": "https://github.com/marionettejs/backbone.radio.git",
"_target": "^2.0.0", "_target": "2.0.0-pre.1",
"_originalSource": "backbone.radio" "_originalSource": "backbone.radio"
} }

17
js/vendor/backbone.radio/CHANGELOG.md поставляемый
Просмотреть файл

@ -1,20 +1,3 @@
### [2.0.0](https://github.com/marionettejs/backbone.radio/releases/tag/2.0.0)
- Updated Backbone and Underscore version ranges.
- Moved Backbone and Underscore to peerDependencies.
### [2.0.0-pre.2](https://github.com/marionettejs/backbone.radio/releases/tag/2.0.0-pre.2)
- Updated Backbone and Underscore version ranges.
### [2.0.0-pre.1](https://github.com/marionettejs/backbone.radio/releases/tag/2.0.0-pre.1)
- Moved Backbone and Underscore to peerDependencies.
### [1.0.5](https://github.com/marionettejs/backbone.radio/releases/tag/1.0.5)
- Updated Backbone dep to allow v1.3.3
### [1.0.4](https://github.com/marionettejs/backbone.radio/releases/tag/1.0.4) ### [1.0.4](https://github.com/marionettejs/backbone.radio/releases/tag/1.0.4)
- **Bug fix**: The UMD generated from rollup was setting `global` to `undefined`. - **Bug fix**: The UMD generated from rollup was setting `global` to `undefined`.

2
js/vendor/backbone.radio/bower.json поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
{ {
"name": "backbone.radio", "name": "backbone.radio",
"version": "2.0.0", "version": "1.0.4",
"homepage": "https://github.com/marionettejs/backbone.radio", "homepage": "https://github.com/marionettejs/backbone.radio",
"authors": [ "authors": [
"Jmeas <jellyes2@gmail.com>" "Jmeas <jellyes2@gmail.com>"

Просмотреть файл

@ -1,4 +1,4 @@
// Backbone.Radio v2.0.0 // Backbone.Radio v2.0.0-pre.1
(function (global, factory) { (function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('underscore'), require('backbone')) : typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('underscore'), require('backbone')) :
@ -9,17 +9,19 @@
_ = 'default' in _ ? _['default'] : _; _ = 'default' in _ ? _['default'] : _;
Backbone = 'default' in Backbone ? Backbone['default'] : Backbone; Backbone = 'default' in Backbone ? Backbone['default'] : Backbone;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { var babelHelpers = {};
babelHelpers.typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj; return typeof obj;
} : function (obj) { } : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
}; };
babelHelpers;
var previousRadio = Backbone.Radio; var previousRadio = Backbone.Radio;
var Radio = Backbone.Radio = {}; var Radio = Backbone.Radio = {};
Radio.VERSION = '2.0.0'; Radio.VERSION = '2.0.0-pre.1';
// This allows you to run multiple instances of Radio on the same // This allows you to run multiple instances of Radio on the same
// webapp. After loading the new version, call `noConflict()` to // webapp. After loading the new version, call `noConflict()` to
@ -63,7 +65,7 @@
var results = {}; var results = {};
// Handle event maps. // Handle event maps.
if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') { if ((typeof name === 'undefined' ? 'undefined' : babelHelpers.typeof(name)) === 'object') {
for (var key in name) { for (var key in name) {
var result = obj[action].apply(obj, [key, name[key]].concat(rest)); var result = obj[action].apply(obj, [key, name[key]].concat(rest));
eventSplitter.test(key) ? _.extend(results, result) : results[key] = result; eventSplitter.test(key) ? _.extend(results, result) : results[key] = result;
@ -145,7 +147,7 @@
// This is to produce an identical function in both tuneIn and tuneOut, // This is to produce an identical function in both tuneIn and tuneOut,
// so that Backbone.Events unregisters it. // so that Backbone.Events unregisters it.
function _partial(channelName) { function _partial(channelName) {
return _logs[channelName] || (_logs[channelName] = _.bind(Radio.log, Radio, channelName)); return _logs[channelName] || (_logs[channelName] = _.partial(Radio.log, channelName));
} }
_.extend(Radio, { _.extend(Radio, {
@ -155,7 +157,7 @@
if (typeof console === 'undefined') { if (typeof console === 'undefined') {
return; return;
} }
var args = _.toArray(arguments).slice(2); var args = _.drop(arguments, 2);
console.log('[' + channelName + '] "' + eventName + '"', args); console.log('[' + channelName + '] "' + eventName + '"', args);
}, },
@ -196,7 +198,7 @@
// Make a request // Make a request
request: function request(name) { request: function request(name) {
var args = _.toArray(arguments).slice(1); var args = _.rest(arguments);
var results = Radio._eventsApi(this, 'request', name, args); var results = Radio._eventsApi(this, 'request', name, args);
if (results) { if (results) {
return results; return results;
@ -330,7 +332,7 @@
_.each(systems, function (system) { _.each(systems, function (system) {
_.each(system, function (method, methodName) { _.each(system, function (method, methodName) {
Radio[methodName] = function (channelName) { Radio[methodName] = function (channelName) {
args = _.toArray(arguments).slice(1); args = _.rest(arguments);
channel = this.channel(channelName); channel = this.channel(channelName);
return channel[methodName].apply(channel, args); return channel[methodName].apply(channel, args);
}; };
@ -339,9 +341,7 @@
Radio.reset = function (channelName) { Radio.reset = function (channelName) {
var channels = !channelName ? this._channels : [this._channels[channelName]]; var channels = !channelName ? this._channels : [this._channels[channelName]];
_.each(channels, function (channel) { _.invoke(channels, 'reset');
channel.reset();
});
}; };
return Radio; return Radio;

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -1,3 +1,3 @@
// Backbone.Radio v2.0.0 // Backbone.Radio v2.0.0-pre.1
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("underscore"),require("backbone")):"function"==typeof define&&define.amd?define(["underscore","backbone"],n):(e.Backbone=e.Backbone||{},e.Backbone.Radio=n(e._,e.Backbone))}(this,function(e,n){"use strict";function t(e,n,t,r){var o=e[n];if(!(t&&t!==o.callback&&t!==o.callback._callback||r&&r!==o.context))return delete e[n],!0}function r(n,r,o,i){n||(n={});for(var s=r?[r]:e.keys(n),u=!1,c=0,a=s.length;c<a;c++)r=s[c],n[r]&&t(n,r,o,i)&&(u=!0);return u}function o(n){return l[n]||(l[n]=e.bind(c.log,c,n))}function i(n){return e.isFunction(n)?n:function(){return n}}e="default"in e?e["default"]:e,n="default"in n?n["default"]:n;var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},u=n.Radio,c=n.Radio={};c.VERSION="2.0.0",c.noConflict=function(){return n.Radio=u,this},c.DEBUG=!1,c._debugText=function(e,n,t){return e+(t?" on the "+t+" channel":"")+': "'+n+'"'},c.debugLog=function(e,n,t){c.DEBUG&&console&&console.warn&&console.warn(c._debugText(e,n,t))};var a=/\s+/;c._eventsApi=function(n,t,r,o){if(!r)return!1;var i={};if("object"===("undefined"==typeof r?"undefined":s(r))){for(var u in r){var c=n[t].apply(n,[u,r[u]].concat(o));a.test(u)?e.extend(i,c):i[u]=c}return i}if(a.test(r)){for(var l=r.split(a),f=0,h=l.length;f<h;f++)i[l[f]]=n[t].apply(n,[l[f]].concat(o));return i}return!1},c._callHandler=function(e,n,t){var r=t[0],o=t[1],i=t[2];switch(t.length){case 0:return e.call(n);case 1:return e.call(n,r);case 2:return e.call(n,r,o);case 3:return e.call(n,r,o,i);default:return e.apply(n,t)}};var l={};e.extend(c,{log:function(n,t){if("undefined"!=typeof console){var r=e.toArray(arguments).slice(2);console.log("["+n+'] "'+t+'"',r)}},tuneIn:function(e){var n=c.channel(e);return n._tunedIn=!0,n.on("all",o(e)),this},tuneOut:function(e){var n=c.channel(e);return n._tunedIn=!1,n.off("all",o(e)),delete l[e],this}}),c.Requests={request:function(n){var t=e.toArray(arguments).slice(1),r=c._eventsApi(this,"request",n,t);if(r)return r;var o=this.channelName,i=this._requests;if(o&&this._tunedIn&&c.log.apply(this,[o,n].concat(t)),i&&(i[n]||i["default"])){var s=i[n]||i["default"];return t=i[n]?t:arguments,c._callHandler(s.callback,s.context,t)}c.debugLog("An unhandled request was fired",n,o)},reply:function(e,n,t){return c._eventsApi(this,"reply",e,[n,t])?this:(this._requests||(this._requests={}),this._requests[e]&&c.debugLog("A request was overwritten",e,this.channelName),this._requests[e]={callback:i(n),context:t||this},this)},replyOnce:function(n,t,r){if(c._eventsApi(this,"replyOnce",n,[t,r]))return this;var o=this,s=e.once(function(){return o.stopReplying(n),i(t).apply(this,arguments)});return this.reply(n,s,r)},stopReplying:function(e,n,t){return c._eventsApi(this,"stopReplying",e)?this:(e||n||t?r(this._requests,e,n,t)||c.debugLog("Attempted to remove the unregistered request",e,this.channelName):delete this._requests,this)}},c._channels={},c.channel=function(e){if(!e)throw new Error("You must provide a name for the channel.");return c._channels[e]?c._channels[e]:c._channels[e]=new c.Channel(e)},c.Channel=function(e){this.channelName=e},e.extend(c.Channel.prototype,n.Events,c.Requests,{reset:function(){return this.off(),this.stopListening(),this.stopReplying(),this}});var f,h,d=[n.Events,c.Requests];return e.each(d,function(n){e.each(n,function(n,t){c[t]=function(n){return h=e.toArray(arguments).slice(1),f=this.channel(n),f[t].apply(f,h)}})}),c.reset=function(n){var t=n?[this._channels[n]]:this._channels;e.each(t,function(e){e.reset()})},c}); !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("underscore"),require("backbone")):"function"==typeof define&&define.amd?define(["underscore","backbone"],n):(e.Backbone=e.Backbone||{},e.Backbone.Radio=n(e._,e.Backbone))}(this,function(e,n){"use strict";function t(e,n,t,r){var o=e[n];return t&&t!==o.callback&&t!==o.callback._callback||r&&r!==o.context?void 0:(delete e[n],!0)}function r(n,r,o,i){n||(n={});for(var s=r?[r]:e.keys(n),u=!1,a=0,c=s.length;c>a;a++)r=s[a],n[r]&&t(n,r,o,i)&&(u=!0);return u}function o(n){return l[n]||(l[n]=e.partial(a.log,n))}function i(n){return e.isFunction(n)?n:function(){return n}}e="default"in e?e["default"]:e,n="default"in n?n["default"]:n;var s={};s["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};var u=n.Radio,a=n.Radio={};a.VERSION="2.0.0-pre.1",a.noConflict=function(){return n.Radio=u,this},a.DEBUG=!1,a._debugText=function(e,n,t){return e+(t?" on the "+t+" channel":"")+': "'+n+'"'},a.debugLog=function(e,n,t){a.DEBUG&&console&&console.warn&&console.warn(a._debugText(e,n,t))};var c=/\s+/;a._eventsApi=function(n,t,r,o){if(!r)return!1;var i={};if("object"===("undefined"==typeof r?"undefined":s["typeof"](r))){for(var u in r){var a=n[t].apply(n,[u,r[u]].concat(o));c.test(u)?e.extend(i,a):i[u]=a}return i}if(c.test(r)){for(var l=r.split(c),f=0,h=l.length;h>f;f++)i[l[f]]=n[t].apply(n,[l[f]].concat(o));return i}return!1},a._callHandler=function(e,n,t){var r=t[0],o=t[1],i=t[2];switch(t.length){case 0:return e.call(n);case 1:return e.call(n,r);case 2:return e.call(n,r,o);case 3:return e.call(n,r,o,i);default:return e.apply(n,t)}};var l={};e.extend(a,{log:function(n,t){if("undefined"!=typeof console){var r=e.drop(arguments,2);console.log("["+n+'] "'+t+'"',r)}},tuneIn:function(e){var n=a.channel(e);return n._tunedIn=!0,n.on("all",o(e)),this},tuneOut:function(e){var n=a.channel(e);return n._tunedIn=!1,n.off("all",o(e)),delete l[e],this}}),a.Requests={request:function(n){var t=e.rest(arguments),r=a._eventsApi(this,"request",n,t);if(r)return r;var o=this.channelName,i=this._requests;if(o&&this._tunedIn&&a.log.apply(this,[o,n].concat(t)),i&&(i[n]||i["default"])){var s=i[n]||i["default"];return t=i[n]?t:arguments,a._callHandler(s.callback,s.context,t)}a.debugLog("An unhandled request was fired",n,o)},reply:function(e,n,t){return a._eventsApi(this,"reply",e,[n,t])?this:(this._requests||(this._requests={}),this._requests[e]&&a.debugLog("A request was overwritten",e,this.channelName),this._requests[e]={callback:i(n),context:t||this},this)},replyOnce:function(n,t,r){if(a._eventsApi(this,"replyOnce",n,[t,r]))return this;var o=this,s=e.once(function(){return o.stopReplying(n),i(t).apply(this,arguments)});return this.reply(n,s,r)},stopReplying:function(e,n,t){return a._eventsApi(this,"stopReplying",e)?this:(e||n||t?r(this._requests,e,n,t)||a.debugLog("Attempted to remove the unregistered request",e,this.channelName):delete this._requests,this)}},a._channels={},a.channel=function(e){if(!e)throw new Error("You must provide a name for the channel.");return a._channels[e]?a._channels[e]:a._channels[e]=new a.Channel(e)},a.Channel=function(e){this.channelName=e},e.extend(a.Channel.prototype,n.Events,a.Requests,{reset:function(){return this.off(),this.stopListening(),this.stopReplying(),this}});var f,h,p=[n.Events,a.Requests];return e.each(p,function(n){e.each(n,function(n,t){a[t]=function(n){return h=e.rest(arguments),f=this.channel(n),f[t].apply(f,h)}})}),a.reset=function(n){var t=n?[this._channels[n]]:this._channels;e.invoke(t,"reset")},a});
//# sourceMappingURL=backbone.radio.min.js.map //# sourceMappingURL=backbone.radio.min.js.map

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

2
js/vendor/backbone.radio/gulpfile.babel.js поставляемый
Просмотреть файл

@ -106,8 +106,8 @@ function build(done) {
.pipe($.rename(exportFileName + '.min.js')) .pipe($.rename(exportFileName + '.min.js'))
.pipe($.sourcemaps.init({ loadMaps: true })) .pipe($.sourcemaps.init({ loadMaps: true }))
.pipe($.uglify()) .pipe($.uglify())
.pipe($.header(banner))
.pipe($.sourcemaps.write('./')) .pipe($.sourcemaps.write('./'))
.pipe($.header(banner))
.pipe(gulp.dest(destinationFolder)) .pipe(gulp.dest(destinationFolder))
.on('end', done); .on('end', done);
}).catch(console.error); }).catch(console.error);

81
js/vendor/backbone.radio/package.json поставляемый
Просмотреть файл

@ -2,7 +2,7 @@
"name": "backbone.radio", "name": "backbone.radio",
"description": "Messaging patterns for Backbone applications.", "description": "Messaging patterns for Backbone applications.",
"homepage": "https://github.com/marionettejs/backbone.radio", "homepage": "https://github.com/marionettejs/backbone.radio",
"version": "2.0.0", "version": "2.0.0-pre.1",
"main": "build/backbone.radio.js", "main": "build/backbone.radio.js",
"keywords": [ "keywords": [
"backbone", "backbone",
@ -41,48 +41,47 @@
}, },
"github": "https://github.com/marionettejs/backbone.radio", "github": "https://github.com/marionettejs/backbone.radio",
"peerDependencies": { "peerDependencies": {
"backbone": "^1.3.3", "backbone": "1.0.0 - 1.3.2",
"underscore": "^1.8.3" "underscore": "1.4.4 - 1.8.3"
}, },
"devDependencies": { "devDependencies": {
"babel-core": "6.7.0", "babel-core": "^6.3.26",
"babel-eslint": "6.0.4", "babel-eslint": "^4.1.6",
"babel-loader": "6.2.0", "babel-loader": "^6.2.0",
"babel-polyfill": "6.6.1", "babel-polyfill": "^6.3.14",
"babel-preset-es2015": "6.3.13", "babel-preset-es2015": "^6.3.13",
"babel-preset-es2015-rollup": "1.1.1", "babel-preset-es2015-rollup": "^1.1.1",
"babel-register": "6.4.3", "babel-register": "^6.3.13",
"backbone": ">=1.3.3 <1.4.0", "backbone": "1.0.0 - 1.3.2",
"chai": "3.4.1", "chai": "^3.4.1",
"del": "2.2.0", "del": "^2.2.0",
"eslint": "3.2.2", "glob": "^6.0.3",
"glob": "6.0.3", "gulp": "^3.9.0",
"gulp": "3.9.0", "gulp-eslint": "^1.1.1",
"gulp-eslint": "3.0.1", "gulp-file": "^0.2.0",
"gulp-file": "0.2.0", "gulp-filter": "^3.0.0",
"gulp-filter": "3.0.0", "gulp-header": "^1.7.1",
"gulp-header": "1.7.1", "gulp-istanbul": "^0.10.3",
"gulp-istanbul": "0.10.3", "gulp-jscs": "^3.0.0",
"gulp-jscs": "3.0.0", "gulp-livereload": "^3.8.1",
"gulp-livereload": "3.8.1", "gulp-load-plugins": "^1.1.0",
"gulp-load-plugins": "1.1.0", "gulp-mocha": "^2.2.0",
"gulp-mocha": "2.2.0", "gulp-plumber": "^1.0.1",
"gulp-plumber": "1.0.1", "gulp-rename": "^1.2.2",
"gulp-rename": "1.2.2", "gulp-sourcemaps": "^1.6.0",
"gulp-sourcemaps": "1.6.0", "gulp-uglify": "^1.5.1",
"gulp-uglify": "1.5.1", "gulp-util": "^3.0.7",
"gulp-util": "3.0.7", "isparta": "^4.0.0",
"isparta": "4.0.0", "json-loader": "^0.5.3",
"json-loader": "0.5.3", "mkdirp": "^0.5.1",
"mkdirp": "0.5.1", "mocha": "^2.3.4",
"mocha": "2.3.4", "rollup": "^0.25.4",
"rollup": "0.25.4", "rollup-plugin-babel": "^2.4.0",
"rollup-plugin-babel": "2.4.0", "sinon": "^1.17.2",
"sinon": "1.17.2", "sinon-chai": "^2.8.0",
"sinon-chai": "2.8.0", "underscore": "1.4.4 - 1.8.3",
"underscore": "1.8.3", "webpack": "^1.12.9",
"webpack": "1.12.9", "webpack-stream": "^3.1.0"
"webpack-stream": "3.1.0"
}, },
"babelBoilerplateOptions": { "babelBoilerplateOptions": {
"entryFileName": "backbone.radio", "entryFileName": "backbone.radio",

Просмотреть файл

@ -128,7 +128,7 @@ var _logs = {};
// This is to produce an identical function in both tuneIn and tuneOut, // This is to produce an identical function in both tuneIn and tuneOut,
// so that Backbone.Events unregisters it. // so that Backbone.Events unregisters it.
function _partial(channelName) { function _partial(channelName) {
return _logs[channelName] || (_logs[channelName] = _.bind(Radio.log, Radio, channelName)); return _logs[channelName] || (_logs[channelName] = _.partial(Radio.log, channelName));
} }
_.extend(Radio, { _.extend(Radio, {
@ -136,7 +136,7 @@ _.extend(Radio, {
// Log information about the channel and event // Log information about the channel and event
log: function(channelName, eventName) { log: function(channelName, eventName) {
if (typeof console === 'undefined') { return; } if (typeof console === 'undefined') { return; }
var args = _.toArray(arguments).slice(2); var args = _.drop(arguments, 2);
console.log('[' + channelName + '] "' + eventName + '"', args); console.log('[' + channelName + '] "' + eventName + '"', args);
}, },
@ -175,7 +175,7 @@ Radio.Requests = {
// Make a request // Make a request
request: function(name) { request: function(name) {
var args = _.toArray(arguments).slice(1); var args = _.rest(arguments);
var results = Radio._eventsApi(this, 'request', name, args); var results = Radio._eventsApi(this, 'request', name, args);
if (results) { if (results) {
return results; return results;
@ -308,7 +308,7 @@ var channel, args, systems = [Backbone.Events, Radio.Requests];
_.each(systems, function(system) { _.each(systems, function(system) {
_.each(system, function(method, methodName) { _.each(system, function(method, methodName) {
Radio[methodName] = function(channelName) { Radio[methodName] = function(channelName) {
args = _.toArray(arguments).slice(1); args = _.rest(arguments);
channel = this.channel(channelName); channel = this.channel(channelName);
return channel[methodName].apply(channel, args); return channel[methodName].apply(channel, args);
}; };
@ -317,7 +317,7 @@ _.each(systems, function(system) {
Radio.reset = function(channelName) { Radio.reset = function(channelName) {
var channels = !channelName ? this._channels : [this._channels[channelName]]; var channels = !channelName ? this._channels : [this._channels[channelName]];
_.each(channels, function(channel) { channel.reset();}); _.invoke(channels, 'reset');
}; };
export default Radio; export default Radio;

46
js/views/roomlistview.js Normal file
Просмотреть файл

@ -0,0 +1,46 @@
/* global Marionette, Handlebars */
/**
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
(function(OCA, Marionette, Handlebars) {
'use strict';
OCA.SpreedMe = OCA.SpreedMe || {};
OCA.SpreedMe.Views = OCA.SpreedMe.Views || {};
var ITEM_TEMPLATE = '<a href="#{{id}}">{{name}} <span class="utils">{{count}}</span></a>';
var RoomItenView = Marionette.View.extend({
tagName: 'li',
modelEvents: {
change: 'render'
},
template: Handlebars.compile(ITEM_TEMPLATE)
});
var RoomListView = Marionette.CollectionView.extend({
tagName: 'ul',
childView: RoomItenView
});
OCA.SpreedMe.Views.RoomListView = RoomListView;
})(OCA, Marionette, Handlebars);

Просмотреть файл

@ -103,7 +103,7 @@ $(document).ready(function() {
$('#app-content').removeClass('icon-loading'); $('#app-content').removeClass('icon-loading');
$('.videoView').removeClass('hidden'); $('.videoView').removeClass('hidden');
openEventSource(); openEventSource();
OCA.SpreedMe.Rooms.list(); OCA.SpreedMe.app.syncRooms();
}); });
webrtc.on('videoAdded', function (video, peer) { webrtc.on('videoAdded', function (video, peer) {

Просмотреть файл

@ -129,15 +129,15 @@ class ApiController extends Controller {
/** /**
* @NoAdminRequired * @NoAdminRequired
* *
* @param string $roomName * @param string $name
* @return JSONResponse * @return JSONResponse
*/ */
public function createRoom($roomName) { public function createRoom($name) {
$query = $this->dbConnection->getQueryBuilder(); $query = $this->dbConnection->getQueryBuilder();
$query->insert('spreedme_rooms') $query->insert('spreedme_rooms')
->values( ->values(
[ [
'name' => $query->createNamedParameter($roomName), 'name' => $query->createNamedParameter($name),
] ]
); );
@ -151,11 +151,9 @@ class ApiController extends Controller {
); );
} }
return new JSONResponse( return new JSONResponse([
[ 'id' => $query->getLastInsertId(),
'roomId' => $query->getLastInsertId(), ]);
]
);
} }
/** /**

Просмотреть файл

@ -8,6 +8,9 @@ script(
[ [
'vendor/backbone.radio/build/backbone.radio.min', 'vendor/backbone.radio/build/backbone.radio.min',
'vendor/backbone.marionette/lib/backbone.marionette.min', 'vendor/backbone.marionette/lib/backbone.marionette.min',
'models/room',
'models/roomcollection',
'views/roomlistview',
'simplewebrtc', 'simplewebrtc',
'xhrconnection', 'xhrconnection',
'rooms', 'rooms',