(function () { "use strict"; var streamApp = angular.module('streamApp'); streamApp.directive('connectionsDirective', ['sharingService', 'groupsService', ConnectionsDirective]); function ConnectionsDirective(sharingService, groupsService) { return { restrict: 'E', scope: { reload: '=', connections: '=' }, templateUrl: '/App/Directives/connectionsDirective/connectionsDirective.html?v=6.0.0c', link: function (scope, element, attrs, tabsCtrl) { scope.$watch('reload', function () { GetData(); }); function GetData() { sharingService.getContacts().then(function (data) { scope.connections = data.data; }); } scope.getData = GetData; GetData(); scope.remove = function (connection) { connection.removeTrue = !connection.removeTrue; connection.message = ['You can not undo this - are you sure you want to remove ' + connection.Name + '?']; }; scope.finalRemove = function (connection) { sharingService.delete(connection.Id).then(function (data) { scope.connections.remove(connection, 'Id'); }).catch(error => console.log(error)); }; scope.viewTags = function (connection) { if (connection.open) { connection.open = false; } else { connection.open = true; sharingService.getViewerTags(connection.Id).then(function (data) { connection.tags = data.data.ViewerTags; }); } }; scope.addTag = function (connection, tag) { if (tag.canNotEdit) { tag.selected = true; return; } sharingService.updateTag(connection.Id, connection.tags.filter(t => t.selected).map(t => t.tagId)); }; scope.updateName = function (connection) { connection.updateName = !connection.updateName; connection.tempName = connection.Name; }; scope.saveName = function (connection) { sharingService.updateName(connection.Id, connection.tempName).then(function (name) { connection.Name = name; connection.updateName = false; }); }; scope.email = function (connection) { sharingService.updateEmailNotification(connection.Id).then(function () { connection.EmailNotifications = !connection.EmailNotifications; }); }; } }; } }());