Commit befd5801 authored by PDuarte's avatar PDuarte

basic asset crud

parent 41ddd740
import { Package, Briefcase, HardDrive, Globe, Flag } from 'react-feather'
export default [
{
id: 'Playlists',
title: 'Playlists',
icon: <Package />,
children: [
{
id: 'playlistsDash',
title: 'Project Playlists',
icon: <Briefcase />,
navLink: '/playlists/projectplaylists'
}
]
}
]
\ No newline at end of file
...@@ -2,15 +2,15 @@ import { Package, Briefcase, HardDrive, Globe, Flag } from 'react-feather' ...@@ -2,15 +2,15 @@ import { Package, Briefcase, HardDrive, Globe, Flag } from 'react-feather'
export default [ export default [
{ {
id: 'Playlists', id: 'Assets',
title: 'Playlists', title: 'Assets',
icon: <Package />, icon: <Package />,
children: [ children: [
{ {
id: 'playlistsDash', id: 'assetsDash',
title: 'Project Playlists', title: 'Project Assets',
icon: <Briefcase />, icon: <Briefcase />,
navLink: '/playlists/projectplaylists' navLink: '/assets/projectassets'
} }
] ]
} }
......
import { lazy } from 'react'
import { Redirect } from 'react-router-dom'
const AssetsRoutes = [
// settingss
{
path: '/assets/projectassets/edit',
exact: true,
component: () => <Redirect to='/assets/projectassets/edit/1' />
},
{
path: '/assets/projectassets/edit/:id',
component: lazy(() => import('../../views/assets/projectassets/edit')),
meta: {
navLink: '/assets/projectassets/edit'
}
},
{
path: '/assets/projectassets/add',
component: lazy(() => import('../../views/assets/projectassets/add')),
meta: {
navLink: '/assets/projectassets/add'
}
},
{
path: '/assets/projectassets',
component: lazy(() => import('../../views/assets/projectassets'))
}
]
export default AssetsRoutes
...@@ -13,6 +13,7 @@ import SettingsRoutes from './Settings' ...@@ -13,6 +13,7 @@ import SettingsRoutes from './Settings'
import ScreensRoutes from './screens' import ScreensRoutes from './screens'
import MenuPagesRoutes from './menupages' import MenuPagesRoutes from './menupages'
import PlaylistsRoutes from './playlists' import PlaylistsRoutes from './playlists'
import AssetsRoutes from './assets'
// ** Document title // ** Document title
const TemplateTitle = '%s - Vuexy React Admin Template' const TemplateTitle = '%s - Vuexy React Admin Template'
...@@ -34,7 +35,8 @@ const Routes = [ ...@@ -34,7 +35,8 @@ const Routes = [
...ScreensRoutes, ...ScreensRoutes,
...PlaylistsRoutes, ...PlaylistsRoutes,
...MenuPagesRoutes, ...MenuPagesRoutes,
...SettingsRoutes ...SettingsRoutes,
...AssetsRoutes
] ]
export { DefaultRoute, TemplateTitle, Routes } export { DefaultRoute, TemplateTitle, Routes }
...@@ -3,7 +3,7 @@ import { Fragment } from 'react' ...@@ -3,7 +3,7 @@ import { Fragment } from 'react'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
// ** Store & Actions // ** Store & Actions
import { addplaylist } from '../../store/actions' import { addasset } from '../../store/actions'
import { useDispatch } from 'react-redux' import { useDispatch } from 'react-redux'
// ** Custom Components // ** Custom Components
...@@ -23,13 +23,12 @@ const Tables = () => { ...@@ -23,13 +23,12 @@ const Tables = () => {
const dispatch = useDispatch() const dispatch = useDispatch()
const onSubmitHandler = values => { const onSubmitHandler = values => {
dispatch( dispatch(
addplaylist({ addasset({
idproject: values.idproject, projectid: values.projectid,
title: values.title, title: values.title,
layout_id: values.layout_id, parentid: values.parentid,
dynamic: values.dynamic, parenttype: values.parenttype,
special: values.special, external_id: values.external_id
special_id: values.special_id
} }
) )
) )
...@@ -37,7 +36,7 @@ const Tables = () => { ...@@ -37,7 +36,7 @@ const Tables = () => {
return ( return (
<Fragment> <Fragment>
<Breadcrumbs breadCrumbTitle='Playlists' breadCrumbParent='Playlists' breadCrumbActive={moduleSettings.mainTitle} /> <Breadcrumbs breadCrumbTitle='Assets' breadCrumbParent='Assets' breadCrumbActive={moduleSettings.mainTitle} />
<Row> <Row>
<Col sm='12'> <Col sm='12'>
<Link to={moduleSettings.baseURL}>Back to {moduleSettings.mainTitle}</Link> <Link to={moduleSettings.baseURL}>Back to {moduleSettings.mainTitle}</Link>
...@@ -52,15 +51,11 @@ const Tables = () => { ...@@ -52,15 +51,11 @@ const Tables = () => {
<div className="card-body"> <div className="card-body">
<ElementCard selectedElement={{ <ElementCard selectedElement={{
id: '<generate>', id: '<generate>',
idproject: '2', projectid: '2',
system_name: '', title: '',
last_seen: '', parentid: null,
layout_page_id: '', parenttype: null,
type: '', external_id: ''
display: '',
pagetypeid: '',
order: '0',
menu_page_layouts: []
}} }}
onSubmitHandler={onSubmitHandler} onSubmitHandler={onSubmitHandler}
/> />
......
...@@ -86,10 +86,9 @@ const handleError = (text) => { ...@@ -86,10 +86,9 @@ const handleError = (text) => {
...dataElement, ...dataElement,
idproject: values.idproject, idproject: values.idproject,
title: values.title, title: values.title,
layout_id: values.layout_id, parentid: values.parentid,
dynamic: values.dynamic, parenttype: values.parenttype,
special: values.special, external_id: values.external_id
special_id: values.special_id
} }
onSubmitHandler(submitElement) onSubmitHandler(submitElement)
...@@ -185,12 +184,12 @@ return ( ...@@ -185,12 +184,12 @@ return (
<Input <Input
readOnly={true} readOnly={true}
type='text' type='text'
name='idproject' name='projectid'
id='idproject' id='projectid'
innerRef={register({ required: true })} innerRef={register({ required: true })}
placeholder='idproject' placeholder='projectid'
defaultValue={dataElement && dataElement.idproject} defaultValue={dataElement && dataElement.projectid}
className={classnames({ 'is-invalid': errors['idproject'] })} className={classnames({ 'is-invalid': errors['projectid'] })}
/> />
</FormGroup> </FormGroup>
</Col> </Col>
...@@ -210,79 +209,53 @@ return ( ...@@ -210,79 +209,53 @@ return (
</Col> </Col>
<Col md='4' sm='12'> <Col md='4' sm='12'>
<FormGroup> <FormGroup>
<Label for='layout_id'>Layout Playlist</Label> <Label for='parenttype'>Parent Type</Label>
<Input <Input
type='select' type='text'
name='layout_id' name='parenttype'
id='layout_id' id='parenttype'
innerRef={register({ required: true })} innerRef={register({ required: false })}
placeholder='layout_id' placeholder='parenttype'
defaultValue={dataElement && dataElement.layout_id} defaultValue={dataElement && dataElement.parenttype}
className={classnames({ 'is-invalid': errors['layout_id'] })} className={classnames({ 'is-invalid': errors['parenttype'] })}
> />
{!!layoutplaylists ? layoutplaylists.map(option => {
return <option key={option.id}
selected={option.id === dataElement.layout_id ? option.id : ''}
value={option.id}>{option.name}</option>
}) : <option>Loading</option> }
</Input>
</FormGroup>
</Col>
<Col md='4' sm='12'>
<FormGroup>
<Label for='dynamic'>dynamic</Label>
<Input
type='select'
name='dynamic'
id='dynamic'
innerRef={register({ required: true })}
placeholder='dynamic'
defaultValue={dataElement && dataElement.dynamic}
className={classnames({ 'is-invalid': errors['dynamic'] })}
>
<option value='0'>No</option>
<option value='1'>Yes</option>
</Input>
</FormGroup> </FormGroup>
</Col> </Col>
<Col md='4' sm='12'> <Col md='4' sm='12'>
<FormGroup> <FormGroup>
<Label for='special'>special</Label> <Label for='parentid'>Parent Id</Label>
<Input <Input
type='select' type='text'
name='special' name='parentid'
id='special' id='parentid'
innerRef={register({ required: true })} innerRef={register({ required: false })}
placeholder='special' placeholder='parentid'
defaultValue={dataElement && dataElement.special} defaultValue={dataElement && dataElement.parentid}
className={classnames({ 'is-invalid': errors['special'] })} className={classnames({ 'is-invalid': errors['parentid'] })}
> />
<option value='0'>No</option>
<option value='1'>Yes</option>
</Input>
</FormGroup> </FormGroup>
</Col> </Col>
<Col md='4' sm='12'> <Col md='4' sm='12'>
<FormGroup> <FormGroup>
<Label for='special_id'>special_id</Label> <Label for='external_id'>External Id</Label>
<Input <Input
type='text' type='text'
name='special_id' name='external_id'
id='special_id' id='external_id'
innerRef={register({ required: false })} innerRef={register({ required: true })}
placeholder='special_id' placeholder='external_id'
defaultValue={dataElement && dataElement.special_id} defaultValue={dataElement && dataElement.external_id}
className={classnames({ 'is-invalid': errors['special_id'] })} className={classnames({ 'is-invalid': errors['external_id'] })}
/> />
</FormGroup> </FormGroup>
</Col> </Col>
</Row> </Row>
<Row className='app-user-edit'> {/* <Row className='app-user-edit'>
<Col sm='12'> <Col sm='12'>
<ManageAssets dataElement={dataElement && dataElement.assets} /> <ManageAssets dataElement={dataElement && dataElement.assets} />
/</Col> /</Col>
</Row> </Row> */}
<Row className='app-user-edit'> <Row className='app-user-edit'>
<Col className='d-flex flex-sm-row flex-column mt-2' sm='12'> <Col className='d-flex flex-sm-row flex-column mt-2' sm='12'>
......
...@@ -18,7 +18,7 @@ import moduleSettings from '../module' ...@@ -18,7 +18,7 @@ import moduleSettings from '../module'
const Tables = () => { const Tables = () => {
return ( return (
<Fragment> <Fragment>
<Breadcrumbs breadCrumbTitle='Playlists' breadCrumbParent='Playlists' breadCrumbActive={moduleSettings.mainTitle} /> <Breadcrumbs breadCrumbTitle='Assets' breadCrumbParent='Assets' breadCrumbActive={moduleSettings.mainTitle} />
<Row> <Row>
<Col sm='12'> <Col sm='12'>
<Link to={moduleSettings.baseURL}>Back to {moduleSettings.mainTitleSingle}</Link> <Link to={moduleSettings.baseURL}>Back to {moduleSettings.mainTitleSingle}</Link>
......
...@@ -2,7 +2,7 @@ import { useState, useEffect, Fragment } from 'react' ...@@ -2,7 +2,7 @@ import { useState, useEffect, Fragment } from 'react'
import { useParams, Link } from 'react-router-dom' import { useParams, Link } from 'react-router-dom'
// ** Store & Actions // ** Store & Actions
import { getplaylist, updateplaylist } from '../../store/actions' import { getasset, updateasset } from '../../store/actions'
import { useSelector, useDispatch } from 'react-redux' import { useSelector, useDispatch } from 'react-redux'
...@@ -15,7 +15,7 @@ import moduleSettings from '../module' ...@@ -15,7 +15,7 @@ import moduleSettings from '../module'
const ElementEdit = () => { const ElementEdit = () => {
// ** States & Vars // ** States & Vars
const store = useSelector(state => state.playlists), const store = useSelector(state => state.assets),
[dataElement, setElementData] = useState(null), [dataElement, setElementData] = useState(null),
dispatch = useDispatch(), dispatch = useDispatch(),
{ id } = useParams() { id } = useParams()
...@@ -23,14 +23,13 @@ const ElementEdit = () => { ...@@ -23,14 +23,13 @@ const ElementEdit = () => {
const onSubmitHandler = values => { const onSubmitHandler = values => {
console.log(values) console.log(values)
dispatch( dispatch(
updateplaylist({ updateasset({
...dataElement, ...dataElement,
idproject: values.idproject, idproject: values.idproject,
title: values.title, title: values.title,
layout_id: values.layout_id, parentid: values.parentid,
dynamic: values.dynamic, parenttype: values.parenttype,
special: values.special, external_id: values.external_id
special_id: values.special_id
}) })
) )
...@@ -38,21 +37,21 @@ const ElementEdit = () => { ...@@ -38,21 +37,21 @@ const ElementEdit = () => {
// ** Function to get user on mount // ** Function to get user on mount
useEffect(() => { useEffect(() => {
dispatch(getplaylist(id)) dispatch(getasset(id))
}, [dispatch]) }, [dispatch])
// ** Update user image on mount or change // ** Update user image on mount or change
useEffect(() => { useEffect(() => {
if (store.selectedPlaylist !== null || (store.selectedPlaylist !== null && dataElement !== null && store.selectedPlaylist.id !== dataElement.id)) { if (store.selectedAsset !== null || (store.selectedAsset !== null && dataElement !== null && store.selectedAsset.id !== dataElement.id)) {
return setElementData(store.selectedPlaylist) return setElementData(store.selectedAsset)
} }
}, [store.selectedPlaylist]) }, [store.selectedAsset])
return store.selectedPlaylist !== null && store.selectedPlaylist !== undefined ? ( return store.selectedAsset !== null && store.selectedAsset !== undefined ? (
<ElementCard <ElementCard
selectedElement={store.selectedPlaylist} selectedElement={store.selectedAsset}
onSubmitHandler={onSubmitHandler} onSubmitHandler={onSubmitHandler}
/> />
) : ( ) : (
......
...@@ -17,7 +17,7 @@ import moduleSettings from './module' ...@@ -17,7 +17,7 @@ import moduleSettings from './module'
const Tables = () => { const Tables = () => {
return ( return (
<Fragment> <Fragment>
<Breadcrumbs breadCrumbTitle='Playlists' breadCrumbParent='Playlists' breadCrumbActive={moduleSettings.mainTitle} /> <Breadcrumbs breadCrumbTitle='Assets' breadCrumbParent='Assets' breadCrumbActive={moduleSettings.mainTitle} />
<Row> <Row>
<Col sm='12'> <Col sm='12'>
<DataTable /> <DataTable />
......
...@@ -3,7 +3,7 @@ import { Fragment, useState, useEffect, memo } from 'react' ...@@ -3,7 +3,7 @@ import { Fragment, useState, useEffect, memo } from 'react'
// ** Table Columns // ** Table Columns
import { serverSideColumns } from './data' import { serverSideColumns } from './data'
// ** Store & Actions // ** Store & Actions
import { getData_playlists } from '../store/actions' import { getData_assets} from '../store/actions'
import { useSelector, useDispatch } from 'react-redux' import { useSelector, useDispatch } from 'react-redux'
import DataTableServerSide from '@components/datatable' import DataTableServerSide from '@components/datatable'
...@@ -12,16 +12,16 @@ import moduleSettings from './module' ...@@ -12,16 +12,16 @@ import moduleSettings from './module'
const DataTable = () => { const DataTable = () => {
// ** Store Vars // ** Store Vars
const dispatch = useDispatch() const dispatch = useDispatch()
const store = useSelector(state => state.playlists) const store = useSelector(state => state.assets)
return ( return (
<DataTableServerSide <DataTableServerSide
cardTitle={moduleSettings.mainTitle} cardTitle={moduleSettings.mainTitle}
allData={store.allDataPlaylists} allData={store.allDataAssets}
getData={getData_playlists} getData={getData_assets}
serverSideColumns={serverSideColumns} serverSideColumns={serverSideColumns}
linkAddButton={`${moduleSettings.baseURL}/add`} linkAddButton={`${moduleSettings.baseURL}/add`}
total={store.totalPlaylists} total={store.totalAssets}
/> />
) )
......
...@@ -48,7 +48,7 @@ const assets = (state = initialState, action) => { ...@@ -48,7 +48,7 @@ const assets = (state = initialState, action) => {
case 'GET_ASSET': case 'GET_ASSET':
return { ...state, return { ...state,
selectedPlaylist : action.data selectedAsset : action.data
} }
case 'UPDATE_ASSET': case 'UPDATE_ASSET':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment