diff options
-rw-r--r-- | js/circles.v1.circles.js | 136 | ||||
-rw-r--r-- | js/circles.v1.js | 218 | ||||
-rw-r--r-- | js/circles.v1.members.js | 102 | ||||
-rw-r--r-- | lib/Api/v1/Circles.php | 19 | ||||
-rw-r--r-- | lib/Service/BroadcastService.php | 2 | ||||
-rw-r--r-- | templates/navigate.php | 4 |
6 files changed, 262 insertions, 219 deletions
diff --git a/js/circles.v1.circles.js b/js/circles.v1.circles.js new file mode 100644 index 00000000..6b85ea11 --- /dev/null +++ b/js/circles.v1.circles.js @@ -0,0 +1,136 @@ +/* + * Circles - Bring cloud-users closer together. + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Maxence Lange <maxence@pontapreta.net> + * @copyright 2017 + * @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/>. + * + */ + +/** global: OC */ +/** global: OCA */ + +var circles = { + + createCircle: function (type, name, callback) { + + var result = {status: -1}; + $.ajax({ + method: 'PUT', + url: OC.generateUrl('/apps/circles/v1/circles'), + data: { + type: type, + name: name + } + }).done(function (res) { + api.onCallback(callback, res); + }).fail(function () { + api.onCallback(callback, result); + }); + }, + + + listCircles: function (type, name, level, callback) { + var result = {status: -1}; + $.ajax({ + method: 'GET', + url: OC.generateUrl('/apps/circles/v1/circles'), + data: { + type: type, + name: name, + level: level + } + }).done(function (res) { + api.onCallback(callback, res); + }).fail(function () { + api.onCallback(callback, result); + }); + }, + + + detailsCircle: function (circleId, callback) { + var result = {status: -1}; + $.ajax({ + method: 'GET', + url: OC.generateUrl('/apps/circles/v1/circles/' + circleId) + }).done(function (res) { + api.onCallback(callback, res); + }).fail(function () { + api.onCallback(callback, result); + }); + }, + + + joinCircle: function (circleId, callback) { + var result = {status: -1}; + $.ajax({ + method: 'GET', + url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/join'), + data: {} + }).done(function (res) { + api.onCallback(callback, res); + }).fail(function () { + api.onCallback(callback, result); + }); + }, + + + settingsCircle: function (circleId, settings, callback) { + var result = {status: -1}; + $.ajax({ + method: 'POST', + url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/settings'), + data: {settings: settings} + }).done(function (res) { + api.onCallback(callback, res); + }).fail(function () { + api.onCallback(callback, result); + }); + }, + + + leaveCircle: function (circleId, callback) { + var result = {status: -1}; + $.ajax({ + method: 'GET', + url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/leave'), + data: {} + }).done(function (res) { + api.onCallback(callback, res); + }).fail(function () { + api.onCallback(callback, result); + }); + }, + + + destroyCircle: function (circleId, callback) { + var result = {status: -1}; + $.ajax({ + method: 'DELETE', + url: OC.generateUrl('/apps/circles/v1/circles/' + circleId), + data: {} + }).done(function (res) { + api.onCallback(callback, res); + }).fail(function () { + api.onCallback(callback, result); + }); + } + +}; + diff --git a/js/circles.v1.js b/js/circles.v1.js index 74cc66b5..ec854124 100644 --- a/js/circles.v1.js +++ b/js/circles.v1.js @@ -33,6 +33,10 @@ * @constructs Circles */ var Circles = function () { + + $.extend(Circles.prototype, circles); + $.extend(Circles.prototype, members); + this.initialize(); }; @@ -43,162 +47,6 @@ var self = this; - this.searchUsers = function (search, callback) { - - var result = {status: -1}; - $.ajax({ - method: 'GET', - url: OC.generateUrl('/apps/circles/v1/globalsearch'), - data: { - search: search - } - }).done(function (res) { - self.onCallback(callback, res); - }).fail(function () { - self.onCallback(callback, result); - }); - } - - - /** - * API function to create a new Circle. - * - * @param type - * @param name - * @param callback - */ - this.createCircle = function (type, name, callback) { - - var result = {status: -1}; - $.ajax({ - method: 'PUT', - url: OC.generateUrl('/apps/circles/v1/circles'), - data: { - type: type, - name: name - } - }).done(function (res) { - self.onCallback(callback, res); - }).fail(function () { - self.onCallback(callback, result); - }); - }; - - - this.listCircles = function (type, name, level, callback) { - var result = {status: -1}; - $.ajax({ - method: 'GET', - url: OC.generateUrl('/apps/circles/v1/circles'), - data: { - type: type, - name: name, - level: level - } - }).done(function (res) { - self.onCallback(callback, res); - }).fail(function () { - self.onCallback(callback, result); - }); - }; - - - this.detailsCircle = function (circleId, callback) { - var result = {status: -1}; - $.ajax({ - method: 'GET', - url: OC.generateUrl('/apps/circles/v1/circles/' + circleId) - }).done(function (res) { - self.onCallback(callback, res); - }).fail(function () { - self.onCallback(callback, result); - }); - }; - - - this.addMember = function (circleId, ident, type, callback) { - var result = {status: -1}; - $.ajax({ - method: 'PUT', - url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/member'), - data: { - ident: ident, - type: type - } - }).done(function (res) { - self.onCallback(callback, res); - }).fail(function () { - self.onCallback(callback, result); - }); - }; - - - // this.addEmail = function (circleId, email, callback) { - // var result = {status: -1}; - // $.ajax({ - // method: 'PUT', - // url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/email'), - // data: { - // email: email - // } - // }).done(function (res) { - // self.onCallback(callback, res); - // }).fail(function () { - // self.onCallback(callback, result); - // }); - // }; - - - // this.addGroupMembers = function (circleId, groupId, callback) { - // var result = {status: -1}; - // $.ajax({ - // method: 'PUT', - // url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/groupmembers'), - // data: { - // name: groupId - // } - // }).done(function (res) { - // self.onCallback(callback, res); - // }).fail(function () { - // self.onCallback(callback, result); - // }); - // }; - - - this.removeMember = function (circleId, userId, userType, callback) { - var result = {status: -1}; - $.ajax({ - method: 'DELETE', - url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/member'), - data: { - member: userId, - type: Number(userType) - } - }).done(function (res) { - self.onCallback(callback, res); - }).fail(function () { - self.onCallback(callback, result); - }); - }; - - - this.levelMember = function (circleId, userId, userType, level, callback) { - var result = {status: -1}; - $.ajax({ - method: 'POST', - url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/level'), - data: { - member: userId, - type: userType, - level: level - } - }).done(function (res) { - self.onCallback(callback, res); - }).fail(function () { - self.onCallback(callback, result); - }); - }; - this.linkGroup = function (circleId, groupId, callback) { var result = {status: -1}; @@ -249,62 +97,6 @@ }; - this.joinCircle = function (circleId, callback) { - var result = {status: -1}; - $.ajax({ - method: 'GET', - url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/join'), - data: {} - }).done(function (res) { - self.onCallback(callback, res); - }).fail(function () { - self.onCallback(callback, result); - }); - }; - - - this.settingsCircle = function (circleId, settings, callback) { - var result = {status: -1}; - $.ajax({ - method: 'POST', - url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/settings'), - data: {settings: settings} - }).done(function (res) { - self.onCallback(callback, res); - }).fail(function () { - self.onCallback(callback, result); - }); - }; - - - this.leaveCircle = function (circleId, callback) { - var result = {status: -1}; - $.ajax({ - method: 'GET', - url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/leave'), - data: {} - }).done(function (res) { - self.onCallback(callback, res); - }).fail(function () { - self.onCallback(callback, result); - }); - }; - - - this.destroyCircle = function (circleId, callback) { - var result = {status: -1}; - $.ajax({ - method: 'DELETE', - url: OC.generateUrl('/apps/circles/v1/circles/' + circleId), - data: {} - }).done(function (res) { - self.onCallback(callback, res); - }).fail(function () { - self.onCallback(callback, result); - }); - }; - - this.shareToCircle = function (circleId, source, type, item, callback) { var result = {status: -1}; $.ajax({ @@ -359,7 +151,7 @@ if (typeof result === 'object') { callback(result); } else { - callback({status: -1}) + callback({status: -1}); } } }; diff --git a/js/circles.v1.members.js b/js/circles.v1.members.js new file mode 100644 index 00000000..1127b333 --- /dev/null +++ b/js/circles.v1.members.js @@ -0,0 +1,102 @@ +/* + * Circles - Bring cloud-users closer together. + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Maxence Lange <maxence@pontapreta.net> + * @copyright 2017 + * @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/>. + * + */ + +/** global: OC */ +/** global: OCA */ + +var members = { + + + searchUsers: function (search, callback) { + + var result = {status: -1}; + $.ajax({ + method: 'GET', + url: OC.generateUrl('/apps/circles/v1/globalsearch'), + data: { + search: search + } + }).done(function (res) { + api.onCallback(callback, res); + }).fail(function () { + api.onCallback(callback, result); + }); + }, + + + addMember: function (circleId, ident, type, callback) { + var result = {status: -1}; + $.ajax({ + method: 'PUT', + url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/member'), + data: { + ident: ident, + type: type + } + }).done(function (res) { + api.onCallback(callback, res); + }).fail(function () { + api.onCallback(callback, result); + }); + }, + + + removeMember: function (circleId, userId, userType, callback) { + var result = {status: -1}; + $.ajax({ + method: 'DELETE', + url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/member'), + data: { + member: userId, + type: Number(userType) + } + }).done(function (res) { + api.onCallback(callback, res); + }).fail(function () { + api.onCallback(callback, result); + }); + }, + + + levelMember: function (circleId, userId, userType, level, callback) { + var result = {status: -1}; + $.ajax({ + method: 'POST', + url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/level'), + data: { + member: userId, + type: userType, + level: level + } + }).done(function (res) { + api.onCallback(callback, res); + }).fail(function () { + api.onCallback(callback, result); + }); + } + + +}; + diff --git a/lib/Api/v1/Circles.php b/lib/Api/v1/Circles.php index 3cd29a2d..5dc6de54 100644 --- a/lib/Api/v1/Circles.php +++ b/lib/Api/v1/Circles.php @@ -34,6 +34,7 @@ use OCA\Circles\Model\FederatedLink; use OCA\Circles\Model\Member; use OCA\Circles\Model\SharingFrame; use OCA\Circles\Service\MiscService; +use OCP\Util; class Circles { @@ -58,6 +59,13 @@ class Circles { } + public static function addJavascriptAPI() { + Util::addScript(Application::APP_NAME, 'circles.v1.circles'); + Util::addScript(Application::APP_NAME, 'circles.v1.members'); + Util::addScript(Application::APP_NAME, 'circles.v1'); + } + + /** * Circles::compareVersion(); * @@ -420,9 +428,14 @@ class Circles { public static function generateCircleParameter(SharingFrame $frame) { return [ 'type' => 'circle', - 'id' => $frame->getCircle()->getUniqueId(), - 'name' => $frame->getCircle()->getName(), - 'link' => self::generateLink($frame->getCircle()->getUniqueId()) + 'id' => $frame->getCircle() + ->getUniqueId(), + 'name' => $frame->getCircle() + ->getName(), + 'link' => self::generateLink( + $frame->getCircle() + ->getUniqueId() + ) ]; } }
\ No newline at end of file diff --git a/lib/Service/BroadcastService.php b/lib/Service/BroadcastService.php index c3b5a94e..03b1eb43 100644 --- a/lib/Service/BroadcastService.php +++ b/lib/Service/BroadcastService.php @@ -117,13 +117,11 @@ class BroadcastService { $members = $this->membersRequest->forceGetMembers( $circle->getUniqueId(), Member::LEVEL_MEMBER, true ); - $this->miscService->log('___>'); foreach ($members AS $member) { $this->parseMember($member); if ($member->isBroadcasting()) { - $this->miscService->log('___ ' . $member->getUserId()); $broadcaster->createShareToMember($frame, $member); } } diff --git a/templates/navigate.php b/templates/navigate.php index 4413c1c7..bd22fe5a 100644 --- a/templates/navigate.php +++ b/templates/navigate.php @@ -24,14 +24,16 @@ * */ +use OCA\Circles\Api\v1\Circles; use OCA\Circles\AppInfo\Application; script(Application::APP_NAME, 'vendor/notyf'); style(Application::APP_NAME, 'notyf'); +Circles::addJavascriptAPI(); script( Application::APP_NAME, [ - 'circles.v1', 'circles.app.elements', 'circles.app.actions', + 'circles.app.elements', 'circles.app.actions', 'circles.app.navigation', 'circles.app.settings', 'circles.app', 'circles.app.results.circles', 'circles.app.results.members', 'circles.app.results.groups', 'circles.app.results.links' |