Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- angular
- .module('hawk.pipelinesManagement')
- .controller('PipelinesController', function ($log, pipelinesStatsService) {
- var vm = this;
- vm.toggleLogo = 1;
- var pipelines = pipelinesStatsService.getAll();
- //Setting pipelines to promise's value
- pipelines.then(function (value) {
- vm.pipelines = groupPipelinesByGroup(value);
- console.log(vm.pipelines);
- });
- function groupPipelinesByGroup(groups) {
- groups = _.groupBy(groups, 'GroupName');
- for (var pipeline in groups) {
- groups[pipeline] = _.groupBy(groups[pipeline], 'Name');
- console.log(groups[pipeline]);
- for (var run in groups[pipeline]) {
- console.log(groups[pipeline][run]);
- groups[pipeline][run] = _.sortBy(groups[pipeline][run], 'ExecutionID');
- }
- }
- return groups;
- }
- //Start the form wizard script on page load
- FormWizard.init();
- vm.wizardInfo = {
- steps: {
- first: 'Setup',
- second: 'Materials',
- third: 'Review'
- },
- buttons: {
- back: 'Back',
- continue: 'Continue',
- submit: 'Submit'
- },
- labels: {
- autoSchedule: 'Auto Scheduling',
- name: 'Name',
- pipelineName: 'Pipeline Name',
- gitUrl: 'Git URL',
- branch: 'Branch',
- username: 'Username',
- password: 'Password',
- tfsDomain: 'Domain',
- projectPath: 'Project Path',
- stageName: 'Stage Name',
- trigger: 'Trigger option'
- },
- validationMsg: {
- error: "You have some form errors. Please check below.",
- success: "Your form validation is successful!"
- },
- placeholders: {
- pipelineName: 'Enter your pipeline name',
- gitUrl: 'Enter your git url',
- username: 'Enter TFS username',
- password: 'Enter TFS password',
- tfsDomain: 'Enter TFS domain',
- projectPath: 'Enter TFS project path',
- stageName: 'Enter stage name',
- materialName: 'Enter material name',
- gitUsername: 'Enter GIT username',
- gitPassword: 'Enter GIT password'
- }
- };
- vm.createPipeline = function (model) {
- if (model.materials.git) {
- var gitMaterial = {
- PipelineName: model.pipeline.name,
- Name: model.materials.git.name,
- Type: 'GIT',
- Url: model.materials.git.url,
- AutoTriggerOnChange: model.pipeline.trigger,
- Destination: model.materials.git.name,
- "MaterialSpecificDetails": {
- "branch": model.materials.git.branch,
- "username": model.materials.git.username,
- "password": model.materials.git.password
- }
- }
- }
- var newPipeline = {
- "OriginalName": model.pipeline.name,
- "Name": model.pipeline.name,
- "GroupName": vm.groupName,
- "Materials": [],
- "EnvironmentVariables": [],
- "Parameters": [],
- "Environment": null,
- "Stages": [],
- "State": "Scheduled",
- "Start": Date.now(),
- "End": '-',
- "Duration": '-',
- "ExecutionMaterials": [],
- "TriggerReason": "User",
- "AutoScheduling": model.pipeline.trigger
- };
- newPipeline.Materials.push(gitMaterial);
- mockService.create(newPipeline);
- $log.debug(newPipeline);
- };
- vm.getGroupName = function (input) {
- vm.groupName = input;
- };
- //Changes class of logos if name is entered by user
- vm.gitInputChange = function (gitName) {
- if (gitName == undefined || gitName.length == 0) {
- $('#logoGit').removeClass('l-active2');
- }
- else {
- $('#logoGit').addClass('l-active2');
- }
- };
- vm.tfsInputChange = function (tfsName) {
- if (tfsName == undefined || tfsName.length == 0) {
- $('#logoTfs').removeClass('l-active2');
- }
- else {
- $('#logoTfs').addClass('l-active2');
- }
- };
- //End of logos functions
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement