added dropbox in left menu

This commit is contained in:
Henry Oswald 2014-07-17 14:20:29 +01:00
parent b428a8fb7d
commit 5fa83fb2b9
6 changed files with 112 additions and 0 deletions

View file

@ -60,6 +60,7 @@ block content
include ./editor/binary-file
include ./editor/track-changes
include ./editor/publish-template
include ./editor/dropbox
.ui-layout-east
include ./editor/chat

View file

@ -0,0 +1,45 @@
script(type="text/ng-template", id="dropboxModalTemplate")
.modal-header
button.close(
type="button"
data-dismiss="modal"
ng-click="cancel()"
) ×
h3 Dropbox link
.modal-body.modal-body-share
div(ng-show="dbState.gotLinkStatus")
div(ng-hide="dbState.userIsLinkedToDropbox || !dbState.hasDropboxFeature")
span(ng-hide="dbState.startedLinkProcess") Your account is not linked to dropbox
|    
a(ng-click="linkToDropbox()").btn.btn-info Update Dropbox Settings
p.small.text-center(ng-show="dbState.startedLinkProcess")
| Please refresh this page after starting your free trial.
div(ng-show="dbState.hasDropboxFeature && dbState.userIsLinkedToDropbox")
progressbar.progress-striped.active(value='percentageLeftTillNextPoll', type="info")
span
strong {{dbState.minsTillNextPoll}} minutes
span until dropbox is next checked for changes.
div.text-center(ng-hide="dbState.hasDropboxFeature")
p You need to upgrade your account to link to dropbox.
p
a.btn.btn-info(ng-click="startFreeTrial('dropbox')") Start Free Trial
p.small(ng-show="startedFreeTrial")
| Please refresh this page after starting your free trial.
div(ng-hide="dbState.gotLinkStatus")
span.small   checking dropbox status  
i.fa.fa-refresh.fa-spin
.modal-footer()
button.btn.btn-default(
ng-click="cancel()",
)
span Dismiss

View file

@ -39,6 +39,15 @@ aside#left-menu.full-size(
i.fa.fa-external-link.fa-fw
|   Publish as Template
span(ng-controller="DropboxController")
h4() Sync
ul.list-unstyled.nav()
li
a(ng-click="openDropboxModal()")
i.fa.fa-dropbox.fa-fw
|    Dropbox
h4 Settings
form.settings(ng-controller="SettingsController")
.containter-fluid

View file

@ -12,6 +12,7 @@ define [
"ide/share/index"
"ide/chat/index"
"ide/templates/index"
"ide/dropbox/index"
"ide/directives/layout"
"ide/services/ide"
"directives/focus"

View file

@ -0,0 +1,52 @@
define [
"base"
"ide/permissions/PermissionsManager"
], (App, PermissionsManager) ->
POLLING_INTERVAL = 15
ONE_MIN_MILI = 1000 * 60
cachedState =
gotLinkStatus: false
startedLinkProcess: false
userIsLinkedToDropbox: false
hasDropboxFeature: false
App.controller "DropboxController", ($scope, $modal, ide) ->
$scope.openDropboxModal = () ->
$modal.open {
templateUrl: "dropboxModalTemplate"
controller: "DropboxModalController"
scope:$scope
}
App.controller "DropboxModalController", ($scope, $modalInstance, ide, $timeout) ->
user_id = ide.$scope.user.id
$scope.dbState = cachedState
$scope.dbState.hasDropboxFeature = $scope.project.features.dropbox
calculatePollTime = ->
ide.socket.emit "getLastTimePollHappned", (err, lastTimePollHappened)=>
milisecondsSinceLastPoll = new Date().getTime() - lastTimePollHappened
roundedMinsSinceLastPoll = Math.round(milisecondsSinceLastPoll / ONE_MIN_MILI)
$scope.dbState.minsTillNextPoll = POLLING_INTERVAL - roundedMinsSinceLastPoll
$scope.dbState.percentageLeftTillNextPoll = 100 - ((roundedMinsSinceLastPoll / POLLING_INTERVAL) * 100)
$timeout calculatePollTime, 60 * 1000
ide.socket.emit "getUserDropboxLinkStatus", user_id, (err, status)=>
if status.registered
calculatePollTime()
$scope.dbState.userIsLinkedToDropbox = true
$scope.dbState.gotLinkStatus = true
cachedState = $scope.dbState
$scope.linkToDropbox = ->
window.open("/user/settings#dropboxSettings")
$scope.startedLinkProcess = true
$scope.cancel = () ->
$modalInstance.dismiss()

View file

@ -0,0 +1,4 @@
define [
"ide/dropbox/controllers/DropboxController"
], () ->