Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
arsnova-click-v2-frontend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
12
Merge Requests
12
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
ARSnova
arsnova-click-v2-frontend
Commits
436a8951
Commit
436a8951
authored
Jun 15, 2018
by
Christopher Mark Fullarton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes a routing bug. Fixes log error from ssr
parent
eceab010
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
42 deletions
+39
-42
src/app/root.module.ts
src/app/root.module.ts
+3
-3
src/app/service/file-upload/file-upload.service.ts
src/app/service/file-upload/file-upload.service.ts
+36
-39
No files found.
src/app/root.module.ts
View file @
436a8951
...
...
@@ -50,15 +50,15 @@ export const appRoutes: Routes = [
},
{
path
:
'
quiz/manager
'
,
loadChildren
:
'
app/quiz/quiz-manager/quiz-manager.module#QuizManagerModule
'
,
},
{
path
:
'
quiz
'
,
loadChildren
:
'
app/quiz/quiz.module#QuizModule
'
,
},
{
path
:
'
quiz/flow
'
,
loadChildren
:
'
app/quiz/quiz-flow/quiz-flow.module#QuizFlowModule
'
,
data
:
{
preload
:
true
,
},
},
{
path
:
'
quiz
'
,
loadChildren
:
'
app/quiz/quiz.module#QuizModule
'
,
},
{
path
:
'
nicks
'
,
loadChildren
:
'
app/root/nickname-chooser/nickname-chooser.module#NicknameChooserModule
'
,
...
...
src/app/service/file-upload/file-upload.service.ts
View file @
436a8951
...
...
@@ -24,53 +24,50 @@ export class FileUploadService {
private
router
:
Router
,
private
activeQuestionGroupService
:
ActiveQuestionGroupService
,
private
quizApiService
:
QuizApiService
,
)
{
this
.
_renameFilesQueue
=
new
FormData
();
}
)
{}
public
uploadFile
(
formData
:
FormData
):
void
{
this
.
_renameFilesQueue
=
new
FormData
();
this
.
_duplicateQuizzes
=
[];
formData
.
append
(
'
privateKey
'
,
window
.
localStorage
.
getItem
(
'
config.private_key
'
));
this
.
quizApiService
.
postQuizUpload
(
formData
).
subscribe
(
(
data
:
IMessage
)
=>
{
if
(
data
.
payload
.
duplicateQuizzes
.
length
)
{
this
.
_duplicateQuizzes
=
data
.
payload
.
duplicateQuizzes
;
data
.
payload
.
duplicateQuizzes
.
forEach
((
duplicateQuiz
:
IDuplicateQuiz
)
=>
{
this
.
_renameFilesQueue
.
append
(
'
uploadFiles[]
'
,
<
File
>
formData
.
getAll
(
'
uploadFiles[]
'
).
filter
((
file
)
=>
{
return
(
<
File
>
file
).
name
===
duplicateQuiz
.
fileName
;
})[
0
],
duplicateQuiz
.
fileName
);
});
this
.
router
.
navigate
([
'
/quiz
'
,
'
rename
'
]);
}
else
{
const
allUploadedFiles
=
formData
.
getAll
(
'
uploadFiles[]
'
);
allUploadedFiles
.
forEach
((
formDataValue
,
index
)
=>
{
const
file
=
<
File
>
formDataValue
;
if
(
file
.
type
!==
'
application/json
'
)
{
return
;
}
const
reader
=
new
FileReader
();
reader
.
onload
=
()
=>
{
this
.
quizApiService
.
postQuizUpload
(
formData
).
subscribe
((
data
:
IMessage
)
=>
{
if
(
data
.
payload
.
duplicateQuizzes
.
length
)
{
this
.
_duplicateQuizzes
=
data
.
payload
.
duplicateQuizzes
;
data
.
payload
.
duplicateQuizzes
.
forEach
((
duplicateQuiz
:
IDuplicateQuiz
)
=>
{
this
.
_renameFilesQueue
.
append
(
'
uploadFiles[]
'
,
<
File
>
formData
.
getAll
(
'
uploadFiles[]
'
).
filter
((
file
)
=>
{
return
(
<
File
>
file
).
name
===
duplicateQuiz
.
fileName
;
})[
0
],
duplicateQuiz
.
fileName
);
});
this
.
router
.
navigate
([
'
/quiz
'
,
'
rename
'
]);
}
else
{
const
allUploadedFiles
=
formData
.
getAll
(
'
uploadFiles[]
'
);
allUploadedFiles
.
forEach
((
formDataValue
,
index
)
=>
{
const
file
=
<
File
>
formDataValue
;
if
(
file
.
type
!==
'
application/json
'
)
{
return
;
}
const
reader
=
new
FileReader
();
reader
.
onload
=
()
=>
{
const
parsedFile
=
JSON
.
parse
(
reader
.
result
);
this
.
activeQuestionGroupService
.
activeQuestionGroup
=
questionGroupReflection
[
parsedFile
.
TYPE
](
parsedFile
);
this
.
activeQuestionGroupService
.
persist
();
const
parsedFile
=
JSON
.
parse
(
reader
.
result
);
this
.
activeQuestionGroupService
.
activeQuestionGroup
=
questionGroupReflection
[
parsedFile
.
TYPE
](
parsedFile
);
this
.
activeQuestionGroupService
.
persist
();
window
.
localStorage
.
removeItem
(
file
.
name
);
const
questionList
=
JSON
.
parse
(
window
.
localStorage
.
getItem
(
'
config.owned_quizzes
'
))
||
[];
questionList
.
splice
(
questionList
.
indexOf
(
file
.
name
),
1
);
window
.
localStorage
.
setItem
(
'
config.owned_quizzes
'
,
JSON
.
stringify
(
questionList
));
window
.
localStorage
.
removeItem
(
file
.
name
);
const
questionList
=
JSON
.
parse
(
window
.
localStorage
.
getItem
(
'
config.owned_quizzes
'
))
||
[];
questionList
.
splice
(
questionList
.
indexOf
(
file
.
name
),
1
);
window
.
localStorage
.
setItem
(
'
config.owned_quizzes
'
,
JSON
.
stringify
(
questionList
));
this
.
router
.
navigate
([
'
/
'
]);
};
reader
.
readAsText
(
file
);
});
}
},
error
=>
{
console
.
log
(
error
);
},
);
this
.
router
.
navigate
([
'
/
'
]);
};
reader
.
readAsText
(
file
);
});
}
},
error
=>
{
console
.
log
(
error
);
});
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment