diff --git a/src/styles/components/_social.scss b/src/styles/components/_social.scss index 125d564a..be7b2ced 100644 --- a/src/styles/components/_social.scss +++ b/src/styles/components/_social.scss @@ -20,6 +20,10 @@ */ .#{$fa-css-prefix} { + &.pin { + color: $social-email-color; + } + &.link { color: $social-email-color; } diff --git a/static/js/directives/socialshare.js b/static/js/directives/socialshare.js index a0576251..8401d0a9 100644 --- a/static/js/directives/socialshare.js +++ b/static/js/directives/socialshare.js @@ -49,6 +49,7 @@ define(['text!partials/socialshare.html'], function(template) { replace: true, link: function($scope, $element, $attr) { $scope.$on("room.updated", function(ev, room) { + $scope.isRoomLocked = rooms.isLocked(); $scope.roomlink = rooms.link(room); }); $scope.$on("room.left", function(ev) { @@ -69,6 +70,22 @@ define(['text!partials/socialshare.html'], function(template) { if (nw === "link") { //$window.alert("Room link: " + $scope.roomlink); alertify.dialog.notify(translation._("Room link"), ''+$scope.roomlink+''); + } else if (nw === "pin") { + if (!$scope.isRoomLocked) { + // Lock + alertify.dialog.prompt(translation._("Please enter a new Room PIN to lock the room"), function(pin) { + rooms.setPIN(pin); + }, function() { + // Do nothing + }); + } else { + // Unlock + alertify.dialog.confirm(translation._("Do you want to unlock the room?"), function() { + rooms.setPIN(""); + }, function() { + // Do nothing + }); + } } } }); diff --git a/static/js/services/rooms.js b/static/js/services/rooms.js index bf4f5ff7..faa99347 100644 --- a/static/js/services/rooms.js +++ b/static/js/services/rooms.js @@ -260,12 +260,13 @@ define([ console.log("Failed to set room PIN", error); return $q.reject(error); }); + }, + isLocked: function(room) { + room = room || currentRoom.Name + return roompin.get(room) !== null; } }; - // NOTE(lcooper): For debugging only, do not use this on production. - $window.setRoomPIN = rooms.setPIN; - return rooms; - }]; + }]; }); diff --git a/static/partials/socialshare.html b/static/partials/socialshare.html index ad2ae588..a72f3349 100644 --- a/static/partials/socialshare.html +++ b/static/partials/socialshare.html @@ -1,4 +1,5 @@
+