@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,20 @@
|
|
|
1
|
+
import { isArray } from '@ember/array';
|
|
2
|
+
|
|
3
|
+
export default function groupApiEvents(webhookEvents = []) {
|
|
4
|
+
const groups = {};
|
|
5
|
+
|
|
6
|
+
if (isArray(webhookEvents)) {
|
|
7
|
+
for (let i = 0; i < webhookEvents.length; i++) {
|
|
8
|
+
const event = webhookEvents[i];
|
|
9
|
+
const eventResource = event.split('.')[0];
|
|
10
|
+
if (!groups[eventResource]) {
|
|
11
|
+
groups[eventResource] = [];
|
|
12
|
+
}
|
|
13
|
+
if (event.includes(eventResource)) {
|
|
14
|
+
groups[eventResource].push(event);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return groups;
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { get } from '@ember/object';
|
|
2
|
+
|
|
3
|
+
export default function groupBy(arr, key) {
|
|
4
|
+
let grouped = {};
|
|
5
|
+
let _key;
|
|
6
|
+
|
|
7
|
+
for (let i = 0; i < arr.length; i++) {
|
|
8
|
+
const item = arr.objectAt(i);
|
|
9
|
+
|
|
10
|
+
if (typeof key === 'string') {
|
|
11
|
+
_key = get(item, key);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (typeof key === 'function') {
|
|
15
|
+
_key = key(item, i);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (!grouped[_key]) {
|
|
19
|
+
grouped[_key] = [];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
grouped[_key].pushObject(item);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return grouped;
|
|
26
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default function hasJsonStructure(str) {
|
|
2
|
+
if (typeof str !== 'string') return false;
|
|
3
|
+
try {
|
|
4
|
+
const result = JSON.parse(str);
|
|
5
|
+
const type = Object.prototype.toString.call(result);
|
|
6
|
+
return type === '[object Object]' || type === '[object Array]';
|
|
7
|
+
} catch (err) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var haversine = (function () {
|
|
2
|
+
var RADII = {
|
|
3
|
+
km: 6371,
|
|
4
|
+
mile: 3960,
|
|
5
|
+
meter: 6371000,
|
|
6
|
+
nmi: 3440,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
// convert to radians
|
|
10
|
+
var toRad = function (num) {
|
|
11
|
+
return (num * Math.PI) / 180;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// convert coordinates to standard format based on the passed format option
|
|
15
|
+
var convertCoordinates = function (format, coordinates) {
|
|
16
|
+
switch (format) {
|
|
17
|
+
case '[lat,lon]':
|
|
18
|
+
return { latitude: coordinates[0], longitude: coordinates[1] };
|
|
19
|
+
case '[lon,lat]':
|
|
20
|
+
return { latitude: coordinates[1], longitude: coordinates[0] };
|
|
21
|
+
case '{lon,lat}':
|
|
22
|
+
return { latitude: coordinates.lat, longitude: coordinates.lon };
|
|
23
|
+
case '{lat,lng}':
|
|
24
|
+
return { latitude: coordinates.lat, longitude: coordinates.lng };
|
|
25
|
+
case 'geojson':
|
|
26
|
+
return {
|
|
27
|
+
latitude: coordinates.geometry.coordinates[1],
|
|
28
|
+
longitude: coordinates.geometry.coordinates[0],
|
|
29
|
+
};
|
|
30
|
+
default:
|
|
31
|
+
return coordinates;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return function haversine(startCoordinates, endCoordinates, options) {
|
|
36
|
+
options = options || {};
|
|
37
|
+
|
|
38
|
+
var R = options.unit in RADII ? RADII[options.unit] : RADII.km;
|
|
39
|
+
|
|
40
|
+
var start = convertCoordinates(options.format, startCoordinates);
|
|
41
|
+
var end = convertCoordinates(options.format, endCoordinates);
|
|
42
|
+
|
|
43
|
+
var dLat = toRad(end.latitude - start.latitude);
|
|
44
|
+
var dLon = toRad(end.longitude - start.longitude);
|
|
45
|
+
var lat1 = toRad(start.latitude);
|
|
46
|
+
var lat2 = toRad(end.latitude);
|
|
47
|
+
|
|
48
|
+
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(lat1) * Math.cos(lat2);
|
|
49
|
+
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
50
|
+
|
|
51
|
+
if (options.threshold) {
|
|
52
|
+
return options.threshold > R * c;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return R * c;
|
|
56
|
+
};
|
|
57
|
+
})();
|
|
58
|
+
|
|
59
|
+
export default haversine;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { humanize as humanizeString } from 'ember-cli-string-helpers/helpers/humanize';
|
|
2
|
+
|
|
3
|
+
export default function humanize(string) {
|
|
4
|
+
const uppercase = ['api', 'vat', 'id', 'uuid', 'sku', 'ean', 'upc', 'erp', 'tms', 'wms', 'ltl', 'ftl', 'lcl', 'fcl', 'rfid', 'jot', 'roi', 'eta', 'pod', 'asn', 'oem', 'ddp', 'fob'];
|
|
5
|
+
|
|
6
|
+
return humanizeString([string])
|
|
7
|
+
.split(' ')
|
|
8
|
+
.map((word) => {
|
|
9
|
+
if (uppercase.includes(word.toLowerCase())) {
|
|
10
|
+
return word.toUpperCase();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return word;
|
|
14
|
+
})
|
|
15
|
+
.join(' ');
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default function isElectron() {
|
|
2
|
+
// Renderer process
|
|
3
|
+
if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// Main process
|
|
8
|
+
if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Detect the user agent when the `nodeIntegration` option is set to true
|
|
13
|
+
if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import isset from './isset';
|
|
2
|
+
import isModel from './is-model';
|
|
3
|
+
import { underscore } from '@ember/string';
|
|
4
|
+
|
|
5
|
+
export default function isRelationMissing(model, relation, options = {}) {
|
|
6
|
+
if (!isModel(model)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
relation = underscore(relation);
|
|
11
|
+
|
|
12
|
+
const isMissingRelation = isset(model, `${relation}_uuid`) && !isset(model, ``);
|
|
13
|
+
const isNotMissingPolymorphicType = isset(model, `${relation}_type`);
|
|
14
|
+
|
|
15
|
+
if (isset(options, 'polymorphic') && options.polymorphic === true) {
|
|
16
|
+
// no relation is set, so false
|
|
17
|
+
return isNotMissingPolymorphicType && isset(model, `${relation}_uuid`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return isMissingRelation;
|
|
21
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { isArray } from '@ember/array';
|
|
2
|
+
import isLatitude from './is-latitude';
|
|
3
|
+
import isLongitude from './is-longitude';
|
|
4
|
+
import isObject from './is-object';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Validates coordinates
|
|
8
|
+
*
|
|
9
|
+
* ```
|
|
10
|
+
* isValidCoordinates([0, 0]);
|
|
11
|
+
* isValidCoordinates({lat: 0, lng: 0});
|
|
12
|
+
* isValidCoordinates({latitude: 0, longitude: 0});
|
|
13
|
+
* isValidCoordinates(0, 0);
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param {Array|Object|Integer} latitude
|
|
17
|
+
* @param {Array|Object|Integer} longitude
|
|
18
|
+
*/
|
|
19
|
+
export default function isValidCoordinates(latitude, longitude = null) {
|
|
20
|
+
let testLatitude, testLongitude;
|
|
21
|
+
|
|
22
|
+
if (isArray(latitude) && longitude === null) {
|
|
23
|
+
testLatitude = latitude[0];
|
|
24
|
+
testLongitude = latitude[1];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!isArray(latitude) && isObject(latitude) && longitude === null) {
|
|
28
|
+
testLatitude = latitude.lat || latitude.latitude;
|
|
29
|
+
testLongitude = latitude.lng || latitude.longitude;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (longitude !== null) {
|
|
33
|
+
testLatitude = latitude;
|
|
34
|
+
testLongitude = longitude;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return isLatitude(testLatitude) && isLongitude(testLongitude);
|
|
38
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isArray } from '@ember/array';
|
|
2
|
+
|
|
3
|
+
const isNumber = (value) => typeof value === 'number' && isFinite(value);
|
|
4
|
+
|
|
5
|
+
export default function last(arr, n = 1) {
|
|
6
|
+
if (!isArray(arr) || arr.length === 0) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
n = isNumber(n) ? +n : 1;
|
|
11
|
+
|
|
12
|
+
if (n === 1) {
|
|
13
|
+
return arr[arr.length - 1];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let res = new Array(n);
|
|
17
|
+
|
|
18
|
+
while (n--) {
|
|
19
|
+
res[n] = arr[--len];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return res;
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { guidFor } from '@ember/object/internals';
|
|
2
|
+
|
|
3
|
+
export default function lazyLoadScript(path) {
|
|
4
|
+
return new Promise(function (resolve, reject) {
|
|
5
|
+
const id = guidFor(path);
|
|
6
|
+
|
|
7
|
+
if (document.getElementById(id)) {
|
|
8
|
+
return resolve();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const element = document.createElement('script');
|
|
12
|
+
element.id = id;
|
|
13
|
+
element.src = path;
|
|
14
|
+
|
|
15
|
+
element.addEventListener('load', function () {
|
|
16
|
+
resolve();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
element.addEventListener('error', function () {
|
|
20
|
+
reject(`Failed to load script (${path})`);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
document.getElementsByTagName('head')[0].appendChild(element);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* global L */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents an icon to provide when creating a marker.
|
|
5
|
+
* More information about its possible options [here](https://leafletjs.com/reference-1.7.1.html#icon-option).
|
|
6
|
+
*
|
|
7
|
+
* @function leafletIcon
|
|
8
|
+
* @param {Object} options the Icon options object
|
|
9
|
+
* @return {Icon}
|
|
10
|
+
*/
|
|
11
|
+
export default function leafletIcon(options = {}) {
|
|
12
|
+
return L.icon(options);
|
|
13
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { dasherize } from '@ember/string';
|
|
2
|
+
import hostServices from '../exports/host-services';
|
|
3
|
+
|
|
4
|
+
export default async function loadEngines(appInstance, withServices = []) {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
return fetch('extensions.json')
|
|
7
|
+
.then((resp) => resp.json())
|
|
8
|
+
.then((extensions) => {
|
|
9
|
+
const engines = {};
|
|
10
|
+
const externalRoutes = {
|
|
11
|
+
console: 'console.home',
|
|
12
|
+
extensions: 'console.extensions',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
16
|
+
const extension = extensions[i];
|
|
17
|
+
const path = dasherize(extension.extension);
|
|
18
|
+
|
|
19
|
+
externalRoutes[path] = `console.${path}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
23
|
+
const extension = extensions[i];
|
|
24
|
+
|
|
25
|
+
engines[extension.name] = {
|
|
26
|
+
dependencies: {
|
|
27
|
+
services: [...hostServices, ...withServices],
|
|
28
|
+
externalRoutes,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
resolve(engines);
|
|
34
|
+
})
|
|
35
|
+
.catch(reject);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { A } from '@ember/array';
|
|
2
|
+
import { computed, get } from '@ember/object';
|
|
3
|
+
import { isPresent } from '@ember/utils';
|
|
4
|
+
|
|
5
|
+
export default function groupBy(collection, property) {
|
|
6
|
+
let dependentKey = collection + '.@each.' + property;
|
|
7
|
+
|
|
8
|
+
return computed(dependentKey, function () {
|
|
9
|
+
let groups = A();
|
|
10
|
+
let items = get(this, collection);
|
|
11
|
+
|
|
12
|
+
if (items) {
|
|
13
|
+
items.forEach(function (item) {
|
|
14
|
+
let value = get(item, property);
|
|
15
|
+
let group = groups.findBy('value', value);
|
|
16
|
+
|
|
17
|
+
if (isPresent(group)) {
|
|
18
|
+
group.items.push(item);
|
|
19
|
+
} else {
|
|
20
|
+
group = { property: property, value: value, items: [item] };
|
|
21
|
+
groups.push(group);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return groups;
|
|
27
|
+
}).readOnly();
|
|
28
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import groupBy from './group-by';
|
|
2
|
+
import { _range } from './range';
|
|
3
|
+
import { format, startOfMonth, endOfMonth, startOfDay, sub, addDays } from 'date-fns';
|
|
4
|
+
|
|
5
|
+
function randomInt(min, max) {
|
|
6
|
+
min = Math.ceil(min);
|
|
7
|
+
max = Math.floor(max);
|
|
8
|
+
return Math.floor(Math.random() * (max - min) + min);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function randomDateThisMonth() {
|
|
12
|
+
const now = new Date();
|
|
13
|
+
const startDate = startOfMonth(now);
|
|
14
|
+
const endDate = endOfMonth(now);
|
|
15
|
+
const diffInDays = (endDate - startDate) / (1000 * 60 * 60 * 24);
|
|
16
|
+
return addDays(startDate, randomInt(0, diffInDays));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function makeMockDataset(start, end, dateProperty = 'created_at') {
|
|
20
|
+
const data = _range(start, end).map(() => {
|
|
21
|
+
return {
|
|
22
|
+
created_at: randomDateThisMonth(),
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
const grouped = groupBy(data, (record) => {
|
|
26
|
+
return format(new Date(record[dateProperty]), 'MMMM, dd yyyy');
|
|
27
|
+
});
|
|
28
|
+
const dataset = [];
|
|
29
|
+
|
|
30
|
+
for (let day in grouped) {
|
|
31
|
+
dataset.pushObject({
|
|
32
|
+
t: new Date(`${day} 00:00:00`),
|
|
33
|
+
y: grouped[day].length,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return dataset.sortBy('t');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { makeMockDataset, randomInt, randomDateThisMonth, _range as range };
|
|
41
|
+
|
|
42
|
+
export default function makeDataset(recordArray, filter = Boolean, dateProperty = 'created_at') {
|
|
43
|
+
const filteredData = recordArray.filter(filter);
|
|
44
|
+
const grouped = groupBy(filteredData, (record) => {
|
|
45
|
+
return format(new Date(record[dateProperty]), 'MMMM, dd yyyy');
|
|
46
|
+
});
|
|
47
|
+
const dataset = [];
|
|
48
|
+
|
|
49
|
+
for (let day in grouped) {
|
|
50
|
+
dataset.pushObject({
|
|
51
|
+
t: new Date(`${day} 00:00:00`),
|
|
52
|
+
y: grouped[day].length,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return dataset.sortBy('t');
|
|
57
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { dasherize } from '@ember/string';
|
|
2
|
+
import hostServices from '../exports/host-services';
|
|
3
|
+
|
|
4
|
+
export default function mapEngines(extensions, withServices = []) {
|
|
5
|
+
const engines = {};
|
|
6
|
+
const externalRoutes = {
|
|
7
|
+
console: 'console.home',
|
|
8
|
+
extensions: 'console.extensions',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
12
|
+
const extension = extensions[i];
|
|
13
|
+
const path = dasherize(extension.extension);
|
|
14
|
+
|
|
15
|
+
externalRoutes[path] = `console.${path}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
19
|
+
const extension = extensions[i];
|
|
20
|
+
|
|
21
|
+
engines[extension.name] = {
|
|
22
|
+
dependencies: {
|
|
23
|
+
services: [...hostServices, ...withServices],
|
|
24
|
+
externalRoutes,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return engines;
|
|
30
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export default function pastTense(verb) {
|
|
2
|
+
const exceptions = {
|
|
3
|
+
are: 'were',
|
|
4
|
+
eat: 'ate',
|
|
5
|
+
go: 'went',
|
|
6
|
+
have: 'had',
|
|
7
|
+
inherit: 'inherited',
|
|
8
|
+
is: 'was',
|
|
9
|
+
run: 'ran',
|
|
10
|
+
sit: 'sat',
|
|
11
|
+
visit: 'visited',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
if (exceptions[verb]) {
|
|
15
|
+
return exceptions[verb];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (/e$/i.test(verb)) {
|
|
19
|
+
return verb + 'd';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (/[aeiou]c/i.test(verb)) {
|
|
23
|
+
return verb + 'ked';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// for american english only
|
|
27
|
+
if (/el$/i.test(verb)) {
|
|
28
|
+
return verb + 'ed';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (/[aeio][aeiou][dlmnprst]$/.test(verb)) {
|
|
32
|
+
return verb + 'ed';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (/[aeiou][bdglmnprst]$/i.test(verb)) {
|
|
36
|
+
return verb.replace(/(.+[aeiou])([bdglmnprst])/, '$1$2$2ed');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return verb + 'ed';
|
|
40
|
+
}
|