@@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
3
3
use serde_json:: Value ;
4
4
use std:: collections:: HashMap ;
5
5
6
- #[ derive( Deserialize , Serialize , Debug ) ]
6
+ #[ derive( Deserialize , Serialize , Debug ) ]
7
7
pub struct Pass {
8
8
pub autologin : String ,
9
9
pub login : String ,
@@ -34,6 +34,7 @@ pub struct Home {
34
34
#[ derive( Deserialize , Debug ) ]
35
35
pub struct Board {
36
36
projets : Vec < Projet > ,
37
+ activites : Vec < Activites > ,
37
38
}
38
39
39
40
#[ derive( Deserialize , Debug ) ]
@@ -47,6 +48,21 @@ pub struct Projet {
47
48
id_activite : String ,
48
49
}
49
50
51
+ #[ derive( Deserialize , Debug ) ]
52
+ pub struct Activites {
53
+ title : String ,
54
+ module : String ,
55
+ module_link : String ,
56
+ module_code : String ,
57
+ title_link : String ,
58
+ timeline_start : String ,
59
+ timeline_end : String ,
60
+ timeline_barre : String ,
61
+ salle : String ,
62
+ token : Option < String > ,
63
+ token_link : String ,
64
+ }
65
+
50
66
#[ derive( Deserialize , Debug ) ]
51
67
pub struct Module {
52
68
title : String ,
@@ -175,6 +191,51 @@ impl Board {
175
191
None => panic ! ( "there is no project with this id" ) ,
176
192
}
177
193
}
194
+
195
+ pub fn print_activity ( & self ) {
196
+ let mut table = Table :: new ( ) ;
197
+ table. set_format ( format_display_table ( ) ) ;
198
+ table. add_row ( row ! [ "ID" , "ACTIVITY_NAME" , "TIMELINE_BARRE" ] ) ;
199
+ table. add_row ( row ! [ "--" , "-------------" , "--------------" ] ) ;
200
+ for ( idx, activite) in self . activites . iter ( ) . enumerate ( ) {
201
+ let nbr: String = parce_json_float_to_string ( & activite. timeline_barre ) ;
202
+ table. add_row ( row ! [
203
+ idx,
204
+ activite. title,
205
+ format!( "|{}|{}%" , parce_timeline( & nbr) , & nbr)
206
+ ] ) ;
207
+ }
208
+ print ! ( "\n " ) ;
209
+ table. printstd ( ) ;
210
+ }
211
+
212
+ pub fn print_activity_detail ( & self , idx : i32 , autologin_url : & String ) {
213
+ match self . activites . get ( idx as usize ) {
214
+ Some ( activite) => {
215
+ let mut table = Table :: new ( ) ;
216
+ let nbr: String = parce_json_float_to_string ( & activite. timeline_barre ) ;
217
+ table. set_format ( format_display ( ) ) ;
218
+ table. add_row ( row ! [ "Title: " , activite. title] ) ;
219
+ table. add_row ( row ! [
220
+ "Link: " ,
221
+ format!( "{}{}project/" , autologin_url, activite. title_link)
222
+ ] ) ;
223
+ table. add_row ( row ! [ "Start_Time: " , activite. timeline_start] ) ;
224
+ table. add_row ( row ! [ "End_Time: " , activite. timeline_end] ) ;
225
+ table. add_row ( row ! [
226
+ "Time_Barre: " ,
227
+ format!( "|{}|{}%" , parce_timeline( & nbr) , & nbr)
228
+ ] ) ;
229
+ table. add_row ( row ! [ "Salle: " , activite. salle] ) ;
230
+ match & activite. token {
231
+ Some ( token) => table. add_row ( row ! [ "token: " , token] ) ,
232
+ None => table. add_row ( row ! [ "token: " , "null" ] ) ,
233
+ } ;
234
+ table. printstd ( ) ;
235
+ }
236
+ None => panic ! ( "there is no project with this id" ) ,
237
+ }
238
+ }
178
239
}
179
240
180
241
impl ModulesNotes {
0 commit comments