removing plural from model names. some cleanup
[plstackapi.git] / planetstack / core / xoslib / static / js / xoslib / xos-backbone.js
index e990e18..28fd72b 100644 (file)
@@ -6,6 +6,7 @@ if (! window.XOSLIB_LOADED ) {
     SLICEROLE_API = "/plstackapi/slice_roles/";
     NODE_API = "/plstackapi/nodes/";
     SITE_API = "/plstackapi/sites/";
+    SITEDEPLOYMENT_API = "/plstackapi/sitedeployments/";
     USER_API = "/plstackapi/users/";
     USERDEPLOYMENT_API = "/plstackapi/user_deployments/";
     DEPLOYMENT_API = "/plstackapi/deployments/";
@@ -18,6 +19,8 @@ if (! window.XOSLIB_LOADED ) {
     SLICEPRIVILEGE_API = "/plstackapi/slice_privileges/";
     NETWORKDEPLOYMENT_API = "/plstackapi/networkdeployments/";
     FLAVOR_API = "/plstackapi/flavors/";
+    CONTROLLER_API = "/plstackapi/controllers/";
+    CONTROLLERSITEDEPLOYMENT_API = "/plstackapi/controllersitedeploymentses";
 
     /* changed as a side effect of the big rename
     SLICEDEPLOYMENT_API = "/plstackapi/slice_deployments/";
@@ -397,6 +400,41 @@ if (! window.XOSLIB_LOADED ) {
             }
         };
 
+        /* defining the models
+
+           modelName          - name of the model.
+
+           relatedCollections - collections which should be drawn as an inline
+                                list when the detail view is displayed.
+                                Format: <collection>:<collectionFieldName> where
+                                <collectionFieldName> is the name of the field
+                                in the collection that points back to the
+                                collection in the detail view.
+
+           foreignCollections - collections which are used in idToName() calls
+                                when presenting the data to the user. Used to
+                                create a listento event. Somewhat
+                                redundant with foreignFields.
+
+           foreignFields -      <localFieldName>:<collection>. Used to
+                                automatically map ids into humanReadableNames
+                                when presenting data to the user.
+
+           m2mfields -          <localFieldName>:<colleciton>. Used to
+                                populate choices in picker lists. Simalar to
+                                foreignFields.
+
+           listFields -         fields to display in lists
+
+           detailFields -       fields to display in detail views
+
+           addFields -          fields to display in popup add windows
+
+           inputType -          by default, "detailFields" will be displayed
+                                as text input controls. This will let you display
+                                a checkbox or a picker instead.
+        */
+
         define_model(this, {urlRoot: SLIVER_API,
                             relatedCollections: {"networkSlivers": "sliver"},
                             foreignCollections: ["slices", "deployments", "images", "nodes", "users", "flavors"],
@@ -454,13 +492,23 @@ if (! window.XOSLIB_LOADED ) {
                             });
 
         define_model(this, {urlRoot: SITE_API,
-                            relatedCollections: {"users": "site", "slices": "site", "nodes": "site"},
+                            relatedCollections: {"users": "site", "slices": "site", "nodes": "site", "siteDeployments": "site"},
                             modelName: "site",
                             listFields: ["backend_status", "id", "name", "site_url", "enabled", "login_base", "is_public", "abbreviated_name"],
                             detailFields: ["backend_status", "name", "abbreviated_name", "url", "enabled", "is_public", "login_base"],
                             inputType: {"enabled": "checkbox", "is_public": "checkbox"},
                             });
 
+        define_model(this, {urlRoot: SITEDEPLOYMENT_API,
+                            relatedCollections: {"controllerSiteDeployment": "site_deployment"},
+                            foreignCollections: ["sites", "deployments", "controllers"],
+                            foreignFields: {"site": "sites", "deployment": "deployments", "controller": "controllers"},
+                            modelName: "siteDeployment",
+                            listFields: ["backend_status", "id", "site", "deployment", "controller", "availability_zone"],
+                            detailFields: ["backend_status", "site", "deployment", "controller", "availability_zone"],
+                            inputType: {"enabled": "checkbox", "is_public": "checkbox"},
+                            });
+
         define_model(this, {urlRoot: USER_API,
                             relatedCollections: {"slicePrivileges": "user", "slices": "owner"},
                             foreignCollections: ["sites"],
@@ -488,8 +536,8 @@ if (! window.XOSLIB_LOADED ) {
 
         define_model(this, {urlRoot: NETWORKTEMPLATE_API,
                             modelName: "networkTemplate",
-                            listFields: ["backend_status", "id", "name", "visibility", "translation", "sharedNetworkName", "sharedNetworkId"],
-                            detailFields: ["backend_status", "name", "description", "visibility", "translation", "sharedNetworkName", "sharedNetworkId"],
+                            listFields: ["backend_status", "id", "name", "visibility", "translation", "shared_network_name", "shared_network_id"],
+                            detailFields: ["backend_status", "name", "description", "visibility", "translation", "shared_network_name", "shared_network_id"],
                             });
 
         define_model(this, {urlRoot: NETWORK_API,
@@ -522,6 +570,20 @@ if (! window.XOSLIB_LOADED ) {
                             inputType: {"default": "checkbox", "deployments": "picker"},
                             });
 
+        define_model(this, {urlRoot: CONTROLLER_API,
+                            modelName: "controller",
+                            listFields: ["backend_status", "id", "name", "version", "backend_type"],
+                            detailFields: ["backend_status", "name", "version", "backend_type", "auth_url", "admin_user", "admin_password", "admin_tenant"],
+                            });
+
+        define_model(this, {urlRoot: CONTROLLERSITEDEPLOYMENT_API,
+                            modelName: "controllerSiteDeployment",
+                            foreignCollections: ["site_deployments", "controllers"],
+                            foreignFields: {"site_deployment": "siteDeployments", "controller": "controllers"},
+                            listFields: ["backend_status", "id", "site_deployment", "controller", "tenant_id"],
+                            detailFields: ["backend_status", "site_deployment", "controller", "tenant_id"],
+                            });
+
         /* DELETED in site-controller branch
 
         define_model(this, {urlRoot: NETWORKDEPLOYMENT_API,
@@ -549,7 +611,7 @@ if (! window.XOSLIB_LOADED ) {
 
         END stuff deleted in site-controller branch */
 
-        /* not deleted, but seems obsolete and should be replaced by ManyToMany
+        /* not deleted, but obsolete since it has degenerated to a ManyToMany with no other fields
 
         define_model(this, {urlRoot: IMAGEDEPLOYMENTS_API,
                             modelName: "imageDeployment",