saasufy-components 3.21.0 → 3.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -56,6 +56,7 @@ You can apply custom CSS/styling to elements that are rendered inside a viewport
|
|
|
56
56
|
|
|
57
57
|
To use a component, you just need to include the relevant `<script>` tag into the `<head>` tag of your `.html` file.
|
|
58
58
|
You can simply copy-paste the script tag provided under the `Import` section of the relevant component's documentation.
|
|
59
|
+
Make sure that you read the documentation carefully; especially the list of available attributes and acceptable values for each component.
|
|
59
60
|
|
|
60
61
|
You should only add the script tags for the components which your page uses to avoid wasting bandwidth and unnecessarily delaying page load for your users.
|
|
61
62
|
You should always include the `socket.js` script and create a top-level `socket-provider` component if you intend to use components which depend on data from Saasufy.
|
|
@@ -86,6 +87,27 @@ The following utility functions can be used anywhere inside template `{{expressi
|
|
|
86
87
|
- Format UNIX timestamp as a human-readable date: `{{date(Product.updatedAt)}}`
|
|
87
88
|
- Given an array of objects, extract the values from the specified field and join them together into a single comma-separated string: `{{joinFields(Product, 'name')}}`
|
|
88
89
|
|
|
90
|
+
### Special fields
|
|
91
|
+
|
|
92
|
+
Saasufy supports a number of special metadata fields which are automatically created and updated on each model record.
|
|
93
|
+
Those fields are hidden by default but may be exposed via the Saasufy control panel and used within your application.
|
|
94
|
+
The fields are:
|
|
95
|
+
|
|
96
|
+
- `id`: String, UUID v4 format; the ID of the resource.
|
|
97
|
+
- `createdBy`: String, UUID v4 format; if the socket was authenticated, this will hold the ID of the account which created the resource.
|
|
98
|
+
- `updatedBy`: String, UUID v4 format; if the socket was authenticated, this will hold the ID of the account which last modified the resource.
|
|
99
|
+
- `createdByIp`: String, IP address format; the IP address of the client which last modified the resource.
|
|
100
|
+
- `createdAt`: Number, UNIX timestamp format; the timestamp for when the resource was created.
|
|
101
|
+
- `updatedAt`: Number, UNIX timestamp format; the timestamp for when the resource was last modified.
|
|
102
|
+
|
|
103
|
+
All of the above fields except for the `id` field are hidden by default and must be exposed via the Saasufy control panel in order to be accessible within your front end application.
|
|
104
|
+
To expose a special field on a specific model, you just need to create a field with the same name under the `fields` section of the relevant model.
|
|
105
|
+
You will need to make sure that the type you specify (`String` or `Number`) matches the type of the special field described above.
|
|
106
|
+
You will need to deploy your Saasufy service from the dashboard for the changes to take effect.
|
|
107
|
+
|
|
108
|
+
The `id` field in Saasufy is extra special; you can optionally specify it when you create a new resource, however, if it is not specified, Saasufy will create one for you.
|
|
109
|
+
Saasufy offers utility functions for creating IDs (random and deterministic). See the previous `Utility functions` section.
|
|
110
|
+
|
|
89
111
|
### File hosting
|
|
90
112
|
|
|
91
113
|
Saasufy provides basic HTTP/HTTPS file hosting functionality with support for client-side caching (with `ETag`).
|
|
@@ -166,7 +188,27 @@ Note that the `app-router` can contain any number of pages/routes so the `slot="
|
|
|
166
188
|
</app-router>
|
|
167
189
|
```
|
|
168
190
|
|
|
169
|
-
|
|
191
|
+
This example shows how to redirect based on the user's authentication status:
|
|
192
|
+
|
|
193
|
+
```html
|
|
194
|
+
<app-router default-page="/home">
|
|
195
|
+
<template slot="page" route-path="/log-in" auth-redirect="/home" hard-redirect>
|
|
196
|
+
<log-in-form
|
|
197
|
+
hostname="sas.saasufy.com"
|
|
198
|
+
port="443"
|
|
199
|
+
network-symbol="sas"
|
|
200
|
+
chain-module-name="sas_chain"
|
|
201
|
+
secure="true"
|
|
202
|
+
></log-in-form>
|
|
203
|
+
</template>
|
|
204
|
+
<template slot="page" route-path="/home" no-auth-redirect="/log-in">
|
|
205
|
+
<div>This is the home page</div>
|
|
206
|
+
</template>
|
|
207
|
+
<div slot="viewport"></div>
|
|
208
|
+
</app-router>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Note that the app router path is based on `location.hash` so the path section in your browser's address bar needs to start with the `#` character.
|
|
170
212
|
So for example, if your `index.html` file is served up from the URL `http://mywebsite.com`, then, to activate the `/products` route as in the example above, you would need to type the URL `http://mywebsite.com#/products`.
|
|
171
213
|
|
|
172
214
|
**Attributes of app-router**
|
|
@@ -180,9 +222,9 @@ So for example, if your `index.html` file is served up from the URL `http://mywe
|
|
|
180
222
|
- `route-path`: The path of the page. Supports custom URL parameters in the format `/org/:orgId/user/:userId`.
|
|
181
223
|
- `partial-route`: An optional attribute which, if specified, will allow the `route-path` to be matched partially from the start. This can be used to ignore the ending of a path which is not relevant to the page in order to avoid unnecessary re-renders.
|
|
182
224
|
- `redirect`: An optional path/route which this page should redirect to. Note that the content of this page will not be shown so it should always be empty.
|
|
183
|
-
- `auth-redirect`: An optional path/route
|
|
184
|
-
- `
|
|
185
|
-
- `hard-redirect`: An optional, additional attribute which can be specified alongside a `redirect`, `auth-redirect` or `
|
|
225
|
+
- `no-auth-redirect`: An optional alternative path/route to redirect to if the user lands on this page but they are not authenticated. If the user is authenticated, then the content of the template will be displayed as normal.
|
|
226
|
+
- `auth-redirect`: An optional alternative path/route to redirect to if the user lands on this page but they are already authenticated. If the user is not authenticated, then the content of the template will be displayed as normal.
|
|
227
|
+
- `hard-redirect`: An optional, additional attribute which can be specified alongside a `redirect`, `no-auth-redirect` or `auth-redirect` attribute to ensure that any redirect will change the URL in the address bar. Redirects are `soft` redirects by default; this means that they redirect the user to the target page but keep the current URL path unchanged.
|
|
186
228
|
|
|
187
229
|
### socket-provider
|
|
188
230
|
|