Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit 3ba0147

Browse files
DataSync 2.0 (#420)
Co-authored-by: Gianluca <[email protected]>
1 parent 58297f5 commit 3ba0147

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1222
-517
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ $RECYCLE.BIN/
3232
Thumbs.db
3333
UserInterfaceState.xcuserstate
3434
package-lock.json
35-
server/src/config/keycloak.json
3635

3736
server/website
3837
yarn.lock

.graphqlrc.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
## GraphQL Config Generated by Graphback
2-
## Please review configuration and adjust it for your own project
2+
## Configuration is being used to generate client side queries
33
schema: ./server/src/schema/schema.graphql
44
documents: ./client/src/graphql/**/*.graphql
55
extensions:
66
graphback:
7-
model: ./model
7+
model: ./server/model/task.graphql
88
crud:
99
create: true
1010
update: true
@@ -15,14 +15,11 @@ extensions:
1515
subUpdate: true
1616
subDelete: true
1717
plugins:
18+
## Schema for preview only - server is not using it as it is generated at runtime
1819
graphback-schema:
1920
format: graphql
2021
outputPath: ./server/src/schema
21-
graphback-resolvers:
22-
format: 'ts'
23-
outputPath: ./server/src/resolvers
22+
## Client side queries
2423
graphback-client:
2524
format: 'ts'
26-
outputPath: ./client/src/graphql
27-
graphback-offix:
28-
outputPath: ./server/src/resolvers
25+
outputFile: ./client/src/graphql/generated.ts

client/package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,20 @@
2222
"graphql-tag": "2.10.3",
2323
"ionicons": "5.0.1",
2424
"keycloak-js": "10.0.2",
25-
"offix-cache": "0.15.1",
26-
"offix-client": "0.15.1",
25+
"offix-cache": "0.16.0-alpha2",
26+
"offix-client": "0.16.0-alpha2",
2727
"react": "16.13.1",
2828
"react-dom": "16.13.1",
29-
"react-offix-hooks": "0.15.1",
29+
"react-offix-hooks": "0.16.0-alpha2",
3030
"react-router": "5.2.0",
3131
"react-router-dom": "5.2.0",
3232
"react-scripts": "3.4.1",
33+
"simpl-schema": "1.7.3",
3334
"subscriptions-transport-ws": "0.9.16",
3435
"typescript": "3.9.5",
35-
"uniforms-ionic": "0.0.11",
3636
"uniforms": "3.0.0-alpha.4",
37-
"uniforms-bridge-simple-schema-2": "3.0.0-alpha.4"
37+
"uniforms-bridge-simple-schema-2": "3.0.0-alpha.4",
38+
"uniforms-ionic": "0.1.0"
3839
},
3940
"scripts": {
4041
"start": "npm run build && cap serve",
@@ -61,7 +62,8 @@
6162
]
6263
},
6364
"devDependencies": {
64-
"@capacitor/cli": "2.1.2"
65+
"@capacitor/cli": "2.1.2",
66+
"@types/simpl-schema": "^0.2.7"
6567
},
6668
"description": "An Ionic project"
6769
}

client/public/assets/icon/avatar.svg

Lines changed: 1 addition & 0 deletions
Loading

client/public/manifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
"type": "image/png",
1313
"sizes": "512x512",
1414
"purpose": "maskable"
15+
},
16+
{
17+
"src": "assets/icon/avatar.svg",
18+
"type": "image/svg",
19+
"sizes": "512x512",
20+
"purpose": "maskable"
1521
}
1622
],
1723
"start_url": ".",

client/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const App: React.FC = () => {
1515
useEffect(() => {
1616
const conflictListener: ConflictListener = {
1717
mergeOccurred() {
18-
setShowConflict(true);
18+
console.log("Merge occured! ")
1919
},
2020
conflictOccurred() {
2121
setShowConflict(true);

client/src/AppContainer.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
22
import { ApolloOfflineClient } from 'offix-client';
33
import { ApolloOfflineProvider } from 'react-offix-hooks';
44
import { ApolloProvider } from '@apollo/react-hooks';
5-
import { AppContext } from './AppContext';
5+
import { AuthContext } from './AuthContext';
66
import { clientConfig } from './config';
77
import { Loading } from './components/Loading';
88
import { IContainerProps } from './declarations';
@@ -20,7 +20,9 @@ export const AppContainer: React.FC<IContainerProps> = ({ app: App }) => {
2020
const init = async () => {
2121
keycloak = await getKeycloakInstance();
2222
await apolloClient.init();
23-
23+
if (keycloak) {
24+
await keycloak?.loadUserProfile();
25+
}
2426
setInitialized(true);
2527
}
2628
init();
@@ -30,13 +32,13 @@ export const AppContainer: React.FC<IContainerProps> = ({ app: App }) => {
3032

3133
// return container with keycloak provider
3234
return (
33-
<AppContext.Provider value={{ keycloak }}>
35+
<AuthContext.Provider value={{ keycloak, profile: keycloak?.profile }}>
3436
<ApolloOfflineProvider client={apolloClient}>
3537
<ApolloProvider client={apolloClient}>
3638
<App />
3739
</ApolloProvider>
3840
</ApolloOfflineProvider>
39-
</AppContext.Provider>
41+
</AuthContext.Provider>
4042
);
4143

4244

client/src/AppContext.tsx

Lines changed: 0 additions & 4 deletions
This file was deleted.

client/src/AuthContext.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
import { KeycloakInstance, KeycloakProfile } from 'keycloak-js';
3+
4+
export interface IAuthContext {
5+
keycloak?: KeycloakInstance | undefined
6+
profile?: KeycloakProfile | undefined
7+
}
8+
9+
export const AuthContext = React.createContext<IAuthContext>({ keycloak: undefined });

client/src/components/Header.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useContext, useState } from 'react';
22
import { IonHeader, IonToolbar, IonButtons, IonTitle, IonToast, IonButton, IonIcon } from '@ionic/react';
33
import { person, exit, arrowBack } from 'ionicons/icons';
4-
import { AppContext } from '../AppContext';
4+
import { AuthContext } from '../AuthContext';
55
import { logout } from '../auth/keycloakAuth';
66
import { useApolloOfflineClient } from 'react-offix-hooks';
77
import { Link } from 'react-router-dom';
@@ -11,7 +11,7 @@ export const Header : React.FC<{ title: string, backHref?: string, match: any, i
1111
const { url } = match;
1212

1313
const client = useApolloOfflineClient();
14-
const { keycloak } = useContext(AppContext);
14+
const { keycloak } = useContext(AuthContext);
1515
const [ showToast, setShowToast ] = useState(false);
1616

1717
const handleLogout = async () => {

0 commit comments

Comments
 (0)