From 4aa4e3f9e84f835e73f388502cd9e7b6222acf75 Mon Sep 17 00:00:00 2001 From: Simon Eisenmann Date: Wed, 11 Jun 2014 18:03:16 +0200 Subject: [PATCH] Implemented settings users controller as overrideable. --- static/js/controllers/controllers.js | 6 +- .../js/controllers/usersettingscontroller.js | 66 +++++++++++++++++++ static/js/directives/settings.js | 36 ---------- static/partials/settings.html | 48 +++++++------- 4 files changed, 94 insertions(+), 62 deletions(-) create mode 100644 static/js/controllers/usersettingscontroller.js diff --git a/static/js/controllers/controllers.js b/static/js/controllers/controllers.js index 6d3411d8..24b7c56b 100644 --- a/static/js/controllers/controllers.js +++ b/static/js/controllers/controllers.js @@ -24,13 +24,15 @@ define([ 'controllers/mediastreamcontroller', 'controllers/statusmessagecontroller', 'controllers/chatroomcontroller', - 'controllers/roomchangecontroller'], function(_, MediastreamController, StatusmessageController, ChatroomController, RoomchangeController) { + 'controllers/roomchangecontroller', + 'controllers/usersettingscontroller'], function(_, MediastreamController, StatusmessageController, ChatroomController, RoomchangeController, UsersettingsController) { var controllers = { MediastreamController: MediastreamController, StatusmessageController: StatusmessageController, ChatroomController: ChatroomController, - RoomchangeController: RoomchangeController + RoomchangeController: RoomchangeController, + UsersettingsController: UsersettingsController }; var initialize = function(angModule) { diff --git a/static/js/controllers/usersettingscontroller.js b/static/js/controllers/usersettingscontroller.js new file mode 100644 index 00000000..2baee76d --- /dev/null +++ b/static/js/controllers/usersettingscontroller.js @@ -0,0 +1,66 @@ +/* + * Spreed WebRTC. + * Copyright (C) 2013-2014 struktur AG + * + * This file is part of Spreed WebRTC. + * + * 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 . + * + */ +define([], function() { + + // UsersettingsController + return ["$scope", "$element", "mediaStream", function($scope, $element, mediaStream) { + + $scope.withUsersForget = true; + + this.registerUserid = function(btn) { + + var successHandler = function(data) { + console.info("Created new userid:", data.userid); + // If the server provided us a nonce, we can do everthing on our own. + mediaStream.users.store(data); + $scope.loadedUserlogin = true; + safeApply($scope); + // Directly authenticate ourselves with the provided nonce. + mediaStream.api.requestAuthentication(data.userid, data.nonce); + delete data.nonce; + }; + + console.log("No userid - creating one ..."); + mediaStream.users.register(btn.form, function(data) { + if (data.nonce) { + successHandler(data); + } else { + // No nonce received. So this means something we cannot do on our own. + // Make are GET request and retrieve nonce that way and let the + // browser/server do the rest. + mediaStream.users.authorize(data, successHandler, function(data, status) { + console.error("Failed to get nonce after create", status, data); + }); + } + }, function(data, status) { + console.error("Failed to create userid", status, data); + }); + + }; + + this.forgetUserid = function() { + mediaStream.users.forget(); + mediaStream.connector.forgetAndReconnect(); + }; + + }]; + +}); diff --git a/static/js/directives/settings.js b/static/js/directives/settings.js index 6716aa05..a05ec15a 100644 --- a/static/js/directives/settings.js +++ b/static/js/directives/settings.js @@ -74,42 +74,6 @@ define(['jquery', 'underscore', 'text!partials/settings.html'], function($, _, t }); }; - $scope.registerUserid = function(btn) { - - var successHandler = function(data) { - console.info("Created new userid:", data.userid); - // If the server provided us a nonce, we can do everthing on our own. - mediaStream.users.store(data); - $scope.loadedUserlogin = true; - safeApply($scope); - // Directly authenticate ourselves with the provided nonce. - mediaStream.api.requestAuthentication(data.userid, data.nonce); - delete data.nonce; - }; - - console.log("No userid - creating one ..."); - mediaStream.users.register(btn.form, function(data) { - if (data.nonce) { - successHandler(data); - } else { - // No nonce received. So this means something we cannot do on our own. - // Make are GET request and retrieve nonce that way and let the - // browser/server do the rest. - mediaStream.users.authorize(data, successHandler, function(data, status) { - console.error("Failed to get nonce after create", status, data); - }); - } - }, function(data, status) { - console.error("Failed to create userid", status, data); - }); - - }; - - $scope.forgetUserid = function() { - mediaStream.users.forget(); - mediaStream.connector.forgetAndReconnect(); - }; - $scope.checkDefaultMediaSources = function() { if ($scope.master.settings.microphoneId && !$scope.mediaSources.hasAudioId($scope.master.settings.microphoneId)) { $scope.master.settings.microphoneId = null; diff --git a/static/partials/settings.html b/static/partials/settings.html index 8a53772d..abb955fa 100644 --- a/static/partials/settings.html +++ b/static/partials/settings.html @@ -19,35 +19,35 @@ {{_('Your picture and name are visible to others.')}} -
- -
-
-
- +
+
+ +
+ +
+ + + +
+
+
{{userid}}
+ {{_('Authenticated by certificate. To log out you have to remove your certificate from the browser.')}} +
+ +
+
{{userid}}
+ - -
-
-
{{userid}}
- {{_('Authenticated by certificate. To log out you have to remove your certificate from the browser.')}}
- -
- -
{{userid}}
-
-
- {{_('Only register an ID if this is your private browser.')}} -