Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(72)

Unified Diff: app/store/env/sandbox.js

Issue 13237052: Update sandbox to send proper data on ServiceGet
Patch Set: Update sandbox to send proper data on ServiceGet Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « app/store/env/fakebackend.js ('k') | app/views/databinding.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/store/env/sandbox.js
=== modified file 'app/store/env/sandbox.js'
--- app/store/env/sandbox.js 2013-09-03 08:38:09 +0000
+++ app/store/env/sandbox.js 2013-09-04 13:30:42 +0000
@@ -1192,11 +1192,41 @@
*/
handleClientServiceGet: function(data, client, state) {
var reply = state.getService(data.Params.ServiceName);
- // TODO Include the optional Config or Constraints in the response.
- client.receive({
+ var response = {
RequestId: data.RequestId,
- Error: reply.error,
- Response: {Service: data.Params.ServiceName}});
+ };
+ if (reply.error) {
+ response.Error = reply.error;
+ client.receive(response);
+ } else {
+ var charmName = reply.result.charm;
+
+ // Get the charm to load the full options data as the service config
+ // format.
+ state.getCharm(charmName, function(payload) {
+ var charmData = payload.result;
+ var formattedConfig = {};
+ var backendConfig = reply.result.config;
+
+ Y.Object.each(charmData.options, function(value, key) {
+ formattedConfig[key] = charmData.options[key];
+ if (backendConfig[key]) {
+ formattedConfig[key].value = backendConfig[key];
+ } else {
+ formattedConfig[key].value = charmData.options[key]['default'];
+ }
+ });
+
+ response.Response = {
+ Service: data.Params.ServiceName,
+ Charm: charmName,
+ Config: formattedConfig,
+ Constraints: reply.result.constraints
+ };
+ client.receiveNow(response);
+ });
+ }
+
},
/**
« no previous file with comments | « app/store/env/fakebackend.js ('k') | app/views/databinding.js » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b