Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scheduler-react-sample
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linh Nguyen
scheduler-react-sample
Commits
7f0bff54
Commit
7f0bff54
authored
Jun 08, 2020
by
Jiawen Lyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add extractUvDateInfo
parent
22a11aaa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
17 deletions
+62
-17
src/App.js
src/App.js
+62
-17
No files found.
src/App.js
View file @
7f0bff54
import
React
,
{
Component
}
from
"
react
"
;
import
Scheduler
from
"
./components/Scheduler
"
;
import
Toolbar
from
"
./components/Toolbar
"
;
//
import Toolbar from "./components/Toolbar";
import
MessageArea
from
"
./components/MessageArea
"
;
import
"
./App.css
"
;
...
...
@@ -10,26 +10,43 @@ const data = [
start_date
:
"
2020-06-10 6:00
"
,
end_date
:
"
2020-06-10 8:00
"
,
text
:
"
C SR03
"
,
id
:
1
,
id
:
1
},
{
start_date
:
"
2020-06-10 8:15
"
,
end_date
:
"
2020-06-10 10:15
"
,
text
:
"
TD SR03
"
,
id
:
2
,
id
:
2
},
{
start_date
:
"
2020-06-13 10:00
"
,
end_date
:
"
2020-06-13 18:00
"
,
text
:
"
Event 2
"
,
id
:
3
,
id
:
3
},
];
const
semestreP20
=
{
start_date
:
"
2020-02-24
"
,
end_date
:
"
2020-06-27
"
}
const
extractUvDateInfo
=
uvs
=>
uvs
.
map
(
uv
=>
({
start_date
:
uv
.
begin
,
end_date
:
uv
.
end
,
day
:
uv
.
day
,
text
:
uv
.
uv
,
id
:
uvs
.
indexOf
(
uv
)
}))
class
App
extends
Component
{
state
=
{
currentTimeFormatState
:
true
,
messages
:
[],
error
:
null
,
isLoaded
:
false
,
uvs
:
[]
};
addMessage
(
message
)
{
const
maxLogLength
=
5
;
...
...
@@ -48,20 +65,48 @@ class App extends Component {
this
.
addMessage
(
message
);
};
componentDidMount
()
{
fetch
(
'
https://cors-anywhere.herokuapp.com/https://webapplis.utc.fr/Edt_ent_rest/myedt/result/?login=jbarthel
'
)
.
then
(
res
=>
res
.
json
())
.
then
(
(
result
)
=>
{
this
.
setState
({
isLoaded
:
true
,
uvs
:
result
});
},
// Remarque : il est important de traiter les erreurs ici
// au lieu d'utiliser un bloc catch(), pour ne pas passer à la trappe
// des exceptions provenant de réels bugs du composant.
(
error
)
=>
{
this
.
setState
({
isLoaded
:
true
,
error
});
}
)
}
render
()
{
const
{
currentTimeFormatState
,
messages
}
=
this
.
state
;
return
(
<
div
>
<
div
className
=
"
scheduler-container
"
>
<
Scheduler
events
=
{
data
}
timeFormatState
=
{
currentTimeFormatState
}
onDataUpdated
=
{
this
.
logDataUpdate
}
/
>
<
/div
>
<
MessageArea
messages
=
{
messages
}
/
>
<
/div
>
);
const
{
currentTimeFormatState
,
messages
,
error
,
isLoaded
,
uvs
}
=
this
.
state
;
const
data
=
extractUvDateInfo
(
uvs
)
if
(
error
)
{
return
<
div
>
Erreur
:
{
error
.
message
}
<
/div>
;
}
else
if
(
!
isLoaded
)
{
return
<
div
>
Chargement
…
<
/div>
;
}
else
{
return
(
<
div
>
<
div
className
=
"
scheduler-container
"
>
<
Scheduler
events
=
{
data
}
timeFormatState
=
{
currentTimeFormatState
}
onDataUpdated
=
{
this
.
logDataUpdate
}
/
>
<
/div
>
<
MessageArea
messages
=
{
messages
}
/
>
<
/div
>
);
}
}
}
export
default
App
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment