diff --git a/services/web/app/views/project/editor.jade b/services/web/app/views/project/editor.jade index 8396d4ddd8..7801af262b 100644 --- a/services/web/app/views/project/editor.jade +++ b/services/web/app/views/project/editor.jade @@ -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 diff --git a/services/web/app/views/project/editor/dropbox.jade b/services/web/app/views/project/editor/dropbox.jade new file mode 100644 index 0000000000..1f3153d929 --- /dev/null +++ b/services/web/app/views/project/editor/dropbox.jade @@ -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 diff --git a/services/web/app/views/project/editor/left-menu.jade b/services/web/app/views/project/editor/left-menu.jade index 9aa630cd3f..ce06f82dcc 100644 --- a/services/web/app/views/project/editor/left-menu.jade +++ b/services/web/app/views/project/editor/left-menu.jade @@ -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 diff --git a/services/web/public/coffee/ide.coffee b/services/web/public/coffee/ide.coffee index aedac82ec6..7e311119a7 100644 --- a/services/web/public/coffee/ide.coffee +++ b/services/web/public/coffee/ide.coffee @@ -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" diff --git a/services/web/public/coffee/ide/dropbox/controllers/DropboxController.coffee b/services/web/public/coffee/ide/dropbox/controllers/DropboxController.coffee new file mode 100644 index 0000000000..444aa3eaf2 --- /dev/null +++ b/services/web/public/coffee/ide/dropbox/controllers/DropboxController.coffee @@ -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() diff --git a/services/web/public/coffee/ide/dropbox/index.coffee b/services/web/public/coffee/ide/dropbox/index.coffee new file mode 100644 index 0000000000..6041320724 --- /dev/null +++ b/services/web/public/coffee/ide/dropbox/index.coffee @@ -0,0 +1,4 @@ +define [ + "ide/dropbox/controllers/DropboxController" +], () -> +