template_name = "slice-resource-view.html"
def get(self, request, slicename):
- return render_to_response(self.template, {"slice": slicename, "theme": self.theme, "username": request.user, "section":"resources"}, context_instance=RequestContext(request))
+ if request.GET.get('message') :
+ msg = "Successfully updated Slice"
+ else :
+ msg = None
+ return render_to_response(self.template, {"msg" : msg, "slice": slicename, "theme": self.theme, "username": request.user, "section":"resources"}, context_instance=RequestContext(request))
*/
var myslice = {
+ slice: null,
pending: [],
+ reserved: [],
add: function(resource) {
if (!this.has(resource)) {
if (!this.pending) {
this.pending = [];
}
+ },
+
+ apply: function() {
+ $('div#loading').show();
+ this.pending = [];
+ this.save();
+ setTimeout(function(){
+ $('div#loading').hide();
+ window.location.href = '/resources/' + this.slice + '?message=true';
+ },6000);
+
+
+
+ // $.post("/rest/slice/", { 'fields': ['resource','slice_hrn'], 'filters': { 'slice_hrn' : this.slice } }, function(data) {
+ // console.log(data);
+ // resources = [];
+ // reserved = [];
+ // update = [];
+ // if ('resource' in data[0]) {
+ // $.each(data[0].resource, function(idx, r) {
+ // resources.push(r.urn);
+ // });
+ // }
+ // //myslice.pending
+ // console.log(myslice.pending);
+ // console.log(resources);
+ // $.each(resources.concat(myslice.pending), function(idx, v) {
+ // update.push({ 'resource': v });
+ // });
+ // console.log(update);
+ // $.post("/update/slice/", { 'filters': { 'slice_hrn' : myslice.slice }, 'params' : update }, function(data) {
+ // console.log(data);
+ // });
+ // });
+ //console.log(this.slice);
}
};
}
});
- $.get("/rest/platform", function(data) {
+ $.get("/rest/network", function(data) {
var list = '<div class="list-group-item sl-platfrom"><span class="list-group-item-heading">Testbeds</span></div>';
for(i=0; i<data.length;i++) {
- list += '<a href="#" class="list-group-item sl-platfrom" data-platform="'+data[i].platform+'"><span class="list-group-item-heading">'+data[i].platform_longname+'</span><p class="list-group-item-text">'+data[i].platform+'</p></a>';
+ list += '<a href="#" class="list-group-item sl-platfrom" data-platform="'+data[i].network_hrn+'"><span class="list-group-item-heading">'+data[i].network_longname+'</span><p class="list-group-item-text">'+data[i].network_hrn+'</p></a>';
}
$('#select-platform').html(list);
}).done(function() {
});
+ $('button#ApplyPendind').click(function() {
+ myslice.apply();
+ // $.each(myslice.pending, function(k, p) {
+ // console.log(p);
+ // });
+ // $.post("/update/slice", {}, function() {
+//
+ // });
+ });
+
//google.maps.event.addDomListener(window, 'load', initialize);
});
});
var infowindow = new google.maps.InfoWindow();
- google.maps.event.addListener(marker, 'click', (function(marker, i) {
+ google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(data[i].hostname);
infowindow.open(map, marker);
{% block head %}
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC1RUj824JAiHRVqgc2CSIg4CpKHhh84Lw&sensor=false"></script>
<script src="{{ STATIC_URL }}js/onelab_slice-resource-view.js"></script>
+<script>
+ myslice.slice = "{{ slice }}";
+</script>
{% endblock %}
{% block content %}
<li><a href="">Reserved</a></li>
<li><a href="">Pending<span class="badge" id="badge-pending" style="display:none;"></span></a></li>
<li>
- <button type="button" class="btn btn-primary apply">Apply</button>
+ <button type="button" class="btn btn-primary apply" id="ApplyPendind">Apply</button>
<button type="button" class="btn btn-default clear">Clear</button>
</li>
+ <li>
+ <div id="loading" style="display:none;"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading" /></div>
+ </li>
</ul>
</div>
+ <div class="row">
+ {% if msg %}
+ <div class="col-md-12"><p class="alert-success">{{ msg }}</p></div>
+ {% endif %}
+ </div>
<div class="row">
<ul class="nav nav-tabs nav-resources">
<li class="active"><a data-panel="resources" href="#">Resources</a></li>
self.type = object_type
self.name = object_name
self.fields = []
- self.params = {}
+ self.params = []
self.filters = {}
self.options = None
def update(self):
query = Query.update(self.type)
query = self.applyFilters(query, True)
-
+ print ">>>>>",self.params
+
if self.params :
- query.set(self.params)
+ query.set({ 'resource' : self.params})
+# for param in self.params :
+
else:
raise Exception, "Params are required for update"
#return error('only post request is supported')
req_items = request.GET
for el in req_items.items():
+
+ print "#===============>",o.params
if el[0].startswith('filters'):
o.filters[el[0][8:-1]] = el[1]
elif el[0].startswith('params'):
- o.params[el[0][7:-1]] = el[1]
+ print "#======>", el[0]
+ print "#======>", el[0][7:8]
+ print "#======>", el[0][10:-1]
+ print "#======>", el[1]
+ o.params.append({ el[0][10:-1] : el[1] })
+
+
elif el[0].startswith('fields'):
o.fields=req_items.getlist('fields[]')
elif el[0].startswith('options'):
o.options = req_items.getlist('options[]')
-
+
try:
response = o.update()