mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 13:07:59 +01:00
Also ordered genres alphabetically in the genre editor.
This commit is contained in:
parent
4c660fcb71
commit
2bd6a0b258
11 changed files with 115 additions and 10 deletions
|
@ -30,10 +30,11 @@ use Cache;
|
||||||
use Poniverse\Ponyfm\Traits\TrackCollection;
|
use Poniverse\Ponyfm\Traits\TrackCollection;
|
||||||
use URL;
|
use URL;
|
||||||
use Poniverse\Ponyfm\Traits\SlugTrait;
|
use Poniverse\Ponyfm\Traits\SlugTrait;
|
||||||
|
use Venturecraft\Revisionable\RevisionableTrait;
|
||||||
|
|
||||||
class Album extends Model
|
class Album extends Model
|
||||||
{
|
{
|
||||||
use SoftDeletes, SlugTrait, DispatchesJobs, TrackCollection;
|
use SoftDeletes, SlugTrait, DispatchesJobs, TrackCollection, RevisionableTrait;
|
||||||
|
|
||||||
protected $dates = ['deleted_at'];
|
protected $dates = ['deleted_at'];
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ use DB;
|
||||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||||
use Poniverse\Ponyfm\Traits\SlugTrait;
|
use Poniverse\Ponyfm\Traits\SlugTrait;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Venturecraft\Revisionable\RevisionableTrait;
|
||||||
|
|
||||||
class Genre extends Model
|
class Genre extends Model
|
||||||
{
|
{
|
||||||
|
@ -34,7 +35,7 @@ class Genre extends Model
|
||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
use SlugTrait;
|
use SlugTrait, RevisionableTrait;
|
||||||
|
|
||||||
public function tracks(){
|
public function tracks(){
|
||||||
return $this->hasMany(Track::class, 'genre_id');
|
return $this->hasMany(Track::class, 'genre_id');
|
||||||
|
|
|
@ -35,7 +35,9 @@ class GenresController extends ApiControllerBase
|
||||||
|
|
||||||
$genres = Genre::with(['trackCountRelation' => function($query) {
|
$genres = Genre::with(['trackCountRelation' => function($query) {
|
||||||
$query->withTrashed();
|
$query->withTrashed();
|
||||||
}])->get();
|
}])
|
||||||
|
->orderBy('name', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
return Response::json([
|
return Response::json([
|
||||||
'genres' => $genres->toArray()
|
'genres' => $genres->toArray()
|
||||||
|
|
|
@ -29,10 +29,11 @@ use Cache;
|
||||||
use Poniverse\Ponyfm\Traits\TrackCollection;
|
use Poniverse\Ponyfm\Traits\TrackCollection;
|
||||||
use URL;
|
use URL;
|
||||||
use Poniverse\Ponyfm\Traits\SlugTrait;
|
use Poniverse\Ponyfm\Traits\SlugTrait;
|
||||||
|
use Venturecraft\Revisionable\RevisionableTrait;
|
||||||
|
|
||||||
class Playlist extends Model
|
class Playlist extends Model
|
||||||
{
|
{
|
||||||
use SoftDeletes, SlugTrait, DispatchesJobs, TrackCollection;
|
use SoftDeletes, SlugTrait, DispatchesJobs, TrackCollection, RevisionableTrait;
|
||||||
|
|
||||||
protected $table = 'playlists';
|
protected $table = 'playlists';
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Log;
|
use Log;
|
||||||
use URL;
|
use URL;
|
||||||
|
use Venturecraft\Revisionable\RevisionableTrait;
|
||||||
|
|
||||||
class Track extends Model
|
class Track extends Model
|
||||||
{
|
{
|
||||||
|
@ -46,6 +47,8 @@ class Track extends Model
|
||||||
SlugTrait::setTitleAttribute as setTitleAttributeSlug;
|
SlugTrait::setTitleAttribute as setTitleAttributeSlug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use RevisionableTrait;
|
||||||
|
|
||||||
public static $Formats = [
|
public static $Formats = [
|
||||||
'FLAC' => [
|
'FLAC' => [
|
||||||
'index' => 0,
|
'index' => 0,
|
||||||
|
|
|
@ -31,10 +31,11 @@ use Illuminate\Foundation\Auth\Access\Authorizable;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\URL;
|
use Illuminate\Support\Facades\URL;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Venturecraft\Revisionable\RevisionableTrait;
|
||||||
|
|
||||||
class User extends Model implements AuthenticatableContract, CanResetPasswordContract, \Illuminate\Contracts\Auth\Access\Authorizable
|
class User extends Model implements AuthenticatableContract, CanResetPasswordContract, \Illuminate\Contracts\Auth\Access\Authorizable
|
||||||
{
|
{
|
||||||
use Authenticatable, CanResetPassword, Authorizable;
|
use Authenticatable, CanResetPassword, Authorizable, RevisionableTrait;
|
||||||
|
|
||||||
protected $table = 'users';
|
protected $table = 'users';
|
||||||
protected $hidden1 = ['password_hash', 'password_salt', 'bio'];
|
protected $hidden1 = ['password_hash', 'password_salt', 'bio'];
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
"intouch/laravel-newrelic": "*",
|
"intouch/laravel-newrelic": "*",
|
||||||
"barryvdh/laravel-ide-helper": "^2.1",
|
"barryvdh/laravel-ide-helper": "^2.1",
|
||||||
"guzzlehttp/guzzle": "~6.0",
|
"guzzlehttp/guzzle": "~6.0",
|
||||||
"doctrine/dbal": "^2.5"
|
"doctrine/dbal": "^2.5",
|
||||||
|
"venturecraft/revisionable": "^1.23"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fzaninotto/faker": "~1.4",
|
"fzaninotto/faker": "~1.4",
|
||||||
|
|
52
composer.lock
generated
52
composer.lock
generated
|
@ -4,8 +4,8 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "de5e29b9defac1327482713da4fc062d",
|
"hash": "5f66a059010df46b5b6e50c3e4056e17",
|
||||||
"content-hash": "e9ed56cee43eb3096269b8fc9db1bf9b",
|
"content-hash": "07e7a5fff5a8914a7ced3d14959d194f",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "barryvdh/laravel-ide-helper",
|
"name": "barryvdh/laravel-ide-helper",
|
||||||
|
@ -2636,6 +2636,54 @@
|
||||||
],
|
],
|
||||||
"time": "2015-07-28 15:18:12"
|
"time": "2015-07-28 15:18:12"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "venturecraft/revisionable",
|
||||||
|
"version": "1.23.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/VentureCraft/revisionable.git",
|
||||||
|
"reference": "75af7add8d857ac0dfcb41398f1958c7ac51d72c"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/VentureCraft/revisionable/zipball/75af7add8d857ac0dfcb41398f1958c7ac51d72c",
|
||||||
|
"reference": "75af7add8d857ac0dfcb41398f1958c7ac51d72c",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"illuminate/support": "~4.0|~5.0|~5.1",
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"classmap": [
|
||||||
|
"src/migrations"
|
||||||
|
],
|
||||||
|
"psr-0": {
|
||||||
|
"Venturecraft\\Revisionable": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Chris Duell",
|
||||||
|
"email": "me@chrisduell.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Keep a revision history for your models without thinking, created as a package for use with Laravel",
|
||||||
|
"homepage": "http://github.com/venturecraft/revisionable",
|
||||||
|
"keywords": [
|
||||||
|
"ardent",
|
||||||
|
"history",
|
||||||
|
"laravel",
|
||||||
|
"model",
|
||||||
|
"revision"
|
||||||
|
],
|
||||||
|
"time": "2015-11-09 22:01:31"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "vlucas/phpdotenv",
|
"name": "vlucas/phpdotenv",
|
||||||
"version": "v1.1.1",
|
"version": "v1.1.1",
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From the venturecraft/revisionable package: https://github.com/VentureCraft/revisionable
|
||||||
|
*
|
||||||
|
* Modified to add a foreign key constraint on the `user_id` column and
|
||||||
|
* designate the `revisionable_id` and `user_id` columns as unsigned.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateRevisionsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('revisions', function ($table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->string('revisionable_type');
|
||||||
|
$table->integer('revisionable_id')->unsigned();
|
||||||
|
$table->integer('user_id')->unsigned()->nullable();
|
||||||
|
$table->string('key');
|
||||||
|
$table->text('old_value')->nullable();
|
||||||
|
$table->text('new_value')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->index(array('revisionable_id', 'revisionable_type'));
|
||||||
|
|
||||||
|
$table->foreign('user_id')->references('id')->on('users');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::drop('revisions');
|
||||||
|
}
|
||||||
|
}
|
|
@ -43,6 +43,7 @@
|
||||||
<li><a href="https://github.com/mgonto/angularytics" target="_blank">Angularytics</a> - for making Google Analytics useful in a single-page app</li>
|
<li><a href="https://github.com/mgonto/angularytics" target="_blank">Angularytics</a> - for making Google Analytics useful in a single-page app</li>
|
||||||
<li><a href="https://github.com/angular-ui/ui-router" target="_blank">UI-Router</a> - for making non-trivial Angular.js routes possible</li>
|
<li><a href="https://github.com/angular-ui/ui-router" target="_blank">UI-Router</a> - for making non-trivial Angular.js routes possible</li>
|
||||||
<li><a href="https://angular-ui.github.io/bootstrap/" target="_blank">UI-Bootstrap</a> - for making Bootstrap and Angular.js get along</li>
|
<li><a href="https://angular-ui.github.io/bootstrap/" target="_blank">UI-Bootstrap</a> - for making Bootstrap and Angular.js get along</li>
|
||||||
|
<li><a href="https://github.com/VentureCraft/revisionable" target="_blank">Revisionable</a> - for making audit logs easy</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
|
|
@ -18,13 +18,13 @@ angular.module('ponyfm').controller 'admin-genres', [
|
||||||
'$scope', '$state', 'admin-genres'
|
'$scope', '$state', 'admin-genres'
|
||||||
($scope, $state, genres) ->
|
($scope, $state, genres) ->
|
||||||
|
|
||||||
$scope.genres = {}
|
$scope.genres = []
|
||||||
|
|
||||||
setGenres = (genres) ->
|
setGenres = (genres) ->
|
||||||
for genre in genres
|
for genre in genres
|
||||||
genre.isSaving = false
|
genre.isSaving = false
|
||||||
genre.isError = false
|
genre.isError = false
|
||||||
$scope.genres[genre.id] = genre
|
$scope.genres.push(genre)
|
||||||
|
|
||||||
genres.fetch().done setGenres
|
genres.fetch().done setGenres
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue