Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
e3a275ffdc | |||
|
9592e2cd93 | ||
|
772a426098 | ||
|
e9e8016249 | ||
|
fb5584615c |
237
src/main/java/com/warhammer/domain/Dataslate.java
Normal file
237
src/main/java/com/warhammer/domain/Dataslate.java
Normal file
@ -0,0 +1,237 @@
|
||||
package com.warhammer.domain;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A dataslate.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "dataslate")
|
||||
public class Dataslate implements Serializable {
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMovement() {
|
||||
return movement;
|
||||
}
|
||||
|
||||
public void setMovement(String movement) {
|
||||
this.movement = movement;
|
||||
}
|
||||
|
||||
public String getWeaponSkill() {
|
||||
return weaponSkill;
|
||||
}
|
||||
|
||||
public void setWeaponSkill(String weaponSkill) {
|
||||
this.weaponSkill = weaponSkill;
|
||||
}
|
||||
|
||||
public String getBallisticSkill() {
|
||||
return ballisticSkill;
|
||||
}
|
||||
|
||||
public void setBallisticSkill(String ballisticSkill) {
|
||||
this.ballisticSkill = ballisticSkill;
|
||||
}
|
||||
|
||||
public Long getStrength() {
|
||||
return strength;
|
||||
}
|
||||
|
||||
public void setStrength(Long strength) {
|
||||
this.strength = strength;
|
||||
}
|
||||
|
||||
public String getToughness() {
|
||||
return toughness;
|
||||
}
|
||||
|
||||
public void setToughness(String toughness) {
|
||||
this.toughness = toughness;
|
||||
}
|
||||
|
||||
public String getWounds() {
|
||||
return wounds;
|
||||
}
|
||||
|
||||
public void setWounds(String wounds) {
|
||||
this.wounds = wounds;
|
||||
}
|
||||
|
||||
public String getAttacks() {
|
||||
return attacks;
|
||||
}
|
||||
|
||||
public void setAttacks(String attacks) {
|
||||
this.attacks = attacks;
|
||||
}
|
||||
|
||||
public Integer getLeadership() {
|
||||
return leadership;
|
||||
}
|
||||
|
||||
public void setLeadership(Integer leadership) {
|
||||
this.leadership = leadership;
|
||||
}
|
||||
|
||||
public Integer getSave() {
|
||||
return save;
|
||||
}
|
||||
|
||||
public void setSave(Integer save) {
|
||||
this.save = save;
|
||||
}
|
||||
|
||||
public Integer getInvulnerable() {
|
||||
return invulnerable;
|
||||
}
|
||||
|
||||
public void setInvulnerable(Integer invulnerable) {
|
||||
this.invulnerable = invulnerable;
|
||||
}
|
||||
|
||||
public Integer getFeelNoPain() {
|
||||
return feelNoPain;
|
||||
}
|
||||
|
||||
public void setFeelNoPain(Integer feelNoPain) {
|
||||
this.feelNoPain = feelNoPain;
|
||||
}
|
||||
|
||||
public String getWargearOptions() {
|
||||
return wargearOptions;
|
||||
}
|
||||
|
||||
public void setWargearOptions(String wargearOptions) {
|
||||
this.wargearOptions = wargearOptions;
|
||||
}
|
||||
|
||||
public String getPsyker() {
|
||||
return psyker;
|
||||
}
|
||||
|
||||
public void setPsyker(String psyker) {
|
||||
this.psyker = psyker;
|
||||
}
|
||||
|
||||
public Set<Weapon> getWeapons() {
|
||||
return weapons;
|
||||
}
|
||||
|
||||
public void setWeapons(Set<Weapon> weapons) {
|
||||
this.weapons = weapons;
|
||||
}
|
||||
|
||||
public Set<UnitKeyword> getKeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public void setKeywords(Set<UnitKeyword> keywords) {
|
||||
this.keywords = keywords;
|
||||
}
|
||||
|
||||
public UnitArmy getUnitArmy() {
|
||||
return unitArmy;
|
||||
}
|
||||
|
||||
public void setUnitArmy(UnitArmy unitArmy) {
|
||||
this.unitArmy = unitArmy;
|
||||
}
|
||||
|
||||
public User getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(User owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public String getOwnerLogin() {
|
||||
return ownerLogin;
|
||||
}
|
||||
|
||||
public void setOwnerLogin(String ownerLogin) {
|
||||
this.ownerLogin = ownerLogin;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
|
||||
@Column(name = "movement")
|
||||
private String movement;
|
||||
|
||||
@Column(name = "weapon_skill")
|
||||
private String weaponSkill;
|
||||
|
||||
@Column(name = "ballistic_skill")
|
||||
private String ballisticSkill;
|
||||
|
||||
@Column(name = "strength")
|
||||
private Long strength;
|
||||
|
||||
@Column(name = "toughness")
|
||||
private String toughness;
|
||||
|
||||
@Column(name = "wounds")
|
||||
private String wounds;
|
||||
|
||||
@Column(name = "attacks")
|
||||
private String attacks;
|
||||
|
||||
@Column(name = "leadership")
|
||||
private Integer leadership;
|
||||
|
||||
@Column(name = "save")
|
||||
private Integer save;
|
||||
|
||||
@Column(name = "invulnerable")
|
||||
private Integer invulnerable;
|
||||
|
||||
@Column(name = "feel_no_pain")
|
||||
private Integer feelNoPain;
|
||||
|
||||
@Lob
|
||||
@Column(name = "wargear_options")
|
||||
private String wargearOptions;
|
||||
|
||||
@Lob
|
||||
@Column(name = "psyker")
|
||||
private String psyker;
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(
|
||||
name = "dataslate_weapon",
|
||||
joinColumns = { @JoinColumn(name = "dataslate_id") },
|
||||
inverseJoinColumns = { @JoinColumn(name = "weapon_id") }
|
||||
)
|
||||
private Set<Weapon> weapons = new HashSet<>();
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(
|
||||
name = "dataslate_keyword",
|
||||
joinColumns = { @JoinColumn(name = "dataslate_id") },
|
||||
inverseJoinColumns = { @JoinColumn(name = "keyword_id") }
|
||||
)
|
||||
private Set<UnitKeyword> keywords = new HashSet<>();
|
||||
|
||||
@ManyToOne
|
||||
private UnitArmy unitArmy;
|
||||
|
||||
@ManyToOne
|
||||
private User owner;
|
||||
|
||||
private String ownerLogin;
|
||||
}
|
59
src/main/java/com/warhammer/domain/UnitKeyword.java
Normal file
59
src/main/java/com/warhammer/domain/UnitKeyword.java
Normal file
@ -0,0 +1,59 @@
|
||||
package com.warhammer.domain;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "unit_keyword")
|
||||
public class UnitKeyword implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "keyword")
|
||||
private String keyword;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "is_faction")
|
||||
private boolean isFaction;
|
||||
|
||||
@ManyToOne
|
||||
private User owner;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
public boolean isFaction() {
|
||||
return isFaction;
|
||||
}
|
||||
|
||||
public void setFaction(boolean faction) {
|
||||
isFaction = faction;
|
||||
}
|
||||
|
||||
public User getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(User owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
}
|
119
src/main/java/com/warhammer/domain/Weapon.java
Normal file
119
src/main/java/com/warhammer/domain/Weapon.java
Normal file
@ -0,0 +1,119 @@
|
||||
package com.warhammer.domain;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "weapon")
|
||||
public class Weapon implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "weapon")
|
||||
private String weapon;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "range")
|
||||
private String range;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "type")
|
||||
private String type;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "strength")
|
||||
private String strength;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "armor_penetration")
|
||||
private String armorPenetration;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "damage")
|
||||
private String damage;
|
||||
|
||||
@Lob
|
||||
@Column(name = "abilities")
|
||||
private String abilities;
|
||||
|
||||
@ManyToOne
|
||||
private User owner;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getWeapon() {
|
||||
return weapon;
|
||||
}
|
||||
|
||||
public void setWeapon(String weapon) {
|
||||
this.weapon = weapon;
|
||||
}
|
||||
|
||||
public String getRange() {
|
||||
return range;
|
||||
}
|
||||
|
||||
public void setRange(String range) {
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getStrength() {
|
||||
return strength;
|
||||
}
|
||||
|
||||
public void setStrength(String strength) {
|
||||
this.strength = strength;
|
||||
}
|
||||
|
||||
public String getArmorPenetration() {
|
||||
return armorPenetration;
|
||||
}
|
||||
|
||||
public void setArmorPenetration(String armorPenetration) {
|
||||
this.armorPenetration = armorPenetration;
|
||||
}
|
||||
|
||||
public String getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public void setDamage(String damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public String getAbilities() {
|
||||
return abilities;
|
||||
}
|
||||
|
||||
public void setAbilities(String abilities) {
|
||||
this.abilities = abilities;
|
||||
}
|
||||
|
||||
public User getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(User owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.warhammer.repository;
|
||||
|
||||
import com.warhammer.domain.Dataslate;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Spring Data repository for Dataslate entity.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Repository
|
||||
public interface DataslateRepository extends JpaRepository<Dataslate, Long> {
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.warhammer.repository;
|
||||
|
||||
import com.warhammer.domain.UnitKeyword;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Spring Data repository for UnitKeyword entity.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Repository
|
||||
public interface UnitKeywordRepository extends JpaRepository<UnitKeyword, Long> {
|
||||
}
|
13
src/main/java/com/warhammer/repository/WeaponRepository.java
Normal file
13
src/main/java/com/warhammer/repository/WeaponRepository.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.warhammer.repository;
|
||||
|
||||
import com.warhammer.domain.Weapon;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Spring Data repository for Weapon entity.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Repository
|
||||
public interface WeaponRepository extends JpaRepository<Weapon, Long> {
|
||||
}
|
46
src/main/java/com/warhammer/service/DataslateService.java
Normal file
46
src/main/java/com/warhammer/service/DataslateService.java
Normal file
@ -0,0 +1,46 @@
|
||||
package com.warhammer.service;
|
||||
|
||||
import com.warhammer.domain.Dataslate;
|
||||
import com.warhammer.service.dto.DataslateDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface DataslateService {
|
||||
|
||||
/**
|
||||
* Save a dataslate
|
||||
*
|
||||
* @param dataslateDTO the entity to save.
|
||||
* @return the persisted entity
|
||||
*/
|
||||
DataslateDTO save(DataslateDTO dataslateDTO);
|
||||
|
||||
/**
|
||||
* Get all the Dataslates
|
||||
*
|
||||
* @return the list of the entities
|
||||
*/
|
||||
List<DataslateDTO> findAll();
|
||||
|
||||
/**
|
||||
* Get all the Dataslates for a user
|
||||
*
|
||||
* @param ownerLogin the owner to search for the dataslates of
|
||||
* @return List of Dataslates owned by Owner
|
||||
*/
|
||||
List<Dataslate> findAllByOwner(Optional <String> ownerLogin);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Optional<DataslateDTO> findOne(Long id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void delete(Long id);
|
||||
}
|
47
src/main/java/com/warhammer/service/UnitKeywordService.java
Normal file
47
src/main/java/com/warhammer/service/UnitKeywordService.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.warhammer.service;
|
||||
|
||||
import com.warhammer.service.dto.UnitKeywordDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface UnitKeywordService {
|
||||
|
||||
/**
|
||||
* Save a UnitKeyword
|
||||
*
|
||||
* @param unitKeywordDTO the entity to save.
|
||||
* @return the persisted entity
|
||||
*/
|
||||
UnitKeywordDTO save(UnitKeywordDTO unitKeywordDTO);
|
||||
|
||||
/**
|
||||
* Get all keywords
|
||||
*
|
||||
* @return the list of the keywords
|
||||
*/
|
||||
List<UnitKeywordDTO> findAll();
|
||||
|
||||
/**
|
||||
* Get all the keywords for a user
|
||||
*
|
||||
* @param ownerLogin the owner to search for the keywords of
|
||||
* @return List of keywords owned by Owner
|
||||
*/
|
||||
List<UnitKeywordDTO> findAllByOwner(Optional <String> ownerLogin);
|
||||
|
||||
/**
|
||||
* Get a single keyword
|
||||
*
|
||||
* @param id of the keyword
|
||||
* @return the entity
|
||||
*/
|
||||
Optional<UnitKeywordDTO> findOne(Long id);
|
||||
|
||||
/**
|
||||
* Delete a single keyword
|
||||
*
|
||||
* @param id of the entity to delete
|
||||
*/
|
||||
void delete(Long id);
|
||||
}
|
47
src/main/java/com/warhammer/service/WeaponService.java
Normal file
47
src/main/java/com/warhammer/service/WeaponService.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.warhammer.service;
|
||||
|
||||
import com.warhammer.service.dto.WeaponDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface WeaponService {
|
||||
|
||||
/**
|
||||
* Save a weapon
|
||||
*
|
||||
* @param weaponDTO
|
||||
* @return the persisted entity
|
||||
*/
|
||||
WeaponDTO save(WeaponDTO weaponDTO);
|
||||
|
||||
/**
|
||||
* Get all weapons
|
||||
*
|
||||
* @return the list of the entities
|
||||
*/
|
||||
List<WeaponDTO> findAll();
|
||||
|
||||
/**
|
||||
* Get all Weapons for a user
|
||||
*
|
||||
* @param ownerLogin the owner to search for the weapons of
|
||||
* @return List of weapons owned by Owner
|
||||
*/
|
||||
List<WeaponDTO> findAllByOwner(Optional <String> ownerLogin);
|
||||
|
||||
/**
|
||||
* Find a single weapon
|
||||
*
|
||||
* @param id the id of the entity
|
||||
* @return the entity
|
||||
*/
|
||||
Optional<WeaponDTO> findOne(Long id);
|
||||
|
||||
/**
|
||||
* Deletes a weapon
|
||||
*
|
||||
* @param id of the weapon
|
||||
*/
|
||||
void delete(Long id);
|
||||
}
|
233
src/main/java/com/warhammer/service/dto/DataslateDTO.java
Normal file
233
src/main/java/com/warhammer/service/dto/DataslateDTO.java
Normal file
@ -0,0 +1,233 @@
|
||||
package com.warhammer.service.dto;
|
||||
|
||||
import com.warhammer.domain.UnitArmy;
|
||||
import com.warhammer.domain.UnitKeyword;
|
||||
import com.warhammer.domain.User;
|
||||
import com.warhammer.domain.Weapon;
|
||||
|
||||
import javax.persistence.Lob;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* A DTO for the {@link com.warhammer.domain.Dataslate} entity.
|
||||
*/
|
||||
public class DataslateDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String movement;
|
||||
|
||||
private String weapon_skill;
|
||||
|
||||
private String ballistic_skill;
|
||||
|
||||
private String strength;
|
||||
|
||||
private String toughness;
|
||||
|
||||
private String wounds;
|
||||
|
||||
private String attacks;
|
||||
|
||||
private Integer leadership;
|
||||
|
||||
private Integer save;
|
||||
|
||||
private Integer invulnerable;
|
||||
|
||||
private Integer feelNoPain;
|
||||
|
||||
@Lob
|
||||
private String wargearOptions;
|
||||
|
||||
@Lob
|
||||
private String psyker;
|
||||
|
||||
private HashSet<Weapon> weapons;
|
||||
|
||||
private HashSet<UnitKeyword> keywords;
|
||||
|
||||
private UnitArmy unitArmy;
|
||||
|
||||
private User owner;
|
||||
|
||||
public String ownerLogin;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMovement() {
|
||||
return movement;
|
||||
}
|
||||
|
||||
public void setMovement(String movement) {
|
||||
this.movement = movement;
|
||||
}
|
||||
|
||||
public String getWeapon_skill() {
|
||||
return weapon_skill;
|
||||
}
|
||||
|
||||
public void setWeapon_skill(String weapon_skill) {
|
||||
this.weapon_skill = weapon_skill;
|
||||
}
|
||||
|
||||
public String getBallistic_skill() {
|
||||
return ballistic_skill;
|
||||
}
|
||||
|
||||
public void setBallistic_skill(String ballistic_skill) {
|
||||
this.ballistic_skill = ballistic_skill;
|
||||
}
|
||||
|
||||
public String getStrength() {
|
||||
return strength;
|
||||
}
|
||||
|
||||
public void setStrength(String strength) {
|
||||
this.strength = strength;
|
||||
}
|
||||
|
||||
public String getToughness() {
|
||||
return toughness;
|
||||
}
|
||||
|
||||
public void setToughness(String toughness) {
|
||||
this.toughness = toughness;
|
||||
}
|
||||
|
||||
public String getWounds() {
|
||||
return wounds;
|
||||
}
|
||||
|
||||
public void setWounds(String wounds) {
|
||||
this.wounds = wounds;
|
||||
}
|
||||
|
||||
public String getAttacks() {
|
||||
return attacks;
|
||||
}
|
||||
|
||||
public void setAttacks(String attacks) {
|
||||
this.attacks = attacks;
|
||||
}
|
||||
|
||||
public Integer getLeadership() {
|
||||
return leadership;
|
||||
}
|
||||
|
||||
public void setLeadership(Integer leadership) {
|
||||
this.leadership = leadership;
|
||||
}
|
||||
|
||||
public Integer getSave() {
|
||||
return save;
|
||||
}
|
||||
|
||||
public void setSave(Integer save) {
|
||||
this.save = save;
|
||||
}
|
||||
|
||||
public Integer getInvulnerable() {
|
||||
return invulnerable;
|
||||
}
|
||||
|
||||
public void setInvulnerable(Integer invulnerable) {
|
||||
this.invulnerable = invulnerable;
|
||||
}
|
||||
|
||||
public Integer getFeelNoPain() {
|
||||
return feelNoPain;
|
||||
}
|
||||
|
||||
public void setFeelNoPain(Integer feelNoPain) {
|
||||
this.feelNoPain = feelNoPain;
|
||||
}
|
||||
|
||||
public String getWargearOptions() {
|
||||
return wargearOptions;
|
||||
}
|
||||
|
||||
public void setWargearOptions(String wargearOptions) {
|
||||
this.wargearOptions = wargearOptions;
|
||||
}
|
||||
|
||||
public String getPsyker() {
|
||||
return psyker;
|
||||
}
|
||||
|
||||
public void setPsyker(String psyker) {
|
||||
this.psyker = psyker;
|
||||
}
|
||||
|
||||
public HashSet<Weapon> getWeapons() {
|
||||
return weapons;
|
||||
}
|
||||
|
||||
public void setWeapons(HashSet<Weapon> weapons) {
|
||||
this.weapons = weapons;
|
||||
}
|
||||
|
||||
public HashSet<UnitKeyword> getKeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public void setKeywords(HashSet<UnitKeyword> keywords) {
|
||||
this.keywords = keywords;
|
||||
}
|
||||
|
||||
public UnitArmy getUnitArmy() {
|
||||
return unitArmy;
|
||||
}
|
||||
|
||||
public void setUnitArmy(UnitArmy unitArmy) {
|
||||
this.unitArmy = unitArmy;
|
||||
}
|
||||
|
||||
public User getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(User owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public String getOwnerLogin() {
|
||||
return ownerLogin;
|
||||
}
|
||||
|
||||
public void setOwnerLogin(String ownerLogin) {
|
||||
this.ownerLogin = ownerLogin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DataslateDTO{" +
|
||||
"id=" + getId() +
|
||||
", movement='" + getMovement() + "'" +
|
||||
", weaponSkill='" + getWeapon_skill() + "'" +
|
||||
", ballisticSkill='" + getBallistic_skill() + "'" +
|
||||
", strength='" + getStrength() + "'" +
|
||||
", toughness='" + getToughness() + "'" +
|
||||
", wounds='" + getWounds() + "'" +
|
||||
", attacks='" + getAttacks() + "'" +
|
||||
", leadership='" + getLeadership() + "'" +
|
||||
", save=" + getSave() +
|
||||
", invulnerable= " + getInvulnerable() +
|
||||
", feelNoPain=" + getFeelNoPain() +
|
||||
", wargearOptions='" + getWargearOptions() + "'" +
|
||||
", psyker='" + getPsyker() + "'" +
|
||||
", weapons='" + getWeapons() + "'" +
|
||||
", keywords='" + getKeywords() + "'" +
|
||||
", unit=" + getUnitArmy() +
|
||||
", owner=" + getOwner() +
|
||||
"}";
|
||||
}
|
||||
|
||||
}
|
56
src/main/java/com/warhammer/service/dto/UnitKeywordDTO.java
Normal file
56
src/main/java/com/warhammer/service/dto/UnitKeywordDTO.java
Normal file
@ -0,0 +1,56 @@
|
||||
package com.warhammer.service.dto;
|
||||
|
||||
import com.warhammer.domain.User;
|
||||
|
||||
public class UnitKeywordDTO {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String keyword;
|
||||
|
||||
private boolean isFaction;
|
||||
|
||||
private User owner;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
public boolean isFaction() {
|
||||
return isFaction;
|
||||
}
|
||||
|
||||
public void setFaction(boolean faction) {
|
||||
isFaction = faction;
|
||||
}
|
||||
|
||||
public User getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(User owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UnitKeywordDTO{" +
|
||||
"id=" + id +
|
||||
", keyword='" + keyword + '\'' +
|
||||
", isFaction=" + isFaction +
|
||||
", owner=" + owner +
|
||||
'}';
|
||||
}
|
||||
}
|
113
src/main/java/com/warhammer/service/dto/WeaponDTO.java
Normal file
113
src/main/java/com/warhammer/service/dto/WeaponDTO.java
Normal file
@ -0,0 +1,113 @@
|
||||
package com.warhammer.service.dto;
|
||||
|
||||
import com.warhammer.domain.User;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class WeaponDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String weapon;
|
||||
|
||||
private String range;
|
||||
|
||||
private String type;
|
||||
|
||||
private String strength;
|
||||
|
||||
private String armorPenetration;
|
||||
|
||||
private String damage;
|
||||
|
||||
private String abilities;
|
||||
|
||||
private User owner;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getWeapon() {
|
||||
return weapon;
|
||||
}
|
||||
|
||||
public void setWeapon(String weapon) {
|
||||
this.weapon = weapon;
|
||||
}
|
||||
|
||||
public String getRange() {
|
||||
return range;
|
||||
}
|
||||
|
||||
public void setRange(String range) {
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getStrength() {
|
||||
return strength;
|
||||
}
|
||||
|
||||
public void setStrength(String strength) {
|
||||
this.strength = strength;
|
||||
}
|
||||
|
||||
public String getArmorPenetration() {
|
||||
return armorPenetration;
|
||||
}
|
||||
|
||||
public void setArmorPenetration(String armorPenetration) {
|
||||
this.armorPenetration = armorPenetration;
|
||||
}
|
||||
|
||||
public String getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public void setDamage(String damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public String getAbilities() {
|
||||
return abilities;
|
||||
}
|
||||
|
||||
public void setAbilities(String abilities) {
|
||||
this.abilities = abilities;
|
||||
}
|
||||
|
||||
public User getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(User owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WeaponDTO{" +
|
||||
"id=" + id +
|
||||
", weapon='" + weapon + '\'' +
|
||||
", range='" + range + '\'' +
|
||||
", type='" + type + '\'' +
|
||||
", strength='" + strength + '\'' +
|
||||
", armorPenetration='" + armorPenetration + '\'' +
|
||||
", damage='" + damage + '\'' +
|
||||
", abilities='" + abilities + '\'' +
|
||||
", owner=" + owner +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.warhammer.service.impl;
|
||||
|
||||
import com.warhammer.domain.Dataslate;
|
||||
import com.warhammer.repository.DataslateRepository;
|
||||
import com.warhammer.service.DataslateService;
|
||||
import com.warhammer.service.dto.DataslateDTO;
|
||||
import com.warhammer.service.mapper.DataslateMapper;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class DataslateServiceImpl implements DataslateService {
|
||||
private final Logger log = LoggerFactory.getLogger(DataslateServiceImpl.class);
|
||||
|
||||
private final DataslateRepository dataslateRepository;
|
||||
|
||||
private final DataslateMapper dataslateMapper;
|
||||
|
||||
public DataslateServiceImpl(DataslateRepository dataslateRepository, DataslateMapper dataslateMapper) {
|
||||
this.dataslateRepository = dataslateRepository;
|
||||
this.dataslateMapper = dataslateMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataslateDTO save(DataslateDTO dataslateDTO) {
|
||||
log.debug("Request to save Dataslate : {}", dataslateDTO);
|
||||
Dataslate dataslate = dataslateMapper.toEntity(dataslateDTO);
|
||||
dataslate = dataslateRepository.save(dataslate);
|
||||
return dataslateMapper.toDto(dataslate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<DataslateDTO> findAll() {
|
||||
log.debug("Request to get all Dataslates");
|
||||
return dataslateRepository.findAll().stream()
|
||||
.map(dataslateMapper::toDto)
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataslateDTO> findAllByOwner(Optional ownerLoginOptional) {
|
||||
log.debug("Request to get all Dataslates by Owner : " + ownerLoginOptional.orElse(null));
|
||||
return dataslateRepository.findAll().stream()
|
||||
.map(dataslateMapper::toDto)
|
||||
.filter(dataslateDTO -> dataslateDTO.getOwnerLogin().equals(ownerLoginOptional.orElse(null)))
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Optional<DataslateDTO> findOne(Long id) {
|
||||
log.debug("Request to get Dataslate : {}", id);
|
||||
return dataslateRepository.findById(id)
|
||||
.map(dataslateMapper::toDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
log.debug("Request to delete Dataslate : {}", id);
|
||||
dataslateRepository.deleteById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package com.warhammer.service.impl;
|
||||
|
||||
import com.warhammer.domain.UnitKeyword;
|
||||
import com.warhammer.repository.UnitKeywordRepository;
|
||||
import com.warhammer.service.UnitKeywordService;
|
||||
import com.warhammer.service.dto.UnitKeywordDTO;
|
||||
import com.warhammer.service.mapper.UnitKeywordMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class UnitKeywordServiceImpl implements UnitKeywordService {
|
||||
private final Logger log = LoggerFactory.getLogger(UnitKeywordServiceImpl.class);
|
||||
|
||||
private final UnitKeywordRepository unitKeywordRepository;
|
||||
|
||||
private final UnitKeywordMapper unitKeywordMapper;
|
||||
|
||||
public UnitKeywordServiceImpl(UnitKeywordRepository unitKeywordRepository, UnitKeywordMapper unitKeywordMapper) {
|
||||
this.unitKeywordRepository = unitKeywordRepository;
|
||||
this.unitKeywordMapper = unitKeywordMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnitKeywordDTO save(UnitKeywordDTO unitKeywordDTO) {
|
||||
log.debug("Request to save UnitKeyword : {}", unitKeywordDTO);
|
||||
UnitKeyword unitKeyword = unitKeywordMapper.toEntity(unitKeywordDTO);
|
||||
unitKeyword = unitKeywordRepository.save(unitKeyword);
|
||||
return unitKeywordMapper.toDto(unitKeyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UnitKeywordDTO> findAll() {
|
||||
log.debug("Request to get all UnitKeywords");
|
||||
return unitKeywordRepository.findAll().stream()
|
||||
.map(unitKeywordMapper::toDto)
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UnitKeywordDTO> findAllByOwner(Optional ownerLoginOptional) {
|
||||
log.debug("Request to get all UnitKeywords by Owner : " + ownerLoginOptional.orElse(null));
|
||||
return unitKeywordRepository.findAll().stream()
|
||||
.map(unitKeywordMapper::toDto)
|
||||
.filter(unitKeywordDto -> unitKeywordDto.getOwner().equals(ownerLoginOptional.orElse(null)))
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<UnitKeywordDTO> findOne(Long id) {
|
||||
log.debug("Request to get UnitKeyword : {}", id);
|
||||
return unitKeywordRepository.findById(id)
|
||||
.map(unitKeywordMapper::toDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
log.debug("Request ot delete UnitKeyword : {}", id);
|
||||
unitKeywordRepository.deleteById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.warhammer.service.impl;
|
||||
|
||||
import com.warhammer.domain.Weapon;
|
||||
import com.warhammer.repository.WeaponRepository;
|
||||
import com.warhammer.service.WeaponService;
|
||||
import com.warhammer.service.dto.WeaponDTO;
|
||||
import com.warhammer.service.mapper.WeaponMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class WeaponServiceImpl implements WeaponService {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(WeaponServiceImpl.class);
|
||||
|
||||
private final WeaponRepository weaponRepository;
|
||||
|
||||
private final WeaponMapper weaponMapper;
|
||||
|
||||
public WeaponServiceImpl(WeaponRepository weaponRepository, WeaponMapper weaponMapper) {
|
||||
this.weaponRepository = weaponRepository;
|
||||
this.weaponMapper = weaponMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeaponDTO save(WeaponDTO weaponDTO) {
|
||||
log.debug("Request to save Weapon : {}", weaponDTO);
|
||||
Weapon weapon = weaponMapper.toEntity(weaponDTO);
|
||||
weapon = weaponRepository.save(weapon);
|
||||
return weaponMapper.toDto(weapon);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<WeaponDTO> findAll() {
|
||||
log.debug("Request to get all Weapons");
|
||||
return weaponRepository.findAll().stream()
|
||||
.map(weaponMapper::toDto)
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<WeaponDTO> findAllByOwner(Optional<String> ownerLoginOptional) {
|
||||
log.debug("Request to get all Weapons by Owner : " + ownerLoginOptional.orElse(null));
|
||||
return weaponRepository.findAll().stream()
|
||||
.map(weaponMapper::toDto)
|
||||
.filter(weaponDTO -> weaponDTO.getOwner().equals(ownerLoginOptional.orElse(null)))
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Optional<WeaponDTO> findOne(Long id) {
|
||||
log.debug("Request to get Dataslate : {}", id);
|
||||
return weaponRepository.findById(id)
|
||||
.map(weaponMapper::toDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
log.debug("Request to delete Weapon : {}", id);
|
||||
weaponRepository.deleteById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.warhammer.service.mapper;
|
||||
|
||||
import com.warhammer.domain.Dataslate;
|
||||
import com.warhammer.service.dto.DataslateDTO;
|
||||
import org.mapstruct.*;
|
||||
|
||||
@Mapper(componentModel = "spring", uses = {UserMapper.class})
|
||||
public interface DataslateMapper extends EntityMapper<DataslateDTO, Dataslate> {
|
||||
@Mapping(source = "owner.id", target = "owner")
|
||||
@Mapping(source = "owner.login", target = "ownerLogin")
|
||||
DataslateDTO toDto(Dataslate dataslate);
|
||||
|
||||
@Mapping(source = "owner", target = "owner")
|
||||
Dataslate toEntity(DataslateDTO dataslateDTO);
|
||||
|
||||
default Dataslate fromId(Long id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
Dataslate dataslate = new Dataslate();
|
||||
dataslate.setId(id);
|
||||
return dataslate;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.warhammer.service.mapper;
|
||||
|
||||
import com.warhammer.domain.UnitKeyword;
|
||||
import com.warhammer.service.dto.UnitKeywordDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper(componentModel = "spring", uses = {UserMapper.class})
|
||||
public interface UnitKeywordMapper extends EntityMapper<UnitKeywordDTO, UnitKeyword> {
|
||||
UnitKeywordDTO toDto(UnitKeyword unitKeyword);
|
||||
|
||||
UnitKeyword toEntity(UnitKeywordDTO unitKeywordDTO);
|
||||
}
|
15
src/main/java/com/warhammer/service/mapper/WeaponMapper.java
Normal file
15
src/main/java/com/warhammer/service/mapper/WeaponMapper.java
Normal file
@ -0,0 +1,15 @@
|
||||
package com.warhammer.service.mapper;
|
||||
|
||||
import com.warhammer.domain.Weapon;
|
||||
import com.warhammer.service.dto.WeaponDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring", uses = {UserMapper.class})
|
||||
public interface WeaponMapper extends EntityMapper<WeaponDTO, Weapon> {
|
||||
// @Mapping(source = "owner.login", target = "owner")
|
||||
@Mapping(source = "weapon", target = "weapon")
|
||||
WeaponDTO toDto(Weapon weapon);
|
||||
|
||||
Weapon toEntity(WeaponDTO weaponDTO);
|
||||
}
|
97
src/main/java/com/warhammer/web/rest/DataslateResource.java
Normal file
97
src/main/java/com/warhammer/web/rest/DataslateResource.java
Normal file
@ -0,0 +1,97 @@
|
||||
package com.warhammer.web.rest;
|
||||
|
||||
import com.warhammer.domain.Dataslate;
|
||||
import com.warhammer.security.SecurityUtils;
|
||||
import com.warhammer.service.DataslateService;
|
||||
import com.warhammer.service.dto.DataslateDTO;
|
||||
import com.warhammer.web.rest.errors.BadRequestAlertException;
|
||||
import io.github.jhipster.web.util.HeaderUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("~/api")
|
||||
public class DataslateResource {
|
||||
private final Logger log = LoggerFactory.getLogger(DataslateResource.class);
|
||||
|
||||
private static final String ENTITY_NAME = "dataslate";
|
||||
|
||||
@Value("crusadetrackerApp")
|
||||
private String applicationName;
|
||||
|
||||
private final DataslateService dataslateService;
|
||||
|
||||
public DataslateResource(DataslateService dataslateService) {
|
||||
this.dataslateService = dataslateService;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code POST /dataslates} : Creates a dataslate.
|
||||
*
|
||||
* @param dataslateDTO the dataslate to create
|
||||
* @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new dataslate, or with status {@code 400 (Bad Request)} if the dataslate already has an ID.
|
||||
* @throws URISyntaxException if the Location URI syntax is incorrect.
|
||||
*/
|
||||
@PostMapping("/dataslates")
|
||||
public ResponseEntity<DataslateDTO> createDataslate(@Valid @RequestBody DataslateDTO dataslateDTO) throws URISyntaxException {
|
||||
log.debug("REST request to save Dataslate : {}", dataslateDTO);
|
||||
if (dataslateDTO.getId() != null) {
|
||||
throw new BadRequestAlertException("A new dataslate cannot already have an ID", ENTITY_NAME, "idexists");
|
||||
}
|
||||
DataslateDTO result = dataslateService.save(dataslateDTO);
|
||||
return ResponseEntity.created(new URI("/api/dataslates/" + result.getId()))
|
||||
.headers(HeaderUtil.createEntityCreationAlert(applicationName, false, ENTITY_NAME, result.getId().toString()))
|
||||
.body(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code PUT /dataslates} : Updates an existing dataslate.
|
||||
*
|
||||
* @param dataslateDTO the dataslate to update
|
||||
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated dataslate,
|
||||
* or with status {@code 400 (Bad Request)} if the dataslate is not valid,
|
||||
* or with status {@code 500 (Internal Server Error)} if the dataslate couldn't be updated.
|
||||
* @throws URISyntaxException if the Location URI syntax is incorrect.
|
||||
*/
|
||||
@PutMapping("/dataslates")
|
||||
public ResponseEntity<DataslateDTO> updateDataSlate(@Valid @RequestBody DataslateDTO dataslateDTO) throws URISyntaxException {
|
||||
log.debug("REST request to update Dataslate : {}", dataslateDTO);
|
||||
if (dataslateDTO.getId() == null) {
|
||||
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
|
||||
}
|
||||
DataslateDTO result = dataslateService.save(dataslateDTO);
|
||||
return ResponseEntity.ok()
|
||||
.headers(HeaderUtil.createEntityUpdateAlert(applicationName, false, ENTITY_NAME,
|
||||
dataslateDTO.getId().toString()))
|
||||
.body(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code GET /dataslates} : get all the dataslates
|
||||
*
|
||||
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of dataslates in body.
|
||||
*/
|
||||
@GetMapping("/dataslates")
|
||||
public List<Dataslate> getAllDataslates() {
|
||||
log.debug("REST request to get all dataslates");
|
||||
Optional<String> userLogin = SecurityUtils.getCurrentUserLogin();
|
||||
return dataslateService.findAllByOwner(userLogin);
|
||||
}
|
||||
|
||||
@DeleteMapping("/dataslates/{id}")
|
||||
public ResponseEntity<Void> deleteDataslate(@PathVariable Long id) {
|
||||
log.debug("REST request to delete Dataslate : {}", id);
|
||||
dataslateService.delete(id);
|
||||
return ResponseEntity.noContent().headers(HeaderUtil.createEntityDeletionAlert(
|
||||
applicationName, false, ENTITY_NAME, id.toString())).build();
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package com.warhammer.web.rest;
|
||||
|
||||
import com.warhammer.security.SecurityUtils;
|
||||
import com.warhammer.service.UnitKeywordService;
|
||||
import com.warhammer.service.dto.UnitKeywordDTO;
|
||||
import com.warhammer.web.rest.errors.BadRequestAlertException;
|
||||
import io.github.jhipster.web.util.HeaderUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
public class UnitKeywordResource {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(UnitKeywordResource.class);
|
||||
|
||||
private static final String ENTITY_NAME = "keyword";
|
||||
|
||||
@Value("crusadetrackerApp")
|
||||
private String applicationName;
|
||||
|
||||
private final UnitKeywordService unitKeywordService;
|
||||
|
||||
public UnitKeywordResource(UnitKeywordService unitKeywordService) {
|
||||
this.unitKeywordService = unitKeywordService;
|
||||
}
|
||||
|
||||
@PostMapping("/keyword")
|
||||
public ResponseEntity<UnitKeywordDTO> createKeyword(@Valid @RequestBody UnitKeywordDTO unitKeywordDTO) throws URISyntaxException {
|
||||
log.debug("REST request to save UnitKeyword : {}", unitKeywordDTO);
|
||||
if (unitKeywordDTO.getId() != null) {
|
||||
throw new BadRequestAlertException("A new unitkeyword cannot already have an ID", ENTITY_NAME, "idexists");
|
||||
}
|
||||
UnitKeywordDTO result = unitKeywordService.save(unitKeywordDTO);
|
||||
return ResponseEntity.created(new URI("/api/keywords/" + result.getId()))
|
||||
.headers(HeaderUtil.createEntityCreationAlert(applicationName, false, ENTITY_NAME, result.getId().toString()))
|
||||
.body(result);
|
||||
}
|
||||
|
||||
@GetMapping("/keyword")
|
||||
public List<UnitKeywordDTO> getAllKeywords() {
|
||||
log.debug("REST request to get all unitkeywords");
|
||||
Optional<String> userLogin = SecurityUtils.getCurrentUserLogin();
|
||||
return unitKeywordService.findAllByOwner(userLogin);
|
||||
}
|
||||
|
||||
@PutMapping("/keyword")
|
||||
public ResponseEntity<UnitKeywordDTO> updateWeapon(@Valid @RequestBody UnitKeywordDTO unitKeywordDTO) throws URISyntaxException {
|
||||
log.debug("REST request to update Keyword : {}", unitKeywordDTO);
|
||||
if (unitKeywordDTO.getId() == null) {
|
||||
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
|
||||
}
|
||||
Optional<String> userLogin = SecurityUtils.getCurrentUserLogin();
|
||||
log.debug("REST request being fulfilled to update Weapon : {} ", unitKeywordDTO);
|
||||
UnitKeywordDTO result = unitKeywordService.save(unitKeywordDTO);
|
||||
return ResponseEntity.ok()
|
||||
.headers(HeaderUtil.createEntityUpdateAlert(applicationName, false, ENTITY_NAME, unitKeywordDTO.getId().toString()))
|
||||
.body(result);
|
||||
}
|
||||
|
||||
@DeleteMapping("/keyword/{id}")
|
||||
public ResponseEntity<Void> deleteKeyword(@PathVariable Long id) {
|
||||
log.debug("REST request to delete UnitKeyword : {}", id);
|
||||
unitKeywordService.delete(id);
|
||||
return ResponseEntity.noContent().headers(HeaderUtil.createEntityDeletionAlert(applicationName, false, ENTITY_NAME, id.toString())).build();
|
||||
}
|
||||
}
|
77
src/main/java/com/warhammer/web/rest/WeaponResource.java
Normal file
77
src/main/java/com/warhammer/web/rest/WeaponResource.java
Normal file
@ -0,0 +1,77 @@
|
||||
package com.warhammer.web.rest;
|
||||
|
||||
import com.warhammer.security.SecurityUtils;
|
||||
import com.warhammer.service.WeaponService;
|
||||
import com.warhammer.service.dto.WeaponDTO;
|
||||
import com.warhammer.web.rest.errors.BadRequestAlertException;
|
||||
import io.github.jhipster.web.util.HeaderUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
public class WeaponResource {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(WeaponResource.class);
|
||||
|
||||
private static final String ENTITY_NAME = "weapon";
|
||||
|
||||
@Value("crusadetrackerApp")
|
||||
private String applicationName;
|
||||
|
||||
private final WeaponService weaponService;
|
||||
|
||||
public WeaponResource(WeaponService weaponService) {
|
||||
this.weaponService = weaponService;
|
||||
}
|
||||
|
||||
@PostMapping("/weapon")
|
||||
public ResponseEntity<WeaponDTO> createWeapon(@Valid @RequestBody WeaponDTO weaponDTO) throws URISyntaxException {
|
||||
log.debug("REST request to save Weapon : {}", weaponDTO);
|
||||
if (weaponDTO.getId() != null) {
|
||||
throw new BadRequestAlertException("A new weapon cannot already have an ID", ENTITY_NAME, "idexists");
|
||||
}
|
||||
WeaponDTO result = weaponService.save(weaponDTO);
|
||||
return ResponseEntity.created(new URI("/api/weapon/" + result.getId()))
|
||||
.headers(HeaderUtil.createEntityCreationAlert(applicationName, false, ENTITY_NAME, result.getId().toString()))
|
||||
.body(result);
|
||||
}
|
||||
|
||||
@GetMapping("/weapon")
|
||||
public List<WeaponDTO> getAllWeapons() {
|
||||
log.debug("REST request to get all weapons");
|
||||
Optional<String> userLogin = SecurityUtils.getCurrentUserLogin();
|
||||
return weaponService.findAllByOwner(userLogin);
|
||||
}
|
||||
|
||||
@PutMapping("/weapon")
|
||||
public ResponseEntity<WeaponDTO> updateWeapon(@Valid @RequestBody WeaponDTO weaponDTO) throws URISyntaxException {
|
||||
log.debug("REST request to update Weapon : {}", weaponDTO);
|
||||
if (weaponDTO.getId() == null) {
|
||||
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
|
||||
}
|
||||
Optional<String> userLogin = SecurityUtils.getCurrentUserLogin();
|
||||
log.debug("REST request being fulfilled to update Weapon : {} ", weaponDTO);
|
||||
WeaponDTO result = weaponService.save(weaponDTO);
|
||||
return ResponseEntity.ok()
|
||||
.headers(HeaderUtil.createEntityUpdateAlert(applicationName, false, ENTITY_NAME, weaponDTO.getId().toString()))
|
||||
.body(result);
|
||||
}
|
||||
|
||||
@DeleteMapping("/weapon/{id}")
|
||||
public ResponseEntity<Void> deleteWeapon(@PathVariable Long id) {
|
||||
log.debug("REST request to delete weapon : {}", id);
|
||||
weaponService.delete(id);
|
||||
return ResponseEntity.noContent().headers(HeaderUtil.createEntityDeletionAlert(applicationName,
|
||||
false, ENTITY_NAME, id.toString())).build();
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<databaseChangeLog
|
||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.9.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
|
||||
|
||||
<property name="autoIncrement" value="true"/>
|
||||
|
||||
<!--
|
||||
Update the entity UnitArmy.
|
||||
to remove entity UnitBase
|
||||
-->
|
||||
<!-- todo -->
|
||||
<changeSet id="20220421081900_add_dataslates.xml-1" author="mitch" runOnChange="true">
|
||||
<createTable tableName="weapon">
|
||||
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="weapon" type="varchar(255)"/>
|
||||
<column name="range" type="varchar(255)"/>
|
||||
<column name="type" type="varchar(255)"/>
|
||||
<column name="strength" type="varchar(255)"/>
|
||||
<column name="armor_penetration" type="varchar(255)"/>
|
||||
<column name="damage" type="varchar(255)"/>
|
||||
<column name="abilities" type="varchar(255)"/>
|
||||
<column name="owner_id" type="bigint">
|
||||
<constraints nullable="false" />
|
||||
</column>
|
||||
</createTable>
|
||||
<createTable tableName="unit_keyword">
|
||||
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
|
||||
<constraints primaryKey="true" nullable="false" />
|
||||
</column>
|
||||
<column name="keyword" type="varchar(255)"/>
|
||||
<column name="is_faction" type="boolean"/>
|
||||
<column name="owner_id" type="bigint">
|
||||
<constraints nullable="false" />
|
||||
</column>
|
||||
</createTable>
|
||||
<createTable tableName="dataslate">
|
||||
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="movement" type="varchar(255)"/>
|
||||
<column name="weapon_skill" type="varchar(255)"/>
|
||||
<column name="ballistic_skill" type="varchar(255)"/>
|
||||
<column name="strength" type="varchar(255)"/>
|
||||
<column name="wounds" type="varchar(255)"/>
|
||||
<column name="attacks" type="varchar(255)"/>
|
||||
<column name="leadership" type="int"/>
|
||||
<column name="save" type="int"/>
|
||||
<column name="invulnerable" type="int"/>
|
||||
<column name="feel_no_pain" type="int"/>
|
||||
<column name="wargear_options" type="${clobType}"/>
|
||||
<column name="psyker" type="${clobType}"/>
|
||||
</createTable>
|
||||
<createTable tableName="dataslate_weapon">
|
||||
<column name="dataslate_id" type="bigint">
|
||||
<constraints nullable="false"
|
||||
primaryKey="true"
|
||||
primaryKeyName="pk_dataslate_weapon_composite"
|
||||
foreignKeyName="fk_dataslate_id"
|
||||
references="dataslate(id)"
|
||||
/>
|
||||
</column>
|
||||
<column name="weapon_id" type="bigint">
|
||||
<constraints nullable="false"
|
||||
primaryKey="true"
|
||||
primaryKeyName="pk_dataslate_wweapon_composite"
|
||||
foreignKeyName="fk_dataslate_weapon_id"
|
||||
references="weapon(id)"
|
||||
/>
|
||||
</column>
|
||||
</createTable>
|
||||
<createTable tableName="dataslate_keyword">
|
||||
<column name="dataslate_id" type="bigint">
|
||||
<constraints nullable="false"
|
||||
primaryKey="true"
|
||||
primaryKeyName="pk_dataslate_keyword_composite"
|
||||
foreignKeyName="fk_dataslate_keyword_dataslate_id"
|
||||
references="dataslate(id)"
|
||||
/>
|
||||
</column>
|
||||
<column name="keyword_id" type="bigint">
|
||||
<constraints nullable="false"
|
||||
primaryKey="true"
|
||||
primaryKeyName="pk_dataslate_keyword_composite"
|
||||
foreignKeyName="fk_dataslate_keyword_keyword_id"
|
||||
references="unit_keyword(id)"
|
||||
/>
|
||||
</column>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
<changeSet id="20220421081900_add_dataslates.xml-2" author="mitch" runOnChange="true">
|
||||
<addColumn tableName="unit_army">
|
||||
<column name="unit_dataslate_id" type="bigint">
|
||||
<constraints nullable="true" foreignKeyName="fk_unit_dataslate_unit_army_id" references="dataslate(id)"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -26,6 +26,7 @@
|
||||
<include file="config/liquibase/changelog/20220304184800_remove_agenda_unit_army.xml" relativeToChangelogFile="false"/>
|
||||
<include file="config/liquibase/changelog/20220313104800_remove_unused_kill_tally.xml" relativeToChangelogFile="false"/>
|
||||
<include file="config/liquibase/changelog/20220315083700_add_tie_tally.xml" relativeToChangelogFile="false"/>
|
||||
<include file="config/liquibase/changelog/20220421081900_add_dataslates.xml" relativeToChangelogFile="false"/>
|
||||
<!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here -->
|
||||
<!-- jhipster-needle-liquibase-add-incremental-changelog - JHipster will add incremental liquibase changelogs here -->
|
||||
</databaseChangeLog>
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
// import { WeaponComponent } from './weapon/weapon.component';
|
||||
// import { KeywordComponent } from './keyword/keyword.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@ -16,8 +18,17 @@ import { RouterModule } from '@angular/router';
|
||||
path: 'force',
|
||||
loadChildren: () => import('./force/force.module').then(m => m.CrusadetrackerForceModule),
|
||||
},
|
||||
{
|
||||
path: 'weapon',
|
||||
loadChildren: () => import('./weapon/weapon.module').then(m => m.CrusadetrackerWeaponModule),
|
||||
},
|
||||
{
|
||||
path: 'keyword',
|
||||
loadChildren: () => import('./keyword/keyword.module').then(m => m.CrusadetrackerKeywordModule),
|
||||
}
|
||||
/* jhipster-needle-add-entity-route - JHipster will add entity modules routes here */
|
||||
]),
|
||||
],
|
||||
// declarations: [WeaponComponent, KeywordComponent],
|
||||
})
|
||||
export class CrusadetrackerEntityModule {}
|
||||
|
@ -0,0 +1,24 @@
|
||||
<form *ngIf="keyword" name="deleteForm" (ngSubmit)="confirmDelete(keyword?.id!)">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Confirm delete operation</h4>
|
||||
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
|
||||
(click)="cancel()">×</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<jhi-alert-error></jhi-alert-error>
|
||||
|
||||
<p id="jhi-delete-keyword-heading">Are you sure you want to delete this Keyword?</p>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="cancel()">
|
||||
<fa-icon icon="ban"></fa-icon> <span>Cancel</span>
|
||||
</button>
|
||||
|
||||
<button id="jhi-confirm-delete-keyword" type="submit" class="btn btn-danger">
|
||||
<fa-icon icon="times"></fa-icon> <span>Delete</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,30 @@
|
||||
import {Component} from "@angular/core";
|
||||
import {IKeyword} from "../../shared/model/keyword.model";
|
||||
import {KeywordService} from "./keyword.service";
|
||||
import {NgbActiveModal} from "@ng-bootstrap/ng-bootstrap";
|
||||
import {JhiEventManager} from "ng-jhipster";
|
||||
|
||||
@Component({
|
||||
templateUrl: './keyword-delete-dialog.component.html',
|
||||
})
|
||||
export class KeywordDeleteDialogComponent {
|
||||
keyword?: IKeyword;
|
||||
|
||||
constructor(
|
||||
protected keywordService: KeywordService,
|
||||
public activeModal: NgbActiveModal,
|
||||
protected eventManager: JhiEventManager
|
||||
) {
|
||||
}
|
||||
|
||||
cancel(): void {
|
||||
this.activeModal.dismiss();
|
||||
}
|
||||
|
||||
confirmDelete(id: number): void {
|
||||
this.keywordService.delete(id).subscribe(() => {
|
||||
this.eventManager.broadcast('keywordListModification');
|
||||
this.activeModal.close();
|
||||
})
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-8">
|
||||
<form name="editForm" role="form" novalidate (ngSubmit)="save()" [formGroup]="editForm">
|
||||
<h2 id="jhi-keyword-heading">Create or edit a Keyword</h2>
|
||||
|
||||
<div>
|
||||
<jhi-alert-error></jhi-alert-error>
|
||||
|
||||
<div class="form-group" [hidden]="!editForm.get('id')!.value">
|
||||
<label for="id">ID</label>
|
||||
<input type="text" class="form-control" id="id" name="id" formControlName="id" readonly />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="field_keyword">Keyword</label>
|
||||
<input type="text" class="form-control" name="keyword" id="field_keyword"
|
||||
formControlName="keyword"/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="field_isFaction">Is Faction</label>
|
||||
<input type="text" class="form-control" name="isFaction" id="field_isFaction"
|
||||
formControlName="isFaction"/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="field_owner">Owner</label>
|
||||
<select class="form-control" id="field_owner" name="owner" formControlName="owner">
|
||||
<option *ngIf="!editForm.get('owner')!.value" [ngValue]="null" selected></option>
|
||||
<option [ngValue]="userOption.id" *ngFor="let userOption of users; trackBy: trackById">{{ userOption.login }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div *ngIf="editForm.get('owner')!.invalid && (editForm.get('owner')!.dirty || editForm.get('owner')!.touched)">
|
||||
<small class="form-text text-danger"
|
||||
*ngIf="editForm.get('owner')?.errors?.required">
|
||||
This field is required.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button type="button" id="cancel-save" class="btn btn-secondary" (click)="previousState()">
|
||||
<fa-icon icon="ban"></fa-icon> <span>Cancel</span>
|
||||
</button>
|
||||
|
||||
<button type="submit" id="save-entity" [disabled]="editForm.invalid || isSaving" class="btn btn-primary">
|
||||
<fa-icon icon="save"></fa-icon> <span>Save</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,98 @@
|
||||
import {Component, OnInit} from "@angular/core";
|
||||
import {JhiDataUtils, JhiEventManager} from "ng-jhipster";
|
||||
import {UserService} from 'app/core/user/user.service';
|
||||
import {KeywordService} from "./keyword.service";
|
||||
import {ActivatedRoute} from "@angular/router";
|
||||
import {FormBuilder} from "@angular/forms";
|
||||
import {HttpResponse} from "@angular/common/http";
|
||||
import {IUser} from 'app/core/user/user.model';
|
||||
import {IKeyword, Keyword} from "../../shared/model/keyword.model";
|
||||
import {Observable} from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'jhi-keyword-update',
|
||||
templateUrl: './keyword-update.component.html',
|
||||
})
|
||||
export class KeywordUpdateComponent implements OnInit {
|
||||
isSaving = false;
|
||||
users: IUser[] = [];
|
||||
|
||||
editForm = this.fb.group({
|
||||
id: [],
|
||||
keyword: [],
|
||||
isFaction: [],
|
||||
owner: [],
|
||||
})
|
||||
|
||||
constructor(
|
||||
protected dataUtils: JhiDataUtils,
|
||||
protected eventManager: JhiEventManager,
|
||||
protected keywordService: KeywordService,
|
||||
protected userService: UserService,
|
||||
protected activatedRoute: ActivatedRoute,
|
||||
protected fb: FormBuilder,
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.activatedRoute.data.subscribe(({ keyword }) => {
|
||||
this.updateForm(keyword);
|
||||
|
||||
this.userService.query().subscribe((res: HttpResponse<IUser[]>) => (this.users = res.body || []));
|
||||
});
|
||||
}
|
||||
|
||||
updateForm(keyword: IKeyword): void {
|
||||
this.editForm.patchValue({
|
||||
id: keyword.id,
|
||||
keyword: keyword.keyword,
|
||||
isFaction: keyword.isFaction,
|
||||
owner: keyword.owner,
|
||||
});
|
||||
}
|
||||
|
||||
save(): void {
|
||||
this.isSaving = true;
|
||||
const keyword = this.createFromForm();
|
||||
if (keyword.id !== undefined) {
|
||||
console.log(keyword);
|
||||
this.subscribeToSaveResponse(this.keywordService.update(keyword));
|
||||
} else {
|
||||
this.subscribeToSaveResponse(this.keywordService.create(keyword));
|
||||
}
|
||||
}
|
||||
|
||||
private createFromForm(): IKeyword {
|
||||
return {
|
||||
...new Keyword(),
|
||||
id: this.editForm.get(['id'])!.value,
|
||||
keyword: this.editForm.get(['keyword'])!.value,
|
||||
isFaction: this.editForm.get(['isFaction'])!.value,
|
||||
owner: this.editForm.get(['owner'])!.value,
|
||||
}
|
||||
}
|
||||
|
||||
protected subscribeToSaveResponse(result: Observable<HttpResponse<IKeyword>>): void {
|
||||
result.subscribe(
|
||||
() => this.onSaveSuccess(),
|
||||
() => this.onSaveError()
|
||||
);
|
||||
}
|
||||
|
||||
protected onSaveSuccess(): void {
|
||||
this.isSaving = false;
|
||||
this.previousState();
|
||||
}
|
||||
|
||||
protected onSaveError(): void {
|
||||
this.isSaving = false;
|
||||
}
|
||||
|
||||
trackById(index: number, item: IUser): any {
|
||||
return item.id;
|
||||
}
|
||||
|
||||
previousState(): void {
|
||||
window.history.back();
|
||||
}
|
||||
}
|
64
src/main/webapp/app/entities/keyword/keyword.component.html
Normal file
64
src/main/webapp/app/entities/keyword/keyword.component.html
Normal file
@ -0,0 +1,64 @@
|
||||
<div>
|
||||
<h2 id="page-heading">
|
||||
<span>Keyword</span>
|
||||
|
||||
<button id="jhi-create-entity" class="btn btn-primary float-right jh-create-entity create-keyword" [routerLink]="['/keyword/new']">
|
||||
<fa-icon icon="plus"></fa-icon>
|
||||
<span>
|
||||
Create new Keyword
|
||||
</span>
|
||||
</button>
|
||||
</h2>
|
||||
|
||||
<jhi-alert-error></jhi-alert-error>
|
||||
|
||||
<jhi-alert></jhi-alert>
|
||||
|
||||
<div class="alert alert-warning" id="no-result" *ngIf="keywords?.length === 0">
|
||||
<span>No keywords found</span>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive" id="entities" *ngIf="keywords && keywords.length > 0">
|
||||
<table class="table table-striped" aria-describedby="page-heading">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><span>ID</span></th>
|
||||
<th scope="col"><span>Keyword</span></th>
|
||||
<th scope="col"><span>IsFaction</span></th>
|
||||
<th scope="col"><span>Owner</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let keyword of keywords; trackBy: trackId">
|
||||
<td><a [routerLink]="['/keyword', keyword.id, 'view']">{{ keyword.id }}</a></td>
|
||||
<td>{{ keyword.keyword }}</td>
|
||||
<td>{{ keyword.isFaction }}</td>
|
||||
<td>{{ keyword.owner }}</td>>
|
||||
<td class="text-right">
|
||||
<div class="btn-group">
|
||||
<button type="submit"
|
||||
[routerLink]="['/keyword', keyword.id, 'view']"
|
||||
class="btn btn-info, btn-sm">
|
||||
<fa-icon icon="eye"></fa-icon>
|
||||
<span class="d-none d-md-inline">View</span>
|
||||
</button>
|
||||
|
||||
<button type="submit"
|
||||
[routerLink]="['/keyword', keyword.id, 'edit']"
|
||||
class="btn btn-primary btn-sm">
|
||||
<fa-icon icon="pencil-alt"></fa-icon>
|
||||
<span class="d-none d-md-inline">Edit</span>
|
||||
</button>
|
||||
|
||||
<button type="submit" (click)="delete(keyword)"
|
||||
class="btn btn-danger btn-sm">
|
||||
<fa-icon icon="times"></fa-icon>
|
||||
<span class="d-none d-md-inline">Delete</span>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
62
src/main/webapp/app/entities/keyword/keyword.component.ts
Normal file
62
src/main/webapp/app/entities/keyword/keyword.component.ts
Normal file
@ -0,0 +1,62 @@
|
||||
import {Component, OnDestroy, OnInit} from '@angular/core';
|
||||
import {IKeyword} from "../../shared/model/keyword.model";
|
||||
import {Subscription} from "rxjs";
|
||||
import {KeywordService} from "./keyword.service";
|
||||
import {JhiDataUtils, JhiEventManager} from "ng-jhipster";
|
||||
import {NgbModal} from "@ng-bootstrap/ng-bootstrap";
|
||||
import {HttpResponse} from "@angular/common/http";
|
||||
import {KeywordDeleteDialogComponent} from "./keyword-delete-dialog.component";
|
||||
|
||||
@Component({
|
||||
selector: 'jhi-keyword',
|
||||
templateUrl: './keyword.component.html',
|
||||
styleUrls: ['./keyword.component.scss']
|
||||
})
|
||||
export class KeywordComponent implements OnInit, OnDestroy {
|
||||
keywords?: IKeyword[];
|
||||
eventSubscriber?: Subscription;
|
||||
|
||||
constructor(
|
||||
protected keywordService: KeywordService,
|
||||
protected dataUtils: JhiDataUtils,
|
||||
protected eventManager: JhiEventManager,
|
||||
protected modalService: NgbModal,
|
||||
) { }
|
||||
|
||||
loadAll(): void {
|
||||
this.keywordService.query().subscribe((res: HttpResponse<IKeyword[]>) => this.keywords = res.body || []);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.loadAll();
|
||||
this.registerChangesInKeywords();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.eventSubscriber) {
|
||||
this.eventManager.destroy(this.eventSubscriber);
|
||||
}
|
||||
}
|
||||
|
||||
trackId(index: number, item: IKeyword): number {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
return item.id!;
|
||||
}
|
||||
|
||||
byteSize(base64String: string): string {
|
||||
return this.dataUtils.byteSize(base64String);
|
||||
}
|
||||
|
||||
openFile(contentType = '', base64String: string): void {
|
||||
return this.dataUtils.openFile(contentType, base64String);
|
||||
}
|
||||
|
||||
registerChangesInKeywords(): void {
|
||||
this.eventSubscriber = this.eventManager.subscribe('keywordListModification', () => this.loadAll());
|
||||
}
|
||||
|
||||
delete(keyword: IKeyword): void {
|
||||
const modalRef = this.modalService.open(KeywordDeleteDialogComponent, {size: 'lg', backdrop: 'static'});
|
||||
modalRef.componentInstance.keyword = keyword;
|
||||
}
|
||||
}
|
16
src/main/webapp/app/entities/keyword/keyword.module.ts
Normal file
16
src/main/webapp/app/entities/keyword/keyword.module.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import {NgModule} from "@angular/core";
|
||||
import {CrusadetrackerSharedModule} from "../../shared/shared.module";
|
||||
import {RouterModule} from "@angular/router";
|
||||
import {keywordRoutes} from "./keyword.route";
|
||||
import {KeywordComponent} from "./keyword.component";
|
||||
import {KeywordUpdateComponent} from "./keyword-update.component";
|
||||
import {KeywordDeleteDialogComponent} from "./keyword-delete-dialog.component";
|
||||
|
||||
@NgModule({
|
||||
imports: [CrusadetrackerSharedModule, RouterModule.forChild(keywordRoutes)],
|
||||
declarations: [KeywordComponent,
|
||||
KeywordUpdateComponent,
|
||||
KeywordDeleteDialogComponent],
|
||||
entryComponents: []
|
||||
})
|
||||
export class CrusadetrackerKeywordModule {}
|
71
src/main/webapp/app/entities/keyword/keyword.route.ts
Normal file
71
src/main/webapp/app/entities/keyword/keyword.route.ts
Normal file
@ -0,0 +1,71 @@
|
||||
import {Injectable} from "@angular/core";
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, Routes} from '@angular/router';
|
||||
import {EMPTY, Observable, of} from "rxjs";
|
||||
import {IKeyword, Keyword} from "../../shared/model/keyword.model";
|
||||
import {KeywordService} from "./keyword.service";
|
||||
import {flatMap} from "rxjs/operators";
|
||||
import {HttpResponse} from "@angular/common/http";
|
||||
import {Army} from "../../shared/model/army.model";
|
||||
import {KeywordComponent} from './keyword.component';
|
||||
import {KeywordUpdateComponent} from './keyword-update.component';
|
||||
import {Authority} from "../../shared/constants/authority.constants";
|
||||
import {UserRouteAccessService} from "../../core/auth/user-route-access-service";
|
||||
|
||||
@Injectable({ providedIn: 'root'})
|
||||
export class KeywordResolve implements Resolve<IKeyword> {
|
||||
constructor(private service: KeywordService, private router: Router) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<IKeyword> | Observable<never> {
|
||||
const id = route.params['id'];
|
||||
if (id) {
|
||||
return this.service.find(id).pipe(
|
||||
flatMap((keyword: HttpResponse<Keyword>) => {
|
||||
if (keyword.body) {
|
||||
return of(keyword.body);
|
||||
} else {
|
||||
this.router.navigate(['404']);
|
||||
return EMPTY;
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
return of(new Army());
|
||||
}
|
||||
}
|
||||
|
||||
export const keywordRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: KeywordComponent,
|
||||
data: {
|
||||
authorities: [Authority.USER],
|
||||
pageTitle: 'Keywords',
|
||||
},
|
||||
canActivate: [UserRouteAccessService],
|
||||
},
|
||||
{
|
||||
path: 'new',
|
||||
component: KeywordUpdateComponent,
|
||||
resolve: {
|
||||
keyword: KeywordResolve,
|
||||
},
|
||||
data: {
|
||||
authorities: [Authority.USER],
|
||||
pageTitle: 'Keyword',
|
||||
},
|
||||
canActivate: [UserRouteAccessService],
|
||||
},
|
||||
{
|
||||
path: ':id/edit',
|
||||
component: KeywordUpdateComponent,
|
||||
resolve: {
|
||||
keyword: KeywordResolve,
|
||||
},
|
||||
data: {
|
||||
authorities: [Authority.USER],
|
||||
pageTitle: 'Keyword',
|
||||
},
|
||||
canActivate: [UserRouteAccessService],
|
||||
}
|
||||
]
|
38
src/main/webapp/app/entities/keyword/keyword.service.ts
Normal file
38
src/main/webapp/app/entities/keyword/keyword.service.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import {Injectable} from "@angular/core";
|
||||
import {SERVER_API_URL} from "../../app.constants";
|
||||
import {HttpClient, HttpResponse} from "@angular/common/http";
|
||||
import {IKeyword} from "../../shared/model/keyword.model";
|
||||
import {Observable} from "rxjs";
|
||||
import {createRequestOption} from "../../shared/util/request-util";
|
||||
|
||||
type EntityResponseType = HttpResponse<IKeyword>;
|
||||
type EntityArrayResponseType = HttpResponse<IKeyword[]>;
|
||||
|
||||
@Injectable({ providedIn: 'root'})
|
||||
export class KeywordService {
|
||||
public resourceUrl = SERVER_API_URL + 'api/keyword';
|
||||
|
||||
constructor(protected http: HttpClient) {
|
||||
}
|
||||
|
||||
create(keyword: IKeyword): Observable<EntityResponseType> {
|
||||
return this.http.post<IKeyword>(this.resourceUrl, keyword, {observe: 'response'});
|
||||
}
|
||||
|
||||
update(keyword: IKeyword): Observable<EntityResponseType> {
|
||||
return this.http.put<IKeyword>(this.resourceUrl, keyword, {observe: 'response'});
|
||||
}
|
||||
|
||||
find(id: number): Observable<EntityResponseType> {
|
||||
return this.http.get<IKeyword>(`${this.resourceUrl}/${id}`, {observe: 'response'});
|
||||
}
|
||||
|
||||
query(req?: any): Observable<EntityArrayResponseType> {
|
||||
const options = createRequestOption(req);
|
||||
return this.http.get<IKeyword[]>(this.resourceUrl, {params: options, observe: 'response'});
|
||||
}
|
||||
|
||||
delete(id: number): Observable<HttpResponse<{}>> {
|
||||
return this.http.delete(`${this.resourceUrl}/${id}`, {observe: 'response'});
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<form *ngIf="weapon" name="deleteForm" (ngSubmit)="confirmDelete(weapon?.id!)">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Confirm delete operation</h4>
|
||||
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
|
||||
(click)="cancel()">×</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<jhi-alert-error></jhi-alert-error>
|
||||
|
||||
<p id="jhi-delete-weapon-heading">Are you sure you want to delete this Weapon?</p>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="cancel()">
|
||||
<fa-icon icon="ban"></fa-icon> <span>Cancel</span>
|
||||
</button>
|
||||
|
||||
<button id="jhi-confirm-delete-weapon" type="submit" class="btn btn-danger">
|
||||
<fa-icon icon="times"></fa-icon> <span>Delete</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,30 @@
|
||||
import {Component} from "@angular/core";
|
||||
import {IWeapon} from "../../shared/model/weapon.model";
|
||||
import {NgbActiveModal} from "@ng-bootstrap/ng-bootstrap";
|
||||
import {WeaponService} from "./weapon.service";
|
||||
import {JhiEventManager} from "ng-jhipster";
|
||||
|
||||
@Component({
|
||||
templateUrl: './weapon-delete-dialog.component.html',
|
||||
})
|
||||
export class WeaponDeleteDialogComponent {
|
||||
weapon?: IWeapon;
|
||||
|
||||
constructor(
|
||||
protected weaponService: WeaponService,
|
||||
public activeModal: NgbActiveModal,
|
||||
protected eventManager: JhiEventManager
|
||||
) {
|
||||
}
|
||||
|
||||
cancel(): void {
|
||||
this.activeModal.dismiss();
|
||||
}
|
||||
|
||||
confirmDelete(id: number): void {
|
||||
this.weaponService.delete(id).subscribe( () => {
|
||||
this.eventManager.broadcast('weaponListModification');
|
||||
this.activeModal.close();
|
||||
})
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-8">
|
||||
<form name="editForm" role="form" novalidate (ngSubmit)="save()" [formGroup]="editForm">
|
||||
<h2 id="jhi-weapon-heading">Create or edit a Weapon</h2>
|
||||
<div>
|
||||
<jhi-alert-error></jhi-alert-error>
|
||||
|
||||
<div class="form-group" [hidden]="!editForm.get('id')!.value">
|
||||
<label for="id">ID</label>
|
||||
<input type="text" class="form-control" id="id" name="id" formControlName="id" readonly/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="field_weapon">Weapon</label>
|
||||
<input type="text" class="form-control" name="weapon" id="field_weapon"
|
||||
formControlName="weapon"/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="field_range">Range</label>
|
||||
<input type="text" class="form-control" name="range" id="field_range"
|
||||
formControlName="range"/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="field_type">type</label>
|
||||
<input type="text" class="form-control" name="type" id="field_type"
|
||||
formControlName="type"/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="field_strength">Strength</label>
|
||||
<input type="text" class="form-control" name="strength" id="field_strength"
|
||||
formControlName="strength"/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="field_armorPenetration">Armour Penetration</label>
|
||||
<input type="text" class="form-control" name="armorPenetration" id="field_armorPenetration"
|
||||
formControlName="armorPenetration"/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="field_damage">Damage</label>
|
||||
<input type="text" class="form-control" name="damage" id="field_damage"
|
||||
formControlName="damage"/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="field_owner">Owner</label>
|
||||
<select class="form-control" id="field_owner" name="owner" formControlName="owner">
|
||||
<option *ngIf="!editForm.get('owner')!.value" [ngValue]="null" selected></option>
|
||||
<option [ngValue]="userOption.id" *ngFor="let userOption of users; trackBy: trackById">{{ userOption.login }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div *ngIf="editForm.get('owner')!.invalid && (editForm.get('owner')!.dirty || editForm.get('owner')!.touched)">
|
||||
<small class="form-text text-danger"
|
||||
*ngIf="editForm.get('owner')?.errors?.required">
|
||||
This field is required.
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button type="button" id="cancel-save" class="btn btn-secondary" (click)="previousState()">
|
||||
<fa-icon icon="ban"></fa-icon> <span>Cancel</span>
|
||||
</button>
|
||||
|
||||
<button type="submit" id="save-entity" [disabled]="editForm.invalid || isSaving" class="btn btn-primary">
|
||||
<fa-icon icon="save"></fa-icon> <span>Save</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
114
src/main/webapp/app/entities/weapon/weapon-update.component.ts
Normal file
114
src/main/webapp/app/entities/weapon/weapon-update.component.ts
Normal file
@ -0,0 +1,114 @@
|
||||
import {Component, OnInit} from "@angular/core";
|
||||
import {IUser} from "../../core/user/user.model";
|
||||
import {JhiDataUtils, JhiEventManager} from "ng-jhipster";
|
||||
import {WeaponService} from "./weapon.service";
|
||||
import {UserService} from "../../core/user/user.service";
|
||||
import {ActivatedRoute} from "@angular/router";
|
||||
import {FormBuilder} from "@angular/forms";
|
||||
import {HttpResponse} from "@angular/common/http";
|
||||
import {IWeapon, Weapon} from "../../shared/model/weapon.model";
|
||||
import {Observable} from "rxjs";
|
||||
import {IArmy} from "../../shared/model/army.model";
|
||||
|
||||
@Component({
|
||||
selector: 'jhi-weapon-update',
|
||||
templateUrl: './weapon-update.component.html',
|
||||
})
|
||||
export class WeaponUpdateComponent implements OnInit {
|
||||
isSaving = false;
|
||||
users: IUser[] = [];
|
||||
|
||||
editForm = this.fb.group({
|
||||
owner: [],
|
||||
})
|
||||
|
||||
// editForm = this.fb.group({
|
||||
// id: [],
|
||||
// weapon: [],
|
||||
// range: [],
|
||||
// type: [],
|
||||
// strength: [],
|
||||
// armorPenetration: [],
|
||||
// damage: [],
|
||||
// owner: [],
|
||||
// })
|
||||
|
||||
constructor(
|
||||
protected dataUtils: JhiDataUtils,
|
||||
protected eventManager: JhiEventManager,
|
||||
protected weaponService: WeaponService,
|
||||
protected userService: UserService,
|
||||
protected activatedRoute: ActivatedRoute,
|
||||
protected fb: FormBuilder,
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.activatedRoute.data.subscribe(({ weapon }) => {
|
||||
this.updateForm(weapon);
|
||||
|
||||
this.userService.query().subscribe((res: HttpResponse<IUser[]>) => (this.users = res.body || []));
|
||||
});
|
||||
}
|
||||
|
||||
updateForm(weapon: IWeapon): void {
|
||||
this.editForm.patchValue({
|
||||
id: weapon.id,
|
||||
weapon: weapon.weapon,
|
||||
range: weapon.range,
|
||||
type: weapon.type,
|
||||
strength: weapon.strength,
|
||||
armorPenetration: weapon.armorPenetration,
|
||||
damage: weapon.damage,
|
||||
owner: weapon.owner,
|
||||
});
|
||||
}
|
||||
|
||||
save(): void {
|
||||
this.isSaving = true;
|
||||
const weapon = this.createFormForm();
|
||||
if (weapon.id !== undefined) {
|
||||
this.subscribeToSaveResponse(this.weaponService.update(weapon));
|
||||
} else {
|
||||
this.subscribeToSaveResponse(this.weaponService.create(weapon))
|
||||
}
|
||||
}
|
||||
|
||||
private createFormForm(): IWeapon {
|
||||
return {
|
||||
...new Weapon(),
|
||||
id: this.editForm.get(['id'])!.value,
|
||||
weapon: this.editForm.get(['weapon'])!.value,
|
||||
range: this.editForm.get(['range'])!.value,
|
||||
type: this.editForm.get(['type'])!.value,
|
||||
strength: this.editForm.get(['strength'])!.value,
|
||||
armorPenetration: this.editForm.get(['armorPenetration'])!.value,
|
||||
damage: this.editForm.get(['damage'])!.value,
|
||||
owner: this.editForm.get(['owner'])!.value,
|
||||
}
|
||||
}
|
||||
|
||||
protected subscribeToSaveResponse(result: Observable<HttpResponse<IWeapon>>): void {
|
||||
result.subscribe(
|
||||
() => this.onSaveSuccess(),
|
||||
() => this.onSaveError()
|
||||
);
|
||||
}
|
||||
|
||||
protected onSaveSuccess(): void {
|
||||
this.isSaving = false;
|
||||
this.previousState();
|
||||
}
|
||||
|
||||
protected onSaveError(): void {
|
||||
this.isSaving = false;
|
||||
}
|
||||
|
||||
trackById(index: number, item: IUser): any {
|
||||
return item.id;
|
||||
}
|
||||
|
||||
previousState(): void {
|
||||
window.history.back();
|
||||
}
|
||||
}
|
71
src/main/webapp/app/entities/weapon/weapon.component.html
Normal file
71
src/main/webapp/app/entities/weapon/weapon.component.html
Normal file
@ -0,0 +1,71 @@
|
||||
<div>
|
||||
<h2 id="page-heading">
|
||||
<span>Weapon</span>
|
||||
|
||||
<button id="jhi-create-entity" class="btn btn-primary float-right jh-create-entity create-weapon" [routerLink]="['/weapon/new']">
|
||||
<fa-icon icon="plus"></fa-icon>
|
||||
<span>
|
||||
Create a new Weapon
|
||||
</span>
|
||||
</button>
|
||||
</h2>
|
||||
|
||||
<jhi-alert-error></jhi-alert-error>
|
||||
<jhi-alert></jhi-alert>
|
||||
|
||||
<div class="alert alert-warning" id="no-result" *ngIf="weapons?.length === 0">
|
||||
<span>No weapons found</span>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive" id="entities" *ngIf="weapons && weapons.length > 0">
|
||||
<table class="table table-striped" aria-describedby="page-heading">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><span>ID</span></th>
|
||||
<th scope="col"><span>Weapon</span></th>
|
||||
<th scope="col"><span>Range</span></th>
|
||||
<th scope="col"><span>Type</span></th>
|
||||
<th scope="col"><span>Strength</span></th>
|
||||
<th scope="col"><span>Armour Penetration</span></th>
|
||||
<th scope="col"><span>Damage</span></th>
|
||||
<th scope="col"><span>Owner</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let weapon of weapons; trackBy: trackId">
|
||||
<td><a [routerLink]="['/weapons', weapon.id, 'view']">{{ weapon.id }}</a> </td>
|
||||
<td>{{ weapon.weapon }}</td>
|
||||
<td>{{ weapon.range }}</td>
|
||||
<td>{{ weapon.type }}</td>
|
||||
<td>{{ weapon.strength }}</td>
|
||||
<td>{{ weapon.armorPenetration }}</td>
|
||||
<td>{{ weapon.damage }}</td>
|
||||
<td>{{ weapon.owner }}</td>
|
||||
<td class="text-right">
|
||||
<div class="btn-group">
|
||||
<button type="submit"
|
||||
[routerLink]="['/weapons', weapon.id, 'view']"
|
||||
class="btn btn-info, btn-sm">
|
||||
<fa-icon icon="eye"></fa-icon>
|
||||
<span class="d-none d-md-inline">View</span>
|
||||
</button>
|
||||
|
||||
<button type="submit"
|
||||
[routerLink]="['/weapons', weapon.id, 'edit']"
|
||||
class="btn btn-primary btn-sm">
|
||||
<fa-icon icon="pencil-alt"></fa-icon>
|
||||
<span class="d-none d-md-inline">Edit</span>
|
||||
</button>
|
||||
|
||||
<button type="submit" (click)="delete(weapon)"
|
||||
class="btn btn-danger btn-sm">
|
||||
<fa-icon icon="times"></fa-icon>
|
||||
<span class="d-none d-md-inline">Delete</span>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
62
src/main/webapp/app/entities/weapon/weapon.component.ts
Normal file
62
src/main/webapp/app/entities/weapon/weapon.component.ts
Normal file
@ -0,0 +1,62 @@
|
||||
import {Component, OnDestroy, OnInit} from '@angular/core';
|
||||
import {IWeapon} from "../../shared/model/weapon.model";
|
||||
import {Subscription} from "rxjs";
|
||||
import {WeaponService} from "./weapon.service";
|
||||
import {JhiDataUtils, JhiEventManager} from "ng-jhipster";
|
||||
import {NgbModal} from "@ng-bootstrap/ng-bootstrap";
|
||||
import {HttpResponse} from "@angular/common/http";
|
||||
import {WeaponDeleteDialogComponent} from "./weapon-delete-dialog.component";
|
||||
|
||||
@Component({
|
||||
selector: 'jhi-weapon',
|
||||
templateUrl: './weapon.component.html',
|
||||
styleUrls: ['./weapon.component.scss']
|
||||
})
|
||||
export class WeaponComponent implements OnInit, OnDestroy {
|
||||
weapons?: IWeapon[];
|
||||
eventSubscriber?: Subscription;
|
||||
|
||||
constructor(
|
||||
protected weaponService: WeaponService,
|
||||
protected dataUtils: JhiDataUtils,
|
||||
protected eventManager: JhiEventManager,
|
||||
protected modalService: NgbModal,
|
||||
) { }
|
||||
|
||||
loadAll(): void {
|
||||
this.weaponService.query().subscribe((res: HttpResponse<IWeapon[]>) => this.weapons = res.body || []);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.loadAll();
|
||||
this.registerChangesInWeapons();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.eventSubscriber) {
|
||||
this.eventManager.destroy(this.eventSubscriber);
|
||||
}
|
||||
}
|
||||
|
||||
trackId(index: number, item: IWeapon): number {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
return item.id!;
|
||||
}
|
||||
|
||||
byteSize(base64String: string): string {
|
||||
return this.dataUtils.byteSize(base64String);
|
||||
}
|
||||
|
||||
openFile(contentType = '', base64String: string): void {
|
||||
return this.dataUtils.openFile(contentType, base64String);
|
||||
}
|
||||
|
||||
registerChangesInWeapons(): void {
|
||||
this.eventSubscriber = this.eventManager.subscribe('weaponListModification', () => this.loadAll());
|
||||
}
|
||||
|
||||
delete(weapon: IWeapon): void {
|
||||
const modalRef = this.modalService.open(WeaponDeleteDialogComponent, {size: 'lg', backdrop: 'static'});
|
||||
modalRef.componentInstance.weapon = weapon;
|
||||
}
|
||||
}
|
18
src/main/webapp/app/entities/weapon/weapon.module.ts
Normal file
18
src/main/webapp/app/entities/weapon/weapon.module.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import {NgModule} from "@angular/core";
|
||||
import {CrusadetrackerSharedModule} from "../../shared/shared.module";
|
||||
import {RouterModule} from "@angular/router";
|
||||
import {weaponRoutes} from "./weapon.route";
|
||||
import {WeaponComponent} from "./weapon.component";
|
||||
import {WeaponUpdateComponent} from "./weapon-update.component";
|
||||
import {WeaponDeleteDialogComponent} from "./weapon-delete-dialog.component";
|
||||
|
||||
@NgModule({
|
||||
imports: [CrusadetrackerSharedModule, RouterModule.forChild(weaponRoutes)],
|
||||
declarations: [
|
||||
WeaponComponent,
|
||||
WeaponUpdateComponent,
|
||||
WeaponDeleteDialogComponent
|
||||
],
|
||||
entryComponents: []
|
||||
})
|
||||
export class CrusadetrackerWeaponModule {}
|
65
src/main/webapp/app/entities/weapon/weapon.route.ts
Normal file
65
src/main/webapp/app/entities/weapon/weapon.route.ts
Normal file
@ -0,0 +1,65 @@
|
||||
import {Injectable} from "@angular/core";
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, Routes} from "@angular/router";
|
||||
import {IWeapon, Weapon} from "../../shared/model/weapon.model";
|
||||
import {WeaponService} from "./weapon.service";
|
||||
import {EMPTY, Observable, of} from "rxjs";
|
||||
import {flatMap} from "rxjs/operators";
|
||||
import {HttpResponse} from "@angular/common/http";
|
||||
import {Army} from "../../shared/model/army.model";
|
||||
import {WeaponComponent} from "./weapon.component";
|
||||
import {Authority} from "../../shared/constants/authority.constants";
|
||||
import {UserRouteAccessService} from "../../core/auth/user-route-access-service";
|
||||
import {WeaponUpdateComponent} from "./weapon-update.component";
|
||||
|
||||
@Injectable({ providedIn: 'root'})
|
||||
export class WeaponResolve implements Resolve<IWeapon> {
|
||||
constructor(private service: WeaponService, private router: Router) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<IWeapon> | Observable<never> {
|
||||
const id = route.params['id'];
|
||||
if (id) {
|
||||
return this.service.find(id).pipe(
|
||||
flatMap((weapon: HttpResponse<Weapon>) => {
|
||||
if (weapon.body) {
|
||||
return of(weapon.body);
|
||||
} else {
|
||||
this.router.navigate(['404']);
|
||||
return EMPTY;
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
return of(new Army());
|
||||
}
|
||||
}
|
||||
|
||||
export const weaponRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: WeaponComponent,
|
||||
data: {
|
||||
authorities: [Authority.USER],
|
||||
pageTitle: 'Weapon',
|
||||
},
|
||||
canActivate: [UserRouteAccessService],
|
||||
},
|
||||
{
|
||||
path: 'new',
|
||||
component: WeaponUpdateComponent,
|
||||
data: {
|
||||
authorities: [Authority.USER],
|
||||
pageTitle: 'Weapon',
|
||||
},
|
||||
canActivate: [UserRouteAccessService],
|
||||
},
|
||||
{
|
||||
path: ':id/edit',
|
||||
component: WeaponUpdateComponent,
|
||||
data: {
|
||||
authorities: [Authority.USER],
|
||||
pageTitle: 'Weapon',
|
||||
},
|
||||
canActivate: [UserRouteAccessService],
|
||||
},
|
||||
]
|
41
src/main/webapp/app/entities/weapon/weapon.service.ts
Normal file
41
src/main/webapp/app/entities/weapon/weapon.service.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import {Injectable} from "@angular/core";
|
||||
import {SERVER_API_URL} from "../../app.constants";
|
||||
import {HttpClient, HttpResponse} from "@angular/common/http";
|
||||
import {IWeapon} from "../../shared/model/weapon.model";
|
||||
import {Observable} from "rxjs";
|
||||
import {createRequestOption} from "../../shared/util/request-util";
|
||||
import {IKeyword} from "../../shared/model/keyword.model";
|
||||
|
||||
|
||||
type EntityResponseType = HttpResponse<IWeapon>;
|
||||
type EntityArrayResponseType = HttpResponse<IWeapon[]>;
|
||||
|
||||
@Injectable({ providedIn: 'root'})
|
||||
export class WeaponService {
|
||||
public resourceUrl = SERVER_API_URL + 'api/weapon';
|
||||
|
||||
constructor(protected http: HttpClient) {
|
||||
}
|
||||
|
||||
create(weapon: IWeapon): Observable<EntityResponseType> {
|
||||
return this.http.post<IWeapon>(this.resourceUrl, weapon, {observe: 'response'});
|
||||
}
|
||||
|
||||
update(weapon: IWeapon): Observable<EntityResponseType> {
|
||||
return this.http.put<IWeapon>(this.resourceUrl, weapon, {observe: 'response'});
|
||||
}
|
||||
|
||||
find(id: number): Observable<EntityResponseType> {
|
||||
return this.http.get<IWeapon>(`${this.resourceUrl}/${id}`, {observe: 'response'});
|
||||
}
|
||||
|
||||
query(req?: any): Observable<EntityArrayResponseType> {
|
||||
const options = createRequestOption(req);
|
||||
return this.http.get<IWeapon[]>(this.resourceUrl, {params: options, observe: 'response'});
|
||||
}
|
||||
|
||||
delete(id: number): Observable<HttpResponse<{}>> {
|
||||
return this.http.delete(`${this.resourceUrl}/${id}`, {observe: `response`});
|
||||
}
|
||||
|
||||
}
|
@ -39,6 +39,18 @@
|
||||
<span>Unit Army</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item" routerLink="keyword" routerLinkActive="active" [routerLinkActiveOptions]="{ exact: true }" (click)="collapseNavbar()">
|
||||
<fa-icon icon="asterisk" [fixedWidth]="true"></fa-icon>
|
||||
<span>Keywords</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item" routerLink="weapon" routerLinkActive="active" [routerLinkActiveOptions]="{ exact: true }" (click)="collapseNavbar()">
|
||||
<fa-icon icon="asterisk" [fixedWidth]="true"></fa-icon>
|
||||
<span>Weapons</span>
|
||||
</a>
|
||||
</li>
|
||||
<!-- jhipster-needle-add-entity-to-menu - JHipster will add entities to the menu here -->
|
||||
</ul>
|
||||
</li>
|
||||
|
16
src/main/webapp/app/shared/model/keyword.model.ts
Normal file
16
src/main/webapp/app/shared/model/keyword.model.ts
Normal file
@ -0,0 +1,16 @@
|
||||
export interface IKeyword {
|
||||
id?: number;
|
||||
keyword?: string,
|
||||
isFaction?: boolean,
|
||||
owner?: string,
|
||||
}
|
||||
|
||||
export class Keyword implements IKeyword {
|
||||
constructor(
|
||||
public id?: number,
|
||||
public keyword?: string,
|
||||
public isFaction?: boolean,
|
||||
public owner?: string,
|
||||
) {
|
||||
}
|
||||
}
|
24
src/main/webapp/app/shared/model/weapon.model.ts
Normal file
24
src/main/webapp/app/shared/model/weapon.model.ts
Normal file
@ -0,0 +1,24 @@
|
||||
export interface IWeapon {
|
||||
id?: number,
|
||||
weapon?: string,
|
||||
range?: string,
|
||||
type?: string,
|
||||
strength?: string,
|
||||
armorPenetration?: string,
|
||||
damage?: string,
|
||||
owner?: string
|
||||
}
|
||||
|
||||
export class Weapon implements IWeapon {
|
||||
constructor(
|
||||
public id?: number,
|
||||
public weapon?: string,
|
||||
public range?: string,
|
||||
public type?: string,
|
||||
public strength?: string,
|
||||
public armorPenetration?: string,
|
||||
public damage?: string,
|
||||
public owner?: string
|
||||
) {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user