diff --git a/persistence/album_repository.go b/persistence/album_repository.go index 513ae3bb3..bee915304 100644 --- a/persistence/album_repository.go +++ b/persistence/album_repository.go @@ -12,20 +12,20 @@ import ( ) type album struct { - ID string `orm:"pk;column(id)"` - Name string `orm:"index"` - ArtistID string `orm:"column(artist_id);index"` - CoverArtPath string `` - CoverArtId string `` - Artist string `orm:"index"` - AlbumArtist string `` - Year int `orm:"index"` - Compilation bool `` - SongCount int `` - Duration int `` - Genre string `orm:"index"` - CreatedAt time.Time `orm:"null"` - UpdatedAt time.Time `orm:"null"` + ID string `json:"id" orm:"pk;column(id)"` + Name string `json:"name" orm:"index"` + ArtistID string `json:"artistId" orm:"column(artist_id);index"` + CoverArtPath string `json:"-"` + CoverArtId string `json:"-"` + Artist string `json:"artist" orm:"index"` + AlbumArtist string `json:"albumArtist"` + Year int `json:"year" orm:"index"` + Compilation bool `json:"compilation"` + SongCount int `json:"songCount"` + Duration int `json:"duration"` + Genre string `json:"genre" orm:"index"` + CreatedAt time.Time `json:"createdAt" orm:"null"` + UpdatedAt time.Time `json:"updatedAt" orm:"null"` } type albumRepository struct { diff --git a/server/app/app.go b/server/app/app.go index a59c38f3d..3c412bace 100644 --- a/server/app/app.go +++ b/server/app/app.go @@ -50,25 +50,25 @@ func (app *Router) routes() http.Handler { // Add User resource r.Use(jwtauth.Verifier(TokenAuth)) r.Use(Authenticator) - R(r, "/user", func(ctx context.Context) rest.Repository { - return app.ds.Resource(model.User{}) - }) - R(r, "/song", func(ctx context.Context) rest.Repository { - return app.ds.Resource(model.MediaFile{}) - }) + app.R(r, "/user", model.User{}) + app.R(r, "/song", model.MediaFile{}) + app.R(r, "/album", model.Album{}) }) return r } -func R(r chi.Router, pathPrefix string, newRepository rest.RepositoryConstructor) { +func (app *Router) R(r chi.Router, pathPrefix string, model interface{}) { + constructor := func(ctx context.Context) rest.Repository { + return app.ds.Resource(model) + } r.Route(pathPrefix, func(r chi.Router) { - r.Get("/", rest.GetAll(newRepository)) - r.Post("/", rest.Post(newRepository)) + r.Get("/", rest.GetAll(constructor)) + r.Post("/", rest.Post(constructor)) r.Route("/{id:[0-9a-f\\-]+}", func(r chi.Router) { r.Use(UrlParams) - r.Get("/", rest.Get(newRepository)) - r.Put("/", rest.Put(newRepository)) - r.Delete("/", rest.Delete(newRepository)) + r.Get("/", rest.Get(constructor)) + r.Put("/", rest.Put(constructor)) + r.Delete("/", rest.Delete(constructor)) }) }) } diff --git a/ui/src/App.js b/ui/src/App.js index 3ba608460..e992c087a 100644 --- a/ui/src/App.js +++ b/ui/src/App.js @@ -6,6 +6,7 @@ import authProvider from './authProvider' import { Login } from './layout' import user from './user' import song from './song' +import album from './album' const App = () => ( ( loginPage={Login} > + ) diff --git a/ui/src/album/AlbumList.js b/ui/src/album/AlbumList.js new file mode 100644 index 000000000..9ffd2527d --- /dev/null +++ b/ui/src/album/AlbumList.js @@ -0,0 +1,57 @@ +import React from 'react' +import { + BooleanField, + Datagrid, + DateField, + Filter, + List, + NumberField, + SearchInput, + TextInput, + Show, + SimpleShowLayout, + TextField +} from 'react-admin' +import { BitrateField, DurationField, Title } from '../common' + +const AlbumFilter = (props) => ( + + + + +) + +const AlbumDetails = (props) => { + return ( + + + + + + + + + ) +} + +const AlbumList = (props) => ( + } + sort={{ field: 'name', order: 'ASC' }} + exporter={false} + bulkActionButtons={false} + filters={} + perPage={15} + > + }> + + + + + + + +) + +export default AlbumList diff --git a/ui/src/album/index.js b/ui/src/album/index.js new file mode 100644 index 000000000..17e55f56c --- /dev/null +++ b/ui/src/album/index.js @@ -0,0 +1,7 @@ +import AlbumIcon from '@material-ui/icons/Album' +import AlbumList from './AlbumList' + +export default { + list: AlbumList, + icon: AlbumIcon +} diff --git a/ui/src/song/index.js b/ui/src/song/index.js index 7f83b4d50..3cd49a66b 100644 --- a/ui/src/song/index.js +++ b/ui/src/song/index.js @@ -1,7 +1,7 @@ -import MusicNote from '@material-ui/icons/MusicNote' +import MusicNoteIcon from '@material-ui/icons/MusicNote' import SongList from './SongList' export default { list: SongList, - icon: MusicNote + icon: MusicNoteIcon }