mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-23 06:07:56 +00:00
show message when can not talk to templates api
This commit is contained in:
parent
abc4306e06
commit
735bc9e53d
2 changed files with 39 additions and 23 deletions
services/web
app/views/project/editor
public/coffee/ide/templates/controllers
|
@ -7,28 +7,34 @@ script(type="text/ng-template", id="publishProjectAsTemplateModalTemplate")
|
|||
) ×
|
||||
h3 Publish as Template
|
||||
.modal-body.modal-body-share
|
||||
form()
|
||||
label(for='Description') Template Description
|
||||
.form-group
|
||||
textarea.form-control(
|
||||
rows=5,
|
||||
name='Description',
|
||||
ng-model="template.description",
|
||||
ng-blur="updateProjectDescription()",
|
||||
value=""
|
||||
)
|
||||
div(ng-show="publishedDetails.exists").text-center.publishedDetails
|
||||
| Your project was last published at
|
||||
strong {{publishedDetails.publishedDate}}.
|
||||
a(ng-href="{{publishedDetails.canonicalUrl}}") View it in template gallery.
|
||||
span(ng-hide="problemTalkingToTemplateApi")
|
||||
form()
|
||||
label(for='Description') Template Description
|
||||
.form-group
|
||||
textarea.form-control(
|
||||
rows=5,
|
||||
name='Description',
|
||||
ng-model="template.description",
|
||||
ng-blur="updateProjectDescription()",
|
||||
value=""
|
||||
)
|
||||
div(ng-show="publishedDetails.exists").text-center.publishedDetails
|
||||
| Your project was last published at
|
||||
strong {{publishedDetails.publishedDate}}.
|
||||
a(ng-href="{{publishedDetails.canonicalUrl}}") View it in template gallery.
|
||||
|
||||
span(ng-show="problemTalkingToTemplateApi") There is a problem with our publishing service, please try again in a few minutes.
|
||||
|
||||
|
||||
|
||||
.modal-footer
|
||||
|
||||
.modal-footer(ng-hide="problemTalkingToTemplateApi")
|
||||
button.btn.btn-default(
|
||||
ng-click="cancel()",
|
||||
ng-disabled="state.publishInflight || state.unpublishInflight"
|
||||
) Cancel
|
||||
)
|
||||
span Cancel
|
||||
|
||||
button.btn.btn-info(
|
||||
ng-click="unpublishTemplate()",
|
||||
ng-disabled="state.publishInflight || state.unpublishInflight"
|
||||
|
@ -36,6 +42,7 @@ script(type="text/ng-template", id="publishProjectAsTemplateModalTemplate")
|
|||
)
|
||||
span(ng-show="!state.unpublishInflight") Unpublish
|
||||
span(ng-show="state.unpublishInflight") Unpublishing...
|
||||
|
||||
button.btn.btn-primary(
|
||||
ng-click="publishTemplate()",
|
||||
ng-disabled="state.publishInflight || state.unpublishInflight"
|
||||
|
|
|
@ -7,26 +7,32 @@ define [
|
|||
$modal.open {
|
||||
templateUrl: "publishProjectAsTemplateModalTemplate"
|
||||
controller: "PublishProjectAsTemplateModalController"
|
||||
resolve:
|
||||
diff: () -> $scope.trackChanges.diff
|
||||
}
|
||||
|
||||
App.controller "PublishProjectAsTemplateModalController", ($scope, $modalInstance, ide) ->
|
||||
permissionsManager = new PermissionsManager(ide, $scope)
|
||||
|
||||
user_id = ide.$scope.user.id
|
||||
$scope.template = {}
|
||||
$scope.publishedDetails =
|
||||
exists:false
|
||||
$scope.problemTalkingToTemplateApi = false
|
||||
|
||||
problemTalkingToTemplateApi = ->
|
||||
$scope.problemTalkingToTemplateApi = true
|
||||
|
||||
successTalkingToTemplateApi = ->
|
||||
$scope.problemTalkingToTemplateApi = true
|
||||
|
||||
$scope.state =
|
||||
publishInflight: false
|
||||
unpublishInflight: false
|
||||
|
||||
refreshPublishedStatus = ->
|
||||
|
||||
ide.socket.emit "getPublishedDetails", user_id, (err, data)->
|
||||
if !data? or err? then return problemTalkingToTemplateApi() else successTalkingToTemplateApi()
|
||||
$scope.publishedDetails = data
|
||||
$scope.publishedDetails.publishedDate = moment(data.publishedDate).format("Do MMM YYYY, h:mm a")
|
||||
console.log data
|
||||
$scope.template.description = data.description
|
||||
|
||||
refreshPublishedStatus()
|
||||
|
@ -34,17 +40,20 @@ define [
|
|||
$scope.updateProjectDescription = ->
|
||||
description = $scope.template.description
|
||||
if description?
|
||||
ide.socket.emit 'updateProjectDescription', description, () =>
|
||||
ide.socket.emit 'updateProjectDescription', description, (err) =>
|
||||
if err? then return problemTalkingToTemplateApi() else successTalkingToTemplateApi()
|
||||
|
||||
$scope.publishTemplate = ->
|
||||
$scope.state.publishInflight = true
|
||||
ide.socket.emit 'publishProjectAsTemplate', user_id, (error, docLines, version) =>
|
||||
ide.socket.emit 'publishProjectAsTemplate', user_id, (error) =>
|
||||
if err? then return problemTalkingToTemplateApi() else successTalkingToTemplateApi()
|
||||
refreshPublishedStatus()
|
||||
$scope.state.publishInflight = false
|
||||
|
||||
$scope.unpublishTemplate = ->
|
||||
$scope.state.unpublishInflight = true
|
||||
ide.socket.emit 'unPublishProjectAsTemplate', user_id, (error, docLines, version) =>
|
||||
ide.socket.emit 'unPublishProjectAsTemplate', user_id, (error) =>
|
||||
if err? then return problemTalkingToTemplateApi() else successTalkingToTemplateApi()
|
||||
refreshPublishedStatus()
|
||||
$scope.state.unpublishInflight = false
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue