Set the power cap

Created toggle button to enable power cap and a text field to set
it. This form is similar to the set network form.
Moved logic for displaying the power cap as disabled to the
overview controller.

Resolves openbmc/openbmc#3221

Tested: Set the power cap on a Witherspoon
Change-Id: I62346fe3ed123b9df58d159cee2584937d46213c
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index a1fad8a..042dde4 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -1388,12 +1388,39 @@
                    withCredentials: true
                  })
               .then(function(response) {
-                var json = JSON.stringify(response.data);
-                var content = JSON.parse(json);
-
-                return (false == content.data.PowerCapEnable) ?
-                    Constants.POWER_CAP_TEXT.disabled :
-                    content.data.PowerCap + ' ' + Constants.POWER_CAP_TEXT.unit;
+                return response.data;
+              });
+        },
+        setPowerCapEnable: function(powerCapEnable) {
+          return $http({
+                   method: 'PUT',
+                   url: DataService.getHost() +
+                       '/xyz/openbmc_project/control/host0/power_cap/attr/PowerCapEnable',
+                   headers: {
+                     'Accept': 'application/json',
+                     'Content-Type': 'application/json'
+                   },
+                   withCredentials: true,
+                   data: JSON.stringify({'data': powerCapEnable})
+                 })
+              .then(function(response) {
+                return response.data;
+              });
+        },
+        setPowerCap: function(powerCap) {
+          return $http({
+                   method: 'PUT',
+                   url: DataService.getHost() +
+                       '/xyz/openbmc_project/control/host0/power_cap/attr/PowerCap',
+                   headers: {
+                     'Accept': 'application/json',
+                     'Content-Type': 'application/json'
+                   },
+                   withCredentials: true,
+                   data: JSON.stringify({'data': powerCap})
+                 })
+              .then(function(response) {
+                return response.data;
               });
         },
         setHostname: function(hostname) {