Skip to content

Commit

Permalink
Commit Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sayoungestguy committed Oct 13, 2024
1 parent 3f0fa56 commit cf638e7
Show file tree
Hide file tree
Showing 11 changed files with 294 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public PasswordEncoder passwordEncoder() {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http, MvcRequestMatcher.Builder mvc) throws Exception {
http
.cors(withDefaults())
//.cors(withDefaults())
.csrf(csrf -> csrf.disable())
.addFilterAfter(new SpaWebFilter(), BasicAuthenticationFilter.class)
.headers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ public ActivityQueryService(ActivityRepository activityRepository, ActivityMappe
@Transactional(readOnly = true)
public Page<ActivityDTO> findByCriteria(ActivityCriteria criteria, Pageable page) {
log.debug("find by criteria : {}, page: {}", criteria, page);
User currentUser = userService.getUserById().orElseThrow(() -> new UsernameNotFoundException("User not found"));
boolean isAdmin = SecurityUtils.isCurrentUserInRole(AuthoritiesConstants.ADMIN);
if (currentUser != null && !isAdmin) {
// Set the creatorProfileId in the criteria to match the current user
if (criteria == null) {
criteria = new ActivityCriteria();
}
LongFilter userFilter = new LongFilter();
userFilter.setEquals(currentUser.getId());
criteria.setCreatorProfileId(userFilter);
}
// User currentUser = userService.getUserById().orElseThrow(() -> new UsernameNotFoundException("User not found"));
// boolean isAdmin = SecurityUtils.isCurrentUserInRole(AuthoritiesConstants.ADMIN);
// if (currentUser != null && !isAdmin) {
// // Set the creatorProfileId in the criteria to match the current user
// if (criteria == null) {
// criteria = new ActivityCriteria();
// }
// LongFilter userFilter = new LongFilter();
// userFilter.setEquals(currentUser.getId());
// criteria.setCreatorProfileId(userFilter);
// }
final Specification<Activity> specification = createSpecification(criteria);
return activityRepository.findAll(specification, page).map(activityMapper::toDto);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/webapp/app/config/icon-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
faUsers,
faUsersCog,
faWrench,
faEnvelope,
} from '@fortawesome/free-solid-svg-icons';

import { library } from '@fortawesome/fontawesome-svg-core';
Expand Down Expand Up @@ -71,5 +72,6 @@ export const loadIcons = () => {
faUsers,
faUsersCog,
faWrench,
faEnvelope,
);
};
22 changes: 13 additions & 9 deletions src/main/webapp/app/entities/activity/activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export const Activity = () => {

const activityList = useAppSelector(state => state.activity.entities);
const loading = useAppSelector(state => state.activity.loading);
// Assuming the user's roles are stored in the authentication state
const currentUser = useAppSelector(state => state.authentication.account);

// Check if the current user has the "admin" role
const isAdmin = currentUser?.authorities?.includes('ROLE_ADMIN');

const [currentActivities, setCurrentActivities] = useState([]);
const [pastActivities, setPastActivities] = useState([]);
Expand All @@ -47,9 +52,14 @@ export const Activity = () => {

const getAllActivities = () => {
dispatch(
getAllActivity({
sort: `${currentPaginationState.sort},${currentPaginationState.order}`,
}),
getAllActivity(
isAdmin
? { sort: `${currentPaginationState.sort},${currentPaginationState.order}` }
: {
sort: `${currentPaginationState.sort},${currentPaginationState.order}`,
query: `creatorProfileId.equals=${currentUser.id.toString()}`,
},
),
);
};

Expand Down Expand Up @@ -193,12 +203,6 @@ export const Activity = () => {
}
}, [currentActivities, pastActivities]);

// Assuming the user's roles are stored in the authentication state
const currentUser = useAppSelector(state => state.authentication.account);

// Check if the current user has the "admin" role
const isAdmin = currentUser?.authorities?.includes('ROLE_ADMIN');

return (
<div>
<h2 id="activity-heading" data-cy="ActivityHeading">
Expand Down
19 changes: 11 additions & 8 deletions src/main/webapp/app/entities/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,30 @@ const EntitiesMenu = () => {
{/*<MenuItem icon="asterisk" to="/code-tables">*/}

Check warning on line 9 in src/main/webapp/app/entities/menu.tsx

View workflow job for this annotation

GitHub Actions / Frontend Test Stage

Expected space or tab after '/*' in comment
{/* Code Tables*/}
{/*</MenuItem>*/}
<MenuItem icon="asterisk" to="/user-profile">
<MenuItem icon="user" to="/user-profile">
User Profile
</MenuItem>
<MenuItem icon="asterisk" to="/skill">
<MenuItem icon="pencil-alt" to="/skill">
Skill
</MenuItem>
<MenuItem icon="asterisk" to="/message">
<MenuItem icon="envelope" to="/message">
Message
</MenuItem>
<MenuItem icon="asterisk" to="/activity">
<MenuItem icon="book" to="/activity">
Activity
</MenuItem>
<MenuItem icon="asterisk" to="/activity-invite">
<MenuItem icon="people-arrows" to="/activity-invite">
Activity Invite
</MenuItem>
<MenuItem icon="asterisk" to="/notification">
Notification
</MenuItem>
{/*<MenuItem icon="asterisk" to="/notification">*/}
{/* Notification*/}
{/*</MenuItem>*/}
<MenuItem icon="asterisk" to="/user-skill">
User Skill
</MenuItem>
<MenuItem icon="search" to="/search">
Search
</MenuItem>
{/* jhipster-needle-add-entity-to-menu - JHipster will add entities to the menu here */}
</>
);
Expand Down
2 changes: 2 additions & 0 deletions src/main/webapp/app/entities/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Activity from './activity';
import ActivityInvite from './activity-invite';
import Notification from './notification';
import UserSkill from './user-skill';
import SearchAppActivity from 'app/entities/search/searchAppActivity';
/* jhipster-needle-add-route-import - JHipster will add routes here */

export default () => {
Expand All @@ -26,6 +27,7 @@ export default () => {
<Route path="activity-invite/*" element={<ActivityInvite />} />
<Route path="notification/*" element={<Notification />} />
<Route path="user-skill/*" element={<UserSkill />} />
<Route path="search/*" element={<SearchAppActivity />} />
{/* jhipster-needle-add-route-path - JHipster will add routes here */}
</ErrorBoundaryRoutes>
</div>
Expand Down
38 changes: 38 additions & 0 deletions src/main/webapp/app/entities/search/commonNameCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Card, CardBody, CardText } from 'reactstrap';
import React from 'react';

export const CommonNameCard = ({ key, id, profilePic, nickname, jobRole }) => {
return (
<>
<Card
style={{
border: '2px solid navy',
borderRadius: '10px',
width: '300px',
padding: '10px',
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
}}
>
{/* Display Picture Placeholder */}
<div
style={{
width: '50px',
height: '50px',
borderRadius: '50%',
backgroundColor: '#ccc',
marginRight: '15px',
}}
></div>
{/* Nickname and Job Role */}
<CardBody style={{ padding: '0' }}>
<h5 style={{ margin: '0', color: 'navy' }}>{nickname}</h5>
<CardText style={{ margin: '0', color: '#666' }}>{jobRole}</CardText>
</CardBody>
</Card>
</>
);
};

export default CommonNameCard;
12 changes: 12 additions & 0 deletions src/main/webapp/app/entities/search/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import ErrorBoundaryRoutes from 'app/shared/error/error-boundary-routes';
import { Route } from 'react-router-dom';
import React from 'react';
import SearchAppActivity from 'app/entities/search/searchAppActivity';

const SearchAppActivityRoutes = () => (
<ErrorBoundaryRoutes>
<Route index element={<SearchAppActivity />} />
</ErrorBoundaryRoutes>
);

export default SearchAppActivityRoutes;
Loading

0 comments on commit cf638e7

Please sign in to comment.