Skip to content

Commit

Permalink
Merge pull request #188 from celluloid-camp/fix-video-player-annotation
Browse files Browse the repository at this point in the history
fix logout and annotation refresh
  • Loading branch information
younes200 authored Jan 6, 2023
2 parents 6f6e306 + 24640cc commit 072dd50
Show file tree
Hide file tree
Showing 13 changed files with 225 additions and 184 deletions.
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ services:
upload-scripts
web-authn
client-policies
dynamic-scopes
volumes:
- /etc/localtime:/etc/localtime:ro
dynamic-scopes
depends_on:
- postgres
command: start
Expand Down
11 changes: 7 additions & 4 deletions packages/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@ import { MuiThemeProvider } from "@material-ui/core/styles";
import ResetScroll from "components/ResetScroll";

import { BrowserRouter, Routes, Route } from "react-router-dom";
import { MuiPickersUtilsProvider } from '@material-ui/pickers';
import { MuiPickersUtilsProvider } from "@material-ui/pickers";
import en from "i18n/en";
import fr from "i18n/fr";
import * as i18next from "i18next";
import MomentUtils from 'material-ui-pickers/utils/moment-utils';
import MomentUtils from "material-ui-pickers/utils/moment-utils";
import { initReactI18next } from "react-i18next";

import { Provider } from "react-redux";
import createAppStore from "store";
import createAppStore, { history } from "store";
import { Bright } from "utils/ThemeUtils";
import LanguageDetector from "i18next-browser-languagedetector";

import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { About } from "components/About";
import { ConnectedRouter } from "connected-react-router";

const queryClient = new QueryClient();

