-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add function field to pulsar instance (#11)
- Loading branch information
Showing
13 changed files
with
287 additions
and
42 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
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
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
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
104 changes: 104 additions & 0 deletions
104
lib/ui/pulsar/widget/pulsar_partitioned_topic_list.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,104 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:paas_dashboard_flutter/generated/l10n.dart'; | ||
import 'package:paas_dashboard_flutter/route/page_route_const.dart'; | ||
import 'package:paas_dashboard_flutter/ui/component/searchable_title.dart'; | ||
import 'package:paas_dashboard_flutter/ui/util/data_cell_util.dart'; | ||
import 'package:paas_dashboard_flutter/ui/util/exception_util.dart'; | ||
import 'package:paas_dashboard_flutter/ui/util/form_util.dart'; | ||
import 'package:paas_dashboard_flutter/ui/util/spinner_util.dart'; | ||
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_namespace_view_model.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
class PulsarPartitionedTopicListWidget extends StatefulWidget { | ||
PulsarPartitionedTopicListWidget(); | ||
|
||
@override | ||
State<StatefulWidget> createState() { | ||
return new PulsarPartitionedTopicListWidgetState(); | ||
} | ||
} | ||
|
||
class PulsarPartitionedTopicListWidgetState extends State<PulsarPartitionedTopicListWidget> { | ||
final searchTextController = TextEditingController(); | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
final vm = Provider.of<PulsarNamespaceViewModel>(context, listen: false); | ||
vm.fetchTopics(); | ||
searchTextController.addListener(() { | ||
vm.filter(searchTextController.text); | ||
}); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
searchTextController.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final vm = Provider.of<PulsarNamespaceViewModel>(context); | ||
if (vm.loading) { | ||
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) { | ||
SpinnerUtil.create(); | ||
}); | ||
} | ||
ExceptionUtil.processLoadExceptionPageable(vm, context); | ||
ExceptionUtil.processOpExceptionPageable(vm, context); | ||
vm.setDataConverter((item) => DataRow( | ||
onSelectChanged: (bool? selected) { | ||
Navigator.pushNamed(context, PageRouteConst.PulsarTopic, | ||
arguments: item.deepCopy()); | ||
}, | ||
cells: [ | ||
DataCell( | ||
Text(item.topic), | ||
), | ||
DataCellUtil.newDellDataCell(() { | ||
vm.deleteTopic(item.topic); | ||
}), | ||
])); | ||
var topicsTable = SingleChildScrollView( | ||
child: PaginatedDataTable( | ||
showCheckboxColumn: false, | ||
columns: [ | ||
DataColumn(label: Text(S.of(context).topicName)), | ||
DataColumn(label: Text(S.of(context).deleteTopic)), | ||
], | ||
source: vm), | ||
); | ||
var formButton = createPartitionTopicButton(context); | ||
var refreshButton = TextButton( | ||
onPressed: () { | ||
vm.fetchTopics(); | ||
}, | ||
child: Text(S.of(context).refresh)); | ||
var body = ListView( | ||
children: <Widget>[ | ||
Container( | ||
height: 50, | ||
child: ListView( | ||
scrollDirection: Axis.horizontal, | ||
shrinkWrap: true, | ||
children: [formButton, refreshButton], | ||
), | ||
), | ||
SearchableTitle(S.of(context).topics, S.of(context).searchByTopic, | ||
searchTextController), | ||
topicsTable | ||
], | ||
); | ||
return body; | ||
} | ||
|
||
ButtonStyleButton createPartitionTopicButton(BuildContext context) { | ||
var list = [FormFieldDef('Topic Name'), FormFieldDef('Partition Number')]; | ||
return FormUtil.createButton2("Partitioned Topic", list, context, | ||
(topic, partition) async { | ||
final vm = Provider.of<PulsarNamespaceViewModel>(context, listen: false); | ||
vm.createTopic(topic, int.parse(partition)); | ||
}); | ||
} | ||
} |
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
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.