-
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.
- Loading branch information
1 parent
727cbf1
commit 70fce26
Showing
25 changed files
with
704 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:mongo_dart/mongo_dart.dart'; | ||
import 'package:paas_dashboard_flutter/module/mongo/mongo_database.dart'; | ||
|
||
class MongoDatabaseApi { | ||
static Future<List<DatabaseResp>> getDatabaseList( | ||
String addr, String username, String password) async { | ||
var db = await Db.create(addr); | ||
await db.open(); | ||
var databases = await db.listDatabases(); | ||
return databases.map((name) => new DatabaseResp(name)).toList(); | ||
} | ||
} |
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,14 @@ | ||
import 'package:mongo_dart/mongo_dart.dart'; | ||
import 'package:paas_dashboard_flutter/module/mongo/mongo_table.dart'; | ||
|
||
class MongoTablesApi { | ||
static Future<List<TableResp>> getTableList(String addr, String username, | ||
String password, String databaseName) async { | ||
var db = await Db.create(addr + "/" + databaseName); | ||
await db.open(); | ||
var collectionNames = await db.getCollectionNames(); | ||
return collectionNames.whereType<String>().map((name) { | ||
return new TableResp(name); | ||
}).toList(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class DatabaseResp { | ||
final String databaseName; | ||
|
||
DatabaseResp(this.databaseName); | ||
|
||
DatabaseResp deepCopy() { | ||
return new DatabaseResp(this.databaseName); | ||
} | ||
|
||
@override | ||
String toString() { | ||
return 'DatabaseResp{databaseName: $databaseName}'; | ||
} | ||
} |
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,14 @@ | ||
class TableResp { | ||
final String tableName; | ||
|
||
TableResp(this.tableName); | ||
|
||
TableResp deepCopy() { | ||
return new TableResp(this.tableName); | ||
} | ||
|
||
@override | ||
String toString() { | ||
return 'TableResp{tableName: $tableName}'; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:paas_dashboard_flutter/ui/mongo/widget/mongo_database_list.dart'; | ||
import 'package:paas_dashboard_flutter/vm/mongo/mongo_database_list_view_model.dart'; | ||
import 'package:paas_dashboard_flutter/vm/mongo/mongo_instance_view_model.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
class MongoInstanceScreen extends StatefulWidget { | ||
MongoInstanceScreen(); | ||
|
||
@override | ||
State<StatefulWidget> createState() { | ||
return new _MongoInstanceState(); | ||
} | ||
} | ||
|
||
class _MongoInstanceState extends State<MongoInstanceScreen> { | ||
_MongoInstanceState(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final vm = Provider.of<MongoInstanceViewModel>(context); | ||
return DefaultTabController( | ||
length: 1, | ||
child: Scaffold( | ||
appBar: AppBar( | ||
title: Text('Mongo ${vm.name} Dashboard'), | ||
bottom: TabBar( | ||
tabs: [ | ||
Tab( | ||
text: "Databases", | ||
), | ||
], | ||
), | ||
), | ||
body: TabBarView( | ||
children: [ | ||
ChangeNotifierProvider( | ||
create: (context) => | ||
MongoDatabaseListViewModel(vm.mongoInstancePo.deepCopy()), | ||
child: MongoDatabaseListWidget(), | ||
).build(context), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
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,53 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:paas_dashboard_flutter/ui/mongo/widget/mongo_table_list.dart'; | ||
import 'package:paas_dashboard_flutter/vm/mongo/mongo_database_view_model.dart'; | ||
import 'package:paas_dashboard_flutter/vm/mongo/mongo_table_list_view_model.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
class MongoDatabaseScreen extends StatefulWidget { | ||
MongoDatabaseScreen(); | ||
|
||
@override | ||
State<StatefulWidget> createState() { | ||
return new MongoDatabaseScreenState(); | ||
} | ||
} | ||
|
||
class MongoDatabaseScreenState extends State<MongoDatabaseScreen> { | ||
@override | ||
void initState() { | ||
super.initState(); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final vm = Provider.of<MongoDatabaseViewModel>(context); | ||
return DefaultTabController( | ||
length: 1, | ||
child: Scaffold( | ||
appBar: AppBar( | ||
title: Text('Mongo ${vm.name} -> ${vm.databaseName}'), | ||
bottom: TabBar( | ||
tabs: [ | ||
Tab(text: "Tables"), | ||
], | ||
), | ||
), | ||
body: TabBarView( | ||
children: [ | ||
ChangeNotifierProvider( | ||
create: (context) => | ||
MongoTableListViewModel(vm.mongoInstancePo, vm.databaseResp), | ||
child: MongoTableListWidget(), | ||
).build(context), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.