eZeeBaseをインストールするには、 <head> タグ内にコードを埋め込んでください。
コード内に自分の実際のプロジェクトIDを忘れずに置き換えてください。
eZeeBaseのログイン機能を使うには、Firebase内に承認モージュルを有効にしてください。
新規登録とログインフォームを設定することができます。そうするには、<form>要素にカスタム属性を設定する必要があります。
名:
値は、フォーム種類によって異なります。下記はそれぞれの種類の設定について説明されています。
フォームを新規登録フォームにするためには、<form>要素にカスタム属性を追加してください。
値
HTML例:
フォームをログインフォームにするためには、<form>要素にカスタム属性を追加してください。
値:
HTML例:
フォームを更新フォームにするためには、<form>要素にカスタム属性を追加してください。
値:
HTML例:
Email(メールアドレス)とPassword(パスワード)は、フォームの必須入力欄となります。
それぞれの入力欄に対して正しくName属性を設定してください。
Email入力欄:
パスワード入力欄:
更新フォームでは入力欄を追加できます。Photo URL(プロフィール画像のURL)とName(名前)を設定できます。下記のName属性を設定してください。
Name入力欄:
Photo URL入力欄:
ウェブサイト上の要素にカスタム属性を追加することで、authモジュールのフィールドからユーザーデータを表示することができます。データはインナーテキストまたはhtml属性値として表示することができます。
データを表示するには、次のようなname属性を追加します
Name:
次に、どのようなデータを表示したいかに基づいて、値を追加します。
次のセクションを見て、正しい属性を探してください。
ユーザーデータを要素内のテキストとして表示するには、下記のようなカスタム属性を設定してください。
この設定によって、ユーザーのIDが要素内のテキストとして表示されます。
この設定によって、ユーザーのメールアドレスが要素内のテキストとして表示されます。
この設定によって、ユーザーの名前が要素内のテキストとして表示されます。
この設定によって、ユーザーの画像URLが要素内のテキストとして表示されます。
HTML例:
ユーザーデータを要素の属性として表示するには、下記のようなカスタム属性を設定してください。
この設定によって、ユーザーのIDが要素の「value」属性の値として表示されます。
この設定によって、ユーザーのメールアドレスが要素の「value」属性の値として表示されます。
この設定によって、ユーザーの名前が要素の「value」属性の値として表示されます。
この設定によって、ユーザーのIDが要素の「src」属性の値として表示されます。
HTML例:
You can hide and show elements on page based on wether user is authenticated or not. To do so, you need to add custom attributes with the following name to such elements.
ユーザーのログイン状況によって、特定の要素を表示・非表示することができます。そうするには、要素に対して下記のようなカスタム属性を設定してください。
名:
下記の値を設定すると、ログインしている場合は非表示で、ログインしていない場合は表示になります。
名:
HTM例:
下記の値を設定すると、ログインしている場合は表示で、ログインしていない場合は非表示になります。
値:
HTM例:
Firebaseの準備完了までにページを隠すロードスクリーンを設定することができます。
ロードスクリーンを追加するには、コンテンツを隠す要素を作成して、その要素に対して下記のようなカスタム属性を設定してください。
名:
値:
eZeeBaseは自動的にロードスクリーンを表示したり、非表示にしたりします。
HTML例:
eZeeBaseでFirebaseとMemberstackのログインを同期することができます。eZeeBaseは、自動的にサイト上のMemberstack会員を監視し、その会員と同じIDのユーザーをFirebase内で作成し、ログインさせます。
その設定を行うには、Firebaseプロジェクト内にクラウドファンクションを作成することが必要です。
まずは、IAM Service Account Credentials APIを有効化する必要があります。
次は、下記のパラメーターのファンクションを作ってください:
ファンクション名:
地域:
次はRuntime, Connections and Security settingsを開いてください:
下の方から新しい変数(VARIABLE)を追加してください:
下記のデータのVARIABLEを作ってください:
名:
値:
参考: list of Cloud Firestore locations.
次は、ファンクションの作成を続けます。
次のページでは、Index.jsの設定からEntry Pointを下記のデータに設定してください。
そして下記のコードを入力してください。
次は、package.jsonを開いて、下記のコードを入力してください。
次は、ファンクションを開いてRuntime, Connections and Security settingsの下から
Runtime Service account名が下記のような設定になっていることを確認してください。
この状態から変更は不要です。
次は、IAM & Adminをナビゲーションから開きます。
Runtime Service account名をアクセス権限のリストから探して、編集アイコンを押してください。
オープンしたページでService Account TokenのRoleを作成してください。
最後は、設定を保存して、デプロイしてください
Firebase Firestoreのデータベースを利用するには、eZeeBaseの設定からFirestoreモジュールを有効にしてください。
To display Firestore collection, first you need to add a Colleection Wrapper <div> and claim a collection in custom attribute of that <div>:
Firestoreコレクションを表示するには、まずはCollection Wrapperとなる<div>要素が必要です。それに対してカスタム属性を設定します。
名:
コレクションを表示する方法はいくつかあります。
Set attribute's value to a name of your Firestore collection (e.g. "projects") to display all documents from that collection.
コレクション全体のドキュメントを表示するには、カスタム属性の値をFirestoreコレクション名に設定してください(例:「projects」)
HTML例:
カスタム属性の値をFirestoreコレクションと表示するドキュメントのIDの組み合わせにしてください(例:「projects/{docId}」)
HTML例:
カスタム属性の値をFirestoreコレクションと表示したいユーザーのuidの組み合わせにしてください(例:「うusers/{uid}」)
HTML例:
カスタム属性の値を表示したいFirestoreコレクションとドキュメントIDをもつURLパラメーターの組み合わせにしてください(例:「projects/{project_id}」)
HTML例:
To set real time listening to changes in collection, add the following custom attribute to Collection Wrapper <div>:
Name:
Value:
HTML example:
Inside of your Collection Wrapper you can create elements, which will be shown when collection has documents to show or when it is empty.
Snapshot element is shown when collection has elements to show at current filters and conditions. Snapshot nests documents inside.
To set Snapshot, add the following custom attribute to an element inside Collection Wrapper:
Name:
Value:
HTML example:
No-snapshot element is shown when collection has no elements to show at current filters and conditions. It is an empty state for your collection list.
To set No-snapshot, add the following custom attribute to an element inside Collection Wrapper:
Name:
Value:
HTML example:
Documents are shown inside of the Snapshot. To show documents, you need to create an element inside snapshot, which will serve as a template for all documents in this collection.
To setup that, add the following custom attribute to an element inside of the Snapshot.
Name:
Value:
HTML example:
You can set a filter to your Collection list.
To do that, add the following custom attribute to Collection Wrapper:
Name:
Value for the attribute should include your filter condition written in Firestore syntaxis (e.g. [['price','>',500]]).
HTML example:
You can set an order for your collection list. To do that, add the following custom attribute to your Collection Wrapper:
Name:
To set order by one field from document collection, set the attribute value to the field name in specific fromat (e.g. [['price']]).
HTML example:
To set a descending order, add that parameter in attribute's value (e.g. [['price', 'desc']]).
HTML example:
To set an order by two fields, write a condition with multiple parameters (e.g. [['price', 'asc'],['discount','desc']]).
HTML example:
Inside of a document you can display document's fields data as an inner text or HTML attributes ("src", "value", "href" etc).
To do that, set custom attributes to elements inside of the document template.
Add an attribute with the following Name:
Name:
To display data as an inner text of the element, set value to field name (e.g. "projects").
HTML example:
To display data as a HTML attribute ("src", "value", "href" etc), set value to field name and attribute name divided by "|" symbol (e.g. "picture_url|src").
HTML example:
You can add variables such as document ID ({docId}) inside of a value (e.g. "https://www.shop.com/products/{docId}|href").
HTML example:
To display data from map field, add the map field name before actual field name and divide them with "." (e.g. "name.first").
HTML example:
To display data from array field, specify array item number in attribute value (e.g. "photos[0]|src").
HTML example:
To display arrays inside of a document, first you will need to create an Array Wrapper - an element with the following custom attribute:
Name:
Set attribute's value to the name of array field in your document (e.g. "items").
Inside of the Array Wrapper, create a template item for array items by adding the following custom attribute:
Name:
Set attribute's value to the name of array item in your document and the item index (e.g. "item, idx"). This element will be copied as a template for all items in the array.
HTML example:
You can display data from array item by setting the following attribute to elements inside of the array item template:
Name:
Set attribute's value to the name of a field inside of the array item (e.g. "item").
HTML example:
In case your array object has a map structure, you can display it's data setting attribute value to the name of the map + "." + field name (e.g. "object.name").
HTML example:
Here are several important things about working with arrays within document or create from:
You can only create array items within a document create or update form.
Add the following custom attribute to the button inside of the array warapper:
Name:
Value:
HTML example:
To delete array item, you can add a delete button or link inside of the array item. It can only be done withing a document update or create form. Add the following custom attribute to this button/link:
Name:
Value:
HTML example:
You can setup forms inside of Collection Wrapper to create or update collection documents. To do that, add a from with the following custom attribute name:
Name:
Then set attribute's value as it is explained in the following paragraphs
For Create form, add the following custom attribute value to the form
Value:
Create form should be outside of the Snapshop.
HTML example:
For Update form, add the following custom attribute value to the form:
Value:
Create form should be inside of the document element.
HTML example:
To delete document, add a delete button or link inside of the document and set the following attribute to that button or link.
Name:
Value:
HTML example:
You can create "before" and "after" handlers for your form, which can be used to call functions.
To create "before" handler, add the following attribute to the form:
Name:
Set attribute's value to the name of your handler (e.g. "addCreatedDate").
To create "after" handler, add the following attribute to the form:
Name:
Set attribute's value to the name of your handler (e.g. "success").
HTML example: