Skip to content

Commit

Permalink
feat: bundle example images
Browse files Browse the repository at this point in the history
  • Loading branch information
ozyx committed Apr 29, 2024
1 parent fa897ef commit c740936
Show file tree
Hide file tree
Showing 18 changed files with 43 additions and 32 deletions.
30 changes: 30 additions & 0 deletions example/imagery/exampleImages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2024, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/

/**
* Import all *.jpg files from the images folder, add to an array
* and export for use in the plugin.
*/
const imagesContext = require.context('@/../example/imagery/images', false, /\.jpg$/);
const imageArray = imagesContext.keys().map((key) => imagesContext(key));

export default imageArray;
Binary file added example/imagery/images/AS16-117-18731.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/imagery/images/AS16-117-18732.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/imagery/images/AS16-117-18733.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/imagery/images/AS16-117-18734.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/imagery/images/AS16-117-18735.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/imagery/images/AS16-117-18736.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/imagery/images/AS16-117-18737.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/imagery/images/AS16-117-18738.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/imagery/images/AS16-117-18739.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/imagery/images/AS16-117-18740.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/imagery/images/AS16-117-18741.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/imagery/images/AS16-117-18742.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/imagery/images/AS16-117-18743.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/imagery/images/AS16-117-18744.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/imagery/images/AS16-117-18745.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 10 additions & 29 deletions example/imagery/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,11 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import DEFAULT_IMAGE_SAMPLES from '@/../example/imagery/exampleImages.js';
import Layer16x9 from '@/plugins/imagery/layers/example-imagery-layer-16x9.png';
import LayerSafe from '@/plugins/imagery/layers/example-imagery-layer-safe.png';
import LayerScale from '@/plugins/imagery/layers/example-imagery-layer-scale.png';

const DEFAULT_IMAGE_SAMPLES = [
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18731.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18732.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18733.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18734.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18735.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18736.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18737.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18738.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18739.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18740.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18741.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18742.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18743.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18744.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18745.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18746.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18747.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18748.jpg'
];
const DEFAULT_IMAGE_LOAD_DELAY_IN_MILLISECONDS = 20000;
const MIN_IMAGE_LOAD_DELAY_IN_MILLISECONDS = 5000;

Expand Down Expand Up @@ -94,15 +78,15 @@ export default function () {
},
layers: [
{
source: 'dist/imagery/example-imagery-layer-16x9.png',
source: Layer16x9,
name: '16:9'
},
{
source: 'dist/imagery/example-imagery-layer-safe.png',
source: LayerSafe,
name: 'Safe'
},
{
source: 'dist/imagery/example-imagery-layer-scale.png',
source: LayerScale,
name: 'Scale'
}
]
Expand Down Expand Up @@ -168,18 +152,15 @@ function getCompassValues(min, max) {

function getImageSamples(configuration) {
let imageSamples = DEFAULT_IMAGE_SAMPLES;
const { imageLocation } = configuration;

if (configuration.imageLocation && configuration.imageLocation.length) {
imageSamples = getImageUrlListFromConfig(configuration);
if (imageLocation && imageLocation.length) {
imageSamples = imageLocation;

Check warning on line 158 in example/imagery/plugin.js

View check run for this annotation

Codecov / codecov/patch

example/imagery/plugin.js#L158

Added line #L158 was not covered by tests
}

return imageSamples;
}

function getImageUrlListFromConfig(configuration) {
return configuration.imageLocation.split(',');
}

function getImageLoadDelay(domainObject) {
const imageLoadDelay = Math.trunc(
Number(domainObject.configuration.imageLoadDelayInMilliSeconds)
Expand Down
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@
<link
rel="icon"
type="image/png"
href="dist/assets/favicons/favicon-96x96.png"
href="dist/favicons/favicon-96x96.png"
sizes="96x96"
type="image/x-icon"
/>
<link
rel="icon"
type="image/png"
href="dist/assets/favicons/favicon-32x32.png"
href="dist/favicons/favicon-32x32.png"
sizes="32x32"
type="image/x-icon"
/>
<link
rel="icon"
type="image/png"
href="dist/assets/favicons/favicon-16x16.png"
href="dist/favicons/favicon-16x16.png"
sizes="16x16"
type="image/x-icon"
/>
Expand Down

0 comments on commit c740936

Please sign in to comment.