Merge branch 'master-redesign' of github.com:sharelatex/web-sharelatex into master-redesign

This commit is contained in:
James Allen 2014-07-17 15:35:06 +01:00
commit 2cf8f8c56f
8 changed files with 125 additions and 9 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='dbState.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

@ -46,6 +46,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
@ -150,4 +159,4 @@ script(type='text/ng-template', id='cloneProjectModalTemplate')
ng-click="clone()"
)
span(ng-hide="state.inflight") Copy
span(ng-show="state.inflight") Copying...
span(ng-show="state.inflight") Copying...

View file

@ -1,10 +1,13 @@
extends ../layout
block content
.container#loginBox
.row
.box.span3.offset4
.page-header
h1 Restricted
.content
.container
.row
.col-md-8.col-md-offset-2.text-center
.page-header
h2 Restricted, sorry you don't have permission to load this page.
p
a(href="/")
i.fa.fa-arrow-circle-o-left
| Take me home!

View file

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

View file

@ -0,0 +1,53 @@
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 = ((roundedMinsSinceLastPoll / POLLING_INTERVAL) * 100)
console.log $scope.dbState.percentageLeftTillNextPoll
$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"
], () ->

View file

@ -39,7 +39,7 @@ define [
$scope.$watch $scope.problemTalkingToTemplateApi, refreshPublishedStatus
$scope.updateProjectDescription = ->
description = $scope.template.description
description = $scope.templateDetails.description
if description?
ide.socket.emit 'updateProjectDescription', description, (err) =>
if err? then return problemTalkingToTemplateApi()