Skip to content

Commit

Permalink
saving profiles works, remove old profile view
Browse files Browse the repository at this point in the history
  • Loading branch information
lardbit committed Aug 1, 2024
1 parent 5e59167 commit ec2f74c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 31 deletions.
8 changes: 4 additions & 4 deletions src/frontend/src/app/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class ApiService {
API_URL_GENRES_MOVIE = '/api/genres/movie/';
API_URL_GENRES_TV = '/api/genres/tv/';
API_URL_MEDIA_CATEGORIES = '/api/media-categories/';
API_URL_QUALITY_PROFILES = '/api/quality-profiles/';
API_URL_QUALITY_PROFILES = '/api/quality-profile/';
API_URL_GIT_COMMIT = '/api/git-commit/';
API_URL_IMPORT_MEDIA_TV = '/api/import/media/tv/';
API_URL_IMPORT_MEDIA_MOVIE = '/api/import/media/movie/';
Expand All @@ -55,7 +55,7 @@ export class ApiService {
public userToken: string;
public users: any; // staff-only list of all users
public settings: any;
public qualityProfiles: string[];
public qualityProfiles: any[] = [];
public mediaCategories: string[];
public watchTVSeasons: any[] = [];
public watchTVSeasonRequests: any[] = [];
Expand Down Expand Up @@ -240,8 +240,8 @@ export class ApiService {
public fetchQualityProfiles() {
return this.http.get(this.API_URL_QUALITY_PROFILES, {headers: this._requestHeaders()}).pipe(
map((data: any) => {
if (data.profiles) {
this.qualityProfiles = data.profiles;
if (data.length) {
this.qualityProfiles = data;
} else {
console.error('no quality profiles');
}
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/app/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@
<div class="my-2">
<label>TV</label>
<select type="text" class="form-select" formControlName="quality_profile_tv" required>
<option *ngFor="let profile of qualityProfiles()" [value]="profile">{{ profile }}</option>
<option *ngFor="let profile of qualityProfiles()" [value]="profile.id">{{ profile.name }}</option>
</select>
</div>
<div class="my-2">
<label>Movies</label>
<select type="text" class="form-select" formControlName="quality_profile_movies" required>
<option *ngFor="let profile of qualityProfiles()" [value]="profile">{{ profile }}</option>
<option *ngFor="let profile of qualityProfiles()" [value]="profile.id">{{ profile.name }}</option>
</select>
</div>
</div>
Expand Down
3 changes: 1 addition & 2 deletions src/frontend/src/app/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export class SettingsComponent implements OnInit, AfterContentChecked {
'open_subtitles_username': [settings['open_subtitles_username']],
'open_subtitles_password': [settings['open_subtitles_password']],
'open_subtitles_auto': [settings['open_subtitles_auto']],
// TODO - use QualityProfile primary key
'quality_profile_tv': [settings['quality_profile_tv'], Validators.required],
'quality_profile_movies': [settings['quality_profile_movies'], Validators.required],
'allow_hardcoded_subs': [settings['allow_hardcoded_subs'], Validators.required],
Expand Down Expand Up @@ -114,7 +113,7 @@ export class SettingsComponent implements OnInit, AfterContentChecked {
).subscribe();
}

public qualityProfiles(): string[] {
public qualityProfiles(): any[] {
return this.apiService.qualityProfiles;
}

Expand Down
21 changes: 6 additions & 15 deletions src/nefarious/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ def get_requested_by(self, watch_media):
return watch_media.user.username


class QualityProfileSerializer(serializers.ModelSerializer):
class Meta:
model = QualityProfile
fields = '__all__'


class NefariousSettingsSerializer(serializers.ModelSerializer):
tmdb_configuration = serializers.JSONField(required=False)
keyword_search_filters = serializers.JSONField(required=False)
Expand All @@ -30,9 +36,6 @@ class NefariousSettingsSerializer(serializers.ModelSerializer):
websocket_url = serializers.SerializerMethodField()
is_debug = serializers.SerializerMethodField()
host_download_path = serializers.SerializerMethodField()
# TODO - need to handle saving
quality_profile_tv = serializers.SerializerMethodField()
quality_profile_movies = serializers.SerializerMethodField()

def get_websocket_url(self, obj):
return settings.WEBSOCKET_URL
Expand All @@ -43,12 +46,6 @@ def get_is_debug(self, obj):
def get_host_download_path(self, obj):
return settings.HOST_DOWNLOAD_PATH

def get_quality_profile_tv(self, obj):
return QualityProfileSerializer(obj.quality_profile_tv).data

def get_quality_profile_movies(self, obj):
return QualityProfileSerializer(obj.quality_profile_movies).data

class Meta:
model = NefariousSettings
fields = '__all__'
Expand Down Expand Up @@ -223,9 +220,3 @@ class TorrentBlacklistSerializer(serializers.ModelSerializer):
class Meta:
model = TorrentBlacklist
fields = '__all__'


class QualityProfileSerializer(serializers.ModelSerializer):
class Meta:
model = QualityProfile
fields = '__all__'
1 change: 0 additions & 1 deletion src/nefarious/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
path('import/media/<str:media_type>/', views.ImportMediaLibraryView.as_view()),
path('genres/<str:media_type>/', views.GenresView.as_view()),
path('media-categories/', views.MediaCategoriesView.as_view()),
path('quality-profiles/', views.QualityProfilesView.as_view()),
path('auth/', views.ObtainAuthTokenView.as_view()), # authenticates user and returns token
path('git-commit/', views.GitCommitView.as_view()), # returns this app's git commit
path('open-subtitles/auth/', views.OpenSubtitlesAuthView.as_view()), # auths against open subtitles
Expand Down
7 changes: 0 additions & 7 deletions src/nefarious/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,6 @@ def get(self, request, media_type: str):
})


@method_decorator(gzip_page, name='dispatch')
class QualityProfilesView(views.APIView):

def get(self, request):
return Response({'profiles': [p.name for p in PROFILES]})


@method_decorator(gzip_page, name='dispatch')
class MediaCategoriesView(views.APIView):

Expand Down

0 comments on commit ec2f74c

Please sign in to comment.