Initial commit

This commit is contained in:
Isaac Parenteau committed 2018-07-07 20:43:51 -05:00
commit 880e39de2e
511 files changed
+38363

No files matched your search

@@ -0,0 +1,74 @@
<md-dialog flex="40">
<form name="gitForm" ng-submit="gitForm.$valid && ok()">
<md-toolbar>
<div class="md-toolbar-tools md-portal">
<span>{{header}}</span>
<span flex></span>
<md-button class="md-icon-button" ng-click="cancel()">
<md-icon aria-label="Close dialog">close</md-icon>
</md-button>
</div>
</md-toolbar>
<md-dialog-content layout-padding flex>
<div>
<div layout-gt-xs="row">
<md-input-container class="md-block" flex-gt-xs>
<label>Name</label>
<input ng-model="git.name" name="name" id="name" required>
<div ng-messages="gitForm.name.$error" ng-show="gitForm.name.$invalid && submitted || gitForm.name.$touched">
<div ng-message="required">Name is required</div>
</div>
</md-input-container>
</div>
<div layout-gt-xs="row">
<md-input-container class="md-block" flex-gt-xs>
<label>Git SCM Url</label>
<input ng-model="git.scm" name="scm" id="scm" required>
<div ng-messages="gitForm.scm.$error" ng-show="gitForm.scm.$invalid && submitted || gitForm.scm.$touched">
<div ng-message="required">Git SCM url is required</div>
</div>
</md-input-container>
</div>
<div layout-gt-xs="row">
<md-input-container class="md-block" flex-gt-xs>
<label>Git Branch</label>
<input ng-model="git.branch" name="branch" id="branch" required>
<div ng-messages="gitForm.branch.$error" ng-show="gitForm.branch.$invalid && submitted || gitForm.branch.$touched">
<div ng-message="required">Git SCM url is required</div>
</div>
</md-input-container>
</div>
<div layout-gt-xs="row">
<md-input-container class="md-block" flex-gt-xs>
<label>Local Checkout Directory</label>
<input ng-model="git.directory" name="directory" id="directory" required>
<div ng-messages="gitForm.directory.$error" ng-show="gitForm.directory.$invalid && submitted || gitForm.directory.$touched">
<div ng-message="required">Checkout directory is required</div>
</div>
</md-input-container>
</div>
<div layout-gt-xs="row">
<md-input-container class="md-block" flex-gt-xs>
<label>Credentials</label>
<md-select ng-model="git.credentials" required name="creds" id="creds" ng-model-options="{trackBy: '$value.uid'}">
<md-option ng-repeat="cred in credentials" ng-value="cred">{{displayKey(cred)}}</md-option>
</md-select>
<div ng-messages="credForm.creds.$error" ng-show="credForm.creds.$invalid && submitted || credForm.creds.$touched">
<div ng-message="required">Credentials are required</div>
</div>
</md-input-container>
</div>
</div>
<div ng-show="loadingBlock" class="loadingFade"></div>
<div class="loadingModal" ng-show="loadingBlock">
<md-progress-circular md-mode="indeterminate" md-diameter="80" class="md-hue-2"></md-progress-circular>
</div>
</md-dialog-content>
<md-dialog-actions layout="row" class="modal-footer">
<div class="text-danger">{{error}}</div>
<md-button id="okButton" type="submit" class="md-raised md-primary" >OK</md-button>
<md-button id="cancelButton" class="md-raised md-warn" ng-click="cancel()">Cancel</md-button>
</md-dialog-actions>
</form>
</md-dialog>
@@ -0,0 +1,67 @@
(function () {
'use strict';
/**
* MODULE DESCRIPTION:
*
* TODO: Write description here.
*/
angular.module('portal.common.partials.addGit', ['ui.router']).controller('AddGitCtrl', addGitCtrlController);
function addGitCtrlController($scope, modalInstance, $state, cache, $mdDialog, GitInfo, Account, accountProvider, gitProvider, credentialStores, portalUtils) {
$scope.trustAsHtml = portalUtils.trustAsHtml;
$scope.header = modalInstance.header;
$scope.submitted = false;
$scope.loadingBlock = false;
$scope.isNew = modalInstance.gitInfo === undefined ? true : false;
$scope.git = $scope.isNew ? new GitInfo() : modalInstance.gitInfo;
$scope.valid = false;
$scope.mCache = cache.request([new credentialStores.Credentials()]).then(function(){
$scope.credentials = $scope.mCache.credentials.data.values;
});
/**
* OK button handler
* @returns {undefined}
*/
$scope.ok = function () {
$scope.loadingBlock = true;
var status = $scope.isNew ? 'added': 'edited';
$scope.submitted = true;
gitProvider.addGitRepo($scope.git).then(function(data){
$scope.loadingBlock = false;
portalUtils.toast('Git ' + status + ' successfully', ['top', 'left'], 2000);
$mdDialog.hide();
}).catch(function(err){
$scope.loadingBlock = false;
$scope.error = err.message;
});
};
$scope.displayKey = function(cred) {
if (cred === undefined) {
return '';
}
return cred.name + (cred.credentialType === 'SSH' ? ' (SSH Key)' : ' (Username/Password)');
};
/**
* Cancel button handler.
* @returns {undefined}
*/
$scope.cancel = function () {
//Dismiss the modal
$mdDialog.cancel();
};
} //end addGitCtrlController function
})();