@indexeddb-orm/idb-orm 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/extensions.json +5 -0
- package/README.md +1280 -0
- package/angular-demo-app/README.md +84 -0
- package/angular-demo-app/angular.json +109 -0
- package/angular-demo-app/package-lock.json +14215 -0
- package/angular-demo-app/package.json +41 -0
- package/angular-demo-app/src/app/app.component.ts +481 -0
- package/angular-demo-app/src/app/app.routes.ts +8 -0
- package/angular-demo-app/src/app/components/actions.component.ts +202 -0
- package/angular-demo-app/src/app/components/cloud-sync-demo.component.ts +296 -0
- package/angular-demo-app/src/app/components/live-query-demo.component.ts +307 -0
- package/angular-demo-app/src/app/components/main-info.component.ts +148 -0
- package/angular-demo-app/src/app/components/posts-live-query-demo.component.ts +336 -0
- package/angular-demo-app/src/app/components/typescript-demo.component.ts +268 -0
- package/angular-demo-app/src/entities/post-tag.entity.ts +25 -0
- package/angular-demo-app/src/entities/post.entity.ts +49 -0
- package/angular-demo-app/src/entities/profile.entity.ts +42 -0
- package/angular-demo-app/src/entities/tag.entity.ts +36 -0
- package/angular-demo-app/src/entities/user.entity.ts +59 -0
- package/angular-demo-app/src/favicon.ico +1 -0
- package/angular-demo-app/src/index.html +16 -0
- package/angular-demo-app/src/main.ts +13 -0
- package/angular-demo-app/src/services/app-logic.service.ts +449 -0
- package/angular-demo-app/src/services/cloud-sync.service.ts +95 -0
- package/angular-demo-app/src/services/database.service.ts +26 -0
- package/angular-demo-app/src/services/live-query.service.ts +63 -0
- package/angular-demo-app/src/services/posts-live-query.service.ts +86 -0
- package/angular-demo-app/src/services/typescript-demo.service.ts +59 -0
- package/angular-demo-app/src/styles.scss +50 -0
- package/angular-demo-app/tsconfig.app.json +13 -0
- package/angular-demo-app/tsconfig.json +34 -0
- package/angular-demo-app/tsconfig.spec.json +13 -0
- package/dist/Database.d.ts +206 -0
- package/dist/Database.js +288 -0
- package/dist/decorators/Column.d.ts +79 -0
- package/dist/decorators/Column.js +236 -0
- package/dist/decorators/Entity.d.ts +32 -0
- package/dist/decorators/Entity.js +44 -0
- package/dist/decorators/Relation.d.ts +70 -0
- package/dist/decorators/Relation.js +120 -0
- package/dist/decorators/index.d.ts +3 -0
- package/dist/decorators/index.js +3 -0
- package/dist/errors/ValidationError.d.ts +4 -0
- package/dist/errors/ValidationError.js +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +7 -0
- package/dist/metadata/Column.d.ts +8 -0
- package/dist/metadata/Column.js +44 -0
- package/dist/metadata/Entity.d.ts +11 -0
- package/dist/metadata/Entity.js +21 -0
- package/dist/metadata/Relation.d.ts +20 -0
- package/dist/metadata/Relation.js +74 -0
- package/dist/metadata/index.d.ts +3 -0
- package/dist/metadata/index.js +3 -0
- package/dist/services/AggregationService.d.ts +38 -0
- package/dist/services/AggregationService.js +229 -0
- package/dist/services/BaseEntity.d.ts +32 -0
- package/dist/services/BaseEntity.js +62 -0
- package/dist/services/CloudSyncService.d.ts +100 -0
- package/dist/services/CloudSyncService.js +196 -0
- package/dist/services/DecoratorUtils.d.ts +12 -0
- package/dist/services/DecoratorUtils.js +10 -0
- package/dist/services/EntityFactory.d.ts +25 -0
- package/dist/services/EntityFactory.js +27 -0
- package/dist/services/EntityRegistry.d.ts +61 -0
- package/dist/services/EntityRegistry.js +56 -0
- package/dist/services/EntitySchema.d.ts +56 -0
- package/dist/services/EntitySchema.js +125 -0
- package/dist/services/MigrationManager.d.ts +70 -0
- package/dist/services/MigrationManager.js +181 -0
- package/dist/services/RelationLoader.d.ts +66 -0
- package/dist/services/RelationLoader.js +310 -0
- package/dist/services/SchemaBuilder.d.ts +68 -0
- package/dist/services/SchemaBuilder.js +191 -0
- package/dist/services/index.d.ts +7 -0
- package/dist/services/index.js +7 -0
- package/dist/types.d.ts +152 -0
- package/dist/types.js +1 -0
- package/dist/utils/logger.d.ts +12 -0
- package/dist/utils/logger.js +16 -0
- package/eslint.config.js +49 -0
- package/homepage/favicon.svg +36 -0
- package/homepage/index.html +1725 -0
- package/package.json +78 -0
- package/react-demo-app/README.md +61 -0
- package/react-demo-app/eslint.config.js +60 -0
- package/react-demo-app/index.html +13 -0
- package/react-demo-app/package-lock.json +4955 -0
- package/react-demo-app/package.json +39 -0
- package/react-demo-app/src/App.tsx +172 -0
- package/react-demo-app/src/assets/react.svg +1 -0
- package/react-demo-app/src/components/Actions.tsx +171 -0
- package/react-demo-app/src/components/CloudSyncDemo.tsx +191 -0
- package/react-demo-app/src/components/LiveQueryDemo.tsx +122 -0
- package/react-demo-app/src/components/MainInfo.tsx +75 -0
- package/react-demo-app/src/components/PostsLiveQueryDemo.tsx +185 -0
- package/react-demo-app/src/components/TypeScriptDemo.tsx +190 -0
- package/react-demo-app/src/database/Database.ts +30 -0
- package/react-demo-app/src/entities/Post.ts +48 -0
- package/react-demo-app/src/entities/PostTag.ts +26 -0
- package/react-demo-app/src/entities/Profile.ts +41 -0
- package/react-demo-app/src/entities/Tag.ts +35 -0
- package/react-demo-app/src/entities/User.ts +61 -0
- package/react-demo-app/src/hooks/useAppLogic.ts +565 -0
- package/react-demo-app/src/hooks/useCloudSyncDemo.ts +84 -0
- package/react-demo-app/src/hooks/useLiveQueryDemo.ts +68 -0
- package/react-demo-app/src/hooks/usePostsLiveQueryDemo.ts +64 -0
- package/react-demo-app/src/hooks/useTypeScriptDemo.ts +43 -0
- package/react-demo-app/src/index.css +26 -0
- package/react-demo-app/src/main.tsx +18 -0
- package/react-demo-app/src/migrations/001-add-user-email-index.ts +17 -0
- package/react-demo-app/src/migrations/002-add-post-category.ts +37 -0
- package/react-demo-app/src/migrations/index.ts +8 -0
- package/react-demo-app/src/vite-env.d.ts +1 -0
- package/react-demo-app/tsconfig.app.json +22 -0
- package/react-demo-app/tsconfig.json +6 -0
- package/react-demo-app/vite.config.ts +10 -0
- package/src/Database.ts +405 -0
- package/src/errors/ValidationError.ts +9 -0
- package/src/index.ts +13 -0
- package/src/metadata/Column.ts +74 -0
- package/src/metadata/Entity.ts +42 -0
- package/src/metadata/Relation.ts +121 -0
- package/src/metadata/index.ts +5 -0
- package/src/services/AggregationService.ts +348 -0
- package/src/services/BaseEntity.ts +77 -0
- package/src/services/CloudSyncService.ts +248 -0
- package/src/services/EntityFactory.ts +35 -0
- package/src/services/EntityRegistry.ts +109 -0
- package/src/services/EntitySchema.ts +154 -0
- package/src/services/MigrationManager.ts +276 -0
- package/src/services/RelationLoader.ts +532 -0
- package/src/services/SchemaBuilder.ts +237 -0
- package/src/services/index.ts +7 -0
- package/src/types.d.ts +1 -0
- package/src/types.ts +169 -0
- package/src/utils/logger.ts +40 -0
- package/svelte-demo-app/README.md +61 -0
- package/svelte-demo-app/package-lock.json +3000 -0
- package/svelte-demo-app/package.json +30 -0
- package/svelte-demo-app/src/app.d.ts +12 -0
- package/svelte-demo-app/src/app.html +13 -0
- package/svelte-demo-app/src/components/Actions.svelte +121 -0
- package/svelte-demo-app/src/components/CloudSyncDemo.svelte +333 -0
- package/svelte-demo-app/src/components/LiveQueryDemo.svelte +191 -0
- package/svelte-demo-app/src/components/MainInfo.svelte +133 -0
- package/svelte-demo-app/src/components/PostsLiveQueryDemo.svelte +330 -0
- package/svelte-demo-app/src/components/TypeScriptDemo.svelte +251 -0
- package/svelte-demo-app/src/database/Database.ts +29 -0
- package/svelte-demo-app/src/entities/Post.ts +46 -0
- package/svelte-demo-app/src/entities/PostTag.ts +22 -0
- package/svelte-demo-app/src/entities/Profile.ts +39 -0
- package/svelte-demo-app/src/entities/Tag.ts +33 -0
- package/svelte-demo-app/src/entities/User.ts +62 -0
- package/svelte-demo-app/src/lib/database/Database.ts +30 -0
- package/svelte-demo-app/src/lib/entities/Post.ts +47 -0
- package/svelte-demo-app/src/lib/entities/PostTag.ts +23 -0
- package/svelte-demo-app/src/lib/entities/Profile.ts +40 -0
- package/svelte-demo-app/src/lib/entities/Tag.ts +34 -0
- package/svelte-demo-app/src/lib/entities/User.ts +59 -0
- package/svelte-demo-app/src/lib/index.ts +7 -0
- package/svelte-demo-app/src/lib/migrations/001-add-user-email-index.ts +17 -0
- package/svelte-demo-app/src/lib/migrations/002-add-post-category.ts +37 -0
- package/svelte-demo-app/src/lib/migrations/index.ts +8 -0
- package/svelte-demo-app/src/migrations/001-add-user-email-index.ts +17 -0
- package/svelte-demo-app/src/migrations/002-add-post-category.ts +37 -0
- package/svelte-demo-app/src/migrations/index.ts +8 -0
- package/svelte-demo-app/src/routes/+layout.js +3 -0
- package/svelte-demo-app/src/routes/+layout.svelte +228 -0
- package/svelte-demo-app/src/routes/+page.js +3 -0
- package/svelte-demo-app/src/routes/+page.svelte +1305 -0
- package/svelte-demo-app/src/stores/appStore.js +603 -0
- package/svelte-demo-app/svelte.config.js +18 -0
- package/svelte-demo-app/tsconfig.json +14 -0
- package/svelte-demo-app/vite.config.ts +6 -0
- package/tests/aggregation.e2e.test.ts +87 -0
- package/tests/base-entity.e2e.test.ts +47 -0
- package/tests/database-api.e2e.test.ts +177 -0
- package/tests/decorators.e2e.test.ts +40 -0
- package/tests/entity-schema.e2e.test.ts +58 -0
- package/tests/relation-loader-table-names.test.ts +192 -0
- package/tests/relations.e2e.test.ts +178 -0
- package/tests/zod-runtime.e2e.test.ts +69 -0
- package/tsconfig.json +21 -0
- package/vitest.config.ts +21 -0
- package/vitest.setup.ts +27 -0
- package/vue-demo-app/README.md +61 -0
- package/vue-demo-app/index.html +13 -0
- package/vue-demo-app/package-lock.json +1537 -0
- package/vue-demo-app/package.json +27 -0
- package/vue-demo-app/src/App.vue +100 -0
- package/vue-demo-app/src/components/Actions.vue +135 -0
- package/vue-demo-app/src/components/CloudSyncDemo.vue +139 -0
- package/vue-demo-app/src/components/LiveQueryDemo.vue +122 -0
- package/vue-demo-app/src/components/MainInfo.vue +80 -0
- package/vue-demo-app/src/components/PostsLiveQueryDemo.vue +136 -0
- package/vue-demo-app/src/components/TypeScriptDemo.vue +133 -0
- package/vue-demo-app/src/database/Database.ts +29 -0
- package/vue-demo-app/src/entities/Post.ts +48 -0
- package/vue-demo-app/src/entities/PostTag.ts +24 -0
- package/vue-demo-app/src/entities/Profile.ts +41 -0
- package/vue-demo-app/src/entities/Tag.ts +35 -0
- package/vue-demo-app/src/entities/User.ts +61 -0
- package/vue-demo-app/src/main.ts +29 -0
- package/vue-demo-app/src/migrations/001-add-user-email-index.ts +23 -0
- package/vue-demo-app/src/migrations/002-add-post-category.ts +46 -0
- package/vue-demo-app/src/migrations/index.ts +14 -0
- package/vue-demo-app/src/services/useAppLogic.ts +565 -0
- package/vue-demo-app/src/services/useCloudSyncDemo.ts +84 -0
- package/vue-demo-app/src/services/useLiveQueryDemo.ts +82 -0
- package/vue-demo-app/src/services/usePostsLiveQueryDemo.ts +77 -0
- package/vue-demo-app/src/services/useTypeScriptDemo.ts +56 -0
- package/vue-demo-app/src/vite-env.d.ts +1 -0
- package/vue-demo-app/tsconfig.json +25 -0
- package/vue-demo-app/tsconfig.node.json +10 -0
- package/vue-demo-app/vite.config.ts +16 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import {
|
|
3
|
+
Component, Input,
|
|
4
|
+
} from '@angular/core';
|
|
5
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
6
|
+
import { MatCardModule } from '@angular/material/card';
|
|
7
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
8
|
+
import { MatListModule } from '@angular/material/list';
|
|
9
|
+
|
|
10
|
+
import { UserEntity } from '../../entities/user.entity';
|
|
11
|
+
import { MainInfoComponent } from './main-info.component';
|
|
12
|
+
|
|
13
|
+
@Component({
|
|
14
|
+
selector: 'app-actions',
|
|
15
|
+
standalone: true,
|
|
16
|
+
imports: [
|
|
17
|
+
CommonModule,
|
|
18
|
+
MatButtonModule,
|
|
19
|
+
MatCardModule,
|
|
20
|
+
MatIconModule,
|
|
21
|
+
MatListModule,
|
|
22
|
+
MainInfoComponent,
|
|
23
|
+
],
|
|
24
|
+
template: `
|
|
25
|
+
<app-main-info></app-main-info>
|
|
26
|
+
|
|
27
|
+
<div class="admin-section">
|
|
28
|
+
<h2 class="section-title">Admin Actions</h2>
|
|
29
|
+
<div class="actions-grid">
|
|
30
|
+
<button mat-stroked-button (click)="addUser()" class="action-button">
|
|
31
|
+
<mat-icon>person_add</mat-icon>
|
|
32
|
+
Add User
|
|
33
|
+
</button>
|
|
34
|
+
|
|
35
|
+
<button mat-stroked-button (click)=
|
|
36
|
+
"testZodValidation()" class="action-button">
|
|
37
|
+
<mat-icon>science</mat-icon>
|
|
38
|
+
Test Zod
|
|
39
|
+
</button>
|
|
40
|
+
|
|
41
|
+
<button mat-stroked-button (click)=
|
|
42
|
+
"testSchemaMigration()" class="action-button">
|
|
43
|
+
<mat-icon>storage</mat-icon>
|
|
44
|
+
Schema
|
|
45
|
+
</button>
|
|
46
|
+
|
|
47
|
+
<button mat-stroked-button (click)="toggleAutoReset()" class="action-button">
|
|
48
|
+
<mat-icon>settings</mat-icon>
|
|
49
|
+
Auto-Reset
|
|
50
|
+
</button>
|
|
51
|
+
|
|
52
|
+
<button mat-stroked-button (click)="testRelations()" class="action-button">
|
|
53
|
+
<mat-icon>link</mat-icon>
|
|
54
|
+
Relations
|
|
55
|
+
</button>
|
|
56
|
+
|
|
57
|
+
<button mat-stroked-button (click)=
|
|
58
|
+
"testTransactions()" class="action-button">
|
|
59
|
+
<mat-icon>speed</mat-icon>
|
|
60
|
+
Transactions
|
|
61
|
+
</button>
|
|
62
|
+
|
|
63
|
+
<button mat-stroked-button (click)=
|
|
64
|
+
"testCompoundIndexes()" class="action-button">
|
|
65
|
+
<mat-icon>search</mat-icon>
|
|
66
|
+
Indexes
|
|
67
|
+
</button>
|
|
68
|
+
|
|
69
|
+
<button mat-stroked-button (click)=
|
|
70
|
+
"testAggregations()" class="action-button">
|
|
71
|
+
<mat-icon>assessment</mat-icon>
|
|
72
|
+
Aggregations
|
|
73
|
+
</button>
|
|
74
|
+
|
|
75
|
+
<button mat-stroked-button (click)=
|
|
76
|
+
"clearAll()" class="action-button clear-button">
|
|
77
|
+
<mat-icon>delete_sweep</mat-icon>
|
|
78
|
+
Clear All
|
|
79
|
+
</button>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<div class="users-section" *ngIf="users.length > 0">
|
|
84
|
+
<h3 class="users-title">Users ({{ users.length }})</h3>
|
|
85
|
+
<div class="users-list">
|
|
86
|
+
<div class="user-card" *ngFor="let user of users">
|
|
87
|
+
<strong>{{ user.name }}</strong> ({{ user.email }})<br />
|
|
88
|
+
Age: {{ user.age }}, Tags: {{ user.tags?.join(', ') || 'none' }}
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
`,
|
|
93
|
+
styles: [`
|
|
94
|
+
.admin-section {
|
|
95
|
+
margin-bottom: 16px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.section-title {
|
|
99
|
+
font-size: 1.5rem;
|
|
100
|
+
font-weight: 400;
|
|
101
|
+
margin: 0 0 16px 0;
|
|
102
|
+
color: rgba(0, 0, 0, 0.87);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.actions-grid {
|
|
106
|
+
display: grid;
|
|
107
|
+
grid-template-columns: repeat(2, 1fr);
|
|
108
|
+
grid-template-rows: repeat(5, auto);
|
|
109
|
+
gap: 8px;
|
|
110
|
+
margin-bottom: 16px;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@media (min-width: 600px) {
|
|
114
|
+
.actions-grid {
|
|
115
|
+
grid-template-columns: repeat(3, 1fr);
|
|
116
|
+
grid-template-rows: repeat(3, auto);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@media (min-width: 960px) {
|
|
121
|
+
.actions-grid {
|
|
122
|
+
grid-template-columns: repeat(4, 1fr);
|
|
123
|
+
grid-template-rows: repeat(3, auto);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@media (min-width: 1200px) {
|
|
128
|
+
.actions-grid {
|
|
129
|
+
grid-template-columns: repeat(5, 1fr);
|
|
130
|
+
grid-template-rows: repeat(2, auto);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.action-button {
|
|
135
|
+
text-transform: none !important;
|
|
136
|
+
font-size: 0.875rem;
|
|
137
|
+
padding: 8px 16px;
|
|
138
|
+
border: 1px solid rgba(0, 0, 0, 0.23);
|
|
139
|
+
background-color: transparent;
|
|
140
|
+
color: rgba(0, 0, 0, 0.87);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.action-button:hover {
|
|
144
|
+
background-color: rgba(0, 0, 0, 0.04);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.clear-button {
|
|
148
|
+
grid-column: 1 / -1;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@media (min-width: 600px) {
|
|
152
|
+
.clear-button {
|
|
153
|
+
grid-column: auto;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@media (max-width: 600px) {
|
|
158
|
+
.action-button {
|
|
159
|
+
font-size: 0.75rem;
|
|
160
|
+
padding: 8px 12px;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.users-section {
|
|
165
|
+
margin-top: 24px;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.users-title {
|
|
169
|
+
font-size: 1.25rem;
|
|
170
|
+
font-weight: 500;
|
|
171
|
+
margin: 0 0 16px 0;
|
|
172
|
+
color: rgba(0, 0, 0, 0.87);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.users-list {
|
|
176
|
+
display: flex;
|
|
177
|
+
flex-direction: column;
|
|
178
|
+
gap: 8px;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.user-card {
|
|
182
|
+
padding: 12px;
|
|
183
|
+
border: 1px solid rgba(0, 0, 0, 0.23);
|
|
184
|
+
border-radius: 4px;
|
|
185
|
+
background-color: #fff;
|
|
186
|
+
font-size: 0.875rem;
|
|
187
|
+
line-height: 1.5;
|
|
188
|
+
}
|
|
189
|
+
`],
|
|
190
|
+
})
|
|
191
|
+
export class ActionsComponent {
|
|
192
|
+
@Input() users: UserEntity[] = [];
|
|
193
|
+
@Input() addUser!: () => void;
|
|
194
|
+
@Input() testZodValidation!: () => void;
|
|
195
|
+
@Input() testSchemaMigration!: () => void;
|
|
196
|
+
@Input() toggleAutoReset!: () => void;
|
|
197
|
+
@Input() testRelations!: () => void;
|
|
198
|
+
@Input() testTransactions!: () => void;
|
|
199
|
+
@Input() testCompoundIndexes!: () => void;
|
|
200
|
+
@Input() testAggregations!: () => void;
|
|
201
|
+
@Input() clearAll!: () => void;
|
|
202
|
+
}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import {
|
|
3
|
+
Component, Input,
|
|
4
|
+
} from '@angular/core';
|
|
5
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
6
|
+
import { MatCardModule } from '@angular/material/card';
|
|
7
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
8
|
+
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
9
|
+
|
|
10
|
+
@Component({
|
|
11
|
+
selector: 'app-cloud-sync-demo',
|
|
12
|
+
standalone: true,
|
|
13
|
+
imports: [
|
|
14
|
+
CommonModule,
|
|
15
|
+
MatButtonModule,
|
|
16
|
+
MatCardModule,
|
|
17
|
+
MatIconModule,
|
|
18
|
+
MatProgressSpinnerModule,
|
|
19
|
+
],
|
|
20
|
+
template: `
|
|
21
|
+
<div class="cloud-sync-container">
|
|
22
|
+
<h2>Cloud Sync Demo</h2>
|
|
23
|
+
<p class="demo-description">
|
|
24
|
+
<strong>Dexie Cloud Addon Integration:</strong> Cloud synchronization demo
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
<div class="sync-grid">
|
|
28
|
+
<div class="sync-status-section">
|
|
29
|
+
<h3 class="section-title">
|
|
30
|
+
<mat-icon color="primary" class="section-icon">cloud_sync</mat-icon>
|
|
31
|
+
Sync status
|
|
32
|
+
</h3>
|
|
33
|
+
<div class="status-display">
|
|
34
|
+
<p><strong>Enabled:</strong> {{ syncStatus.enabled ? 'Yes' : 'No' }}</p>
|
|
35
|
+
<p><strong>
|
|
36
|
+
Online:
|
|
37
|
+
</strong>
|
|
38
|
+
{{ syncStatus.isOnline !== undefined
|
|
39
|
+
? (syncStatus.isOnline ? 'Yes' : 'No')
|
|
40
|
+
: 'Unknown' }}
|
|
41
|
+
</p>
|
|
42
|
+
<p><strong>Last sync:</strong> {{ syncStatus.lastSync
|
|
43
|
+
? syncStatus.lastSync.toLocaleString()
|
|
44
|
+
: 'Never' }}</p>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div class="sync-controls-section">
|
|
49
|
+
<h3 class="section-title">
|
|
50
|
+
<mat-icon color="primary" class="section-icon">settings</mat-icon>
|
|
51
|
+
Sync controls
|
|
52
|
+
</h3>
|
|
53
|
+
<div class="controls-container">
|
|
54
|
+
<button mat-stroked-button
|
|
55
|
+
(click)="handleManualSync()"
|
|
56
|
+
[disabled]="!syncStatus.enabled || isLoading"
|
|
57
|
+
class="sync-button manual-sync">
|
|
58
|
+
{{ isLoading ? 'Syncing...' : 'Sync manually' }}
|
|
59
|
+
</button>
|
|
60
|
+
|
|
61
|
+
<button mat-stroked-button
|
|
62
|
+
(click)="handleSyncTables()"
|
|
63
|
+
[disabled]="!syncStatus.enabled || isLoading"
|
|
64
|
+
class="sync-button sync-tables">
|
|
65
|
+
Sync tables (users, posts)
|
|
66
|
+
</button>
|
|
67
|
+
|
|
68
|
+
<button *ngIf="!syncStatus.enabled"
|
|
69
|
+
mat-stroked-button
|
|
70
|
+
(click)="handleEnableCloudSync()"
|
|
71
|
+
[disabled]="isLoading"
|
|
72
|
+
class="sync-button enable-sync">
|
|
73
|
+
Enable cloud sync
|
|
74
|
+
</button>
|
|
75
|
+
|
|
76
|
+
<button *ngIf="syncStatus.enabled"
|
|
77
|
+
mat-stroked-button
|
|
78
|
+
(click)="handleDisableCloudSync()"
|
|
79
|
+
[disabled]="isLoading"
|
|
80
|
+
class="sync-button disable-sync">
|
|
81
|
+
Disable cloud sync
|
|
82
|
+
</button>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div class="instructions-section">
|
|
88
|
+
<h4 class="instructions-title">
|
|
89
|
+
<mat-icon color="primary" class="section-icon">info</mat-icon>
|
|
90
|
+
Instructions:
|
|
91
|
+
</h4>
|
|
92
|
+
<ol class="instructions-list">
|
|
93
|
+
<li><strong>
|
|
94
|
+
Install dexie-cloud-addon:
|
|
95
|
+
</strong> <code>npm install dexie-cloud-addon</code></li>
|
|
96
|
+
<li><strong>
|
|
97
|
+
Configure database URL
|
|
98
|
+
</strong> in <code>demo-app/src/database/Database.ts</code></li>
|
|
99
|
+
<li><strong>Enable cloud sync</strong> using the button above</li>
|
|
100
|
+
<li><strong>Test sync</strong> – add data and verify it synchronizes</li>
|
|
101
|
+
</ol>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<div class="configuration-info">
|
|
105
|
+
<strong>
|
|
106
|
+
Configuration:
|
|
107
|
+
// </strong>
|
|
108
|
+
Cloud sync is configured in Database.ts with automatic sync every 30 seconds
|
|
109
|
+
.<br />
|
|
110
|
+
<strong>
|
|
111
|
+
Offline Support:
|
|
112
|
+
</strong> The app works offline and syncs when connection is restored.<br />
|
|
113
|
+
<strong>
|
|
114
|
+
Reactivity:
|
|
115
|
+
</strong> All changes are automatically synchronized with the cloud!
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
`,
|
|
119
|
+
styles: [`
|
|
120
|
+
.cloud-sync-container {
|
|
121
|
+
border: 2px solid #2196f3;
|
|
122
|
+
padding: 20px;
|
|
123
|
+
margin: 20px 0;
|
|
124
|
+
border-radius: 8px;
|
|
125
|
+
background-color: #e3f2fd;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.cloud-sync-container h2 {
|
|
129
|
+
margin: 0 0 8px 0;
|
|
130
|
+
font-size: 1.5rem;
|
|
131
|
+
font-weight: 400;
|
|
132
|
+
color: rgba(0, 0, 0, 0.87);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.demo-description {
|
|
136
|
+
color: #666;
|
|
137
|
+
margin: 0 0 20px 0;
|
|
138
|
+
font-size: 0.875rem;
|
|
139
|
+
line-height: 1.5;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.sync-grid {
|
|
143
|
+
display: grid;
|
|
144
|
+
grid-template-columns: 1fr 1fr;
|
|
145
|
+
gap: 20px;
|
|
146
|
+
margin-bottom: 20px;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@media (max-width: 768px) {
|
|
150
|
+
.sync-grid {
|
|
151
|
+
grid-template-columns: 1fr;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.section-title {
|
|
156
|
+
display: flex;
|
|
157
|
+
align-items: center;
|
|
158
|
+
gap: 8px;
|
|
159
|
+
margin: 0 0 12px 0;
|
|
160
|
+
font-size: 1rem;
|
|
161
|
+
font-weight: 500;
|
|
162
|
+
color: rgba(0, 0, 0, 0.87);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.section-icon {
|
|
166
|
+
font-size: 20px;
|
|
167
|
+
width: 20px;
|
|
168
|
+
height: 20px;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.status-display {
|
|
172
|
+
background-color: white;
|
|
173
|
+
padding: 15px;
|
|
174
|
+
border-radius: 4px;
|
|
175
|
+
border: 1px solid #ddd;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.status-display p {
|
|
179
|
+
margin: 0 0 8px 0;
|
|
180
|
+
font-size: 0.875rem;
|
|
181
|
+
line-height: 1.5;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.status-display p:last-child {
|
|
185
|
+
margin-bottom: 0;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.controls-container {
|
|
189
|
+
display: flex;
|
|
190
|
+
flex-direction: column;
|
|
191
|
+
gap: 10px;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.sync-button {
|
|
195
|
+
padding: 10px 15px;
|
|
196
|
+
border: none;
|
|
197
|
+
border-radius: 4px;
|
|
198
|
+
cursor: pointer;
|
|
199
|
+
font-size: 0.875rem;
|
|
200
|
+
text-transform: none !important;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.manual-sync {
|
|
204
|
+
background-color: #4caf50;
|
|
205
|
+
color: white;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.manual-sync:disabled {
|
|
209
|
+
background-color: #ccc;
|
|
210
|
+
cursor: not-allowed;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.sync-tables {
|
|
214
|
+
background-color: #ff9800;
|
|
215
|
+
color: white;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.sync-tables:disabled {
|
|
219
|
+
background-color: #ccc;
|
|
220
|
+
cursor: not-allowed;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.enable-sync {
|
|
224
|
+
background-color: #2196f3;
|
|
225
|
+
color: white;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.disable-sync {
|
|
229
|
+
background-color: #f44336;
|
|
230
|
+
color: white;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.instructions-section {
|
|
234
|
+
background-color: #fff3e0;
|
|
235
|
+
padding: 15px;
|
|
236
|
+
border-radius: 4px;
|
|
237
|
+
border: 1px solid #ffb74d;
|
|
238
|
+
margin-bottom: 15px;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.instructions-title {
|
|
242
|
+
display: flex;
|
|
243
|
+
align-items: center;
|
|
244
|
+
gap: 8px;
|
|
245
|
+
margin: 0 0 16px 0;
|
|
246
|
+
font-size: 1rem;
|
|
247
|
+
font-weight: 500;
|
|
248
|
+
color: rgba(0, 0, 0, 0.87);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.instructions-list {
|
|
252
|
+
margin: 10px 0;
|
|
253
|
+
padding-left: 20px;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.instructions-list li {
|
|
257
|
+
margin-bottom: 8px;
|
|
258
|
+
font-size: 0.875rem;
|
|
259
|
+
line-height: 1.5;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.instructions-list code {
|
|
263
|
+
background-color: #f5f5f5;
|
|
264
|
+
padding: 2px 4px;
|
|
265
|
+
border-radius: 2px;
|
|
266
|
+
font-family: 'Courier New', monospace;
|
|
267
|
+
font-size: 0.8rem;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.configuration-info {
|
|
271
|
+
margin-top: 15px;
|
|
272
|
+
font-size: 0.9em;
|
|
273
|
+
color: #666;
|
|
274
|
+
background-color: #e8f5e8;
|
|
275
|
+
padding: 10px;
|
|
276
|
+
border-radius: 4px;
|
|
277
|
+
line-height: 1.5;
|
|
278
|
+
}
|
|
279
|
+
`],
|
|
280
|
+
})
|
|
281
|
+
export class CloudSyncDemoComponent {
|
|
282
|
+
@Input() syncStatus: {
|
|
283
|
+
enabled: boolean;
|
|
284
|
+
isOnline?: boolean;
|
|
285
|
+
lastSync?: Date;
|
|
286
|
+
} = {
|
|
287
|
+
enabled: false,
|
|
288
|
+
isOnline: undefined,
|
|
289
|
+
lastSync: undefined,
|
|
290
|
+
};
|
|
291
|
+
@Input() isLoading: boolean = false;
|
|
292
|
+
@Input() handleManualSync!: () => void;
|
|
293
|
+
@Input() handleEnableCloudSync!: () => void;
|
|
294
|
+
@Input() handleDisableCloudSync!: () => void;
|
|
295
|
+
@Input() handleSyncTables!: () => void;
|
|
296
|
+
}
|