Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
vannizhang committed Sep 10, 2021
2 parents 0341750 + 7479e57 commit f4082c5
Show file tree
Hide file tree
Showing 116 changed files with 5,785 additions and 3,230 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# wayback
# World Imagery Wayback App
This app provides a dynamic browsing experience where previous World Imagery versions are presented within the map, along a timeline, and as a list. Versions that resulted in local changes are dynamically presented to the user based on location and scale. Preview changes by hovering and/or selecting individual layers. When ready, one or more Wayback layers can be added to an export queue and pushed to a new ArcGIS Online web map.

[View it live](https://livingatlas.arcgis.com/wayback/)
Expand Down Expand Up @@ -35,7 +35,7 @@ npm run build
```

## External Libraries:
- [ArcGIS API for JavaScript (4.18)](https://developers.arcgis.com/javascript/index.html)
- [ArcGIS API for JavaScript (4.20)](https://developers.arcgis.com/javascript/index.html)
- [D3.js v4](https://d3js.org/)

## Resources
Expand Down
615 changes: 568 additions & 47 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
},
"homepage": "https://livingatlas.arcgis.com/wayback/",
"devDependencies": {
"@arcgis/webpack-plugin": "^4.20.0",
"@babel/core": "^7.12.9",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
Expand All @@ -41,7 +42,10 @@
"@babel/preset-typescript": "^7.12.7",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/react-helmet": "^6.1.0",
"@types/react-redux": "^7.1.11",
"@types/shortid": "0.0.29",
"@types/styled-components": "^5.1.9",
"@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0",
"babel-core": "^6.26.3",
Expand Down Expand Up @@ -73,6 +77,8 @@
"webpack-dev-server": "^3.11.0"
},
"dependencies": {
"@arcgis/core": "^4.20.2",
"@entryline/gifstream": "^1.2.1",
"@esri/arcgis-rest-auth": "^2.22.0",
"@esri/arcgis-rest-feature-layer": "^2.22.0",
"@esri/arcgis-rest-request": "^2.22.0",
Expand All @@ -84,13 +90,21 @@
"classnames": "^2.2.6",
"d3": "^5.12.0",
"es6-promise": "^4.2.8",
<<<<<<< HEAD
"esri-loader": "^3.2.0",
=======
"esri-loader": "^2.16.0",
"gifshot": "^0.4.5",
>>>>>>> es-modules
"helper-toolkit-ts": "^1.1.14",
"isomorphic-fetch": "^3.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-helmet": "^6.1.0",
"react-redux": "^7.2.2",
"redux": "^4.0.5"
"redux": "^4.0.5",
"shortid": "^2.2.16",
"styled-components": "^5.3.0"
},
"resolutions": {
"styled-components": "^5"
Expand Down
8 changes: 6 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>World Imagery Wayback</title>

<meta property="og:image" content="public/thumbnail.png" />
<meta property="og:image" content="https://livingatlas.arcgis.com/wayback/public/thumbnail.png" />
<link rel="icon" href="public/favicon.ico">
<script src="//mtags.arcgis.com/tags-min.js"></script>

<script type="module" src="https://js.arcgis.com/calcite-components/1.0.0-beta.61/calcite.esm.js"></script>
<script nomodule="" src="https://js.arcgis.com/calcite-components/1.0.0-beta.61/calcite.js"></script>

<link rel="stylesheet" type="text/css" href="https://js.arcgis.com/calcite-components/1.0.0-beta.61/calcite.css" />
</head>
<body>
<div id='appRootDiv'></div>
Expand Down
12 changes: 12 additions & 0 deletions src/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const config: IAppConfig = {
// The registered application id used for authentication, this appId below only works for the app hosted on arcgis.com domain
appId: 'WaybackImagery',
shouldUseWaybackFootprintsLayer: false,
// if on-premises is true, some functionalities (share app to social media and etc) will be disabled
onPremises: false,
productionEnv: {
serviceUrls: {
'portal-url': 'https://www.arcgis.com',
Expand All @@ -13,6 +15,12 @@ const config: IAppConfig = {
'https://s3-us-west-2.amazonaws.com/config.maptiles.arcgis.com/waybackconfig.json',
'wayback-change-detector-layer':
'https://metadatadev.maptiles.arcgis.com/arcgis/rest/services/Wayback_Footprints/MapServer/0',
// the vector tile layer provides a detailed reference layer, including transporation and labels for the world.
'reference-layer':
'https://www.arcgis.com/sharing/rest/content/items/2a2e806e6e654ea78ecb705149ceae9f/resources/styles/root.json',
// this world imagery basemap will be used when user saves selected Wayback items into a new webmap
'world-imagery-basemap':
'https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/',
},
},
// The dev enivornment is optional, please comment out the dev section below if don't need the dev enivornment
Expand All @@ -25,6 +33,10 @@ const config: IAppConfig = {
'https://s3-us-west-2.amazonaws.com/config.maptiles.arcgis.com/dev/waybackconfig.json',
'wayback-change-detector-layer':
'https://metadatadev.maptiles.arcgis.com/arcgis/rest/services/Wayback_Footprints/MapServer/0',
'reference-layer':
'https://devext.arcgis.com/sharing/rest/content/items/2155f4cadf454b9a973b12dc73d1ffaf/resources/styles/root.json?f=pjson',
'world-imagery-basemap':
'https://servicesdev.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/',
},
},
defaultMapExtent: {
Expand Down
161 changes: 161 additions & 0 deletions src/components/AnimationControls/AnimationControls.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
import React, {
useCallback,
useEffect
} from 'react'

import { useSelector, useDispatch, batch } from 'react-redux';

import {
// releaseNum4ItemsWithLocalChangesSelector,
// allWaybackItemsSelector,
// activeWaybackItemSelector,
// releaseNum4ActiveWaybackItemUpdated,
waybackItemsWithLocalChangesSelector
} from '../../store/reducers/WaybackItems';

import {
waybackItems4AnimationLoaded,
// rNum4AnimationFramesSelector,
rNum2ExcludeSelector,
toggleAnimationFrame,
rNum2ExcludeReset,
// animationSpeedChanged,
animationSpeedSelector,
isAnimationPlayingToggled,
isAnimationPlayingSelector,
startAnimation,
stopAnimation,
updateAnimationSpeed,
indexOfCurrentAnimationFrameSelector,
waybackItem4CurrentAnimationFrameSelector,
setActiveFrameByReleaseNum
} from '../../store/reducers/AnimationMode'

import { IWaybackItem } from '../../types';

import DonwloadGifButton from './DonwloadGifButton';
import FramesSeletor from './FramesSeletor';
import SpeedSelector from './SpeedSelector';
import PlayPauseBtn from './PlayPauseBtn';
import { usePrevious } from '../../hooks/usePrevious';
import { saveFrames2ExcludeInURLQueryParam } from '../../utils/UrlSearchParam';

const AnimationControls = () => {

const dispatch = useDispatch();

const rNum2ExcludeFromAnimation: number[] = useSelector(rNum2ExcludeSelector);

// const activeItem:IWaybackItem = useSelector(activeWaybackItemSelector);

const waybackItemsWithLocalChanges: IWaybackItem[] = useSelector(waybackItemsWithLocalChangesSelector);

const prevWaybackItemsWithLocalChanges = usePrevious<IWaybackItem[]>(waybackItemsWithLocalChanges)

const animationSpeed = useSelector(animationSpeedSelector);

const isPlaying = useSelector(isAnimationPlayingSelector)

const waybackItem4CurrentAnimationFrame = useSelector(waybackItem4CurrentAnimationFrameSelector);

const speedOnChange = useCallback((speed:number)=>{
dispatch(updateAnimationSpeed(speed))
}, []);

const playPauseBtnOnClick = useCallback(()=>{
if(isPlaying){
dispatch(stopAnimation())
} else {
dispatch(startAnimation())
}
}, [isPlaying])

const getContent = ()=>{

if(!waybackItemsWithLocalChanges || !waybackItemsWithLocalChanges.length){
return (
<div className='text-center'>
<p className='leader-1 font-size--2'>Loading versions with local changes.</p>
</div>
)
}

return (
<>
<DonwloadGifButton />

<div className='leader-half'>
<span className='font-size--3'>Animation Speed</span>
</div>

<div
style={{
display: 'flex',
alignItems: 'center'
}}
>
<PlayPauseBtn
isPlaying={isPlaying}
onClick={playPauseBtnOnClick}
/>

<SpeedSelector
defaultVal={animationSpeed}
onChange={speedOnChange}
/>

</div>

<FramesSeletor
waybackItemsWithLocalChanges={waybackItemsWithLocalChanges}
// activeItem={activeItem}
// rNum4AnimationFrames={rNum4AnimationFrames}
rNum2Exclude={rNum2ExcludeFromAnimation}
setActiveFrame={(rNum)=>{
dispatch(setActiveFrameByReleaseNum(rNum))
}}
toggleFrame={(rNum)=>{
dispatch(toggleAnimationFrame(rNum))
}}
waybackItem4CurrentAnimationFrame={waybackItem4CurrentAnimationFrame}
isButtonDisabled={isPlaying}
/>
</>
);
}

useEffect(()=>{

batch(()=>{
dispatch(waybackItems4AnimationLoaded(waybackItemsWithLocalChanges))

if(
prevWaybackItemsWithLocalChanges &&
prevWaybackItemsWithLocalChanges.length
){
dispatch(rNum2ExcludeReset())
}
});
}, [waybackItemsWithLocalChanges])

useEffect(()=>{
// console.log(rNum2ExcludeFromAnimation)
saveFrames2ExcludeInURLQueryParam(rNum2ExcludeFromAnimation)
}, [rNum2ExcludeFromAnimation])

return (
<>
<div
style={{
padding: '0 1rem',
marginTop: '.5rem'
}}
>
{ getContent() }
</div>

</>
)
}

export default AnimationControls
25 changes: 25 additions & 0 deletions src/components/AnimationControls/DonwloadGifButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, { useCallback} from 'react'
import { useDispatch, useSelector } from 'react-redux'
import classnames from 'classnames'
import { isDownloadGIFDialogOnToggled, isLoadingFrameDataSelector } from '../../store/reducers/AnimationMode';

const DonwloadGifButton = () => {

const dispatch = useDispatch();

const isLoadingFrameData = useSelector(isLoadingFrameDataSelector)

const onClickHandler = useCallback(() => {
dispatch(isDownloadGIFDialogOnToggled())
},[]);

const classNames = classnames('btn btn-fill', {
'btn-disabled': isLoadingFrameData
})

return (
<div className={classNames} onClick={onClickHandler}>Download GIF</div>
)
}

export default DonwloadGifButton
Loading

0 comments on commit f4082c5

Please sign in to comment.