From 57cb229bc0c384bd12ce7f1b90a256bca45eb3c8 Mon Sep 17 00:00:00 2001 From: Shakeh Brys Date: Thu, 28 Mar 2019 12:56:46 -0700 Subject: [PATCH 1/2] component to run xlr given a template id and task name. --- Gruntfile.js | 6 +++ app/js/mms/directives/runXlr.js | 92 +++++++++++++++++++++++++++++++++ src/lib/ckeditor/config.js | 3 +- 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 app/js/mms/directives/runXlr.js diff --git a/Gruntfile.js b/Gruntfile.js index 513ac1a34..69e4b3c51 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -67,6 +67,12 @@ module.exports = function(grunt) { host: 'mms-ts-uat.jpl.nasa.gov',//'localhost',//'100.64.243.161', port: 8080 }, + { + context: '/xlrapi', + https: serverHttps, + host: servers[key], + port: serverPort + }, { context: '/alfresco', // '/api' host: servers[key], diff --git a/app/js/mms/directives/runXlr.js b/app/js/mms/directives/runXlr.js new file mode 100644 index 000000000..567a5f9a4 --- /dev/null +++ b/app/js/mms/directives/runXlr.js @@ -0,0 +1,92 @@ +'use strict'; + +angular.module('mms.directives') + .directive('runXlr', ['$http', '$uibModal', '$window', 'growl', 'ApplicationService', runXlr]); + +function runXlr($http, $uibModal, $window, growl, ApplicationService) { + return { + template: '', + scope: { + templateId: '@', + xlrTaskName: '@' + }, + controller: ['$scope', runXlrCtrl], + link: runXlrLink + }; + function runXlrLink(scope, element, attrs, ctrls) {} + + function runXlrCtrl($scope) { + var modalOpen = false; + $scope.xlrTaskName = $scope.xlrTaskName ? $scope.xlrTaskName : 'Sync FN to JPL Network'; + $scope.runXLR = runXLR; + function runXLR() { + + modalOpen = true; + $uibModal.open({ + template: '', + scope: $scope, + backdrop: 'static', + controller: ['$scope', '$uibModalInstance', function ($scope, $uibModalInstance) { + $scope.credentials = { + username: '', + password: '' + }; + $scope.spin = false; + + function make_base_auth(user, password) { + var tok = user + ':' + password; + var hash = $window.btoa(tok); + return "Basic " + hash; + } + $scope.login = function (credentials) { + $scope.spin = true; + var baseAuth = make_base_auth(credentials.username, credentials.password); + var email = credentials.username + '@jpl.nasa.gov'; + var postBody = { + "releaseTitle": "CAE Portal Sync", + "releaseVariables": { + "contentEditor": credentials.username, + "editorEmail": email + }, + "autoStart": true + }; + + var link = "/xlrapi/v1/templates/Applications/" + $scope.templateId + "/create"; + var config = { + method: 'POST', + url: link, + headers: { + 'Authorization': baseAuth, + "Content-Type": "application/json", + "cache-control": "no-cache", + }, + "data": postBody, + "withCredentials": true, + "async": true, + "crossDomain": true, + "processData": false + }; + $http(config).then(function() { + growl.success($scope.xlrTaskName + ' is running. You will receive a completion email'); + }, function(error){ + growl.error($scope.xlrTaskName + ' has failed.'); + }).finally(function() { + $scope.spin = false; + modalOpen = false; + $uibModalInstance.dismiss(); + }); + }; + }], + size: 'md' + }).result.finally(function(){ + modalOpen = false; + }); + + } + + } +} diff --git a/src/lib/ckeditor/config.js b/src/lib/ckeditor/config.js index 7fa77d6ba..1dd6ff2dd 100644 --- a/src/lib/ckeditor/config.js +++ b/src/lib/ckeditor/config.js @@ -22,7 +22,8 @@ CKEDITOR.editorConfig = function( config ) { config.autoGrow_onStartup = true; config.startupFocus = 'end'; config.mathJaxLib = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML'; - config.allowedContent = true; + config.allowedContent = true; + config.extraAllowedContent = 'mms-run-xlr'; config.specialChars = ['€', '‘', '’', '“', '”', '–', '—', '¡', '¢', '£', '¤', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '®', '¯', '°', '²', '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ', 'Œ', 'œ', 'Ŵ', 'Ŷ', 'ŵ', 'ŷ', '‚', '‛', '„', '…', '™', '►', '•', '→', '⇒', '⇔', '♦', '≈','α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','π','ρ','σ','τ','υ','φ','χ','ψ','ω','Α','Β','Γ','Δ','Ε','Ζ','Η','Θ','Ι','Κ','Λ','Μ','Ν','Ξ','Ο','Π','Ρ','Σ','Τ','Υ','Φ','Χ','Ψ','Ω']; //config.protectedSource.push( /]*><\/i>/g ); From 57584fef88e01f31c3a75d2da7acb2f525679a3d Mon Sep 17 00:00:00 2001 From: Shakeh Brys Date: Tue, 2 Apr 2019 22:32:08 -0700 Subject: [PATCH 2/2] cleanup --- app/js/mms/directives/runXlr.js | 2 +- src/lib/ckeditor/config.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/js/mms/directives/runXlr.js b/app/js/mms/directives/runXlr.js index 567a5f9a4..4e4eb94a1 100644 --- a/app/js/mms/directives/runXlr.js +++ b/app/js/mms/directives/runXlr.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('mms.directives') +angular.module('mmsApp') .directive('runXlr', ['$http', '$uibModal', '$window', 'growl', 'ApplicationService', runXlr]); function runXlr($http, $uibModal, $window, growl, ApplicationService) { diff --git a/src/lib/ckeditor/config.js b/src/lib/ckeditor/config.js index 1dd6ff2dd..9b8c8d934 100644 --- a/src/lib/ckeditor/config.js +++ b/src/lib/ckeditor/config.js @@ -23,7 +23,6 @@ CKEDITOR.editorConfig = function( config ) { config.startupFocus = 'end'; config.mathJaxLib = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML'; config.allowedContent = true; - config.extraAllowedContent = 'mms-run-xlr'; config.specialChars = ['€', '‘', '’', '“', '”', '–', '—', '¡', '¢', '£', '¤', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '®', '¯', '°', '²', '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ', 'Œ', 'œ', 'Ŵ', 'Ŷ', 'ŵ', 'ŷ', '‚', '‛', '„', '…', '™', '►', '•', '→', '⇒', '⇔', '♦', '≈','α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','π','ρ','σ','τ','υ','φ','χ','ψ','ω','Α','Β','Γ','Δ','Ε','Ζ','Η','Θ','Ι','Κ','Λ','Μ','Ν','Ξ','Ο','Π','Ρ','Σ','Τ','Υ','Φ','Χ','Ψ','Ω']; //config.protectedSource.push( /]*><\/i>/g );