Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab
authorCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Mon, 10 Mar 2014 17:39:20 +0000 (18:39 +0100)
committerCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Mon, 10 Mar 2014 17:39:20 +0000 (18:39 +0100)
Conflicts:
portal/static/js/myslice.js

1  2 
devel/server-loop.sh
plugins/query_editor/static/js/query_editor.js
portal/static/css/onelab.css
portal/static/js/myslice.js
portal/templates/about.html
portal/templates/onelab/onelab__widget-topmenu.html
portal/templates/onelab/onelab_slice-view.html
portal/templates/onelab/onelab_widget-slice-sections.html
ui/templates/base.html

diff --combined devel/server-loop.sh
@@@ -4,7 -4,7 +4,7 @@@ cd $DIRNAME/.
  
  # default port : if hostname starts with z -> use 8080 ; otherwise take 80
  #hostname | grep -q '^z' && port=8080 || port=8080
--hostname | grep -q '^z' && port=8080 || port=80
++hostname | grep -q '^z' && port=8080 || port=8080
  [[ -n "$@" ]] && port=$1
  
  while true; do 
@@@ -35,7 -35,7 +35,7 @@@
                      // XXX This should be handled by manifold
                      manifold.raise_event(self.options.query_uuid, FILTER_REMOVED, [key, op]);
                  }
