Added template for angular files
This commit is contained in:
parent
fb5584615c
commit
e9e8016249
@ -1,4 +1,60 @@
|
|||||||
package com.warhammer.web.rest;
|
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 {
|
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<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("/keywords")
|
||||||
|
public List<UnitKeywordDTO> getAllKeywords() {
|
||||||
|
log.debug("REST request to get all unitkeywords");
|
||||||
|
Optional<String> userLogin = SecurityUtils.getCurrentUserLogin();
|
||||||
|
return unitKeywordService.findAllByOwner(userLogin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/dataslates/{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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,24 @@
|
|||||||
package com.warhammer.web.rest;
|
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 {
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
|
// import { WeaponComponent } from './weapon/weapon.component';
|
||||||
|
// import { KeywordComponent } from './keyword/keyword.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@ -16,8 +18,17 @@ import { RouterModule } from '@angular/router';
|
|||||||
path: 'force',
|
path: 'force',
|
||||||
loadChildren: () => import('./force/force.module').then(m => m.CrusadetrackerForceModule),
|
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 */
|
/* jhipster-needle-add-entity-route - JHipster will add entity modules routes here */
|
||||||
]),
|
]),
|
||||||
],
|
],
|
||||||
|
// declarations: [WeaponComponent, KeywordComponent],
|
||||||
})
|
})
|
||||||
export class CrusadetrackerEntityModule {}
|
export class CrusadetrackerEntityModule {}
|
||||||
|
@ -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,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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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<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;
|
||||||
|
}
|
||||||
|
|
||||||
|
trackById(index: number, item: IUser): any {
|
||||||
|
return item.id;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
<p>keyword works!</p>
|
15
src/main/webapp/app/entities/keyword/keyword.component.ts
Normal file
15
src/main/webapp/app/entities/keyword/keyword.component.ts
Normal file
@ -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 {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
src/main/webapp/app/entities/keyword/keyword.module.ts
Normal file
18
src/main/webapp/app/entities/keyword/keyword.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 {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 {}
|
84
src/main/webapp/app/entities/keyword/keyword.route.ts
Normal file
84
src/main/webapp/app/entities/keyword/keyword.route.ts
Normal file
@ -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<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: ':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],
|
||||||
|
}
|
||||||
|
]
|
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/keywords';
|
||||||
|
|
||||||
|
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,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,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);
|
||||||
|
}
|
||||||
|
}
|
@ -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<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;
|
||||||
|
}
|
||||||
|
|
||||||
|
trackById(index: number, item: IUser): any {
|
||||||
|
return item.id;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
<p>weapon works!</p>
|
15
src/main/webapp/app/entities/weapon/weapon.component.ts
Normal file
15
src/main/webapp/app/entities/weapon/weapon.component.ts
Normal file
@ -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 {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
20
src/main/webapp/app/entities/weapon/weapon.module.ts
Normal file
20
src/main/webapp/app/entities/weapon/weapon.module.ts
Normal file
@ -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 {}
|
75
src/main/webapp/app/entities/weapon/weapon.route.ts
Normal file
75
src/main/webapp/app/entities/weapon/weapon.route.ts
Normal file
@ -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<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: ':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],
|
||||||
|
},
|
||||||
|
]
|
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/weapons';
|
||||||
|
|
||||||
|
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`});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
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