-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Walk): Rename Button renames image files based on calendar
- Loading branch information
Showing
14 changed files
with
208 additions
and
334 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import moment from 'moment'; | ||
import React, { useState } from 'react'; | ||
import 'react-dates/initialize'; | ||
import { isInclusivelyBeforeDay, SingleDatePicker } from 'react-dates'; | ||
import 'react-dates/lib/css/_datepicker.css'; | ||
|
||
import RenameButton from './RenameButton'; | ||
|
||
function Menu({ | ||
showMenu, | ||
imageFilenames, | ||
path, | ||
}) { | ||
const [isFocused, setFocus] = useState(false); | ||
const [date, setDate] = useState(moment().hour(1)); | ||
|
||
if (showMenu) { | ||
return ( | ||
<section> | ||
<SingleDatePicker | ||
date={date} | ||
displayFormat="yyyy-MM-DD" | ||
showDefaultInputIcon | ||
focused={isFocused} | ||
onDateChange={(inputDate) => setDate(inputDate)} | ||
onFocusChange={({ focused }) => setFocus(focused)} | ||
isOutsideRange={(day) => !isInclusivelyBeforeDay(day, moment())} | ||
regular | ||
/> | ||
<RenameButton | ||
filenames={imageFilenames} | ||
prefix={date.toISOString().split('T')[0]} | ||
path={path} | ||
/> | ||
</section> | ||
); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
export default Menu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import Button from '../../components/Button'; | ||
import config from '../../../../config.json'; | ||
import request from '../../utils/request'; | ||
|
||
function Rename({ | ||
filenames, | ||
path, | ||
prefix, | ||
}) { | ||
const [output, setOutput] = useState(''); | ||
const postBody = { | ||
filenames, | ||
prefix, | ||
source_folder: path, | ||
preview: false, | ||
raw: true, | ||
rename_associated: true, | ||
}; | ||
const options = { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
method: 'POST', | ||
body: JSON.stringify(postBody), | ||
}; | ||
|
||
function onClick() { | ||
/* | ||
curl -d '{"filenames":["a.jpg","b.jpg"], "prefix": "2020-06-13", | ||
"source_folder": "/todo/doit", "preview": "false", "raw": "true", "rename_associated": "true"}' | ||
-i http://127.0.0.1:8000/admin/rename -H "Content-Type: application/json" | ||
*/ | ||
return request(`http://localhost:${config.apiPort}/admin/rename`, options) | ||
.then(setOutput); | ||
} | ||
|
||
return [ | ||
<Button | ||
key="rename" | ||
handleRoute={onClick} | ||
> | ||
Rename | ||
</Button>, | ||
<textarea | ||
key="console" | ||
id="console" | ||
style={{ padding: '1em', fontFamily: '"Montserrat", "sans-serif"', fontSize: '1em' }} | ||
value={JSON.stringify(output.xml, null, '\t')} | ||
/>, | ||
]; | ||
} | ||
|
||
export default Rename; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.