Skip to content

Commit

Permalink
Merge branch 'deployment/naxa' into meta-update-rapid-pr
Browse files Browse the repository at this point in the history
  • Loading branch information
varun2948 authored Nov 27, 2023
2 parents e5f89c6 + c45151d commit 84d7caf
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 20 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build_and_deploy_backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build and Deploy Tasking Manager Backend

on:
push:
branches:
- deployment/naxa
paths:
- "backend/**"
workflow_dispatch:

jobs:
deploy:
name: Deploy to Server
runs-on: [ubuntu-latest]
steps:
- name: Clone repository
uses: actions/checkout@v3

- name: Recreate Services
uses: appleboy/ssh-action@master
with:
host: ${{ vars.SERVER_IP }}
username: ${{ vars.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
command_timeout: 20m
script: |
echo '==In Server=='
echo '==Building Backend=='
cd /home/ubuntu/Projects/tasking-manager
git pull naxa deployment/naxa
docker compose build --no-cache backend
docker compose up -d --force-recreate
39 changes: 39 additions & 0 deletions .github/workflows/build_and_deploy_frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and Deploy Tasking Manager Frontend

on:
push:
branches:
- deployment/naxa
paths:
- "frontend/**"
workflow_dispatch:

jobs:
deploy:
name: Deploy to Server
runs-on: [ubuntu-latest]
steps:
- name: Clone repository
uses: actions/checkout@v3

- name: SSH Run command
uses: appleboy/ssh-action@master
with:
host: ${{ vars.SERVER_IP }}
username: ${{ vars.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
command_timeout: 20m
script: |
#!/bin/bash -i
echo '==In Server=='
echo '==Building Frontend=='
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
cd /home/ubuntu/Projects/tasking-manager
git pull naxa deployment/naxa
cd /home/ubuntu/Projects/tasking-manager/frontend
nvm i 16
nvm use 16
npm i -g yarn
yarn install
npm run build
3 changes: 1 addition & 2 deletions backend/api/teams/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ def delete(self, team_id):
"SubCode": "UserNotTeamManager",
}, 401

TeamService.delete_team(team_id)
return {"Success": "Team deleted"}, 200
return TeamService.delete_team(team_id)


class TeamsAllAPI(Resource):
Expand Down
6 changes: 5 additions & 1 deletion backend/services/team_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,12 @@ def delete_team(team_id: int):

if team.can_be_deleted():
team.delete()
return {"Success": "Team deleted"}, 200
else:
raise TeamServiceError("Team has projects, cannot be deleted")
return {
"Error": "Team has projects, cannot be deleted",
"SubCode": "This team has projects associated. Before deleting a team, unlink any associated projects."
}, 400

@staticmethod
def check_team_membership(project_id: int, allowed_roles: list, user_id: int):
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/assets/styles/_extra.scss
Original file line number Diff line number Diff line change
Expand Up @@ -616,3 +616,8 @@ a[href="https://www.mapbox.com/map-feedback/"]
.link:focus {
outline: revert;
}

// Override tachyons font-family for code tag
.code {
font-family: inherit;
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const PostProjectComment = ({ projectId, refetchComments, contributors })
isShowUserPicture
isShowFooter
isShowTabNavs
contributors={contributors?.userContributions?.map((user) => user.username)}
contributors={contributors?.map((user) => user.username)}
/>
</div>

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/projects/projectCardPaginator.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const ProjectCardPaginator = ({ status, pagination, fullProjectsQuery, se
);
};

if (!apiIsFetched) {
// do not show pagination when the data is being fetched or it has zero results
if (!apiIsFetched || !pagination?.total) {
return null;
}
const activePage = (apiIsFetched && pagination?.page) || 1;
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/rapidEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function generateStartingHash({ comment, presets, gpxUrl, powerUser, imagery })
return hashParams;
}


/**
* Resize rapid
* @param {Context} rapidContext The rapid context to resize
Expand Down
13 changes: 3 additions & 10 deletions frontend/src/components/taskSelection/actionSidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,19 +586,12 @@ const TaskValidationSelector = ({
// the contributors is filled only on the case of single task validation,
// so we need to fetch the task history in the case of multiple task validation
useEffect(() => {
if (showCommentInput && isValidatingMultipleTasks && !contributors.length) {
if (showCommentInput && isValidatingMultipleTasks) {
fetchLocalJSONAPI(`projects/${projectId}/tasks/${id}/`).then((response) =>
setContributorsList(getTaskContributors(response.taskHistory, userDetails.username)),
);
}
}, [
isValidatingMultipleTasks,
showCommentInput,
contributors,
id,
projectId,
userDetails.username,
]);
}, [isValidatingMultipleTasks, showCommentInput, id, projectId, userDetails.username]);

return (
<div className="cf w-100 db pt1 pv2 blue-dark">
Expand Down Expand Up @@ -650,7 +643,7 @@ const TaskValidationSelector = ({
<CommentInputField
comment={comment}
setComment={setComment}
contributors={contributors.length ? contributors : contributorsList}
contributors={isValidatingMultipleTasks ? contributorsList : contributors}
enableHashtagPaste
enableContributorsHashtag
isShowTabNavs
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/views/contributions.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ export const ContributionsPage = () => {
<section className="pb5 pt180 pull-center">
<MyTasksNav />
<TaskResults retryFn={forceUpdate} state={state} />
<ProjectCardPaginator projectAPIstate={state} setQueryParam={setContributionsQuery} />
<ProjectCardPaginator
projectAPIstate={state}
status={state.isLoading ? 'pending' : 'success'}
pagination={state?.pagination}
setQueryParam={setContributionsQuery}
/>
</section>
);
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function Settings() {
</div>
<div className="fl w-100 w-40-l pb3 pl3-l">
<PersonalInformationForm />
<OSMCard username={userDetails.username} />
{userDetails?.username && <OSMCard username={userDetails.username} />}
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/teams.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ export function TeamDetail() {
const [error, loading, team] = useFetch(`teams/${id}/`);
// eslint-disable-next-line
const [projectsError, projectsLoading, projects] = useFetch(
`projects/?teamId=${id}&omitMapResults=true`,
`projects/?teamId=${id}&omitMapResults=true&projectStatuses=PUBLISHED,DRAFT,ARCHIVED`,
id,
);
const [isMember, setIsMember] = useState(false);
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/views/userDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { CountriesMapped } from '../components/userDetail/countriesMapped';
import { TopProjects } from '../components/userDetail/topProjects';
import { ContributionTimeline } from '../components/userDetail/contributionTimeline';
import { NotFound } from './notFound';
import { OHSOME_STATS_BASE_URL } from '../config';
import { OHSOME_STATS_BASE_URL, OSM_SERVER_URL } from '../config';
import { fetchExternalJSONAPI } from '../network/genericJSONRequest';
import { useFetch } from '../hooks/UseFetch';
import { useSetTitleTag } from '../hooks/UseMetaTags';
Expand All @@ -33,6 +33,7 @@ export const UserDetail = ({ withHeader = true }) => {
const token = useSelector((state) => state.auth.token);
const currentUser = useSelector((state) => state.auth.userDetails);
const [osmStats, setOsmStats] = useState({});
const [userOsmDetails, setUserOsmDetails] = useState({});
const [errorDetails, loadingDetails, userDetails] = useFetch(
`users/queries/${username}/`,
username !== undefined,
Expand All @@ -54,6 +55,9 @@ export const UserDetail = ({ withHeader = true }) => {

useEffect(() => {
if (userDetails.id) {
fetchExternalJSONAPI(`${OSM_SERVER_URL}/api/0.6/user/${userDetails.id}.json`, false)
.then((res) => setUserOsmDetails(res?.user))
.catch((e) => console.log(e));
fetchExternalJSONAPI(`${OHSOME_STATS_BASE_URL}/hot-tm-user?userId=${userDetails.id}`, true)
.then((res) => setOsmStats(res.result))
.catch((e) => console.log(e));
Expand All @@ -74,7 +78,7 @@ export const UserDetail = ({ withHeader = true }) => {
rows={5}
ready={!errorDetails && !loadingDetails}
>
<HeaderProfile userDetails={userDetails} changesets={osmStats.changesets} />
<HeaderProfile userDetails={userDetails} changesets={userOsmDetails?.changesets?.count} />
</ReactPlaceholder>
</div>
)}
Expand Down

0 comments on commit 84d7caf

Please sign in to comment.