From bc9273c3c02c8d45c3bff6f29ea7ec5435c84e1a Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 11 Jul 2024 08:53:05 +0200 Subject: [PATCH 1/2] update Django readme --- demos/django-todolist/README.md | 36 +++++++++++++++--- .../lib/app_config_template.dart | 6 +-- demos/django-todolist/macos/Podfile.lock | 37 +++++++------------ 3 files changed, 48 insertions(+), 31 deletions(-) diff --git a/demos/django-todolist/README.md b/demos/django-todolist/README.md index 8fc9fecf..a5e10baa 100644 --- a/demos/django-todolist/README.md +++ b/demos/django-todolist/README.md @@ -1,6 +1,6 @@ # PowerSync + Django Flutter Demo: Todo List App -Demo app demonstrating use of the PowerSync SDK for Flutter together with the [demo Django backend](https://github.com/powersync-ja/powersync-django-backend-todolist-demo). +Demo app demonstrating use of the PowerSync SDK for Flutter together with the [demo Django backend](https://github.com/powersync-ja/powersync-django-backend-todolist-demo). # Running the app @@ -12,9 +12,35 @@ Ensure you have [melos](https://melos.invertase.dev/~melos-latest/getting-starte 4. Insert your Django URL and PowerSync project credentials into `lib/app_config.dart` (See instructions below) 5. `flutter run` -# Set up Django project +# Service Configuration -Follow the instructions in the django backend project's README. +This demo can be used with cloud or local services. + +## Local Services + +The [Self Hosting Demo](https://github.com/powersync-ja/self-host-demo) repository contains a Docker Compose Django backend demo which can be used with this client. +See [instructions](https://github.com/powersync-ja/self-host-demo/blob/main/demos/django/README.md) for starting the backend locally. + +The backend demo should perform all the required setup automatically. A test user with the following credentials will be available: + +``` +username: testuser +password: testpassword +``` + +### Android + +Note that Android requires port forwarding of local services. These can be configured with ADB as below: + +```bash +adb reverse tcp:8080 tcp:8080 && adb reverse tcp:6061 tcp:6061 +``` + +## Cloud Services + +### Set up Django project + +Follow the instructions in the django backend project's README. The instructions guide you through the following: @@ -22,7 +48,7 @@ The instructions guide you through the following: 2. Creates a test user. 3. Create a logical replication publication called `powersync` for `lists` and `todos`. -# Set up PowerSync Instance +### Set up PowerSync Instance Create a new PowerSync instance by signing up for PowerSync Cloud at www.powersync.com, then connect to the database of your Django project. @@ -38,6 +64,6 @@ bucket_definitions: - select * from todos where list_id = bucket.list_id ``` -# Configure the app +### Configure the app Insert the credentials of your new Django backend and PowerSync projects into `lib/app_config.dart` diff --git a/demos/django-todolist/lib/app_config_template.dart b/demos/django-todolist/lib/app_config_template.dart index aaeefb5c..33ed86fe 100644 --- a/demos/django-todolist/lib/app_config_template.dart +++ b/demos/django-todolist/lib/app_config_template.dart @@ -1,7 +1,7 @@ // Copy this template: `cp lib/app_config_template.dart lib/app_config.dart` // Edit lib/app_config.dart and enter your Django and PowerSync project details. class AppConfig { - static const String djangoUrl = 'https://foo.ngrok.app'; - static const String powersyncUrl = - 'https://myprojectid.powersync.journeyapps.com'; + // These are defaults when using the [self-host local demo](https://github.com/powersync-ja/self-host-demo/tree/main/demos/django) + static const String djangoUrl = 'http://localhost:6061'; + static const String powersyncUrl = 'http://localhost:8080'; } diff --git a/demos/django-todolist/macos/Podfile.lock b/demos/django-todolist/macos/Podfile.lock index 55e41f1b..67953800 100644 --- a/demos/django-todolist/macos/Podfile.lock +++ b/demos/django-todolist/macos/Podfile.lock @@ -1,6 +1,4 @@ PODS: - - app_links (1.0.0): - - FlutterMacOS - FlutterMacOS (1.0.0) - path_provider_foundation (0.0.1): - Flutter @@ -12,32 +10,31 @@ PODS: - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS - - sqlite3 (3.46.0): - - sqlite3/common (= 3.46.0) - - sqlite3/common (3.46.0) - - sqlite3/fts5 (3.46.0): + - "sqlite3 (3.46.0+1)": + - "sqlite3/common (= 3.46.0+1)" + - "sqlite3/common (3.46.0+1)" + - "sqlite3/dbstatvtab (3.46.0+1)": + - sqlite3/common + - "sqlite3/fts5 (3.46.0+1)": - sqlite3/common - - sqlite3/perf-threadsafe (3.46.0): + - "sqlite3/perf-threadsafe (3.46.0+1)": - sqlite3/common - - sqlite3/rtree (3.46.0): + - "sqlite3/rtree (3.46.0+1)": - sqlite3/common - sqlite3_flutter_libs (0.0.1): - FlutterMacOS - - sqlite3 (~> 3.46.0) + - "sqlite3 (~> 3.46.0+1)" + - sqlite3/dbstatvtab - sqlite3/fts5 - sqlite3/perf-threadsafe - sqlite3/rtree - - url_launcher_macos (0.0.1): - - FlutterMacOS DEPENDENCIES: - - app_links (from `Flutter/ephemeral/.symlinks/plugins/app_links/macos`) - FlutterMacOS (from `Flutter/ephemeral`) - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) - powersync_flutter_libs (from `Flutter/ephemeral/.symlinks/plugins/powersync_flutter_libs/macos`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) - sqlite3_flutter_libs (from `Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/macos`) - - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) SPEC REPOS: trunk: @@ -45,8 +42,6 @@ SPEC REPOS: - sqlite3 EXTERNAL SOURCES: - app_links: - :path: Flutter/ephemeral/.symlinks/plugins/app_links/macos FlutterMacOS: :path: Flutter/ephemeral path_provider_foundation: @@ -57,19 +52,15 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin sqlite3_flutter_libs: :path: Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/macos - url_launcher_macos: - :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos SPEC CHECKSUMS: - app_links: 10e0a0ab602ffaf34d142cd4862f29d34b303b2a FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 - path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c + path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 powersync-sqlite-core: 4c38c8f470f6dca61346789fd5436a6826d1e3dd powersync_flutter_libs: 1eb1c6790a72afe08e68d4cc489d71ab61da32ee - shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 - sqlite3: 154b084339ede06960a5b3c8160066adc9176b7d - sqlite3_flutter_libs: 1be4459672f8168ded2d8667599b8e3ca5e72b83 - url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95 + shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 + sqlite3: 292c3e1bfe89f64e51ea7fc7dab9182a017c8630 + sqlite3_flutter_libs: 5ca46c1a04eddfbeeb5b16566164aa7ad1616e7b PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 From 72fed8247bdc90d82bef9697e6c30cf9d5ca78c3 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 11 Jul 2024 09:12:30 +0200 Subject: [PATCH 2/2] make test user info better --- demos/django-todolist/README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/demos/django-todolist/README.md b/demos/django-todolist/README.md index a5e10baa..a7b8c3d0 100644 --- a/demos/django-todolist/README.md +++ b/demos/django-todolist/README.md @@ -12,6 +12,13 @@ Ensure you have [melos](https://melos.invertase.dev/~melos-latest/getting-starte 4. Insert your Django URL and PowerSync project credentials into `lib/app_config.dart` (See instructions below) 5. `flutter run` +A test user with the following credentials will be available: + +``` +username: testuser +password: testpassword +``` + # Service Configuration This demo can be used with cloud or local services. @@ -21,12 +28,7 @@ This demo can be used with cloud or local services. The [Self Hosting Demo](https://github.com/powersync-ja/self-host-demo) repository contains a Docker Compose Django backend demo which can be used with this client. See [instructions](https://github.com/powersync-ja/self-host-demo/blob/main/demos/django/README.md) for starting the backend locally. -The backend demo should perform all the required setup automatically. A test user with the following credentials will be available: - -``` -username: testuser -password: testpassword -``` +The backend demo should perform all the required setup automatically. ### Android