| <% |
| /* |
| * |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you 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. |
| * |
| */ |
| include('/controllers/login/validator.jag'); |
| include('/controllers/menu/menu_generator.jag'); |
| |
| var log = new Log("apacheStratos.wizard"); |
| var error = []; |
| var caramel = require('caramel'), |
| setptype,psetptype,nsettype,steplast = false, |
| context = caramel.configs().context, |
| util = require('/controllers/rest/rest_calls.jag'), |
| menuJson = require('/controllers/menu/menu.json'), |
| uriMatcher = new URIMatcher(request.getRequestURI()), |
| elements = uriMatcher.match('/{context}/wizard/{wtype}/{wstep}'), |
| wizardstep = '', |
| wizardtype = 'vm', |
| isSelection = false, |
| userPermissions = session.get('PERMISSIONS'); |
| |
| if(elements==null){ |
| wizardstep = 1; |
| }else{ |
| wizardstep = elements.wstep; |
| } |
| |
| var vm = { |
| '1':'network-partitions', |
| '2':'autoscaling-policies', |
| '3':'deployments', |
| '4':'loadbalancer', |
| '5':'cartridges' , |
| '6':'multitenant' |
| }; |
| var kubernetesClusters = [ |
| 'autoscaling-policies', |
| 'deployments', |
| 'loadbalancer', |
| 'cartridges' , |
| 'multitenant' |
| ]; |
| |
| var count = 0; |
| for (var k in vm) { |
| if (vm.hasOwnProperty(k)) { |
| ++count; |
| } |
| } |
| |
| if(wizardtype == 'vm' && vm.hasOwnProperty(wizardstep)){ |
| |
| nsettype = parseInt(wizardstep)+1; |
| setptype = vm[wizardstep]; |
| psetptype = parseInt(wizardstep)-1; |
| var formData = require('/controllers/forms/schema/configure/' + vm[wizardstep] + '.json'), |
| formDataRaw = require('/controllers/forms/default/configure/' + vm[wizardstep] + '.json'), |
| formTitle = formData.title; |
| }else{ |
| error.push({"errorMessage": "Sorry incorrect wizard value set"}); |
| } |
| |
| if(count >= nsettype){ |
| }else{ |
| nsettype=count; |
| steplast=true; |
| } |
| |
| |
| //create left menu |
| var leftMenu = menuGenerator(context, menuJson.menu, userPermissions); |
| //create metro block |
| var metroMenu = metroGenerator('/', menuJson.menu, userPermissions); |
| |
| var config_status = util.RESTCalls.getConfigStatus(); |
| |
| |
| |
| |
| |
| |
| log.info(config_status) |
| caramel.render({ |
| metro_menu: metroMenu, |
| left_menu: leftMenu, |
| formTitle: formTitle, |
| formDataRaw: JSON.stringify(formDataRaw), |
| formData: JSON.stringify(formData), |
| isSelection: isSelection, |
| wizardstep:wizardstep, |
| nsettype:nsettype, |
| step:setptype, |
| pstep:psetptype, |
| steplast:steplast, |
| error: error |
| }); |
| |
| %> |