2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
6 * http://www.apache.org/licenses/LICENSE-2.0
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
20 .controller('PodsController', PodsController);
22 PodsController.$inject = [
23 '$scope', '$http', '$filter', '$state', 'testapiApiUrl','raiseAlert'
27 * TestAPI Pods Controller
28 * This controller is for the '/pods' page where a user can browse
29 * through pods declared in TestAPI.
31 function PodsController($scope, $http, $filter, $state, testapiApiUrl,
34 ctrl.url = testapiApiUrl + '/pods';
39 ctrl.clearFilters = clearFilters;
41 ctrl.roles = ['community-ci', 'production-ci'];
42 ctrl.modes = ['metal', 'virtual'];
43 ctrl.createRequirements = [
44 {label: 'name', type: 'text', required: true},
45 {label: 'mode', type: 'select', selects: ctrl.modes},
46 {label: 'role', type: 'select', selects: ctrl.roles},
47 {label: 'details', type: 'textarea', required: false}
51 ctrl.role = 'community-ci';
56 * This is called when the date filter calendar is opened. It
57 * does some event handling, and sets a scope variable so the UI
58 * knows which calendar was opened.
59 * @param {Object} $event - The Event object
60 * @param {String} openVar - Tells which calendar was opened
62 function open($event, openVar) {
63 $event.preventDefault();
64 $event.stopPropagation();
69 * This function will clear all filters and update the results
72 function clearFilters() {
77 * This will contact the TestAPI to create a new pod.
80 ctrl.showError = false;
83 var pods_url = ctrl.url;
91 $http.post(pods_url, body).error(function (data, status) {
92 ctrl.showError = true;
95 'Error creating the new pod from server: Pod\'s name already exists'
100 ctrl.showError = true;
101 ctrl.error = 'Name is missing.'
106 * This will contact the TestAPI to get a listing of declared pods.
109 ctrl.showError = false;
111 $http.get(ctrl.url).success(function (data) {
113 }).error(function (error) {
115 ctrl.showError = true;
117 'Error retrieving pods from server: ' +
118 angular.toJson(error);