forked from apache/beam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tour of Beam][Frontend] Content Tree and SDK models (apache#23316) (a…
…pache#23417) * Content Tree and SDK models (apache#23316) models from JSON (apache#23316) removed generated files (apache#23316) const model constructors (apache#23316) fvm config (apache#23316) ignore *g.dart files (apache#23316) server node, group, unit models abstract node model (apache#23316) node type in enums (apache#23316) gitignore sort (apache#23316) sdk model (apache#23316) api calls (apache#23316) getSdks in SdkDropdown (apache#23316) requests in functions (apache#23316) k in functions (apache#23316) server folder in models (apache#23316) review comments (apache#23316) Move response model files (apache#23316) Add CloudFunctionsTobClient (apache#23316) Move a file (apache#23316) Rename a file (apache#23316) ContentTreeCache (apache#23316) ContentTreeCache (apache#23316) * Update README with building manual (apache#23316) * Move hardcoded URLs to a config file (apache#23316) Co-authored-by: darkhan.nausharipov <[email protected]> Co-authored-by: Alexey Inkin <[email protected]>
- Loading branch information
1 parent
9b2f87d
commit 41ddc4a
Showing
28 changed files
with
903 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
learning/tour-of-beam/frontend/lib/cache/content_tree.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import 'dart:async'; | ||
|
||
import 'package:flutter/widgets.dart'; | ||
|
||
import '../models/content_tree.dart'; | ||
import '../repositories/client/client.dart'; | ||
|
||
class ContentTreeCache extends ChangeNotifier { | ||
final TobClient client; | ||
|
||
ContentTreeModel? _contentTree; | ||
Future<ContentTreeModel>? _future; | ||
|
||
ContentTreeCache({ | ||
required this.client, | ||
}); | ||
|
||
ContentTreeModel? getContentTree() { | ||
if (_future == null) { | ||
unawaited(_loadContentTree()); | ||
} | ||
|
||
return _contentTree; | ||
} | ||
|
||
Future<ContentTreeModel?> _loadContentTree() async { | ||
_future = client.getContentTree(); | ||
final result = await _future!; | ||
_contentTree = result; | ||
|
||
notifyListeners(); | ||
return _contentTree; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import 'dart:async'; | ||
|
||
import 'package:flutter/widgets.dart'; | ||
|
||
import '../models/sdk.dart'; | ||
import '../repositories/client/client.dart'; | ||
import '../repositories/models/get_sdks_response.dart'; | ||
|
||
class SdkCache extends ChangeNotifier { | ||
final TobClient client; | ||
|
||
final _sdks = <SdkModel>[]; | ||
Future<GetSdksResponse>? _future; | ||
|
||
SdkCache({ | ||
required this.client, | ||
}); | ||
|
||
List<SdkModel> getSdks() { | ||
if (_future == null) { | ||
unawaited(_loadSdks()); | ||
} | ||
|
||
return _sdks; | ||
} | ||
|
||
Future<List<SdkModel>> _loadSdks() async { | ||
_future = client.getSdks(); | ||
final result = await _future!; | ||
|
||
_sdks.addAll(result.sdks); | ||
notifyListeners(); | ||
return _sdks; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
learning/tour-of-beam/frontend/lib/components/builders/content_tree.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import 'package:flutter/widgets.dart'; | ||
import 'package:get_it/get_it.dart'; | ||
|
||
import '../../cache/content_tree.dart'; | ||
import '../../models/content_tree.dart'; | ||
|
||
class ContentTreeBuilder extends StatelessWidget { | ||
final ValueWidgetBuilder<ContentTreeModel?> builder; | ||
|
||
const ContentTreeBuilder({ | ||
required this.builder, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final cache = GetIt.instance.get<ContentTreeCache>(); | ||
|
||
return AnimatedBuilder( | ||
animation: cache, | ||
builder: (context, child) => builder( | ||
context, | ||
cache.getContentTree(), | ||
child, | ||
), | ||
); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
learning/tour-of-beam/frontend/lib/components/builders/sdks_builder.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import 'package:flutter/widgets.dart'; | ||
import 'package:get_it/get_it.dart'; | ||
|
||
import '../../cache/sdk_cache.dart'; | ||
import '../../models/sdk.dart'; | ||
|
||
class SdksBuilder extends StatelessWidget { | ||
final ValueWidgetBuilder<List<SdkModel>> builder; | ||
|
||
const SdksBuilder({ | ||
required this.builder, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final cache = GetIt.instance.get<SdkCache>(); | ||
|
||
return AnimatedBuilder( | ||
animation: cache, | ||
builder: (context, child) => builder(context, cache.getSdks(), child), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// TODO(alexeyinkin): Generate this file on deployment. | ||
|
||
const _cloudFunctionsProjectRegion = 'us-central1'; | ||
const _cloudFunctionsProjectId = 'tour-of-beam-2'; | ||
const cloudFunctionsBaseUrl = 'https://' | ||
'$_cloudFunctionsProjectRegion-$_cloudFunctionsProjectId' | ||
'.cloudfunctions.net'; | ||
|
||
// Copied from Playground's config.g.dart | ||
|
||
const String kAnalyticsUA = 'UA-73650088-2'; | ||
const String kApiClientURL = | ||
'https://backend-router-beta-dot-apache-beam-testing.appspot.com'; | ||
const String kApiJavaClientURL = | ||
'https://backend-java-beta-dot-apache-beam-testing.appspot.com'; | ||
const String kApiGoClientURL = | ||
'https://backend-go-beta-dot-apache-beam-testing.appspot.com'; | ||
const String kApiPythonClientURL = | ||
'https://backend-python-beta-dot-apache-beam-testing.appspot.com'; | ||
const String kApiScioClientURL = | ||
'https://backend-scio-beta-dot-apache-beam-testing.appspot.com'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.