<button type="button" class="btn btn-default" data-container="body"
data-toggle="tooltip" data-placement="top" title="Instantiate NS"
- onclick="javascript:openModalCreateNS({ 'project_id':'{{project_id}}','vim_list_url': '{% url "vim:list" %}'})" disabled>
+ onclick="javascript:openModalCreateNS({ 'project_id':'{{project_id}}','vim_list_url': '{% url "vim:list" %}', 'nsd_list_url': '{% url "projects:list_descriptors" project_id=project_id descriptor_type='nsd' %}'})" >
<i class="fa fa-paper-plane"></i> <span> New NS</span></button>
</div>
<div class="form-group">
<label for="nsdId" class="col-sm-3 control-label">Nsd Id *</label>
<div class="col-sm-6">
- <input class="form-control" id="nsdId" name="nsdId"
- placeholder="Nsd Id">
+ <select required id="nsdId" class="js-example-basic form-control" name="nsdId">
+ </select>
</div>
</div>
<div class="form-group">
<label for="vimAccountId" class="col-sm-3 control-label">Vim Account Id *</label>
<div class="col-sm-6">
- <select id="vimAccountId" class="js-example-basic form-control" name="vimAccountId">
+ <select required id="vimAccountId" class="js-example-basic form-control" name="vimAccountId">
</select>
</div>
</div>
{% extends "descriptor/descriptor_view_base.html" %}
{% load staticfiles %}
-{% block head_base %}
- {% with skin_css="AdminLTE/dist/css/skins/skin-purple.min.css"%}
- {{ block.super }}
- {% endwith %}
-{% endblock %}
-{% block body %}
- {% with skin="purple"%}
- {{ block.super }}
- {% endwith %}
-{% endblock %}
-{% block logo_sidebar %}
- {% with logo_mini="assets/img/osm_small_logo.png" logo="assets/img/OSM-logo.png"%}
- {{ block.super }}
- {% endwith %}
-{% endblock %}
{% block title_header_big %}
{{ block.super }}
{{ block.super }}
<script>
+ var descr_list_url = '{% url "projects:list_descriptors" project_id=project_id descriptor_type=descriptor_type%}'
var dropZone = document.getElementById('drop-zone');
dropZone.ondrop = function(e) {
success: function(result) {
console.log(result)
- window.location.href="/projects/{{project_id}}/descriptors/{{descriptor_type}}"
+ window.location.href=descr_list_url
},
error: function(result) {
}
function cancel(id){
- window.location.href="/projects/{{project_id}}/descriptors/{{descriptor_type}}"
+ window.location.href= descr_list_url
}
<td>
<div class="btn-group">
{% if descriptor_type == "nsd" %}
- <button type="button" class="btn btn-default" data-container="body" data-toggle="tooltip" data-placement="top" title="Instantiate NS" onclick="javascript:openModalCreateNS({ 'project_id':'{{project_id}}', 'descriptor_type': '{{descriptor_type}}', 'descriptor_id':'{{ k|get:"_id" }}','vim_list_url': '{% url "vim:list" %}'})"><i class="fa fa-paper-plane"></i></button>
+ <button type="button" class="btn btn-default" data-container="body" data-toggle="tooltip" data-placement="top" title="Instantiate NS" onclick="javascript:openModalCreateNS({ 'project_id':'{{project_id}}', 'descriptor_type': '{{descriptor_type}}', 'descriptor_name':'{{ k|get:"name" }}', 'descriptor_id':'{{ k|get:"_id" }}','vim_list_url': '{% url "vim:list" %}', 'nsd_list_url': '{% url "projects:list_descriptors" project_id=project_id descriptor_type=descriptor_type %}' })"><i class="fa fa-paper-plane"></i></button>
{% endif %}
<button type="button" class="btn btn-default" data-container="body" data-toggle="tooltip" data-placement="top" title="Edit" onclick="javascript:openDescriptorView('{{project_id}}', '{{descriptor_type}}', '{{ k|get:"_id" }}')"><i class="fa fa-edit"></i></button>
<button type="button" class="btn btn-default" data-container="body" data-toggle="tooltip" data-placement="top" title="Show content" onclick="javascript:openPackageContentList('{{project_id}}', '{{descriptor_type}}', '{{ k|get:"_id" }}')"><i class="fa fa-folder-open"></i></button>
<div class="inner"><h3>{{ project_overview.nsd }}</h3>
<p>NS packages</p></div>
<div class="icon"><i class="fa fa-archive"></i></div>
- <a href="/projects/{{ project_id }}/descriptors/nsd" class="small-box-footer">Open list <i
+ <a href='{% url "projects:list_descriptors" project_id=project_id descriptor_type="nsd" %}' class="small-box-footer">Open list <i
class="fa fa-arrow-circle-right"></i></a></div>
</div>
<div class="col-md-6 ">
<div class="inner"><h3>{{ project_overview.vnfd }}</h3>
<p>VNF packages</p></div>
<div class="icon"><i class="fa fa-archive"></i></div>
- <a href="/projects/{{ project_id }}/descriptors/vnfd" class="small-box-footer">Open list <i
+ <a href='{% url "projects:list_descriptors" project_id=project_id descriptor_type="vnfd" %}' class="small-box-footer">Open list <i
class="fa fa-arrow-circle-right"></i></a></div>
</div>
</div>
<i class="fa fa-file-text fa-fw"></i><span>Overview</span>
</a>
</li>
- {% url "projects:list_descriptors" project_id=project_id descriptor_type="vnfd" as nsd_list_url %}
+ {% url "projects:list_descriptors" project_id=project_id descriptor_type="nsd" as nsd_list_url %}
{% url "projects:list_descriptors" project_id=project_id descriptor_type='vnfd' as vnfd_list_url %}
- <li {% if request.get_full_path == nsd_list_url %} class="active treeview" {% else %} class="treeview" {% endif %} >
+ <li {% if request.get_full_path == nsd_list_url or request.get_full_path == vnfd_list_url%} class="active treeview" {% else %} class="treeview" {% endif %} >
<a href="#">
<i class="fa fa-archive fa-fw"></i> <span>Packages {{nsd_list}}</span>
<span class="pull-right-container">
</a>
<ul class="treeview-menu">
<li {% if request.get_full_path == nsd_list_url %} class="active" {% endif %}>
- <a href="/projects/{{project_id}}/descriptors/nsd">
+ <a href='{{ nsd_list_url }}'>
<i class="fa fa-archive fa-fw"></i>NS Packages
</a>
</li>
<li {% if request.get_full_path == vnfd_list_url %} class="active" {% endif %}>
- <a href="/projects/{{project_id}}/descriptors/vnfd">
+ <a href='{{ vnfd_list_url }}'>
<i class="fa fa-archive fa-fw"></i>VNF Packages
</a>
</li>
url(r'^(?P<project_id>\d+)/graph/addlink$', views.add_link, name='addlink'),
url(r'^(?P<project_id>\d+)/graph/removelink$', views.remove_link, name='removelink'),
url(r'^(?P<project_id>\d+)/graph/availablenodes', views.get_available_nodes, name='get_available_nodes'),
- url(r'^(?P<project_id>\d+)/descriptors/(?P<descriptor_type>\w+)(/$)', views.show_descriptors, name='list_descriptors'),
+ url(r'^(?P<project_id>\d+)/descriptors/(?P<descriptor_type>\w+)/list$', views.show_descriptors, name='list_descriptors'),
url(r'^(?P<project_id>\d+)/descriptors/(?P<descriptor_type>\w+)/(?P<descriptor_id>[-\w]+)(/$)',
views.edit_descriptor, name='edit_descriptor'),
url(r'^(?P<project_id>\d+)/descriptors/(?P<descriptor_type>\w+)/(?P<descriptor_id>[-\w]+)/delete$',
return render(request, 'error.html', {'error_msg': 'Project not found.'})
-
@login_required
def show_descriptors(request, project_id=None, descriptor_type=None):
csrf_token_value = get_token(request)
project_overview = projects[0].get_overview_data()
prj_token = project_overview['type']
- page = prj_token + '/' + prj_token + '_project_descriptors.html'
-
- return render(request, page, {
+ url = prj_token + '/' + prj_token + '_project_descriptors.html'
+ return __response_handler(request, {
'descriptors': projects[0].get_descriptors(descriptor_type),
'project_id': project_id,
'project_type': prj_token,
'project_overview_data': project_overview,
"csrf_token_value": csrf_token_value,
'descriptor_type': descriptor_type
- })
+ },url)
@login_required
function openModalCreateNS(args) {
-
// load vim account list
select2_groups = $('#vimAccountId').select2({
placeholder: 'Select VIM',
}
}
});
- /*
+
// load nsd list
select2_groups = $('#nsdId').select2({
placeholder: 'Select NSD',
+ width: '100%',
ajax: {
url: args.nsd_list_url,
dataType: 'json',
processResults: function (data) {
nsd_list = [];
- if (data['nsd_list']) {
- for (d in data['nsd_list']) {
- var nsd = data['nsd_list'][d];
+
+ if (data['descriptors']) {
+ for (d in data['descriptors']) {
+ var nsd = data['descriptors'][d];
nsd_list.push({id: nsd['_id'], text: nsd['name']})
}
}
}
}
});
- */
- $('#nsdId').val(args.descriptor_id);
+
+ if(args.descriptor_id){
+ // Set the value, creating a new option if necessary
+ if ($('#nsdId').find("option[value='" + args.descriptor_id + "']").length) {
+ $('#nsdId').val(args.descriptor_id).trigger('change');
+ } else {
+ // Create a DOM Option and pre-select by default
+ var newOption = new Option(args.descriptor_name, args.descriptor_id, true, true);
+ // Append it to the select
+ $('#nsdId').append(newOption).trigger('change');
+ }
+ }
+
$('#modal_new_instance').modal('show');
}
\ No newline at end of file