add: in production

This commit is contained in:
Charles Hathaway
2023-10-03 16:17:34 -07:00
parent dfb8584910
commit d16d1e0ac5
12 changed files with 339 additions and 57 deletions
+40 -22
View File
@@ -10,9 +10,9 @@ void main() async {
Logger logger = Logger();
logger.i("Establishing connection...");
final channel = ClientChannel(
'192.168.0.65',
port: 8080,
options: const ChannelOptions(credentials: ChannelCredentials.insecure()),
'home.chathaway.codes',
//port: 80,
//options: const ChannelOptions(credentials: ChannelCredentials.insecure()),
channelShutdownHandler: () {
logger.e("Channel shutdown unexpectedly");
},
@@ -54,7 +54,7 @@ class MyApp extends StatelessWidget {
client,
sessionService,
title: 'Home Sensors',
home: "home1234",
home: "Sunnyvale",
),
);
}
@@ -85,12 +85,14 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> {
String topMessage = "Creating session...";
List<Call> camerasToRender = [];
List<Widget> samples = [];
@override
void initState() {
super.initState();
_getSession();
_listCameras();
_listSensors();
}
_getSession() async {
@@ -99,6 +101,20 @@ class _MyHomePageState extends State<MyHomePage> {
setState(() {});
}
_listSensors() async {
var callOptions = CallOptions(metadata: {
'Authorization': await widget.sessionService.getAuthToken(widget.home)
});
var resp = await widget.client
.listSamples(ListSamplesRequest(), options: callOptions);
for (var sample in resp.samples) {
samples
.add(Text("${sample.type}: ${sample.reading} on ${sample.cameraId}"));
}
setState(() {});
}
_listCameras() async {
var callOptions = CallOptions(metadata: {
'Authorization': await widget.sessionService.getAuthToken(widget.home)
@@ -126,24 +142,26 @@ class _MyHomePageState extends State<MyHomePage> {
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Column(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: SingleChildScrollView(
child: Column(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
children: <Widget>[
Text(topMessage),
] +
camerasToRender,
),
);
children: <Widget>[
Text(topMessage),
] +
samples +
camerasToRender,
),
));
}
}