2019-10-15 09:10:56 -04:00
|
|
|
define(['base'], App => {
|
2019-07-16 05:13:18 -04:00
|
|
|
App.controller('ShareController', function(
|
|
|
|
$scope,
|
|
|
|
$modal,
|
|
|
|
ide,
|
|
|
|
projectInvites,
|
|
|
|
projectMembers,
|
2019-10-15 09:10:56 -04:00
|
|
|
// eslint-disable-next-line camelcase
|
2019-07-16 05:13:18 -04:00
|
|
|
event_tracking
|
|
|
|
) {
|
|
|
|
$scope.openShareProjectModal = function(isAdmin) {
|
|
|
|
$scope.isAdmin = isAdmin
|
|
|
|
event_tracking.sendMBOnce('ide-open-share-modal-once')
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2019-10-15 09:10:56 -04:00
|
|
|
$modal.open({
|
2019-07-16 05:13:18 -04:00
|
|
|
templateUrl: 'shareProjectModalTemplate',
|
|
|
|
controller: 'ShareProjectModalController',
|
|
|
|
scope: $scope
|
2018-11-05 05:06:39 -05:00
|
|
|
})
|
|
|
|
}
|
2019-07-16 05:13:18 -04:00
|
|
|
|
|
|
|
ide.socket.on('project:tokens:changed', data => {
|
|
|
|
if (data.tokens != null) {
|
|
|
|
ide.$scope.project.tokens = data.tokens
|
2019-10-15 09:10:56 -04:00
|
|
|
$scope.$digest()
|
2019-07-16 05:13:18 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-10-15 09:10:56 -04:00
|
|
|
ide.socket.on('project:membership:changed', data => {
|
2019-07-16 05:13:18 -04:00
|
|
|
if (data.members) {
|
|
|
|
projectMembers
|
|
|
|
.getMembers()
|
|
|
|
.then(response => {
|
2019-10-15 09:10:56 -04:00
|
|
|
if (response.data.members) {
|
|
|
|
$scope.project.members = response.data.members
|
2019-07-16 05:13:18 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(() => {
|
2019-10-15 09:10:56 -04:00
|
|
|
console.error('Error fetching members for project')
|
2019-07-16 05:13:18 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
if (data.invites) {
|
2019-10-15 09:10:56 -04:00
|
|
|
projectInvites
|
2019-07-16 05:13:18 -04:00
|
|
|
.getInvites()
|
|
|
|
.then(response => {
|
2019-10-15 09:10:56 -04:00
|
|
|
if (response.data.invites) {
|
|
|
|
$scope.project.invites = response.data.invites
|
2019-07-16 05:13:18 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(() => {
|
2019-10-15 09:10:56 -04:00
|
|
|
console.error('Error fetching invites for project')
|
2019-07-16 05:13:18 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
2019-10-15 09:10:56 -04:00
|
|
|
})
|
|
|
|
})
|