diff --git a/static/js/controllers/contactsmanagercontroller.js b/static/js/controllers/contactsmanagercontroller.js
index 51e354d2..bd32899c 100644
--- a/static/js/controllers/contactsmanagercontroller.js
+++ b/static/js/controllers/contactsmanagercontroller.js
@@ -21,11 +21,21 @@
define([], function() {
// ContactsmanagerController
- return ["$scope", "$modalInstance", "contactData", "data", "contacts", function($scope, $modalInstance, contactData, data, contacts) {
-
+ return ["$scope", "$modalInstance", "contactData", "data", "contacts", 'dialogs', 'translation', function($scope, $modalInstance, contactData, data, contacts, dialogs, translation) {
$scope.header = data.header;
$scope.contacts = [];
- $scope.search = {};
+ $scope.openContactsManagerEdit = function(contact) {
+ return dialogs.create(
+ "/contactsmanager/edit.html",
+ "ContactsmanagereditController",
+ {
+ header: translation._("Edit Contact"),
+ contact: contact,
+ }, {
+ wc: "contactsmanager"
+ }
+ );
+ };
var updateContacts = function() {
$scope.contacts = contactData.getAll();
@@ -34,11 +44,12 @@ define([], function() {
contacts.e.on('contactadded', function() {
updateContacts();
});
-
- $scope.removeContact = function(id) {
- contacts.remove(id);
+ contacts.e.on('contactupdated', function() {
updateContacts();
- };
+ });
+ contacts.e.on('contactremoved', function() {
+ updateContacts();
+ });
}];
diff --git a/static/js/controllers/contactsmanagereditcontroller.js b/static/js/controllers/contactsmanagereditcontroller.js
new file mode 100644
index 00000000..cc4b01bb
--- /dev/null
+++ b/static/js/controllers/contactsmanagereditcontroller.js
@@ -0,0 +1,67 @@
+/*
+ * 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() {
+
+ // ContactsmanagereditController
+ return ["$scope", "$modalInstance", "data", "contacts", 'buddyData', function($scope, $modalInstance, data, contacts, buddyData) {
+ $scope.header = data.header;
+ $scope.contact = data.contact ? data.contact : null;
+ $scope.buddySyncable = false;
+
+ var originalDisplayName = null;
+ var setContactInfo = function(contact) {
+ contacts.update(contact);
+ };
+ if ($scope.contact) {
+ originalDisplayName = $scope.contact.Status.displayName;
+ var scope = buddyData.lookup($scope.contact.Userid, false, false);
+ if (scope) {
+ var session = scope.session.get();
+ $scope.buddySyncable = session && session.Type ? true : false;
+ }
+ }
+
+ $scope.removeContact = function() {
+ contacts.remove($scope.contact.Userid);
+ $modalInstance.close();
+ };
+
+ $scope.syncContactInfo = function() {
+ var scope = buddyData.lookup($scope.contact.Userid, false, false);
+ if (scope) {
+ var session = scope.session.get();
+ $scope.contact.Status.displayName = session.Status.displayName;
+ }
+ };
+
+ $scope.save = function() {
+ setContactInfo($scope.contact);
+ $modalInstance.close();
+ };
+
+ $scope.cancel = function(contact) {
+ $scope.contact.Status.displayName = originalDisplayName;
+ $modalInstance.dismiss();
+ };
+
+ }];
+
+});
diff --git a/static/js/controllers/controllers.js b/static/js/controllers/controllers.js
index 26b18ddf..e0d385d2 100644
--- a/static/js/controllers/controllers.js
+++ b/static/js/controllers/controllers.js
@@ -26,7 +26,8 @@ define([
'controllers/chatroomcontroller',
'controllers/roomchangecontroller',
'controllers/usersettingscontroller',
- 'controllers/contactsmanagercontroller'], function(_, MediastreamController, StatusmessageController, ChatroomController, RoomchangeController, UsersettingsController, ContactsmanagerController) {
+ 'controllers/contactsmanagercontroller',
+ 'controllers/contactsmanagereditcontroller'], function(_, MediastreamController, StatusmessageController, ChatroomController, RoomchangeController, UsersettingsController, ContactsmanagerController, ContactsmanagereditController) {
var controllers = {
MediastreamController: MediastreamController,
@@ -34,7 +35,8 @@ define([
ChatroomController: ChatroomController,
RoomchangeController: RoomchangeController,
UsersettingsController: UsersettingsController,
- ContactsmanagerController: ContactsmanagerController
+ ContactsmanagerController: ContactsmanagerController,
+ ContactsmanagereditController: ContactsmanagereditController
};
var initialize = function(angModule) {
diff --git a/static/js/directives/buddylist.js b/static/js/directives/buddylist.js
index e3c71d5f..b458d768 100644
--- a/static/js/directives/buddylist.js
+++ b/static/js/directives/buddylist.js
@@ -84,6 +84,7 @@ define(['underscore', 'text!partials/buddylist.html'], function(_, template) {
var onStatus = _.bind(buddylist.onStatus, buddylist);
var onContactAdded = _.bind(buddylist.onContactAdded, buddylist);
var onContactRemoved = _.bind(buddylist.onContactRemoved, buddylist);
+ var onContactUpdated = _.bind(buddylist.onContactUpdated, buddylist);
mediaStream.api.e.on("received.userleftorjoined", function(event, dataType, data) {
if (dataType === "Left") {
onLeft(data);
@@ -119,6 +120,9 @@ define(['underscore', 'text!partials/buddylist.html'], function(_, template) {
contacts.e.on("contactremoved", function(event, data) {
onContactRemoved(data);
});
+ contacts.e.on("contactupdated", function(event, data) {
+ onContactUpdated(data);
+ });
}];
diff --git a/static/js/directives/settings.js b/static/js/directives/settings.js
index 83cf2805..5465bd50 100644
--- a/static/js/directives/settings.js
+++ b/static/js/directives/settings.js
@@ -85,7 +85,7 @@ define(['jquery', 'underscore', 'text!partials/settings.html'], function($, _, t
};
$scope.openContactsManager = function() {
- dialogs.create(
+ return dialogs.create(
"/contactsmanager/main.html",
"ContactsmanagerController",
{
@@ -93,7 +93,7 @@ define(['jquery', 'underscore', 'text!partials/settings.html'], function($, _, t
}, {
wc: "contactsmanager"
}
- )
+ );
};
$scope.checkDefaultMediaSources = function() {
diff --git a/static/js/services/buddylist.js b/static/js/services/buddylist.js
index ba7e4afe..d2071ab5 100644
--- a/static/js/services/buddylist.js
+++ b/static/js/services/buddylist.js
@@ -18,7 +18,7 @@
* along with this program. If not, see .
*
*/
-define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!partials/buddyactions.html', 'text!partials/buddyactionsforaudiomixer.html'], function(_, Modernizr, AvlTree, templateBuddy, templateBuddyActions, templateBuddyActionsForAudioMixer) {
+define(['angular', 'underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!partials/buddyactions.html', 'text!partials/buddyactionsforaudiomixer.html'], function(angular, _, Modernizr, AvlTree, templateBuddy, templateBuddyActions, templateBuddyActionsForAudioMixer) {
var BuddyTree = function() {
@@ -450,6 +450,15 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
};
+ Buddylist.prototype.onContactUpdated = function(data) {
+ var scope = buddyData.get(data.Userid);
+ if (scope && scope.contact) {
+ scope.contact.Status = angular.extend(scope.contact.Status, data.Status);
+ }
+ this.updateDisplay(data.Id, scope, data, "status");
+ //console.log("onContactUpdated", 'data', data, 'scope', scope);
+ };
+
Buddylist.prototype.onStatus = function(data) {
//console.log("onStatus", data);
diff --git a/static/js/services/contacts.js b/static/js/services/contacts.js
index 76b57ec1..efe49078 100644
--- a/static/js/services/contacts.js
+++ b/static/js/services/contacts.js
@@ -18,7 +18,7 @@
* along with this program. If not, see .
*
*/
-define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmanager.html'], function(underscore, $, Modernizr, sjcl, templateContactsManager) {
+define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmanager.html', 'text!partials/contactsmanageredit.html'], function(_, $, Modernizr, sjcl, templateContactsManager, templateContactsManagerEdit) {
var Database = function(name) {
this.version = 3;
@@ -36,6 +36,7 @@ define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmana
console.info("Created contacts database.")
};
request.onsuccess = _.bind(that.onsuccess, that);
+ request.onerror = _.bind(that.onerror, that);
};
Database.prototype.init = function(db) {
var createOrUpdateStore = function(name, obj) {
@@ -124,6 +125,7 @@ define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmana
// Inject our templates.
$templateCache.put('/contactsmanager/main.html', templateContactsManager);
+ $templateCache.put('/contactsmanager/edit.html', templateContactsManagerEdit);
var Contacts = function() {
@@ -155,6 +157,13 @@ define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmana
};
+ Contacts.prototype.put = function(contact) {
+ this.database.put("contacts", {
+ id: this.id(contact.Userid),
+ contact: this.encrypt(contact)
+ });
+ }
+
Contacts.prototype.open = function(userid, suserid) {
if (this.database && (!userid || this.userid !== userid)) {
@@ -241,10 +250,7 @@ define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmana
var contact = contactData.addByRequest(request, status);
this.e.triggerHandler("contactadded", contact);
if (this.database) {
- this.database.put("contacts", {
- id: this.id(contact.Userid),
- contact: this.encrypt(contact)
- })
+ this.put(contact);
}
};
@@ -260,6 +266,12 @@ define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmana
}
};
+ Contacts.prototype.update = function(contact) {
+ this.put(contact);
+ //console.log("contact update", contact);
+ this.e.triggerHandler("contactupdated", contact);
+ };
+
return new Contacts();
}];
diff --git a/static/partials/contactsmanager.html b/static/partials/contactsmanager.html
index 2e442f64..2269880d 100644
--- a/static/partials/contactsmanager.html
+++ b/static/partials/contactsmanager.html
@@ -14,10 +14,10 @@
![]()
- {{contact.Status.displayName}}
+ {{contact.Userid|displayName}}
|
-
+
|
diff --git a/static/partials/contactsmanageredit.html b/static/partials/contactsmanageredit.html
new file mode 100644
index 00000000..703d52ff
--- /dev/null
+++ b/static/partials/contactsmanageredit.html
@@ -0,0 +1,35 @@
+