Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Yudi committed May 23, 2024
1 parent bfa4d34 commit 18dfde7
Show file tree
Hide file tree
Showing 23 changed files with 531 additions and 184 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@ionic/angular": "^8.2.0",
"@ngneat/until-destroy": "^10.0.0",
"@pdfme/generator": "^4.0.1",
"@supabase/supabase-js": "^2.43.4",
"@sweetalert2/ngx-sweetalert2": "^12.3.0",
"buffer": "^6.0.3",
"bwip-js": "^4.3.2",
Expand Down
12 changes: 6 additions & 6 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,38 +79,38 @@ export const routes: Routes = [
path: 'login',
title: 'Entrar',
loadComponent: () => import('src/app/auth/login/login.page').then((m) => m.LoginPage),
...canActivate(redirectLoggedInToMenu),
canActivate: [redirectLoggedInToMenu],
},
{
path: 'register',
title: 'Registrar-se',
loadComponent: () => import('src/app/auth/register/register.page').then((m) => m.RegisterPage),
...canActivate(redirectUnauthorizedToLogin),
canActivate: [redirectUnauthorizedToLogin],
},
{
path: 'perfil',
title: 'Perfil',
data: { preload: true },
loadChildren: () => import('src/app/profile/profile-info.routes').then((m) => m.routes),
...canActivate(redirectUnauthorizedToLogin),
canActivate: [redirectUnauthorizedToLogin],
},
{
path: 'eventos/inscrever/:eventID',
title: 'Inscrição',
loadChildren: () => import('src/app/tabs/major-events-display/subscribe/subscribe.routes').then((m) => m.routes),
...canActivate(redirectUnauthorizedToLogin),
canActivate: [redirectUnauthorizedToLogin],
},
{
path: 'inscricoes',
title: 'Minhas participações',
loadChildren: () => import('src/app/profile/my-attendances/my-attendances.routes').then((m) => m.routes),
...canActivate(redirectUnauthorizedToLogin),
canActivate: [redirectUnauthorizedToLogin],
},
{
path: 'confirmar-presenca/:eventID',
title: 'Confirmar presença',
loadChildren: () => import('src/app/modals/confirm-attendance/confirm-attendance.routes').then((m) => m.routes),
...canActivate(redirectUnauthorizedToLogin),
canActivate: [redirectUnauthorizedToLogin],
},
{
path: 'certificado/verificar/:param',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,69 +1,5 @@
<div class="google-button-container margin-horizontal-auto">
@if (!environment.firebase.useEmulators) {
<!-- prettier-ignore -->
@if (!isLoaded()) {
<ion-button expand="block" fill="outline" disabled="" color="medium">
<ion-spinner name="dots" color="medium"></ion-spinner>
</ion-button>
}
<!-- prettier-ignore -->

<div #googleButton class="margin-horizontal-auto"></div>
} @else {
<svg
(click)="authService.GoogleAuth()"
width="210px"
height="40px"
viewBox="0 0 185 40"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="btn_google_dark_normal_ios">
<g id="button">
<g id="button-bg">
<g id="path-2-link" fill="#4285F4">
<rect id="path-2" x="0" y="0" width="200" height="40" rx="2"></rect>
</g>
</g>
</g>
<g id="button-bg-copy" transform="translate(1.000000, 1.000000)">
<g id="path-3-link" fill="#FFFFFF">
<rect id="path-3" x="0" y="0" width="38" height="38" rx="1"></rect>
</g>
</g>
<g id="logo_googleg_48dp" transform="translate(11.000000, 11.000000)">
<path
d="M17.64,9.20454545 C17.64,8.56636364 17.5827273,7.95272727 17.4763636,7.36363636 L9,7.36363636 L9,10.845 L13.8436364,10.845 C13.635,11.97 13.0009091,12.9231818 12.0477273,13.5613636 L12.0477273,15.8195455 L14.9563636,15.8195455 C16.6581818,14.2527273 17.64,11.9454545 17.64,9.20454545 L17.64,9.20454545 Z"
id="Shape"
fill="#4285F4"
fill-rule="nonzero"></path>
<path
d="M9,18 C11.43,18 13.4672727,17.1940909 14.9563636,15.8195455 L12.0477273,13.5613636 C11.2418182,14.1013636 10.2109091,14.4204545 9,14.4204545 C6.65590909,14.4204545 4.67181818,12.8372727 3.96409091,10.71 L0.957272727,10.71 L0.957272727,13.0418182 C2.43818182,15.9831818 5.48181818,18 9,18 L9,18 Z"
id="Shape"
fill="#34A853"
fill-rule="nonzero"></path>
<path
d="M3.96409091,10.71 C3.78409091,10.17 3.68181818,9.59318182 3.68181818,9 C3.68181818,8.40681818 3.78409091,7.83 3.96409091,7.29 L3.96409091,4.95818182 L0.957272727,4.95818182 C0.347727273,6.17318182 0,7.54772727 0,9 C0,10.4522727 0.347727273,11.8268182 0.957272727,13.0418182 L3.96409091,10.71 L3.96409091,10.71 Z"
id="Shape"
fill="#FBBC05"
fill-rule="nonzero"></path>
<path
d="M9,3.57954545 C10.3213636,3.57954545 11.5077273,4.03363636 12.4404545,4.92545455 L15.0218182,2.34409091 C13.4631818,0.891818182 11.4259091,0 9,0 C5.48181818,0 2.43818182,2.01681818 0.957272727,4.95818182 L3.96409091,7.29 C4.67181818,5.16272727 6.65590909,3.57954545 9,3.57954545 L9,3.57954545 Z"
id="Shape"
fill="#EA4335"
fill-rule="nonzero"></path>
<polygon id="Shape" points="0 0 18 0 18 18 0 18"></polygon>
</g>
<text
id="Entrar-com-o-Google"
font-family="Roboto-Medium, Roboto, system-ui, sans-serif"
font-size="14"
font-weight="400"
fill="#FFFFFF">
<tspan x="48.012207" y="25">Entrar com o Emulador</tspan>
</text>
</g>
</g>
</svg>
}
<div #googleButton class="margin-horizontal-auto"></div>
</div>
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild, WritableSignal, signal } from '@angular/core';
import { AuthService } from 'src/app/shared/services/auth.service';
import { CredentialResponse } from 'google-one-tap';
import { environment } from 'src/environments/environment';
import { IonSpinner, IonButton, IonSkeletonText } from '@ionic/angular/standalone';
import { CommonModule } from '@angular/common';
import { SupabaseAuthService } from 'src/app/shared/services/supabase-auth.service';
import { take } from 'rxjs';
import { ActivatedRoute, Router } from '@angular/router';

