/** * Copyright 2017 NEC Corporation * * 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'; /** * @ngdoc overview * @name horizon.dashboard.container-infra.clusters.rolling-upgrade.service * @description Service for the container-infra cluster rolling upgrade modal. * Allows user to choose a Cluster template with higher version number the * cluster should upgrade to. Optionally, the number of nodes in a single * upgrade batch can be chosen. */ angular .module('horizon.dashboard.container-infra.clusters') .factory('horizon.dashboard.container-infra.clusters.rolling-upgrade.service', upgradeService); upgradeService.$inject = [ '$q', '$document', 'horizon.app.core.openstack-service-api.magnum', 'horizon.framework.util.actions.action-result.service', 'horizon.framework.util.i18n.gettext', 'horizon.framework.util.q.extensions', 'horizon.framework.widgets.form.ModalFormService', 'horizon.framework.widgets.toast.service', 'horizon.framework.widgets.modal-wait-spinner.service', 'horizon.dashboard.container-infra.clusters.resourceType', 'horizon.dashboard.container-infra.utils.service' ]; function upgradeService( $q, $document, magnum, actionResult, gettext, $qExtensions, modal, toast, spinnerModal, resourceType, utils ) { var modalConfig, formModel, isLatestTemplate, clusterTemplatesTitleMap; var service = { perform: perform, allowed: allowed }; return service; ////////////// function perform(selected, $scope) { // Simulate a click to dismiss opened action dropdown, otherwise it could interfere with // correct behaviour of other dropdowns. $document[0].body.click(); var deferred = $q.defer(); spinnerModal.showModalSpinner(gettext('Loading')); var activeTemplateVersion, activeTemplateId; magnum.getCluster(selected.id).then(function(response) { formModel = getFormModelDefaults(); formModel.id = selected.id; clusterTemplatesTitleMap = [ // Default