mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-04 20:30:35 +00:00
Added select server screen and add server screen
This commit is contained in:
parent
e1ff7a151d
commit
a97ae20631
22 changed files with 623 additions and 27 deletions
35
lib/services/database.dart
Normal file
35
lib/services/database.dart
Normal file
|
@ -0,0 +1,35 @@
|
|||
import 'package:sqflite/sqflite.dart';
|
||||
|
||||
Future<Map<String, dynamic>> loadDb() async {
|
||||
List<Map<String, Object?>>? servers;
|
||||
// List<Map<String, Object?>>? appConfig;
|
||||
|
||||
Database db = await openDatabase(
|
||||
'adguard_home_manager.db',
|
||||
version: 1,
|
||||
onCreate: (Database db, int version) async {
|
||||
await db.execute("CREATE TABLE servers (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, connectionMethod TEXT, domain TEXT, path TEXT, port INTEGER, user TEXT, password TEXT, defaultServer INTEGER)");
|
||||
},
|
||||
onUpgrade: (Database db, int oldVersion, int newVersion) async {
|
||||
|
||||
},
|
||||
onOpen: (Database db) async {
|
||||
await db.transaction((txn) async{
|
||||
servers = await txn.rawQuery(
|
||||
'SELECT * FROM servers',
|
||||
);
|
||||
});
|
||||
// await db.transaction((txn) async{
|
||||
// appConfig = await txn.rawQuery(
|
||||
// 'SELECT * FROM appConfig',
|
||||
// );
|
||||
// });
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
"servers": servers,
|
||||
// "appConfig": appConfig![0],
|
||||
"dbInstance": db,
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue