@fleetbase/ember-core 0.0.1 → 0.0.3
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 +5 -12
- package/addon/adapters/application.js +4 -0
- package/addon/authenticators/fleetbase.js +0 -1
- package/addon/decorators/fetch-from.js +1 -1
- package/addon/decorators/from-store.js +1 -2
- package/addon/serializers/application.js +1 -2
- package/addon/services/current-user.js +1 -1
- package/addon/services/fetch.js +5 -1
- package/addon/services/theme.js +0 -2
- package/addon/utils/auto-serialize.js +1 -1
- package/addon/utils/download.js +1 -1
- package/addon/utils/get-routing-host.js +0 -5
- package/addon/utils/last.js +1 -0
- package/addon/utils/leaflet-icon.js +0 -2
- package/addon/utils/make-dataset.js +1 -1
- package/addon/utils/serialize/normalize-polymorphic-type-within-hash.js +1 -1
- package/addon/utils/serialize/normalize-relations-with-hash.js +0 -1
- package/package.json +1 -1
- package/pnpm-lock.yaml +0 -12750
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# @fleetbase/ember-core
|
|
2
2
|
|
|
3
|
-
Ember Core Services, Utilities and Framework for building Fleetbase Extensions in the Console
|
|
4
|
-
|
|
3
|
+
Ember Core Services, Utilities and Framework for building Fleetbase Extensions in the Console. To start building with Fleetbase, you need to install `@fleetbase/ember-core`, which is built using Ember, a JavaScript framework for building web applications
|
|
5
4
|
|
|
6
5
|
## Compatibility
|
|
7
6
|
|
|
@@ -9,23 +8,17 @@ Ember Core Services, Utilities and Framework for building Fleetbase Extensions i
|
|
|
9
8
|
* Ember CLI v3.24 or above
|
|
10
9
|
* Node.js v14 or above
|
|
11
10
|
|
|
12
|
-
|
|
13
11
|
## Installation
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
ember install @fleetbase/ember-core
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
## Usage
|
|
21
|
-
|
|
22
|
-
[Longer description of how to use the addon in apps.]
|
|
13
|
+
To install ember-core, run:
|
|
23
14
|
|
|
15
|
+
`ember install @fleetbase/ember-core`
|
|
24
16
|
|
|
25
17
|
## Contributing
|
|
26
18
|
|
|
27
|
-
|
|
19
|
+
We welcome contributions to Ember-Core from the Fleetbase community!
|
|
28
20
|
|
|
21
|
+
If you'd like to contribute, please follow the contributing guidelines.
|
|
29
22
|
|
|
30
23
|
## License
|
|
31
24
|
|
|
@@ -9,6 +9,10 @@ import { pluralize } from 'ember-inflector';
|
|
|
9
9
|
import getUserOptions from '../utils/get-user-options';
|
|
10
10
|
import config from 'ember-get-config';
|
|
11
11
|
|
|
12
|
+
if (isBlank(config.API.host)) {
|
|
13
|
+
config.API.host = `${window.location.protocol}//${window.location.hostname}:8000`;
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
export default class ApplicationAdapter extends RESTAdapter {
|
|
13
17
|
/**
|
|
14
18
|
* Inject the `session` service
|
|
@@ -8,7 +8,7 @@ export default function fetchFrom(endpoint, query = {}, options = {}) {
|
|
|
8
8
|
assert('The second argument of the @fetchFrom decorator must be an object', typeof query === 'object');
|
|
9
9
|
assert('The third argument of the @fetchFrom decorator must be an object', typeof options === 'object');
|
|
10
10
|
|
|
11
|
-
return decoratorWithRequiredParams(function (target, key
|
|
11
|
+
return decoratorWithRequiredParams(function (target, key) {
|
|
12
12
|
const symbol = Symbol(`__${key}_fetchFrom`);
|
|
13
13
|
|
|
14
14
|
Object.defineProperty(target, symbol, {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { decoratorWithRequiredParams } from '@ember-decorators/utils/decorator';
|
|
2
2
|
import { assert } from '@ember/debug';
|
|
3
|
-
import { get } from '@ember/object';
|
|
4
3
|
import { getOwner } from '@ember/application';
|
|
5
4
|
import { scheduleOnce } from '@ember/runloop';
|
|
6
5
|
|
|
@@ -9,7 +8,7 @@ export default function fromStore(modelName, query = {}, options = {}) {
|
|
|
9
8
|
assert('The second argument of the @fromStore decorator must be an object', typeof query === 'object');
|
|
10
9
|
assert('The third argument of the @fromStore decorator must be an object', typeof options === 'object');
|
|
11
10
|
|
|
12
|
-
return decoratorWithRequiredParams(function (target, key
|
|
11
|
+
return decoratorWithRequiredParams(function (target, key) {
|
|
13
12
|
const symbol = Symbol(`__${key}_fromStore`);
|
|
14
13
|
|
|
15
14
|
Object.defineProperty(target, symbol, {
|
|
@@ -18,7 +18,7 @@ export default class ApplicationSerializer extends RESTSerializer {
|
|
|
18
18
|
*
|
|
19
19
|
* @var {String}
|
|
20
20
|
*/
|
|
21
|
-
keyForPolymorphicType(key
|
|
21
|
+
keyForPolymorphicType(key) {
|
|
22
22
|
return `${underscore(key)}_type`;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -77,7 +77,6 @@ export default class ApplicationSerializer extends RESTSerializer {
|
|
|
77
77
|
* @param {Array} attributes
|
|
78
78
|
*/
|
|
79
79
|
serializeAttribute(snapshot, json, key, attributes) {
|
|
80
|
-
const { modelName } = snapshot;
|
|
81
80
|
const excludedKeys = ['name', 'meta', 'options', 'config', 'excluded_addons', 'translations', 'tags'];
|
|
82
81
|
|
|
83
82
|
if (snapshot.record?.get('isNew') || snapshot.changedAttributes()[key] || isArray(snapshot.attr(key)) || excludedKeys.includes(key)) {
|
package/addon/services/fetch.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Service from '@ember/service';
|
|
2
2
|
import { tracked } from '@glimmer/tracking';
|
|
3
3
|
import { inject as service } from '@ember/service';
|
|
4
|
-
import { get, set
|
|
4
|
+
import { get, set } from '@ember/object';
|
|
5
5
|
import { isBlank } from '@ember/utils';
|
|
6
6
|
import { dasherize } from '@ember/string';
|
|
7
7
|
import { isArray } from '@ember/array';
|
|
@@ -17,6 +17,10 @@ import download from '../utils/download';
|
|
|
17
17
|
import getUserOptions from '../utils/get-user-options';
|
|
18
18
|
import fetch from 'fetch';
|
|
19
19
|
|
|
20
|
+
if (isBlank(config.API.host)) {
|
|
21
|
+
config.API.host = `${window.location.protocol}//${window.location.hostname}:8000`;
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
export default class FetchService extends Service {
|
|
21
25
|
/**
|
|
22
26
|
* Creates an instance of FetchService.
|
package/addon/services/theme.js
CHANGED
|
@@ -4,7 +4,6 @@ import { inject as service } from '@ember/service';
|
|
|
4
4
|
import { dasherize } from '@ember/string';
|
|
5
5
|
import { isArray } from '@ember/array';
|
|
6
6
|
import { getOwner } from '@ember/application';
|
|
7
|
-
import closeSidebar from '@fleetbase/ember-ui/utils/close-sidebar';
|
|
8
7
|
|
|
9
8
|
export default class ThemeService extends Service {
|
|
10
9
|
/**
|
|
@@ -108,7 +107,6 @@ export default class ThemeService extends Service {
|
|
|
108
107
|
* @void
|
|
109
108
|
*/
|
|
110
109
|
routeWillChange() {
|
|
111
|
-
closeSidebar();
|
|
112
110
|
this.removeRoutebodyClassNames(this.currentRouteBodyClasses);
|
|
113
111
|
}
|
|
114
112
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Model from '@ember-data/model';
|
|
2
2
|
import { isArray } from '@ember/array';
|
|
3
3
|
import { get } from '@ember/object';
|
|
4
|
-
import { isEmpty
|
|
4
|
+
import { isEmpty } from '@ember/utils';
|
|
5
5
|
|
|
6
6
|
const _isEmpty = (value) => {
|
|
7
7
|
let empty = isEmpty(value);
|
package/addon/utils/download.js
CHANGED
|
@@ -148,7 +148,7 @@ export default function download(data, strFileName, strMimeType) {
|
|
|
148
148
|
|
|
149
149
|
// Blob but not URL support:
|
|
150
150
|
reader = new FileReader();
|
|
151
|
-
reader.onload = function (
|
|
151
|
+
reader.onload = function () {
|
|
152
152
|
saver(this.result);
|
|
153
153
|
};
|
|
154
154
|
reader.readAsDataURL(blob);
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { get } from '@ember/object';
|
|
2
2
|
import { isArray } from '@ember/array';
|
|
3
3
|
import { isBlank } from '@ember/utils';
|
|
4
|
-
// import { getOwner } from '@ember/application';
|
|
5
4
|
import config from '@fleetbase/console/config/environment';
|
|
6
5
|
|
|
7
6
|
const isRoutingInCountry = (country, payload, waypoints = []) => {
|
|
8
|
-
// const owner = getOwner(this);
|
|
9
|
-
// const currentUser = owner.lookup(`service:current-user`);
|
|
10
|
-
// const whois = currentUser.getOption('whois');
|
|
11
|
-
|
|
12
7
|
if (isBlank(payload)) {
|
|
13
8
|
payload = {};
|
|
14
9
|
}
|
package/addon/utils/last.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import groupBy from './group-by';
|
|
2
2
|
import { _range } from './range';
|
|
3
|
-
import { format, startOfMonth, endOfMonth,
|
|
3
|
+
import { format, startOfMonth, endOfMonth, addDays } from 'date-fns';
|
|
4
4
|
|
|
5
5
|
function randomInt(min, max) {
|
|
6
6
|
min = Math.ceil(min);
|
|
@@ -11,7 +11,7 @@ export default function serializeNormalizePolymorphicTypeWithinHash(hash) {
|
|
|
11
11
|
if (typeof attr === 'string' && attr.includes('_type') && encodeURI(hash[attr]).includes('%5C')) {
|
|
12
12
|
const emberPolymorphicType = normalizePolymorphicType(hash[attr]);
|
|
13
13
|
const polymorphicRelationType = attr.replace(`_type`, ``);
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
hash[attr] = emberPolymorphicType;
|
|
16
16
|
|
|
17
17
|
// set the type of relationship using the polymorphic relation attr
|
package/package.json
CHANGED