Expand Down Expand Up @@ -62,6 +63,7 @@ const styles = createStyles({
const Content = () => {
return (
<Provider store={store}>
{/* <ConnectedRouter history={history}> */}
<MuiThemeProvider theme={Bright}>
<QueryClientProvider client={queryClient}>
{/* <MuiPickersUtilsProvider utils={MomentUtils}> */}
Expand All @@ -70,7 +72,7 @@ const Content = () => {
<React.Fragment>
<UpdateIndicator />
<BrowserRouter>
<ResetScroll/>
<ResetScroll />
<Routes>
<Route
path="/"
Expand All @@ -92,6 +94,7 @@ const Content = () => {
{/* </MuiPickersUtilsProvider> */}
</QueryClientProvider>
</MuiThemeProvider>
{/* </ConnectedRouter> */}
</Provider>
);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/actions/ProjectActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const createProjectThunk =
dispatch(triggerUpsertProjectLoading());
return ProjectService.create(data)
.then(project => {
dispatch(push(`/projects/${project.id}`));
// dispatch(push(`/projects/${project.id}`));
dispatch(discardNewVideo());
return dispatch(succeedUpsertProject(project));
})
Expand Down
3 changes: 3 additions & 0 deletions packages/client/src/actions/Signin/UserActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ export const fetchCurrentUserThunk = () => (dispatch: Dispatch) => {
};

export const doLogoutThunk = () => (dispatch: Dispatch) => {

console.log("doLogoutThunk")
return UserService
.logout()
.then(() => {
console.log("logout result")
return dispatch(succeedCurrentUser());
})
.catch(error => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import { AppState } from "types/StateTypes";
import { PeertubeVideoInfo } from "types/YoutubeTypes";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";

const styles = ({ spacing }: Theme) =>
createStyles({
Expand Down Expand Up @@ -161,6 +162,7 @@ const NewProjectContainer: React.FC<Props> = ({
onCancel,
onNewTag,
}) => {
const navigate = useNavigate();
const { t } = useTranslation();
const [state, setState] = useState<State>({
project: {
Expand Down Expand Up @@ -216,6 +218,14 @@ const NewProjectContainer: React.FC<Props> = ({
});
};

const handleSubmit = async (project: ProjectCreateData)=>{
const {error, payload} = await onSubmit(project);
if(!error){
navigate(`/projects/${(payload as ProjectGraphRecord).id}`);
}


}
if (video && user && user.role !== "Student") {
return (
<Dialog
Expand Down Expand Up @@ -501,7 +511,7 @@ const NewProjectContainer: React.FC<Props> = ({
</Button>
<Button
onClick={() =>
onSubmit({ ...project, videoId: video.id, host: video.host })
handleSubmit({ ...project, videoId: video.id, host: video.host })
}
color="primary"
variant="contained"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export default connect(
</TransitionGroup>
</div>
)}
{isReady && user && canAnnotate(project, user) && (
{user && canAnnotate(project, user) && (
<Zoom
appear={true}
exit={true}
Expand Down
102 changes: 51 additions & 51 deletions packages/client/src/services/UserService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ import {
Credentials,
TeacherConfirmData,
TeacherConfirmResetPasswordData,
StudentSignupData
} from '@celluloid/types';
StudentSignupData,
} from "@celluloid/types";

import * as Constants from './Constants';
import * as Constants from "./Constants";

export default class {
static login(credentials: Credentials) {
const headers = {
Accepts: 'application/json',
'Content-type': 'application/json'
Accepts: "application/json",
"Content-type": "application/json",
};
return fetch(`/api/users/login`, {
method: 'POST',
method: "POST",
headers: new Headers(headers),
credentials: 'include',
body: JSON.stringify(credentials)
}).then(response => {
credentials: "include",
body: JSON.stringify(credentials),
}).then((response) => {
if (response.status === 200) {
return response.json();
} else if (response.status === 400) {
Expand All @@ -33,16 +33,16 @@ export default class {

static signup(data: TeacherSignupData) {
const headers = {
Accepts: 'application/json',
'Content-type': 'application/json'
Accepts: "application/json",
"Content-type": "application/json",
};

return fetch(`/api/users/signup`, {
method: 'POST',
method: "POST",
headers: new Headers(headers),
credentials: 'include',
body: JSON.stringify(data)
}).then(response => {
credentials: "include",
body: JSON.stringify(data),
}).then((response) => {
if (response.status === 201) {
return response.json();
} else if (response.status === 400) {
Expand All @@ -56,16 +56,16 @@ export default class {

static studentSignup(data: StudentSignupData) {
const headers = {
Accepts: 'application/json',
'Content-type': 'application/json'
Accepts: "application/json",
"Content-type": "application/json",
};

return fetch(`/api/users/student-signup`, {
method: 'POST',
method: "POST",
headers: new Headers(headers),
credentials: 'include',
body: JSON.stringify(data)
}).then(response => {
credentials: "include",
body: JSON.stringify(data),
}).then((response) => {
if (response.status === 201) {
return response.json();
} else if (response.status === 400) {
Expand All @@ -79,16 +79,16 @@ export default class {

static confirmSignup(data: TeacherConfirmData) {
const headers = {
Accepts: 'application/json',
'Content-type': 'application/json'
Accepts: "application/json",
"Content-type": "application/json",
};

return fetch(`/api/users/confirm-signup`, {
method: 'POST',
method: "POST",
headers: new Headers(headers),
credentials: 'include',
body: JSON.stringify(data)
}).then(response => {
credentials: "include",
body: JSON.stringify(data),
}).then((response) => {
if (response.status === 200) {
return response.json();
} else if (response.status === 400) {
Expand All @@ -102,16 +102,16 @@ export default class {

static resetPassword(email: string) {
const headers = {
Accepts: 'application/json',
'Content-type': 'application/json'
Accepts: "application/json",
"Content-type": "application/json",
};

return fetch(`/api/users/reset-password`, {
method: 'POST',
method: "POST",
headers: new Headers(headers),
credentials: 'include',
body: JSON.stringify({ email })
}).then(response => {
credentials: "include",
body: JSON.stringify({ email }),
}).then((response) => {
if (response.status === 200) {
return response.json();
} else if (response.status === 400) {
Expand All @@ -125,16 +125,16 @@ export default class {

static confirmResetPassword(data: TeacherConfirmResetPasswordData) {
const headers = {
Accepts: 'application/json',
'Content-type': 'application/json'
Accepts: "application/json",
"Content-type": "application/json",
};

return fetch(`/api/users/confirm-reset-password`, {
method: 'POST',
method: "POST",
headers: new Headers(headers),
credentials: 'include',
body: JSON.stringify(data)
}).then(response => {
credentials: "include",
body: JSON.stringify(data),
}).then((response) => {
if (response.status === 200) {
return response.json();
} else if (response.status === 400) {
Expand All @@ -148,16 +148,16 @@ export default class {

static resendCode(email: string) {
const headers = {
Accepts: 'application/json',
'Content-type': 'application/json'
Accepts: "application/json",
"Content-type": "application/json",
};

return fetch(`/api/users/resend-code`, {
method: 'POST',
method: "POST",
headers: new Headers(headers),
credentials: 'include',
body: JSON.stringify({ email })
}).then(response => {
credentials: "include",
body: JSON.stringify({ email }),
}).then((response) => {
if (response.status === 200) {
return response.json();
} else if (response.status === 400) {
Expand All @@ -171,14 +171,14 @@ export default class {

static me() {
const headers = {
Accepts: 'application/json'
Accepts: "application/json",
};

return fetch(`/api/users/me`, {
method: 'GET',
method: "GET",
headers: new Headers(headers),
credentials: 'include'
}).then(response => {
credentials: "include",
}).then((response) => {
if (response.status === 200) {
return response.json();
} else if (response.status === 401) {
Expand All @@ -190,8 +190,8 @@ export default class {

static logout() {
return fetch(`/api/users/logout`, {
method: 'PUT',
credentials: 'include'
method: "PUT",
credentials: "include",
});
}
}
2 changes: 1 addition & 1 deletion packages/client/tsconfig.tsbuildinfo

Large diffs are not rendered by default.

Loading

0 comments on commit 072dd50

Please sign in to comment.