Advertisement
Guest User

Untitled

a guest
Feb 4th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.91 KB | None | 0 0
  1. 'use strict';
  2.  
  3. angular
  4. .module('hawk.pipelinesManagement')
  5. .controller('PipelinesController', function ($log, pipelinesStatsService) {
  6. var vm = this;
  7. vm.toggleLogo = 1;
  8.  
  9. var pipelines = pipelinesStatsService.getAll();
  10.  
  11. //Setting pipelines to promise's value
  12. pipelines.then(function (value) {
  13. vm.pipelines = groupPipelinesByGroup(value);
  14. console.log(vm.pipelines);
  15. });
  16.  
  17. function groupPipelinesByGroup(groups) {
  18. groups = _.groupBy(groups, 'GroupName');
  19. for (var pipeline in groups) {
  20. groups[pipeline] = _.groupBy(groups[pipeline], 'Name');
  21. console.log(groups[pipeline]);
  22. for (var run in groups[pipeline]) {
  23. console.log(groups[pipeline][run]);
  24. groups[pipeline][run] = _.sortBy(groups[pipeline][run], 'ExecutionID');
  25. }
  26. }
  27. return groups;
  28. }
  29.  
  30. //Start the form wizard script on page load
  31. FormWizard.init();
  32.  
  33. vm.wizardInfo = {
  34. steps: {
  35. first: 'Setup',
  36. second: 'Materials',
  37. third: 'Review'
  38. },
  39. buttons: {
  40. back: 'Back',
  41. continue: 'Continue',
  42. submit: 'Submit'
  43. },
  44. labels: {
  45. autoSchedule: 'Auto Scheduling',
  46. name: 'Name',
  47. pipelineName: 'Pipeline Name',
  48. gitUrl: 'Git URL',
  49. branch: 'Branch',
  50. username: 'Username',
  51. password: 'Password',
  52. tfsDomain: 'Domain',
  53. projectPath: 'Project Path',
  54. stageName: 'Stage Name',
  55. trigger: 'Trigger option'
  56. },
  57. validationMsg: {
  58. error: "You have some form errors. Please check below.",
  59. success: "Your form validation is successful!"
  60. },
  61. placeholders: {
  62. pipelineName: 'Enter your pipeline name',
  63. gitUrl: 'Enter your git url',
  64. username: 'Enter TFS username',
  65. password: 'Enter TFS password',
  66. tfsDomain: 'Enter TFS domain',
  67. projectPath: 'Enter TFS project path',
  68. stageName: 'Enter stage name',
  69. materialName: 'Enter material name',
  70. gitUsername: 'Enter GIT username',
  71. gitPassword: 'Enter GIT password'
  72. }
  73. };
  74.  
  75. vm.createPipeline = function (model) {
  76.  
  77. if (model.materials.git) {
  78. var gitMaterial = {
  79. PipelineName: model.pipeline.name,
  80. Name: model.materials.git.name,
  81. Type: 'GIT',
  82. Url: model.materials.git.url,
  83. AutoTriggerOnChange: model.pipeline.trigger,
  84. Destination: model.materials.git.name,
  85. "MaterialSpecificDetails": {
  86. "branch": model.materials.git.branch,
  87. "username": model.materials.git.username,
  88. "password": model.materials.git.password
  89. }
  90. }
  91. }
  92.  
  93. var newPipeline = {
  94. "OriginalName": model.pipeline.name,
  95. "Name": model.pipeline.name,
  96. "GroupName": vm.groupName,
  97. "Materials": [],
  98. "EnvironmentVariables": [],
  99. "Parameters": [],
  100. "Environment": null,
  101. "Stages": [],
  102. "State": "Scheduled",
  103. "Start": Date.now(),
  104. "End": '-',
  105. "Duration": '-',
  106. "ExecutionMaterials": [],
  107. "TriggerReason": "User",
  108. "AutoScheduling": model.pipeline.trigger
  109. };
  110.  
  111. newPipeline.Materials.push(gitMaterial);
  112. mockService.create(newPipeline);
  113.  
  114. $log.debug(newPipeline);
  115. };
  116.  
  117. vm.getGroupName = function (input) {
  118. vm.groupName = input;
  119. };
  120.  
  121. //Changes class of logos if name is entered by user
  122. vm.gitInputChange = function (gitName) {
  123. if (gitName == undefined || gitName.length == 0) {
  124. $('#logoGit').removeClass('l-active2');
  125. }
  126. else {
  127. $('#logoGit').addClass('l-active2');
  128. }
  129. };
  130.  
  131. vm.tfsInputChange = function (tfsName) {
  132. if (tfsName == undefined || tfsName.length == 0) {
  133. $('#logoTfs').removeClass('l-active2');
  134. }
  135. else {
  136. $('#logoTfs').addClass('l-active2');
  137. }
  138. };
  139. //End of logos functions
  140.  
  141.  
  142.  
  143.  
  144. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement