saasufy-components 3.16.0 → 3.16.1
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 +41 -32
- package/collection-browser.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,41 +54,14 @@ You can apply custom CSS/styling to elements that are rendered inside a viewport
|
|
|
54
54
|
|
|
55
55
|
### Components
|
|
56
56
|
|
|
57
|
-
To use
|
|
58
|
-
|
|
59
|
-
```html
|
|
60
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/socket.js" type="module" defer></script>
|
|
61
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/app-router.js" type="module" defer></script>
|
|
62
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/collection-browser.js" type="module" defer></script>
|
|
63
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/collection-adder.js" type="module" defer></script>
|
|
64
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/collection-deleter.js" type="module" defer></script>
|
|
65
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/collection-reducer.js" type="module" defer></script>
|
|
66
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/model-input.js" type="module" defer></script>
|
|
67
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/model-text.js" type="module" defer></script>
|
|
68
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/model-viewer.js" type="module" defer></script>
|
|
69
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/input-provider.js" type="module" defer></script>
|
|
70
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/input-combiner.js" type="module" defer></script>
|
|
71
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/input-transformer.js" type="module" defer></script>
|
|
72
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/log-in-form.js" type="module" defer></script>
|
|
73
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/log-out.js" type="module" defer></script>
|
|
74
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/oauth-link.js" type="module" defer></script>
|
|
75
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/oauth-handler.js" type="module" defer></script>
|
|
76
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/render-group.js" type="module" defer></script>
|
|
77
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/if-group.js" type="module" defer></script>
|
|
78
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/switch-group.js" type="module" defer></script>
|
|
79
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/collection-adder-group.js" type="module" defer></script>
|
|
80
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/confirm-modal.js" type="module" defer></script>
|
|
81
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/overlay-modal.js" type="module" defer></script>
|
|
82
|
-
<script src="https://saasufy.com/node_modules/saasufy-components/download-link.js" type="module" defer></script>
|
|
83
|
-
```
|
|
57
|
+
To use a component, you just need to include the relevant `<script>` tag into the `<head>` tag of your `.html` file.
|
|
58
|
+
You can simply copy-paste the script tag provided under the `Import` section of the relevant component's documentation.
|
|
84
59
|
|
|
85
60
|
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.
|
|
86
|
-
|
|
87
|
-
The only exception is the `socket-provider` component which is located inside the `socket.js` file - This is because that file exposes multiple components which are used behind the scenes by other components.
|
|
88
|
-
You should always include the `socket.js` script as shown above whenever you use components which depend on data from Saasufy.
|
|
61
|
+
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.
|
|
89
62
|
|
|
90
|
-
Linking the scripts directly from `saasufy.com`
|
|
91
|
-
An alternative approach is to download Saasufy components using `npm install saasufy-components` and
|
|
63
|
+
Linking the scripts directly from `saasufy.com` is the simplest way to get started as it doesn't require loading anything or hosting the scripts yourself.
|
|
64
|
+
An alternative approach is to download Saasufy components using `npm install saasufy-components` and self-host them.
|
|
92
65
|
|
|
93
66
|
### Styling
|
|
94
67
|
|
|
@@ -113,6 +86,42 @@ The following utility functions can be used anywhere inside template `{{expressi
|
|
|
113
86
|
- Format UNIX timestamp as a human-readable date: `{{date(Product.updatedAt)}}`
|
|
114
87
|
- 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')}}`
|
|
115
88
|
|
|
89
|
+
### File hosting
|
|
90
|
+
|
|
91
|
+
Saasufy provides basic HTTP/HTTPS file hosting functionality with support for client-side caching (with `ETag`).
|
|
92
|
+
This is especially useful for hosting images.
|
|
93
|
+
|
|
94
|
+
To upload files to Saasufy, you first need to create a field of type `string` on a model of your choice.
|
|
95
|
+
You will then need to check/enable the `blob` constraint to tell Saasufy to treat this field as a base64 file.
|
|
96
|
+
|
|
97
|
+
After you've deployed your schema from the Saasufy dashboard, you will be able to manually add new records into your model via its `data` section.
|
|
98
|
+
Saasufy will show you a file picker next to the relevant field name which you can use to upload a file/image to Saasufy.
|
|
99
|
+
|
|
100
|
+
After adding a record to Saasufy which holds a file in one of its fields, that file can be accessed over HTTP/HTTPS via your Saasufy service's `/files` HTTP endpoint.
|
|
101
|
+
The format of the URL to link directly to a specific file/image is:
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
https://saasufy.com/:serviceId/files/:modelName/:modelId/:fieldName
|
|
105
|
+
```
|
|
106
|
+
For example, if the URL for your Saasufy service (which you get after deploying your service) is `wss://saasufy.com/sid7999/socketcluster/`
|
|
107
|
+
and your file is stored inside an `Image` model with ID `58f2051c-14bc-4518-8816-ff387cfdd57e` inside a `data` field, you will be able to link to your image directly using this URL:
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
https://saasufy.com/sid7999/files/Image/58f2051c-14bc-4518-8816-ff387cfdd57e/data
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
You can use it to embed images into your application using the `<img>` tag like this:
|
|
114
|
+
|
|
115
|
+
```html
|
|
116
|
+
<img src="https://saasufy.com/sid7999/files/Image/58f2051c-14bc-4518-8816-ff387cfdd57e/data" alt="My image" />
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Saasufy enforces access controls for HTTP in the same way as it does for its WebSocket protocol.
|
|
120
|
+
It's possible to block or restrict access to specific files stored on specific fields via the `Access` page under the relevant model.
|
|
121
|
+
|
|
122
|
+
If your model field's access is set to `restrict`, only authenticated users with matching permissions will be able to view/download the image/file.
|
|
123
|
+
In this case, you will need to add your user's JWT token to a cookie with the name `socketcluster.saasufyService.authToken` and it will be passed along with the request.
|
|
124
|
+
|
|
116
125
|
## Components
|
|
117
126
|
|
|
118
127
|
### app-router
|
package/collection-browser.js
CHANGED
|
@@ -247,7 +247,7 @@ class CollectionBrowser extends SocketConsumer {
|
|
|
247
247
|
render() {
|
|
248
248
|
let collectionType = this.getAttribute('collection-type');
|
|
249
249
|
let collectionFields = this.getAttribute('collection-fields') || '';
|
|
250
|
-
let collectionView = this.getAttribute('collection-view');
|
|
250
|
+
let collectionView = this.getAttribute('collection-view') || 'defaultView';
|
|
251
251
|
let collectionPageSize = this.getAttribute('collection-page-size');
|
|
252
252
|
let collectionViewParams = this.getAttribute('collection-view-params') || '';
|
|
253
253
|
let collectionPageOffset = this.getAttribute('collection-page-offset');
|