--            }
++            };
          },
  
          init: function(options, element) {
@@@ -13,13 -13,13 +13,13 @@@ a, a:active, a:focus 
  
  h1 {
      border-bottom:1px solid #DDDDDD;
--    padding:0 0 5px 0;
--    margin:0 0 15px 0;
++    padding:0 0 0 0;
++    margin:0 0 0 0;
      font-size:18pt;
  }
  h1 img {
      vertical-align:middle;
--    margin-bottom:4px;
++    margin-bottom:6px;
  }
  h2 {
      font-size:14pt;
@@@ -29,6 -29,6 +29,7 @@@ h3 
      font-size:13pt;
      color:#201E62;
  }
++
  div.wrapper {
      width:980px;
      margin:0 auto;
@@@ -258,7 -258,7 +259,6 @@@ div#home-dashboard div#home-slice-list 
  /* NAV TABS */
  
  .nav.nav-tabs {
--    margin-bottom:25px;
  }
  
  .nav.nav-tabs li.active a {
@@@ -334,6 -334,6 +334,27 @@@ div#ticket-request p 
  }
  
  /* SLICE VIEW */
++ul.nav-sliceview {}
++ul.nav-sliceview li {
++    
++}
++ul.nav-sliceview li:first-child {
++    padding:0;
++}
++ul.nav-sliceview li:first-child a {
++    font-weight:bold;
++    padding:6px 15px 4px 15px;
++}
++ul.nav-sliceview li:first-child img {
++    margin:0 4px 1px 0;
++    padding:0;
++}
++
++
++
++
++
++
  div#slice-view {
      margin:0;
  }
   * MySlice Class
   */
  
 -var myslice = {
 -      slice: null,
 -    pending: [],
 -    reserved: [],
 -    
 -    add: function(resource) {
 -      if (!this.has(resource)) {
 -              this.pending.push(resource);
 -              this.save();
 -      }
 -    },
 +function list() {
 +      this.elements = [];
 +}
 +
 +list.prototype.save = function() {
 +      for (var prop in this) {
 +      if (typeof this[prop] != 'function') {
 +        console.log("prop: " + prop);
 +      } else {
 +              console.log("func: " + prop);
 +      }
 +    }
 +      //localStorage.setItem(name, JSON.stringify(value));
 +};
 +
 +list.prototype.load = function(name) {
 +      this.pending = JSON.parse(localStorage.getItem(name));
 +      if (!this.pending) {
 +              this.pending = [];
 +      }
 +};
 +
 +list.prototype.add = function(element) {
 +      if (!this.has(element)) {
 +              this.elements.push(element);
 +      }
 +};
      
 -    del: function(resource) {
 -      if (this.has(resource)) {
 -              this.pending.splice(index, 1);
 -      }
 -    },
 +list.prototype.del = function(element) {
 +      if (this.has(element)) {
 +              this.elements.splice(index, 1);
 +      }
 +};
      
 -    has: function(resource) {
 -      index = jQuery.inArray( resource, this.pending );
 -      if (index != -1) {
 -              return true;
 -      }
 -      return false;
 -    },
 +list.prototype.has = function(element) {
 +      index = $.inArray( element, this.elements );
 +      if (index != -1) {
 +              return true;
 +      }
 +      return false;
 +};
      
 -    count: function() {
 -      return this.pending.length;
 -    },
 +list.prototype.count = function() {
 +    return this.elements.length;
 +};
 +
 +
 +/*
 + * resources, users, leases
 + */
 +
 +function resources() {
 +      this.pending = {
 +              toremove: new list(),
 +              toadd: new list(),
 +      };
 +};
 +
 +function users() {
 +      this.pending = {
 +              toremove: new list(),
 +              toadd: new list(),
 +      };
 +};
 +
 +function leases() {
 +      this.pending = {
 +              toremove: new list(),
 +              toadd: new list(),
 +      };
 +};
 +
 +/*
 + * Slice
 + */
 +function slice(name) {
 +      this.name = name;
 +      this.resources = new resources();
 +      this.users = new users();
 +      this.leases = new leases();
 +      
 +};
 +slice.prototype.pending = function() {
 +      
 +};
 +slice.prototype.reserve = function() {
 +      
 +};
 +slice.prototype.unreserve = function() {
 +      
 +};
 +
 +/*
 + * User
 + */
 +function user(u) {
 +      this.u = u;
 +      this.testbeds = {};
 +      this.slices = {};
 +      
 +      for (i = 0; i < this.u.slices.length; i++) {
 +              this.slices[this.u.slices[i]] = new slice(this.u.slices[i]);
 +      }
 +};
 +
 +user.prototype.slice = function(name) {
 +      return this.slices[name];
 +};
 +
 +user.prototype.list = function() {
 +    for (s in this.slices) {
 +      for (o in s) {
 +      if (typeof o != 'function') {
 +        console.log(o);
 +      } else {
 +              console.log("w "+o);
 +      }
 +      }
 +    }
 +};
 +
 +/*
 + * MySlice
 + */
 +var myslice = {
 +      user: {},
      
 -    save: function() {
 -      localStorage.setItem('pending', JSON.stringify(this.pending));
 +    getSlices: function(name) {
 +      
      },
      
 -    load: function() {
 -      this.pending = JSON.parse(localStorage.getItem('pending'));
 -      if (!this.pending) {
 -              this.pending = [];
 -      }
 +    refreshUser: function() {
 +      
      },
      
      apply: function() {
-       $('div#loading').show();
-       this.pending = [];
-       this.save();
-       // setTimeout(function(){
-               // $('div#loading').hide();
-               // window.location.href = '/resources/' + this.slice + '?message=true';
-               // },6000);
++
+       //$('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' : 'ple.upmc.myslicedemo'  }, 'params' : update }, function(data) {
-                       console.log(data);
-               });
-       });
-       //console.log(this.slice);
+        $.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( v );
+                });
+                console.log(update);
+                $.post("/update/slice/", { 'filters': { 'slice_hrn' : myslice.slice  }, 'params' : update }, function(data) {
+                        console.log(data);
+                });
+        });
+       console.log(this.slice);
      }
      
  };
  
 +
 +/* MySlice Init */
 +
 +// var Reflector = function(obj) {
 +  // this.getProperties = function() {
 +    // var properties = [];
 +    // for (var prop in obj) {
 +      // if (typeof obj[prop] != 'function') {
 +        // properties.push(prop);
 +        // console.log("prop: " + prop);
 +      // } else {
 +              // console.log("func: " + prop);
 +      // }
 +    // }
 +    // return properties;
 +  // };
 +// };
 +// var reflector = new Reflector(myslice.slices[0].resources.pending);
 +// reflector.getProperties();
 +
 +
  $(document).ready(function() {
 +      // $.post("/rest/user/",{'filters':{'user_hrn':'$user_hrn'}}, function(data) {
 +              // myslice.user = new user(data[0]);
 +              // console.log(myslice.user.slices);
 +              // myslice.user.list();
 +//      
 +      // }).fail(function() {
 +              // throw "error retreiving user data";
 +      // });
        // Put the object into storage
        //localStorage.setItem('testObject', JSON.stringify(testObject));
  
        // Retrieve the object from storage
 -      myslice.load();
 +      //myslice.load();
  
  });
 +
 +/* EXEMPLES */
 +// add a resource to pending
 +
 +myslice.user.slice('ple.upmc.myslicedemo').resources.pending.add(resource);
 +
