@fleetbase/ember-core 0.0.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/LICENSE.md +9 -0
- package/README.md +32 -0
- package/addon/adapters/application.js +155 -0
- package/addon/adapters/user.js +19 -0
- package/addon/authenticators/fleetbase.js +72 -0
- package/addon/decorators/fetch-from.js +55 -0
- package/addon/decorators/from-store.js +56 -0
- package/addon/decorators/is-equal.js +15 -0
- package/addon/exports/host-services.js +18 -0
- package/addon/exports/services.js +18 -0
- package/addon/initializers/local-storage-adapter.js +21 -0
- package/addon/serializers/application.js +87 -0
- package/addon/services/app-cache.js +59 -0
- package/addon/services/crud.js +226 -0
- package/addon/services/current-user.js +259 -0
- package/addon/services/fetch.js +648 -0
- package/addon/services/filters.js +183 -0
- package/addon/services/loader.js +136 -0
- package/addon/services/notifications.js +32 -0
- package/addon/services/session.js +221 -0
- package/addon/services/theme.js +200 -0
- package/addon/services/url-search-params.js +92 -0
- package/addon/transforms/array.js +29 -0
- package/addon/transforms/object.js +11 -0
- package/addon/transforms/raw.js +11 -0
- package/addon/utils/api-url.js +11 -0
- package/addon/utils/apply-column-filters.js +3 -0
- package/addon/utils/auto-serialize.js +100 -0
- package/addon/utils/calculate-percentage.js +3 -0
- package/addon/utils/close-sidebar.js +7 -0
- package/addon/utils/console-url.js +56 -0
- package/addon/utils/copy-to-clipboard.js +35 -0
- package/addon/utils/corslite.js +95 -0
- package/addon/utils/download.js +157 -0
- package/addon/utils/env.js +3 -0
- package/addon/utils/extract-coordinates.js +35 -0
- package/addon/utils/extract-latitude.js +28 -0
- package/addon/utils/extract-longitude.js +28 -0
- package/addon/utils/find-closest-waypoint.js +20 -0
- package/addon/utils/first.js +10 -0
- package/addon/utils/frontend-url.js +30 -0
- package/addon/utils/generate-slug.js +11 -0
- package/addon/utils/generate-uuid.js +3 -0
- package/addon/utils/get-length-units.js +44 -0
- package/addon/utils/get-meta-field-types.js +3 -0
- package/addon/utils/get-mime-type.js +25 -0
- package/addon/utils/get-model-name.js +45 -0
- package/addon/utils/get-permission-action.js +47 -0
- package/addon/utils/get-permission-resource.js +16 -0
- package/addon/utils/get-pod-methods.js +7 -0
- package/addon/utils/get-routing-host.js +44 -0
- package/addon/utils/get-service-name.js +21 -0
- package/addon/utils/get-user-options.js +21 -0
- package/addon/utils/get-weight-units.js +32 -0
- package/addon/utils/get-with-default.js +6 -0
- package/addon/utils/group-api-events.js +20 -0
- package/addon/utils/group-by.js +26 -0
- package/addon/utils/has-extension.js +11 -0
- package/addon/utils/has-json-structure.js +10 -0
- package/addon/utils/hason-structure.js +3 -0
- package/addon/utils/haversine.js +59 -0
- package/addon/utils/humanize.js +16 -0
- package/addon/utils/is-electron.js +18 -0
- package/addon/utils/is-email.js +5 -0
- package/addon/utils/is-function.js +3 -0
- package/addon/utils/is-image-file.js +3 -0
- package/addon/utils/is-iterable.js +7 -0
- package/addon/utils/is-json.js +9 -0
- package/addon/utils/is-latitude.js +3 -0
- package/addon/utils/is-letter.js +3 -0
- package/addon/utils/is-longitude.js +3 -0
- package/addon/utils/is-model.js +6 -0
- package/addon/utils/is-not-empty.js +5 -0
- package/addon/utils/is-not-model.js +5 -0
- package/addon/utils/is-numeric.js +3 -0
- package/addon/utils/is-object.js +3 -0
- package/addon/utils/is-proxy.js +5 -0
- package/addon/utils/is-relation-missing.js +21 -0
- package/addon/utils/is-valid-coordinates.js +38 -0
- package/addon/utils/is-video-file.js +3 -0
- package/addon/utils/is-waypoint-record.js +5 -0
- package/addon/utils/ison.js +3 -0
- package/addon/utils/isset.js +10 -0
- package/addon/utils/last.js +23 -0
- package/addon/utils/lazy-load-script.js +25 -0
- package/addon/utils/leaflet-icon.js +13 -0
- package/addon/utils/leaflet-points-from-coordinates.js +3 -0
- package/addon/utils/load-engines.js +37 -0
- package/addon/utils/load-extensions.js +8 -0
- package/addon/utils/macros/group-by.js +28 -0
- package/addon/utils/make-dataset.js +57 -0
- package/addon/utils/map-engines.js +30 -0
- package/addon/utils/mock-response.js +15 -0
- package/addon/utils/numbers-only.js +11 -0
- package/addon/utils/past-tense.js +40 -0
- package/addon/utils/path-to-route.js +10 -0
- package/addon/utils/polyline.js +161 -0
- package/addon/utils/range.js +19 -0
- package/addon/utils/refresh-route.js +3 -0
- package/addon/utils/replace-table-row.js +17 -0
- package/addon/utils/reverse-point.js +3 -0
- package/addon/utils/serialize/normalize-polymorphic-type-within-hash.js +27 -0
- package/addon/utils/serialize/normalize-polymorphic-type.js +13 -0
- package/addon/utils/serialize/normalize-relations-with-hash.js +32 -0
- package/addon/utils/set-column-filter-options.js +3 -0
- package/addon/utils/strip-html.js +3 -0
- package/addon/utils/to-leaflet-bounds.js +6 -0
- package/addon/utils/to-model.js +18 -0
- package/addon/utils/waypoint-label.js +3 -0
- package/addon/utils/with-default-value.js +5 -0
- package/addon/utils/words.js +5 -0
- package/app/adapters/user.js +1 -0
- package/app/authenticators/fleetbase.js +1 -0
- package/app/decorators/fetch-from.js +1 -0
- package/app/decorators/from-store.js +1 -0
- package/app/decorators/is-equal.js +1 -0
- package/app/exports/host-services.js +1 -0
- package/app/exports/services.js +1 -0
- package/app/initializers/local-storage-adapter.js +1 -0
- package/app/serializers/application.js +1 -0
- package/app/services/app-cache.js +1 -0
- package/app/services/crud.js +1 -0
- package/app/services/current-user.js +1 -0
- package/app/services/fetch.js +1 -0
- package/app/services/filters.js +1 -0
- package/app/services/loader.js +1 -0
- package/app/services/notifications.js +1 -0
- package/app/services/session.js +1 -0
- package/app/services/theme.js +1 -0
- package/app/services/url-search-params.js +1 -0
- package/app/storages/local-cache.js +12 -0
- package/app/storages/user-options.js +12 -0
- package/app/transforms/array.js +1 -0
- package/app/transforms/object.js +1 -0
- package/app/transforms/raw.js +1 -0
- package/app/utils/api-url.js +1 -0
- package/app/utils/apply-column-filters.js +1 -0
- package/app/utils/auto-serialize.js +1 -0
- package/app/utils/calculate-percentage.js +1 -0
- package/app/utils/close-sidebar.js +1 -0
- package/app/utils/console-url.js +1 -0
- package/app/utils/copy-to-clipboard.js +1 -0
- package/app/utils/corslite.js +1 -0
- package/app/utils/download.js +1 -0
- package/app/utils/env.js +1 -0
- package/app/utils/extract-coordinates.js +1 -0
- package/app/utils/extract-latitude.js +1 -0
- package/app/utils/extract-longitude.js +1 -0
- package/app/utils/find-closest-waypoint.js +1 -0
- package/app/utils/first.js +1 -0
- package/app/utils/frontend-url.js +1 -0
- package/app/utils/generate-slug.js +1 -0
- package/app/utils/generate-uuid.js +1 -0
- package/app/utils/get-length-units.js +1 -0
- package/app/utils/get-meta-field-types.js +1 -0
- package/app/utils/get-mime-type.js +1 -0
- package/app/utils/get-model-name.js +1 -0
- package/app/utils/get-permission-action.js +1 -0
- package/app/utils/get-permission-resource.js +1 -0
- package/app/utils/get-pod-methods.js +1 -0
- package/app/utils/get-routing-host.js +1 -0
- package/app/utils/get-service-name.js +1 -0
- package/app/utils/get-user-options.js +1 -0
- package/app/utils/get-weight-units.js +1 -0
- package/app/utils/get-with-default.js +1 -0
- package/app/utils/group-api-events.js +1 -0
- package/app/utils/group-by.js +1 -0
- package/app/utils/has-extension.js +1 -0
- package/app/utils/has-json-structure.js +1 -0
- package/app/utils/hason-structure.js +1 -0
- package/app/utils/haversine.js +1 -0
- package/app/utils/humanize.js +1 -0
- package/app/utils/is-electron.js +1 -0
- package/app/utils/is-email.js +1 -0
- package/app/utils/is-function.js +1 -0
- package/app/utils/is-image-file.js +1 -0
- package/app/utils/is-iterable.js +1 -0
- package/app/utils/is-latitude.js +1 -0
- package/app/utils/is-letter.js +1 -0
- package/app/utils/is-longitude.js +1 -0
- package/app/utils/is-model.js +1 -0
- package/app/utils/is-not-empty.js +1 -0
- package/app/utils/is-not-model.js +1 -0
- package/app/utils/is-numeric.js +1 -0
- package/app/utils/is-object.js +1 -0
- package/app/utils/is-proxy.js +1 -0
- package/app/utils/is-relation-missing.js +1 -0
- package/app/utils/is-valid-coordinates.js +1 -0
- package/app/utils/is-video-file.js +1 -0
- package/app/utils/is-waypoint-record.js +1 -0
- package/app/utils/ison.js +1 -0
- package/app/utils/isset.js +1 -0
- package/app/utils/last.js +1 -0
- package/app/utils/lazy-load-script.js +1 -0
- package/app/utils/leaflet-icon.js +1 -0
- package/app/utils/leaflet-points-from-coordinates.js +1 -0
- package/app/utils/load-engines.js +1 -0
- package/app/utils/load-extensions.js +1 -0
- package/app/utils/macros/group-by.js +1 -0
- package/app/utils/make-dataset.js +1 -0
- package/app/utils/map-engines.js +1 -0
- package/app/utils/mock-response.js +1 -0
- package/app/utils/numbers-only.js +1 -0
- package/app/utils/past-tense.js +1 -0
- package/app/utils/path-to-route.js +1 -0
- package/app/utils/polyline.js +1 -0
- package/app/utils/range.js +1 -0
- package/app/utils/refresh-route.js +1 -0
- package/app/utils/replace-table-row.js +1 -0
- package/app/utils/reverse-point.js +1 -0
- package/app/utils/serialize/normalize-polymorphic-type-within-hash.js +1 -0
- package/app/utils/serialize/normalize-polymorphic-type.js +1 -0
- package/app/utils/serialize/normalize-relations-with-hash.js +1 -0
- package/app/utils/set-column-filter-options.js +1 -0
- package/app/utils/strip-html.js +1 -0
- package/app/utils/to-leaflet-bounds.js +1 -0
- package/app/utils/to-model.js +1 -0
- package/app/utils/waypoint-label.js +1 -0
- package/app/utils/with-default-value.js +1 -0
- package/app/utils/words.js +1 -0
- package/config/environment.js +5 -0
- package/index.js +26 -0
- package/package.json +117 -0
- package/pnpm-lock.yaml +12750 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Based off of [the offical Google document](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)
|
|
5
|
+
*
|
|
6
|
+
* Some parts from [this implementation](http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/PolylineEncoder.js)
|
|
7
|
+
* by [Mark McClure](http://facstaff.unca.edu/mcmcclur/)
|
|
8
|
+
*
|
|
9
|
+
* @module polyline
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
var polyline = {};
|
|
13
|
+
|
|
14
|
+
function py2_round(value) {
|
|
15
|
+
// Google's polyline algorithm uses the same rounding strategy as Python 2, which is different from JS for negative values
|
|
16
|
+
return Math.floor(Math.abs(value) + 0.5) * (value >= 0 ? 1 : -1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function encode(current, previous, factor) {
|
|
20
|
+
current = py2_round(current * factor);
|
|
21
|
+
previous = py2_round(previous * factor);
|
|
22
|
+
var coordinate = current - previous;
|
|
23
|
+
coordinate <<= 1;
|
|
24
|
+
if (current - previous < 0) {
|
|
25
|
+
coordinate = ~coordinate;
|
|
26
|
+
}
|
|
27
|
+
var output = '';
|
|
28
|
+
while (coordinate >= 0x20) {
|
|
29
|
+
output += String.fromCharCode((0x20 | (coordinate & 0x1f)) + 63);
|
|
30
|
+
coordinate >>= 5;
|
|
31
|
+
}
|
|
32
|
+
output += String.fromCharCode(coordinate + 63);
|
|
33
|
+
return output;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Decodes to a [latitude, longitude] coordinates array.
|
|
38
|
+
*
|
|
39
|
+
* This is adapted from the implementation in Project-OSRM.
|
|
40
|
+
*
|
|
41
|
+
* @param {String} str
|
|
42
|
+
* @param {Number} precision
|
|
43
|
+
* @returns {Array}
|
|
44
|
+
*
|
|
45
|
+
* @see https://github.com/Project-OSRM/osrm-frontend/blob/master/WebContent/routing/OSRM.RoutingGeometry.js
|
|
46
|
+
*/
|
|
47
|
+
polyline.decode = function (str, precision) {
|
|
48
|
+
var index = 0,
|
|
49
|
+
lat = 0,
|
|
50
|
+
lng = 0,
|
|
51
|
+
coordinates = [],
|
|
52
|
+
shift = 0,
|
|
53
|
+
result = 0,
|
|
54
|
+
byte = null,
|
|
55
|
+
latitude_change,
|
|
56
|
+
longitude_change,
|
|
57
|
+
factor = Math.pow(10, Number.isInteger(precision) ? precision : 5);
|
|
58
|
+
|
|
59
|
+
// Coordinates have variable length when encoded, so just keep
|
|
60
|
+
// track of whether we've hit the end of the string. In each
|
|
61
|
+
// loop iteration, a single coordinate is decoded.
|
|
62
|
+
while (index < str.length) {
|
|
63
|
+
// Reset shift, result, and byte
|
|
64
|
+
byte = null;
|
|
65
|
+
shift = 0;
|
|
66
|
+
result = 0;
|
|
67
|
+
|
|
68
|
+
do {
|
|
69
|
+
byte = str.charCodeAt(index++) - 63;
|
|
70
|
+
result |= (byte & 0x1f) << shift;
|
|
71
|
+
shift += 5;
|
|
72
|
+
} while (byte >= 0x20);
|
|
73
|
+
|
|
74
|
+
latitude_change = result & 1 ? ~(result >> 1) : result >> 1;
|
|
75
|
+
|
|
76
|
+
shift = result = 0;
|
|
77
|
+
|
|
78
|
+
do {
|
|
79
|
+
byte = str.charCodeAt(index++) - 63;
|
|
80
|
+
result |= (byte & 0x1f) << shift;
|
|
81
|
+
shift += 5;
|
|
82
|
+
} while (byte >= 0x20);
|
|
83
|
+
|
|
84
|
+
longitude_change = result & 1 ? ~(result >> 1) : result >> 1;
|
|
85
|
+
|
|
86
|
+
lat += latitude_change;
|
|
87
|
+
lng += longitude_change;
|
|
88
|
+
|
|
89
|
+
coordinates.push([lat / factor, lng / factor]);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return coordinates;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Encodes the given [latitude, longitude] coordinates array.
|
|
97
|
+
*
|
|
98
|
+
* @param {Array.<Array.<Number>>} coordinates
|
|
99
|
+
* @param {Number} precision
|
|
100
|
+
* @returns {String}
|
|
101
|
+
*/
|
|
102
|
+
polyline.encode = function (coordinates, precision) {
|
|
103
|
+
if (!coordinates.length) {
|
|
104
|
+
return '';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
var factor = Math.pow(10, Number.isInteger(precision) ? precision : 5),
|
|
108
|
+
output = encode(coordinates[0][0], 0, factor) + encode(coordinates[0][1], 0, factor);
|
|
109
|
+
|
|
110
|
+
for (var i = 1; i < coordinates.length; i++) {
|
|
111
|
+
var a = coordinates[i],
|
|
112
|
+
b = coordinates[i - 1];
|
|
113
|
+
output += encode(a[0], b[0], factor);
|
|
114
|
+
output += encode(a[1], b[1], factor);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return output;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
function flipped(coords) {
|
|
121
|
+
var flipped = [];
|
|
122
|
+
for (var i = 0; i < coords.length; i++) {
|
|
123
|
+
var coord = coords[i].slice();
|
|
124
|
+
flipped.push([coord[1], coord[0]]);
|
|
125
|
+
}
|
|
126
|
+
return flipped;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Encodes a GeoJSON LineString feature/geometry.
|
|
131
|
+
*
|
|
132
|
+
* @param {Object} geojson
|
|
133
|
+
* @param {Number} precision
|
|
134
|
+
* @returns {String}
|
|
135
|
+
*/
|
|
136
|
+
polyline.fromGeoJSON = function (geojson, precision) {
|
|
137
|
+
if (geojson && geojson.type === 'Feature') {
|
|
138
|
+
geojson = geojson.geometry;
|
|
139
|
+
}
|
|
140
|
+
if (!geojson || geojson.type !== 'LineString') {
|
|
141
|
+
throw new Error('Input must be a GeoJSON LineString');
|
|
142
|
+
}
|
|
143
|
+
return polyline.encode(flipped(geojson.coordinates), precision);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Decodes to a GeoJSON LineString geometry.
|
|
148
|
+
*
|
|
149
|
+
* @param {String} str
|
|
150
|
+
* @param {Number} precision
|
|
151
|
+
* @returns {Object}
|
|
152
|
+
*/
|
|
153
|
+
polyline.toGeoJSON = function (str, precision) {
|
|
154
|
+
var coords = polyline.decode(str, precision);
|
|
155
|
+
return {
|
|
156
|
+
type: 'LineString',
|
|
157
|
+
coordinates: flipped(coords),
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export default polyline;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import isNumeric from './is-numeric';
|
|
2
|
+
import isLetter from './is-letter';
|
|
3
|
+
|
|
4
|
+
const _range = (start, end) => {
|
|
5
|
+
return [...Array(end - start + 1).keys()].map((i) => i + start);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { _range };
|
|
9
|
+
export default function range(start, end) {
|
|
10
|
+
if (isNumeric(start) && isNumeric(end)) {
|
|
11
|
+
return _range(start, end);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (isLetter(start) && isLetter(end)) {
|
|
15
|
+
return [...String.fromCharCode(..._range(start.charCodeAt(0), end.charCodeAt(0)))];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return _range(start, end);
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { get } from '@ember/object';
|
|
2
|
+
|
|
3
|
+
export default function replaceTableRow(table, newRow, findBy) {
|
|
4
|
+
const rows = table.rows.content;
|
|
5
|
+
let rowIndex = false;
|
|
6
|
+
if (typeof findBy === 'string') {
|
|
7
|
+
rowIndex = rows.findIndex((row) => get(row, findBy) === get(newRow, findBy));
|
|
8
|
+
} else if (typeof findBy === 'function') {
|
|
9
|
+
rowIndex = rows.findIndex(findBy);
|
|
10
|
+
}
|
|
11
|
+
if (rowIndex) {
|
|
12
|
+
table.removeRowAt(rowIndex);
|
|
13
|
+
table.insertRowAt(rowIndex, newRow);
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import normalizePolymorphicType from './normalize-polymorphic-type';
|
|
2
|
+
import { isBlank } from '@ember/utils';
|
|
3
|
+
import { set } from '@ember/object';
|
|
4
|
+
|
|
5
|
+
export default function serializeNormalizePolymorphicTypeWithinHash(hash) {
|
|
6
|
+
if (typeof hash !== 'object') {
|
|
7
|
+
return hash;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
for (let attr in hash) {
|
|
11
|
+
if (typeof attr === 'string' && attr.includes('_type') && encodeURI(hash[attr]).includes('%5C')) {
|
|
12
|
+
const emberPolymorphicType = normalizePolymorphicType(hash[attr]);
|
|
13
|
+
const polymorphicRelationType = attr.replace(`_type`, ``);
|
|
14
|
+
|
|
15
|
+
hash[attr] = emberPolymorphicType;
|
|
16
|
+
|
|
17
|
+
// set the type of relationship using the polymorphic relation attr
|
|
18
|
+
if (hash[polymorphicRelationType] && !isBlank(hash[polymorphicRelationType])) {
|
|
19
|
+
if (hash[polymorphicRelationType].type) {
|
|
20
|
+
set(hash, `${polymorphicRelationType}._type`, hash[polymorphicRelationType].type);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return hash;
|
|
27
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const lowercase = (string) => string.toLowerCase();
|
|
2
|
+
|
|
3
|
+
export default function serializeNormalizePolymorphicType(polymorphicTypeValue, defaultValue = null) {
|
|
4
|
+
// encode first
|
|
5
|
+
const encodedPolymorphicTypeValue = encodeURI(polymorphicTypeValue);
|
|
6
|
+
// if encoded is invalid send the default value or the original value back
|
|
7
|
+
if (!encodedPolymorphicTypeValue.includes('%5C')) {
|
|
8
|
+
return defaultValue || polymorphicTypeValue;
|
|
9
|
+
}
|
|
10
|
+
// from fleetbase api should be something like Fleetbase\Models\Model
|
|
11
|
+
// change value to ember-data polymorphic type
|
|
12
|
+
return lowercase(encodedPolymorphicTypeValue.split('%5C').reverse()[0]);
|
|
13
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import isModel from '../is-model';
|
|
2
|
+
import { get, setProperties } from '@ember/object';
|
|
3
|
+
import { isBlank } from '@ember/utils';
|
|
4
|
+
|
|
5
|
+
export default function serializeNormalizeRelationsWithinHash(hash, primaryKey = 'uuid') {
|
|
6
|
+
if (typeof hash !== 'object') {
|
|
7
|
+
return hash;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
for (let attr in hash) {
|
|
11
|
+
if (typeof attr === 'string' && attr.includes('_uuid')) {
|
|
12
|
+
// console.log(attr, hash[attr]);
|
|
13
|
+
if (typeof hash[attr] === 'object' && !isBlank(hash[attr])) {
|
|
14
|
+
// the relation has loaded back into `_uuid` - change this to the proper `uuid` string value and set the relationship
|
|
15
|
+
const relation = hash[attr];
|
|
16
|
+
const id = get(relation, primaryKey);
|
|
17
|
+
const relationAttr = attr.replace('_uuid', '');
|
|
18
|
+
|
|
19
|
+
// console.log(`normalizing relation ${relationAttr} from ${attr}`);
|
|
20
|
+
// console.log(relationAttr, relation);
|
|
21
|
+
// console.log(attr, id);
|
|
22
|
+
|
|
23
|
+
setProperties(hash, {
|
|
24
|
+
[relationAttr]: relation,
|
|
25
|
+
[attr]: id,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return hash;
|
|
32
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import CoreObject from '@ember/object/core';
|
|
2
|
+
import { getOwner } from '@ember/application';
|
|
3
|
+
|
|
4
|
+
class ToModel extends CoreObject {
|
|
5
|
+
fn(record, modelName) {
|
|
6
|
+
const owner = getOwner(this);
|
|
7
|
+
const store = owner.lookup('service:store');
|
|
8
|
+
const normalized = store.normalize(modelName, record);
|
|
9
|
+
|
|
10
|
+
return store.push(normalized);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const toModel = (record, modelName) => {
|
|
15
|
+
return ToModel.create().fn(record, modelName);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default toModel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/adapters/user';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/authenticators/fleetbase';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/decorators/fetch-from';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/decorators/from-store';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/decorators/is-equal';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/exports/host-services';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/exports/services';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, initialize } from '@fleetbase/ember-core/initializers/local-storage-adapter';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/serializers/application';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/services/app-cache';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/services/crud';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/services/current-user';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/services/fetch';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/services/filters';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/services/loader';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/services/notifications';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/services/session';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/services/theme';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/services/url-search-params';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import StorageObject from 'ember-local-storage/local/object';
|
|
2
|
+
|
|
3
|
+
const Storage = StorageObject.extend();
|
|
4
|
+
|
|
5
|
+
// Uncomment if you would like to set initialState
|
|
6
|
+
// Storage.reopenClass({
|
|
7
|
+
// initialState() {
|
|
8
|
+
// return {};
|
|
9
|
+
// }
|
|
10
|
+
// });
|
|
11
|
+
|
|
12
|
+
export default Storage;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import StorageObject from 'ember-local-storage/local/object';
|
|
2
|
+
|
|
3
|
+
const Storage = StorageObject.extend();
|
|
4
|
+
|
|
5
|
+
// Uncomment if you would like to set initialState
|
|
6
|
+
// Storage.reopenClass({
|
|
7
|
+
// initialState() {
|
|
8
|
+
// return {};
|
|
9
|
+
// }
|
|
10
|
+
// });
|
|
11
|
+
|
|
12
|
+
export default Storage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/transforms/array';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/transforms/object';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/transforms/raw';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/api-url';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/apply-column-filters';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/auto-serialize';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/calculate-percentage';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/close-sidebar';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/console-url';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/copy-to-clipboard';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/corslite';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/download';
|
package/app/utils/env.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/env';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/extract-coordinates';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/extract-latitude';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/extract-longitude';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/find-closest-waypoint';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/first';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/frontend-url';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/generate-slug';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/generate-uuid';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/get-length-units';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/get-meta-field-types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/get-mime-type';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/get-model-name';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/get-permission-action';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/get-permission-resource';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/get-pod-methods';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/get-routing-host';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/get-service-name';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/get-user-options';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/get-weight-units';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/get-with-default';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/group-api-events';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/group-by';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/has-extension';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/has-json-structure';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/hason-structure';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/haversine';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/humanize';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/is-electron';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/is-email';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/is-function';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/is-image-file';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/is-iterable';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/is-latitude';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/is-letter';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/is-longitude';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/is-model';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/is-not-empty';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/is-not-model';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/is-numeric';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/is-object';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/ember-core/utils/is-proxy';
|