Version 1.0
This commit is contained in:
commit
a4b0db9118
102 files changed
+16343
No files matched your search
@@ -0,0 +1,85 @@
|
||||
import axios from "axios";
|
||||
|
||||
let protocol = ('https:' == document.location.protocol ? 'https://' : 'http://');
|
||||
let hostname = window.location.hostname;
|
||||
if( window.location.hostname.includes("localhost" ) ){
|
||||
hostname += ':3000';
|
||||
}
|
||||
|
||||
const API_URL = `${protocol}${hostname}/api`;
|
||||
|
||||
export default class GameService{
|
||||
|
||||
checkExistingGame( gameId ){
|
||||
return axios.get(
|
||||
API_URL + `/game/check/${gameId}`,
|
||||
{
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
"Content-Type":"application/json",
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
setupNewHostGame(){
|
||||
return axios.post(
|
||||
API_URL + "/game/host",
|
||||
{},
|
||||
{
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
"Content-Type":"application/json",
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
setupJoinGame( code ){
|
||||
return axios.get(
|
||||
API_URL + "/game/join/setup/" + code,
|
||||
{
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
"Content-Type":"application/json",
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
getBoardToGame( gameId ){
|
||||
return axios.get(
|
||||
API_URL + `/game/${gameId}/board`,
|
||||
{
|
||||
withCredentials: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const GAME_STATES = Object.freeze({
|
||||
none: "gameUndefined",
|
||||
init: "initializing",
|
||||
joining: "joining",
|
||||
waiting: "waiting",
|
||||
inProgress: "inProgress",
|
||||
ended: "ended",
|
||||
});
|
||||
|
||||
export const QUESTION_TYPES = Object.freeze({
|
||||
textQuestion: "Simple question with text",
|
||||
multilineQuestion: "Question with multiline text",
|
||||
imageQuestion: "Question with text and image(s)",
|
||||
audioQuestion: "Question with text and audio",
|
||||
})
|
||||
|
||||
export const ANSWER_TYPES = Object.freeze({
|
||||
textAnswer: "Answer with text",
|
||||
imageAnswer: "Answer with text and image",
|
||||
})
|
||||
|
||||
export const ANSWER_INTERACTION = Object.freeze({
|
||||
buzzerInteraction: "Buzzer",
|
||||
freeTextInteraction: "Free Text",
|
||||
})
|
||||
@@ -0,0 +1,104 @@
|
||||
import axios from "axios";
|
||||
|
||||
let protocol = ('https:' == document.location.protocol ? 'https://' : 'http://');
|
||||
let hostname = window.location.hostname;
|
||||
if( window.location.hostname.includes("localhost" ) ){
|
||||
hostname += ':3000';
|
||||
}
|
||||
|
||||
const API_URL = `${protocol}${hostname}/api`;
|
||||
|
||||
export default class UserService{
|
||||
|
||||
signupUser(username, password){
|
||||
return axios.post(
|
||||
API_URL + "/user/signup",
|
||||
{
|
||||
username: username,
|
||||
password: password,
|
||||
},
|
||||
{
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
"Content-Type":"application/json",
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
loginUser(username, password){
|
||||
return axios.post(
|
||||
API_URL + "/user/login",
|
||||
{
|
||||
username: username,
|
||||
password: password,
|
||||
},
|
||||
{
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
"Content-Type":"application/json",
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
getUserFromSession(){
|
||||
return axios.get(
|
||||
API_URL + "/user",
|
||||
{
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
"Content-Type":"application/json",
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
logoutUser(){
|
||||
return axios.post(
|
||||
API_URL + "/user/logout",
|
||||
{},
|
||||
{
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
"Content-Type":"application/json",
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
getUserBoards(){
|
||||
return axios.get(
|
||||
API_URL + "/user/boards",
|
||||
{
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
"Content-Type":"application/json",
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
saveUserBoard( boardFormData ){
|
||||
return axios.post(
|
||||
API_URL + "/user/boards/save",
|
||||
boardFormData,
|
||||
{
|
||||
withCredentials: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
getBoardFromUser( boardId ){
|
||||
return axios.get(
|
||||
API_URL + "/user/boards/" + boardId,
|
||||
{
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
"Content-Type":"application/json",
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import BoardEntry from "@/models/BoardEntry";
|
||||
import Category from "@/models/Category";
|
||||
import Board from "@/models/Board";
|
||||
|
||||
export function boardResponseToBoardModel( boardResponse ){
|
||||
let categories = [];
|
||||
|
||||
for( let cResponseIndex in boardResponse.categories ){
|
||||
let categoriesResponse = boardResponse.categories[cResponseIndex];
|
||||
let boardEntriesTmp = [];
|
||||
for( let bEResponseIndex in categoriesResponse.boardEntries ){
|
||||
let boardEntriesResponse = categoriesResponse.boardEntries[bEResponseIndex];
|
||||
boardEntriesTmp.push(
|
||||
new BoardEntry(
|
||||
boardEntriesResponse.questions,
|
||||
boardEntriesResponse.answer,
|
||||
boardEntriesResponse.points,
|
||||
)
|
||||
);
|
||||
}
|
||||
categories.push(
|
||||
new Category(
|
||||
categoriesResponse.categoryName,
|
||||
categoriesResponse.categoryDescription,
|
||||
boardEntriesTmp,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return new Board( boardResponse._id, boardResponse.name, categories );
|
||||
}
|
||||
Reference in new issue
Block a user