From e9e8016249ba0d64d8287781597ed6a72fcb30d6 Mon Sep 17 00:00:00 2001 From: mitch Date: Sun, 18 Sep 2022 08:01:45 -0400 Subject: [PATCH] Added template for angular files --- .../web/rest/UnitKeywordResource.java | 56 +++++++++++++ .../warhammer/web/rest/WeaponResource.java | 20 +++++ src/main/webapp/app/entities/entity.module.ts | 11 +++ .../keyword-delete-dialog.component.html | 0 .../keyword-delete-dialog.component.ts | 30 +++++++ .../keyword/keyword-detail.component.html | 0 .../keyword/keyword-detail.component.ts | 28 +++++++ .../keyword/keyword-update.component.html | 0 .../keyword/keyword-update.component.ts | 60 +++++++++++++ .../entities/keyword/keyword.component.html | 1 + .../entities/keyword/keyword.component.scss | 0 .../app/entities/keyword/keyword.component.ts | 15 ++++ .../app/entities/keyword/keyword.module.ts | 18 ++++ .../app/entities/keyword/keyword.route.ts | 84 +++++++++++++++++++ .../app/entities/keyword/keyword.service.ts | 38 +++++++++ .../weapon-delete-dialog.component.html | 0 .../weapon/weapon-delete-dialog.component.ts | 30 +++++++ .../weapon/weapon-detail.component.html | 0 .../weapon/weapon-detail.component.ts | 26 ++++++ .../weapon/weapon-update.component.html | 0 .../weapon/weapon-update.component.ts | 67 +++++++++++++++ .../app/entities/weapon/weapon.component.html | 1 + .../app/entities/weapon/weapon.component.scss | 0 .../app/entities/weapon/weapon.component.ts | 15 ++++ .../app/entities/weapon/weapon.module.ts | 20 +++++ .../app/entities/weapon/weapon.route.ts | 75 +++++++++++++++++ .../app/entities/weapon/weapon.service.ts | 41 +++++++++ .../webapp/app/shared/model/keyword.model.ts | 16 ++++ .../webapp/app/shared/model/weapon.model.ts | 24 ++++++ 29 files changed, 676 insertions(+) create mode 100644 src/main/webapp/app/entities/keyword/keyword-delete-dialog.component.html create mode 100644 src/main/webapp/app/entities/keyword/keyword-delete-dialog.component.ts create mode 100644 src/main/webapp/app/entities/keyword/keyword-detail.component.html create mode 100644 src/main/webapp/app/entities/keyword/keyword-detail.component.ts create mode 100644 src/main/webapp/app/entities/keyword/keyword-update.component.html create mode 100644 src/main/webapp/app/entities/keyword/keyword-update.component.ts create mode 100644 src/main/webapp/app/entities/keyword/keyword.component.html create mode 100644 src/main/webapp/app/entities/keyword/keyword.component.scss create mode 100644 src/main/webapp/app/entities/keyword/keyword.component.ts create mode 100644 src/main/webapp/app/entities/keyword/keyword.module.ts create mode 100644 src/main/webapp/app/entities/keyword/keyword.route.ts create mode 100644 src/main/webapp/app/entities/keyword/keyword.service.ts create mode 100644 src/main/webapp/app/entities/weapon/weapon-delete-dialog.component.html create mode 100644 src/main/webapp/app/entities/weapon/weapon-delete-dialog.component.ts create mode 100644 src/main/webapp/app/entities/weapon/weapon-detail.component.html create mode 100644 src/main/webapp/app/entities/weapon/weapon-detail.component.ts create mode 100644 src/main/webapp/app/entities/weapon/weapon-update.component.html create mode 100644 src/main/webapp/app/entities/weapon/weapon-update.component.ts create mode 100644 src/main/webapp/app/entities/weapon/weapon.component.html create mode 100644 src/main/webapp/app/entities/weapon/weapon.component.scss create mode 100644 src/main/webapp/app/entities/weapon/weapon.component.ts create mode 100644 src/main/webapp/app/entities/weapon/weapon.module.ts create mode 100644 src/main/webapp/app/entities/weapon/weapon.route.ts create mode 100644 src/main/webapp/app/entities/weapon/weapon.service.ts create mode 100644 src/main/webapp/app/shared/model/keyword.model.ts create mode 100644 src/main/webapp/app/shared/model/weapon.model.ts diff --git a/src/main/java/com/warhammer/web/rest/UnitKeywordResource.java b/src/main/java/com/warhammer/web/rest/UnitKeywordResource.java index a3881e33..78750653 100644 --- a/src/main/java/com/warhammer/web/rest/UnitKeywordResource.java +++ b/src/main/java/com/warhammer/web/rest/UnitKeywordResource.java @@ -1,4 +1,60 @@ 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; + 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("/keywords") + public ResponseEntity 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("/keywords") + public List getAllKeywords() { + log.debug("REST request to get all unitkeywords"); + Optional userLogin = SecurityUtils.getCurrentUserLogin(); + return unitKeywordService.findAllByOwner(userLogin); + } + + @DeleteMapping("/dataslates/{id}") + public ResponseEntity 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(); + } } diff --git a/src/main/java/com/warhammer/web/rest/WeaponResource.java b/src/main/java/com/warhammer/web/rest/WeaponResource.java index 1be49897..f7ee0384 100644 --- a/src/main/java/com/warhammer/web/rest/WeaponResource.java +++ b/src/main/java/com/warhammer/web/rest/WeaponResource.java @@ -1,4 +1,24 @@ package com.warhammer.web.rest; +import com.warhammer.service.WeaponService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; + 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; + } + + } diff --git a/src/main/webapp/app/entities/entity.module.ts b/src/main/webapp/app/entities/entity.module.ts index 4f2a1526..3457a601 100644 --- a/src/main/webapp/app/entities/entity.module.ts +++ b/src/main/webapp/app/entities/entity.module.ts @@ -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 {} diff --git a/src/main/webapp/app/entities/keyword/keyword-delete-dialog.component.html b/src/main/webapp/app/entities/keyword/keyword-delete-dialog.component.html new file mode 100644 index 00000000..e69de29b diff --git a/src/main/webapp/app/entities/keyword/keyword-delete-dialog.component.ts b/src/main/webapp/app/entities/keyword/keyword-delete-dialog.component.ts new file mode 100644 index 00000000..7acc2a1f --- /dev/null +++ b/src/main/webapp/app/entities/keyword/keyword-delete-dialog.component.ts @@ -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(); + }) + } +} diff --git a/src/main/webapp/app/entities/keyword/keyword-detail.component.html b/src/main/webapp/app/entities/keyword/keyword-detail.component.html new file mode 100644 index 00000000..e69de29b diff --git a/src/main/webapp/app/entities/keyword/keyword-detail.component.ts b/src/main/webapp/app/entities/keyword/keyword-detail.component.ts new file mode 100644 index 00000000..768ada30 --- /dev/null +++ b/src/main/webapp/app/entities/keyword/keyword-detail.component.ts @@ -0,0 +1,28 @@ +import {Component, OnInit} from "@angular/core"; +import {IUser} from "../../core/user/user.model"; +import { FormBuilder, Validators } from '@angular/forms'; +import {JhiDataUtils, JhiEventManager} from "ng-jhipster"; +import {KeywordService} from "./keyword.service"; +import {ActivatedRoute} from "@angular/router"; +import {IKeyword} from "../../shared/model/keyword.model"; + +@Component({ + selector: 'jhi-keyword-update', + templateUrl: './keyword-detail.component.html', +}) +export class KeywordDetailComponent implements OnInit { + keyword: IKeyword | null = null; + + constructor(protected dataUtils: JhiDataUtils, + protected activatedRoute: ActivatedRoute) { + } + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ keyword }) => (this.keyword = keyword)); + } + + logger(msg: string): void { + console.log(msg); + } + +} diff --git a/src/main/webapp/app/entities/keyword/keyword-update.component.html b/src/main/webapp/app/entities/keyword/keyword-update.component.html new file mode 100644 index 00000000..e69de29b diff --git a/src/main/webapp/app/entities/keyword/keyword-update.component.ts b/src/main/webapp/app/entities/keyword/keyword-update.component.ts new file mode 100644 index 00000000..0e7fef1c --- /dev/null +++ b/src/main/webapp/app/entities/keyword/keyword-update.component.ts @@ -0,0 +1,60 @@ +import {Component, OnInit} from "@angular/core"; +import {JhiDataUtils, JhiEventManager} from "ng-jhipster"; +import {UserService} from "../../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 "../../core/user/user.model"; +import {IKeyword} from "../../shared/model/keyword.model"; + +@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.keywordService.query().subscribe((res: HttpResponse) => (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; + } + + trackById(index: number, item: IUser): any { + return item.id; + } +} diff --git a/src/main/webapp/app/entities/keyword/keyword.component.html b/src/main/webapp/app/entities/keyword/keyword.component.html new file mode 100644 index 00000000..78b7f843 --- /dev/null +++ b/src/main/webapp/app/entities/keyword/keyword.component.html @@ -0,0 +1 @@ +

keyword works!

diff --git a/src/main/webapp/app/entities/keyword/keyword.component.scss b/src/main/webapp/app/entities/keyword/keyword.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/src/main/webapp/app/entities/keyword/keyword.component.ts b/src/main/webapp/app/entities/keyword/keyword.component.ts new file mode 100644 index 00000000..6f982a0d --- /dev/null +++ b/src/main/webapp/app/entities/keyword/keyword.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'jhi-keyword', + templateUrl: './keyword.component.html', + styleUrls: ['./keyword.component.scss'] +}) +export class KeywordComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/main/webapp/app/entities/keyword/keyword.module.ts b/src/main/webapp/app/entities/keyword/keyword.module.ts new file mode 100644 index 00000000..028394c8 --- /dev/null +++ b/src/main/webapp/app/entities/keyword/keyword.module.ts @@ -0,0 +1,18 @@ +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 {KeywordDetailComponent} from "./keyword-detail.component"; +import {KeywordUpdateComponent} from "./keyword-update.component"; +import {KeywordDeleteDialogComponent} from "./keyword-delete-dialog.component"; + +@NgModule({ + imports: [CrusadetrackerSharedModule, RouterModule.forChild(keywordRoutes)], + declarations: [KeywordComponent, + KeywordDetailComponent, + KeywordUpdateComponent, + KeywordDeleteDialogComponent], + entryComponents: [] +}) +export class CrusadetrackerKeywordModule {} diff --git a/src/main/webapp/app/entities/keyword/keyword.route.ts b/src/main/webapp/app/entities/keyword/keyword.route.ts new file mode 100644 index 00000000..9fb96497 --- /dev/null +++ b/src/main/webapp/app/entities/keyword/keyword.route.ts @@ -0,0 +1,84 @@ +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 {KeywordDetailComponent} from './keyword-detail.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 { + constructor(private service: KeywordService, private router: Router) { + } + + resolve(route: ActivatedRouteSnapshot): Observable | Observable { + const id = route.params['id']; + if (id) { + return this.service.find(id).pipe( + flatMap((keyword: HttpResponse) => { + 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: ':id/view', + component: KeywordDetailComponent, + resolve: { + keyword: KeywordResolve, + }, + data: { + authorities: [Authority.USER], + pageTitle: 'Keyword', + }, + 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], + } +] diff --git a/src/main/webapp/app/entities/keyword/keyword.service.ts b/src/main/webapp/app/entities/keyword/keyword.service.ts new file mode 100644 index 00000000..548c3ad6 --- /dev/null +++ b/src/main/webapp/app/entities/keyword/keyword.service.ts @@ -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; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root'}) +export class KeywordService { + public resourceUrl = SERVER_API_URL + 'api/keywords'; + + constructor(protected http: HttpClient) { + } + + create(keyword: IKeyword): Observable { + return this.http.post(this.resourceUrl, keyword, {observe: 'response'}); + } + + update(keyword: IKeyword): Observable { + return this.http.put(this.resourceUrl, keyword, {observe: 'response'}); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, {observe: 'response'}); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, {params: options, observe: 'response'}); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, {observe: 'response'}); + } +} diff --git a/src/main/webapp/app/entities/weapon/weapon-delete-dialog.component.html b/src/main/webapp/app/entities/weapon/weapon-delete-dialog.component.html new file mode 100644 index 00000000..e69de29b diff --git a/src/main/webapp/app/entities/weapon/weapon-delete-dialog.component.ts b/src/main/webapp/app/entities/weapon/weapon-delete-dialog.component.ts new file mode 100644 index 00000000..7f42663e --- /dev/null +++ b/src/main/webapp/app/entities/weapon/weapon-delete-dialog.component.ts @@ -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(); + }) + } +} diff --git a/src/main/webapp/app/entities/weapon/weapon-detail.component.html b/src/main/webapp/app/entities/weapon/weapon-detail.component.html new file mode 100644 index 00000000..e69de29b diff --git a/src/main/webapp/app/entities/weapon/weapon-detail.component.ts b/src/main/webapp/app/entities/weapon/weapon-detail.component.ts new file mode 100644 index 00000000..01662be8 --- /dev/null +++ b/src/main/webapp/app/entities/weapon/weapon-detail.component.ts @@ -0,0 +1,26 @@ +import {Component, OnInit} from "@angular/core"; +import {IWeapon} from "../../shared/model/weapon.model"; +import {JhiDataUtils} from "ng-jhipster"; +import {ActivatedRoute} from "@angular/router"; + +@Component({ + selector: 'jhi-weapon-update', + templateUrl: './weapon-detail.component.html', +}) +export class WeaponDetailComponent implements OnInit { + weapon: IWeapon | null = null; + + constructor( + protected dataUtils: JhiDataUtils, + protected activatedRoute: ActivatedRoute + ) { + } + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ weapon }) => (this.weapon = weapon )); + } + + logger(msg: string): void { + console.log(msg); + } +} diff --git a/src/main/webapp/app/entities/weapon/weapon-update.component.html b/src/main/webapp/app/entities/weapon/weapon-update.component.html new file mode 100644 index 00000000..e69de29b diff --git a/src/main/webapp/app/entities/weapon/weapon-update.component.ts b/src/main/webapp/app/entities/weapon/weapon-update.component.ts new file mode 100644 index 00000000..dec0f4ae --- /dev/null +++ b/src/main/webapp/app/entities/weapon/weapon-update.component.ts @@ -0,0 +1,67 @@ +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} from "../../shared/model/weapon.model"; + +@Component({ + selector: 'jhi-weapon-update', + templateUrl: './weapon-update.component.html', +}) +export class WeaponUpdateComponent implements OnInit { + isSaving = false; + users: IUser[] = []; + + 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.weaponService.query().subscribe((res: HttpResponse) => 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; + } + + trackById(index: number, item: IUser): any { + return item.id; + } +} diff --git a/src/main/webapp/app/entities/weapon/weapon.component.html b/src/main/webapp/app/entities/weapon/weapon.component.html new file mode 100644 index 00000000..60de2be9 --- /dev/null +++ b/src/main/webapp/app/entities/weapon/weapon.component.html @@ -0,0 +1 @@ +

