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