upgrade CRUD console
parent
5f3e045a7b
commit
a17fbfa937
|
|
@ -101,19 +101,19 @@ const AlbumCreate = ({
|
||||||
id='titleAlbumInput'
|
id='titleAlbumInput'
|
||||||
autoComplete='off'
|
autoComplete='off'
|
||||||
ref={ titleInput }
|
ref={ titleInput }
|
||||||
/>
|
/> <br />
|
||||||
description:
|
description:
|
||||||
<input
|
<input
|
||||||
id='descriptionAlbumInput'
|
id='descriptionAlbumInput'
|
||||||
autoComplete='off'
|
autoComplete='off'
|
||||||
ref={ descriptionInput }
|
ref={ descriptionInput }
|
||||||
/>
|
/> <br />
|
||||||
image:
|
image:
|
||||||
<input
|
<input
|
||||||
id='imageAlbumInput'
|
id='imageAlbumInput'
|
||||||
autoComplete='off'
|
autoComplete='off'
|
||||||
ref={ imageInput }
|
ref={ imageInput }
|
||||||
/>
|
/> <br />
|
||||||
<button type='submit' />
|
<button type='submit' />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ const AlbumGetAll = ({
|
||||||
let list = '.albums\n'
|
let list = '.albums\n'
|
||||||
for (let i = 0; i < albums.length; i++) {
|
for (let i = 0; i < albums.length; i++) {
|
||||||
list += '├── ' + albums[i].title + '\n'
|
list += '├── ' + albums[i].title + '\n'
|
||||||
+ '│ ├── id: ' + albums[i].id + '\n'
|
+ '│ ├── id: ' + albums[i].id + '\n'
|
||||||
+ '│ ├── user id: ' + albums[i].user_id + '\n'
|
+ '│ ├── user id: ' + albums[i].user_id + '\n'
|
||||||
+ '│ └── url: ' + albums[i].url_code + '\n'
|
+ '│ └── url: ' + albums[i].url_code + '\n'
|
||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,8 @@ import AlbumDelete from './commands/fetchCommands/Album/Delete'
|
||||||
|
|
||||||
import '../../../styles/general.scss'
|
import '../../../styles/general.scss'
|
||||||
|
|
||||||
import { deleteAuth } from '../../../stores/user/duck/operations'
|
|
||||||
|
|
||||||
const IndexConsole = ({
|
const IndexConsole = ({
|
||||||
user,
|
user
|
||||||
deleteAuth
|
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
const [consoleHistory, setConsoleHistory] = useState('')
|
const [consoleHistory, setConsoleHistory] = useState('')
|
||||||
|
|
@ -60,27 +57,17 @@ const IndexConsole = ({
|
||||||
let inputValue = consoleInput.current.value
|
let inputValue = consoleInput.current.value
|
||||||
consoleUser += inputValue + '\n'
|
consoleUser += inputValue + '\n'
|
||||||
|
|
||||||
|
let splitCommand = inputValue.split(' ')
|
||||||
|
let choiceCRUD = splitCommand[ splitCommand.length - 1 ]
|
||||||
|
|
||||||
if ( user.username !== '' ) {
|
if ( user.username !== '' ) {
|
||||||
if ( inputValue === 'help' ){
|
if ( inputValue === 'help' ){
|
||||||
setConsoleHistory( consoleHistory + consoleUser + commands.helpUser() )
|
setConsoleHistory( consoleHistory + consoleUser + commands.helpUser() )
|
||||||
} else if ( inputValue === 'logout' ) {
|
} else if ( inputValue === 'logout' ) {
|
||||||
setConsoleHistory( consoleHistory + consoleUser )
|
setConsoleHistory( consoleHistory + consoleUser )
|
||||||
setLogout( !logout )
|
setLogout( !logout )
|
||||||
} else if ( inputValue === 'get all album') {
|
} else if ( choiceCRUD === 'album' ) {
|
||||||
setConsoleHistory( consoleHistory + consoleUser )
|
albumCRUD( inputValue )
|
||||||
setAlbumGetAll( !albumGetAll )
|
|
||||||
} else if ( inputValue === 'get one album' ) {
|
|
||||||
setConsoleHistory( consoleHistory + consoleUser )
|
|
||||||
setAlbumGetOne( !albumGetOne )
|
|
||||||
} else if ( inputValue === 'create album' ) {
|
|
||||||
setConsoleHistory( consoleHistory + consoleUser )
|
|
||||||
setAlbumCreate( !albumCreate )
|
|
||||||
} else if ( inputValue === 'update album' ) {
|
|
||||||
setConsoleHistory( consoleHistory + consoleUser )
|
|
||||||
setAlbumUpdate( !albumUpdate )
|
|
||||||
} else if ( inputValue === 'delete album' ) {
|
|
||||||
setConsoleHistory( consoleHistory + consoleUser )
|
|
||||||
setAlbumDelete( !albumDelete )
|
|
||||||
} else if ( inputValue === 'clean' ){
|
} else if ( inputValue === 'clean' ){
|
||||||
setConsoleHistory( '' )
|
setConsoleHistory( '' )
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -104,6 +91,25 @@ const IndexConsole = ({
|
||||||
activateInput()
|
activateInput()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const albumCRUD = ( inputValue ) => {
|
||||||
|
if ( inputValue === 'get all album') {
|
||||||
|
setConsoleHistory( consoleHistory + consoleUser )
|
||||||
|
setAlbumGetAll( !albumGetAll )
|
||||||
|
} else if ( inputValue === 'get one album' ) {
|
||||||
|
setConsoleHistory( consoleHistory + consoleUser )
|
||||||
|
setAlbumGetOne( !albumGetOne )
|
||||||
|
} else if ( inputValue === 'create album' ) {
|
||||||
|
setConsoleHistory( consoleHistory + consoleUser )
|
||||||
|
setAlbumCreate( !albumCreate )
|
||||||
|
} else if ( inputValue === 'update album' ) {
|
||||||
|
setConsoleHistory( consoleHistory + consoleUser )
|
||||||
|
setAlbumUpdate( !albumUpdate )
|
||||||
|
} else if ( inputValue === 'delete album' ) {
|
||||||
|
setConsoleHistory( consoleHistory + consoleUser )
|
||||||
|
setAlbumDelete( !albumDelete )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const activateInput = () => {
|
const activateInput = () => {
|
||||||
document.getElementById('consoleInput').focus()
|
document.getElementById('consoleInput').focus()
|
||||||
}
|
}
|
||||||
|
|
@ -214,7 +220,6 @@ const mapStateToProps = state => ({
|
||||||
})
|
})
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
deleteAuth: (token) => dispatch( deleteAuth(token) )
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(IndexConsole)
|
export default connect(mapStateToProps, mapDispatchToProps)(IndexConsole)
|
||||||
Loading…
Reference in New Issue