@kalisio/kdk 1.6.0 → 1.7.0
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/.travis.test.sh +1 -1
- package/CHANGELOG.md +63 -13
- package/extras/tours/map/catalog-panel.js +61 -10
- package/extras/tours/map/create-view.js +25 -0
- package/extras/tours/map/fab.js +10 -1
- package/extras/tours/map/navigation-bar.js +7 -9
- package/lib/core/api/application.js +9 -1
- package/lib/core/api/application.js.map +1 -1
- package/lib/core/client/components/chart/KChart.vue +115 -0
- package/lib/core/client/components/chart/KStatsChart.vue +76 -0
- package/lib/core/client/components/chart/index.js +20 -0
- package/lib/core/client/components/chart/index.js.map +1 -0
- package/lib/core/client/components/collection/KFilter.vue +6 -0
- package/lib/core/client/components/collection/KHistoryEntry.vue +1 -1
- package/lib/core/client/components/collection/KItem.vue +4 -4
- package/lib/core/client/components/form/KChipsField.vue +4 -4
- package/lib/core/client/components/form/KView.vue +1 -1
- package/lib/core/client/components/frame/KAction.vue +40 -5
- package/lib/core/client/components/frame/KBlock.vue +7 -7
- package/lib/core/client/components/frame/KContent.vue +1 -1
- package/lib/core/client/components/frame/KOpener.vue +1 -1
- package/lib/core/client/components/frame/KPanel.vue +8 -7
- package/lib/core/client/components/frame/KPopupAction.vue +6 -0
- package/lib/core/client/components/frame/KScreen.vue +1 -1
- package/lib/core/client/components/frame/KStamp.vue +4 -2
- package/lib/core/client/components/frame/index.js +1 -6
- package/lib/core/client/components/frame/index.js.map +1 -1
- package/lib/core/client/components/input/KIconChooser.vue +5 -2
- package/lib/core/client/components/input/KPalette.vue +1 -1
- package/lib/core/client/components/input/index.js +14 -4
- package/lib/core/client/components/input/index.js.map +1 -1
- package/lib/core/client/components/layout/KFab.vue +1 -1
- package/lib/core/client/components/layout/KLayout.vue +10 -2
- package/lib/core/client/components/layout/KPage.vue +19 -18
- package/lib/core/client/components/layout/KTour.vue +5 -3
- package/lib/core/client/components/layout/KWindow.vue +211 -59
- package/lib/core/client/components/media/KMediaBrowser.vue +6 -6
- package/lib/core/client/components/menu/KMenu.vue +13 -5
- package/lib/core/client/components/menu/KRadialFab.vue +22 -24
- package/lib/core/client/components/menu/KRadialFabItem.vue +17 -18
- package/lib/core/client/components/team/KGroupsActivity.vue +1 -1
- package/lib/core/client/components/team/KJoinGroup.vue +2 -2
- package/lib/core/client/components/time/KAbsoluteTimeRange.vue +190 -0
- package/lib/core/client/components/time/KRelativeTimeRanges.vue +192 -0
- package/lib/core/client/components/time/index.js +20 -0
- package/lib/core/client/components/time/index.js.map +1 -0
- package/lib/core/client/i18n/core_en.json +35 -12
- package/lib/core/client/i18n/core_fr.json +36 -13
- package/lib/core/client/index.js +1 -1
- package/lib/core/client/index.js.map +1 -1
- package/lib/core/client/mixins/mixin.base-collection.js +11 -1
- package/lib/core/client/mixins/mixin.base-collection.js.map +1 -1
- package/lib/core/client/mixins/mixin.base-widget.js +25 -13
- package/lib/core/client/mixins/mixin.base-widget.js.map +1 -1
- package/lib/core/client/services/index.js +2 -1
- package/lib/core/client/services/index.js.map +1 -1
- package/lib/core/client/services/local-settings.service.js +4 -0
- package/lib/core/client/services/local-settings.service.js.map +1 -1
- package/lib/core/client/time.js +25 -15
- package/lib/core/client/time.js.map +1 -1
- package/lib/core/client/units.js +12 -0
- package/lib/core/client/units.js.map +1 -1
- package/lib/core/client/utils.js +11 -0
- package/lib/core/client/utils.js.map +1 -1
- package/lib/core/common/schemas/settings.update.json +14 -4
- package/lib/map/api/hooks/hooks.catalog.js +20 -0
- package/lib/map/api/hooks/hooks.catalog.js.map +1 -1
- package/lib/map/api/models/catalog.model.mongodb.js +6 -1
- package/lib/map/api/models/catalog.model.mongodb.js.map +1 -1
- package/lib/map/api/models/features.model.mongodb.js +5 -0
- package/lib/map/api/models/features.model.mongodb.js.map +1 -1
- package/lib/map/api/services/catalog/catalog.hooks.js +3 -1
- package/lib/map/api/services/catalog/catalog.hooks.js.map +1 -1
- package/lib/map/client/components/KColorLegend.vue +22 -21
- package/lib/map/client/components/KFeaturesChart.vue +81 -110
- package/lib/map/client/components/KLayerStyleForm.vue +119 -47
- package/lib/map/client/components/KLevelSlider.vue +30 -29
- package/lib/map/client/components/KLocationMap.vue +2 -2
- package/lib/map/client/components/KMeasureTool.vue +30 -6
- package/lib/map/client/components/KPositionIndicator.vue +4 -4
- package/lib/map/client/components/KTimeline.vue +25 -27
- package/lib/map/client/components/KTimezoneMap.vue +156 -0
- package/lib/map/client/components/KUrlLegend.vue +11 -10
- package/lib/map/client/components/catalog/KBaseLayersSelector.vue +1 -1
- package/lib/map/client/components/catalog/KCatalogLayersPanel.vue +56 -0
- package/lib/map/client/components/catalog/KCreateView.vue +91 -0
- package/lib/map/client/components/catalog/KLayerCategories.vue +2 -1
- package/lib/map/client/components/catalog/{KCatalog.vue → KLayersPanel.vue} +19 -37
- package/lib/map/client/components/catalog/KUserLayersPanel.vue +40 -0
- package/lib/map/client/components/catalog/KViewSelector.vue +46 -0
- package/lib/map/client/components/catalog/KViewsPanel.vue +110 -0
- package/lib/map/client/components/catalog/KWeatherLayersSelector.vue +4 -13
- package/lib/map/client/components/form/KTimezoneField.vue +135 -0
- package/lib/map/client/components/widget/KElevationProfile.vue +488 -0
- package/lib/map/client/components/widget/KInformationBox.vue +48 -23
- package/lib/map/client/components/widget/KMapillaryViewer.vue +26 -20
- package/lib/map/client/components/widget/KTimeSeries.vue +267 -347
- package/lib/map/client/i18n/map_en.json +63 -40
- package/lib/map/client/i18n/map_fr.json +65 -42
- package/lib/map/client/leaflet/GradientPath.js +40 -19
- package/lib/map/client/leaflet/GradientPath.js.map +1 -1
- package/lib/map/client/leaflet/TiledFeatureLayer.js +527 -93
- package/lib/map/client/leaflet/TiledFeatureLayer.js.map +1 -1
- package/lib/map/client/leaflet/TiledMeshLayer.js +58 -35
- package/lib/map/client/leaflet/TiledMeshLayer.js.map +1 -1
- package/lib/map/client/leaflet/utils.js +44 -3
- package/lib/map/client/leaflet/utils.js.map +1 -1
- package/lib/map/client/mixins/globe/mixin.base-globe.js +16 -1
- package/lib/map/client/mixins/globe/mixin.base-globe.js.map +1 -1
- package/lib/map/client/mixins/globe/mixin.file-layers.js +12 -2
- package/lib/map/client/mixins/globe/mixin.file-layers.js.map +1 -1
- package/lib/map/client/mixins/globe/mixin.geojson-layers.js +7 -6
- package/lib/map/client/mixins/globe/mixin.geojson-layers.js.map +1 -1
- package/lib/map/client/mixins/globe/mixin.popup.js +4 -2
- package/lib/map/client/mixins/globe/mixin.popup.js.map +1 -1
- package/lib/map/client/mixins/globe/mixin.style.js +8 -4
- package/lib/map/client/mixins/globe/mixin.style.js.map +1 -1
- package/lib/map/client/mixins/globe/mixin.tooltip.js +4 -2
- package/lib/map/client/mixins/globe/mixin.tooltip.js.map +1 -1
- package/lib/map/client/mixins/index.js +23 -18
- package/lib/map/client/mixins/index.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.base-map.js +20 -2
- package/lib/map/client/mixins/map/mixin.base-map.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.edit-layers.js +8 -4
- package/lib/map/client/mixins/map/mixin.edit-layers.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.geojson-layers.js +27 -5
- package/lib/map/client/mixins/map/mixin.geojson-layers.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.heatmap-layers.js +6 -1
- package/lib/map/client/mixins/map/mixin.heatmap-layers.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.popup.js +1 -1
- package/lib/map/client/mixins/map/mixin.popup.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.style.js +8 -4
- package/lib/map/client/mixins/map/mixin.style.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.tiled-mesh-layers.js +4 -11
- package/lib/map/client/mixins/map/mixin.tiled-mesh-layers.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.tiled-wind-layers.js +0 -11
- package/lib/map/client/mixins/map/mixin.tiled-wind-layers.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.tooltip.js +1 -1
- package/lib/map/client/mixins/map/mixin.tooltip.js.map +1 -1
- package/lib/map/client/mixins/mixin.activity.js +150 -150
- package/lib/map/client/mixins/mixin.activity.js.map +1 -1
- package/lib/map/client/mixins/mixin.catalog-panel.js +36 -0
- package/lib/map/client/mixins/mixin.catalog-panel.js.map +1 -0
- package/lib/map/client/mixins/mixin.feature-selection.js +17 -8
- package/lib/map/client/mixins/mixin.feature-selection.js.map +1 -1
- package/lib/map/client/mixins/mixin.feature-service.js +36 -16
- package/lib/map/client/mixins/mixin.feature-service.js.map +1 -1
- package/lib/map/client/mixins/mixin.infobox.js +1 -1
- package/lib/map/client/mixins/mixin.infobox.js.map +1 -1
- package/lib/map/client/mixins/mixin.levels.js +26 -12
- package/lib/map/client/mixins/mixin.levels.js.map +1 -1
- package/lib/map/client/mixins/mixin.style.js +1 -0
- package/lib/map/client/mixins/mixin.style.js.map +1 -1
- package/lib/map/client/mixins/mixin.weacast.js +15 -23
- package/lib/map/client/mixins/mixin.weacast.js.map +1 -1
- package/lib/map/client/pixi-utils.js +8 -177
- package/lib/map/client/pixi-utils.js.map +1 -1
- package/lib/map/client/utils.js +1 -0
- package/lib/map/client/utils.js.map +1 -1
- package/lib/map/common/grid.js +131 -0
- package/lib/map/common/grid.js.map +1 -1
- package/lib/map/common/index.js +22 -11
- package/lib/map/common/index.js.map +1 -1
- package/lib/map/common/meteo-model-grid-source.js +5 -2
- package/lib/map/common/meteo-model-grid-source.js.map +1 -1
- package/lib/map/common/time-based-grid-source.js +5 -2
- package/lib/map/common/time-based-grid-source.js.map +1 -1
- package/lib/test/client/core/collection.js +31 -13
- package/lib/test/client/core/collection.js.map +1 -1
- package/lib/test/client/core/layout.js +137 -49
- package/lib/test/client/core/layout.js.map +1 -1
- package/lib/test/client/core/utils.js +89 -22
- package/lib/test/client/core/utils.js.map +1 -1
- package/lib/test/client/map/catalog.js +134 -41
- package/lib/test/client/map/catalog.js.map +1 -1
- package/lib/test/client/map/controls.js +7 -4
- package/lib/test/client/map/controls.js.map +1 -1
- package/lib/test/client/map/index.js +12 -0
- package/lib/test/client/map/index.js.map +1 -1
- package/lib/test/client/map/utils.js +67 -0
- package/lib/test/client/map/utils.js.map +1 -0
- package/package.json +5 -5
- package/extras/tours/map/favorite-views.js +0 -53
- package/lib/core/client/components/frame/KChart.vue +0 -60
- package/lib/core/client/components/input/KCodeInput.vue +0 -50
- package/lib/core/client/components/input/KTimeRangeChooser.vue +0 -109
- package/lib/core/client/components/time/KTimeRange.vue +0 -144
- package/lib/map/client/components/KFavoriteViews.vue +0 -217
|
@@ -57,7 +57,17 @@ const baseCollectionMixin = {
|
|
|
57
57
|
// We keep order from the updated list as depending on the sorting criteria a new item might have to be pushed on top of current items
|
|
58
58
|
const sortQuery = _lodash2.default.get(this.getCollectionBaseQuery(), '$sort');
|
|
59
59
|
if (sortQuery) {
|
|
60
|
-
|
|
60
|
+
// By default orderBy is case sensitive while using collation we want to perform case insensitive sort
|
|
61
|
+
this.items = _lodash2.default.orderBy(this.items,
|
|
62
|
+
// Sort function for each sort property
|
|
63
|
+
_lodash2.default.map(_lodash2.default.keys(sortQuery), property => {
|
|
64
|
+
return item => {
|
|
65
|
+
const value = _lodash2.default.get(item, property);
|
|
66
|
+
return typeof value === 'string' ? value.toLowerCase() : value;
|
|
67
|
+
};
|
|
68
|
+
}),
|
|
69
|
+
// Sort order for each sort property
|
|
70
|
+
_lodash2.default.map(_lodash2.default.values(sortQuery), value => {
|
|
61
71
|
return value > 0 ? 'asc' : 'desc';
|
|
62
72
|
}));
|
|
63
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../core/client/mixins/mixin.base-collection.js"],"names":["baseCollectionMixin","props","nbItemsPerPage","type","Number","default","appendItems","Boolean","refreshThrottle","computed","nbPages","Math","ceil","nbTotalItems","data","items","currentPage","methods","subscribe","query","unsubscribe","itemListener","getService","watch","listStrategy","find","response","features","_","unionBy","sortQuery","get","getCollectionBaseQuery","orderBy","keys","map","values","value","total","$emit","error","$events","getCollectionFilterQuery","getCollectionPaginationQuery","$limit","$skip","resetCollection","refreshCollection","onPageChanged","onItemToggled","item","toggled","onItemSelected","section","onItemsSelected","onItemsUpdated","updatedItems","Array","isArray","intersectionWith","item1","item2","_id","toString","length","created","fullQuery","Object","assign","$locale","throttle","leading","service","on","beforeDestroy","off"],"mappings":";;;;;;AAAA;;;;AACA;;;;AAEA,MAAMA,sBAAsB;AAC1BC,SAAO;AACL;AACA;AACAC,oBAAgB;AACdC,YAAMC,MADQ;AAEdC,eAAS;AAFK,KAHX;AAOL;AACAC,iBAAa;AACXH,YAAMI,OADK;AAEXF,eAAS;AAFE,KARR;AAYL;AACAG,qBAAiB;AACfL,YAAMC,MADS;AAEfC,eAAS;AAFM;AAbZ,GADmB;AAmB1BI,YAAU;AACRC,cAAW;AACT,aAAQ,KAAKR,cAAL,GAAsB,CAAtB,GAA0BS,KAAKC,IAAL,CAAU,KAAKC,YAAL,GAAoB,KAAKX,cAAnC,CAA1B,GAA+E,CAAvF;AACD;AAHO,GAnBgB;AAwB1BY,SAAQ;AACN,WAAO;AACLC,aAAO,EADF;AAELF,oBAAc,CAFT;AAGLG,mBAAa;AAHR,KAAP;AAKD,GA9ByB;AA+B1BC,WAAS;AACPC,cAAWC,KAAX,EAAkB;AAChB;AACA,WAAKC,WAAL;AACA,WAAKC,YAAL,GAAoB,KAAKC,UAAL,GAAkBC,KAAlB,CAAwB,EAAEC,cAAc,KAAKA,YAAL,IAAqB,QAArC,EAAxB,EACjBC,IADiB,CACZ,EAAEN,KAAF,EADY,EAEjBD,SAFiB,CAEPQ,YAAY;AACrB;AACA,YAAIA,SAASvB,IAAT,KAAkB,mBAAtB,EAA2C;AACzC,eAAKY,KAAL,GAAaW,SAASC,QAAtB;AACD,SAFD,MAEO,IAAI,KAAKrB,WAAT,EAAsB;AAC3B;AACA,eAAKS,KAAL,GAAaa,iBAAEC,OAAF,CAAUH,SAASZ,IAAnB,EAAyB,KAAKC,KAA9B,EA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AzB;;AAEA,QAAI,KAAKjE,WAAT,EAAsB;AACpB,YAAMkE,UAAU,KAAKlD,UAAL,EAAhB;AACAkD,cAAQC,EAAR,CAAW,SAAX,EAAsB,KAAKlB,cAA3B;AACAiB,cAAQC,EAAR,CAAW,SAAX,EAAsB,KAAKlB,cAA3B;AACAiB,cAAQC,EAAR,CAAW,SAAX,EAAsB,KAAKlB,cAA3B;AACD;AACF,GAjIyB;AAkI1BmB,kBAAiB;AACf,SAAKtD,WAAL;AACA,QAAI,KAAKd,WAAT,EAAsB;AACpB,YAAMkE,UAAU,KAAKlD,UAAL,EAAhB;AACAkD,cAAQG,GAAR,CAAY,SAAZ,EAAuB,KAAKpB,cAA5B;AACAiB,cAAQG,GAAR,CAAY,SAAZ,EAAuB,KAAKpB,cAA5B;AACAiB,cAAQG,GAAR,CAAY,SAAZ,EAAuB,KAAKpB,cAA5B;AACD;AACF;AA1IyB,CAA5B;;kBA6IevD,mB","file":"mixin.base-collection.js","sourcesContent":["import _ from 'lodash'\r\nimport { getLocale } from '../utils'\r\n\r\nconst baseCollectionMixin = {\r\n props: {\r\n // This value can be overriden in activities if they want to manage pagination by themselves\r\n // nbItemsPerPage = 0 means that the client does not handle pagination and server defaults will be used\r\n nbItemsPerPage: {\r\n type: Number,\r\n default: 12\r\n },\r\n // This value indicate if items of each page replace or are appended to previous ones\r\n appendItems: {\r\n type: Boolean,\r\n default: false\r\n },\r\n // Only invoke refresh at most once per every refreshThrottle milliseconds\r\n refreshThrottle: {\r\n type: Number,\r\n default: 500\r\n }\r\n },\r\n computed: {\r\n nbPages () {\r\n return (this.nbItemsPerPage > 0 ? Math.ceil(this.nbTotalItems / this.nbItemsPerPage) : 1)\r\n }\r\n },\r\n data () {\r\n return {\r\n items: [],\r\n nbTotalItems: 0,\r\n currentPage: 1\r\n }\r\n },\r\n methods: {\r\n subscribe (query) {\r\n // Remove previous listener if any\r\n this.unsubscribe()\r\n this.itemListener = this.getService().watch({ listStrategy: this.listStrategy || 'always' })\r\n .find({ query })\r\n .subscribe(response => {\r\n // Manage GeoJson features collection as well\r\n if (response.type === 'FeatureCollection') {\r\n this.items = response.features\r\n } else if (this.appendItems) {\r\n // Append the response ensuring there is no duplicates\r\n this.items = _.unionBy(response.data, this.items, '_id')\r\n // We keep order from the updated list as depending on the sorting criteria a new item might have to be pushed on top of current items\r\n const sortQuery = _.get(this.getCollectionBaseQuery(), '$sort')\r\n if (sortQuery) {\r\n this.items = _.orderBy(this.items, _.keys(sortQuery), _.map(_.values(sortQuery), value => { return value > 0 ? 'asc' : 'desc' }))\r\n }\r\n } else {\r\n this.items = response.data\r\n }\r\n this.nbTotalItems = response.total\r\n this.$emit('collection-refreshed', this.items)\r\n }, error => {\r\n this.$events.$emit('error', error)\r\n })\r\n },\r\n unsubscribe () {\r\n if (this.itemListener) {\r\n this.itemListener.unsubscribe()\r\n this.itemListener = null\r\n }\r\n },\r\n getCollectionBaseQuery () {\r\n // This method should be overriden in collections\r\n return {}\r\n },\r\n getCollectionFilterQuery () {\r\n // This method should be overriden in collections\r\n return {}\r\n },\r\n getCollectionPaginationQuery () {\r\n // This method can be overriden in collections\r\n if (this.nbItemsPerPage > 0) {\r\n return {\r\n $limit: this.nbItemsPerPage,\r\n $skip: (this.currentPage - 1) * this.nbItemsPerPage\r\n }\r\n } else return {}\r\n },\r\n resetCollection () {\r\n // Reset pagination and start again refreshing the collection\r\n this.items = []\r\n this.currentPage = 1\r\n this.refreshCollection()\r\n },\r\n onPageChanged () {\r\n this.refreshCollection()\r\n },\r\n onItemToggled (item, toggled) {\r\n this.$emit('toggle-changed', item, toggled)\r\n },\r\n onItemSelected (item, section) {\r\n this.$emit('selection-changed', item, section)\r\n },\r\n onItemsSelected (items) {\r\n this.$emit('selection-changed', items)\r\n },\r\n onItemsUpdated (items) {\r\n // When we append items some items of the previous pages might have been updated.\r\n // In this case we need to reset the full collection as Rx only tracks changes on the current page\r\n let updatedItems = (Array.isArray(items) ? items : [items])\r\n // We keep order from the updated list as depending on the sorting criteria a new item might have to be pushed on top of current items\r\n updatedItems = _.intersectionWith(this.items, updatedItems, (item1, item2) => (item1._id.toString() === item2._id.toString()))\r\n if (updatedItems.length > 0) this.resetCollection()\r\n }\r\n },\r\n created () {\r\n // Avoid initiating too much request as the same time, this might be the case\r\n // when async UI components update simultaneously the base/filter query\r\n // see https://github.com/kalisio/kdk/issues/432\r\n const refreshCollection = () => {\r\n // Add locale to perform sorting (i.e. collation) correctly w.r.t. user's language\r\n const fullQuery = Object.assign({ $locale: getLocale() },\r\n this.getCollectionBaseQuery(),\r\n this.getCollectionFilterQuery(),\r\n this.getCollectionPaginationQuery())\r\n // Find the desired items\r\n this.subscribe(fullQuery)\r\n }\r\n this.refreshCollection = _.throttle(refreshCollection, this.refreshThrottle, { leading: false })\r\n\r\n if (this.appendItems) {\r\n const service = this.getService()\r\n service.on('patched', this.onItemsUpdated)\r\n service.on('updated', this.onItemsUpdated)\r\n service.on('removed', this.onItemsUpdated)\r\n }\r\n },\r\n beforeDestroy () {\r\n this.unsubscribe()\r\n if (this.appendItems) {\r\n const service = this.getService()\r\n service.off('patched', this.onItemsUpdated)\r\n service.off('updated', this.onItemsUpdated)\r\n service.off('removed', this.onItemsUpdated)\r\n }\r\n }\r\n}\r\n\r\nexport default baseCollectionMixin\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../core/client/mixins/mixin.base-collection.js"],"names":["baseCollectionMixin","props","nbItemsPerPage","type","Number","default","appendItems","Boolean","refreshThrottle","computed","nbPages","Math","ceil","nbTotalItems","data","items","currentPage","methods","subscribe","query","unsubscribe","itemListener","getService","watch","listStrategy","find","response","features","_","unionBy","sortQuery","get","getCollectionBaseQuery","orderBy","map","keys","property","item","value","toLowerCase","values","total","$emit","error","$events","getCollectionFilterQuery","getCollectionPaginationQuery","$limit","$skip","resetCollection","refreshCollection","onPageChanged","onItemToggled","toggled","onItemSelected","section","onItemsSelected","onItemsUpdated","updatedItems","Array","isArray","intersectionWith","item1","item2","_id","toString","length","created","fullQuery","Object","assign","$locale","throttle","leading","service","on","beforeDestroy","off"],"mappings":";;;;;;AAAA;;;;AACA;;;;AAEA,MAAMA,sBAAsB;AAC1BC,SAAO;AACL;AACA;AACAC,oBAAgB;AACdC,YAAMC,MADQ;AAEdC,eAAS;AAFK,KAHX;AAOL;AACAC,iBAAa;AACXH,YAAMI,OADK;AAEXF,eAAS;AAFE,KARR;AAYL;AACAG,qBAAiB;AACfL,YAAMC,MADS;AAEfC,eAAS;AAFM;AAbZ,GADmB;AAmB1BI,YAAU;AACRC,cAAW;AACT,aAAQ,KAAKR,cAAL,GAAsB,CAAtB,GAA0BS,KAAKC,IAAL,CAAU,KAAKC,YAAL,GAAoB,KAAKX,cAAnC,CAA1B,GAA+E,CAAvF;AACD;AAHO,GAnBgB;AAwB1BY,SAAQ;AACN,WAAO;AACLC,aAAO,EADF;AAELF,oBAAc,CAFT;AAGLG,mBAAa;AAHR,KAAP;AAKD,GA9ByB;AA+B1BC,WAAS;AACPC,cAAWC,KAAX,EAAkB;AAChB;AACA,WAAKC,WAAL;AACA,WAAKC,YAAL,GAAoB,KAAKC,UAAL,GAAkBC,KAAlB,CAAwB,EAAEC,cAAc,KAAKA,YAAL,IAAqB,QAArC,EAAxB,EACjBC,IADiB,CACZ,EAAEN,KAAF,EADY,EAEjBD,SAFiB,CAEPQ,YAAY;AACrB;AACA,YAAIA,SAASvB,IAAT,KAAkB,mBAAtB,EAA2C;AACzC,eAAKY,KAAL,GAAaW,SAASC,QAAtB;AACD,SAFD,MAEO,IAAI,KAAKrB,WAAT,EAAsB;AAC3B;AACA,eAAKS,KAAL,GAAaa,iBAAEC,OAAF,CAAUH,SAASZ,IAAnB,EAAyB,KAAKC,KAA9B,EAAqC,KAArC,CAAb;AACA;AACA,gBAAMe,YAAYF,iBAAEG,GAAF,CAAM,KAAKC,sBAAL,EAAN,EAAqC,OAArC,CAAlB;AACA,cAAIF,SAAJ,EAAe;AACb;AACA,iBAAKf,KAAL,GAAaa,iBAAEK,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4C,QAAF,CAAWtB,iBAAX,EAA8B,KAAK1C,eAAnC,EAAoD,EAAEiE,SAAS,KAAX,EAApD,CAAzB;;AAEA,QAAI,KAAKnE,WAAT,EAAsB;AACpB,YAAMoE,UAAU,KAAKpD,UAAL,EAAhB;AACAoD,cAAQC,EAAR,CAAW,SAAX,EAAsB,KAAKlB,cAA3B;AACAiB,cAAQC,EAAR,CAAW,SAAX,EAAsB,KAAKlB,cAA3B;AACAiB,cAAQC,EAAR,CAAW,SAAX,EAAsB,KAAKlB,cAA3B;AACD;AACF,GA3IyB;AA4I1BmB,kBAAiB;AACf,SAAKxD,WAAL;AACA,QAAI,KAAKd,WAAT,EAAsB;AACpB,YAAMoE,UAAU,KAAKpD,UAAL,EAAhB;AACAoD,cAAQG,GAAR,CAAY,SAAZ,EAAuB,KAAKpB,cAA5B;AACAiB,cAAQG,GAAR,CAAY,SAAZ,EAAuB,KAAKpB,cAA5B;AACAiB,cAAQG,GAAR,CAAY,SAAZ,EAAuB,KAAKpB,cAA5B;AACD;AACF;AApJyB,CAA5B;;kBAuJezD,mB","file":"mixin.base-collection.js","sourcesContent":["import _ from 'lodash'\r\nimport { getLocale } from '../utils'\r\n\r\nconst baseCollectionMixin = {\r\n props: {\r\n // This value can be overriden in activities if they want to manage pagination by themselves\r\n // nbItemsPerPage = 0 means that the client does not handle pagination and server defaults will be used\r\n nbItemsPerPage: {\r\n type: Number,\r\n default: 12\r\n },\r\n // This value indicate if items of each page replace or are appended to previous ones\r\n appendItems: {\r\n type: Boolean,\r\n default: false\r\n },\r\n // Only invoke refresh at most once per every refreshThrottle milliseconds\r\n refreshThrottle: {\r\n type: Number,\r\n default: 500\r\n }\r\n },\r\n computed: {\r\n nbPages () {\r\n return (this.nbItemsPerPage > 0 ? Math.ceil(this.nbTotalItems / this.nbItemsPerPage) : 1)\r\n }\r\n },\r\n data () {\r\n return {\r\n items: [],\r\n nbTotalItems: 0,\r\n currentPage: 1\r\n }\r\n },\r\n methods: {\r\n subscribe (query) {\r\n // Remove previous listener if any\r\n this.unsubscribe()\r\n this.itemListener = this.getService().watch({ listStrategy: this.listStrategy || 'always' })\r\n .find({ query })\r\n .subscribe(response => {\r\n // Manage GeoJson features collection as well\r\n if (response.type === 'FeatureCollection') {\r\n this.items = response.features\r\n } else if (this.appendItems) {\r\n // Append the response ensuring there is no duplicates\r\n this.items = _.unionBy(response.data, this.items, '_id')\r\n // We keep order from the updated list as depending on the sorting criteria a new item might have to be pushed on top of current items\r\n const sortQuery = _.get(this.getCollectionBaseQuery(), '$sort')\r\n if (sortQuery) {\r\n // By default orderBy is case sensitive while using collation we want to perform case insensitive sort\r\n this.items = _.orderBy(this.items,\r\n // Sort function for each sort property\r\n _.map(_.keys(sortQuery), property => {\r\n return item => {\r\n const value = _.get(item, property)\r\n return (typeof value === 'string' ? value.toLowerCase() : value)\r\n }\r\n }),\r\n // Sort order for each sort property\r\n _.map(_.values(sortQuery), value => { return value > 0 ? 'asc' : 'desc' }))\r\n }\r\n } else {\r\n this.items = response.data\r\n }\r\n this.nbTotalItems = response.total\r\n this.$emit('collection-refreshed', this.items)\r\n }, error => {\r\n this.$events.$emit('error', error)\r\n })\r\n },\r\n unsubscribe () {\r\n if (this.itemListener) {\r\n this.itemListener.unsubscribe()\r\n this.itemListener = null\r\n }\r\n },\r\n getCollectionBaseQuery () {\r\n // This method should be overriden in collections\r\n return {}\r\n },\r\n getCollectionFilterQuery () {\r\n // This method should be overriden in collections\r\n return {}\r\n },\r\n getCollectionPaginationQuery () {\r\n // This method can be overriden in collections\r\n if (this.nbItemsPerPage > 0) {\r\n return {\r\n $limit: this.nbItemsPerPage,\r\n $skip: (this.currentPage - 1) * this.nbItemsPerPage\r\n }\r\n } else return {}\r\n },\r\n resetCollection () {\r\n // Reset pagination and start again refreshing the collection\r\n this.items = []\r\n this.currentPage = 1\r\n this.refreshCollection()\r\n },\r\n onPageChanged () {\r\n this.refreshCollection()\r\n },\r\n onItemToggled (item, toggled) {\r\n this.$emit('toggle-changed', item, toggled)\r\n },\r\n onItemSelected (item, section) {\r\n this.$emit('selection-changed', item, section)\r\n },\r\n onItemsSelected (items) {\r\n this.$emit('selection-changed', items)\r\n },\r\n onItemsUpdated (items) {\r\n // When we append items some items of the previous pages might have been updated.\r\n // In this case we need to reset the full collection as Rx only tracks changes on the current page\r\n let updatedItems = (Array.isArray(items) ? items : [items])\r\n // We keep order from the updated list as depending on the sorting criteria a new item might have to be pushed on top of current items\r\n updatedItems = _.intersectionWith(this.items, updatedItems, (item1, item2) => (item1._id.toString() === item2._id.toString()))\r\n if (updatedItems.length > 0) this.resetCollection()\r\n }\r\n },\r\n created () {\r\n // Avoid initiating too much request as the same time, this might be the case\r\n // when async UI components update simultaneously the base/filter query\r\n // see https://github.com/kalisio/kdk/issues/432\r\n const refreshCollection = () => {\r\n // Add locale to perform sorting (i.e. collation) correctly w.r.t. user's language\r\n const fullQuery = Object.assign({ $locale: getLocale() },\r\n this.getCollectionBaseQuery(),\r\n this.getCollectionFilterQuery(),\r\n this.getCollectionPaginationQuery())\r\n // Find the desired items\r\n this.subscribe(fullQuery)\r\n }\r\n this.refreshCollection = _.throttle(refreshCollection, this.refreshThrottle, { leading: false })\r\n\r\n if (this.appendItems) {\r\n const service = this.getService()\r\n service.on('patched', this.onItemsUpdated)\r\n service.on('updated', this.onItemsUpdated)\r\n service.on('removed', this.onItemsUpdated)\r\n }\r\n },\r\n beforeDestroy () {\r\n this.unsubscribe()\r\n if (this.appendItems) {\r\n const service = this.getService()\r\n service.off('patched', this.onItemsUpdated)\r\n service.off('updated', this.onItemsUpdated)\r\n service.off('removed', this.onItemsUpdated)\r\n }\r\n }\r\n}\r\n\r\nexport default baseCollectionMixin\r\n"]}
|
|
@@ -4,26 +4,38 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
const baseWidgetMixin = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
computed: {
|
|
8
|
+
widgetStyle() {
|
|
9
|
+
const widgetSize = this.window.size;
|
|
10
|
+
if (widgetSize) {
|
|
11
|
+
// compute the widget size
|
|
12
|
+
const widgetWidth = this.window.size[0];
|
|
13
|
+
let widgetHeight = this.window.size[1];
|
|
14
|
+
const windowHeaderElement = document.getElementById('window-header');
|
|
15
|
+
if (windowHeaderElement) {
|
|
16
|
+
widgetHeight -= parseInt(window.getComputedStyle(windowHeaderElement).getPropertyValue('height'));
|
|
17
|
+
}
|
|
18
|
+
const windowFooterElement = document.getElementById('window-footer');
|
|
19
|
+
if (windowFooterElement) {
|
|
20
|
+
widgetHeight -= parseInt(window.getComputedStyle(windowFooterElement).getPropertyValue('height'));
|
|
21
|
+
}
|
|
22
|
+
// store the widget size
|
|
23
|
+
this.widgetWidth = widgetWidth;
|
|
24
|
+
this.widgetHeight = widgetHeight;
|
|
25
|
+
// return the style
|
|
26
|
+
return `minWidth: ${widgetWidth}px;
|
|
27
|
+
maxWidth: ${widgetWidth}px;
|
|
28
|
+
minHeight: ${widgetHeight}px;
|
|
29
|
+
maxHeight: ${widgetHeight}px;`;
|
|
13
30
|
}
|
|
14
31
|
}
|
|
15
32
|
},
|
|
16
33
|
data() {
|
|
17
34
|
return {
|
|
35
|
+
window: this.$store.get('window'),
|
|
36
|
+
widgetWidth: 0,
|
|
18
37
|
widgetHeight: 0
|
|
19
38
|
};
|
|
20
|
-
},
|
|
21
|
-
computed: {
|
|
22
|
-
widgetStyle() {
|
|
23
|
-
const screenHeight = this.$q.screen.height;
|
|
24
|
-
this.widgetHeight = this.mode === 'maximized' ? screenHeight : screenHeight * 0.3; // 30vh
|
|
25
|
-
return `height: ${this.widgetHeight}px`;
|
|
26
|
-
}
|
|
27
39
|
}
|
|
28
40
|
};
|
|
29
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../core/client/mixins/mixin.base-widget.js"],"names":["baseWidgetMixin","
|
|
1
|
+
{"version":3,"sources":["../../../../core/client/mixins/mixin.base-widget.js"],"names":["baseWidgetMixin","computed","widgetStyle","widgetSize","window","size","widgetWidth","widgetHeight","windowHeaderElement","document","getElementById","parseInt","getComputedStyle","getPropertyValue","windowFooterElement","data","$store","get"],"mappings":";;;;;AAAA,MAAMA,kBAAkB;AACtBC,YAAU;AACRC,kBAAe;AACb,YAAMC,aAAa,KAAKC,MAAL,CAAYC,IAA/B;AACA,UAAIF,UAAJ,EAAgB;AACd;AACA,cAAMG,cAAc,KAAKF,MAAL,CAAYC,IAAZ,CAAiB,CAAjB,CAApB;AACA,YAAIE,eAAe,KAAKH,MAAL,CAAYC,IAAZ,CAAiB,CAAjB,CAAnB;AACA,cAAMG,sBAAsBC,SAASC,cAAT,CAAwB,eAAxB,CAA5B;AACA,YAAIF,mBAAJ,EAAyB;AACvBD,0BAAgBI,SAASP,OAAOQ,gBAAP,CAAwBJ,mBAAxB,EAA6CK,gBAA7C,CAA8D,QAA9D,CAAT,CAAhB;AACD;AACD,cAAMC,sBAAsBL,SAASC,cAAT,CAAwB,eAAxB,CAA5B;AACA,YAAII,mBAAJ,EAAyB;AACvBP,0BAAgBI,SAASP,OAAOQ,gBAAP,CAAwBE,mBAAxB,EAA6CD,gBAA7C,CAA8D,QAA9D,CAAT,CAAhB;AACD;AACD;AACA,aAAKP,WAAL,GAAmBA,WAAnB;AACA,aAAKC,YAAL,GAAoBA,YAApB;AACA;AACA,eAAQ,aAAYD,WAAY;4BACZA,WAAY;6BACXC,YAAa;6BACbA,YAAa,KAHlC;AAID;AACF;AAxBO,GADY;AA2BtBQ,SAAQ;AACN,WAAO;AACLX,cAAQ,KAAKY,MAAL,CAAYC,GAAZ,CAAgB,QAAhB,CADH;AAELX,mBAAa,CAFR;AAGLC,oBAAc;AAHT,KAAP;AAKD;AAjCqB,CAAxB;;kBAoCeP,e","file":"mixin.base-widget.js","sourcesContent":["const baseWidgetMixin = {\r\n computed: {\r\n widgetStyle () {\r\n const widgetSize = this.window.size\r\n if (widgetSize) {\r\n // compute the widget size\r\n const widgetWidth = this.window.size[0]\r\n let widgetHeight = this.window.size[1]\r\n const windowHeaderElement = document.getElementById('window-header')\r\n if (windowHeaderElement) {\r\n widgetHeight -= parseInt(window.getComputedStyle(windowHeaderElement).getPropertyValue('height'))\r\n }\r\n const windowFooterElement = document.getElementById('window-footer')\r\n if (windowFooterElement) {\r\n widgetHeight -= parseInt(window.getComputedStyle(windowFooterElement).getPropertyValue('height'))\r\n }\r\n // store the widget size\r\n this.widgetWidth = widgetWidth\r\n this.widgetHeight = widgetHeight\r\n // return the style\r\n return `minWidth: ${widgetWidth}px;\r\n maxWidth: ${widgetWidth}px;\r\n minHeight: ${widgetHeight}px; \r\n maxHeight: ${widgetHeight}px;`\r\n }\r\n }\r\n },\r\n data () {\r\n return {\r\n window: this.$store.get('window'),\r\n widgetWidth: 0,\r\n widgetHeight: 0\r\n }\r\n }\r\n}\r\n\r\nexport default baseWidgetMixin\r\n"]}
|
|
@@ -45,7 +45,7 @@ function init() {
|
|
|
45
45
|
longDate: 'time.format.date.long',
|
|
46
46
|
shortYear: 'time.format.year.short',
|
|
47
47
|
longYear: 'time.format.year.long',
|
|
48
|
-
|
|
48
|
+
timezone: 'time.format.timezone',
|
|
49
49
|
timelineStep: 'time.step',
|
|
50
50
|
timelineInterval: 'time.interval',
|
|
51
51
|
timeseriesSpan: 'timeseries.span',
|
|
@@ -53,6 +53,7 @@ function init() {
|
|
|
53
53
|
restoreView: 'restore.view',
|
|
54
54
|
restoreLayers: 'restore.layers',
|
|
55
55
|
defaultLength: 'units.default.length',
|
|
56
|
+
defaultAltitude: 'units.default.altitude',
|
|
56
57
|
defaultArea: 'units.default.area',
|
|
57
58
|
defaultVelocity: 'units.default.velocity',
|
|
58
59
|
defaultTemperature: 'units.default.temperature',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../core/client/services/index.js"],"names":["init","LocalSettingsService","api","declareService","context","createService","_","merge","config","settings","service","propertyMapping","shortTime","longTime","shortDate","longDate","shortYear","longYear","
|
|
1
|
+
{"version":3,"sources":["../../../../core/client/services/index.js"],"names":["init","LocalSettingsService","api","declareService","context","createService","_","merge","config","settings","service","propertyMapping","shortTime","longTime","shortDate","longDate","shortYear","longYear","timezone","timelineStep","timelineInterval","timeseriesSpan","location","restoreView","restoreLayers","defaultLength","defaultAltitude","defaultArea","defaultVelocity","defaultTemperature","defaultAngle","defaultPrecision"],"mappings":";;;;;;kBAMwBA,I;;AANxB;;;;AACA;;;;AACA;;;;;;QAESC,oB,GAAAA,uB;AAEM,SAASD,IAAT,GAAiB;AAC9B,QAAME,MAAM,IAAZ;;AAEA;AACAA,MAAIC,cAAJ,CAAmB,OAAnB;AACAD,MAAIC,cAAJ,CAAmB,gBAAnB;AACAD,MAAIC,cAAJ,CAAmB,MAAnB,EAA2B,EAAEC,SAAS,IAAX,EAA3B;AACAF,MAAIC,cAAJ,CAAmB,eAAnB;AACAD,MAAIC,cAAJ,CAAmB,SAAnB,EAA8B,EAAEC,SAAS,IAAX,EAA9B;AACAF,MAAIC,cAAJ,CAAmB,QAAnB,EAA6B,EAAEC,SAAS,IAAX,EAA7B;AACAF,MAAIC,cAAJ,CAAmB,SAAnB,EAA8B,EAAEC,SAAS,IAAX,EAA9B;AACAF,MAAIC,cAAJ,CAAmB,SAAnB;AACAD,MAAIC,cAAJ,CAAmB,SAAnB;;AAEA;AACAD,MAAIG,aAAJ,CAAkB,UAAlB,EAA8BC,iBAAEC,KAAF,CAAQC,iBAAOC,QAAP,IAAmB,EAA3B,EAA+B;AAC3DC,aAAST,uBADkD;AAE3DU,qBAAiB;AACfC,iBAAW,wBADI;AAEfC,gBAAU,uBAFK;AAGfC,iBAAW,wBAHI;AAIfC,gBAAU,uBAJK;AAKfC,iBAAW,wBALI;AAMfC,gBAAU,uBANK;AAOfC,gBAAU,sBAPK;AAQfC,oBAAc,WARC;AASfC,wBAAkB,eATH;AAUfC,sBAAgB,iBAVD;AAWfC,gBAAU,gBAXK;AAYfC,mBAAa,cAZE;AAafC,qBAAe,gBAbA;AAcfC,qBAAe,sBAdA;AAefC,uBAAiB,wBAfF;AAgBfC,mBAAa,oBAhBE;AAiBfC,uBAAiB,wBAjBF;AAkBfC,0BAAoB,2BAlBL;AAmBfC,oBAAc,qBAnBC;AAoBfC,wBAAkB;AApBH;AAF0C,GAA/B,CAA9B,EAf8B,CAuC1B;AACL","file":"index.js","sourcesContent":["import _ from 'lodash'\r\nimport LocalSettingsService from './local-settings.service'\r\nimport config from 'config'\r\n\r\nexport { LocalSettingsService }\r\n\r\nexport default function init () {\r\n const api = this\r\n\r\n // Declare the built-in services, others are optional\r\n api.declareService('users')\r\n api.declareService('authorisations')\r\n api.declareService('tags', { context: true })\r\n api.declareService('organisations')\r\n api.declareService('members', { context: true })\r\n api.declareService('groups', { context: true })\r\n api.declareService('storage', { context: true })\r\n api.declareService('account')\r\n api.declareService('devices')\r\n\r\n // Setup service for settings edition\r\n api.createService('settings', _.merge(config.settings || {}, {\r\n service: LocalSettingsService,\r\n propertyMapping: {\r\n shortTime: 'time.format.time.short',\r\n longTime: 'time.format.time.long',\r\n shortDate: 'time.format.date.short',\r\n longDate: 'time.format.date.long',\r\n shortYear: 'time.format.year.short',\r\n longYear: 'time.format.year.long',\r\n timezone: 'time.format.timezone',\r\n timelineStep: 'time.step',\r\n timelineInterval: 'time.interval',\r\n timeseriesSpan: 'timeseries.span',\r\n location: 'locationFormat',\r\n restoreView: 'restore.view',\r\n restoreLayers: 'restore.layers',\r\n defaultLength: 'units.default.length',\r\n defaultAltitude: 'units.default.altitude',\r\n defaultArea: 'units.default.area',\r\n defaultVelocity: 'units.default.velocity',\r\n defaultTemperature: 'units.default.temperature',\r\n defaultAngle: 'units.default.angle',\r\n defaultPrecision: 'units.default.precision'\r\n }\r\n })) // Default options can be overriden from app config\r\n}\r\n"]}
|
|
@@ -58,6 +58,10 @@ exports.default = function (name, api, options) {
|
|
|
58
58
|
let settings = window.localStorage.getItem(settingsKey);
|
|
59
59
|
if (!settings) return;
|
|
60
60
|
settings = JSON.parse(settings);
|
|
61
|
+
// Backward compatibility when changed utc mode to timezone setting
|
|
62
|
+
if (_lodash2.default.get(settings, 'utc') && _lodash2.default.has(mapping, 'timezone') && !_lodash2.default.get(settings, 'timezone')) {
|
|
63
|
+
_lodash2.default.set(settings, 'timezone', 'UTC');
|
|
64
|
+
}
|
|
61
65
|
_lodash2.default.forOwn(mapping, (value, key) => {
|
|
62
66
|
if (value && _lodash2.default.has(settings, key)) {
|
|
63
67
|
_store.Store.set(value, _lodash2.default.get(settings, key));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../core/client/services/local-settings.service.js"],"names":["name","api","options","mapping","propertyMapping","rootPaths","_","uniq","values","map","path","split","settingsKey","config","appName","toLowerCase","get","id","data","forOwn","value","key","set","Store","patch","previousRootValues","rootPath","forEach","index","eventName","kebabCase","Events","$emit","saveSettings","has","window","localStorage","setItem","JSON","stringify","restoreSettings","settings","getItem","parse","getSettingsMapping"],"mappings":";;;;;;kBAKe,UAAUA,IAAV,EAAgBC,GAAhB,EAAqBC,OAArB,EAA8B;AAC3C,QAAMC,UAAUD,QAAQE,eAAxB;AACA;AACA;AACA,QAAMC,YAAYC,iBAAEC,IAAF,CAAOD,iBAAEE,MAAF,CAASL,OAAT,EAAkBM,GAAlB,CAAsBC,QAAQA,KAAKC,KAAL,CAAW,GAAX,EAAgB,CAAhB,CAA9B,CAAP,CAAlB;AACA,QAAMC,cAAcC,iBAAOC,OAAP,CAAeC,WAAf,KAA+B,GAA/B,IAAsCb,QAAQU,WAAR,IAAuB,UAA7D,CAApB;AACA,SAAO;;AAECI,OAAN,CAAWC,EAAX,EAAe;AAAA;AACb,cAAMC,OAAO,EAAb;AACAZ,yBAAEa,MAAF,CAAShB,OAAT,EAAkB,UAACiB,KAAD,EAAQC,GAAR,EAAgB;AAChC,cAAID,KAAJ,EAAW;AACTd,6BAAEgB,GAAF,CAAMJ,I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C,WAAWN,OAAOC,YAAP,CAAoBM,OAApB,CAA4B9B,WAA5B,CAAf;AACA,UAAI,CAAC6B,QAAL,EAAe;AACfA,iBAAWH,KAAKK,KAAL,CAAWF,QAAX,CAAX;
|
|
1
|
+
{"version":3,"sources":["../../../../core/client/services/local-settings.service.js"],"names":["name","api","options","mapping","propertyMapping","rootPaths","_","uniq","values","map","path","split","settingsKey","config","appName","toLowerCase","get","id","data","forOwn","value","key","set","Store","patch","previousRootValues","rootPath","forEach","index","eventName","kebabCase","Events","$emit","saveSettings","has","window","localStorage","setItem","JSON","stringify","restoreSettings","settings","getItem","parse","getSettingsMapping"],"mappings":";;;;;;kBAKe,UAAUA,IAAV,EAAgBC,GAAhB,EAAqBC,OAArB,EAA8B;AAC3C,QAAMC,UAAUD,QAAQE,eAAxB;AACA;AACA;AACA,QAAMC,YAAYC,iBAAEC,IAAF,CAAOD,iBAAEE,MAAF,CAASL,OAAT,EAAkBM,GAAlB,CAAsBC,QAAQA,KAAKC,KAAL,CAAW,GAAX,EAAgB,CAAhB,CAA9B,CAAP,CAAlB;AACA,QAAMC,cAAcC,iBAAOC,OAAP,CAAeC,WAAf,KAA+B,GAA/B,IAAsCb,QAAQU,WAAR,IAAuB,UAA7D,CAApB;AACA,SAAO;;AAECI,OAAN,CAAWC,EAAX,EAAe;AAAA;AACb,cAAMC,OAAO,EAAb;AACAZ,yBAAEa,MAAF,CAAShB,OAAT,EAAkB,UAACiB,KAAD,EAAQC,GAAR,EAAgB;AAChC,cAAID,KAAJ,EAAW;AACTd,6BAAEgB,GAAF,CAAMJ,IAAN,EAAYG,GAAZ,EAAiBE,aAAMP,GAAN,CAAUI,KAAV,CAAjB;AACD;AACF,SAJD;AAKA,eAAOF,IAAP;AAPa;AAQd,KAVI;;AAYCM,SAAN,CAAaP,EAAb,EAAiBC,IAAjB,EAAuB;AAAA;;AAAA;AACrB,cAAMO,qBAAqBpB,UAAUI,GAAV,CAAc;AAAA,iBAAYc,aAAMP,GAAN,CAA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A1B,IAAwD,CAACG,iBAAEU,GAAF,CAAMyB,QAAN,EAAgB,UAAhB,CAA7D,EAA0F;AACxFnC,yBAAEgB,GAAF,CAAMmB,QAAN,EAAgB,UAAhB,EAA4B,KAA5B;AACD;AACDnC,uBAAEa,MAAF,CAAShB,OAAT,EAAkB,CAACiB,KAAD,EAAQC,GAAR,KAAgB;AAChC,YAAID,SAASd,iBAAE4B,GAAF,CAAMO,QAAN,EAAgBpB,GAAhB,CAAb,EAAmC;AACjCE,uBAAMD,GAAN,CAAUF,KAAV,EAAiBd,iBAAEU,GAAF,CAAMyB,QAAN,EAAgBpB,GAAhB,CAAjB;AACD;AACF,OAJD;AAKD,KAjDI;;AAmDLuB,yBAAsB;AACpB,aAAOzC,OAAP;AACD;AArDI,GAAP;AAuDD,C;;AAlED;;;;AACA;;;;AACA;;AACA","file":"local-settings.service.js","sourcesContent":["import _ from 'lodash'\r\nimport config from 'config'\r\nimport { Store } from '../store'\r\nimport { Events } from '../events'\r\n\r\nexport default function (name, api, options) {\r\n const mapping = options.propertyMapping\r\n // We will emit also an event for all top level properties in case of nested ones\r\n // This simplifies event management for some listeners instead of listening to all nested properties\r\n const rootPaths = _.uniq(_.values(mapping).map(path => path.split('.')[0]))\r\n const settingsKey = config.appName.toLowerCase() + '-' + (options.settingsKey || 'settings')\r\n return {\r\n\r\n async get (id) {\r\n const data = {}\r\n _.forOwn(mapping, (value, key) => {\r\n if (value) {\r\n _.set(data, key, Store.get(value))\r\n }\r\n })\r\n return data\r\n },\r\n\r\n async patch (id, data) {\r\n const previousRootValues = rootPaths.map(rootPath => Store.get(rootPath))\r\n _.forOwn(data, (value, key) => {\r\n if (_.get(mapping, key)) {\r\n Store.set(mapping[key], value)\r\n }\r\n })\r\n rootPaths.forEach((rootPath, index) => {\r\n const eventName = _.kebabCase(`${rootPath}-changed`)\r\n Events.$emit(eventName, Store.get(rootPath), previousRootValues[index])\r\n })\r\n this.saveSettings()\r\n },\r\n\r\n saveSettings () {\r\n const data = {}\r\n _.forOwn(mapping, (value, key) => {\r\n if (value && Store.has(value)) {\r\n _.set(data, key, Store.get(value))\r\n }\r\n })\r\n window.localStorage.setItem(settingsKey, JSON.stringify(data))\r\n },\r\n\r\n restoreSettings () {\r\n let settings = window.localStorage.getItem(settingsKey)\r\n if (!settings) return\r\n settings = JSON.parse(settings)\r\n // Backward compatibility when changed utc mode to timezone setting\r\n if (_.get(settings, 'utc') && _.has(mapping, 'timezone') && !_.get(settings, 'timezone')) {\r\n _.set(settings, 'timezone', 'UTC')\r\n }\r\n _.forOwn(mapping, (value, key) => {\r\n if (value && _.has(settings, key)) {\r\n Store.set(value, _.get(settings, key))\r\n }\r\n })\r\n },\r\n\r\n getSettingsMapping () {\r\n return mapping\r\n }\r\n }\r\n}\r\n"]}
|
package/lib/core/client/time.js
CHANGED
|
@@ -9,9 +9,13 @@ var _lodash = require('lodash');
|
|
|
9
9
|
|
|
10
10
|
var _lodash2 = _interopRequireDefault(_lodash);
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _momentTimezoneWithData10YearRange = require('moment-timezone/builds/moment-timezone-with-data-10-year-range');
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _momentTimezoneWithData10YearRange2 = _interopRequireDefault(_momentTimezoneWithData10YearRange);
|
|
15
|
+
|
|
16
|
+
var _config = require('config');
|
|
17
|
+
|
|
18
|
+
var _config2 = _interopRequireDefault(_config);
|
|
15
19
|
|
|
16
20
|
var _events = require('./events');
|
|
17
21
|
|
|
@@ -25,10 +29,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
29
|
const Time = exports.Time = {
|
|
26
30
|
initialize() {
|
|
27
31
|
// Set locale globally
|
|
28
|
-
|
|
32
|
+
_momentTimezoneWithData10YearRange2.default.locale((0, _utils.getLocale)());
|
|
29
33
|
// Set the time object within the store
|
|
30
|
-
const now =
|
|
31
|
-
|
|
34
|
+
const now = _momentTimezoneWithData10YearRange2.default.utc();
|
|
35
|
+
// Try to guess user timezone
|
|
36
|
+
const timezone = _momentTimezoneWithData10YearRange2.default.tz.guess() || '';
|
|
37
|
+
_store.Store.set('time', _lodash2.default.merge(_config2.default.time || {}, {
|
|
32
38
|
range: {
|
|
33
39
|
start: now.clone().subtract(1, 'months').startOf('day'),
|
|
34
40
|
end: now.clone().endOf('day'),
|
|
@@ -48,23 +54,24 @@ const Time = exports.Time = {
|
|
|
48
54
|
short: 'YY',
|
|
49
55
|
long: 'YYYY'
|
|
50
56
|
},
|
|
51
|
-
|
|
57
|
+
timezone
|
|
52
58
|
},
|
|
53
59
|
currentTime: now,
|
|
54
60
|
step: 60, // 1H
|
|
55
61
|
interval: 60 // 1m
|
|
56
|
-
});
|
|
62
|
+
}));
|
|
57
63
|
this.updateTimeRangeQuery();
|
|
58
64
|
// Make filter react to external changes to update the query
|
|
59
65
|
_events.Events.$on('time-range-changed', () => this.updateTimeRangeQuery());
|
|
60
66
|
},
|
|
61
67
|
convertToMoment(datetime) {
|
|
62
|
-
if (
|
|
68
|
+
if (_momentTimezoneWithData10YearRange2.default.isMoment(datetime)) {
|
|
63
69
|
// Clone to avoid mutating and force UTC mode
|
|
64
|
-
return
|
|
70
|
+
return _momentTimezoneWithData10YearRange2.default.utc(datetime.valueOf());
|
|
65
71
|
} else {
|
|
66
72
|
// Convert from Date, string or milliseconds (ie EPOCH)
|
|
67
|
-
|
|
73
|
+
// Check for ambiguous input as ISO 8601 consider it as locale and not UTC
|
|
74
|
+
if (typeof datetime === 'string' && !datetime.endsWith('Z')) return (0, _momentTimezoneWithData10YearRange2.default)(datetime).utc();else return _momentTimezoneWithData10YearRange2.default.utc(datetime);
|
|
68
75
|
}
|
|
69
76
|
},
|
|
70
77
|
get() {
|
|
@@ -89,15 +96,18 @@ const Time = exports.Time = {
|
|
|
89
96
|
getFormat() {
|
|
90
97
|
return this.get().format;
|
|
91
98
|
},
|
|
99
|
+
getFormatTimezone() {
|
|
100
|
+
return this.getFormat().timezone;
|
|
101
|
+
},
|
|
92
102
|
format(datetime, format, options = { year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit' }) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
currentTime
|
|
103
|
+
const currentTime = this.convertToMoment(datetime);
|
|
104
|
+
// Convert to local time
|
|
105
|
+
if (this.getFormatTimezone()) {
|
|
106
|
+
currentTime.tz(this.getFormatTimezone());
|
|
97
107
|
}
|
|
98
108
|
if (format === 'iso') return currentTime.format();else if (format === 'locale') return currentTime.toDate().toLocaleString((0, _utils.getLocale)(), options);
|
|
99
109
|
// Defaults to long mode if not given
|
|
100
|
-
else return currentTime.format(_lodash2.default.get(this.getFormat(), format
|
|
110
|
+
else return currentTime.format(_lodash2.default.get(this.getFormat(), format));
|
|
101
111
|
},
|
|
102
112
|
getCurrentTime() {
|
|
103
113
|
return this.get().currentTime;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../core/client/time.js"],"names":["Time","initialize","moment","locale","now","utc","Store","set","range","start","clone","subtract","startOf","end","endOf","field","query","format","
|
|
1
|
+
{"version":3,"sources":["../../../core/client/time.js"],"names":["Time","initialize","moment","locale","now","utc","timezone","tz","guess","Store","set","_","merge","config","time","range","start","clone","subtract","startOf","end","endOf","field","query","format","short","long","date","year","currentTime","step","interval","updateTimeRangeQuery","Events","$on","convertToMoment","datetime","isMoment","valueOf","endsWith","get","getRange","patchRange","patch","getRangeQuery","$gte","$lte","isEqual","getFormat","getFormatTimezone","options","month","day","hour","minute","toDate","toLocaleString","getCurrentTime","setCurrentTime","isSame","getCurrentFormattedTime","iso","getStep"],"mappings":";;;;;;;AAAA;;;;AACA;;;;AACA;;;;AACA;;AACA;;AACA;;;;AAEA;AACO,MAAMA,sBAAO;AAClBC,eAAc;AACZ;AACAC,gDAAOC,MAAP,CAAc,uBAAd;AACA;AACA,UAAMC,MAAMF,4CAAOG,GAAP,EAAZ;AACA;AACA,UAAMC,WAAWJ,4CAAOK,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ezone/builds/moment-timezone-with-data-10-year-range'\r\nimport config from 'config'\r\nimport { Events } from './events'\r\nimport { Store } from './store'\r\nimport { getLocale } from './utils'\r\n\r\n// Export singleton\r\nexport const Time = {\r\n initialize () {\r\n // Set locale globally\r\n moment.locale(getLocale())\r\n // Set the time object within the store\r\n const now = moment.utc()\r\n // Try to guess user timezone\r\n const timezone = moment.tz.guess() || ''\r\n Store.set('time', _.merge(config.time || {}, {\r\n range: {\r\n start: now.clone().subtract(1, 'months').startOf('day'),\r\n end: now.clone().endOf('day'),\r\n field: 'createdAt',\r\n query: {}\r\n },\r\n format: {\r\n time: {\r\n short: 'H[h]',\r\n long: 'HH:mm'\r\n },\r\n date: {\r\n short: 'DD/MM',\r\n long: 'dddd D'\r\n },\r\n year: {\r\n short: 'YY',\r\n long: 'YYYY'\r\n },\r\n timezone\r\n },\r\n currentTime: now,\r\n step: 60, // 1H\r\n interval: 60 // 1m\r\n }))\r\n this.updateTimeRangeQuery()\r\n // Make filter react to external changes to update the query\r\n Events.$on('time-range-changed', () => this.updateTimeRangeQuery())\r\n },\r\n convertToMoment (datetime) {\r\n if (moment.isMoment(datetime)) {\r\n // Clone to avoid mutating and force UTC mode\r\n return moment.utc(datetime.valueOf())\r\n } else { // Convert from Date, string or milliseconds (ie EPOCH)\r\n // Check for ambiguous input as ISO 8601 consider it as locale and not UTC\r\n if ((typeof datetime === 'string') && !datetime.endsWith('Z')) return moment(datetime).utc()\r\n else return moment.utc(datetime)\r\n }\r\n },\r\n get () {\r\n return Store.get('time')\r\n },\r\n getRange () {\r\n return this.get().range\r\n },\r\n patchRange (range) {\r\n Store.patch('time.range', range)\r\n },\r\n getRangeQuery () {\r\n return Store.get('time.range.query')\r\n },\r\n // Build sort query\r\n updateTimeRangeQuery () {\r\n const query = {}\r\n query[this.getRange().field] = { $gte: this.getRange().start.format(), $lte: this.getRange().end.format() }\r\n // Avoid reentrance as we listen to other filter property changes\r\n if (!_.isEqual(query, this.getRangeQuery())) Store.patch('time.range', { query })\r\n },\r\n getFormat () {\r\n return this.get().format\r\n },\r\n getFormatTimezone () {\r\n return this.getFormat().timezone\r\n },\r\n format (datetime, format, options = { year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit' }) {\r\n const currentTime = this.convertToMoment(datetime)\r\n // Convert to local time\r\n if (this.getFormatTimezone()) {\r\n currentTime.tz(this.getFormatTimezone())\r\n }\r\n if (format === 'iso') return currentTime.format()\r\n else if (format === 'locale') return currentTime.toDate().toLocaleString(getLocale(), options)\r\n // Defaults to long mode if not given\r\n else return currentTime.format(_.get(this.getFormat(), format))\r\n },\r\n getCurrentTime () {\r\n return this.get().currentTime\r\n },\r\n setCurrentTime (datetime) {\r\n const now = this.convertToMoment(datetime)\r\n if (this.getCurrentTime().isSame(now)) return\r\n Store.patch('time.currentTime', now)\r\n },\r\n getCurrentFormattedTime () {\r\n const currentTime = this.getCurrentTime()\r\n return {\r\n time: {\r\n short: this.format(currentTime, 'time.short'),\r\n long: this.format(currentTime, 'time.long')\r\n },\r\n date: {\r\n short: this.format(currentTime, 'date.short'),\r\n long: this.format(currentTime, 'date.long')\r\n },\r\n year: {\r\n short: this.format(currentTime, 'year.short'),\r\n long: this.format(currentTime, 'year.long')\r\n },\r\n iso: this.format(currentTime, 'iso')\r\n }\r\n },\r\n getStep () {\r\n return this.get().step\r\n }\r\n}\r\n"]}
|
package/lib/core/client/units.js
CHANGED
|
@@ -44,6 +44,16 @@ const length = {
|
|
|
44
44
|
definition: '1852 m'
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
+
const altitude = {
|
|
48
|
+
m: {
|
|
49
|
+
symbol: 'units.METER_SYMBOL',
|
|
50
|
+
label: 'units.METER_LABEL'
|
|
51
|
+
},
|
|
52
|
+
ft: {
|
|
53
|
+
symbol: 'units.FEET_SYMBOL',
|
|
54
|
+
label: 'units.FEET_LABEL'
|
|
55
|
+
}
|
|
56
|
+
};
|
|
47
57
|
const area = {
|
|
48
58
|
'm^2': {
|
|
49
59
|
symbol: 'units.SQUARED_METER_SYMBOL',
|
|
@@ -104,6 +114,7 @@ const angle = {
|
|
|
104
114
|
|
|
105
115
|
const quantities = {
|
|
106
116
|
length,
|
|
117
|
+
altitude,
|
|
107
118
|
area,
|
|
108
119
|
velocity,
|
|
109
120
|
temperature,
|
|
@@ -117,6 +128,7 @@ const quantities = {
|
|
|
117
128
|
_store.Store.set('units', _lodash2.default.merge(_config2.default.units || {}, quantities, {
|
|
118
129
|
default: {
|
|
119
130
|
length: 'm',
|
|
131
|
+
altitude: 'm',
|
|
120
132
|
area: 'm^2',
|
|
121
133
|
velocity: 'm/s',
|
|
122
134
|
temperature: 'degC',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../core/client/units.js"],"names":["math","length","m","symbol","label","mi","NM","definition","area","acre","hectare","velocity","kt","temperature","degC","degF","K","angle","deg","rad","quantities","Units","initialize","Store","set","_","merge","config","units","default","precision","getQuantities","forEach","quantity","getUnits","unit","createUnit","name","omit","get","getDefaultPrecision","keys","values","mapValues","value","key","Object","assign","concat","getUnit","find","getUnitSymbol","i18next","t","getDefaultUnit","quantityOrUnit","defaultUnit","baseUnit","convert","sourceUnit","targetUnit","n","toNumber","format","options","output","toFixed"],"mappings":";;;;;;;AAAA;;;;AACA;;;;AACA;;IAAYA,I;;AACZ;;;;AACA;;;;;;AAEA;AACA;AACA,MAAMC,SAAS;AACbC,KAAG;AACDC,YAAQ,oBADP;AAEDC,WAAO;AAFN,GADU;AAKbC,MAAI;AACFF,YAAQ,mBADN;AAEFC,WAAO;AAFL,GALS;AASbE,MAAI;AACFH,YAAQ,4BADN;AAEFC,WAAO,2BAFL;AAGFG,gBAAY;AAHV;AATS,CAAf;AAeA,MAAMC,OAAO;AACX,SAAO;
|
|
1
|
+
{"version":3,"sources":["../../../core/client/units.js"],"names":["math","length","m","symbol","label","mi","NM","definition","altitude","ft","area","acre","hectare","velocity","kt","temperature","degC","degF","K","angle","deg","rad","quantities","Units","initialize","Store","set","_","merge","config","units","default","precision","getQuantities","forEach","quantity","getUnits","unit","createUnit","name","omit","get","getDefaultPrecision","keys","values","mapValues","value","key","Object","assign","concat","getUnit","find","getUnitSymbol","i18next","t","getDefaultUnit","quantityOrUnit","defaultUnit","baseUnit","convert","sourceUnit","targetUnit","n","toNumber","format","options","output","toFixed"],"mappings":";;;;;;;AAAA;;;;AACA;;;;AACA;;IAAYA,I;;AACZ;;;;AACA;;;;;;AAEA;AACA;AACA,MAAMC,SAAS;AACbC,KAAG;AACDC,YAAQ,oBADP;AAEDC,WAAO;AAFN,GADU;AAKbC,MAAI;AACFF,YAAQ,mBADN;AAEFC,WAAO;AAFL,GALS;AASbE,MAAI;AACFH,YAAQ,4BADN;AAEFC,WAAO,2BAFL;AAGFG,gBAAY;AAHV;AATS,CAAf;AAeA,MAAMC,WAAW;AACfN,KAAG;AACDC,YAAQ,oBADP;AAEDC,WAAO;AAFN,GADY;AAKfK,MAAI;AACFN,YAAQ,mBADN;AAEFC,WAAO;AAFL;AALW,CAAjB;AAUA,MAAMM,OAAO;AACX,SAAO;AACLP,YAAQ,4BADH;AAELC,WAAO;AAFF,GADI;AAKX,UAAQ;AACND,YAAQ,gCADF;AAENC,WAAO;AAFD,GALG;AASXO,QAAM;AACJR,YAAQ,mBADJ;AAEJC,WAAO;AAFH,GATK;AAaXQ,WAAS;AACPT,YAAQ,sBADD;AAEPC,WAAO;AAFA;AAbE,CAAb;AAkBA,MAAMS,WAAW;AACf,SAAO;AACLV,YAAQ,+BADH;AAELC,WAAO;AAFF,GADQ;AAKf,UAAQ;AACND,YAAQ,iCADF;AAENC,WAAO;AAFD,GALO;AASfU,MAAI;AACFX,YAAQ,mBADN;AAEFC,WAAO,kBAFL;AAGFG,gBAAY;AAHV;AATW,CAAjB;AAeA,MAAMQ,cAAc;AAClBC,QAAM;AACJb,YAAQ,sBADJ;AAEJC,WAAO;AAFH,GADY;AAKlBa,QAAM;AACJd,YAAQ,yBADJ;AAEJC,WAAO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d;AACf;AACD,WAAOuB,WAAP;AACD,GA/DkB;AAgEnBE,UAASd,KAAT,EAAgBe,UAAhB,EAA4BC,UAA5B,EAAwC;AACtC,QAAID,eAAeC,UAAnB,EAA+B,OAAOhB,KAAP;AAC/B,QAAIiB,IAAI/D,KAAKqC,IAAL,CAAUS,KAAV,EAAiBe,UAAjB,CAAR;AACAE,QAAIA,EAAEC,QAAF,CAAWF,UAAX,CAAJ;AACA;AACAC,QAAKD,eAAe,KAAf,GAAwBC,IAAI,GAAJ,GAAUA,IAAI,KAAd,GAAsBA,CAA9C,GAAmDA,CAAxD;AACA,WAAOA,CAAP;AACD,GAvEkB;AAwEnBE,SAAQnB,KAAR,EAAee,UAAf,EAA2BC,UAA3B,EAAuCI,UAAU,EAAE/D,QAAQ,IAAV,EAAjD,EAAmE;AACjE;AACA,QAAI,CAAC2D,UAAL,EAAiBA,aAAa,KAAKN,cAAL,CAAoBK,UAApB,CAAb;AACjB,UAAME,IAAKD,aAAa,KAAKF,OAAL,CAAad,KAAb,EAAoBe,UAApB,EAAgCC,UAAhC,CAAb,GAA2DhB,KAAtE;AACA,QAAIqB,SAASJ,EAAEK,OAAF,CAAUF,QAAQlC,SAAR,IAAqB,KAAKU,mBAAL,EAA/B,CAAb;AACA,QAAIwB,QAAQ/D,MAAZ,EAAoB;AAClBgE,gBAAW,IAAGL,aAAa,KAAKT,aAAL,CAAmBS,UAAnB,CAAb,GAA8C,KAAKT,aAAL,CAAmBQ,UAAnB,CAA+B,EAA3F;AACD;AACD,WAAOM,MAAP;AACD;AAjFkB,CAAd","file":"units.js","sourcesContent":["import _ from 'lodash'\r\nimport i18next from 'i18next'\r\nimport * as math from 'mathjs'\r\nimport config from 'config'\r\nimport { Store } from './store'\r\n\r\n// Default units organised by physical quantity\r\n// Each key is the internal mathjs \"identifier\" of the unit\r\nconst length = {\r\n m: {\r\n symbol: 'units.METER_SYMBOL',\r\n label: 'units.METER_LABEL'\r\n },\r\n mi: {\r\n symbol: 'units.MILE_SYMBOL',\r\n label: 'units.MILE_LABEL'\r\n },\r\n NM: {\r\n symbol: 'units.NAUTICAL_MILE_SYMBOL',\r\n label: 'units.NAUTICAL_MILE_LABEL',\r\n definition: '1852 m'\r\n }\r\n}\r\nconst altitude = {\r\n m: {\r\n symbol: 'units.METER_SYMBOL',\r\n label: 'units.METER_LABEL'\r\n },\r\n ft: {\r\n symbol: 'units.FEET_SYMBOL',\r\n label: 'units.FEET_LABEL'\r\n }\r\n}\r\nconst area = {\r\n 'm^2': {\r\n symbol: 'units.SQUARED_METER_SYMBOL',\r\n label: 'units.SQUARED_METER_LABEL'\r\n },\r\n 'km^2': {\r\n symbol: 'units.SQUARED_KILOMETER_SYMBOL',\r\n label: 'units.SQUARED_KILOMETER_LABEL'\r\n },\r\n acre: {\r\n symbol: 'units.ACRE_SYMBOL',\r\n label: 'units.ACRE_LABEL'\r\n },\r\n hectare: {\r\n symbol: 'units.HECTARE_SYMBOL',\r\n label: 'units.HECTARE_LABEL'\r\n }\r\n}\r\nconst velocity = {\r\n 'm/s': {\r\n symbol: 'units.METER_PER_SECOND_SYMBOL',\r\n label: 'units.METER_PER_SECOND_LABEL'\r\n },\r\n 'km/h': {\r\n symbol: 'units.KILOMETER_PER_HOUR_SYMBOL',\r\n label: 'units.KILOMETER_PER_HOUR_LABEL'\r\n },\r\n kt: {\r\n symbol: 'units.KNOT_SYMBOL',\r\n label: 'units.KNOT_LABEL',\r\n definition: '0.514444 m/s'\r\n }\r\n}\r\nconst temperature = {\r\n degC: {\r\n symbol: 'units.CELSIUS_SYMBOL',\r\n label: 'units.CELSIUS_LABEL'\r\n },\r\n degF: {\r\n symbol: 'units.FAHRENHEIT_SYMBOL',\r\n label: 'units.FAHRENHEIT_LABEL'\r\n },\r\n K: {\r\n symbol: 'units.KELVIN_SYMBOL',\r\n label: 'units.KELVIN_LABEL'\r\n }\r\n}\r\nconst angle = {\r\n deg: {\r\n symbol: 'units.DEGREE_SYMBOL',\r\n label: 'units.DEGREE_LABEL'\r\n },\r\n rad: {\r\n symbol: 'units.RADIAN_SYMBOL',\r\n label: 'units.RADIAN_LABEL'\r\n }\r\n}\r\n\r\nconst quantities = {\r\n length,\r\n altitude,\r\n area,\r\n velocity,\r\n temperature,\r\n angle\r\n}\r\n\r\n// Export singleton\r\nexport const Units = {\r\n\r\n initialize () {\r\n // Set the units object within the store\r\n Store.set('units', _.merge(config.units || {},\r\n quantities, {\r\n default: {\r\n length: 'm',\r\n altitude: 'm',\r\n area: 'm^2',\r\n velocity: 'm/s',\r\n temperature: 'degC',\r\n angle: 'deg',\r\n precision: 1\r\n }\r\n }))\r\n // Create units not defined by default in mathjs\r\n this.getQuantities().forEach(quantity => {\r\n const units = this.getUnits(quantity)\r\n units.forEach(unit => {\r\n if (unit.definition) math.createUnit(unit.name, _.omit(unit, ['label']))\r\n })\r\n })\r\n },\r\n get () {\r\n return Store.get('units')\r\n },\r\n getDefaultPrecision () {\r\n return Store.get('units.default.precision', 1)\r\n },\r\n getQuantities () {\r\n return _.keys(_.omit(this.get(), ['default']))\r\n },\r\n getUnits (quantity) {\r\n // Get units for a given quantity\r\n if (quantity) {\r\n const units = Store.get(`units.${quantity}`, {})\r\n return _.values(_.mapValues(units, (value, key) => Object.assign({ name: key, quantity }, value)))\r\n } else { // Or all units\r\n let units = []\r\n this.getQuantities().forEach(quantity => {\r\n units = units.concat(this.getUnits(quantity))\r\n })\r\n return units\r\n }\r\n },\r\n getUnit (unit) {\r\n return _.find(this.getUnits(), { name: unit })\r\n },\r\n getUnitSymbol (unit) {\r\n const definition = this.getUnit(unit)\r\n return (definition ? i18next.t(definition.symbol) : unit)\r\n },\r\n getDefaultUnit (quantityOrUnit) {\r\n // Check for quantity first\r\n let defaultUnit = Store.get(`units.default.${quantityOrUnit}`)\r\n // If not check by matching quantity based on given unit\r\n if (!defaultUnit) {\r\n const baseUnit = Units.getUnit(quantityOrUnit)\r\n // Get default unit for this quantity instead\r\n if (baseUnit) defaultUnit = Units.getDefaultUnit(baseUnit.quantity)\r\n }\r\n return defaultUnit\r\n },\r\n convert (value, sourceUnit, targetUnit) {\r\n if (sourceUnit === targetUnit) return value\r\n let n = math.unit(value, sourceUnit)\r\n n = n.toNumber(targetUnit)\r\n // Remap from [-180,+180[ to [0,360[ for angles\r\n n = (targetUnit === 'deg' ? (n < 0.0 ? n + 360.0 : n) : n)\r\n return n\r\n },\r\n format (value, sourceUnit, targetUnit, options = { symbol: true }) {\r\n // If target unit is not given use default one\r\n if (!targetUnit) targetUnit = this.getDefaultUnit(sourceUnit)\r\n const n = (targetUnit ? this.convert(value, sourceUnit, targetUnit) : value)\r\n let output = n.toFixed(options.precision || this.getDefaultPrecision())\r\n if (options.symbol) {\r\n output += ` ${targetUnit ? this.getUnitSymbol(targetUnit) : this.getUnitSymbol(sourceUnit)}`\r\n }\r\n return output\r\n }\r\n}\r\n"]}
|
package/lib/core/client/utils.js
CHANGED
|
@@ -41,11 +41,16 @@ exports.getIconName = getIconName;
|
|
|
41
41
|
exports.processIcon = processIcon;
|
|
42
42
|
exports.dotify = dotify;
|
|
43
43
|
exports.isObjectID = isObjectID;
|
|
44
|
+
exports.getTimezoneLabel = getTimezoneLabel;
|
|
44
45
|
|
|
45
46
|
var _lodash = require('lodash');
|
|
46
47
|
|
|
47
48
|
var _lodash2 = _interopRequireDefault(_lodash);
|
|
48
49
|
|
|
50
|
+
var _moment = require('moment');
|
|
51
|
+
|
|
52
|
+
var _moment2 = _interopRequireDefault(_moment);
|
|
53
|
+
|
|
49
54
|
var _emailValidator = require('email-validator');
|
|
50
55
|
|
|
51
56
|
var _emailValidator2 = _interopRequireDefault(_emailValidator);
|
|
@@ -251,4 +256,10 @@ var checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$');
|
|
|
251
256
|
function isObjectID(id) {
|
|
252
257
|
return id.length === 24 && checkForHexRegExp.test(id);
|
|
253
258
|
}
|
|
259
|
+
|
|
260
|
+
// Add UTC offset to timezone name
|
|
261
|
+
function getTimezoneLabel(timezone) {
|
|
262
|
+
const offset = (0, _moment2.default)().tz(timezone).format('Z');
|
|
263
|
+
return `${timezone} (${offset})`;
|
|
264
|
+
}
|
|
254
265
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../core/client/utils.js"],"names":["options","Promise","resolve","reject","Dialog","create","onOk","data","ok","onCancel","cancel","onDismiss","dismiss","dialog","createQuerablePromise","getPaletteFromColor","getColorFromPalette","getLocale","getAppLocale","getInitials","isEmailValid","createThumbnail","downloadAsBlob","toast","getIconName","processIcon","dotify","isObjectID","Notify","setDefaults","position","timeout","textColor","actions","icon","color","Loading","spinnerColor","spinnerSize","messageColor","customClass","promiseOrExecutor","promise","isResolved","isPending","isRejected","isFulfilled","result","then","value","error","Colors","dark","red","pink","purple","indigo","blue","cyan","teal","green","lime","yellow","amber","orange","brown","grey","_","findKey","item","locale","navigator","language","languages","browserLanguage","userLanguage","systemLanguage","languageCodes","split","length","localeConfig","config","localeBrowser","default","name","initials","toUpperCase","match","join","email","emailValidator","validate","imageDataUri","width","height","quality","callback","image","document","createElement","onload","canvas","ctx","getContext","drawImage","toDataURL","src","filename","mimeType","blob","Blob","type","Platform","is","cordova","window","requestFileSystem","LocalFileSystem","PERSISTENT","fs","root","getFile","exclusive","fileEntry","createWriter","fileWriter","write","plugins","fileOpener2","open","nativeURL","Object","assign","omit","object","path","get","startsWith","set","dotifiedObject","recurse","current","forOwn","key","newKey","checkForHexRegExp","RegExp","id","test"],"mappings":";;;;;;;AAiKA;;+BACO,WAAuBA,OAAvB,EAAgC;AACrC,WAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAUC,MAAV,EAAqB;AACtCC,qBAAOC,MAAP,CAAcL,OAAd,EACGM,IADH,CACQ,UAACC,IAAD;AAAA,eAAUL,QAAQ,EAAEM,IAAI,IAAN,EAAYD,IAAZ,EAAR,CAAV;AAAA,OADR,EAEGE,QAFH,CAEY;AAAA,eAAMP,QAAQ,EAAEQ,Q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uG,UAAL,CAAgB,KAAhB,IAA0B,OAAMvG,IAAK,EAArC,GAAyCA,IAAjD;AACD;;AAEM,SAAST,WAAT,CAAsB6G,MAAtB,EAA8BC,OAAO,WAArC,EAAkD;AACvD;AACApE,mBAAEuE,GAAF,CAAMJ,MAAN,EAAcC,IAAd,EAAoB/G,YAAY8G,MAAZ,EAAoBC,IAApB,CAApB;AACD;;AAED;AACO,SAAS7G,MAAT,CAAiB4G,MAAjB,EAAyB;AAC9B,MAAIK,iBAAiB,EAArB;AACA,WAASC,OAAT,CAAkBN,MAAlB,EAA0BO,OAA1B,EAAmC;AACjC1E,qBAAE2E,MAAF,CAASR,MAAT,EAAiB,CAACrF,KAAD,EAAQ8F,GAAR,KAAgB;AAC/B,UAAIC,SAAUH,UAAUA,UAAU,GAAV,GAAgBE,GAA1B,GAAgCA,GAA9C,CAD+B,CACoB;AACnD,UAAI9F,SAAS,OAAOA,KAAP,KAAiB,QAA9B,EAAwC;AACtC2F,gBAAQ3F,KAAR,EAAe+F,MAAf,EADsC,CACf;AACxB,OAFD,MAEO;AACLL,uBAAeK,MAAf,IAAyB/F,KAAzB,CADK,CAC0B;AAChC;AACF,KAPD;AAQD;;AAED2F,UAAQN,MAAR;AACA,SAAOK,cAAP;AACD;;AAED;AACA,IAAIM,oBAAoB,IAAIC,MAAJ,CAAW,mBAAX,CAAxB;;AAEA;AACO,SAASvH,UAAT,CAAqBwH,EAArB,EAAyB;AAC9B,SAAQA,GAAGpE,MAAH,KAAc,EAAd,IAAoBkE,kBAAkBG,IAAlB,CAAuBD,EAAvB,CAA5B;AACD","file":"utils.js","sourcesContent":["import _ from 'lodash'\r\nimport emailValidator from 'email-validator'\r\nimport config from 'config'\r\nimport { Platform, Notify, Dialog, Loading, exportFile } from 'quasar'\r\n\r\nNotify.setDefaults({\r\n position: 'bottom-left',\r\n timeout: 5000,\r\n textColor: 'white',\r\n actions: [{ icon: 'las la-times', color: 'white' }]\r\n})\r\n\r\nLoading.setDefaults({\r\n spinnerColor: 'primary',\r\n spinnerSize: 140,\r\n messageColor: 'white',\r\n customClass: 'full-width'\r\n})\r\n\r\n/**\r\n * This function allow you to modify a JS Promise by adding some status properties.\r\n * Based on: http://stackoverflow.com/questions/21485545/is-there-a-way-to-tell-if-an-es6-promise-is-fulfilled-rejected-resolved\r\n * But modified according to the specs of promises : https://promisesaplus.com/\r\n */\r\nexport function createQuerablePromise (promiseOrExecutor) {\r\n let promise = promiseOrExecutor\r\n if (typeof promiseOrExecutor === 'function') {\r\n promise = new Promise(promiseOrExecutor)\r\n }\r\n // Don't modify any promise that has been already modified.\r\n if (promise.isResolved) return promise\r\n\r\n // Set initial state\r\n let isPending = true\r\n let isRejected = false\r\n let isFulfilled = false\r\n\r\n // Observe the promise, saving the fulfillment in a closure scope.\r\n const result = promise.then(\r\n (value) => {\r\n isFulfilled = true\r\n isPending = false\r\n return value\r\n },\r\n (error) => {\r\n isRejected = true\r\n isPending = false\r\n throw error\r\n }\r\n )\r\n\r\n result.isFulfilled = () => { return isFulfilled }\r\n result.isPending = () => { return isPending }\r\n result.isRejected = () => { return isRejected }\r\n\r\n return result\r\n}\r\n\r\nexport const Colors = {\r\n dark: '#333',\r\n red: '#f44336',\r\n pink: '#e91e63',\r\n purple: '#9c27b0',\r\n 'deep-purple': '#673ab7',\r\n indigo: '#3f51b5',\r\n blue: '#2196f3',\r\n 'light-blue': '#03a9f4',\r\n cyan: '#00bcd4',\r\n teal: '#009688',\r\n green: '#4caf50',\r\n 'light-green': '#8bc34a',\r\n lime: '#cddc39',\r\n yellow: '#ffeb3b',\r\n amber: '#ffc107',\r\n orange: '#ff9800',\r\n 'deep-orange': '#ff5722',\r\n brown: '#795548',\r\n grey: '#9e9e9e',\r\n 'blue-grey': '#607d8b'\r\n}\r\n\r\nexport function getPaletteFromColor (color) {\r\n return _.findKey(Colors, item => item === color)\r\n}\r\n\r\nexport function getColorFromPalette (color) {\r\n return Colors[color]\r\n}\r\n\r\nexport function getLocale () {\r\n const locale =\r\n navigator.language ||\r\n navigator.languages[0] ||\r\n navigator.browserLanguage ||\r\n navigator.userLanguage ||\r\n navigator.systemLanguage\r\n\r\n if (locale) {\r\n // see https://www.ietf.org/rfc/bcp/bcp47.txt\r\n const languageCodes = _.split(locale, '-')\r\n if (languageCodes.length > 0) return languageCodes[0]\r\n }\r\n // return undefined by default\r\n}\r\n\r\nexport function getAppLocale () {\r\n const localeConfig = config.locale || {}\r\n const localeBrowser = getLocale()\r\n return localeConfig.default || localeBrowser\r\n}\r\n\r\nexport function getInitials (name) {\r\n const initials = name.toUpperCase().match(/\\b\\w/g) || []\r\n return initials.join('')\r\n}\r\n\r\nexport function isEmailValid (email) {\r\n return emailValidator.validate(email)\r\n}\r\n\r\nexport function createThumbnail (imageDataUri, width, height, quality, callback) {\r\n const image = document.createElement('img')\r\n image.onload = function () {\r\n const canvas = document.createElement('canvas')\r\n const ctx = canvas.getContext('2d')\r\n // set its dimension to target size\r\n canvas.width = width\r\n canvas.height = height\r\n ctx.drawImage(this, 0, 0, width, height)\r\n callback(canvas.toDataURL('image/jpeg', quality))\r\n }\r\n image.src = imageDataUri\r\n}\r\n\r\nexport function downloadAsBlob (data, filename, mimeType) {\r\n const blob = new Blob([data], { type: mimeType })\r\n if (Platform.is.cordova) {\r\n window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, (fs) => {\r\n fs.root.getFile(filename, { create: true, exclusive: false }, (fileEntry) => {\r\n fileEntry.createWriter((fileWriter) => {\r\n fileWriter.write(blob)\r\n cordova.plugins.fileOpener2.open(fileEntry.nativeURL, mimeType)\r\n })\r\n })\r\n })\r\n } else {\r\n exportFile(filename, blob)\r\n }\r\n}\r\n\r\nexport function toast (options) {\r\n // We deduce the color from the type as it was not initially supported by Quasar.\r\n // The built-in type property appeared with Quasar 1.9 so that we should not need this function anymore.\r\n // However, we have prefered to keep this function for backward compatibility.\r\n const type = options.type || 'negative'\r\n // Notify.create returns a function that, when invoked, hides the notification\r\n return Notify.create(Object.assign({\r\n color: (type === 'negative' ? 'red' : (type === 'warning' ? 'orange' : 'green'))\r\n }, _.omit(options, ['type'])))\r\n}\r\n\r\n// Simplify Quasar dialog plugin usage with async/await\r\nexport async function dialog (options) {\r\n return new Promise((resolve, reject) => {\r\n Dialog.create(options)\r\n .onOk((data) => resolve({ ok: true, data }))\r\n .onCancel(() => resolve({ cancel: true }))\r\n .onDismiss(() => resolve({ dismiss: true }))\r\n })\r\n}\r\n\r\n// Extract icon name from a given icon property on a given target object\r\nexport function getIconName (object, path = 'icon.name') {\r\n // Make function work in a generic way, sometimes the provided input is directly the icon name\r\n const icon = (typeof object === 'object' ? _.get(object, path, '') : object)\r\n // Check whether the returned icon is an object (can be true in some cases)\r\n if (typeof icon === 'object') return ''\r\n // Name icons to ensure backward compatibility with font awesome 4\r\n return (icon.startsWith('fa-') ? `fas ${icon}` : icon)\r\n}\r\n\r\nexport function processIcon (object, path = 'icon.name') {\r\n // Process icons for backward compatibility with font awesome 4\r\n _.set(object, path, getIconName(object, path))\r\n}\r\n\r\n// Transform nested object to dot notation\r\nexport function dotify (object) {\r\n var dotifiedObject = {}\r\n function recurse (object, current) {\r\n _.forOwn(object, (value, key) => {\r\n var newKey = (current ? current + '.' + key : key) // joined key with dot\r\n if (value && typeof value === 'object') {\r\n recurse(value, newKey) // it's a nested object, so do it again\r\n } else {\r\n dotifiedObject[newKey] = value // it's not an object, so set the property\r\n }\r\n })\r\n }\r\n\r\n recurse(object)\r\n return dotifiedObject\r\n}\r\n\r\n// Regular expression that checks for hex value\r\nvar checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$')\r\n\r\n// Check if a string is a valid MongoDB Object ID\r\nexport function isObjectID (id) {\r\n return (id.length === 24 && checkForHexRegExp.test(id))\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../core/client/utils.js"],"names":["options","Promise","resolve","reject","Dialog","create","onOk","data","ok","onCancel","cancel","onDismiss","dismiss","dialog","createQuerablePromise","getPaletteFromColor","getColorFromPalette","getLocale","getAppLocale","getInitials","isEmailValid","createThumbnail","downloadAsBlob","toast","getIconName","processIcon","dotify","isObjectID","getTimezoneLabel","Notify","setDefaults","position","timeout","textColor","actions","icon","color","Loading","spinnerColor","spinnerSize","messageColor","customClass","promiseOrExecutor","promise","isResolved","isPending","isRejected","isFulfilled","result","then","value","error","Colors","dark","red","pink","purple","indigo","blue","cyan","teal","green","lime","yellow","amber","orange","brown","grey","_","findKey","item","locale","navigator","language","languages","browserLanguage","userLanguage","systemLanguage","languageCodes","split","length","localeConfig","config","localeBrowser","default","name","initials","toUpperCase","match","join","email","emailValidator","validate","imageDataUri","width","height","quality","callback","image","document","createElement","onload","canvas","ctx","getContext","drawImage","toDataURL","src","filename","mimeType","blob","Blob","type","Platform","is","cordova","window","requestFileSystem","LocalFileSystem","PERSISTENT","fs","root","getFile","exclusive","fileEntry","createWriter","fileWriter","write","plugins","fileOpener2","open","nativeURL","Object","assign","omit","object","path","get","startsWith","set","dotifiedObject","recurse","current","forOwn","key","newKey","checkForHexRegExp","RegExp","id","test","timezone","offset","tz","format"],"mappings":";;;;;;;AAkKA;;+BACO,WAAuBA,OAAvB,EAAgC;AACrC,WAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAUC,MAAV,EAAqB;AACtCC,qBAAOC,MAAP,CAAcL,OAAd,EACGM,IADH,CACQ,UAACC,IAAD;AAAA,eAAUL,QAAQ,EAAEM,IAAI,IAAN,EAAYD,IAAZ,EAAR,CAAV;AAAA,OADR,EAEGE,QAFH,CAEY;AAAA,eAAMP,QAAQ,EAAEQ,QAAQ,IAAV,EAAR,CAAN;AAAA,OAFZ,EAGGC,SAHH,CAGa;AAAA,eAAMT,QAAQ,EAAEU,SAAS,IAAX,EAAR,CAAN;AAAA,OAHb;AAID,KALM,CAAP;AAMD,G;;kBAPqBC,M;;;;;AAStB;;;QAnJgBC,qB,GAAAA,qB;QAyDAC,mB,GAAAA,mB;QAIAC,mB,GAAAA,mB;QAIAC,S,GAAAA,S;QAgBA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AACD;;AAED;AACO,SAAS9G,MAAT,CAAiB6G,MAAjB,EAAyB;AAC9B,MAAIK,iBAAiB,EAArB;AACA,WAASC,OAAT,CAAkBN,MAAlB,EAA0BO,OAA1B,EAAmC;AACjC1E,qBAAE2E,MAAF,CAASR,MAAT,EAAiB,CAACrF,KAAD,EAAQ8F,GAAR,KAAgB;AAC/B,UAAIC,SAAUH,UAAUA,UAAU,GAAV,GAAgBE,GAA1B,GAAgCA,GAA9C,CAD+B,CACoB;AACnD,UAAI9F,SAAS,OAAOA,KAAP,KAAiB,QAA9B,EAAwC;AACtC2F,gBAAQ3F,KAAR,EAAe+F,MAAf,EADsC,CACf;AACxB,OAFD,MAEO;AACLL,uBAAeK,MAAf,IAAyB/F,KAAzB,CADK,CAC0B;AAChC;AACF,KAPD;AAQD;;AAED2F,UAAQN,MAAR;AACA,SAAOK,cAAP;AACD;;AAED;AACA,IAAIM,oBAAoB,IAAIC,MAAJ,CAAW,mBAAX,CAAxB;;AAEA;AACO,SAASxH,UAAT,CAAqByH,EAArB,EAAyB;AAC9B,SAAQA,GAAGpE,MAAH,KAAc,EAAd,IAAoBkE,kBAAkBG,IAAlB,CAAuBD,EAAvB,CAA5B;AACD;;AAED;AACO,SAASxH,gBAAT,CAA2B0H,QAA3B,EAAqC;AAC1C,QAAMC,SAAS,wBAASC,EAAT,CAAYF,QAAZ,EAAsBG,MAAtB,CAA6B,GAA7B,CAAf;AACA,SAAQ,GAAEH,QAAS,KAAIC,MAAO,GAA9B;AACD","file":"utils.js","sourcesContent":["import _ from 'lodash'\r\nimport moment from 'moment'\r\nimport emailValidator from 'email-validator'\r\nimport config from 'config'\r\nimport { Platform, Notify, Dialog, Loading, exportFile } from 'quasar'\r\n\r\nNotify.setDefaults({\r\n position: 'bottom-left',\r\n timeout: 5000,\r\n textColor: 'white',\r\n actions: [{ icon: 'las la-times', color: 'white' }]\r\n})\r\n\r\nLoading.setDefaults({\r\n spinnerColor: 'primary',\r\n spinnerSize: 140,\r\n messageColor: 'white',\r\n customClass: 'full-width'\r\n})\r\n\r\n/**\r\n * This function allow you to modify a JS Promise by adding some status properties.\r\n * Based on: http://stackoverflow.com/questions/21485545/is-there-a-way-to-tell-if-an-es6-promise-is-fulfilled-rejected-resolved\r\n * But modified according to the specs of promises : https://promisesaplus.com/\r\n */\r\nexport function createQuerablePromise (promiseOrExecutor) {\r\n let promise = promiseOrExecutor\r\n if (typeof promiseOrExecutor === 'function') {\r\n promise = new Promise(promiseOrExecutor)\r\n }\r\n // Don't modify any promise that has been already modified.\r\n if (promise.isResolved) return promise\r\n\r\n // Set initial state\r\n let isPending = true\r\n let isRejected = false\r\n let isFulfilled = false\r\n\r\n // Observe the promise, saving the fulfillment in a closure scope.\r\n const result = promise.then(\r\n (value) => {\r\n isFulfilled = true\r\n isPending = false\r\n return value\r\n },\r\n (error) => {\r\n isRejected = true\r\n isPending = false\r\n throw error\r\n }\r\n )\r\n\r\n result.isFulfilled = () => { return isFulfilled }\r\n result.isPending = () => { return isPending }\r\n result.isRejected = () => { return isRejected }\r\n\r\n return result\r\n}\r\n\r\nexport const Colors = {\r\n dark: '#333',\r\n red: '#f44336',\r\n pink: '#e91e63',\r\n purple: '#9c27b0',\r\n 'deep-purple': '#673ab7',\r\n indigo: '#3f51b5',\r\n blue: '#2196f3',\r\n 'light-blue': '#03a9f4',\r\n cyan: '#00bcd4',\r\n teal: '#009688',\r\n green: '#4caf50',\r\n 'light-green': '#8bc34a',\r\n lime: '#cddc39',\r\n yellow: '#ffeb3b',\r\n amber: '#ffc107',\r\n orange: '#ff9800',\r\n 'deep-orange': '#ff5722',\r\n brown: '#795548',\r\n grey: '#9e9e9e',\r\n 'blue-grey': '#607d8b'\r\n}\r\n\r\nexport function getPaletteFromColor (color) {\r\n return _.findKey(Colors, item => item === color)\r\n}\r\n\r\nexport function getColorFromPalette (color) {\r\n return Colors[color]\r\n}\r\n\r\nexport function getLocale () {\r\n const locale =\r\n navigator.language ||\r\n navigator.languages[0] ||\r\n navigator.browserLanguage ||\r\n navigator.userLanguage ||\r\n navigator.systemLanguage\r\n\r\n if (locale) {\r\n // see https://www.ietf.org/rfc/bcp/bcp47.txt\r\n const languageCodes = _.split(locale, '-')\r\n if (languageCodes.length > 0) return languageCodes[0]\r\n }\r\n // return undefined by default\r\n}\r\n\r\nexport function getAppLocale () {\r\n const localeConfig = config.locale || {}\r\n const localeBrowser = getLocale()\r\n return localeConfig.default || localeBrowser\r\n}\r\n\r\nexport function getInitials (name) {\r\n const initials = name.toUpperCase().match(/\\b\\w/g) || []\r\n return initials.join('')\r\n}\r\n\r\nexport function isEmailValid (email) {\r\n return emailValidator.validate(email)\r\n}\r\n\r\nexport function createThumbnail (imageDataUri, width, height, quality, callback) {\r\n const image = document.createElement('img')\r\n image.onload = function () {\r\n const canvas = document.createElement('canvas')\r\n const ctx = canvas.getContext('2d')\r\n // set its dimension to target size\r\n canvas.width = width\r\n canvas.height = height\r\n ctx.drawImage(this, 0, 0, width, height)\r\n callback(canvas.toDataURL('image/jpeg', quality))\r\n }\r\n image.src = imageDataUri\r\n}\r\n\r\nexport function downloadAsBlob (data, filename, mimeType) {\r\n const blob = new Blob([data], { type: mimeType })\r\n if (Platform.is.cordova) {\r\n window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, (fs) => {\r\n fs.root.getFile(filename, { create: true, exclusive: false }, (fileEntry) => {\r\n fileEntry.createWriter((fileWriter) => {\r\n fileWriter.write(blob)\r\n cordova.plugins.fileOpener2.open(fileEntry.nativeURL, mimeType)\r\n })\r\n })\r\n })\r\n } else {\r\n exportFile(filename, blob)\r\n }\r\n}\r\n\r\nexport function toast (options) {\r\n // We deduce the color from the type as it was not initially supported by Quasar.\r\n // The built-in type property appeared with Quasar 1.9 so that we should not need this function anymore.\r\n // However, we have prefered to keep this function for backward compatibility.\r\n const type = options.type || 'negative'\r\n // Notify.create returns a function that, when invoked, hides the notification\r\n return Notify.create(Object.assign({\r\n color: (type === 'negative' ? 'red' : (type === 'warning' ? 'orange' : 'green'))\r\n }, _.omit(options, ['type'])))\r\n}\r\n\r\n// Simplify Quasar dialog plugin usage with async/await\r\nexport async function dialog (options) {\r\n return new Promise((resolve, reject) => {\r\n Dialog.create(options)\r\n .onOk((data) => resolve({ ok: true, data }))\r\n .onCancel(() => resolve({ cancel: true }))\r\n .onDismiss(() => resolve({ dismiss: true }))\r\n })\r\n}\r\n\r\n// Extract icon name from a given icon property on a given target object\r\nexport function getIconName (object, path = 'icon.name') {\r\n // Make function work in a generic way, sometimes the provided input is directly the icon name\r\n const icon = (typeof object === 'object' ? _.get(object, path, '') : object)\r\n // Check whether the returned icon is an object (can be true in some cases)\r\n if (typeof icon === 'object') return ''\r\n // Name icons to ensure backward compatibility with font awesome 4\r\n return (icon.startsWith('fa-') ? `fas ${icon}` : icon)\r\n}\r\n\r\nexport function processIcon (object, path = 'icon.name') {\r\n // Process icons for backward compatibility with font awesome 4\r\n _.set(object, path, getIconName(object, path))\r\n}\r\n\r\n// Transform nested object to dot notation\r\nexport function dotify (object) {\r\n var dotifiedObject = {}\r\n function recurse (object, current) {\r\n _.forOwn(object, (value, key) => {\r\n var newKey = (current ? current + '.' + key : key) // joined key with dot\r\n if (value && typeof value === 'object') {\r\n recurse(value, newKey) // it's a nested object, so do it again\r\n } else {\r\n dotifiedObject[newKey] = value // it's not an object, so set the property\r\n }\r\n })\r\n }\r\n\r\n recurse(object)\r\n return dotifiedObject\r\n}\r\n\r\n// Regular expression that checks for hex value\r\nvar checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$')\r\n\r\n// Check if a string is a valid MongoDB Object ID\r\nexport function isObjectID (id) {\r\n return (id.length === 24 && checkForHexRegExp.test(id))\r\n}\r\n\r\n// Add UTC offset to timezone name\r\nexport function getTimezoneLabel (timezone) {\r\n const offset = moment().tz(timezone).format('Z')\r\n return `${timezone} (${offset})`\r\n}\r\n"]}
|
|
@@ -59,12 +59,12 @@
|
|
|
59
59
|
"helper": "schemas.TIME_FORMAT_LONG_YEAR_FIELD_HELPER"
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
-
"
|
|
63
|
-
"type": "
|
|
62
|
+
"timezone": {
|
|
63
|
+
"type": "string",
|
|
64
64
|
"group": "schemas.TIME_FORMAT_SETTINGS",
|
|
65
65
|
"field": {
|
|
66
|
-
"component": "form/
|
|
67
|
-
"label": "schemas.
|
|
66
|
+
"component": "form/KTimezoneField",
|
|
67
|
+
"label": "schemas.TIME_FORMAT_TIMEZONE_FIELD_LABEL"
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
"timelineStep": {
|
|
@@ -152,6 +152,15 @@
|
|
|
152
152
|
"quantity": "length"
|
|
153
153
|
}
|
|
154
154
|
},
|
|
155
|
+
"defaultAltitude": {
|
|
156
|
+
"type": "string",
|
|
157
|
+
"group": "schemas.UNITS_SETTINGS",
|
|
158
|
+
"field": {
|
|
159
|
+
"component": "form/KUnitField",
|
|
160
|
+
"label": "schemas.ALTITUDE_FIELD_LABEL",
|
|
161
|
+
"quantity": "altitude"
|
|
162
|
+
}
|
|
163
|
+
},
|
|
155
164
|
"defaultArea": {
|
|
156
165
|
"type": "string",
|
|
157
166
|
"group": "schemas.UNITS_SETTINGS",
|
|
@@ -206,6 +215,7 @@
|
|
|
206
215
|
"longDate",
|
|
207
216
|
"shortYear",
|
|
208
217
|
"longYear",
|
|
218
|
+
"timezone",
|
|
209
219
|
"location"
|
|
210
220
|
]
|
|
211
221
|
}
|