diff --git a/Public API v1.yaml b/Public API v1.yaml index 589e91f..96ba54d 100644 --- a/Public API v1.yaml +++ b/Public API v1.yaml @@ -148,7 +148,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/inline_response_200_5' + $ref: '#/components/schemas/SuccessObject' security: - Auth query parameter: [] /api/disableSharing: @@ -170,7 +170,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/inline_response_200_5' + $ref: '#/components/schemas/SuccessObject' security: - Auth query parameter: [] /api/subscribe: @@ -311,14 +311,14 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/body_10' + $ref: '#/components/schemas/CreatePlaylistRequest' responses: '200': description: OK content: application/json: schema: - $ref: '#/components/schemas/inline_response_200_12' + $ref: '#/components/schemas/CreatePlaylistResponse' security: - Auth query parameter: [] /api/getPlaylist: @@ -332,28 +332,49 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/body_11' + $ref: '#/components/schemas/GetPlaylistRequest' responses: '200': description: OK content: application/json: schema: - $ref: '#/components/schemas/inline_response_200_13' + $ref: '#/components/schemas/GetPlaylistResponse' security: - Auth query parameter: [] /api/updatePlaylist: + post: + tags: + - playlists + summary: Update playlist + description: Updates the playlist object + operationId: post-api-updatePlaylist + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdatePlaylistRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/SuccessObject' + security: + - Auth query parameter: [] + /api/updatePlaylistFiles: post: tags: - playlists summary: Update playlist files description: Updates the list of filenames in the playlist object - operationId: post-api-updatePlaylist + operationId: post-api-updatePlaylistFiles requestBody: content: application/json: schema: - $ref: '#/components/schemas/body_12' + $ref: '#/components/schemas/UpdatePlaylistFilesRequest' responses: '200': description: OK @@ -374,14 +395,14 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/body_13' + $ref: '#/components/schemas/DeletePlaylistRequest' responses: '200': description: OK content: application/json: schema: - $ref: '#/components/schemas/inline_response_200_5' + $ref: '#/components/schemas/SuccessObject' security: - Auth query parameter: [] /api/deleteMp4: @@ -495,7 +516,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/inline_response_200_5' + $ref: '#/components/schemas/SuccessObject' security: - Auth query parameter: [] /api/isPinSet: @@ -532,7 +553,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/inline_response_200_5' + $ref: '#/components/schemas/SuccessObject' security: - Auth query parameter: [] /api/setPin: @@ -552,7 +573,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/inline_response_200_5' + $ref: '#/components/schemas/SuccessObject' security: - Auth query parameter: [] description: '' @@ -625,7 +646,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/inline_response_200_5' + $ref: '#/components/schemas/SuccessObject' security: - Auth query parameter: [] /api/downloads: @@ -1196,12 +1217,13 @@ components: type: array items: $ref: '#/components/schemas/Subscription' - body_10: + CreatePlaylistRequest: required: - fileNames - playlistName - thumbnailURL - type + - duration type: object properties: playlistName: @@ -1211,30 +1233,33 @@ components: items: type: string type: - type: string + $ref: '#/components/schemas/FileType' thumbnailURL: type: string - inline_response_200_12: + duration: + type: number + CreatePlaylistResponse: required: - new_playlist - success type: object properties: new_playlist: - $ref: '#/components/schemas/inline_response_200_12_new_playlist' + $ref: '#/components/schemas/Playlist' success: type: boolean - body_11: + GetPlaylistRequest: required: - playlistID - - type type: object properties: playlistID: type: string type: + $ref: '#/components/schemas/FileType' + uuid: type: string - inline_response_200_13: + GetPlaylistResponse: required: - playlist - success @@ -1244,10 +1269,17 @@ components: playlist: $ref: '#/components/schemas/Playlist' type: - type: string + $ref: '#/components/schemas/FileType' success: type: boolean - body_12: + UpdatePlaylistRequest: + required: + - playlist + type: object + properties: + playlist: + $ref: '#/components/schemas/Playlist' + UpdatePlaylistFilesRequest: required: - fileNames - playlistID @@ -1261,8 +1293,8 @@ components: items: type: string type: - type: string - body_13: + $ref: '#/components/schemas/FileType' + DeletePlaylistRequest: required: - playlistID - type @@ -1271,7 +1303,7 @@ components: playlistID: type: string type: - type: string + $ref: '#/components/schemas/FileType' body_15: required: - fileNames @@ -1435,6 +1467,9 @@ components: - id - name - thumbnailURL + - type + - registered + - duration type: object properties: name: @@ -1447,6 +1482,12 @@ components: type: string thumbnailURL: type: string + type: + $ref: '#/components/schemas/FileType' + registered: + type: number + duration: + type: number Download: required: - uid @@ -1545,25 +1586,6 @@ components: type: array items: type: object - inline_response_200_12_new_playlist: - required: - - fileNames - - id - - name - - thumbnailURL - - type - type: object - properties: - name: - type: string - fileNames: - type: string - id: - type: string - thumbnailURL: - type: string - type: - type: string User: title: user type: object diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index 3625449..28e672c 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -20,6 +20,7 @@ import { CreatePlaylistComponent } from 'app/create-playlist/create-playlist.com import { Platform } from '@angular/cdk/platform'; import { v4 as uuid } from 'uuid'; import { ArgModifierDialogComponent } from 'app/dialogs/arg-modifier-dialog/arg-modifier-dialog.component'; +import type { FileType } from 'api-types'; export let audioFilesMouseHovering = false; export let videoFilesMouseHovering = false; @@ -453,7 +454,7 @@ export class MainComponent implements OnInit { } public removePlaylistMp3(playlistID, index) { - this.postsService.removePlaylist(playlistID, 'audio').subscribe(res => { + this.postsService.removePlaylist(playlistID, 'audio' as FileType).subscribe(res => { if (res['success']) { this.playlists.audio.splice(index, 1); this.openSnackBar('Playlist successfully removed.', ''); @@ -472,7 +473,7 @@ export class MainComponent implements OnInit { } public removePlaylistMp4(playlistID, index) { - this.postsService.removePlaylist(playlistID, 'video').subscribe(res => { + this.postsService.removePlaylist(playlistID, 'video' as FileType).subscribe(res => { if (res['success']) { this.playlists.video.splice(index, 1); this.openSnackBar('Playlist successfully removed.', ''); diff --git a/src/app/player/player.component.ts b/src/app/player/player.component.ts index 3640d7ad..79eb371 100644 --- a/src/app/player/player.component.ts +++ b/src/app/player/player.component.ts @@ -7,6 +7,7 @@ import { MatSnackBar } from '@angular/material/snack-bar'; import { InputDialogComponent } from 'app/input-dialog/input-dialog.component'; import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; import { ShareMediaDialogComponent } from '../dialogs/share-media-dialog/share-media-dialog.component'; +import type { FileType } from 'api-types'; export interface IMedia { title: string; @@ -360,7 +361,7 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy { // Eventually do additional checks on name if (name) { const fileNames = this.getFileNames(); - this.postsService.createPlaylist(name, fileNames, this.type, null).subscribe(res => { + this.postsService.createPlaylist(name, fileNames, this.type as FileType, null).subscribe(res => { if (res['success']) { dialogRef.close(); const new_playlist = res['new_playlist']; @@ -401,7 +402,7 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy { updatePlaylist() { const fileNames = this.getFileNames(); this.playlist_updating = true; - this.postsService.updatePlaylistFiles(this.id, fileNames, this.type).subscribe(res => { + this.postsService.updatePlaylistFiles(this.id, fileNames, this.type as FileType).subscribe(res => { this.playlist_updating = false; if (res['success']) { const fileNamesEncoded = fileNames.join('|nvr|'); diff --git a/src/app/posts.services.ts b/src/app/posts.services.ts index 92b2b43..c7e7322 100644 --- a/src/app/posts.services.ts +++ b/src/app/posts.services.ts @@ -11,7 +11,10 @@ import { BehaviorSubject } from 'rxjs'; import { MatSnackBar } from '@angular/material/snack-bar'; import * as Fingerprint2 from 'fingerprintjs2'; import { + CreatePlaylistRequest, + CreatePlaylistResponse, DeleteMp3Mp4Request, + DeletePlaylistRequest, DeleteSubscriptionFileRequest, FileType, GetAllDownloadsResponse, @@ -23,18 +26,24 @@ import { GetFileResponse, GetMp3sResponse, GetMp4sResponse, + GetPlaylistRequest, + GetPlaylistResponse, GetSubscriptionRequest, GetSubscriptionResponse, Mp3DownloadRequest, Mp3DownloadResponse, Mp4DownloadRequest, Mp4DownloadResponse, + Playlist, + SharingToggle, SubscribeRequest, SubscribeResponse, SubscriptionRequestData, SuccessObject, UnsubscribeRequest, - UnsubscribeResponse + UnsubscribeResponse, + UpdatePlaylistFilesRequest, + UpdatePlaylistRequest, } from 'api-types'; @Injectable() @@ -293,39 +302,46 @@ export class PostsService implements CanActivate { return this.http.post(this.path + 'generateNewAPIKey', {}, this.httpOptions); } - enableSharing(uid, type, is_playlist) { - return this.http.post(this.path + 'enableSharing', {uid: uid, type: type, is_playlist: is_playlist}, this.httpOptions); + enableSharing(uid: string, type: FileType, is_playlist: boolean) { + const body: SharingToggle = {uid: uid, type: type, is_playlist: is_playlist}; + return this.http.post(this.path + 'enableSharing', body, this.httpOptions); } - disableSharing(uid, type, is_playlist) { - return this.http.post(this.path + 'disableSharing', {uid: uid, type: type, is_playlist: is_playlist}, this.httpOptions); + disableSharing(uid: string, type: FileType, is_playlist: boolean) { + const body: SharingToggle = {uid: uid, type: type, is_playlist: is_playlist}; + return this.http.post(this.path + 'disableSharing', body, this.httpOptions); } - createPlaylist(playlistName, fileNames, type, thumbnailURL, duration = null) { - return this.http.post(this.path + 'createPlaylist', {playlistName: playlistName, - fileNames: fileNames, - type: type, - thumbnailURL: thumbnailURL, - duration: duration}, this.httpOptions); + createPlaylist(playlistName: string, fileNames: string[], type: FileType, thumbnailURL: string, duration: number = null) { + const body: CreatePlaylistRequest = {playlistName: playlistName, + fileNames: fileNames, + type: type, + thumbnailURL: thumbnailURL, + duration: duration}; + return this.http.post(this.path + 'createPlaylist', body, this.httpOptions); } - getPlaylist(playlistID, type, uuid = null) { - return this.http.post(this.path + 'getPlaylist', {playlistID: playlistID, - type: type, uuid: uuid}, this.httpOptions); + getPlaylist(playlistID: string, type: FileType, uuid: string = null) { + const body: GetPlaylistRequest = {playlistID: playlistID, + type: type, uuid: uuid}; + return this.http.post(this.path + 'getPlaylist', body, this.httpOptions); } - updatePlaylist(playlist) { - return this.http.post(this.path + 'updatePlaylist', {playlist: playlist}, this.httpOptions); + updatePlaylist(playlist: Playlist) { + const body: UpdatePlaylistRequest = {playlist: playlist}; + return this.http.post(this.path + 'updatePlaylist', body, this.httpOptions); } - updatePlaylistFiles(playlistID, fileNames, type) { - return this.http.post(this.path + 'updatePlaylistFiles', {playlistID: playlistID, - fileNames: fileNames, - type: type}, this.httpOptions); + updatePlaylistFiles(playlistID: string, fileNames: string[], type: FileType) { + const body: UpdatePlaylistFilesRequest = {playlistID: playlistID, + fileNames: fileNames, + type: type}; + return this.http.post(this.path + 'updatePlaylistFiles', body, this.httpOptions); } - removePlaylist(playlistID, type) { - return this.http.post(this.path + 'deletePlaylist', {playlistID: playlistID, type: type}, this.httpOptions); + removePlaylist(playlistID: string, type: FileType) { + const body: DeletePlaylistRequest = {playlistID: playlistID, type: type}; + return this.http.post(this.path + 'deletePlaylist', body, this.httpOptions); } createSubscription(url: string, name: string, timerange: string = null, streamingOnly = false, audioOnly = false, customArgs: string = null, customFileOutput: string = null) {