overleaf/services/web/public/coffee/ide/share/controllers/ShareController.coffee

43 lines
1.3 KiB
CoffeeScript
Raw Normal View History

2014-07-08 07:02:26 -04:00
define [
"base"
], (App) ->
App.controller "ShareController", ["$scope", "$modal", "ide", "projectInvites", "projectMembers", "event_tracking",
($scope, $modal, ide, projectInvites, projectMembers, event_tracking) ->
$scope.openShareProjectModal = () ->
event_tracking.sendMBOnce "ide-open-share-modal-once"
2016-07-05 09:32:56 -04:00
$modal.open(
templateUrl: "shareProjectModalTemplate"
controller: "ShareProjectModalController"
scope: $scope
)
ide.socket.on 'project:tokens:changed', (data) =>
if data.tokens?
ide.$scope.project.tokens = data.tokens
$scope.$digest()
ide.socket.on 'project:publicAccessLevel:changed', (data) =>
if data.newAccessLevel?
ide.$scope.project.publicAccesLevel = data.newAccessLevel
$scope.$digest()
ide.socket.on 'project:membership:changed', (data) =>
if data.members
2016-08-05 09:09:37 -04:00
projectMembers.getMembers()
.then (response) =>
{ data } = response
if data.members
$scope.project.members = data.members
.catch () =>
2016-08-05 09:09:37 -04:00
console.error "Error fetching members for project"
if data.invites
2016-08-05 09:09:37 -04:00
projectInvites.getInvites()
.then (response) =>
{ data } = response
if data.invites
$scope.project.invites = data.invites
.catch () =>
2016-08-05 09:09:37 -04:00
console.error "Error fetching invites for project"
2014-07-08 07:02:26 -04:00
]