DropboxController.coffee 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. define [
  2. "base"
  3. "ide/permissions/PermissionsManager"
  4. ], (App, PermissionsManager) ->
  5. POLLING_INTERVAL = 15
  6. ONE_MIN_MILI = 1000 * 60
  7. cachedState =
  8. gotLinkStatus: false
  9. startedLinkProcess: false
  10. userIsLinkedToDropbox: false
  11. hasDropboxFeature: false
  12. App.controller "DropboxController", ($scope, $modal, ide) ->
  13. $scope.openDropboxModal = () ->
  14. $modal.open {
  15. templateUrl: "dropboxModalTemplate"
  16. controller: "DropboxModalController"
  17. scope:$scope
  18. }
  19. App.controller "DropboxModalController", ($scope, $modalInstance, ide, $timeout) ->
  20. user_id = ide.$scope.user.id
  21. $scope.dbState = cachedState
  22. $scope.dbState.hasDropboxFeature = $scope.project.features.dropbox
  23. ide.socket.emit "getUserDropboxLinkStatus", user_id, (err, status)=>
  24. $scope.dbState.gotLinkStatus = true
  25. if status.registered
  26. $scope.dbState.userIsLinkedToDropbox = true
  27. cachedState = $scope.dbState
  28. $scope.linkToDropbox = ->
  29. window.open("/user/settings#dropboxSettings")
  30. $scope.startedLinkProcess = true
  31. $scope.cancel = () ->
  32. $modalInstance.dismiss()