Commit 9ecd0aba authored by Jiri Novotny's avatar Jiri Novotny
Browse files

Final preparations

parent 710de1f8
Pipeline #142699 passed with stage
in 1 minute and 25 seconds
This diff is collapsed.
......@@ -6,74 +6,78 @@ import { Link } from 'react-router-dom';
export function Agent (props: any){
return(
<Card style={{ width: '80%', marginTop:"1rem"}}>
<Card.Header as="h5">
<img src={ serviceImage } width="40px" height="40px"/>
{ props.codeName }
</Card.Header>
<Row>
<Col>
<Card.Title>Skills</Card.Title>
<Row>
<Col md={{ span: 8, offset: 2 }}>
<Card className='mt-4'>
<Card.Header as="h5">
<img src={ serviceImage } width="40px" height="40px"/>
{ props.codeName }
</Card.Header>
<Row>
<Col>
<Card.Subtitle className="mb-2 text-muted">Language</Card.Subtitle>
<ListGroup variant="flush">
{ props.skills.filter((skill: any) => skill.type === "LANGUAGE").map((skill: any) => {
return(
<ListGroup.Item>{ skill.name }</ListGroup.Item>
)
})}
</ListGroup>
<Card.Title>Skills</Card.Title>
<Row>
<Col>
<Card.Subtitle className="mb-2 text-muted">Language</Card.Subtitle>
<ListGroup variant="flush">
{ props.skills.filter((skill: any) => skill.type === "LANGUAGE").map((skill: any) => {
return(
<ListGroup.Item>{ skill.name }</ListGroup.Item>
)
})}
</ListGroup>
</Col>
<Col>
<Card.Subtitle className="mb-2 text-muted">Weapon</Card.Subtitle>
<ListGroup variant="flush">
{ props.skills.filter((skill: any) => skill.type === "WEAPON").map((skill: any) => {
return(
<ListGroup.Item>{ skill.name }</ListGroup.Item>
)
})}
</ListGroup>
</Col>
</Row>
</Col>
<Col>
<Card.Subtitle className="mb-2 text-muted">Weapon</Card.Subtitle>
<ListGroup variant="flush">
{ props.skills.filter((skill: any) => skill.type === "WEAPON").map((skill: any) => {
return(
<ListGroup.Item>{ skill.name }</ListGroup.Item>
)
})}
</ListGroup>
<Card.Title>Trainings</Card.Title>
<Row>
<Col>
<Card.Subtitle className="mb-2 text-muted">Basic</Card.Subtitle>
<ListGroup variant="flush">
{ props.trainings.filter((training: any) => training.difficulty === "EASY").map((training: any) => {
return(
<ListGroup.Item>{ training.name }</ListGroup.Item>
)
})}
</ListGroup>
</Col>
<Col>
<Card.Subtitle className="mb-2 text-muted">Intermediate</Card.Subtitle>
<ListGroup variant="flush">
{ props.trainings.filter((training: any) => training.difficulty === "MEDIUM").map((training: any) => {
return(
<ListGroup.Item>{ training.name }</ListGroup.Item>
)
})}
</ListGroup>
</Col>
<Col>
<Card.Subtitle className="mb-2 text-muted">Advanced</Card.Subtitle>
<ListGroup variant="flush">
{ props.trainings.filter((training: any) => training.difficulty === "HARD").map((training: any) => {
return(
<ListGroup.Item>{ training.name }</ListGroup.Item>
)
})}
</ListGroup>
</Col>
</Row>
</Col>
</Row>
</Col>
<Col>
<Card.Title>Trainings</Card.Title>
<Row>
<Col>
<Card.Subtitle className="mb-2 text-muted">Basic</Card.Subtitle>
<ListGroup variant="flush">
{ props.trainings.filter((training: any) => training.difficulty === "EASY").map((training: any) => {
return(
<ListGroup.Item>{ training.name }</ListGroup.Item>
)
})}
</ListGroup>
</Col>
<Col>
<Card.Subtitle className="mb-2 text-muted">Intermediate</Card.Subtitle>
<ListGroup variant="flush">
{ props.trainings.filter((training: any) => training.difficulty === "MEDIUM").map((training: any) => {
return(
<ListGroup.Item>{ training.name }</ListGroup.Item>
)
})}
</ListGroup>
</Col>
<Col>
<Card.Subtitle className="mb-2 text-muted">Advanced</Card.Subtitle>
<ListGroup variant="flush">
{ props.trainings.filter((training: any) => training.difficulty === "HARD").map((training: any) => {
return(
<ListGroup.Item>{ training.name }</ListGroup.Item>
)
})}
</ListGroup>
</Col>
</Row>
</Col>
</Row>
<Button component={Link} to={"/agent/" + props.agentId}>Got to agent</Button>
</Card>
<Button component={Link} to={"/agent/" + props.agentId}>Go to agent</Button>
</Card>
</Col>
</Row>
)
}
\ No newline at end of file
......@@ -29,7 +29,13 @@ export function AgentDetail() {
}
const agentData = res.data;
setAgent(agentData);
});
})
.catch(error => {
if (error.response.status == 403) {
navigate('/forbidden');
}
console.log(error.response.status)
});
},[]);
if (agent === null) {
......
......@@ -21,7 +21,7 @@ export function AgentInMission (props: any){
useEffect(() => {
if (reportId) {
axios.get(`/rest/reports/reports` + reportId, {
axios.get(`/rest/reports/reports/` + reportId, {
headers: {
'Authorization': 'Bearer ' + sessionStorage.getItem('access_token')
}
......@@ -32,7 +32,13 @@ export function AgentInMission (props: any){
}
const reportData = res.data;
setReport(reportData);
});
})
.catch(error => {
if (error.response.status == 403) {
navigate('/forbidden');
}
console.log(error.response.status)
});
}
},[reportId]);
......@@ -99,7 +105,7 @@ export function AgentInMission (props: any){
)
})}
</Card.Text>
<Link to={"/agent/" + props.agentId}>Got to agent</Link>
<Link to={"/agent/" + props.agentId}>Go to agent</Link>
</Card.Body>
</Card>
......
......@@ -20,13 +20,14 @@ export function AgentsList () {
}
})
.then(res => {
if (res.status == 403) {
navigate('/forbidden');
}
const agentData = res.data;
setAgents(agentData);
});
console.log(agents)
}).catch(error => {
if (error.response.status == 403) {
navigate('/forbidden');
}
console.log(error.response.status)
});
},[page]);
if (agents === null) {
......@@ -46,13 +47,13 @@ export function AgentsList () {
agentId={ agent.id }/>
);
}) }
<Row>
<Col md="2">
<Row className='mt-2'>
<Col md={{ span: 2, offset: 2 }}>
<Button onClick={ () => setPage(page - 1) } disabled={ page === 0} variant="outline-dark">
<FontAwesomeIcon icon={solid('angle-left')} /> Previous
</Button>
</Col>
<Col md="8">
<Col md="4">
<p> Page {page + 1} of { agents.totalPageCount}</p>
</Col>
<Col md="2">
......
......@@ -19,7 +19,6 @@ export function FindAvailableAgents() {
const searchForAgent = useCallback (()=>{
if (picked.country !== null && (picked.skill === null || picked.skill === '')) {
console.log("country", picked.country)
axios.get(`/rest/agents/countries/`+ picked.country.id + `?page=0&pageSize=5`, {
headers: {
'Authorization': 'Bearer ' + sessionStorage.getItem('access_token')
......@@ -31,11 +30,16 @@ export function FindAvailableAgents() {
}
const agents = res.data;
setResult(agents);
});
})
.catch(error => {
if (error.response.status == 403) {
navigate('/forbidden');
}
console.log(error.response.status)
});
}
if (picked.skill !== null && (picked.country === null || picked.country === '')){
console.log("skill", picked.skill)
axios.get(`/rest/agents/skills/` + picked.skill.id + `?page=0&pageSize=5`, {
headers: {
'Authorization': 'Bearer ' + sessionStorage.getItem('access_token')
......@@ -47,11 +51,16 @@ export function FindAvailableAgents() {
}
const skillsData = res.data;
setSkills(skillsData);
});
})
.catch(error => {
if (error.response.status == 403) {
navigate('/forbidden');
}
console.log(error.response.status)
});
}
if ((picked.skill !== null && picked.skill !== '') && (picked.country !== null && picked.country !== '')){
console.log("both", picked.country.id, picked.skill.id);
axios.get(`/rest/agents/countries/` + picked.country.id + `/skills/` + picked.skill.id + `?page=0&pageSize=10`, {
headers: {
'Authorization': 'Bearer ' + sessionStorage.getItem('access_token')
......@@ -63,10 +72,15 @@ export function FindAvailableAgents() {
}
const skillsData = res.data;
setSkills(skillsData);
});
})
.catch(error => {
if (error.response.status == 403) {
navigate('/forbidden');
}
console.log(error.response.status)
});
}
if (!(picked.skill !== null || picked.skill !== '') && !(picked.country !== null && picked.country !== '')) {
console.log("none");
setResult({data: []});
}
},[picked]);
......@@ -83,7 +97,13 @@ export function FindAvailableAgents() {
}
const skillsData = res.data;
setSkills(skillsData);
});
})
.catch(error => {
if (error.response.status == 403) {
navigate('/forbidden');
}
console.log(error.response.status)
});;
axios.get(`/rest/countries/allCountries?page=0&pageSize=0`, {
headers: {
......@@ -96,7 +116,13 @@ export function FindAvailableAgents() {
}
const countryData = res.data;
setCountries(countryData);
});
})
.catch(error => {
if (error.response.status == 403) {
navigate('/forbidden');
}
console.log(error.response.status)
});
},[]);
......@@ -135,7 +161,6 @@ export function FindAvailableAgents() {
} } className="btn btn-primary">Search</button>
</Col>
</Row>
<div className="agentList">
{ result.data.map((agent: any) => {
return(
<Agent codeName={ agent.codeName }
......@@ -144,7 +169,7 @@ export function FindAvailableAgents() {
agentId={ agent.id }/>
);
}) }
</div>
</div>
)
}
......
......@@ -34,7 +34,8 @@ export function Home (props: any) {
You can explore your agent details.
</Card.Text>
<div className="d-gridx mt-3 text-center">
<Link to={"/agents"} className="btn btn-outline-primary btn-m">
<Link to={"/agents"} className={ sessionStorage.getItem("username") === "agent" ? "btn disabled btn-outline-primary btn-m"
: "btn btn-outline-primary btn-m" }>
Visit Agents
</Link>
</div>
......@@ -57,13 +58,14 @@ export function Home (props: any) {
You can explore ongoing and finished missions.
</Card.Text>
<div className="d-gridx mt-3 text-center">
<Link to={"/missions"} className="btn btn-outline-primary btn-m">
<Link to={"/missions"} className={ sessionStorage.getItem("username") === "agent" ? "btn disabled btn-outline-primary btn-m"
: "btn btn-outline-primary btn-m" }>
Visit Missions
</Link>
</div>
</Card.Body>
<Card.Footer>
<small className="text-muted">Available for all agents </small>
<small className="text-muted">Available for operator </small>
</Card.Footer>
</Card>
<Card>
......@@ -80,7 +82,8 @@ export function Home (props: any) {
You can find agnets, which are currently free.
</Card.Text>
<div className="d-gridx mt-3 text-center">
<Link to={"/agents"} className="btn btn-outline-primary btn-m">
<Link to={"/findAgent"} className={ sessionStorage.getItem("username") === "agent" ? "btn disabled btn-outline-primary btn-m"
: "btn btn-outline-primary btn-m" }>
Find Free Agents
</Link>
</div>
......
......@@ -28,8 +28,8 @@ export function LogIn(props: ILogInProps) {
data: 'client_id=archive-login&username=' + event.target.username.value + '&password=' + event.target.username.value + '&grant_type=password&client_secret=mrmAhajtblAVVAQ8whrylOYQrN1W0axk'
})
.then(function (response) {
console.log(response.data.access_token);
sessionStorage.setItem("access_token",response.data.access_token);
sessionStorage.setItem("username",event.target.username.value);
navigate(`/home`);
props.main.setState({userName: event.target.username.value});
})
......@@ -47,6 +47,7 @@ export function LogIn(props: ILogInProps) {
console.log('Error', error.message);
}
sessionStorage.removeItem("access_token");
sessionStorage.removeItem("username");
alert("invalid username or password")
});
}
......
......@@ -55,19 +55,5 @@ export class Main extends Component<IMainProps, IMainState>{
</Routes>
</div>
)
// if (!this.state.loggedIn) {
// return(
// <div>
// <LogIn main={ this }/>
// </div>
// )
// } else {
// return(
// <div>
// <NavBar main= { this }/>
// <Content/>
// </div>
// )
// }
}
}
\ No newline at end of file
......@@ -23,12 +23,15 @@ export function MissionDetail() {
}
})
.then(res => {
if (res.status == 403) {
navigate('/forbidden');
}
const missionData = res.data;
setMission(missionData);
});
})
.catch(error => {
if (error.response.status == 403) {
navigate('/forbidden');
}
console.log(error.response.status)
});
},[]);
if (mission === null) {
......@@ -39,18 +42,6 @@ export function MissionDetail() {
)
} else {
return(
// <div>
// <h2> { mission[`codeName`] } </h2>
// <h4>Agents</h4>
// { mission[`agents`].map((agent: any) => {
// return(
// <AgentInMission codeName={ agent.agentCodeName.codename }
// startDate={ agent.startDate }
// endDate={ agent.endDate }
// agentId={ agent.agentCodeName.id }/>
// );
// }) }
// </div>
<div >
<h2>
{ mission[`codeName`] }
......
......@@ -28,7 +28,7 @@ export function MissionInAgent (props: any){
<Card.Text>
To: { props.endDate }
</Card.Text>
<Button component={Link} to={"/mission/" + props.missionId}>Got to mission</Button>
{sessionStorage.getItem("username") === "agent" ? <></> : <Button component={Link} to={"/mission/" + props.missionId}>Go to mission</Button> }
</Card.Body>
</Card>
)
......
......@@ -14,35 +14,21 @@ export function MissionsList () {
const navigate = useNavigate();
useEffect(() => {
console.log('Bearer ' + sessionStorage.getItem('access_token'));
axios.get(`/rest/missions/allMissions?page=` + page + `&pageSize=18`, {
headers: {
'Authorization': 'Bearer ' + sessionStorage.getItem('access_token')
}
})
.then(res => {
if (res.status == 403) {
navigate('/forbidden');
}
const agentData = res.data;
setMissions(agentData);
})
.catch(function (error) {
if (error.response) {
// Request made and server responded
console.log(error.response.data);
console.log(error.response.status);
console.log(error.response.headers);
} else if (error.request) {
// The request was made but no response was received
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error', error.message);
.catch(error => {
if (error.response.status == 403) {
navigate('/forbidden');
}
});;
console.log(missions)
console.log(error.response.status)
});
},[page]);
if (missions === null) {
......@@ -70,12 +56,12 @@ export function MissionsList () {
}) }
</div>
<Row>
<Col md="2">
<Col md={{ span: 2, offset: 1 }}>
<Button onClick={ () => setPage(page - 1) } disabled={ page === 0} variant="outline-dark">
<FontAwesomeIcon icon={solid('angle-left')} /> Previous
</Button>
</Col>
<Col md="8">
<Col md="6">
<p> Page {page + 1} of { missions.totalPageCount}</p>
</Col>
<Col md="2">
......
......@@ -17,10 +17,6 @@ export class NavBar extends Component<INavBarProps, INavBarState>{
super(props);
this.state = {
}
this.onLogOut = this.onLogOut.bind(this);
}
onLogOut(){
}
render(){
......@@ -38,10 +34,17 @@ export class NavBar extends Component<INavBarProps, INavBarState>{
/>{' '}
Secret Service Archive
</Navbar.Brand>
{
sessionStorage.getItem("username") === "agent" ? <></> :
<Nav className="me-auto">
<Nav.Link href="/pa165/agents">Agents</Nav.Link>
<Nav.Link href="/pa165/missions">Missions</Nav.Link>
<Nav.Link href="/pa165/findAgent">Find Available Agent</Nav.Link>
<Nav.Link href="/pa165/agents">Agents</Nav.Link>
<Nav.Link href="/pa165/missions">Missions</Nav.Link>
<Nav.Link href="/pa165/findAgent">Find Available Agent</Nav.Link>
</Nav>
}
<Nav className="justify-content-end ">
{ sessionStorage.getItem("username") === "agent" ? <Nav.Link href="/pa165/agent/1">My profile</Nav.Link> : <></> }
<Nav.Link href="/pa165/" onClick={ () => sessionStorage.removeItem("access_token") }>Log Out</Nav.Link>
</Nav>
</Container>
</Navbar>
......@@ -60,8 +63,8 @@ export class NavBar extends Component<INavBarProps, INavBarState>{
/>{' '}
Secret Service Archive
</Navbar.Brand>
<Nav className="me-auto">
<Nav.Link href="/pa165/login">Log In</Nav.Link>
<Nav className="justify-content-end">
<Nav.Link href="/pa165/login" >Log In</Nav.Link>
</Nav>
</Container>
</Navbar>
......