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 Mongo instances page #23

Merged
merged 1 commit into from
Jan 10, 2022
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
17 changes: 17 additions & 0 deletions .github/workflows/flutter_analyze.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Flutter Analyze

on:
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v1
with:
channel: 'beta'
- run: flutter pub get
- run: flutter analyze .
17 changes: 17 additions & 0 deletions .github/workflows/flutter_check_style.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Flutter Format

on:
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v1
with:
channel: 'beta'
- run: flutter pub get
- run: flutter format --set-exit-if-changed .
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ Flutter Paas Dashboard
- [Install Doc](install.md)

# 开发环境准备
## macos
```bash
flutter config --enable-macos-desktop
```
## windows
```bash
flutter config --enable-windows-desktop
```
## 开发注意事项
### 数据存储位置
- macos ~/Library/Containers/com.github.shoothzj.paasDashboardFlutter/Data

# 运行
## web
Expand Down
Binary file added assets/images/icons/mongo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/icons/mysql.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/icons/rocketmq.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion lib/api/http_util.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class HttpUtil {

static bool abnormal(int code) {
return code < 200 || code >= 300;
}
Expand Down
34 changes: 19 additions & 15 deletions lib/api/pulsar/pulsar_namespace_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@ import 'package:paas_dashboard_flutter/api/http_util.dart';
import 'package:paas_dashboard_flutter/module/pulsar/pulsar_namespace.dart';

class PulsarNamespaceApi {

static Future<void> createNamespace(String host, int port, String tenant, String namespace) async {
var url = 'http://$host:${port.toString()}/admin/v2/namespaces/$tenant/$namespace';
static Future<void> createNamespace(
String host, int port, String tenant, String namespace) async {
var url =
'http://$host:${port.toString()}/admin/v2/namespaces/$tenant/$namespace';
final response = await http.put(Uri.parse(url));
if (HttpUtil.abnormal(response.statusCode)) {
log('ErrorCode is ${response.statusCode}, body is ${response.body}');
throw Exception('ErrorCode is ${response.statusCode}, body is ${response.body}');
throw Exception(
'ErrorCode is ${response.statusCode}, body is ${response.body}');
}
}

static Future<void> deleteNamespace(
String host, int port, String tenant, String namespace) async {
var url = 'http://$host:${port.toString()}/admin/v2/namespaces/$tenant/$namespace';
var url =
'http://$host:${port.toString()}/admin/v2/namespaces/$tenant/$namespace';
final response = await http.delete(Uri.parse(url));
if (HttpUtil.abnormal(response.statusCode)) {
log('ErrorCode is ${response.statusCode}, body is ${response.body}');
throw Exception('ErrorCode is ${response.statusCode}, body is ${response.body}');
throw Exception(
'ErrorCode is ${response.statusCode}, body is ${response.body}');
}
}

Expand All @@ -32,22 +36,22 @@ class PulsarNamespaceApi {
final response = await http.get(Uri.parse(url));
if (HttpUtil.abnormal(response.statusCode)) {
log('ErrorCode is ${response.statusCode}, body is ${response.body}');
throw Exception('ErrorCode is ${response.statusCode}, body is ${response.body}');
throw Exception(
'ErrorCode is ${response.statusCode}, body is ${response.body}');
}
List jsonResponse = json.decode(response.body) as List;
return jsonResponse
.map((name) => new NamespaceResp.fromJson(name))
.toList();
}

static Future<BacklogQuotaResp> getBacklogQuota(String host, int port, String tenant,
String namespace) async {
static Future<BacklogQuotaResp> getBacklogQuota(
String host, int port, String tenant, String namespace) async {
String url =
'http://$host:${port.toString()}/admin/v2/namespaces/$tenant/$namespace/backlogQuotaMap';
var response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
});
var response = await http.get(Uri.parse(url), headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
});
if (HttpUtil.abnormal(response.statusCode)) {
log('ErrorCode is ${response.statusCode}, body is ${response.body}');
throw Exception(
Expand All @@ -65,7 +69,8 @@ class PulsarNamespaceApi {
String namespace, int limit, int? limitTime, String policy) async {
String url =
'http://$host:${port.toString()}/admin/v2/namespaces/$tenant/$namespace/backlogQuota';
BacklogQuotaReq backlogQuotaReq = new BacklogQuotaReq(limit, limitTime, policy);
BacklogQuotaReq backlogQuotaReq =
new BacklogQuotaReq(limit, limitTime, policy);
var response = await http.post(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
Expand All @@ -77,5 +82,4 @@ class PulsarNamespaceApi {
'ErrorCode is ${response.statusCode}, body is ${response.body}');
}
}

}
4 changes: 2 additions & 2 deletions lib/api/pulsar/pulsar_sink_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class PulsarSinkApi {
return jsonResponse.map((name) => new SinkResp(name)).toList();
}

static Future<SinkConfigResp> getSink(
String host, int port, String tenant, String namespace, String sinkName) async {
static Future<SinkConfigResp> getSink(String host, int port, String tenant,
String namespace, String sinkName) async {
var url =
'http://$host:${port.toString()}/admin/v3/sinks/$tenant/$namespace/$sinkName';
final response = await http.get(Uri.parse(url));
Expand Down
8 changes: 4 additions & 4 deletions lib/api/pulsar/pulsar_source_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class PulsarSourceApi {
String config) async {
String url =
'http://$host:${port.toString()}/admin/v3/sinks/$tenant/$namespace/$sourceName';
SourceConfigReq sinkConfigReq = new SourceConfigReq(sourceName, tenant, namespace, outputTopic,
json.decode(config), "builtin://$sourceType");
SourceConfigReq sinkConfigReq = new SourceConfigReq(sourceName, tenant,
namespace, outputTopic, json.decode(config), "builtin://$sourceType");
String curlCommand = "curl '$url' -F sourceConfig='" +
jsonEncode(sinkConfigReq) +
";type=application/json'";
Expand Down Expand Up @@ -52,8 +52,8 @@ class PulsarSourceApi {
return jsonResponse.map((name) => new SourceResp(name)).toList();
}

static Future<SourceConfigResp> getSource(
String host, int port, String tenant, String namespace, String sourceName) async {
static Future<SourceConfigResp> getSource(String host, int port,
String tenant, String namespace, String sourceName) async {
var url =
'http://$host:${port.toString()}/admin/v3/sources/$tenant/$namespace/$sourceName';
final response = await http.get(Uri.parse(url));
Expand Down
18 changes: 15 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ import 'package:paas_dashboard_flutter/ui/general/author_screen.dart';
import 'package:paas_dashboard_flutter/ui/general/settings_screen.dart';
import 'package:paas_dashboard_flutter/ui/home/home_page.dart';
import 'package:paas_dashboard_flutter/ui/kubernetes/k8s_page.dart';
import 'package:paas_dashboard_flutter/ui/mongo/mongo_page.dart';
import 'package:paas_dashboard_flutter/ui/mysql/mysql_page.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/pulsar_page.dart';
import 'package:paas_dashboard_flutter/vm/bk/bk_instance_list_view_model.dart';
import 'package:paas_dashboard_flutter/vm/general/settings_view_model.dart';
import 'package:paas_dashboard_flutter/vm/kubernetes/k8s_instance_list_view_model.dart';
import 'package:paas_dashboard_flutter/vm/mongo/mongo_instance_list_view_model.dart';
import 'package:paas_dashboard_flutter/vm/mysql/mysql_instance_list_view_model.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_instance_list_view_model.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_instance_view_model.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_namespace_view_model.dart';
Expand Down Expand Up @@ -64,9 +68,17 @@ class MyApp extends StatelessWidget {
child: BkPage(),
),
PageRouteConst.Kubernetes: (context) => ChangeNotifierProvider(
create: (context) => K8sInstanceListViewModel(),
child: K8sPage(),
),
create: (context) => K8sInstanceListViewModel(),
child: K8sPage(),
),
PageRouteConst.Mongo: (context) => ChangeNotifierProvider(
create: (context) => MongoInstanceListViewModel(),
child: MongoPage(),
),
PageRouteConst.Mysql: (context) => ChangeNotifierProvider(
create: (context) => MysqlInstanceListViewModel(),
child: MysqlPage(),
),
PageRouteConst.Pulsar: (context) => ChangeNotifierProvider(
create: (context) => PulsarInstanceListViewModel(),
child: PulsarPage(),
Expand Down
2 changes: 0 additions & 2 deletions lib/module/pulsar/pulsar_namespace.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,3 @@ class BacklogQuotaResp {
return BacklogQuotaResp(map["limitSize"], map["limitTime"], map["policy"]);
}
}


1 change: 0 additions & 1 deletion lib/module/pulsar/pulsar_tenant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class TenantResp {
}
}


class TenantInfoResp {
final String adminRoles;
final String allowedClusters;
Expand Down
34 changes: 32 additions & 2 deletions lib/persistent/persistent.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import 'package:paas_dashboard_flutter/persistent/persistent_db.dart';
import 'package:paas_dashboard_flutter/persistent/persistent_memory.dart';
import 'package:paas_dashboard_flutter/persistent/po/bk_instance_po.dart';
import 'package:paas_dashboard_flutter/persistent/po/k8s_instance_po.dart';
import 'package:paas_dashboard_flutter/persistent/po/mongo_instance_po.dart';
import 'package:paas_dashboard_flutter/persistent/po/mysql_instance_po.dart';
import 'package:paas_dashboard_flutter/persistent/po/pulsar_instance_po.dart';

class Persistent {
Expand All @@ -23,7 +25,8 @@ class Persistent {

static Future<void> savePulsar(String name, String host, int port,
String functionHost, int functionPort) async {
return (await getApi()).savePulsar(name, host, port, functionHost, functionPort);
return (await getApi())
.savePulsar(name, host, port, functionHost, functionPort);
}

static Future<void> deletePulsar(int id) async {
Expand All @@ -46,7 +49,8 @@ class Persistent {
return (await getApi()).bookkeeperInstances();
}

static Future<void> saveKubernetesSsh(String name, List<SshStep> sshSteps) async {
static Future<void> saveKubernetesSsh(
String name, List<SshStep> sshSteps) async {
return (await getApi()).saveKubernetesSsh(name, sshSteps);
}

Expand All @@ -58,6 +62,32 @@ class Persistent {
return (await getApi()).kubernetesInstances();
}

static Future<void> saveMongo(
String name, String addr, String username, String password) async {
return (await getApi()).saveMongo(name, addr, username, password);
}

static Future<void> deleteMongo(int id) async {
return (await getApi()).deleteMongo(id);
}

static Future<List<MongoInstancePo>> mongoInstances() async {
return (await getApi()).mongoInstances();
}

static Future<void> saveMysql(String name, String host, int port,
String username, String password) async {
return (await getApi()).saveMysql(name, host, port, username, password);
}

static Future<void> deleteMysql(int id) async {
return (await getApi()).deleteMysql(id);
}

static Future<List<MysqlInstancePo>> mysqlInstances() async {
return (await getApi()).mysqlInstances();
}

static bool supportDb() {
return !kIsWeb;
}
Expand Down
19 changes: 18 additions & 1 deletion lib/persistent/persistent_api.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import 'package:paas_dashboard_flutter/module/ssh/ssh_step.dart';
import 'package:paas_dashboard_flutter/persistent/po/bk_instance_po.dart';
import 'package:paas_dashboard_flutter/persistent/po/k8s_instance_po.dart';
import 'package:paas_dashboard_flutter/persistent/po/mongo_instance_po.dart';
import 'package:paas_dashboard_flutter/persistent/po/mysql_instance_po.dart';
import 'package:paas_dashboard_flutter/persistent/po/pulsar_instance_po.dart';

abstract class PersistentApi {
Future<void> savePulsar(String name, String host, int port, String functionHost, int functionPort);
Future<void> savePulsar(String name, String host, int port,
String functionHost, int functionPort);

Future<void> deletePulsar(int id);

Expand All @@ -21,4 +24,18 @@ abstract class PersistentApi {
Future<void> deleteKubernetes(int id);

Future<List<K8sInstancePo>> kubernetesInstances();

Future<void> saveMongo(
String name, String addr, String username, String password);

Future<void> deleteMongo(int id);

Future<List<MongoInstancePo>> mongoInstances();

Future<void> saveMysql(
String name, String host, int port, String username, String password);

Future<void> deleteMysql(int id);

Future<List<MysqlInstancePo>> mysqlInstances();
}
Loading