0.0.11 • Published 6 years ago

sheetbase-angular v0.0.11

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

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.

KeyTypeDescription
googleApiKeystringGoogle API Key
databaseIdstringID of database spreadsheet

Option 2: Full options

Using backend to get data and other functions.

KeyTypeDescription
apiKeystringBackend API Key
backendUrlstringBackend URL

Other configs

KeyTypeDescription
modifiersobjectCustom 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@email.email',
	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@email.email',
	'password'
)
.subscribe(profile => {
	console.log(profile);
});
  • signInWithEmailAndPassword(email: string, password: string)

Log user in by using email and password.

this.sheetbaseUser.signInWithEmailAndPassword(
	'email@email.email',
	'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@email.email')
.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

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago