2 * Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 var app = angular.module('ModifyLab');
20 'ModifyLabController',
21 function($scope, restAPISvc) {
25 function initialize() {
26 $scope.loadingLabs = true;
29 $scope.selectedLab = '';
33 restAPISvc.getRestAPI("/api/v1/lab/", function(data) {
35 $scope.labInfos = data;
36 angular.forEach(data, function(lab) {
37 $scope.labs.push(lab.lab);
40 confirm("No labs found");
42 $scope.loadingLabs = false;
46 $scope.selectedLabChange = function() {
50 var finalLabInfo = '';
51 angular.forEach($scope.labInfos, function(labInfo) {
52 if ($scope.selectedLab.trim() === labInfo.lab
54 finalLabInfo = labInfo;
58 confirm("Error in lab info");
61 $scope.oldName = finalLabInfo.lab;
62 $scope.oldSilo = finalLabInfo.silo;
65 $scope.modify = function() {
66 if (!$scope.selectedLab || !$scope.newData.name
67 || !$scope.newData.silo) {
68 confirm("You must specify all the values");
71 var finalLabInfo = '';
72 angular.forEach($scope.labInfos, function(labInfo) {
73 if ($scope.selectedLab.trim() === labInfo.lab
75 finalLabInfo = labInfo;
79 confirm("Error in lab info");
82 finalLabInfo.lab = $scope.newData.name;
83 finalLabInfo.silo = $scope.newData.silo;
90 var confirmText = "The lab has been modified successfully."
93 confirm("Error when modifying the lab");