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

optimize variable to use question mark instead of -1 #18

Merged
merged 1 commit into from
Dec 10, 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
5 changes: 4 additions & 1 deletion lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes

import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';
Expand All @@ -34,6 +33,7 @@ class MessageLookup extends MessageLookupByLibrary {
"confirmDeleteQuestion":
MessageLookupByLibrary.simpleMessage("ConfirmDelete?"),
"consume": MessageLookupByLibrary.simpleMessage("consume"),
"consumer": MessageLookupByLibrary.simpleMessage("consumer"),
"consumerList": MessageLookupByLibrary.simpleMessage("Consumer List"),
"delete": MessageLookupByLibrary.simpleMessage("Delete"),
"deleteNamespace":
Expand All @@ -46,6 +46,7 @@ class MessageLookup extends MessageLookupByLibrary {
"languageSettings":
MessageLookupByLibrary.simpleMessage("Language Settings"),
"name": MessageLookupByLibrary.simpleMessage("name"),
"namespace": MessageLookupByLibrary.simpleMessage("namespace"),
"namespaceName": MessageLookupByLibrary.simpleMessage("Namespace Name"),
"namespaces": MessageLookupByLibrary.simpleMessage("Namespaces"),
"partitionList": MessageLookupByLibrary.simpleMessage("Partition List"),
Expand All @@ -61,11 +62,13 @@ class MessageLookup extends MessageLookupByLibrary {
"searchByTopic":
MessageLookupByLibrary.simpleMessage("Search by Topic Name"),
"settings": MessageLookupByLibrary.simpleMessage("Settings"),
"submit": MessageLookupByLibrary.simpleMessage("Submit"),
"subscription": MessageLookupByLibrary.simpleMessage("subscription"),
"subscriptionList":
MessageLookupByLibrary.simpleMessage("Subscription list"),
"subscriptionName":
MessageLookupByLibrary.simpleMessage("Subscription Name"),
"tenant": MessageLookupByLibrary.simpleMessage("tenant"),
"tenantName": MessageLookupByLibrary.simpleMessage("Tenant Name"),
"tenants": MessageLookupByLibrary.simpleMessage("Tenants"),
"topicName": MessageLookupByLibrary.simpleMessage("Topic Name"),
Expand Down
5 changes: 4 additions & 1 deletion lib/generated/intl/messages_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes

import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';
Expand All @@ -32,6 +31,7 @@ class MessageLookup extends MessageLookupByLibrary {
"confirmClearBacklog": MessageLookupByLibrary.simpleMessage("确认清理积压吗?"),
"confirmDeleteQuestion": MessageLookupByLibrary.simpleMessage("确认删除吗?"),
"consume": MessageLookupByLibrary.simpleMessage("消费"),
"consumer": MessageLookupByLibrary.simpleMessage("消费者"),
"consumerList": MessageLookupByLibrary.simpleMessage("消费者列表"),
"delete": MessageLookupByLibrary.simpleMessage("删除"),
"deleteNamespace": MessageLookupByLibrary.simpleMessage("删除命名空间"),
Expand All @@ -42,6 +42,7 @@ class MessageLookup extends MessageLookupByLibrary {
"isLeader": MessageLookupByLibrary.simpleMessage("是否是主节点"),
"languageSettings": MessageLookupByLibrary.simpleMessage("语言设置"),
"name": MessageLookupByLibrary.simpleMessage("名称"),
"namespace": MessageLookupByLibrary.simpleMessage("命名空间"),
"namespaceName": MessageLookupByLibrary.simpleMessage("命名空间名称"),
"namespaces": MessageLookupByLibrary.simpleMessage("命名空间列表"),
"partitionList": MessageLookupByLibrary.simpleMessage("partition 列表"),
Expand All @@ -53,9 +54,11 @@ class MessageLookup extends MessageLookupByLibrary {
"searchByTenant": MessageLookupByLibrary.simpleMessage("按租户名称搜索"),
"searchByTopic": MessageLookupByLibrary.simpleMessage("按 Topic 名称搜索"),
"settings": MessageLookupByLibrary.simpleMessage("设置"),
"submit": MessageLookupByLibrary.simpleMessage("提交"),
"subscription": MessageLookupByLibrary.simpleMessage("订阅"),
"subscriptionList": MessageLookupByLibrary.simpleMessage("订阅列表"),
"subscriptionName": MessageLookupByLibrary.simpleMessage("订阅名称"),
"tenant": MessageLookupByLibrary.simpleMessage("租户"),
"tenantName": MessageLookupByLibrary.simpleMessage("租户名称"),
"tenants": MessageLookupByLibrary.simpleMessage("租户列表"),
"topicName": MessageLookupByLibrary.simpleMessage("Topic 名称"),
Expand Down
40 changes: 40 additions & 0 deletions lib/generated/l10n.dart

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

4 changes: 4 additions & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"confirmClearBacklog": "ConfirmClear?",
"confirmDeleteQuestion": "ConfirmDelete?",
"consume": "consume",
"consumer": "consumer",
"consumerList": "Consumer List",
"delete": "Delete",
"deleteNamespace": "Delete Namespace",
Expand All @@ -19,6 +20,7 @@
"isLeader": "Is Leader",
"languageSettings": "Language Settings",
"name": "name",
"namespace": "namespace",
"namespaceName": "Namespace Name",
"namespaces": "Namespaces",
"partitionList": "Partition List",
Expand All @@ -30,9 +32,11 @@
"searchByTenant": "Search by Tenant Name",
"searchByTopic": "Search by Topic Name",
"settings": "Settings",
"submit": "Submit",
"subscription": "subscription",
"subscriptionList": "Subscription list",
"subscriptionName": "Subscription Name",
"tenant": "tenant",
"tenantName": "Tenant Name",
"tenants": "Tenants",
"topicName": "Topic Name",
Expand Down
4 changes: 4 additions & 0 deletions lib/l10n/intl_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"confirmClearBacklog": "确认清理积压吗?",
"confirmDeleteQuestion": "确认删除吗?",
"consume": "消费",
"consumer": "消费者",
"consumerList": "消费者列表",
"delete": "删除",
"deleteNamespace": "删除命名空间",
Expand All @@ -19,6 +20,7 @@
"isLeader": "是否是主节点",
"languageSettings": "语言设置",
"name": "名称",
"namespace": "命名空间",
"namespaceName": "命名空间名称",
"namespaces": "命名空间列表",
"partitionList": "partition 列表",
Expand All @@ -30,9 +32,11 @@
"searchByTenant": "按租户名称搜索",
"searchByTopic": "按 Topic 名称搜索",
"settings": "设置",
"submit": "提交",
"subscription": "订阅",
"subscriptionList": "订阅列表",
"subscriptionName": "订阅名称",
"tenant": "租户",
"tenantName": "租户名称",
"tenants": "租户列表",
"topicName": "Topic 名称",
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/general/author_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class AuthorScreen extends StatelessWidget {
Widget build(BuildContext context) {
List<Author> authors = [
Author('fu_turer', "futurer@outlook.com"),
Author('goflutterjava', "goflutterjava@gmail.com"),
Author('lovehzj', "1922919664@qq.com"),
Author('shoothzj', 'shoothzj@gmail.com')
];
List<String> name = ['fu_turer', 'shoothzj'];
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/pulsar/screen/pulsar_namespace.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:paas_dashboard_flutter/generated/l10n.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/widget/pulsar_namespace_backlog_quota.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/widget/pulsar_namespace_policies.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/widget/pulsar_partitioned_topic_list.dart';
Expand Down Expand Up @@ -42,7 +43,7 @@ class PulsarNamespaceScreenState extends State<PulsarNamespaceScreen> {
child: Scaffold(
appBar: AppBar(
title: Text(
'Pulsar Namespace Tenant ${vm.tenant} -> Namespace ${vm.namespace}'),
'Pulsar ${S.of(context).tenant} ${S.of(context).tenant} ${vm.tenant} -> ${S.of(context).namespace} ${vm.namespace}'),
bottom: TabBar(
tabs: [
Tab(text: "BacklogQuota"),
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/pulsar/screen/pulsar_partitioned_topic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class _PulsarPartitionedTopicState extends State<PulsarPartitionedTopic> {
child: Scaffold(
appBar: AppBar(
title: Text(
'Pulsar Partitioned Topic Tenant ${vm.tenant} -> Namespace ${vm.namespace} -> Topic ${vm.topic}'),
'Pulsar Partitioned Topic ${S.of(context).tenant} ${vm.tenant} -> ${S.of(context).namespace} ${vm.namespace} -> Topic ${vm.topic}'),
bottom: TabBar(
tabs: [
Tab(text: S.of(context).basic),
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/pulsar/screen/pulsar_sink.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class _PulsarSinkScreenState extends State<PulsarSinkScreen> {
child: Scaffold(
appBar: AppBar(
title: Text(
'Pulsar Sink Tenant ${vm.tenant} -> Namespace ${vm.namespace} -> Topic ${vm.sinkName}'),
'Pulsar Sink ${S.of(context).tenant} ${vm.tenant} -> ${S.of(context).namespace} ${vm.namespace} -> Topic ${vm.sinkName}'),
bottom: TabBar(
tabs: [
Tab(text: S.of(context).basic),
Expand Down
3 changes: 1 addition & 2 deletions lib/ui/pulsar/screen/pulsar_source.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:paas_dashboard_flutter/generated/l10n.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/widget/pulsar_source_basic.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/widget/pulsar_topic_basic.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_source_basic_view_model.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_source_view_model.dart';
import 'package:provider/provider.dart';
Expand All @@ -26,7 +25,7 @@ class _PulsarSourceScreenState extends State<PulsarSourceScreen> {
child: Scaffold(
appBar: AppBar(
title: Text(
'Pulsar Source Tenant ${vm.tenant} -> Namespace ${vm.namespace} -> Topic ${vm.sourceName}'),
'Pulsar Source ${S.of(context).tenant} ${vm.tenant} -> ${S.of(context).namespace} ${vm.namespace} -> Topic ${vm.sourceName}'),
bottom: TabBar(
tabs: [
Tab(text: S.of(context).basic),
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/pulsar/screen/pulsar_tenant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ class PulsarTenantScreenState extends State<PulsarTenantScreen> {
);
return Scaffold(
appBar: AppBar(
title: Text('Pulsar Tenant ${vm.tenant}'),
title: Text('Pulsar ${S.of(context).tenant} ${vm.tenant}'),
),
body: listView,
);
}

ButtonStyleButton createNamespace(BuildContext context) {
var list = [FormFieldDef('Namespace Name')];
return FormUtil.createButton1("Pulsar Namespace", list, context,
return FormUtil.createButton1("Pulsar ${S.of(context).namespace}", list, context,
(namespace) async {
final vm = Provider.of<PulsarTenantViewModel>(context, listen: false);
vm.createNamespace(namespace);
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/pulsar/screen/pulsar_topic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class _PulsarTopicState extends State<PulsarTopic> {
child: Scaffold(
appBar: AppBar(
title: Text(
'Pulsar Topic Tenant ${vm.tenant} -> Namespace ${vm.namespace} -> Topic ${vm.topic}'),
'Pulsar Topic ${S.of(context).tenant} ${vm.tenant} -> ${S.of(context).namespace} ${vm.namespace} -> Topic ${vm.topic}'),
bottom: TabBar(
tabs: [
Tab(text: S.of(context).basic),
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/pulsar/widget/pulsar_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class PulsarTenantsState extends State<PulsarTenantsWidget> {
ButtonStyleButton createTenant(BuildContext context, String host, int port) {
final vm = Provider.of<PulsarInstanceViewModel>(context, listen: false);
var list = [FormFieldDef(S.of(context).tenantName)];
return FormUtil.createButton1("Pulsar Tenant", list, context,
return FormUtil.createButton1("Pulsar ${S.of(context).tenant}", list, context,
(tenant) async {
vm.createTenant(tenant);
});
Expand Down
6 changes: 3 additions & 3 deletions lib/ui/pulsar/widget/pulsar_namespace_backlog_quota.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class PulsarNamespaceBacklogQuotaWidgetState extends State<PulsarNamespaceBacklo
shrinkWrap: true,
children: [
Text(
'LimitSize is ${vm.limitSize}',
'LimitSize is ${vm.limitSizeDisplayStr}',
style: new TextStyle(fontSize: 20),
),
],
Expand All @@ -75,7 +75,7 @@ class PulsarNamespaceBacklogQuotaWidgetState extends State<PulsarNamespaceBacklo
shrinkWrap: true,
children: [
Text(
'LimitTime is ${vm.limitTime}',
'LimitTime is ${vm.limitTimeDisplayStr}',
style: new TextStyle(fontSize: 20),
),
],
Expand All @@ -88,7 +88,7 @@ class PulsarNamespaceBacklogQuotaWidgetState extends State<PulsarNamespaceBacklo
shrinkWrap: true,
children: [
Text(
'Policy is ${vm.retentionPolicy}',
'Policy is ${vm.retentionPolicyDisplayStr}',
style: new TextStyle(fontSize: 20),
),
],
Expand Down
42 changes: 36 additions & 6 deletions lib/vm/pulsar/pulsar_namespace_backlog_quota_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class PulsarNamespaceBacklogQuotaViewModel extends BaseLoadViewModel {
final PulsarInstancePo pulsarInstancePo;
final TenantResp tenantResp;
final NamespaceResp namespaceResp;
int limitSize = -1;
int limitTime = -1;
String retentionPolicy = "unset";
int? limitSize;
int? limitTime;
String? retentionPolicy;

PulsarNamespaceBacklogQuotaViewModel(
this.pulsarInstancePo, this.tenantResp, this.namespaceResp);
Expand Down Expand Up @@ -44,13 +44,43 @@ class PulsarNamespaceBacklogQuotaViewModel extends BaseLoadViewModel {
return this.namespaceResp.namespace;
}

String get limitSizeDisplayStr {
if (loading) {
return "loading";
}
if (limitSize == null) {
return "unset";
}
return limitSize!.toString();
}

String get limitTimeDisplayStr {
if (loading) {
return "loading";
}
if (limitTime == null) {
return "unset";
}
return limitTime!.toString();
}

String get retentionPolicyDisplayStr {
if (loading) {
return "loading";
}
if (retentionPolicy == null) {
return "unset";
}
return retentionPolicy!;
}

Future<void> fetchBacklogQuota() async {
try {
final BacklogQuotaResp resp = await PulsarNamespaceApi.getBacklogQuota(
host, port, tenant, namespace);
this.limitSize = resp.limitSize == null ? -1 : resp.limitSize!;
this.limitTime = resp.limitTime == null ? -1 : resp.limitTime!;
this.retentionPolicy = resp.policy == null ? "null" : resp.policy!;
this.limitSize = resp.limitSize;
this.limitTime = resp.limitTime;
this.retentionPolicy = resp.policy;
loadSuccess();
} on Exception catch (e) {
loadException = e;
Expand Down