Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add empty impl for partitioned-topic partition and producers #5

Merged
merged 3 commits into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Flutter Paas Dashboard

## 其他语言文档
- [English Doc](README_en.md)

# 运行
## web
如需在Web下运行,需要关闭`chrome`的安全开关,步骤如下,参考链接: https://stackoverflow.com/questions/65630743/how-to-solve-flutter-web-api-cors-error-only-with-dart-code
Expand Down
3 changes: 3 additions & 0 deletions README_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# paas_dashboard_flutter

Flutter Paas Dashboard
8 changes: 7 additions & 1 deletion lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class MessageLookup extends MessageLookupByLibrary {
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"aboutAuthor": MessageLookupByLibrary.simpleMessage("About author"),
"appName": MessageLookupByLibrary.simpleMessage("Paas Dashboard"),
"basic": MessageLookupByLibrary.simpleMessage("Basic"),
"brokersName": MessageLookupByLibrary.simpleMessage("Broker Instance"),
"cancel": MessageLookupByLibrary.simpleMessage("Cancel"),
"clearBacklog": MessageLookupByLibrary.simpleMessage("Clear Backlog"),
Expand All @@ -43,6 +44,10 @@ class MessageLookup extends MessageLookupByLibrary {
"name": MessageLookupByLibrary.simpleMessage("name"),
"namespaceName": MessageLookupByLibrary.simpleMessage("Namespace Name"),
"namespaces": MessageLookupByLibrary.simpleMessage("Namespaces"),
"partitionNum":
MessageLookupByLibrary.simpleMessage("partition number"),
"produce": MessageLookupByLibrary.simpleMessage("Produce"),
"producerList": MessageLookupByLibrary.simpleMessage("Producer List"),
"refresh": MessageLookupByLibrary.simpleMessage("Refresh"),
"searchByNamespace":
MessageLookupByLibrary.simpleMessage("Search by Namespace Name"),
Expand All @@ -51,9 +56,10 @@ class MessageLookup extends MessageLookupByLibrary {
"searchByTopic":
MessageLookupByLibrary.simpleMessage("Search by Topic Name"),
"settings": MessageLookupByLibrary.simpleMessage("Settings"),
"subscriptionList":
MessageLookupByLibrary.simpleMessage("Subscription list"),
"subscriptionName":
MessageLookupByLibrary.simpleMessage("Subscription Name"),
"subscriptions": MessageLookupByLibrary.simpleMessage("Subscriptions"),
"tenantName": MessageLookupByLibrary.simpleMessage("Tenant Name"),
"tenants": MessageLookupByLibrary.simpleMessage("Tenants"),
"topicName": MessageLookupByLibrary.simpleMessage("Topic Name"),
Expand Down
6 changes: 5 additions & 1 deletion lib/generated/intl/messages_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class MessageLookup extends MessageLookupByLibrary {
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"aboutAuthor": MessageLookupByLibrary.simpleMessage("关于作者"),
"appName": MessageLookupByLibrary.simpleMessage("Paas 仪表盘"),
"basic": MessageLookupByLibrary.simpleMessage("基础信息"),
"brokersName": MessageLookupByLibrary.simpleMessage("Pulsar 实例"),
"cancel": MessageLookupByLibrary.simpleMessage("取消"),
"clearBacklog": MessageLookupByLibrary.simpleMessage("清理积压"),
Expand All @@ -39,13 +40,16 @@ class MessageLookup extends MessageLookupByLibrary {
"name": MessageLookupByLibrary.simpleMessage("名称"),
"namespaceName": MessageLookupByLibrary.simpleMessage("命名空间名称"),
"namespaces": MessageLookupByLibrary.simpleMessage("命名空间列表"),
"partitionNum": MessageLookupByLibrary.simpleMessage("partition 个数"),
"produce": MessageLookupByLibrary.simpleMessage("生产"),
"producerList": MessageLookupByLibrary.simpleMessage("生产者列表"),
"refresh": MessageLookupByLibrary.simpleMessage("刷新"),
"searchByNamespace": MessageLookupByLibrary.simpleMessage("按命名空间名称搜索"),
"searchByTenant": MessageLookupByLibrary.simpleMessage("按租户名称搜索"),
"searchByTopic": MessageLookupByLibrary.simpleMessage("按 Topic 名称搜索"),
"settings": MessageLookupByLibrary.simpleMessage("设置"),
"subscriptionList": MessageLookupByLibrary.simpleMessage("订阅列表"),
"subscriptionName": MessageLookupByLibrary.simpleMessage("订阅名称"),
"subscriptions": MessageLookupByLibrary.simpleMessage("订阅列表"),
"tenantName": MessageLookupByLibrary.simpleMessage("租户名称"),
"tenants": MessageLookupByLibrary.simpleMessage("租户列表"),
"topicName": MessageLookupByLibrary.simpleMessage("Topic 名称"),
Expand Down
48 changes: 44 additions & 4 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"delete": "Delete",
"cancel": "Cancel",
"confirm": "Confirm",
"basic": "Basic",
"confirmDeleteQuestion": "ConfirmDelete?",
"brokersName": "Broker Instance",
"isLeader": "Is Leader",
Expand All @@ -20,9 +21,12 @@
"searchByTopic": "Search by Topic Name",
"topicName": "Topic Name",
"deleteTopic": "Delete Topic",
"produce": "Produce",
"producerList": "Producer List",
"partitionNum": "partition number",
"clearBacklog": "Clear Backlog",
"confirmClearBacklog": "ConfirmClear?",
"subscriptions": "Subscriptions",
"subscriptionList": "Subscription list",
"subscriptionName": "Subscription Name",
"aboutAuthor": "About author",
"settings": "Settings",
Expand Down
6 changes: 5 additions & 1 deletion lib/l10n/intl_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"delete": "删除",
"cancel": "取消",
"confirm": "确认",
"basic": "基础信息",
"confirmDeleteQuestion": "确认删除吗?",
"brokersName": "Pulsar 实例",
"isLeader": "是否是主节点",
Expand All @@ -20,9 +21,12 @@
"searchByTopic": "按 Topic 名称搜索",
"topicName": "Topic 名称",
"deleteTopic": "删除 Topic",
"produce": "生产",
"producerList": "生产者列表",
"partitionNum": "partition 个数",
"clearBacklog": "清理积压",
"confirmClearBacklog": "确认清理积压吗?",
"subscriptions": "订阅列表",
"subscriptionList": "订阅列表",
"subscriptionName": "订阅名称",
"aboutAuthor": "关于作者",
"settings": "设置",
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class MyApp extends StatelessWidget {
return RouteGen.pulsarNamespace(args);
}
if (settings.name == PageRouteConst.PulsarTopic) {
final args = settings.arguments as PulsarTopicViewModel;
final args = settings.arguments as PulsarPartitionedTopicViewModel;
return RouteGen.pulsarPartitionedTopic(args);
}
},
Expand Down
9 changes: 9 additions & 0 deletions lib/module/pulsar/pulsar_produce.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class ProducerResp {
final String producerName;

ProducerResp(this.producerName);

ProducerResp deepCopy() {
return new ProducerResp(producerName);
}
}
2 changes: 1 addition & 1 deletion lib/module/pulsar/pulsar_topic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class PulsarTopicModule {
}

class TopicPageContext {
final PulsarTopicViewModel pulsarTopicViewModel;
final PulsarPartitionedTopicViewModel pulsarTopicViewModel;
final PulsarTopicModule topicModule;

TopicPageContext(this.pulsarTopicViewModel, this.topicModule);
Expand Down
5 changes: 3 additions & 2 deletions lib/route/route_gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ class RouteGen {
));
}

static Route pulsarPartitionedTopic(PulsarTopicViewModel viewModel) {
static Route pulsarPartitionedTopic(
PulsarPartitionedTopicViewModel viewModel) {
return MaterialPageRoute(
builder: (context) => ChangeNotifierProvider(
create: (context) => viewModel,
child: PulsarPartitionedTopicScreen(),
child: PulsarPartitionedTopic(),
));
}
}
3 changes: 2 additions & 1 deletion lib/ui/pulsar/pulsar_instance.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class _PulsarInstanceState extends State<PulsarInstanceScreen> {
body: TabBarView(
children: [
ChangeNotifierProvider(
create: (context) => PulsarClusterViewModel(vm.pulsarInstancePo),
create: (context) =>
PulsarClusterViewModel(vm.pulsarInstancePo.deepCopy()),
child: PulsarBasicWidget(),
).build(context),
ChangeNotifierProvider(
Expand Down
125 changes: 51 additions & 74 deletions lib/ui/pulsar/screen/pulsar_partitioned_topic.dart
Original file line number Diff line number Diff line change
@@ -1,94 +1,71 @@
import 'package:flutter/material.dart';
import 'package:paas_dashboard_flutter/generated/l10n.dart';
import 'package:paas_dashboard_flutter/ui/component/clear_backlog_button.dart';
import 'package:paas_dashboard_flutter/ui/util/exception_util.dart';
import 'package:paas_dashboard_flutter/ui/util/spinner_util.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/widget/pulsar_partitioned_topic_basic.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/widget/pulsar_partitioned_topic_produce.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/widget/pulsar_partitioned_topic_subscription.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_partitioned_topic_basic_view_model.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_partitioned_topic_produce_view_model.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_partitioned_topic_subscription_view_model.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_partitioned_topic_view_model.dart';
import 'package:provider/provider.dart';

class PulsarPartitionedTopicScreen extends StatefulWidget {
PulsarPartitionedTopicScreen();
class PulsarPartitionedTopic extends StatefulWidget {
PulsarPartitionedTopic();

@override
State<StatefulWidget> createState() {
return new PulsarPartitionedTopicScreenState();
return new _PulsarPartitionedTopicState();
}
}

class PulsarPartitionedTopicScreenState
extends State<PulsarPartitionedTopicScreen> {
@override
void initState() {
super.initState();
final vm = Provider.of<PulsarTopicViewModel>(context, listen: false);
vm.fetchSubscriptions();
}
class _PulsarPartitionedTopicState extends State<PulsarPartitionedTopic> {
_PulsarPartitionedTopicState();

@override
Widget build(BuildContext context) {
final vm = Provider.of<PulsarTopicViewModel>(context);
if (vm.loading) {
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
SpinnerUtil.create();
});
}
ExceptionUtil.processLoadException(vm, context);
ExceptionUtil.processOpException(vm, context);
var topicsFuture = SingleChildScrollView(
child: DataTable(
showCheckboxColumn: false,
columns: [
DataColumn(label: Text(S.of(context).subscriptionName)),
DataColumn(label: Text('MsgBacklog')),
DataColumn(label: Text('MsgRateOut')),
DataColumn(label: Text(S.of(context).clearBacklog)),
],
rows: vm.displayList
.map((data) => DataRow(cells: [
DataCell(
Text(data.subscriptionName),
),
DataCell(
Text(data.backlog.toString()),
),
DataCell(
Text(data.rateOut.toString()),
),
DataCell(ClearBacklogButton(() {
vm.clearBacklog(data.subscriptionName);
})),
]))
.toList()),
);
var refreshButton = TextButton(
onPressed: () {
vm.fetchSubscriptions();
},
child: Text(S.of(context).refresh));
var body = ListView(
children: <Widget>[
Container(
height: 50,
child: ListView(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
children: [refreshButton],
final vm = Provider.of<PulsarPartitionedTopicViewModel>(context);
return DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
title: Text('Pulsar ${vm.topic} Dashboard'),
bottom: TabBar(
tabs: [
Tab(text: "Basic"),
Tab(text: "Subscription"),
Tab(text: "Produce"),
],
),
),
Text(
S.of(context).subscriptions,
style: TextStyle(fontSize: 22),
body: TabBarView(
children: [
ChangeNotifierProvider(
create: (context) => PulsarPartitionedTopicBasicViewModel(
vm.pulsarInstancePo,
vm.tenantResp,
vm.namespaceResp,
vm.topicResp),
child: PulsarPartitionedTopicBasicWidget(),
).build(context),
ChangeNotifierProvider(
create: (context) =>
new PulsarPartitionedTopicSubscriptionViewModel(
vm.pulsarInstancePo,
vm.tenantResp,
vm.namespaceResp,
vm.topicResp),
child: PulsarPartitionedTopicSubscriptionWidget(),
).build(context),
ChangeNotifierProvider(
create: (context) => PulsarPartitionedTopicProduceViewModel(
vm.pulsarInstancePo,
vm.tenantResp,
vm.namespaceResp,
vm.topicResp),
child: PulsarPartitionedTopicProduceWidget(),
).build(context),
],
),
topicsFuture
],
);

return Scaffold(
appBar: AppBar(
title: Text(
'Pulsar Tenant ${vm.tenant} -> Namespace ${vm.namespace} -> Topic ${vm.topic}'),
),
body: body,
);
}
}
Loading