-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separated upload types. Implemented FGC API.
- Loading branch information
1 parent
b535d8c
commit e814720
Showing
12 changed files
with
201 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import {Event, FGCProvider, Match, Team, TOAConfig, TOAProvider} from "@the-orange-alliance/lib-ems"; | ||
import TOAUploadManager from "./TOAUploadManager"; | ||
import FGCUploadManager from "./FGCUploadManager"; | ||
|
||
class UploadManager { | ||
public static TOA: number = 0; | ||
public static FGC: number = 1; | ||
|
||
private static _instance: UploadManager; | ||
|
||
private _type: number; | ||
|
||
public static getInstance(): UploadManager { | ||
if (typeof UploadManager._instance === "undefined") { | ||
UploadManager._instance = new UploadManager(); | ||
} | ||
return UploadManager._instance; | ||
} | ||
|
||
private constructor() {} | ||
|
||
public initialize(type: number, toaConfig: TOAConfig): void { | ||
this._type = type; | ||
if (this._type === UploadManager.TOA) { | ||
TOAProvider.initialize(toaConfig); | ||
} | ||
if (this._type === UploadManager.FGC) { | ||
FGCProvider.initialize("127.0.0.1", 8088); // DEBUG | ||
} | ||
} | ||
|
||
public getEvent(eventKey: string): Promise<Event> { | ||
if (this._type === UploadManager.TOA) { | ||
return TOAUploadManager.getEvent(eventKey); | ||
} else if (this._type === UploadManager.FGC) { | ||
return FGCUploadManager.getEvent(eventKey); | ||
} else { | ||
return new Promise<Event>((resolve, reject) => reject()); | ||
} | ||
} | ||
|
||
public getTeams(eventKey: string): Promise<Team[]> { | ||
if (this._type === UploadManager.TOA) { | ||
return TOAUploadManager.getTeams(eventKey); | ||
} else if (this._type === UploadManager.FGC) { | ||
return FGCUploadManager.getTeams(eventKey); | ||
} else { | ||
return new Promise<Team[]>((resolve, reject) => reject()); | ||
} | ||
} | ||
|
||
public postEventParticipants(eventKey: string, teams: Team[]): Promise<any> { | ||
if (this._type === UploadManager.TOA) { | ||
return TOAUploadManager.postEventParticipants(eventKey, teams); | ||
} else if (this._type === UploadManager.FGC) { | ||
return FGCUploadManager.postEventParticipants(eventKey, teams); | ||
} else { | ||
return new Promise<any>((resolve, reject) => reject()); | ||
} | ||
} | ||
|
||
public postMatchSchedule(eventKey: string, matches: Match[]): Promise<any> { | ||
if (this._type === UploadManager.TOA) { | ||
return TOAUploadManager.postMatchSchedule(eventKey, matches); | ||
} else if (this._type === UploadManager.FGC) { | ||
return FGCUploadManager.postMatchSchedule(eventKey, matches); | ||
} else { | ||
return new Promise<any>((resolve, reject) => reject()); | ||
} | ||
} | ||
|
||
public postMatchResults(eventKey: string, match: Match): Promise<any> { | ||
if (this._type === UploadManager.TOA) { | ||
return TOAUploadManager.postMatchResults(eventKey, match); | ||
} else if (this._type === UploadManager.FGC) { | ||
return FGCUploadManager.postMatchResults(eventKey, match); | ||
} else { | ||
return new Promise<any>((resolve, reject) => reject()); | ||
} | ||
} | ||
|
||
} | ||
|
||
export const TOA = UploadManager.TOA; | ||
export const FGC = UploadManager.FGC; | ||
|
||
export default UploadManager.getInstance(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.