Skip to content

Commit 49dceb4

Browse files
committed
UI/UX improvements
1 parent 59ff54c commit 49dceb4

File tree

6 files changed

+108
-78
lines changed

6 files changed

+108
-78
lines changed

src/client/components/composer/NewRequest/GRPCAutoInputForm.jsx

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ class GRPCAutoInputForm extends Component {
101101
...this.state
102102
}, () => {
103103
let req;
104-
// let results = [];
105104
let results = {};
106-
let query = '';
107105
/*
108106
for each service obj in the services array, if its name matches the current selected service option then:
109107
- iterate through the rpcs and if its name matches the current selected request then save the name of req/rpc
@@ -118,34 +116,22 @@ class GRPCAutoInputForm extends Component {
118116
}
119117
}
120118
for (const message of service.messages) {
121-
// console.log('message: ', message);
122119
if (message.name === req ) {
123120
for (const key in message.def) {
124121
// if message type is a nested message (message.def.nested === true)
125-
// message.def = key: {dependent: dependent.message.def}
126-
// console.log('message.def.nested: ', message.def[key].nested);
127-
// console.log('key: ', key);
128122
if (message.def[key].nested) {
129123
for (const submess of service.messages) {
130-
// console.log('submess: ', submess);
131-
// console.log('submess.name: ', submess.name);
132-
// console.log('message.def[key].dependent: ', message.def[key].dependent);
133124
if (submess.name === message.def[key].dependent ) {
134125
// define obj for the submessage definition
135-
let tempObj = {};
126+
let subObj = {};
136127
for (const subKey in submess.def) {
137-
tempObj[subKey] = submess.def[subKey].type.slice(5).toLowerCase()
128+
subObj[subKey] = submess.def[subKey].type.slice(5).toLowerCase()
138129
}
139-
// console.log('tempObj: ', tempObj);
140-
// JSON.stringify(JSON.parse(this.props.newRequestBody.bodyContent), null, 4
141-
// results.push(`"${key}":${JSON.stringify(tempObj, null, 2)}`)
142-
results[key] = tempObj
130+
results[key] = subObj
143131
break;
144132
}
145133
}
146134
} else {
147-
// console.log('message.def: ', message.def);
148-
// results.push(`"${key}": "${message.def[key].type.slice(5).toLowerCase()}"`)
149135
results[key] = message.def[key].type.slice(5).toLowerCase()
150136
}
151137
}
@@ -154,34 +140,12 @@ class GRPCAutoInputForm extends Component {
154140
}
155141
}
156142
}
157-
// console.log('resultsobj: ', results)
158-
// query for messages with single key:value pair
159-
// if (results.length === 1) {
160-
// query = results[0];
161-
// }
162-
// query for messages with multiple key:value pairs
163-
// else {
164-
// for (let i = 0; i < results.length; i++) {
165-
// query = `${query},
166-
// ${results[i]}`
167-
// }
168-
// query = query.slice(1).trim();
169-
// }
170-
// set query in streamsArr
171-
// if (streamsArr[0] !== '') {
172-
// streamsArr[0].query = `{
173-
// ${query}
174-
// }`;
175-
// }
143+
// push JSON formatted query in streamContent arr
176144
const queryJSON = JSON.stringify(results, null, 4)
177145
if (streamsArr[0] !== '') {
178146
streamsArr[0].query = queryJSON
179147
}
180148
// remove initial empty string then push new query to stream content arr
181-
// streamContent.pop();
182-
// streamContent.push(`{
183-
// ${query}
184-
// }`);
185149
streamContent.pop();
186150
streamContent.push(queryJSON);
187151
// set state in the store with updated content

src/client/components/composer/NewRequest/GRPCBodyEntryForm.jsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,9 @@ class GRPCBodyEntryForm extends Component {
4747
// construct new stream body obj & push into the streamsArr
4848
const newStream = {};
4949
newStream.id = this.props.newRequestStreams.count;
50-
// newStream.query = `{
51-
// ${firstBodyQuery}
52-
// }`;
53-
newStream.query = firstBodyQuery
50+
newStream.query = firstBodyQuery
5451
streamsArr.push(newStream)
5552
// push query of initial stream body into streamContent array
56-
// streamContent.push(`{
57-
// ${firstBodyQuery}
58-
// }`);
5953
streamContent.push(firstBodyQuery);
6054
// update mew state in the store
6155
this.props.setNewRequestStreams({

src/client/components/composer/NewRequest/GRPCBodyStream.jsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,8 @@ class GRPCBodyStream extends Component {
7777
</button>
7878
)
7979
}
80-
/*
81-
pseudocode for the return section
82-
- renders the stream body (and the stream number if for client or bidirectional stream)
83-
*/
80+
// pseudocode for the return section:
81+
// renders the stream body (and the stream number if for client or bidirectional stream)
8482
return (
8583
<div style={{ display: 'flex' }}>
8684
<div>
Lines changed: 101 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,111 @@
1+
// Copyright 2015 gRPC authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
syntax = "proto3";
216

3-
package helloworld;
17+
option java_multiple_files = true;
18+
option java_package = "io.grpc.examples.routeguide";
19+
option java_outer_classname = "RouteGuideProto";
20+
option objc_class_prefix = "RTG";
21+
22+
package routeguide;
23+
24+
// Interface exported by the server.
25+
service RouteGuide {
26+
// A simple RPC.
27+
//
28+
// Obtains the feature at a given position.
29+
//
30+
// A feature with an empty name is returned if there's no feature at the given
31+
// position.
32+
rpc GetFeature(Point) returns (Feature) {}
33+
34+
// A server-to-client streaming RPC.
35+
//
36+
// Obtains the Features available within the given Rectangle. Results are
37+
// streamed rather than returned at once (e.g. in a response message with a
38+
// repeated field), as the rectangle may cover a large area and contain a
39+
// huge number of features.
40+
rpc ListFeatures(Rectangle) returns (stream Feature) {}
441

5-
// The greeting service definition.
6-
service Greeter {
7-
// Sends a greeting
8-
rpc SayHello (HelloRequest) returns (HelloReply) {}
9-
rpc SayHelloCS (stream HelloRequest) returns (HelloReply) {}
10-
rpc SayHellos (HelloRequest) returns (stream HelloReply) {}
11-
rpc SayHelloBidi (stream HelloRequest) returns (stream HelloReply) {}
42+
// A client-to-server streaming RPC.
43+
//
44+
// Accepts a stream of Points on a route being traversed, returning a
45+
// RouteSummary when traversal is completed.
46+
rpc RecordRoute(stream Point) returns (RouteSummary) {}
47+
48+
// A Bidirectional streaming RPC.
49+
//
50+
// Accepts a stream of RouteNotes sent while a route is being traversed,
51+
// while receiving other RouteNotes (e.g. from other users).
52+
rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
53+
}
54+
55+
// Points are represented as latitude-longitude pairs in the E7 representation
56+
// (degrees multiplied by 10**7 and rounded to the nearest integer).
57+
// Latitudes should be in the range +/- 90 degrees and longitude should be in
58+
// the range +/- 180 degrees (inclusive).
59+
message Point {
60+
int32 latitude = 1;
61+
int32 longitude = 2;
1262
}
1363

14-
service Butler {
15-
// Sends a greeting
16-
rpc SayHello (HelloRequest) returns (HelloReply) {}
17-
rpc SayHelloCS (stream HelloRequest) returns (HelloReply) {}
18-
rpc SayHellos (HelloRequest) returns (stream HelloReply) {}
19-
rpc SayHelloBidi (stream HelloRequest) returns (stream HelloReply) {}
64+
// A latitude-longitude rectangle, represented as two diagonally opposite
65+
// points "lo" and "hi".
66+
message Rectangle {
67+
// One corner of the rectangle.
68+
Point lo = 1;
69+
70+
// The other corner of the rectangle.
71+
Point hi = 2;
2072
}
21-
// The request message containing the user's name.
22-
message HelloRequest {
73+
74+
// A feature names something at a given point.
75+
//
76+
// If a feature could not be named, the name is empty.
77+
message Feature {
78+
// The name of the feature.
2379
string name = 1;
80+
81+
// The point where the feature is detected.
82+
Point location = 2;
83+
}
84+
85+
// A RouteNote is a message sent while at a given point.
86+
message RouteNote {
87+
// The location from which the message is sent.
88+
Point location = 1;
89+
90+
// The message to be sent.
91+
string message = 2;
2492
}
2593

26-
// The response message containing the greetings
27-
message HelloReply {
28-
string message = 1;
94+
// A RouteSummary is received in response to a RecordRoute rpc.
95+
//
96+
// It contains the number of individual points received, the number of
97+
// detected features, and the total distance covered as the cumulative sum of
98+
// the distance between each point.
99+
message RouteSummary {
100+
// The number of points received.
101+
int32 point_count = 1;
102+
103+
// The number of known features passed while traversing the route.
104+
int32 feature_count = 2;
105+
106+
// The distance covered in metres.
107+
int32 distance = 3;
108+
109+
// The duration of the traversal in seconds.
110+
int32 elapsed_time = 4;
29111
}

src/client/components/containers/HistoryContainer.jsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import { connect } from 'react-redux';
33
import * as actions from '../../actions/actions';
44
import HistoryDate from '../display/HistoryDate.jsx';
55
import ClearHistoryBtn from '../display/ClearHistoryBtn.jsx';
6-
import historyController from '../../controllers/historyController';
7-
8-
const { dialog } = require('electron').remote;
9-
import parse from 'date-fns/parse'
106

117
const mapStateToProps = store => ({
128
history: store.business.history,
@@ -43,7 +39,6 @@ class HistoryContainer extends Component {
4339
setNewRequestCookies={this.props.setNewRequestCookies}
4440
setNewRequestBody={this.props.setNewRequestBody}
4541
setNewRequestStreams={this.props.setNewRequestStreams}
46-
// newRequestStreams={this.props.newRequestStreams}
4742
/>
4843
})
4944

src/client/components/display/HistoryDate.jsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ class HistoryDate extends Component {
1313
}
1414

1515
focusOnForm(event) {
16-
// console.log('history date this is the changed tab',document.querySelector('.composer_url_input'))
17-
// console.log('this is the new request field', this.props.NewRequestFields)
1816
let composerUrlField = document.querySelector('.composer_url_input');
1917
composerUrlField.focus()
2018
}
@@ -37,7 +35,6 @@ class HistoryDate extends Component {
3735
setNewRequestCookies={this.props.setNewRequestCookies}
3836
setNewRequestBody={this.props.setNewRequestBody}
3937
setNewRequestStreams={this.props.setNewRequestStreams}
40-
// newRequestStreams={this.props.newRequestStreams}
4138
/>
4239
})
4340

0 commit comments

Comments
 (0)