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
Wendys Racing Horses
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
tu-wien
Wendys Racing Horses
Commits
f9a8d501
Commit
f9a8d501
authored
Mar 18, 2020
by
Ivaylo Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
US01, US02: Add missing files
parent
98d55532
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
129 additions
and
0 deletions
+129
-0
backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/enums/ERace.java
.../at/ac/tuwien/sepm/assignment/individual/enums/ERace.java
+8
-0
frontend/wendys-friends/src/app/component/add-horse/add-horse.component.html
...ends/src/app/component/add-horse/add-horse.component.html
+56
-0
frontend/wendys-friends/src/app/component/add-horse/add-horse.component.scss
...ends/src/app/component/add-horse/add-horse.component.scss
+0
-0
frontend/wendys-friends/src/app/component/add-horse/add-horse.component.ts
...riends/src/app/component/add-horse/add-horse.component.ts
+65
-0
No files found.
backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/enums/ERace.java
0 → 100644
View file @
f9a8d501
package
at.ac.tuwien.sepm.assignment.individual.enums
;
public
enum
ERace
{
ARABIAN
,
MORGAN
,
PAINT
,
APPALOOSA
}
frontend/wendys-friends/src/app/component/add-horse/add-horse.component.html
0 → 100644
View file @
f9a8d501
<div
*ngIf=
"error"
class=
"alert alert-danger alert-dismissible fade show"
role=
"alert"
>
<strong>
Error!
</strong>
{{ errorMessage }}
<button
type=
"button"
(click)=
"vanishError()"
class=
"close"
data-dismiss=
"alert"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
</div>
<div
*ngIf=
"success"
class=
"alert alert-success alert-dismissible fade show"
role=
"alert"
>
<p><strong>
Success!
</strong>
Horse {{ success }} has been successfully added.
</p>
<button
type=
"button"
(click)=
"vanishAlert()"
class=
"close"
data-dismiss=
"alert"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
</div>
<div
class=
"container"
>
<h1>
Add new horse
</h1>
<form
(ngSubmit)=
"addHorse()"
#horseForm
="
ngForm
"
>
<div
class=
"form-group"
>
<label
for=
"name"
>
Name
</label>
<input
type=
"text"
class=
"form-control"
name=
"name"
[(ngModel)]=
"horse.name"
required
>
</div>
<div
class=
"form-group"
>
<label
for=
"description"
>
Description
</label>
<textarea
class=
"form-control"
name=
"description"
[(ngModel)]=
"horse.description"
value=
""
></textarea>
</div>
<div
class=
"form-group"
>
<label
for=
"score"
>
Score
</label>
<select
class=
"form-control"
name=
"score"
[(ngModel)]=
"horse.score"
required
>
<option
value=
"1"
>
1
</option>
<option
value=
"2"
>
2
</option>
<option
value=
"3"
>
3
</option>
<option
value=
"4"
>
4
</option>
<option
value=
"5"
>
5
</option>
</select>
</div>
<div
class=
"form-group"
>
<label
for=
"race"
>
Race
</label>
<select
class=
"form-control"
name=
"race"
[(ngModel)]=
"horse.race"
required
>
<option
value=
"ARABIAN"
>
Arabian
</option>
<option
value=
"MORGAN"
>
Morgan
</option>
<option
value=
"PAINT"
>
Paint
</option>
<option
value=
"APPALOOSA"
>
Appaloosa
</option>
</select>
</div>
<div
class=
"form-group"
>
<label
for=
"birthday"
>
Birthday
</label>
<input
type=
"date"
class=
"form-control"
name=
"birthday"
[(ngModel)]=
"horse.birthday"
required
pattern=
"\d{4}-\d{2}-\d{2}"
>
</div>
<button
type=
"submit"
class=
"btn btn-success"
[disabled]=
"!horseForm.form.valid"
(submit)=
"addHorse()"
>
Submit
</button>
</form>
</div>
\ No newline at end of file
frontend/wendys-friends/src/app/component/add-horse/add-horse.component.scss
0 → 100644
View file @
f9a8d501
frontend/wendys-friends/src/app/component/add-horse/add-horse.component.ts
0 → 100644
View file @
f9a8d501
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
Horse
}
from
'
../../dto/horse
'
;
import
{
HorseService
}
from
'
../../service/horse.service
'
;
@
Component
({
selector
:
'
app-add-horse
'
,
templateUrl
:
'
./add-horse.component.html
'
,
styleUrls
:
[
'
./add-horse.component.scss
'
]
})
export
class
AddHorseComponent
implements
OnInit
{
error
=
false
;
success
:
string
;
errorMessage
=
''
;
horse
:
Horse
=
new
Horse
(
null
,
null
,
null
,
null
,
null
,
null
,
null
);
constructor
(
private
horseService
:
HorseService
)
{
}
ngOnInit
():
void
{}
/**
* Will be called on a click on the success alert close button
*/
public
vanishAlert
()
{
this
.
success
=
null
;
}
/**
* Will be called on a click on the error alert close button
*/
public
vanishError
()
{
this
.
errorMessage
=
null
;
}
/**
* Creates a new horse and loads it
* @param horse
*/
public
addHorse
()
{
console
.
log
(
"
POST horse to API
"
)
console
.
log
(
this
.
horse
);
// TODO: Make it possible for the horse to be added with an owner
this
.
horseService
.
addHorse
(
this
.
horse
).
subscribe
(
(
result
:
Horse
)
=>
{
this
.
success
=
result
.
name
;
},
error
=>
{
this
.
defaultServiceErrorHandling
(
error
);
}
);
}
private
defaultServiceErrorHandling
(
error
:
any
)
{
console
.
log
(
error
);
this
.
error
=
true
;
if
(
error
.
status
===
0
)
{
// If status is 0, the backend is probably down
this
.
errorMessage
=
'
The backend seems not to be reachable
'
;
}
else
if
(
error
.
error
.
message
===
'
No message available
'
)
{
// If no detailed error message is provided, fall back to the simple error name
this
.
errorMessage
=
error
.
error
.
error
;
}
else
{
this
.
errorMessage
=
error
.
error
.
message
;
}
}
}
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