npm-run-build tenant view
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/field/field.component.js b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/field/field.component.js
index 2c249cc..fa02dbb 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/field/field.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/field/field.component.js
@@ -228,9 +228,6 @@
         if(!$attrs.ngModel){
           throw new Error('[xosField] Please provide an ng-model');
         }
-        if(this.field.type === 'select' && !this.ngModel ){
-          //this.ngModel = this.field.options[0].id;
-        }
         this.getType = XosFormHelpers._getFieldFormat;
         this.formatLabel = LabelFormatter.format;
 
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.component.js b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.component.js
index a2ee7d5..ca6d7d8 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.component.js
@@ -210,10 +210,7 @@
       template: `
         <form name="vm.{{vm.config.formName || 'form'}}" novalidate>
           <div class="form-group" ng-repeat="(name, field) in vm.formField">
-          <!--{{vm.ngModel[name] | json}}-->
             <xos-field name="name" field="field" ng-model="vm.ngModel[name]"></xos-field>
-            <!--<pre>{{vm[vm.config.formName] || 'form'  | json }}</pre>-->
-            <!--{{field}}-->
             <xos-validation field="vm[vm.config.formName || 'form'][name]" form = "vm[vm.config.formName || 'form']"></xos-validation>
             <div class="alert alert-info" ng-show="(field.hint).length >0" role="alert">{{field.hint}}</div>
           </div>
diff --git a/views/ngXosViews/tenant/src/index.html b/views/ngXosViews/tenant/src/index.html
index 16822bf..e1a83d4 100644
--- a/views/ngXosViews/tenant/src/index.html
+++ b/views/ngXosViews/tenant/src/index.html
@@ -8,14 +8,10 @@
 <link rel="stylesheet" href="/css/main.css">
 <link rel="stylesheet" href="/../../../xos/core/static/xosNgLib.css">
 <!-- endinject -->
-<p>
-  hello
-</p>
+
 
 <div ng-app="xos.tenant" id="xosTenant" class="container-fluid">
-  <div ui-sref="createslice"></div>
-  <div ui-view></div>
-  <div></div>
+   <div ui-view></div>
 </div>
 
 <!-- bower:js -->
diff --git a/views/ngXosViews/tenant/src/js/main.js b/views/ngXosViews/tenant/src/js/main.js
index e5f702e..65fc90d 100644
--- a/views/ngXosViews/tenant/src/js/main.js
+++ b/views/ngXosViews/tenant/src/js/main.js
@@ -64,7 +64,6 @@
       })
       .then((users) => {
         this.slices = users;
-        //console.log(this.sites,this.slices);
         this.site_list = this.returnData(this.sites, this.slices);
       })
       .catch((e) => {
@@ -73,8 +72,6 @@
 
 
       this.returnData = (sites, slices) => {
-        //console.log(sites,slices);
-        //console.log(sites.length)
         var i, j=0;
         var site_list=[];
 
@@ -93,11 +90,9 @@
             'instance_total': instance_t,
             'instance_total_ready': instance_t_r
           };
-          //console.log(sites[i].id);
           site_list.push(data_sites);
         }
         return site_list;
-        //this.site_list = site_list;
       }
     }
   };
@@ -151,10 +146,6 @@
     controllerAs: 'cs',
     templateUrl: 'templates/createslice.html',
     controller: function(Slices, SlicesPlus, Sites, Images, $stateParams, $http, $state, $q){
-      //var sites;
-      //console.log(this.users.name);
-
-      //console.log(this.config);
       this.config = {
         exclude: ['site', 'password', 'last_login', 'mount_data_sets', 'default_flavor', 'creator', 'exposed_ports', 'networks', 'omf_friendly', 'omf_friendly', 'no_sync', 'no_policy', 'lazy_blocked', 'write_protect', 'deleted', 'backend_status', 'backend_register', 'policed', 'enacted', 'updated', 'created', 'validators', 'humanReadableName'],
         formName: 'SliceDetails',
@@ -185,9 +176,9 @@
             label: 'Save and add another',
             icon: 'ok', // refers to bootstraps glyphicon
             cb: (model, form) => {
-             saveform(model,form).then(()=> {
-               $state.go('createslice',{site : this.model.site,id : ''});
-             });
+              saveform(model,form).then(()=> {
+                $state.go('createslice',{site : this.model.site,id : ''});
+              });
             },
             class: 'primary'
           }
@@ -314,7 +305,6 @@
 
         }
       };
-      //console.log(this.config.exclude);
       var data;
       Images.query().$promise
           .then((users) => {
@@ -336,7 +326,6 @@
           retObj.push(optVal);
 
         }
-        //console.log(retObj);
         return retObj;
       };
 
@@ -347,8 +336,6 @@
         delete this.config.fields['site'];
         this.config.exclude.push('site');
 
-        //console.log(this.config.exclude);
-
         Slices.get({id: $stateParams.id}).$promise
           .then((users) => {
             this.users = users;
@@ -368,8 +355,6 @@
         $http.get('/xoslib/tenantview/').
         success((data) => {
           this.userList = data;
-          console.log(this.userList);
-          //this.model={}
           this.model['creator'] = this.userList.current_user_id;
 
         });
@@ -382,7 +367,6 @@
         Sites.query().$promise
       .then((users) => {
         this.users_site = users;
-        //console.log(users);
         this.optionVal = this.setData(this.users_site, {field1: 'id', field2: 'name'});
         this.config.fields['site'].options = this.optionVal;
         //= this.optionVal;
@@ -398,37 +382,37 @@
       { // receive the model
         var deferred = $q.defer();
         delete model.networks;
-              if (form.$valid )
-              {
-                if(model.id){
-                  var pr = Slices.update(model).$promise;
-                }
-                else{
-                  var pr = Slices.save(model).$promise;
-                }
-                pr.then((users) => {
-                  this.model = users;
-                  //data = users;
-                  //this.model = this.users;
-                  this.config.feedback.show = true;
-                  deferred.resolve(this.model);
-                })
-                .catch((e) => {
-                  this.config.feedback.show = true;
-                  this.config.feedback.type='danger';
-                  if(e.data && e.data.detail )
-                  {
-                    this.config.feedback.message = e.data.detail;
-                  }
-                  else {
-                    this.config.feedback.message=e.statusText;
-                  }
-                  deferred.reject(e);
-                });
-              }
-
-              return  deferred.promise;
+        if (form.$valid )
+        {
+          if(model.id){
+            var pr = Slices.update(model).$promise;
+          }
+          else{
+            var pr = Slices.save(model).$promise;
+          }
+          pr.then((users) => {
+            this.model = users;
+            //data = users;
+            //this.model = this.users;
+            this.config.feedback.show = true;
+            deferred.resolve(this.model);
+          })
+          .catch((e) => {
+            this.config.feedback.show = true;
+            this.config.feedback.type='danger';
+            if(e.data && e.data.detail )
+            {
+              this.config.feedback.message = e.data.detail;
             }
+            else {
+              this.config.feedback.message=e.statusText;
+            }
+            deferred.reject(e);
+          });
+        }
+
+        return  deferred.promise;
+      }
     }
   };
 });
\ No newline at end of file
diff --git a/xos/core/xoslib/dashboards/xosTenant.html b/xos/core/xoslib/dashboards/xosTenant.html
index 8881bb8..928b16c 100644
--- a/xos/core/xoslib/dashboards/xosTenant.html
+++ b/xos/core/xoslib/dashboards/xosTenant.html
@@ -1,122 +1,17 @@
-<script src="{{ STATIC_URL }}/js/vendor/underscore-min.js"></script>
-<script src="{{ STATIC_URL }}/js/vendor/backbone.js"></script>
-<script src="{{ STATIC_URL }}/js/vendor/backbone.syphon.js"></script>
-<script src="{{ STATIC_URL }}/js/vendor/backbone.wreqr.js"></script>
-<script src="{{ STATIC_URL }}/js/vendor/backbone.babysitter.js"></script>
-<script src="{{ STATIC_URL }}/js/vendor/backbone.marionette.js"></script>
+<!-- browserSync -->
 
-<link rel="stylesheet" type="text/css" href="{% static 'css/xosTenantDashboard.css' %}" media="all" >
-<link rel="stylesheet" type="text/css" href="{% static 'css/xosAdminSite.css' %}" media="all" >
+<!-- endcss -->
+<!-- inject:css -->
+<link rel="stylesheet" href="/static/css/xosTenant.css">
+<!-- endinject -->
 
-<script src="{{ STATIC_URL }}/js/xoslib/xos-util.js"></script>
-<script src="{{ STATIC_URL }}/js/xoslib/xos-defaults.js"></script>
-<script src="{{ STATIC_URL }}/js/xoslib/xos-validators.js"></script>
-<script src="{{ STATIC_URL }}/js/xoslib/xos-backbone.js"></script>
-<script src="{{ STATIC_URL }}/js/xoslib/xosHelper.js"></script>
-<script src="{{ STATIC_URL }}/js/picker.js"></script>
-<script src="{{ STATIC_URL }}/js/xosTenant.js"></script>
 
-<script type="text/template" id="xos-tenant-buttons-template">
-  <div class="box save-box">
-    <button class="btn btn-high btn-success btn-tenant-create">Create New Slice</button>
-    <button class="btn btn-high btn-danger btn-tenant-delete">Delete Slice</button>
-    <button class="btn btn-high btn-primary btn-tenant-add-user">Edit Users</button>
-    <button class="btn btn-high btn-primary btn-tenant-download-ssh">SSH Commands</button>
-    <button class="btn btn-high btn-success btn-tenant-save">Save</button>
-  </div>
-</script>
-
-<script type="text/template" id="xos-tenant-buttons-noslice-template">
-  <div class="box save-box">
-    <button class="btn btn-high btn-tenant-create">Create New Slice</button>
-  </div>
-</script>
-
-<script type="text/template" id="xos-log-template">
-  <tr id="<%= logMessageId %>" class="xos-log xos-<%= statusclass %>">
-     <td><%= what %><br>
-         <%= status %> <%= statusText %>
-     </td>
-  </tr>
-</script>
-
-<script type="text/template" id="tenant-sanity-check">
-    Tenant view sanity check failed:
-       <ul>
-       <% for (index in errors) { %>
-           <li><%= errors[index] %></li>
-       <% } %>
-       </ul>
-       Steps to correct issues in the tenant view:
-       <ol>
-       <li>Make sure that the tenant view is linked to at least one deployment. You
-           may find the list of dashboard views at <a href="/admin/core/dashboardview/">here</a>.
-           Deployments currently attached to the tenant view are: <%= blessed_deployment_names.join(",") %>
-           </li>
-       <li>Make sure that at least one Image and one Flavor is attached to a tenant view deployment.</li>
-       <li>Make sure at least one Site is attached to a tenant view deployment.</li>
-       <li>Make sure at least one of the Sites has one or more nodes attached to it.</li>
-       </ol>
-</script>
-
-<script type="text/template" id="tenant-edit-users">
-    <%= xosPickerTemplate({pickedItems: model.usersBuffer,
-                          unpickedItems: array_subtract(xos.tenant().current_user_site_users, model.usersBuffer),
-                          id: "users",
-                          fieldName: "users",
-                          detailView: detailView,
-                          lookupFunc: function(x) { return array_pair_lookup(x,
-                                                     $.merge($.merge([], xos.tenant().current_user_site_user_names), model.user_namesOrig),
-                                                     $.merge($.merge([], xos.tenant().current_user_site_users), model.usersOrig)); },
-                          } ) %>
-</script>
-
-<div id="xos-confirm-dialog" title="Confirmation Required">
-  Are you sure about this?
+<div ng-app="xos.tenant" id="xosTenant" class="container-fluid">
+   <div ui-view></div>
 </div>
 
-<div id="tenant-addslice-dialog" title="Create New Slice">
-<div id="tenant-addslice-interior"></div>
-</div>
 
-<div id="tenant-edit-users-dialog" title="Edit Users">
-<div id="tenant-edit-users-interior"></div>
-</div>
-
-<div id="tenant-ssh-commands-dialog" title="SSH Commands">
-<div id="tenant-ssh-commands-interior"></div>
-</div>
-
-<div id="xos-error-dialog" title="Error Message">
-</div>
-
-<div id="xos-tenant-view-panel"> <!-- contentPanel"> -->
-<div id="contentTitle">
-</div>
-<div id="contentButtonPanel">
-
-<div id="rightButtonPanel"></div>
-
-<div class="box" id="logPanel">
-<table id="logTable">
-<tbody>
-</tbody>
-</table> <!-- end logTable -->
-</div> <!-- end logPanel -->
-</div> <!-- end contentButtonPanel -->
-
-<div id="contentInner">
-
-<div id="tenantSliceSelector">
-</div>
-<div id="tenantSummary">
-</div>
-<div id="tenantSiteList">
-</div>
-<div id="tenantButtons">
-</div>
-
-</div> <!-- end contentInner -->
-</div> <!-- end contentPanel -->
-
-{% include 'xosAdmin.html' %}
+<!-- endjs -->
+<!-- inject:js -->
+<script src="/static/js/xosTenant.js"></script>
+<!-- endinject -->
\ No newline at end of file
diff --git a/xos/core/xoslib/static/css/xosTenant.css b/xos/core/xoslib/static/css/xosTenant.css
new file mode 100644
index 0000000..1675325
--- /dev/null
+++ b/xos/core/xoslib/static/css/xosTenant.css
@@ -0,0 +1 @@
+#xosTenant a{margin-bottom:15px}
\ No newline at end of file
diff --git a/xos/core/xoslib/static/js/vendor/ngXosHelpers.js b/xos/core/xoslib/static/js/vendor/ngXosHelpers.js
index 3842d35..bc83b29 100644
--- a/xos/core/xoslib/static/js/vendor/ngXosHelpers.js
+++ b/xos/core/xoslib/static/js/vendor/ngXosHelpers.js
@@ -1346,7 +1346,7 @@
         config: '=',
         ngModel: '='
       },
-      template: '\n        <form name="vm.{{vm.config.formName || \'form\'}}" novalidate>\n          <div class="form-group" ng-repeat="(name, field) in vm.formField">\n          <!--{{vm.ngModel[name] | json}}-->\n            <xos-field name="name" field="field" ng-model="vm.ngModel[name]"></xos-field>\n            <!--<pre>{{vm[vm.config.formName] || \'form\'  | json }}</pre>-->\n            <!--{{field}}-->\n            <xos-validation field="vm[vm.config.formName || \'form\'][name]" form = "vm[vm.config.formName || \'form\']"></xos-validation>\n            <div class="alert alert-info" ng-show="(field.hint).length >0" role="alert">{{field.hint}}</div>\n          </div>\n          <div class="form-group" ng-if="vm.config.actions">\n          <xos-alert config="vm.config.feedback" show="vm.config.feedback.show">{{vm.config.feedback.message}}</xos-alert>\n\n            <button role="button" href=""\n              ng-repeat="action in vm.config.actions"\n              ng-click="action.cb(vm.ngModel, vm[vm.config.formName || \'form\'])"\n              class="btn btn-{{action.class}}"\n              title="{{action.label}}">\n              <i class="glyphicon glyphicon-{{action.icon}}"></i>\n              {{action.label}}\n            </button>\n          </div>\n        </form>\n      ',
+      template: '\n        <form name="vm.{{vm.config.formName || \'form\'}}" novalidate>\n          <div class="form-group" ng-repeat="(name, field) in vm.formField">\n            <xos-field name="name" field="field" ng-model="vm.ngModel[name]"></xos-field>\n            <xos-validation field="vm[vm.config.formName || \'form\'][name]" form = "vm[vm.config.formName || \'form\']"></xos-validation>\n            <div class="alert alert-info" ng-show="(field.hint).length >0" role="alert">{{field.hint}}</div>\n          </div>\n          <div class="form-group" ng-if="vm.config.actions">\n          <xos-alert config="vm.config.feedback" show="vm.config.feedback.show">{{vm.config.feedback.message}}</xos-alert>\n\n            <button role="button" href=""\n              ng-repeat="action in vm.config.actions"\n              ng-click="action.cb(vm.ngModel, vm[vm.config.formName || \'form\'])"\n              class="btn btn-{{action.class}}"\n              title="{{action.label}}">\n              <i class="glyphicon glyphicon-{{action.icon}}"></i>\n              {{action.label}}\n            </button>\n          </div>\n        </form>\n      ',
       bindToController: true,
       controllerAs: 'vm',
       controller: ["$scope", "$log", "_", "XosFormHelpers", function controller($scope, $log, _, XosFormHelpers) {
@@ -1571,9 +1571,6 @@
         if (!$attrs.ngModel) {
           throw new Error('[xosField] Please provide an ng-model');
         }
-        if (this.field.type === 'select' && !this.ngModel) {
-          //this.ngModel = this.field.options[0].id;
-        }
         this.getType = XosFormHelpers._getFieldFormat;
         this.formatLabel = LabelFormatter.format;
 
diff --git a/xos/core/xoslib/static/js/xosTenant.js b/xos/core/xoslib/static/js/xosTenant.js
index 0bd3604..834dc12 100644
--- a/xos/core/xoslib/static/js/xosTenant.js
+++ b/xos/core/xoslib/static/js/xosTenant.js
@@ -1,524 +1 @@
-

-/* globals XOSModel, XOSCollection */

-/* eslint-disable no-undef, guard-for-in, new-cap, space-before-blocks, no-unused-vars, no-alert, eqeqeq */

-

-XOSTenantSite = XOSModel.extend({

-  listFields: ['name', 'allocated'],

-  modelName: 'tenantSite',

-  collectionName: 'tenantSites'

-});

-

-XOSTenantSiteCollection = XOSCollection.extend({

-  listFields: ['name', 'allocated', 'ready'],

-  modelName: 'tenantSite',

-  collectionName: 'tenantSites',

-

-  getFromSlice: function(slice) {

-    var tenantSites = [];

-    var id = 0;

-    var that = this;

-

-    for (siteName in slice.attributes.site_allocation) {

-      allocated = slice.attributes.site_allocation[siteName];

-      ready = slice.attributes.site_ready[siteName] || 0;

-      tenantSites.push(new XOSTenantSite({name: siteName, allocated: allocated, ready: ready, id: id}));

-      id = id + 1;

-    }

-

-    for (index in xos.tenantview.models[0].attributes.blessed_site_names) {

-      siteName = xos.tenantview.models[0].attributes.blessed_site_names[index];

-      if (! (siteName in slice.attributes.site_allocation)) {

-        tenantSites.push(new XOSTenantSite({name: siteName, allocated: 0, ready: 0, id: id}));

-        id = id + 1;

-      }

-    }

-    this.set(tenantSites);

-

-    this.listenTo(slice, 'change', function() {

-      that.getReadyFromSlice(slice);

-    });

-  },

-

-  getReadyFromSlice: function(slice) {

-    for (siteName in slice.attributes.site_ready) {

-      ready = slice.attributes.site_ready[siteName];

-      for (index in this.models) {

-        tenantSite = this.models[index];

-        if (tenantSite.attributes.name == siteName) {

-          tenantSite.set('ready', ready);

-        }

-      }

-    }

-  },

-

-  putToSlice: function(slice) {

-    slice.attributes.site_allocation = {};

-    for (index in this.models) {

-      var model = this.models[index];

-

-      slice.attributes.site_allocation[ model.attributes.name ] = model.attributes.allocated;

-    }

-  },

-});

-

-XOSEditUsersView = Marionette.ItemView.extend({

-  template: '#tenant-edit-users',

-  viewInitializers: [],

-

-  onShow: function() {

-    _.each(this.viewInitializers, function(initializer) {

-      initializer();

-    });

-  },

-

-  templateHelpers: function() {

-    return {detailView: this, model: this.model};

-  }

-

-});

-

-XOSTenantSummaryView = XOSDetailView.extend({

-  events: {'change': 'onChange'},

-

-  onChange: function(e) {

-    XOSTenantApp.setDirty(true);

-  },

-

-  saveSuccess: function() {

-    XOSTenantApp.setDirty(false);

-  },

-

-});

-

-

-XOSTenantButtonView = Marionette.ItemView.extend({

-  template: '#xos-tenant-buttons-template',

-

-  events: {'click button.btn-tenant-create': 'createClicked',

-           'click button.btn-tenant-delete': 'deleteClicked',

-           'click button.btn-tenant-add-user': 'addUserClicked',

-           'click button.btn-tenant-save': 'saveClicked',

-           'click button.btn-tenant-download-ssh': 'downloadClicked',

-           },

-

-  createClicked: function() {

-    XOSTenantApp.addSlice();

-  },

-

-  deleteClicked: function() {

-    XOSTenantApp.deleteSlice(this.options.linkedView.model);

-  },

-

-  addUserClicked: function() {

-    XOSTenantApp.editUsers(this.options.linkedView.model);

-  },

-

-  downloadClicked: function() {

-    XOSTenantApp.downloadSSH(this.options.linkedView.model);

-  },

-

-  saveClicked: function(e) {

-    var model = this.options.linkedView.model;

-

-    model.tenantSiteCollection.putToSlice(model);

-    model.attributes.users = model.usersBuffer;

-

-    e.preventDefault();

-    this.options.linkedView.save();

-    //this.options.linkedView.submitContinueClicked.call(this.options.linkedView, e);

-    //XOSTenantApp.setDirty(false);

-  }

-});

-

-XOSTenantApp = new XOSApplication({

-  logTableId: '#logTable',

-  statusMsgId: '#statusMsg',

-  hideTabsByDefault: true,

-  dirty: false,

-  varName: 'XOSTenantApp',

-});

-

-XOSTenantApp.addRegions({

-  tenantSliceSelector: '#tenantSliceSelector',

-  tenantSummary: '#tenantSummary',

-  tenantSiteList: '#tenantSiteList',

-  tenantButtons: '#tenantButtons',

-  tenantAddSliceInterior: '#tenant-addslice-interior',

-  tenantEditUsersInterior: '#tenant-edit-users-interior',

-  tenantSSHCommandsInterior: '#tenant-ssh-commands-interior',

-});

-

-XOSTenantApp.setDirty = function(dirty) {

-  XOSTenantApp.dirty = dirty;

-  if (dirty) {

-    $('button.btn-tenant-save').addClass('btn-success');

-  }

-  else {

-    $('button.btn-tenant-save').removeClass('btn-success');

-  }

-};

-

-XOSTenantApp.buildViews = function() {

-  XOSTenantApp.tenantSites = new XOSTenantSiteCollection();

-

-  tenantSummaryClass = XOSTenantSummaryView.extend({

-    template: '#xos-detail-template',

-    app: XOSTenantApp,

-    detailFields: ['serviceClass', 'default_image', 'default_flavor', 'network_ports'],

-    fieldDisplayNames: {

-      serviceClass: 'Service Level',

-      default_flavor: 'Flavor',

-      default_image: 'Image',

-      mount_data_sets: 'Data Sets'

-    },

-    helpText: {

-      'serviceClass': 'Existing instances will be re-instantiated if changed',

-      'default_image': 'Existing instances will be re-instantiated if changed',

-      'default_flavor': 'Existing instances will be re-instantiated if changed'

-    },

-    onShow: function() {

-      // the slice selector is in a different table, so make every label cell the maximal width

-      make_same_width('#xos-tenant-view-panel', '.xos-label-cell');

-    },

-  });

-

-  XOSTenantApp.tenantSummaryView = tenantSummaryClass;

-

-  tenantAddClass = XOSDetailView.extend({

-    template: '#xos-detail-template',

-    app: XOSTenantApp,

-    detailFields: ['name', 'description']

-  });

-

-  XOSTenantApp.tenantAddView = tenantAddClass;

-

-  tenantSiteItemClass = XOSItemView.extend({

-    template: '#xos-listitem-template',

-    app: XOSTenantApp

-  });

-

-  XOSTenantApp.tenantSiteItemView = tenantSiteItemClass;

-

-  tenantSiteListClass = XOSDataTableView.extend({

-    template: '#xos-list-template',

-    app: XOSTenantApp,

-    childView: tenantSiteItemClass,

-    collection: XOSTenantApp.tenantSites,

-    title: 'sites',

-    inputType: {allocated: 'spinner'},

-    noDeleteColumn: true,

-    disablePaginate: true,

-    disableFilter: true,

-    fieldDisplayNames: {name: 'Site'},

-  });

-

-  XOSTenantApp.tenantSiteListView = tenantSiteListClass;

-

-  XOSTenantApp.tenantSliceSelectorView = SliceSelectorView.extend({

-    sliceChanged: function(id) {

-      XOSTenantApp.navToSlice(id);

-    },

-    filter: function(slice) {

-      return slice.attributes.current_user_can_see;

-    },

-  });

-

-  xos.sites.fetch();

-  xos.slicesPlus.fetch();

-  xos.tenantview.fetch();

-};

-

-make_choices = function(list_of_names, list_of_values) {

-  var result = [];

-  var displayName;

-

-  if (!list_of_values) {

-    for (var index in list_of_names) {

-      displayName = list_of_names[index];

-      result.push([displayName, displayName]);

-    }

-  }

-  else {

-    for (var index in list_of_names) {

-      displayName = list_of_names[index];

-      id = list_of_values[index];

-      result.push([displayName, id]);

-    }

-  }

-  return result;

-};

-

-XOSTenantApp.navToSlice = function(id) {

-  XOSTenantApp.viewSlice(xos.slicesPlus.get(id));

-};

-

-XOSTenantApp.adjustCollectionField = function(collectionName, id, fieldName, amount) {

-  model = XOSTenantApp[collectionName].get(id);

-  model.set(fieldName, Math.max(model.get(fieldName) + amount, 0));

-  XOSTenantApp.setDirty(true);

-};

-

-XOSTenantApp.addSlice = function() {

-  var app = this;

-

-  if (!xos.tenant().current_user_can_create_slice) {

-    window.alert('You do not have sufficient rights to create a slice on your site');

-    return;

-  }

-

-  model = new xos.slicesPlus.model({

-    site: xos.tenant().current_user_site_id,

-    name: xos.tenant().current_user_login_base + '_',

-    creator: xos.tenant().current_user_id

-  });

-

-  var detailView = new XOSTenantApp.tenantAddView({

-    model: model,

-    collection: xos.slicesPlus,

-    noSubmitButton: true,

-  });

-

-  detailView.dialog = $('#tenant-addslice-dialog');

-  app.tenantAddSliceInterior.show(detailView);

-

-  $('#tenant-addslice-dialog').dialog({

-    autoOpen: false,

-    modal: true,

-    width: 640,

-    buttons: {

-      'Create Slice': function() {

-        var addDialog = this;

-

-        detailView.synchronous = true;

-        detailView.afterSave = function() {

-          $(addDialog).dialog('close');

-          XOSTenantApp.navToSlice(detailView.model.id);

-        };

-        detailView.save();

-      },

-      'Cancel': function() {

-        $(this).dialog('close');

-      }

-    }

-  });

-  $('#tenant-addslice-dialog').dialog('open');

-};

-

-XOSTenantApp.editUsers = function(model) {

-  var app = this;

-  var detailView = new XOSEditUsersView({model: model, collection: xos.slicesPlus});

-

-  detailView.dialog = $('#tenant-edit-users-dialog');

-  app.tenantEditUsersInterior.show(detailView);

-

-  $('#tenant-edit-users-dialog').dialog({

-    autoOpen: false,

-    modal: true,

-    width: 640,

-    buttons: {

-      'Ok': function() {

-        var editDialog = this;

-        var user_ids = all_options($('#tenant-edit-users-dialog').find('.select-picker-to'));

-

-        user_ids = user_ids.map(function(x) {

-          return parseInt(x,10);

-        });

-

-        if (!array_same_elements(user_ids, model.usersBuffer)) {

-          XOSTenantApp.setDirty(true);

-        }

-        model.usersBuffer = user_ids;

-        $(editDialog).dialog('close');

-      },

-      'Cancel': function() {

-        $(this).dialog('close');

-      }

-    }

-  });

-  $('#tenant-edit-users-dialog').dialog('open');

-};

-

-XOSTenantApp.downloadSSH = function(model) {

-  var sshCommands = '';

-

-  for (index in model.attributes.sliceInfo.sshCommands) {

-    sshCommand = model.attributes.sliceInfo.sshCommands[index];

-    sshCommands = sshCommands + sshCommand + '\n';

-  }

-

-  if (sshCommands.length == 0) {

-    alert('this slice has no instantiated instances yet');

-    return;

-  }

-

-  var htmlView = new HTMLView({

-    html: '<pre style="overflow: auto; word-wrap: normal; white-space: pre; word-wrap: normal;">' +

-      sshCommands + '</pre>'

-  });

-

-  XOSTenantApp.tenantSSHCommandsInterior.show(htmlView);

-

-  $('#tenant-ssh-commands-dialog').dialog({

-    autoOpen: false,

-    modal: true,

-    width: 640,

-    buttons: {

-      'Download': function() {

-        var dlLink = document.createElement('a');

-

-        dlLink.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(sshCommands));

-        dlLink.setAttribute('download', 'sshcommands.txt');

-        dlLink.click();

-

-        //window.open('data:text/text,' + encodeURIComponent(sshCommands));

-      },

-      'Close': function() {

-        $(this).dialog('close');

-      },

-    }

-  });

-  $('#tenant-ssh-commands-dialog').dialog('open');

-};

-

-XOSTenantApp.deleteSlice = function(model) {

-  var app = this;

-

-  app.deleteDialog(model, function() {

-    app.viewSlice(undefined);

-  });

-};

-

-XOSTenantApp.viewSlice = function(model) {

-  if (XOSTenantApp.dirty) {

-    if (!confirm('The current instance has unsaved data -- view new instance anyway ?')) {

-      $('#tenantSliceSelector select').val(XOSTenantApp.currentSlice.id);

-      return;

-    }

-  }

-

-  XOSTenantApp.setDirty(false);

-

-  if (!model && xos.slicesPlus.models.length > 0) {

-    model = xos.slicesPlus.models[0];

-  }

-

-  if (model) {

-    sliceSelector = new XOSTenantApp.tenantSliceSelectorView({

-      collection: xos.slicesPlus,

-      selectedID: model ? model.id : null,

-    });

-

-    XOSTenantApp.sliceSelector = sliceSelector;

-    XOSTenantApp.tenantSliceSelector.show(sliceSelector);

-

-    tenantSummary = new XOSTenantApp.tenantSummaryView({

-      model: model,

-      choices: {

-        mount_data_sets: make_choices(xos.tenant().public_volume_names, null),

-        serviceClass: make_choices(xos.tenant().blessed_service_class_names, xos.tenant().blessed_service_classes),

-        default_image: make_choices(xos.tenant().blessed_image_names, xos.tenant().blessed_images),

-        default_flavor: make_choices(xos.tenant().blessed_flavor_names, xos.tenant().blessed_flavors)

-      },

-    });

-

-    XOSTenantApp.tenantSummary.show(tenantSummary);

-

-    tenantSites = new XOSTenantSiteCollection();

-    tenantSites.getFromSlice(model);

-    model.usersBuffer = model.attributes.users; /* save a copy of 'users' that we can edit. This prevents another view (developer) from overwriting our copy with a fetch from the server */

-    model.usersOrig = model.attributes.users;   /* save an immutable copy that we'll use for username lookups */

-    model.user_namesOrig = model.attributes.user_names;

-    model.tenantSiteCollection = tenantSites;

-    XOSTenantApp.tenantSites = tenantSites;

-

-    tenantSiteList = new XOSTenantApp.tenantSiteListView({collection: tenantSites});

-    XOSTenantApp.tenantSiteList.show(tenantSiteList);

-    // on xos.slicePlus.sort, need to update xostenantapp.tenantSites

-

-    XOSTenantApp.tenantButtons.show(

-      new XOSTenantButtonView({

-        app: XOSTenantApp,

-        linkedView: tenantSummary

-      })

-    );

-

-    XOSTenantApp.currentSlice = model;

-  }

-  else {

-    XOSTenantApp.tenantSliceSelector.show(new HTMLView({html: ''}));

-    XOSTenantApp.tenantSummary.show(new HTMLView({html: 'You have no slices'}));

-    XOSTenantApp.tenantSiteList.show(new HTMLView({html: ''}));

-    XOSTenantApp.tenantButtons.show(

-      new XOSTenantButtonView({

-        template: '#xos-tenant-buttons-noslice-template',

-        app: XOSTenantApp,

-        linkedView: tenantSummary

-      })

-    );

-  }

-};

-

-XOSTenantApp.sanityCheck = function() {

-  errors = [];

-  if (xos.tenant().blessed_deployments && xos.tenant().blessed_deployments.length == 0) {

-    errors.push('no blessed deployments');

-  }

-  if (xos.tenant().blessed_service_classes.length == 0) {

-    errors.push('no blessed service classes');

-  }

-  if (xos.tenant().blessed_flavors.length == 0) {

-    errors.push('no blessed flavors');

-  }

-  if (xos.tenant().blessed_images.length == 0) {

-    errors.push('no blessed images');

-  }

-  if (xos.tenant().blessed_sites.length == 0) {

-    errors.push('no blessed sites');

-  }

-  if (xos.tenant().current_user_site_id == null) {

-    errors.push('current user does not have a site');

-  }

-

-  if (errors.length > 0) {

-    t = templateFromId('#tenant-sanity-check');

-    $('#tenantSummary').html(t({

-      errors: errors,

-      blessed_deployment_names:

-      xos.tenant().blessed_deployment_names

-    }));

-    return false;

-  }

-

-  return true;

-};

-

-XOSTenantApp.collectionLoadChange = function() {

-  stats = xos.getCollectionStatus();

-

-  if (!XOSTenantApp.navigationStarted) {

-    if (stats['isLoaded'] + stats['failedLoad'] >= stats['startedLoad']) {

-      if (XOSTenantApp.sanityCheck()) {

-        XOSTenantApp.viewSlice(undefined);

-      }

-    }

-    else {

-      $('#tenantSummary').html('<h3>Loading...</h3><div id="xos-startup-progress"></div>');

-      $('#xos-startup-progress').progressbar({value: stats['completedLoad'], max: stats['startedLoad']});

-    }

-  }

-};

-

-XOSTenantApp.on('start', function() {

-  XOSTenantApp.buildViews();

-

-  // fire it once to initially show the progress bar

-  XOSTenantApp.collectionLoadChange();

-

-  // fire it each time the collection load status is updated

-  Backbone.on('xoslib:collectionLoadChange', XOSTenantApp.collectionLoadChange);

-});

-

-$(document).ready(function() {

-  XOSTenantApp.start();

-});

-/* eslint-enable */

+"use strict";angular.module("xos.tenant",["ngResource","ngCookies","ui.router","xos.helpers"]).config(["$stateProvider",function(e){e.state("user-list",{url:"/",template:"<users-list></users-list>"}).state("site",{url:"/site/:id",template:"<site-detail></site-detail>"}).state("createslice",{url:"/site/:site/slice/:id?",template:"<create-slice></create-slice>"})}]).config(["$httpProvider",function(e){e.interceptors.push("NoHyperlinks")}]).directive("usersList",function(){return{restrict:"E",scope:{},bindToController:!0,controllerAs:"vm",templateUrl:"templates/users-list.tpl.html",controller:["Sites","SlicesPlus",function(e,t){var i=this;this.tableConfig={columns:[{label:"Site1",prop:"name",link:function(e){return"/#/site/"+e.id}},{label:"Allocated",prop:"instance_total"},{label:"Ready",prop:"instance_total_ready"}]},e.query().$promise.then(function(e){return i.sites=e,t.query().$promise}).then(function(e){i.slices=e,i.site_list=i.returnData(i.sites,i.slices)})["catch"](function(e){throw new Error(e)}),this.returnData=function(e,t){var i,s=0,l=[];for(i=0;i<e.length;i++){var n=0,a=0;for(s=0;s<t.length;s++)null!=e[i].id&&null!=t[s].site&&e[i].id===t[s].site&&(n+=t[s].instance_total,a+=t[s].instance_total_ready);var r={id:e[i].id,name:e[i].name,instance_total:n,instance_total_ready:a};l.push(r)}return l}}]}}).directive("siteDetail",function(){return{restrict:"E",scope:{},bindToController:!0,controllerAs:"sl",templateUrl:"templates/slicelist.html",controller:["SlicesPlus","$stateParams",function(e,t){var i=this;this.siteId=t.id,this.tableConfig={columns:[{label:"Slice List",prop:"name",link:function(e){return"/#/site/"+e.site+"/slice/"+e.id}},{label:"Allocated",prop:"instance_total"},{label:"Ready",prop:"instance_total_ready"}]},e.query({site:t.id}).$promise.then(function(e){i.sliceList=e})["catch"](function(e){throw new Error(e)})}]}}).directive("createSlice",function(){return{restrict:"E",scope:{},bindToController:!0,controllerAs:"cs",templateUrl:"templates/createslice.html",controller:["Slices","SlicesPlus","Sites","Images","$stateParams","$http","$state","$q",function(e,t,i,s,l,n,a,r){var o=this;this.config={exclude:["site","password","last_login","mount_data_sets","default_flavor","creator","exposed_ports","networks","omf_friendly","omf_friendly","no_sync","no_policy","lazy_blocked","write_protect","deleted","backend_status","backend_register","policed","enacted","updated","created","validators","humanReadableName"],formName:"SliceDetails",feedback:{show:!1,message:"Form submitted successfully !!!",type:"success"},actions:[{label:"Save",icon:"ok",cb:function(e,t){d(e,t).then(function(){a.go("site",{id:o.model.site})})},"class":"success"},{label:"Save and continue editing",icon:"ok",cb:function(e,t){d(e,t)},"class":"primary"},{label:"Save and add another",icon:"ok",cb:function(e,t){d(e,t).then(function(){a.go("createslice",{site:o.model.site,id:""})})},"class":"primary"}],fields:{site:{label:"Site",type:"select",validators:{required:!0},hint:"The Site this Slice belongs to",options:[]},name:{label:"Name",type:"string",hint:"The Name of the Slice",validators:{required:!0}},serviceClass:{label:"ServiceClass",type:"select",validators:{required:!0},hint:"The Site this Slice belongs to",options:[{id:1,label:"Best effort"}]},enabled:{label:"Enabled",type:"boolean",hint:"Status for this Slice"},description:{label:"Description",type:"string",hint:"High level description of the slice and expected activities",validators:{required:!1,minlength:10}},service:{label:"Service",type:"select",validators:{required:!1},options:[{id:0,label:"--------"}]},slice_url:{label:"Slice url",type:"string",validators:{required:!1,minlength:10}},max_instances:{label:"Max Instances",type:"number",validators:{required:!1,min:0}},default_isolation:{label:"Default Isolation",type:"select",validators:{required:!1},options:[{id:"vm",label:"Virtual Machine"},{id:"container",label:"Container"},{id:"container_vm",label:"Container in VM"}]},default_image:{label:"Default image",type:"select",validators:{required:!1},options:[]},network:{label:"Network",type:"select",validators:{required:!1},options:[{id:"default",label:"Default"},{id:"host",label:"Host"},{id:"bridged",label:"Bridged"},{id:"noauto",label:"No Automatic Networks"}]}}};var c;s.query().$promise.then(function(e){o.users=e,c=o.users,o.optionValImg=o.setData(c,{field1:"id",field2:"name"}),o.config.fields.default_image.options=o.optionValImg})["catch"](function(e){throw new Error(e)}),this.setData=function(e,t){var i,s=[];for(i=0;i<e.length;i++){var l={id:e[i][t.field1],label:e[i][t.field2]};s.push(l)}return s},l.id?(delete this.config.fields.site,this.config.exclude.push("site"),e.get({id:l.id}).$promise.then(function(e){o.users=e,c=e,o.model=c})["catch"](function(e){throw new Error(e)})):(this.model={},n.get("/xoslib/tenantview/").success(function(e){o.userList=e,o.model.creator=o.userList.current_user_id}),i.query().$promise.then(function(e){o.users_site=e,o.optionVal=o.setData(o.users_site,{field1:"id",field2:"name"}),o.config.fields.site.options=o.optionVal})["catch"](function(e){throw new Error(e)}));var d=function(t,i){var s=r.defer();if(delete t.networks,i.$valid){if(t.id)var l=e.update(t).$promise;else var l=e.save(t).$promise;l.then(function(e){o.model=e,o.config.feedback.show=!0,s.resolve(o.model)})["catch"](function(e){o.config.feedback.show=!0,o.config.feedback.type="danger",e.data&&e.data.detail?o.config.feedback.message=e.data.detail:o.config.feedback.message=e.statusText,s.reject(e)})}return s.promise}}]}}),angular.module("xos.tenant").run(["$templateCache",function(e){e.put("templates/createslice.html",'<!--<xos-table config="cs.tableConfig" data="cs.sites"></xos-table>-->\r\n<h2>Slice Details</h2>\r\n<hr></hr>\r\n<xos-form ng-model="cs.model" config="cs.config" ></xos-form>\r\n\r\n<!--<pre>-->\r\n<!--&lt;!&ndash;{{cs.users | json}}&ndash;&gt;-->\r\n\r\n<!--{{cs.users.name | json}}-->\r\n\r\n<!--</pre>-->'),e.put("templates/slicelist.html",'<!--<span ng-bind="siteNameSe"></span>-->\r\n<!--<xos-field></xos-field>-->\r\n<a class="addlink btn btn-info" ui-sref="createslice({site: sl.siteId})"><i class="glyphicon glyphicon-plus-sign"></i> Create Slice</a>\r\n<xos-table config="sl.tableConfig" data="sl.sliceList"></xos-table>\r\n<!--<div ui-view="sliceDetails"></div>-->\r\n<!--<pre>{{sl.users[0].site}}</pre>-->\r\n'),e.put("templates/users-list.tpl.html",'<xos-table config="vm.tableConfig" data="vm.site_list"></xos-table>')}]),angular.module("xos.tenant").run(["$location",function(e){e.path("/")}]);
\ No newline at end of file