Skip to content

Commit

Permalink
fixed intermittent issues with moving applications on a team (#632)
Browse files Browse the repository at this point in the history
* fixed intermittent issues with moving applications on a team
  • Loading branch information
sei-aschlackman authored Dec 22, 2023
1 parent 9f34781 commit 8dfed22
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
>
<mat-icon
svgIcon="ic_expand_more_black_24px"
Expand All @@ -76,7 +76,7 @@
[ngClass]="moveDown.disabled ? 'disabled-button' : null"
title="Move Down"
mat-icon-button
(click)="swapDisplayOrders(app, applications[i + 1])"
(click)="moveAppDown(app.id)"
>
<mat-icon svgIcon="ic_expand_more_black_24px"></mat-icon>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,37 +111,16 @@ export class TeamApplicationsSelectComponent implements OnInit {
});
}

/**
* Swaps the display orders of two teams in the application
* @param app1
* @param app2
*/
swapDisplayOrders(
app1: ApplicationInstance,
app2: ApplicationInstance
): void {
const a1 = <ApplicationInstanceForm>{
id: app1.id,
teamId: this.team.id,
applicationId: app1.applicationId,
displayOrder: app2.displayOrder,
};
const a2 = <ApplicationInstanceForm>{
id: app2.id,
teamId: this.team.id,
applicationId: app2.applicationId,
displayOrder: app1.displayOrder,
};
public moveAppUp(id: string) {
this.applicationService
.moveUpApplicationInstance(id)
.subscribe((x) => (this.applications = x));
}

public moveAppDown(id: string) {
this.applicationService
.updateApplicationInstance(app1.id, a1)
.subscribe(() => {
this.applicationService
.updateApplicationInstance(app2.id, a2)
.subscribe(() => {
this.refreshTeamApplications();
});
});
.moveDownApplicationInstance(id)
.subscribe((x) => (this.applications = x));
}

/**
Expand Down
114 changes: 114 additions & 0 deletions src/app/generated/player-api/api/application.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,120 @@ export class ApplicationService {
);
}

/**
* Moves an Application Instance down
* Moves an Application Instance down one spot in the list &lt;para /&gt; Accessible only to a SuperUser or a User on an Admin Team in the Application Instances\&#39;s Team\&#39;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<Array<ApplicationInstance>>;
public moveDownApplicationInstance(id: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json'}): Observable<HttpResponse<Array<ApplicationInstance>>>;
public moveDownApplicationInstance(id: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json'}): Observable<HttpEvent<Array<ApplicationInstance>>>;
public moveDownApplicationInstance(id: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json'}): Observable<any> {
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<Array<ApplicationInstance>>(`${this.configuration.basePath}/api/application-instances/${encodeURIComponent(String(id))}/move-down`,
null,
{
responseType: <any>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 &lt;para /&gt; Accessible only to a SuperUser or a User on an Admin Team in the Application Instances\&#39;s Team\&#39;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<Array<ApplicationInstance>>;
public moveUpApplicationInstance(id: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json'}): Observable<HttpResponse<Array<ApplicationInstance>>>;
public moveUpApplicationInstance(id: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json'}): Observable<HttpEvent<Array<ApplicationInstance>>>;
public moveUpApplicationInstance(id: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json'}): Observable<any> {
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<Array<ApplicationInstance>>(`${this.configuration.basePath}/api/application-instances/${encodeURIComponent(String(id))}/move-up`,
null,
{
responseType: <any>responseType,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}

/**
* Updates an Application
* Updates an Application with the attributes specified &lt;para /&gt; Accessible only to a SuperUser or a User on an Admin Team in the Application\&#39;s assigned View
Expand Down

0 comments on commit 8dfed22

Please sign in to comment.