Timur Sufiev 05f4f22b9e Implement auto-completion field in Merlin
Also provide first approach to changing dependent field on field
change according to schema received by $http AJAX call.

This commit includes updated angular-bootstrap code is well for the
typeahead plugin to work with ng-model-options="{getterSetter: true}"
option. The ideal solution here would be to create a pull-request to the
angular-bootstrap plugin repo at github, make it merged and then make
the new version to be used in Horizon (and eliminate the need to use the
customized version of angular-bootstrap plugin in Merlin).

Implements: blueprint angular-fields-dependencies
Change-Id: I2be49de07beb09f430a8a4ffe5a19552fbaeb81e
2015-04-22 16:49:52 +03:00

58 lines
1.9 KiB
Python

# Copyright (c) 2014 Mirantis, Inc.
#
# 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.
import json
from django.core.urlresolvers import reverse_lazy
from django import http
from django.views.generic import View
from horizon import tables
from horizon.views import APIView
import yaml
from mistral import api
from mistral import forms as mistral_forms
from mistral import tables as mistral_tables
class CreateWorkbookView(APIView):
template_name = 'project/mistral/create.html'
class ActionTypesView(View):
def get(self, request, *args, **kwargs):
key = request.GET.get('key')
schema = {
'nova.create_server': ['image', 'flavor', 'network_id'],
'neutron.create_network': ['name', 'create_subnet'],
'glance.create_image': ['image_url']
}
response = http.HttpResponse(content_type='application/json')
if key:
result = schema.get(key)
if result is None:
return http.HttpResponse(status=404)
response.write(json.dumps(schema.get(key)))
else:
response.write(json.dumps(schema.keys()))
return response
class IndexView(tables.DataTableView):
template_name = 'project/mistral/index.html'
table_class = mistral_tables.WorkbooksTable
def get_data(self):
return api.list_workbooks(self.request)