weapon works!

diff --git a/src/main/webapp/app/entities/weapon/weapon.component.scss b/src/main/webapp/app/entities/weapon/weapon.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/src/main/webapp/app/entities/weapon/weapon.component.ts b/src/main/webapp/app/entities/weapon/weapon.component.ts new file mode 100644 index 00000000..a6711f25 --- /dev/null +++ b/src/main/webapp/app/entities/weapon/weapon.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'jhi-weapon', + templateUrl: './weapon.component.html', + styleUrls: ['./weapon.component.scss'] +}) +export class WeaponComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/main/webapp/app/entities/weapon/weapon.module.ts b/src/main/webapp/app/entities/weapon/weapon.module.ts new file mode 100644 index 00000000..b7646e9b --- /dev/null +++ b/src/main/webapp/app/entities/weapon/weapon.module.ts @@ -0,0 +1,20 @@ +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 {WeaponDetailComponent} from "./weapon-detail.component"; +import {WeaponUpdateComponent} from "./weapon-update.component"; +import {WeaponDeleteDialogComponent} from "./weapon-delete-dialog.component"; + +@NgModule({ + imports: [CrusadetrackerSharedModule, RouterModule.forChild(weaponRoutes)], + declarations: [ + WeaponComponent, + WeaponDetailComponent, + WeaponUpdateComponent, + WeaponDeleteDialogComponent + ], + entryComponents: [] +}) +export class CrusadetrackerWeaponModule {} diff --git a/src/main/webapp/app/entities/weapon/weapon.route.ts b/src/main/webapp/app/entities/weapon/weapon.route.ts new file mode 100644 index 00000000..94569b45 --- /dev/null +++ b/src/main/webapp/app/entities/weapon/weapon.route.ts @@ -0,0 +1,75 @@ +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 {WeaponDetailComponent} from "./weapon-detail.component"; +import {WeaponUpdateComponent} from "./weapon-update.component"; + +@Injectable({ providedIn: 'root'}) +export class WeaponResolve implements Resolve { + constructor(private service: WeaponService, private router: Router) { + } + + resolve(route: ActivatedRouteSnapshot): Observable | Observable { + const id = route.params['id']; + if (id) { + return this.service.find(id).pipe( + flatMap((weapon: HttpResponse) => { + 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: ':id/view', + component: WeaponDetailComponent, + 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], + }, +] diff --git a/src/main/webapp/app/entities/weapon/weapon.service.ts b/src/main/webapp/app/entities/weapon/weapon.service.ts new file mode 100644 index 00000000..dbf6e52f --- /dev/null +++ b/src/main/webapp/app/entities/weapon/weapon.service.ts @@ -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; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root'}) +export class WeaponService { + public resourceUrl = SERVER_API_URL + 'api/weapons'; + + constructor(protected http: HttpClient) { + } + + create(weapon: IWeapon): Observable { + return this.http.post(this.resourceUrl, weapon, {observe: 'response'}); + } + + update(weapon: IWeapon): Observable { + return this.http.put(this.resourceUrl, weapon, {observe: 'response'}); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, {observe: 'response'}); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, {params: options, observe: 'response'}); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, {observe: `response`}); + } + +} diff --git a/src/main/webapp/app/shared/model/keyword.model.ts b/src/main/webapp/app/shared/model/keyword.model.ts new file mode 100644 index 00000000..6fcf7335 --- /dev/null +++ b/src/main/webapp/app/shared/model/keyword.model.ts @@ -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, + ) { + } +} diff --git a/src/main/webapp/app/shared/model/weapon.model.ts b/src/main/webapp/app/shared/model/weapon.model.ts new file mode 100644 index 00000000..e3ea739c --- /dev/null +++ b/src/main/webapp/app/shared/model/weapon.model.ts @@ -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 + ) { + } +}