@Component({
selector: 'app-google-button',
Expand All @@ -19,34 +21,32 @@ export class GoogleButtonComponent implements AfterViewInit {

public isLoaded: WritableSignal<boolean> = signal(false);

constructor(public authService: AuthService) {}
constructor(public authService: SupabaseAuthService) {}

handleCredentialResponse(response: CredentialResponse) {
this.authService.GoogleOneTap(response);
this.authService.GoogleOneTapSignIn(response);
}

ngAfterViewInit() {
if (environment.production) {
//@ts-ignore
google.accounts.id.initialize({
// Ref: https://developers.google.com/identity/gsi/web/reference/js-reference#IdConfiguration
client_id: '169157391934-n61n94q5pdv1uloqnejher4v9fudd9g7.apps.googleusercontent.com',
callback: this.handleCredentialResponse.bind(this),
auto_select: true,
cancel_on_tap_outside: false,
});

//@ts-ignore
google.accounts.id.renderButton(this.googleButton.nativeElement, {
theme: 'outline',
size: 'large',
shape: 'rectangular',
type: 'standard',
logo_alignment: 'left',
width: 300,
});

this.isLoaded.set(true);
}
//@ts-ignore
google.accounts.id.initialize({
// Ref: https://developers.google.com/identity/gsi/web/reference/js-reference#IdConfiguration
client_id: '169157391934-vff3m8m24armjnojmn611iv3tbapbsrn.apps.googleusercontent.com',
callback: this.handleCredentialResponse.bind(this),
auto_select: true,
cancel_on_tap_outside: false,
});

this.isLoaded.set(true);

//@ts-ignore
google.accounts.id.renderButton(this.googleButton.nativeElement, {
theme: 'outline',
size: 'large',
shape: 'rectangular',
type: 'standard',
logo_alignment: 'left',
width: 300,
});
}
}
5 changes: 5 additions & 0 deletions src/app/development-tools/development-tools.routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Routes } from '@angular/router';

import { DevelopmentToolsPage } from './development-tools.page';
import { SupabaseToolsPage } from 'src/app/development-tools/supabase-tools/supabase-tools.page';

export const routes: Routes = [
{
Expand All @@ -11,4 +12,8 @@ export const routes: Routes = [
path: 'populate-db',
loadChildren: () => import('./populate-database/populate-database.routes').then((m) => m.routes),
},
{
path: 'supabase-tools',
loadComponent: () => import('./supabase-tools/supabase-tools.page').then((m) => m.SupabaseToolsPage),
},
];
48 changes: 48 additions & 0 deletions src/app/development-tools/supabase-tools/supabase-tools.page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<ion-header [translucent]="true">
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button defaultHref="menu"></ion-back-button>
</ion-buttons>
<ion-title>Supabase</ion-title>
</ion-toolbar>
</ion-header>

<ion-content [fullscreen]="true">
<ion-header collapse="condense">
<ion-toolbar>
<ion-title size="large">Subapase</ion-title>
</ion-toolbar>
</ion-header>

<ion-card>
<ion-item>
<ion-input label="E-mail" [(ngModel)]="emailInput"></ion-input>
</ion-item>
<ion-item>
<ion-input label="Senha" [(ngModel)]="passwordInput"></ion-input>
</ion-item>

<ion-button (click)="login()">
<ion-icon name="log-in-outline" slot="start"></ion-icon>
Entrar com e-mail
</ion-button>

<ion-button (click)="logout()">
<ion-icon name="log-out-outline" slot="start"></ion-icon>
Sair
</ion-button>
<div class="ion-padding">
<h1>isLoggedIn: {{supabaseAuth.isLoggedIn()}}</h1>
<h2>User data:</h2>
@if (supabaseAuth.$user | async; as user) {
<pre>{{ user | json }}</pre>
}
<h2>DB data:</h2>
@if (supabaseAuth.$profile | async; as profile) {
<pre>{{ profile | json }}</pre>
} @else {
<code>Empty or not logged in</code>
}
</div>
</ion-card>
</ion-content>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SupabaseToolsPage } from './supabase-tools.page';

describe('SupabaseToolsPage', () => {
let component: SupabaseToolsPage;
let fixture: ComponentFixture<SupabaseToolsPage>;

beforeEach(() => {
fixture = TestBed.createComponent(SupabaseToolsPage);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
55 changes: 55 additions & 0 deletions src/app/development-tools/supabase-tools/supabase-tools.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Component, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import {
IonContent,
IonHeader,
IonTitle,
IonToolbar,
IonButtons,
IonBackButton,
IonCard,
IonInput,
IonItem,
IonButton,
IonIcon,
} from '@ionic/angular/standalone';
import { SupabaseAuthService } from 'src/app/shared/services/supabase-auth.service';

@Component({
selector: 'app-supabase-tools',
templateUrl: './supabase-tools.page.html',
styleUrls: ['./supabase-tools.page.scss'],
standalone: true,
imports: [
IonIcon,
IonButton,
IonItem,
IonInput,
IonCard,
IonContent,
IonHeader,
IonTitle,
IonToolbar,
IonButtons,
IonBackButton,
CommonModule,
FormsModule,
],
})
export class SupabaseToolsPage implements OnInit {
emailInput: string = '';
passwordInput: string = '';

constructor(public supabaseAuth: SupabaseAuthService) {}

login(): void {
this.supabaseAuth.signIn(this.emailInput, this.passwordInput);
}

logout(): void {
this.supabaseAuth.signOut();
}

ngOnInit() {}
}
4 changes: 2 additions & 2 deletions src/app/profile/profile-info.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<ion-icon name="pencil" slot="start" aria-hidden="true"></ion-icon>
<ion-label>Informações pessoais</ion-label>
</ion-item>
@if (isUnesp && !alreadyLinked) {
<!-- @if (isUnesp && !alreadyLinked) {
<ion-item (click)="authService.GoogleLink()" button lines="none">
<ion-icon name="mail-outline" slot="start" aria-hidden="true"></ion-icon>
<ion-label>Vincular e-mail pessoal</ion-label>
Expand All @@ -39,7 +39,7 @@
<ion-icon name="mail-outline" slot="start" aria-hidden="true"></ion-icon>
<ion-label>E-mail pessoal já vinculado</ion-label>
</ion-item>
}
} -->
</ion-card>
</ion-col>

Expand Down
Loading

0 comments on commit 18dfde7

Please sign in to comment.