From 5ef7bad60fef4806f861c277189be58a6bcb918a Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Fri, 24 Nov 2017 14:58:35 +0000 Subject: [PATCH 1/5] removed groove --- services/web/public/coffee/libs.coffee | 1 - services/web/public/js/libs/groove.js | 84 -------------------------- 2 files changed, 85 deletions(-) delete mode 100644 services/web/public/js/libs/groove.js diff --git a/services/web/public/coffee/libs.coffee b/services/web/public/coffee/libs.coffee index 533891548b..5b3f2a165a 100644 --- a/services/web/public/coffee/libs.coffee +++ b/services/web/public/coffee/libs.coffee @@ -11,7 +11,6 @@ define [ "libs/angular-cookie" "libs/passfield" "libs/sixpack" - "libs/groove" "libs/angular-sixpack" "libs/ng-tags-input-3.0.0" ], () -> diff --git a/services/web/public/js/libs/groove.js b/services/web/public/js/libs/groove.js deleted file mode 100644 index 983b2a73dc..0000000000 --- a/services/web/public/js/libs/groove.js +++ /dev/null @@ -1,84 +0,0 @@ -!function(window) { - - window.Groove = { - - init: function(options) { - this._options = options; - if (typeof grooveOnReady != 'undefined') {grooveOnReady();} - }, - - createTicket: function(params, callback) { - var postData = serialize({ - "ticket[enduser_name]": params["name"], - "ticket[enduser_email]": params["email"], - "ticket[title]": params["subject"], - "ticket[enduser_about]": params["about"], - "ticket[label_string]": params["labels"], - "ticket[comments_attributes][0][body]": params["message"] - }); - - sendRequest(this._options.widget_ticket_url, function(req) { - if (callback) {callback(req);} - }, postData); - } - }; - - // http://www.quirksmode.org/js/xmlhttp.html - function sendRequest(url, callback, postData) { - var req = createXMLHTTPObject(); - if (!req) return; - var method = (postData) ? "POST" : "GET"; - req.open(method, url, true); - if (postData){ - try { - req.setRequestHeader('Content-type','application/x-www-form-urlencoded'); - } - catch(e) { - req.contentType = 'application/x-www-form-urlencoded'; - }; - }; - req.onreadystatechange = function () { - if (req.readyState != 4) return; - callback(req); - } - if (req.readyState == 4) return; - req.send(postData); - } - - var XMLHttpFactories = [ - function () {return new XDomainRequest()}, - function () {return new XMLHttpRequest()}, - function () {return new ActiveXObject("Msxml2.XMLHTTP")}, - function () {return new ActiveXObject("Msxml3.XMLHTTP")}, - function () {return new ActiveXObject("Microsoft.XMLHTTP")} - ]; - - function createXMLHTTPObject() { - var xmlhttp = false; - for (var i = 0; i < XMLHttpFactories.length; i++) { - try { - xmlhttp = XMLHttpFactories[i](); - } - catch (e) { - continue; - } - break; - } - return xmlhttp; - } - - function serialize(obj) { - var str = []; - for(var p in obj) { - if (obj[p]) { - str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); - } - } - return str.join("&"); -} - -if (typeof grooveOnLoad != 'undefined') {grooveOnLoad();} -}(window); - -Groove.init({"widget_ticket_url":"https://sharelatex-accounts.groovehq.com/widgets/f5ad3b09-7d99-431b-8af5-c5725e3760ce/ticket.json"}); - From 7eb2f0d917214643f44ec33c59e237ec5f626b79 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 27 Nov 2017 12:49:12 +0000 Subject: [PATCH 2/5] move generic sales modal to use new support endpoint --- services/web/app/views/subscriptions/plans.pug | 2 +- services/web/public/coffee/main/contact-us.coffee | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/services/web/app/views/subscriptions/plans.pug b/services/web/app/views/subscriptions/plans.pug index 88584dba76..f096fef051 100644 --- a/services/web/app/views/subscriptions/plans.pug +++ b/services/web/app/views/subscriptions/plans.pug @@ -228,7 +228,7 @@ block content .form-group input#Field13.field.text.medium.span8.form-control(ng-model="form.position", name='Field13', type='text', value='', maxlength='255', tabindex='4', onkeyup='') .form-group - input(ng-model="form.source", type="hidden", ng-init="form.source = '__ref__'; form.subject = 'ShareLaTeX for Universities';") + input(ng-model="form.source", type="hidden", ng-init="form.source = '__ref__'; form.subject = 'General enquiry for larger ShareLaTeX use';") .form-group.text-center input#saveForm.btn-success.btn.btn-lg(name='saveForm', type='submit', ng-disabled="sending", value='Request a quote') span(ng-show="sent") diff --git a/services/web/public/coffee/main/contact-us.coffee b/services/web/public/coffee/main/contact-us.coffee index 7bb86a6b93..d370dd6b0f 100644 --- a/services/web/public/coffee/main/contact-us.coffee +++ b/services/web/public/coffee/main/contact-us.coffee @@ -74,7 +74,7 @@ define [ $modalInstance.close() - App.controller 'UniverstiesContactController', ($scope, $modal) -> + App.controller 'UniverstiesContactController', ($scope, $modal, $http) -> $scope.form = {} $scope.sent = false @@ -85,16 +85,16 @@ define [ return $scope.sending = true ticketNumber = Math.floor((1 + Math.random()) * 0x10000).toString(32) - params = + data = + _csrf : window.csrfToken name: $scope.form.name || $scope.form.email email: $scope.form.email labels: "#{$scope.form.source} accounts" message: "Please contact me with more details" - subject: $scope.form.subject + " - [#{ticketNumber}]" - about : "#{$scope.form.position || ''} #{$scope.form.university || ''}" + subject: "#{$scope.form.subject} - #{$scope.form.position} #{$scope.form.university}" + inbox: "accounts" - Groove.createTicket params, (err, json)-> + request = $http.post "/support", data + request.then (response)-> $scope.sent = true $scope.$apply() - - From 3f2ec422f84f04e4bbe6009e0ae35fec42d10c8e Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 27 Nov 2017 13:52:31 +0000 Subject: [PATCH 3/5] change subject line to put details in subject --- services/web/public/coffee/main/contact-us.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/public/coffee/main/contact-us.coffee b/services/web/public/coffee/main/contact-us.coffee index d370dd6b0f..21e8100863 100644 --- a/services/web/public/coffee/main/contact-us.coffee +++ b/services/web/public/coffee/main/contact-us.coffee @@ -91,7 +91,7 @@ define [ email: $scope.form.email labels: "#{$scope.form.source} accounts" message: "Please contact me with more details" - subject: "#{$scope.form.subject} - #{$scope.form.position} #{$scope.form.university}" + subject: "#{$scope.form.name} - General Enquiry - #{$scope.form.position} - #{$scope.form.university}" inbox: "accounts" request = $http.post "/support", data From b16862fa31d770d8325feffd8592344074a0d50e Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 27 Nov 2017 18:03:42 +0000 Subject: [PATCH 4/5] add error handling for form --- services/web/app/views/subscriptions/plans.pug | 4 +++- services/web/public/coffee/main/contact-us.coffee | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/services/web/app/views/subscriptions/plans.pug b/services/web/app/views/subscriptions/plans.pug index f096fef051..8a179fa323 100644 --- a/services/web/app/views/subscriptions/plans.pug +++ b/services/web/app/views/subscriptions/plans.pug @@ -231,7 +231,9 @@ block content input(ng-model="form.source", type="hidden", ng-init="form.source = '__ref__'; form.subject = 'General enquiry for larger ShareLaTeX use';") .form-group.text-center input#saveForm.btn-success.btn.btn-lg(name='saveForm', type='submit', ng-disabled="sending", value='Request a quote') - span(ng-show="sent") + span(ng-show="sent && error") + p Error sending request. + span(ng-show="sent && error == false") p Request Sent, Thank you. .row diff --git a/services/web/public/coffee/main/contact-us.coffee b/services/web/public/coffee/main/contact-us.coffee index 21e8100863..1eb67145e5 100644 --- a/services/web/public/coffee/main/contact-us.coffee +++ b/services/web/public/coffee/main/contact-us.coffee @@ -79,6 +79,7 @@ define [ $scope.form = {} $scope.sent = false $scope.sending = false + $scope.error = false $scope.contactUs = -> if !$scope.form.email? console.log "email not set" @@ -97,4 +98,5 @@ define [ request = $http.post "/support", data request.then (response)-> $scope.sent = true + $scope.error = (response.status != 200) $scope.$apply() From 7ce56aa3b63c9b9f44f6bff0c31b1b62877cf172 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Tue, 28 Nov 2017 10:13:54 +0000 Subject: [PATCH 5/5] add http catch onto form --- services/web/app/views/subscriptions/plans.pug | 8 ++++---- services/web/public/coffee/main/contact-us.coffee | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/services/web/app/views/subscriptions/plans.pug b/services/web/app/views/subscriptions/plans.pug index 8a179fa323..89a07abe1c 100644 --- a/services/web/app/views/subscriptions/plans.pug +++ b/services/web/app/views/subscriptions/plans.pug @@ -210,7 +210,7 @@ block content h3 #{translate("group_plan_enquiry")} .modal-body form.text-left.form(ng-controller="UniverstiesContactController", ng-submit="contactUs()", ng-cloak) - span(ng-show="sent == false") + span(ng-show="sent == false && error == false") .form-group label#title9(for='Field9') | Name @@ -231,10 +231,10 @@ block content input(ng-model="form.source", type="hidden", ng-init="form.source = '__ref__'; form.subject = 'General enquiry for larger ShareLaTeX use';") .form-group.text-center input#saveForm.btn-success.btn.btn-lg(name='saveForm', type='submit', ng-disabled="sending", value='Request a quote') - span(ng-show="sent && error") - p Error sending request. - span(ng-show="sent && error == false") + span(ng-show="sent == true && error == false") p Request Sent, Thank you. + span(ng-show="error") + p Error sending request. .row .col-md-12 diff --git a/services/web/public/coffee/main/contact-us.coffee b/services/web/public/coffee/main/contact-us.coffee index 1eb67145e5..138f459890 100644 --- a/services/web/public/coffee/main/contact-us.coffee +++ b/services/web/public/coffee/main/contact-us.coffee @@ -96,6 +96,11 @@ define [ inbox: "accounts" request = $http.post "/support", data + + request.catch ()-> + $scope.error = true + $scope.$apply() + request.then (response)-> $scope.sent = true $scope.error = (response.status != 200)