@@@ -2,7 -2,7 +2,7 @@@
  
  {% block content %}
  <div class="row">
--      <h1><img src="{{ STATIC_URL }}img/icon_slices_small.png" alt="About MySlice" /> About</h1>
++      <h1><img src="{{ STATIC_URL }}icons/slices-xs.png" alt="About MySlice" /> About</h1>
  </div>
  
  <div class="row">
@@@ -1,7 -1,7 +1,4 @@@
--{% insert_str prelude "js/bootstrap.js" %}
--{% insert_str prelude "css/bootstrap.css" %}
--{% insert_str prelude "css/topmenu.css" %}
--{% insert_str prelude "js/logout.js" %}
++
  <div id="header">
        <div class="wrapper">
                <div class="logo">
@@@ -1,24 -1,24 +1,29 @@@
  {% extends "layout_wide.html" %}
  
  {% block content %}
--      <div class="col-md-2"></div>
--      <div class="col-md-10">
--              <div class="row">
--                      {% include theme|add:"_widget-slice-sections.html" %}
++<div class="wrapper">
++      <div class="row">
++              <div class="col-md-12">
++              {% include theme|add:"_widget-slice-sections.html" %}
++          </div>
++      </div>
++</div>
++<div class="container-fluid">
++      <div class="row">
++              <div class="col-md-2">
++                      ll
                </div>
--    </div>
--    
--      <div class="col-md-2"></div>
--      <div class="col-md-10">
--        <br>
--        <br>
--        <div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
--        <div id="slice-tab-loaded" style="display:none;">
--            <table id="slice-tab">
--            </table>
--        </div>
--      </div>
-- 
++              <div class="col-md-10">
++              <br>
++              <br>
++              <div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
++              <div id="slice-tab-loaded" style="display:none;">
++                  <table id="slice-tab">
++                  </table>
++              </div>
++              </div>
++      </div>
++</div>
  <script>
      $(document).ready(function() {
          $.post("/rest/slice/",{'filters':{'slice_hrn':'{{slice}}'}}, function( data ) {
@@@ -1,13 -1,13 +1,14 @@@
--<div class="col-md-8 slice-sections">
--      <ul class="nav nav-pills nav-justified">
--              <li {% if section == 'slice' %}class="active"{% endif %}><a href="/slice/{{ slice }}/">{{ slice }}</a></li>
--              <li {% if section == 'testbeds' %}class="active"{% endif %}><a href="/testbeds/{{ slice }}/">Testbeds</a></li>
--              <li {% if section == 'resources' %}class="active"{% endif %}><a href="/resources/{{ slice }}/">Resources</a></li>
--              <li {% if section == 'users' %}class="active"{% endif %}><a href="/users/{{ slice }}/">Users</a></li>
--              <li><a href="">Statistics</a></li>
--              <li><a href="">Measurements</a></li>
--      </ul>
--</div>
--<div class="col-md-4 slice-experiment">
--      <a href="/portal/experiment"><button type="button" class="btn btn-default">Experiment</button></a>
--</div>
++<ul class="nav nav-tabs nav-sliceview">
++      <li class="active"><a href="/slice/{{ slice }}/"><img src="{{ STATIC_URL }}icons/slices-xs.png" alt="About MySlice" /> {{ slice }}</a></li>
++      <li><a href="/testbeds/{{ slice }}/">Testbeds</a></li>
++      <li><a href="/resources/{{ slice }}/">Resources</a></li>
++      <li><a href="/users/{{ slice }}/">Users</a></li>
++      <li><a href="">Statistics</a></li>
++      <li><a href="">Measurements</a></li>
++      <li><a href="/portal/experiment">Experiment</a></li>
++</ul>
++<script>
++      $(document).ready(function() {
++              
++      });
++</script>
diff --combined ui/templates/base.html
  {% insert_str prelude "js/manifold.js" %}
  {% insert_str prelude "css/manifold.css" %}
  {% insert_str prelude "css/plugin.css" %}
++{% insert_str prelude "js/bootstrap.js" %}
++{% insert_str prelude "css/bootstrap.css" %}
++{% insert_str prelude "css/topmenu.css" %}
++{% insert_str prelude "js/logout.js" %}
  <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/{{ theme }}.css">
  </head>
  <body>