wacom 14.2.0 → 14.2.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 +465 -465
- package/esm2020/lib/components/alert/alert.component.mjs +5 -5
- package/esm2020/lib/components/alert/wrapper/wrapper.component.mjs +5 -5
- package/esm2020/lib/components/files/files.component.mjs +5 -5
- package/esm2020/lib/components/loader/loader.component.mjs +5 -5
- package/esm2020/lib/components/modal/modal.component.mjs +5 -5
- package/esm2020/lib/directives/click-outside.directive.mjs +5 -5
- package/esm2020/lib/guard/meta.guard.mjs +4 -4
- package/esm2020/lib/interfaces/alert.interface.mjs +1 -1
- package/esm2020/lib/interfaces/config.mjs +1 -1
- package/esm2020/lib/interfaces/modal.interface.mjs +1 -1
- package/esm2020/lib/pipes/arr.pipe.mjs +4 -4
- package/esm2020/lib/pipes/mongodate.pipe.mjs +4 -4
- package/esm2020/lib/pipes/pagination.pipe.mjs +4 -4
- package/esm2020/lib/pipes/safe.pipe.mjs +4 -4
- package/esm2020/lib/pipes/search.pipe.mjs +4 -4
- package/esm2020/lib/pipes/splice.pipe.mjs +4 -4
- package/esm2020/lib/services/alert.service.mjs +4 -4
- package/esm2020/lib/services/base.service.mjs +4 -4
- package/esm2020/lib/services/core.service.mjs +4 -4
- package/esm2020/lib/services/crud.service.mjs +4 -4
- package/esm2020/lib/services/dom.service.mjs +4 -4
- package/esm2020/lib/services/file.service.mjs +4 -4
- package/esm2020/lib/services/hash.service.mjs +4 -4
- package/esm2020/lib/services/http.service.mjs +49 -22
- package/esm2020/lib/services/loader.service.mjs +4 -4
- package/esm2020/lib/services/meta.service.mjs +7 -7
- package/esm2020/lib/services/modal.service.mjs +4 -4
- package/esm2020/lib/services/mongo.service.mjs +4 -4
- package/esm2020/lib/services/render.service.mjs +4 -4
- package/esm2020/lib/services/socket.service.mjs +4 -4
- package/esm2020/lib/services/store.service.mjs +4 -4
- package/esm2020/lib/services/time.service.mjs +4 -4
- package/esm2020/lib/services/ui.service.mjs +4 -4
- package/esm2020/lib/wacom.module.mjs +5 -5
- package/esm2020/public-api.mjs +1 -1
- package/fesm2015/wacom.mjs +148 -121
- package/fesm2015/wacom.mjs.map +1 -1
- package/fesm2020/wacom.mjs +148 -121
- package/fesm2020/wacom.mjs.map +1 -1
- package/package.json +1 -1
- package/src/lib/components/alert/README.md +34 -34
- package/src/lib/components/loader/README.md +34 -34
package/README.md
CHANGED
|
@@ -1,465 +1,465 @@
|
|
|
1
|
-
# Angular (ngx) common
|
|
2
|
-
Module which has common services and components which can be used on all projects.
|
|
3
|
-
|
|
4
|
-
## Getting Started
|
|
5
|
-
|
|
6
|
-
### License
|
|
7
|
-
[MIT](LICENSE)
|
|
8
|
-
|
|
9
|
-
### Instalation
|
|
10
|
-
```bash
|
|
11
|
-
$ npm i --save wacom
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
### Services
|
|
15
|
-
| Name | Description |
|
|
16
|
-
| ------- |:-----:|
|
|
17
|
-
| [**`Core`**](https://www.npmjs.com/package/wacom#core-service) | Common supportive function which can be used in any service |
|
|
18
|
-
| [**`Http`**](https://www.npmjs.com/package/wacom#http-service) | Http layer for HttpClient |
|
|
19
|
-
| [**`Store`**](https://www.npmjs.com/package/wacom#store-service) | Service will is responsible for keeping information on the device |
|
|
20
|
-
| [**`Hash`**](https://www.npmjs.com/package/wacom#hash-service) | Hash management for easily use, storage which stay in url |
|
|
21
|
-
| [**`Render`**](https://www.npmjs.com/package/wacom#render-service) | Make not automated render management well structured |
|
|
22
|
-
| [**`Meta`**](https://www.npmjs.com/package/wacom#meta-service) | Website meta tags management within router |
|
|
23
|
-
| [**`Alert`**](https://www.npmjs.com/package/wacom#alert-service) | Alerts management |
|
|
24
|
-
| [**`Modal`**](https://www.npmjs.com/package/wacom#modal-service) | Modals management |
|
|
25
|
-
| [**`UI`**](https://www.npmjs.com/package/wacom#ui-service) | Supportive UI/UX service |
|
|
26
|
-
|
|
27
|
-
## Mongo Service
|
|
28
|
-
Mongo Service is an suportive service for combining angular 6 client with waw CRUD back-end. Which means that you have to use [waw Framework](https://www.npmjs.com/package/waw) or you have to made your back-end routes in a way of waw crud. Example of importing mongo service:
|
|
29
|
-
```javascript
|
|
30
|
-
import { MongoService } from 'wacom';
|
|
31
|
-
constructor(private mongo: MongoService){};
|
|
32
|
-
```
|
|
33
|
-
### create `function`
|
|
34
|
-
connecting with waw CRUD create. As parameters accepting name of mongo collection, object with values for document and optionally callback function which will return the document. Document will be filled inside read callbacks. Example:
|
|
35
|
-
```javascript
|
|
36
|
-
mongo.create('colName', {
|
|
37
|
-
name: 'docName'
|
|
38
|
-
}, created => {
|
|
39
|
-
console.log('document has been created');
|
|
40
|
-
});
|
|
41
|
-
```
|
|
42
|
-
### read `function`
|
|
43
|
-
connecting with waw CRUD read. As parameters accepting name of mongo collection, optionally options, optionally callback which will return all documents in array as first parameter and in object with doc._id placeholder for doc as second parameter. Function returning directing array which will host the documents. Example:
|
|
44
|
-
```javascript
|
|
45
|
-
mongo.get('colName',{
|
|
46
|
-
replace: { // will create or modify selected fields on documents
|
|
47
|
-
name: function(val, cb, doc){
|
|
48
|
-
cb(val+'_modified')
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
name: 'me', // customized query
|
|
52
|
-
populate: [{ // will fill id with document
|
|
53
|
-
field: 'author',
|
|
54
|
-
part: 'user'
|
|
55
|
-
}],
|
|
56
|
-
groups: 'city name' || ['city', 'name'] || { // will make objects with arrays by selected query
|
|
57
|
-
first_name: {
|
|
58
|
-
field: function(doc, cb){
|
|
59
|
-
if(doc.name.split(' ').length>1) cb(doc.name.split(' ')[1]);
|
|
60
|
-
retun doc.name.split(' ')[0];
|
|
61
|
-
},
|
|
62
|
-
allow: function(doc){
|
|
63
|
-
return !!doc.name;
|
|
64
|
-
},
|
|
65
|
-
ignore: function(){
|
|
66
|
-
return false;
|
|
67
|
-
},
|
|
68
|
-
sort: function(){
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
query: { // will make arrays by selected query
|
|
74
|
-
male: function(doc){
|
|
75
|
-
return doc.gender;
|
|
76
|
-
},
|
|
77
|
-
female: {
|
|
78
|
-
allow: function(doc){
|
|
79
|
-
return !doc.gender;
|
|
80
|
-
},
|
|
81
|
-
ignore: function(){
|
|
82
|
-
return typeof doc.gender != 'boolean';
|
|
83
|
-
},
|
|
84
|
-
sort: function(a, b){
|
|
85
|
-
if(a.order > b.order) return -1;
|
|
86
|
-
return 1;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
fields: 'url' // will fill obj with docs by url field
|
|
91
|
-
}, (arr, obj, name, resp) => {
|
|
92
|
-
/*
|
|
93
|
-
* arr will be array with total docs from that part
|
|
94
|
-
* obj will be object with total docs from that part binded by _id
|
|
95
|
-
* groups will be saved into obj in the way: obj.name['Denys'] or obj.city['Kiev']
|
|
96
|
-
* name is the name of current pull from server
|
|
97
|
-
* resp is the array of responsinse with documents queried
|
|
98
|
-
*/
|
|
99
|
-
})
|
|
100
|
-
```
|
|
101
|
-
#### replace `options`
|
|
102
|
-
work as filler of each doc for cases when we can calculate things to use in website. Good example can be currencies which change each moment, we have product in one currency and we want to show it in different currrencies. Other good example can be date fields, which is saved as string and we need them in `new Date()` format.
|
|
103
|
-
#### populate `options`
|
|
104
|
-
works in the same way as populate of mongodb but in the client side. This works great when you need documents inside other documents and put on them sorting or other things.
|
|
105
|
-
#### groups `options`
|
|
106
|
-
makings arrays which show different documents inside specific placeholders. As example we can have list of users in specific town or country, so we don't have to create pipes for that.
|
|
107
|
-
#### next `options`
|
|
108
|
-
works as level of pulling different documents from the server. This is mostly made for performance, so user can have the info he needs directly.
|
|
109
|
-
### update `function`
|
|
110
|
-
connecting with waw CRUD updateAll. As parameters accepting name of mongo collection, document object, optionally options and optionally callback function which will return the document. Example:
|
|
111
|
-
```javascript
|
|
112
|
-
mongo.updateAll('colName', {
|
|
113
|
-
name: doc.name,
|
|
114
|
-
_id: doc._id
|
|
115
|
-
}, {
|
|
116
|
-
fields: 'name'
|
|
117
|
-
}, () => {
|
|
118
|
-
console.log('document is updated');
|
|
119
|
-
});
|
|
120
|
-
```
|
|
121
|
-
### unique `function`
|
|
122
|
-
connecting with waw CRUD updateUnique. As parameters accepting name of mongo collection, object with document _id and field value, optionally options and optionally callback function which will return if field has been updated. Example:
|
|
123
|
-
```javascript
|
|
124
|
-
mongo.unique('colName', {
|
|
125
|
-
name: doc.name,
|
|
126
|
-
_id: doc._id
|
|
127
|
-
}, {
|
|
128
|
-
name: 'name'
|
|
129
|
-
}, (resp) => {
|
|
130
|
-
if(resp){
|
|
131
|
-
console.log('field is updated');
|
|
132
|
-
}else {
|
|
133
|
-
console.log('field is not updated');
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
```
|
|
137
|
-
### delete `function`
|
|
138
|
-
connecting with waw CRUD delete. As parameters accepting name of mongo collection, document object, optionally options and optionally callback function which will return the document. Example:
|
|
139
|
-
```javascript
|
|
140
|
-
mongo.delate('colName',{
|
|
141
|
-
_id: doc._id
|
|
142
|
-
}, {
|
|
143
|
-
name: 'admin'
|
|
144
|
-
}, () => {
|
|
145
|
-
console.log('document is deleted');
|
|
146
|
-
});
|
|
147
|
-
```
|
|
148
|
-
### _id `function`
|
|
149
|
-
provide new mongo _id. As parameters accepting callback function which will return the _id. Example:
|
|
150
|
-
```javascript
|
|
151
|
-
mongo._id( _id => {
|
|
152
|
-
console.log(_id);
|
|
153
|
-
});
|
|
154
|
-
```
|
|
155
|
-
### to_id `function`
|
|
156
|
-
convert array of documents, object with documents, mixed documents or _id and converting it to array of _id. Example:
|
|
157
|
-
```javascript
|
|
158
|
-
mongo.to_id([{
|
|
159
|
-
_id: '1'
|
|
160
|
-
}, '2']);
|
|
161
|
-
// ['1', '2']
|
|
162
|
-
mongo.to_id({
|
|
163
|
-
'1': true
|
|
164
|
-
'2': false
|
|
165
|
-
});
|
|
166
|
-
// ['1']
|
|
167
|
-
```
|
|
168
|
-
### afterWhile `function`
|
|
169
|
-
provide delay on any action, usefull with input and model change. As parameters accepting document, callback and optionally time. Example:
|
|
170
|
-
```javascript
|
|
171
|
-
mongo.afterWhile(doc, () => {
|
|
172
|
-
console.log('change can be applied');
|
|
173
|
-
}, 2000);
|
|
174
|
-
```
|
|
175
|
-
### populate `function`
|
|
176
|
-
making population on specific field with specific collection. Example with doc which will have field as document of part provided:
|
|
177
|
-
```javascript
|
|
178
|
-
mongo.populate(doc, 'field', 'colName');
|
|
179
|
-
```
|
|
180
|
-
### on `function`
|
|
181
|
-
accepting array or string of parts and callback which will be called when all parts will be loaded.
|
|
182
|
-
Example:
|
|
183
|
-
```javascript
|
|
184
|
-
mongo.on('user post', () => {
|
|
185
|
-
console.log('user and post part has been loaded');
|
|
186
|
-
});
|
|
187
|
-
```
|
|
188
|
-
## Sort
|
|
189
|
-
Set of functions, which are accepted by th function ```array.sort()``` as a parameter. Each of these functions is for sorting documents(objects).
|
|
190
|
-
### sortAscId `function`
|
|
191
|
-
accepting array of objects and return it sorted in ascending order by _id
|
|
192
|
-
Example:
|
|
193
|
-
```javascript
|
|
194
|
-
array.sort(mongo.sortAscId());
|
|
195
|
-
```
|
|
196
|
-
### sortDescId `function`
|
|
197
|
-
accepting array of objects and return it sorted in descending order by _id
|
|
198
|
-
Example:
|
|
199
|
-
```javascript
|
|
200
|
-
mongo.sortDescId();
|
|
201
|
-
```
|
|
202
|
-
### sortAscString `function`
|
|
203
|
-
accepting array of object and return it sorted in ascending order by alphabet
|
|
204
|
-
Example:
|
|
205
|
-
```javascript
|
|
206
|
-
mongo.sortAscString();
|
|
207
|
-
```
|
|
208
|
-
### sortDescString `function`
|
|
209
|
-
accepting array of object and return it sorted in descending order by alphabet
|
|
210
|
-
Example:
|
|
211
|
-
```javascript
|
|
212
|
-
mongo.sortDescString();
|
|
213
|
-
```
|
|
214
|
-
### sortAscDate `function`
|
|
215
|
-
accepting array of object and return it sorted in ascending order by date
|
|
216
|
-
Example:
|
|
217
|
-
```javascript
|
|
218
|
-
mongo.sortAscDate();
|
|
219
|
-
```
|
|
220
|
-
### sortDescDate `function`
|
|
221
|
-
accepting array of object and return it sorted in descending order by date
|
|
222
|
-
Example:
|
|
223
|
-
```javascript
|
|
224
|
-
mongo.sortDescDate();
|
|
225
|
-
```
|
|
226
|
-
### sortAscNumber `function`
|
|
227
|
-
accepting array of object and return it sorted in ascending order by number
|
|
228
|
-
Example:
|
|
229
|
-
```javascript
|
|
230
|
-
mongo.sortAscNumber();
|
|
231
|
-
```
|
|
232
|
-
### sortDescNumber `function`
|
|
233
|
-
accepting array of object and return it sorted in descending order by number
|
|
234
|
-
Example:
|
|
235
|
-
```javascript
|
|
236
|
-
mongo.sortDescNumber();
|
|
237
|
-
```
|
|
238
|
-
### sortAscBoolean `function`
|
|
239
|
-
accepting array of object and return it sorted: first - true, second - false
|
|
240
|
-
Example:
|
|
241
|
-
```javascript
|
|
242
|
-
mongo.sortAscBoolean();
|
|
243
|
-
```
|
|
244
|
-
### sortDescBoolean `function`
|
|
245
|
-
accepting array of object and return it sorted: first - false, second - true
|
|
246
|
-
Example:
|
|
247
|
-
```javascript
|
|
248
|
-
mongo.sortDescBoolean();
|
|
249
|
-
```
|
|
250
|
-
### beArr `function`
|
|
251
|
-
checking value if it's array then we keep it and in other case, we replace it with new array. Example where each doc will have data as array:
|
|
252
|
-
```javascript
|
|
253
|
-
mongo.get('colName', {
|
|
254
|
-
replace: {
|
|
255
|
-
data:mongo.beArr
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
```
|
|
259
|
-
### beObj `function`
|
|
260
|
-
checking value if it's object then we keep it and in other case, we replace it with new object. Example where each doc will have data as array:
|
|
261
|
-
```javascript
|
|
262
|
-
mongo.get('colName', {
|
|
263
|
-
replace: {
|
|
264
|
-
data:mongo.beObj
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
```
|
|
268
|
-
### beDate `function`
|
|
269
|
-
making value new Date(valueContent). Example where each doc will have date as date:
|
|
270
|
-
```javascript
|
|
271
|
-
mongo.get('colName', {
|
|
272
|
-
replace: {
|
|
273
|
-
date:mongo.beDate
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
```
|
|
277
|
-
### forceArr `function`
|
|
278
|
-
convert any value to array within replace options. Example where each doc will have data as empty array:
|
|
279
|
-
```javascript
|
|
280
|
-
mongo.get('colName', {
|
|
281
|
-
replace: {
|
|
282
|
-
data:mongo.forceArr
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
```
|
|
286
|
-
### forceObj `function`
|
|
287
|
-
convert any value to object within replace options. Example where each doc will have data as empty object:
|
|
288
|
-
```javascript
|
|
289
|
-
mongo.get('colName', {
|
|
290
|
-
replace: {
|
|
291
|
-
data:mongo.forceObj
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
```
|
|
295
|
-
## Alert Service
|
|
296
|
-
Alert Service is an suportive service for alerts manamanagement. Example of importing alert service:
|
|
297
|
-
```javascript
|
|
298
|
-
import { AlertService } from 'wacom';
|
|
299
|
-
constructor(private alert: AlertService){};
|
|
300
|
-
```
|
|
301
|
-
### show `function`
|
|
302
|
-
Opens the alert and return htmlElement of this alert.
|
|
303
|
-
Example 1:
|
|
304
|
-
```javascript
|
|
305
|
-
let my_alert = alert.show({
|
|
306
|
-
text: 'Are you sure?',
|
|
307
|
-
type: 'question',
|
|
308
|
-
timeout: 5000,
|
|
309
|
-
class: 'myClass',
|
|
310
|
-
position: 'bottomRight',
|
|
311
|
-
buttons: [{
|
|
312
|
-
text: 'YES',
|
|
313
|
-
callback: ()=>{
|
|
314
|
-
console.log("YES!");
|
|
315
|
-
}
|
|
316
|
-
},{
|
|
317
|
-
text: 'NO',
|
|
318
|
-
callback: ()=>{
|
|
319
|
-
console.log("NO!");
|
|
320
|
-
}
|
|
321
|
-
}]
|
|
322
|
-
});
|
|
323
|
-
```
|
|
324
|
-
Example 2:
|
|
325
|
-
```javascript
|
|
326
|
-
let my_alert = alert.show({
|
|
327
|
-
component: MyCustomComponent,
|
|
328
|
-
timeout: 5000,
|
|
329
|
-
class: 'myClass',
|
|
330
|
-
position: 'center',
|
|
331
|
-
closable: true
|
|
332
|
-
});
|
|
333
|
-
```
|
|
334
|
-
### options
|
|
335
|
-
| Name | Type | Description |
|
|
336
|
-
| --------------- |--------- | --------------- |
|
|
337
|
-
| `text` | string | Text of alert. |
|
|
338
|
-
| `type` | string | Type of alert(etc `info`, `success`, `warning`, `error`, `question`). |
|
|
339
|
-
| `class` | string | Custom class for your alert. |
|
|
340
|
-
| `unique` | string | Identificator for your alerts. |
|
|
341
|
-
| `progress` | boolean | Enable timeout progress bar. |
|
|
342
|
-
| `position` | string | Position of the alert(`topLeft`, `topCenter`, `topRight`, `right`, `bottomRight`, `bottomCenter`, `bottomLeft`, `left`, `center`). |
|
|
343
|
-
| `timeout` | number | Amount in milliseconds to close the alert, 0 to disable. |
|
|
344
|
-
| `closable` | boolean | Show "x" close button. |
|
|
345
|
-
| `buttons` | number | Array of buttons for your alerts. |
|
|
346
|
-
| `component` | string or @Component | Component which will be appended into the alert. |
|
|
347
|
-
| `close` | function | custom function for close alert. |
|
|
348
|
-
| `onClose` | function | Capture when the alert is closing. |
|
|
349
|
-
### destroy `function`
|
|
350
|
-
Close all alerts. Example:
|
|
351
|
-
```javascript
|
|
352
|
-
alert.destroy();
|
|
353
|
-
```
|
|
354
|
-
## Modal Service
|
|
355
|
-
Modal Service is an suportive service for modals manamanagement. Example of importing modal service:
|
|
356
|
-
```javascript
|
|
357
|
-
import { ModalService } from 'wacom';
|
|
358
|
-
constructor(private modal: ModalService){};
|
|
359
|
-
```
|
|
360
|
-
### show `function`
|
|
361
|
-
Opens the modal and return htmlElement of this modal. Example:
|
|
362
|
-
```javascript
|
|
363
|
-
let my_modal = modal.show({
|
|
364
|
-
component: MyCustomComponent,
|
|
365
|
-
size: 'mid',
|
|
366
|
-
timeout: 5000,
|
|
367
|
-
class: 'myClass',
|
|
368
|
-
position: 'center',
|
|
369
|
-
closable: true
|
|
370
|
-
});
|
|
371
|
-
```
|
|
372
|
-
### options
|
|
373
|
-
| Name | Type | Description |
|
|
374
|
-
| --------------- |--------- | --------------- |
|
|
375
|
-
| `id` | string | |
|
|
376
|
-
| `component` | string or @Component | Component which will be appended into the modal. |
|
|
377
|
-
| `size` | string | Size of the modal. |
|
|
378
|
-
| `timeout` | number | Amount in milliseconds to close the modal, 0 to disable. |
|
|
379
|
-
| `class` | string | Custom class for your modal. |
|
|
380
|
-
| `closable` | boolean | Show "x" close button. |
|
|
381
|
-
| `unique` | string | Identificator for your modals. |
|
|
382
|
-
| `close` | function | custom function for close modal. |
|
|
383
|
-
| `onOpen` | function | Capture when the modal is opening. |
|
|
384
|
-
| `onClose` | function | Capture when the modal is closing. |
|
|
385
|
-
### destroy `function`
|
|
386
|
-
Close all modals. Example:
|
|
387
|
-
```javascript
|
|
388
|
-
modal.destroy();
|
|
389
|
-
```
|
|
390
|
-
## Loader Service
|
|
391
|
-
Loader Service is an suportive service for loaders manamanagement.Example of importing loader service:
|
|
392
|
-
```javascript
|
|
393
|
-
import { LoaderService } from 'wacom';
|
|
394
|
-
constructor(private load: LoaderService){};
|
|
395
|
-
```
|
|
396
|
-
### show `function`
|
|
397
|
-
Opens the loader and return htmlElement of this loader. Example:
|
|
398
|
-
```javascript
|
|
399
|
-
let my_loader = load.show({
|
|
400
|
-
timeout: 5000,
|
|
401
|
-
class: 'myClass',
|
|
402
|
-
closable: true
|
|
403
|
-
});
|
|
404
|
-
```
|
|
405
|
-
### options
|
|
406
|
-
| Name | Type | Description |
|
|
407
|
-
| --------------- |--------- | --------------- |
|
|
408
|
-
| `append` | @Component | Component where the loader will be appended. |
|
|
409
|
-
| `component` | string or @Component | Component which will be appended into the loader. |
|
|
410
|
-
| `timeout` | number | Amount in milliseconds to close the loader, 0 to disable. |
|
|
411
|
-
| `progress` | boolean | Enable timeout progress bar. |
|
|
412
|
-
| `class` | string | Custom class for your loader. |
|
|
413
|
-
| `closable` | boolean | Show "x" close button. |
|
|
414
|
-
| `close` | function | custom function for close loader. |
|
|
415
|
-
| `onClose` | function | Capture when the loader is closing. |
|
|
416
|
-
### destroy `function`
|
|
417
|
-
Close all loaders. Example:
|
|
418
|
-
```javascript
|
|
419
|
-
loader.destroy();
|
|
420
|
-
```
|
|
421
|
-
## UI/UX Service
|
|
422
|
-
UI/UX Service is supportive service for front-end features. This service provides saving css varibles and containes helpful tools for the front developer.
|
|
423
|
-
### var
|
|
424
|
-
Object which can be used to contain all needed fields for front-end.
|
|
425
|
-
### get `function`
|
|
426
|
-
Returns Object with all saved css viriables.
|
|
427
|
-
Example:
|
|
428
|
-
```javascript
|
|
429
|
-
ui.get();
|
|
430
|
-
```
|
|
431
|
-
Result example:
|
|
432
|
-
```javascript
|
|
433
|
-
{
|
|
434
|
-
test: '15px solid'
|
|
435
|
-
}
|
|
436
|
-
```
|
|
437
|
-
### remove `function`
|
|
438
|
-
Removes css varible by the key.
|
|
439
|
-
Example:
|
|
440
|
-
```javascript
|
|
441
|
-
ui.remove('css');
|
|
442
|
-
```
|
|
443
|
-
### set `function`
|
|
444
|
-
Method interface sets a new value for a property on a CSS style declaration object and saves all css variables which you have passed.
|
|
445
|
-
Example:
|
|
446
|
-
```javascript
|
|
447
|
-
ui.set(variables, options);
|
|
448
|
-
```
|
|
449
|
-
```variables``` - All css varibles you want to pass. If you want to set array of variables you'll need to have specific structure of the array. Example: ```[{key: 'name', value: example}]```. Object will be saved with the same structure.
|
|
450
|
-
|
|
451
|
-
```options``` - If you want to save css variables to the localStorage you should pass ```local: true```. Also if you want to save variables only for specific host you should pass ```host: 'hostname'```
|
|
452
|
-
### arr `function`
|
|
453
|
-
Helps developer to generate array with custom length and with elements of specific type.
|
|
454
|
-
Example:
|
|
455
|
-
```html
|
|
456
|
-
<div *ngFor="let obj of ui.arr(length, type)"></div>
|
|
457
|
-
```
|
|
458
|
-
```length``` - Length of generated array.
|
|
459
|
-
```type``` - ```'number'||'text'||'date'``` Will set elements with random content at choosed type. 'number' is default type of elements.
|
|
460
|
-
### text `function`
|
|
461
|
-
Helps developer to generate random string with specific length.
|
|
462
|
-
Example:
|
|
463
|
-
```html
|
|
464
|
-
<span>{{ui.text(length)}}</span>
|
|
465
|
-
```
|
|
1
|
+
# Angular (ngx) common
|
|
2
|
+
Module which has common services and components which can be used on all projects.
|
|
3
|
+
|
|
4
|
+
## Getting Started
|
|
5
|
+
|
|
6
|
+
### License
|
|
7
|
+
[MIT](LICENSE)
|
|
8
|
+
|
|
9
|
+
### Instalation
|
|
10
|
+
```bash
|
|
11
|
+
$ npm i --save wacom
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### Services
|
|
15
|
+
| Name | Description |
|
|
16
|
+
| ------- |:-----:|
|
|
17
|
+
| [**`Core`**](https://www.npmjs.com/package/wacom#core-service) | Common supportive function which can be used in any service |
|
|
18
|
+
| [**`Http`**](https://www.npmjs.com/package/wacom#http-service) | Http layer for HttpClient |
|
|
19
|
+
| [**`Store`**](https://www.npmjs.com/package/wacom#store-service) | Service will is responsible for keeping information on the device |
|
|
20
|
+
| [**`Hash`**](https://www.npmjs.com/package/wacom#hash-service) | Hash management for easily use, storage which stay in url |
|
|
21
|
+
| [**`Render`**](https://www.npmjs.com/package/wacom#render-service) | Make not automated render management well structured |
|
|
22
|
+
| [**`Meta`**](https://www.npmjs.com/package/wacom#meta-service) | Website meta tags management within router |
|
|
23
|
+
| [**`Alert`**](https://www.npmjs.com/package/wacom#alert-service) | Alerts management |
|
|
24
|
+
| [**`Modal`**](https://www.npmjs.com/package/wacom#modal-service) | Modals management |
|
|
25
|
+
| [**`UI`**](https://www.npmjs.com/package/wacom#ui-service) | Supportive UI/UX service |
|
|
26
|
+
|
|
27
|
+
## Mongo Service
|
|
28
|
+
Mongo Service is an suportive service for combining angular 6 client with waw CRUD back-end. Which means that you have to use [waw Framework](https://www.npmjs.com/package/waw) or you have to made your back-end routes in a way of waw crud. Example of importing mongo service:
|
|
29
|
+
```javascript
|
|
30
|
+
import { MongoService } from 'wacom';
|
|
31
|
+
constructor(private mongo: MongoService){};
|
|
32
|
+
```
|
|
33
|
+
### create `function`
|
|
34
|
+
connecting with waw CRUD create. As parameters accepting name of mongo collection, object with values for document and optionally callback function which will return the document. Document will be filled inside read callbacks. Example:
|
|
35
|
+
```javascript
|
|
36
|
+
mongo.create('colName', {
|
|
37
|
+
name: 'docName'
|
|
38
|
+
}, created => {
|
|
39
|
+
console.log('document has been created');
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
### read `function`
|
|
43
|
+
connecting with waw CRUD read. As parameters accepting name of mongo collection, optionally options, optionally callback which will return all documents in array as first parameter and in object with doc._id placeholder for doc as second parameter. Function returning directing array which will host the documents. Example:
|
|
44
|
+
```javascript
|
|
45
|
+
mongo.get('colName',{
|
|
46
|
+
replace: { // will create or modify selected fields on documents
|
|
47
|
+
name: function(val, cb, doc){
|
|
48
|
+
cb(val+'_modified')
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
name: 'me', // customized query
|
|
52
|
+
populate: [{ // will fill id with document
|
|
53
|
+
field: 'author',
|
|
54
|
+
part: 'user'
|
|
55
|
+
}],
|
|
56
|
+
groups: 'city name' || ['city', 'name'] || { // will make objects with arrays by selected query
|
|
57
|
+
first_name: {
|
|
58
|
+
field: function(doc, cb){
|
|
59
|
+
if(doc.name.split(' ').length>1) cb(doc.name.split(' ')[1]);
|
|
60
|
+
retun doc.name.split(' ')[0];
|
|
61
|
+
},
|
|
62
|
+
allow: function(doc){
|
|
63
|
+
return !!doc.name;
|
|
64
|
+
},
|
|
65
|
+
ignore: function(){
|
|
66
|
+
return false;
|
|
67
|
+
},
|
|
68
|
+
sort: function(){
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
query: { // will make arrays by selected query
|
|
74
|
+
male: function(doc){
|
|
75
|
+
return doc.gender;
|
|
76
|
+
},
|
|
77
|
+
female: {
|
|
78
|
+
allow: function(doc){
|
|
79
|
+
return !doc.gender;
|
|
80
|
+
},
|
|
81
|
+
ignore: function(){
|
|
82
|
+
return typeof doc.gender != 'boolean';
|
|
83
|
+
},
|
|
84
|
+
sort: function(a, b){
|
|
85
|
+
if(a.order > b.order) return -1;
|
|
86
|
+
return 1;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
fields: 'url' // will fill obj with docs by url field
|
|
91
|
+
}, (arr, obj, name, resp) => {
|
|
92
|
+
/*
|
|
93
|
+
* arr will be array with total docs from that part
|
|
94
|
+
* obj will be object with total docs from that part binded by _id
|
|
95
|
+
* groups will be saved into obj in the way: obj.name['Denys'] or obj.city['Kiev']
|
|
96
|
+
* name is the name of current pull from server
|
|
97
|
+
* resp is the array of responsinse with documents queried
|
|
98
|
+
*/
|
|
99
|
+
})
|
|
100
|
+
```
|
|
101
|
+
#### replace `options`
|
|
102
|
+
work as filler of each doc for cases when we can calculate things to use in website. Good example can be currencies which change each moment, we have product in one currency and we want to show it in different currrencies. Other good example can be date fields, which is saved as string and we need them in `new Date()` format.
|
|
103
|
+
#### populate `options`
|
|
104
|
+
works in the same way as populate of mongodb but in the client side. This works great when you need documents inside other documents and put on them sorting or other things.
|
|
105
|
+
#### groups `options`
|
|
106
|
+
makings arrays which show different documents inside specific placeholders. As example we can have list of users in specific town or country, so we don't have to create pipes for that.
|
|
107
|
+
#### next `options`
|
|
108
|
+
works as level of pulling different documents from the server. This is mostly made for performance, so user can have the info he needs directly.
|
|
109
|
+
### update `function`
|
|
110
|
+
connecting with waw CRUD updateAll. As parameters accepting name of mongo collection, document object, optionally options and optionally callback function which will return the document. Example:
|
|
111
|
+
```javascript
|
|
112
|
+
mongo.updateAll('colName', {
|
|
113
|
+
name: doc.name,
|
|
114
|
+
_id: doc._id
|
|
115
|
+
}, {
|
|
116
|
+
fields: 'name'
|
|
117
|
+
}, () => {
|
|
118
|
+
console.log('document is updated');
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
### unique `function`
|
|
122
|
+
connecting with waw CRUD updateUnique. As parameters accepting name of mongo collection, object with document _id and field value, optionally options and optionally callback function which will return if field has been updated. Example:
|
|
123
|
+
```javascript
|
|
124
|
+
mongo.unique('colName', {
|
|
125
|
+
name: doc.name,
|
|
126
|
+
_id: doc._id
|
|
127
|
+
}, {
|
|
128
|
+
name: 'name'
|
|
129
|
+
}, (resp) => {
|
|
130
|
+
if(resp){
|
|
131
|
+
console.log('field is updated');
|
|
132
|
+
}else {
|
|
133
|
+
console.log('field is not updated');
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
### delete `function`
|
|
138
|
+
connecting with waw CRUD delete. As parameters accepting name of mongo collection, document object, optionally options and optionally callback function which will return the document. Example:
|
|
139
|
+
```javascript
|
|
140
|
+
mongo.delate('colName',{
|
|
141
|
+
_id: doc._id
|
|
142
|
+
}, {
|
|
143
|
+
name: 'admin'
|
|
144
|
+
}, () => {
|
|
145
|
+
console.log('document is deleted');
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
### _id `function`
|
|
149
|
+
provide new mongo _id. As parameters accepting callback function which will return the _id. Example:
|
|
150
|
+
```javascript
|
|
151
|
+
mongo._id( _id => {
|
|
152
|
+
console.log(_id);
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
### to_id `function`
|
|
156
|
+
convert array of documents, object with documents, mixed documents or _id and converting it to array of _id. Example:
|
|
157
|
+
```javascript
|
|
158
|
+
mongo.to_id([{
|
|
159
|
+
_id: '1'
|
|
160
|
+
}, '2']);
|
|
161
|
+
// ['1', '2']
|
|
162
|
+
mongo.to_id({
|
|
163
|
+
'1': true
|
|
164
|
+
'2': false
|
|
165
|
+
});
|
|
166
|
+
// ['1']
|
|
167
|
+
```
|
|
168
|
+
### afterWhile `function`
|
|
169
|
+
provide delay on any action, usefull with input and model change. As parameters accepting document, callback and optionally time. Example:
|
|
170
|
+
```javascript
|
|
171
|
+
mongo.afterWhile(doc, () => {
|
|
172
|
+
console.log('change can be applied');
|
|
173
|
+
}, 2000);
|
|
174
|
+
```
|
|
175
|
+
### populate `function`
|
|
176
|
+
making population on specific field with specific collection. Example with doc which will have field as document of part provided:
|
|
177
|
+
```javascript
|
|
178
|
+
mongo.populate(doc, 'field', 'colName');
|
|
179
|
+
```
|
|
180
|
+
### on `function`
|
|
181
|
+
accepting array or string of parts and callback which will be called when all parts will be loaded.
|
|
182
|
+
Example:
|
|
183
|
+
```javascript
|
|
184
|
+
mongo.on('user post', () => {
|
|
185
|
+
console.log('user and post part has been loaded');
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
## Sort
|
|
189
|
+
Set of functions, which are accepted by th function ```array.sort()``` as a parameter. Each of these functions is for sorting documents(objects).
|
|
190
|
+
### sortAscId `function`
|
|
191
|
+
accepting array of objects and return it sorted in ascending order by _id
|
|
192
|
+
Example:
|
|
193
|
+
```javascript
|
|
194
|
+
array.sort(mongo.sortAscId());
|
|
195
|
+
```
|
|
196
|
+
### sortDescId `function`
|
|
197
|
+
accepting array of objects and return it sorted in descending order by _id
|
|
198
|
+
Example:
|
|
199
|
+
```javascript
|
|
200
|
+
mongo.sortDescId();
|
|
201
|
+
```
|
|
202
|
+
### sortAscString `function`
|
|
203
|
+
accepting array of object and return it sorted in ascending order by alphabet
|
|
204
|
+
Example:
|
|
205
|
+
```javascript
|
|
206
|
+
mongo.sortAscString();
|
|
207
|
+
```
|
|
208
|
+
### sortDescString `function`
|
|
209
|
+
accepting array of object and return it sorted in descending order by alphabet
|
|
210
|
+
Example:
|
|
211
|
+
```javascript
|
|
212
|
+
mongo.sortDescString();
|
|
213
|
+
```
|
|
214
|
+
### sortAscDate `function`
|
|
215
|
+
accepting array of object and return it sorted in ascending order by date
|
|
216
|
+
Example:
|
|
217
|
+
```javascript
|
|
218
|
+
mongo.sortAscDate();
|
|
219
|
+
```
|
|
220
|
+
### sortDescDate `function`
|
|
221
|
+
accepting array of object and return it sorted in descending order by date
|
|
222
|
+
Example:
|
|
223
|
+
```javascript
|
|
224
|
+
mongo.sortDescDate();
|
|
225
|
+
```
|
|
226
|
+
### sortAscNumber `function`
|
|
227
|
+
accepting array of object and return it sorted in ascending order by number
|
|
228
|
+
Example:
|
|
229
|
+
```javascript
|
|
230
|
+
mongo.sortAscNumber();
|
|
231
|
+
```
|
|
232
|
+
### sortDescNumber `function`
|
|
233
|
+
accepting array of object and return it sorted in descending order by number
|
|
234
|
+
Example:
|
|
235
|
+
```javascript
|
|
236
|
+
mongo.sortDescNumber();
|
|
237
|
+
```
|
|
238
|
+
### sortAscBoolean `function`
|
|
239
|
+
accepting array of object and return it sorted: first - true, second - false
|
|
240
|
+
Example:
|
|
241
|
+
```javascript
|
|
242
|
+
mongo.sortAscBoolean();
|
|
243
|
+
```
|
|
244
|
+
### sortDescBoolean `function`
|
|
245
|
+
accepting array of object and return it sorted: first - false, second - true
|
|
246
|
+
Example:
|
|
247
|
+
```javascript
|
|
248
|
+
mongo.sortDescBoolean();
|
|
249
|
+
```
|
|
250
|
+
### beArr `function`
|
|
251
|
+
checking value if it's array then we keep it and in other case, we replace it with new array. Example where each doc will have data as array:
|
|
252
|
+
```javascript
|
|
253
|
+
mongo.get('colName', {
|
|
254
|
+
replace: {
|
|
255
|
+
data:mongo.beArr
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
```
|
|
259
|
+
### beObj `function`
|
|
260
|
+
checking value if it's object then we keep it and in other case, we replace it with new object. Example where each doc will have data as array:
|
|
261
|
+
```javascript
|
|
262
|
+
mongo.get('colName', {
|
|
263
|
+
replace: {
|
|
264
|
+
data:mongo.beObj
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
```
|
|
268
|
+
### beDate `function`
|
|
269
|
+
making value new Date(valueContent). Example where each doc will have date as date:
|
|
270
|
+
```javascript
|
|
271
|
+
mongo.get('colName', {
|
|
272
|
+
replace: {
|
|
273
|
+
date:mongo.beDate
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
```
|
|
277
|
+
### forceArr `function`
|
|
278
|
+
convert any value to array within replace options. Example where each doc will have data as empty array:
|
|
279
|
+
```javascript
|
|
280
|
+
mongo.get('colName', {
|
|
281
|
+
replace: {
|
|
282
|
+
data:mongo.forceArr
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
```
|
|
286
|
+
### forceObj `function`
|
|
287
|
+
convert any value to object within replace options. Example where each doc will have data as empty object:
|
|
288
|
+
```javascript
|
|
289
|
+
mongo.get('colName', {
|
|
290
|
+
replace: {
|
|
291
|
+
data:mongo.forceObj
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
```
|
|
295
|
+
## Alert Service
|
|
296
|
+
Alert Service is an suportive service for alerts manamanagement. Example of importing alert service:
|
|
297
|
+
```javascript
|
|
298
|
+
import { AlertService } from 'wacom';
|
|
299
|
+
constructor(private alert: AlertService){};
|
|
300
|
+
```
|
|
301
|
+
### show `function`
|
|
302
|
+
Opens the alert and return htmlElement of this alert.
|
|
303
|
+
Example 1:
|
|
304
|
+
```javascript
|
|
305
|
+
let my_alert = alert.show({
|
|
306
|
+
text: 'Are you sure?',
|
|
307
|
+
type: 'question',
|
|
308
|
+
timeout: 5000,
|
|
309
|
+
class: 'myClass',
|
|
310
|
+
position: 'bottomRight',
|
|
311
|
+
buttons: [{
|
|
312
|
+
text: 'YES',
|
|
313
|
+
callback: ()=>{
|
|
314
|
+
console.log("YES!");
|
|
315
|
+
}
|
|
316
|
+
},{
|
|
317
|
+
text: 'NO',
|
|
318
|
+
callback: ()=>{
|
|
319
|
+
console.log("NO!");
|
|
320
|
+
}
|
|
321
|
+
}]
|
|
322
|
+
});
|
|
323
|
+
```
|
|
324
|
+
Example 2:
|
|
325
|
+
```javascript
|
|
326
|
+
let my_alert = alert.show({
|
|
327
|
+
component: MyCustomComponent,
|
|
328
|
+
timeout: 5000,
|
|
329
|
+
class: 'myClass',
|
|
330
|
+
position: 'center',
|
|
331
|
+
closable: true
|
|
332
|
+
});
|
|
333
|
+
```
|
|
334
|
+
### options
|
|
335
|
+
| Name | Type | Description |
|
|
336
|
+
| --------------- |--------- | --------------- |
|
|
337
|
+
| `text` | string | Text of alert. |
|
|
338
|
+
| `type` | string | Type of alert(etc `info`, `success`, `warning`, `error`, `question`). |
|
|
339
|
+
| `class` | string | Custom class for your alert. |
|
|
340
|
+
| `unique` | string | Identificator for your alerts. |
|
|
341
|
+
| `progress` | boolean | Enable timeout progress bar. |
|
|
342
|
+
| `position` | string | Position of the alert(`topLeft`, `topCenter`, `topRight`, `right`, `bottomRight`, `bottomCenter`, `bottomLeft`, `left`, `center`). |
|
|
343
|
+
| `timeout` | number | Amount in milliseconds to close the alert, 0 to disable. |
|
|
344
|
+
| `closable` | boolean | Show "x" close button. |
|
|
345
|
+
| `buttons` | number | Array of buttons for your alerts. |
|
|
346
|
+
| `component` | string or @Component | Component which will be appended into the alert. |
|
|
347
|
+
| `close` | function | custom function for close alert. |
|
|
348
|
+
| `onClose` | function | Capture when the alert is closing. |
|
|
349
|
+
### destroy `function`
|
|
350
|
+
Close all alerts. Example:
|
|
351
|
+
```javascript
|
|
352
|
+
alert.destroy();
|
|
353
|
+
```
|
|
354
|
+
## Modal Service
|
|
355
|
+
Modal Service is an suportive service for modals manamanagement. Example of importing modal service:
|
|
356
|
+
```javascript
|
|
357
|
+
import { ModalService } from 'wacom';
|
|
358
|
+
constructor(private modal: ModalService){};
|
|
359
|
+
```
|
|
360
|
+
### show `function`
|
|
361
|
+
Opens the modal and return htmlElement of this modal. Example:
|
|
362
|
+
```javascript
|
|
363
|
+
let my_modal = modal.show({
|
|
364
|
+
component: MyCustomComponent,
|
|
365
|
+
size: 'mid',
|
|
366
|
+
timeout: 5000,
|
|
367
|
+
class: 'myClass',
|
|
368
|
+
position: 'center',
|
|
369
|
+
closable: true
|
|
370
|
+
});
|
|
371
|
+
```
|
|
372
|
+
### options
|
|
373
|
+
| Name | Type | Description |
|
|
374
|
+
| --------------- |--------- | --------------- |
|
|
375
|
+
| `id` | string | |
|
|
376
|
+
| `component` | string or @Component | Component which will be appended into the modal. |
|
|
377
|
+
| `size` | string | Size of the modal. |
|
|
378
|
+
| `timeout` | number | Amount in milliseconds to close the modal, 0 to disable. |
|
|
379
|
+
| `class` | string | Custom class for your modal. |
|
|
380
|
+
| `closable` | boolean | Show "x" close button. |
|
|
381
|
+
| `unique` | string | Identificator for your modals. |
|
|
382
|
+
| `close` | function | custom function for close modal. |
|
|
383
|
+
| `onOpen` | function | Capture when the modal is opening. |
|
|
384
|
+
| `onClose` | function | Capture when the modal is closing. |
|
|
385
|
+
### destroy `function`
|
|
386
|
+
Close all modals. Example:
|
|
387
|
+
```javascript
|
|
388
|
+
modal.destroy();
|
|
389
|
+
```
|
|
390
|
+
## Loader Service
|
|
391
|
+
Loader Service is an suportive service for loaders manamanagement.Example of importing loader service:
|
|
392
|
+
```javascript
|
|
393
|
+
import { LoaderService } from 'wacom';
|
|
394
|
+
constructor(private load: LoaderService){};
|
|
395
|
+
```
|
|
396
|
+
### show `function`
|
|
397
|
+
Opens the loader and return htmlElement of this loader. Example:
|
|
398
|
+
```javascript
|
|
399
|
+
let my_loader = load.show({
|
|
400
|
+
timeout: 5000,
|
|
401
|
+
class: 'myClass',
|
|
402
|
+
closable: true
|
|
403
|
+
});
|
|
404
|
+
```
|
|
405
|
+
### options
|
|
406
|
+
| Name | Type | Description |
|
|
407
|
+
| --------------- |--------- | --------------- |
|
|
408
|
+
| `append` | @Component | Component where the loader will be appended. |
|
|
409
|
+
| `component` | string or @Component | Component which will be appended into the loader. |
|
|
410
|
+
| `timeout` | number | Amount in milliseconds to close the loader, 0 to disable. |
|
|
411
|
+
| `progress` | boolean | Enable timeout progress bar. |
|
|
412
|
+
| `class` | string | Custom class for your loader. |
|
|
413
|
+
| `closable` | boolean | Show "x" close button. |
|
|
414
|
+
| `close` | function | custom function for close loader. |
|
|
415
|
+
| `onClose` | function | Capture when the loader is closing. |
|
|
416
|
+
### destroy `function`
|
|
417
|
+
Close all loaders. Example:
|
|
418
|
+
```javascript
|
|
419
|
+
loader.destroy();
|
|
420
|
+
```
|
|
421
|
+
## UI/UX Service
|
|
422
|
+
UI/UX Service is supportive service for front-end features. This service provides saving css varibles and containes helpful tools for the front developer.
|
|
423
|
+
### var
|
|
424
|
+
Object which can be used to contain all needed fields for front-end.
|
|
425
|
+
### get `function`
|
|
426
|
+
Returns Object with all saved css viriables.
|
|
427
|
+
Example:
|
|
428
|
+
```javascript
|
|
429
|
+
ui.get();
|
|
430
|
+
```
|
|
431
|
+
Result example:
|
|
432
|
+
```javascript
|
|
433
|
+
{
|
|
434
|
+
test: '15px solid'
|
|
435
|
+
}
|
|
436
|
+
```
|
|
437
|
+
### remove `function`
|
|
438
|
+
Removes css varible by the key.
|
|
439
|
+
Example:
|
|
440
|
+
```javascript
|
|
441
|
+
ui.remove('css');
|
|
442
|
+
```
|
|
443
|
+
### set `function`
|
|
444
|
+
Method interface sets a new value for a property on a CSS style declaration object and saves all css variables which you have passed.
|
|
445
|
+
Example:
|
|
446
|
+
```javascript
|
|
447
|
+
ui.set(variables, options);
|
|
448
|
+
```
|
|
449
|
+
```variables``` - All css varibles you want to pass. If you want to set array of variables you'll need to have specific structure of the array. Example: ```[{key: 'name', value: example}]```. Object will be saved with the same structure.
|
|
450
|
+
|
|
451
|
+
```options``` - If you want to save css variables to the localStorage you should pass ```local: true```. Also if you want to save variables only for specific host you should pass ```host: 'hostname'```
|
|
452
|
+
### arr `function`
|
|
453
|
+
Helps developer to generate array with custom length and with elements of specific type.
|
|
454
|
+
Example:
|
|
455
|
+
```html
|
|
456
|
+
<div *ngFor="let obj of ui.arr(length, type)"></div>
|
|
457
|
+
```
|
|
458
|
+
```length``` - Length of generated array.
|
|
459
|
+
```type``` - ```'number'||'text'||'date'``` Will set elements with random content at choosed type. 'number' is default type of elements.
|
|
460
|
+
### text `function`
|
|
461
|
+
Helps developer to generate random string with specific length.
|
|
462
|
+
Example:
|
|
463
|
+
```html
|
|
464
|
+
<span>{{ui.text(length)}}</span>
|
|
465
|
+
```
|