From c64bde7c2ae3ac8a71c45e5288c5736fe7abaf2b Mon Sep 17 00:00:00 2001 From: Andrew Schlackman <72105194+sei-aschlackman@users.noreply.github.com> Date: Thu, 21 Dec 2023 16:31:47 -0500 Subject: [PATCH 1/3] fixed intermittent issues with moving applications on a team --- .../team-applications-select.component.html | 4 +- .../team-applications-select.component.ts | 12 ++ .../player-api/api/application.service.ts | 119 +++++++++++++++++- 3 files changed, 128 insertions(+), 7 deletions(-) diff --git a/src/app/components/admin-app/team-applications-select/team-applications-select.component.html b/src/app/components/admin-app/team-applications-select/team-applications-select.component.html index 5ec45290..f75554c4 100644 --- a/src/app/components/admin-app/team-applications-select/team-applications-select.component.html +++ b/src/app/components/admin-app/team-applications-select/team-applications-select.component.html @@ -61,7 +61,7 @@ [ngClass]="moveUp.disabled ? 'disabled-button' : null" mat-icon-button title="Move Up" - (click)="swapDisplayOrders(app, applications[i - 1])" + (click)="moveAppUp(app.id)" > diff --git a/src/app/components/admin-app/team-applications-select/team-applications-select.component.ts b/src/app/components/admin-app/team-applications-select/team-applications-select.component.ts index 51ac885e..0ad44ee3 100644 --- a/src/app/components/admin-app/team-applications-select/team-applications-select.component.ts +++ b/src/app/components/admin-app/team-applications-select/team-applications-select.component.ts @@ -111,6 +111,18 @@ export class TeamApplicationsSelectComponent implements OnInit { }); } + public moveAppUp(id: string) { + this.applicationService + .moveUpApplicationInstance(id) + .subscribe((x) => (this.applications = x)); + } + + public moveAppDown(id: string) { + this.applicationService + .moveDownApplicationInstance(id) + .subscribe((x) => (this.applications = x)); + } + /** * Swaps the display orders of two teams in the application * @param app1 diff --git a/src/app/generated/player-api/api/application.service.ts b/src/app/generated/player-api/api/application.service.ts index dadd6db0..3a000c01 100644 --- a/src/app/generated/player-api/api/application.service.ts +++ b/src/app/generated/player-api/api/application.service.ts @@ -1,8 +1,3 @@ -/* -Copyright 2021 Carnegie Mellon University. All Rights Reserved. - Released under a MIT (SEI)-style license. See LICENSE.md in the project root for license information. -*/ - /** * Player API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) @@ -792,6 +787,120 @@ export class ApplicationService { ); } + /** + * Moves an Application Instance down + * Moves an Application Instance down one spot in the list <para /> Accessible only to a SuperUser or a User on an Admin Team in the Application Instances\'s Team\'s View + * @param id The id of the Application Instance + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public moveDownApplicationInstance(id: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json'}): Observable>; + public moveDownApplicationInstance(id: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json'}): Observable>>; + public moveDownApplicationInstance(id: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json'}): Observable>>; + public moveDownApplicationInstance(id: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json'}): Observable { + if (id === null || id === undefined) { + throw new Error('Required parameter id was null or undefined when calling moveDownApplicationInstance.'); + } + + let headers = this.defaultHeaders; + + // authentication (oauth2) required + if (this.configuration.accessToken) { + const accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headers = headers.set('Authorization', 'Bearer ' + accessToken); + } + + let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (httpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'text/plain', + 'application/json', + 'text/json' + ]; + httpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (httpHeaderAcceptSelected !== undefined) { + headers = headers.set('Accept', httpHeaderAcceptSelected); + } + + + let responseType: 'text' | 'json' = 'json'; + if(httpHeaderAcceptSelected && httpHeaderAcceptSelected.startsWith('text')) { + responseType = 'text'; + } + + return this.httpClient.post>(`${this.configuration.basePath}/api/application-instances/${encodeURIComponent(String(id))}/move-down`, + null, + { + responseType: responseType, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Moves an Application Instance up + * Moves an Application Instance up one spot in the list <para /> Accessible only to a SuperUser or a User on an Admin Team in the Application Instances\'s Team\'s View + * @param id The id of the Application Instance + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public moveUpApplicationInstance(id: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json'}): Observable>; + public moveUpApplicationInstance(id: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json'}): Observable>>; + public moveUpApplicationInstance(id: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json'}): Observable>>; + public moveUpApplicationInstance(id: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json'}): Observable { + if (id === null || id === undefined) { + throw new Error('Required parameter id was null or undefined when calling moveUpApplicationInstance.'); + } + + let headers = this.defaultHeaders; + + // authentication (oauth2) required + if (this.configuration.accessToken) { + const accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headers = headers.set('Authorization', 'Bearer ' + accessToken); + } + + let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (httpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'text/plain', + 'application/json', + 'text/json' + ]; + httpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (httpHeaderAcceptSelected !== undefined) { + headers = headers.set('Accept', httpHeaderAcceptSelected); + } + + + let responseType: 'text' | 'json' = 'json'; + if(httpHeaderAcceptSelected && httpHeaderAcceptSelected.startsWith('text')) { + responseType = 'text'; + } + + return this.httpClient.post>(`${this.configuration.basePath}/api/application-instances/${encodeURIComponent(String(id))}/move-up`, + null, + { + responseType: responseType, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + } + ); + } + /** * Updates an Application * Updates an Application with the attributes specified <para /> Accessible only to a SuperUser or a User on an Admin Team in the Application\'s assigned View From a3864bc6a69d1f5f19e8b85b99c4914c8ef14d02 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 21 Dec 2023 21:32:42 +0000 Subject: [PATCH 2/3] Add missing document markings --- src/app/generated/player-api/api/application.service.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/generated/player-api/api/application.service.ts b/src/app/generated/player-api/api/application.service.ts index 3a000c01..73e1a37b 100644 --- a/src/app/generated/player-api/api/application.service.ts +++ b/src/app/generated/player-api/api/application.service.ts @@ -1,3 +1,8 @@ +/* +Copyright 2021 Carnegie Mellon University. All Rights Reserved. + Released under a MIT (SEI)-style license. See LICENSE.md in the project root for license information. +*/ + /** * Player API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) From 645dc360e7c551d959bb13c828b6dbb8b47f71d2 Mon Sep 17 00:00:00 2001 From: Andrew Schlackman <72105194+sei-aschlackman@users.noreply.github.com> Date: Thu, 21 Dec 2023 16:48:22 -0500 Subject: [PATCH 3/3] removed unused function --- .../team-applications-select.component.ts | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/src/app/components/admin-app/team-applications-select/team-applications-select.component.ts b/src/app/components/admin-app/team-applications-select/team-applications-select.component.ts index 0ad44ee3..f4162d72 100644 --- a/src/app/components/admin-app/team-applications-select/team-applications-select.component.ts +++ b/src/app/components/admin-app/team-applications-select/team-applications-select.component.ts @@ -123,39 +123,6 @@ export class TeamApplicationsSelectComponent implements OnInit { .subscribe((x) => (this.applications = x)); } - /** - * Swaps the display orders of two teams in the application - * @param app1 - * @param app2 - */ - swapDisplayOrders( - app1: ApplicationInstance, - app2: ApplicationInstance - ): void { - const a1 = { - id: app1.id, - teamId: this.team.id, - applicationId: app1.applicationId, - displayOrder: app2.displayOrder, - }; - const a2 = { - id: app2.id, - teamId: this.team.id, - applicationId: app2.applicationId, - displayOrder: app1.displayOrder, - }; - - this.applicationService - .updateApplicationInstance(app1.id, a1) - .subscribe(() => { - this.applicationService - .updateApplicationInstance(app2.id, a2) - .subscribe(() => { - this.refreshTeamApplications(); - }); - }); - } - /** * Removes an application from a team * @param app App to remove