Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

⛔️ DEPRECATED, Angular module for using Sheetbase in Angular/Ionic projects.

Notifications You must be signed in to change notification settings

316company/sheetbase-angular

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⛔️ DEPRECATED

Please use https://github.com/sheetbase/angular instead.

Sheetbase Angular

Angular module for using Sheetbase in Angular/Ionic projects.

Install

npm install --save sheetbase-angular

Usage

Import SheetbaseModule to your app.module.ts.

import { SheetbaseModule } from 'sheetbase-angular';
import { SHEETBASE_CONFIG } from '../configs/sheetbase.config';

imports: [
	SheetbaseModule.forRoot(SHEETBASE_CONFIG)
]

Inject services into your page.

import { DataService } from 'sheetbase-angular';

constructor(
	private sheetbaseData: DataService
) {}

ngOnInit() {
	this.sheetbaseData.get('posts')
	.subscribe(posts => {
		console.log('My posts: ', posts);
	});
}

Config

There are 2 ways to config the module.

Option 1: Data only

Get data directly from Google API.

Key Type Description
googleApiKey string Google API Key
databaseId string ID of database spreadsheet

Option 2: Full options

Using backend to get data and other functions.

Key Type Description
apiKey string Backend API Key
backendUrl string Backend URL

Other configs

Key Type Description
modifiers object Custom modifying data

API

DataService

  • get(collection: string, doc: string = null, query: IDataQuery = null)

Get data from database.

this.sheetbaseData.get('posts', 'post-1')
.subscribe(post1 => {
	console.log(post1);
});

ApiService

  • GET(endpoint: string = null, params: any = {})

Request GET method.

this.sheetbaseApi.GET('/data', {
	apiKey: 'my_api_key',
	table: 'posts'
})
.subscribe(posts => {
	console.log(posts);
});
  • POST(endpoint: string = null, params: any = {}, body: any = {})

Request POST method.

this.sheetbaseApi.POST('/user/create', {}, {
	apiKey: 'my_api_key',
	email: '[email protected]',
	password: 'password'
})
.subscribe(profile => {
	console.log(profile);
});

UserService

  • getToken()

Get user id token.

this.sheetbaseUser.getToken()
.subscribe(token => {
	console.log(token);
});
  • getUser()

Get user data.

this.sheetbaseUser.getUser()
.subscribe(profile => {
	console.log(profile);
});
  • onAuthStateChanged()

Event of user authentication status.

this.sheetbaseUser.onAuthStateChanged()
.subscribe(profile => {
	console.log(profile);
});
  • createUserWithEmailAndPassword(email: string, password: string)

Register new user by email and password.

this.sheetbaseUser.createUserWithEmailAndPassword(
	'[email protected]',
	'password'
)
.subscribe(profile => {
	console.log(profile);
});
  • signInWithEmailAndPassword(email: string, password: string)

Log user in by using email and password.

this.sheetbaseUser.signInWithEmailAndPassword(
	'[email protected]',
	'password'
)
.subscribe(profile => {
	console.log(profile);
});
  • signOut()

Log user out.

this.sheetbaseUser.signOut()
.subscribe(() => {
	console.log('You are out!');
});
  • updateProfile(profile: any)

Update user profile.

this.sheetbaseUser.updateProfile({
	displayName: 'My Name',
	tel: '+1 2345 6789'
})
.subscribe(profile => {
	console.log(profile);
});
  • sendPasswordResetEmail(email: string)

Ask for password reset email.

this.sheetbaseUser.sendPasswordResetEmail('[email protected]')
.subscribe(() => {
	console.log('Email sent!');
});
  • confirmPasswordReset(oobCode: string, password: string)

Change user password.

this.sheetbaseUser.confirmPasswordReset(
	'my_oob_code',
	'new-password'
)
.subscribe(() => {
	console.log('Cool! Please login with your new password!');
});
  • applyActionCode(oobCode: string)

Verify out-of-band code.

this.sheetbaseUser.applyActionCode('my_oob_code')
.subscribe(() => {
	console.log('Valid!');
});

FileService

  • get(fileId: string)

Get file information by id.

this.sheetbaseFile.get('file_id')
.subscribe(fileInfo => {
	console.log(fileInfo);
});
  • upload(appFile: IAppFile, customFolder: string = null)

Upload a file.

this.sheetbaseFile.upload({
	name: 'file.txt',
	mimeType: 'text/plain',
	base64String: 'Ab73Ajdwk...'
})
.subscribe(fileInfo => {
	console.log(fileInfo);
});
  • load(file: File)

Load local file.

this.sheetbaseFile.load(localFile)
.subscribe(localFileInfo => {
	console.log(localFileInfo);
});

Homepage

Please visit https://sheetbase.net/ for more.

Support us

About

⛔️ DEPRECATED, Angular module for using Sheetbase in Angular/Ionic projects.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published