From 6e35f2fade1112f1533d356dd20183c8e5c6150d Mon Sep 17 00:00:00 2001 From: hallidayo <22655069+Hallidayo@users.noreply.github.com> Date: Thu, 15 Aug 2024 08:28:47 +0100 Subject: [PATCH] feat: ionic angular connect example (#27806) * ionic angular connect guide * connect icon constants --- .../Home/Connect/Connect.constants.ts | 14 ++ .../Home/Connect/ConnectionIcon.tsx | 7 +- .../ionicangular/supabasejs/content.tsx | 145 ++++++++++++++++++ 3 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 apps/studio/components/interfaces/Home/Connect/content/ionicangular/supabasejs/content.tsx diff --git a/apps/studio/components/interfaces/Home/Connect/Connect.constants.ts b/apps/studio/components/interfaces/Home/Connect/Connect.constants.ts index 50c4465350e..9d80f29444d 100644 --- a/apps/studio/components/interfaces/Home/Connect/Connect.constants.ts +++ b/apps/studio/components/interfaces/Home/Connect/Connect.constants.ts @@ -248,6 +248,20 @@ export const MOBILES: ConnectionType[] = [ }, ], }, + { + key: 'ionicangular', + label: 'Ionic Angular', + icon: 'ionic-angular', + guideLink: 'https://supabase.com/docs/guides/getting-started/tutorials/with-ionic-angular', + children: [ + { + key: 'supabasejs', + label: 'Supabase-js', + children: [], + icon: 'supabase', + }, + ], + }, ] export const ORMS: ConnectionType[] = [ diff --git a/apps/studio/components/interfaces/Home/Connect/ConnectionIcon.tsx b/apps/studio/components/interfaces/Home/Connect/ConnectionIcon.tsx index 4f13bec8806..a79acebc468 100644 --- a/apps/studio/components/interfaces/Home/Connect/ConnectionIcon.tsx +++ b/apps/studio/components/interfaces/Home/Connect/ConnectionIcon.tsx @@ -9,16 +9,19 @@ interface ConnectionIconProps { const ConnectionIcon = ({ connection }: ConnectionIconProps) => { const { resolvedTheme } = useTheme() + const imageFolder = ['ionic-angular'].includes(connection) ? 'icons/frameworks' : 'libraries' + const imageExtension = imageFolder === 'icons/frameworks' ? '' : '-icon' + return ( {`${connection} { + return ( + + + + + + + + + + + + {` +export const environment = { + supabaseUrl: '${projectKeys.apiUrl ?? 'your-project-url'}', + supabaseKey: '${projectKeys.anonKey ?? 'your-anon-key'}', +}; +`} + + + + + + {` +import { Injectable } from '@angular/core'; +import { createClient, SupabaseClient } from '@supabase/supabase-js'; +import { environment } from '../environments/environment'; + +@Injectable({ + providedIn: 'root', +}) +export class SupabaseService { + private supabase: SupabaseClient; + constructor() { + this.supabase = createClient( + environment.supabaseUrl, + environment.supabaseKey + ); + } + + getTodos() { + return this.supabase.from('todos').select('*'); + } +} +`} + + + + + + {` +import { Component, OnInit } from '@angular/core'; +import { SupabaseService } from './supabase.service'; + +@Component({ + selector: 'app-root', + templateUrl: 'app.component.html', + styleUrls: ['app.component.scss'], +}) +export class AppComponent implements OnInit { + todos: any[] = []; + + constructor(private supabaseService: SupabaseService) {} + + async ngOnInit() { + await this.loadTodos(); + } + + async loadTodos() { + const { data, error } = await this.supabaseService.getTodos(); + if (error) { + console.error('Error fetching todos:', error); + } else { + this.todos = data; + } + } +} +`} + + + + + + {` + + + Todo List + + + + + + + {{ todo.title }} + + + +`} + + + + + + {` +import { NgModule } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { BrowserModule } from '@angular/platform-browser'; +import { RouterModule } from '@angular/router'; + +import { IonicModule } from '@ionic/angular'; + +import { AppComponent } from './app.component'; +import { SupabaseService } from './supabase.service'; + +@NgModule({ + imports: [ + BrowserModule, + FormsModule, + RouterModule.forRoot([]), + IonicModule.forRoot({ mode: 'ios' }), + ], + declarations: [AppComponent], + providers: [SupabaseService], + bootstrap: [AppComponent], +}) +export class AppModule {} +`} + + + + ) +} + +export default ContentFile