horizon/openstack_dashboard/static/app/tech-debt/image-form.controller.js
Rajat Vig 8a9329c5fe Add tests for controllers in tech-debt
Controllers image-form and hz-namespace-resource-type-form
do not have any tests.
This patch simply adds unit tests.

Change-Id: I537b7bdf6b778c333f84491891afeb8dbc45eb53
Closes-Bug: #1501513
2015-10-01 00:18:30 -07:00

41 lines
1.3 KiB
JavaScript

/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function () {
'use strict';
angular
.module('horizon.app.tech-debt')
.controller('ImageFormController', ImageFormController);
function ImageFormController() {
var ctrl = this;
ctrl.copyFrom = angular.element('.image_url').val();
ctrl.diskFormat = angular.element('.disk_format').val();
ctrl.selectImageFormat = function (path) {
if (!path) { return; }
var format = path.substr(path.lastIndexOf(".") + 1).toLowerCase().replace(/[^a-z0-9]+/gi, "");
/* eslint-disable angular/ng_angularelement */
if ($('#id_disk_format').find('[value=' + format + ']').length !== 0) {
/* eslint-enable angular/ng_angularelement */
ctrl.diskFormat = format;
} else {
ctrl.diskFormat = "";
}
};
}
})();