-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from Open-MBEE/release/3.5.2
Release 3.5.2
- Loading branch information
Showing
8 changed files
with
107 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
'use strict'; | ||
|
||
angular.module('mmsApp') | ||
.directive('runXlr', ['$http', '$uibModal', '$window', 'growl', 'ApplicationService', runXlr]); | ||
|
||
function runXlr($http, $uibModal, $window, growl, ApplicationService) { | ||
return { | ||
template: '<button class="btn btn-primary" ng-click="runXLR()">{{xlrTaskName}}</button>', | ||
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: '<div class="modal-header"><h4>Please login to {{xlrTaskName}}.</h4></div><div class="modal-body"><form name="loginForm" ng-submit="login(credentials)">' + | ||
'<input type="text" class="form-control" ng-model="credentials.username" placeholder="Username" style="margin-bottom: 1.5em;" autofocus>' + | ||
'<input type="password" class="form-control" ng-model="credentials.password" placeholder="Password" style="margin-bottom: 1.5em;">' + | ||
'<button class="btn btn-block btn-primary" type="submit">LOG IN <span ng-if="spin" ><i class="fa fa-spin fa-spinner"></i>' + | ||
'</span></button></form></div>', | ||
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; | ||
}); | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters