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