@@ -55,11 +55,11 @@ impl Default for DashboardManager {
5555
5656impl DashboardManager {
5757 /// Create a new dashboard manager
58- ///
58+ ///
5959 /// # Arguments
6060 /// * `output_dir` - Directory to save dashboard files
6161 /// * `verbosity` - Verbosity level (0-3)
62- ///
62+ ///
6363 /// # Returns
6464 /// * `DashboardManager` - Dashboard manager
6565 pub fn new ( output_dir : & str , verbosity : u8 ) -> Self {
@@ -69,140 +69,148 @@ impl DashboardManager {
6969 verbosity,
7070 }
7171 }
72-
72+
7373 /// Set dashboard title
74- ///
74+ ///
7575 /// # Arguments
7676 /// * `title` - Dashboard title
77- ///
77+ ///
7878 /// # Returns
7979 /// * `&mut Self` - Self reference for method chaining
8080 pub fn with_title ( & mut self , title : & str ) -> & mut Self {
8181 self . title = title. to_string ( ) ;
8282 self
8383 }
84-
84+
8585 /// Set verbosity level
86- ///
86+ ///
8787 /// # Arguments
8888 /// * `verbosity` - Verbosity level (0-3)
89- ///
89+ ///
9090 /// # Returns
9191 /// * `&mut Self` - Self reference for method chaining
9292 pub fn with_verbosity ( & mut self , verbosity : u8 ) -> & mut Self {
9393 self . verbosity = verbosity;
9494 self
9595 }
96-
96+
9797 /// Generate and save dashboard HTML
98- ///
98+ ///
9999 /// # Arguments
100100 /// * `nodes` - List of node information
101- ///
101+ ///
102102 /// # Returns
103103 /// * `Result<String, Box<dyn Error>>` - Path to the dashboard file
104104 pub fn generate_dashboard ( & self , nodes : & [ NodeInfo ] ) -> Result < String , Box < dyn Error > > {
105105 // Ensure output directory exists
106106 fs:: create_dir_all ( & self . output_dir ) ?;
107-
107+
108108 // Generate HTML content
109109 // Pass verbosity level to the dashboard generator
110110 let html_content = generate_monitoring_dashboard ( nodes, self . verbosity ) ;
111-
112-
111+
113112 // Create output file path
114113 let file_path = format ! ( "{}/osvm_dashboard.html" , self . output_dir) ;
115-
114+
116115 // Write HTML to file
117116 fs:: write ( & file_path, html_content) ?;
118-
117+
119118 Ok ( file_path)
120119 }
121-
120+
122121 /// Open dashboard in default browser
123- ///
122+ ///
124123 /// # Arguments
125124 /// * `file_path` - Path to the dashboard HTML file
126- ///
125+ ///
127126 /// # Returns
128127 /// * `Result<(), Box<dyn Error>>` - Result
129128 pub fn open_in_browser ( & self , file_path : & str ) -> Result < ( ) , Box < dyn Error > > {
130129 // Convert to absolute path if needed
131130 let path = Path :: new ( file_path) ;
132-
131+
133132 // Get file URL
134133 let file_url = if path. is_absolute ( ) {
135134 format ! ( "file://{}" , path. display( ) )
136135 } else {
137136 let abs_path = fs:: canonicalize ( path) ?;
138137 format ! ( "file://{}" , abs_path. display( ) )
139138 } ;
140-
139+
141140 // Determine the platform and open browser accordingly
142141 #[ cfg( target_os = "windows" ) ]
143142 {
144143 Command :: new ( "cmd" )
145144 . args ( & [ "/c" , "start" , "" , & file_url] )
146145 . spawn ( )
147- . map_err ( |e| Box :: new ( DashboardError :: BrowserError ( e. to_string ( ) ) ) as Box < dyn Error > ) ?;
146+ . map_err ( |e| {
147+ Box :: new ( DashboardError :: BrowserError ( e. to_string ( ) ) ) as Box < dyn Error >
148+ } ) ?;
148149 }
149-
150+
150151 #[ cfg( target_os = "macos" ) ]
151152 {
152- Command :: new ( "open" )
153- . arg ( & file_url)
154- . spawn ( )
155- . map_err ( |e| Box :: new ( DashboardError :: BrowserError ( e. to_string ( ) ) ) as Box < dyn Error > ) ?;
153+ Command :: new ( "open" ) . arg ( & file_url) . spawn ( ) . map_err ( |e| {
154+ Box :: new ( DashboardError :: BrowserError ( e. to_string ( ) ) ) as Box < dyn Error >
155+ } ) ?;
156156 }
157-
157+
158158 #[ cfg( target_os = "linux" ) ]
159159 {
160160 Command :: new ( "xdg-open" )
161161 . arg ( & file_url)
162162 . spawn ( )
163- . map_err ( |e| Box :: new ( DashboardError :: BrowserError ( e. to_string ( ) ) ) as Box < dyn Error > ) ?;
163+ . map_err ( |e| {
164+ Box :: new ( DashboardError :: BrowserError ( e. to_string ( ) ) ) as Box < dyn Error >
165+ } ) ?;
164166 }
165-
167+
166168 Ok ( ( ) )
167169 }
168-
170+
169171 /// Generate dashboard and open in browser
170- ///
172+ ///
171173 /// # Arguments
172174 /// * `nodes` - List of node information
173- ///
175+ ///
174176 /// # Returns
175177 /// * `Result<(), Box<dyn Error>>` - Result
176178 pub fn generate_and_open ( & self , nodes : & [ NodeInfo ] ) -> Result < ( ) , Box < dyn Error > > {
177179 let file_path = self . generate_dashboard ( nodes) ?;
178180 self . open_in_browser ( & file_path) ?;
179-
181+
180182 Ok ( ( ) )
181183 }
182-
184+
183185 /// Create a real-time dashboard server (this would require an actual implementation)
184- ///
186+ ///
185187 /// # Arguments
186188 /// * `port` - Port to run the dashboard server on
187- ///
189+ ///
188190 /// # Returns
189191 /// * `Result<(), Box<dyn Error>>` - Result
190192 pub fn run_dashboard_server ( & self , port : u16 , verbosity : u8 ) -> Result < ( ) , Box < dyn Error > > {
191193 // This would normally start a web server that provides real-time updates
192194 // For this prototype, we'll just print a message with detail based on verbosity
193- println ! ( "Dashboard server would be running on http://localhost:{}" , port) ;
194-
195+ println ! (
196+ "Dashboard server would be running on http://localhost:{}" ,
197+ port
198+ ) ;
199+
195200 // Show additional details based on verbosity level
196201 match verbosity {
197202 0 => Ok ( ( ) ) , // Minimal output
198203 1 => {
199204 println ! ( "(Real implementation would start an actual web server)" ) ;
200205 Ok ( ( ) )
201- } ,
206+ }
202207 2 => {
203- println ! ( "Monitoring {} nodes with refresh rate of {} seconds" , "[node_count]" , 5 ) ;
208+ println ! (
209+ "Monitoring {} nodes with refresh rate of {} seconds" ,
210+ "[node_count]" , 5
211+ ) ;
204212 Ok ( ( ) )
205- } ,
213+ }
206214 _ => {
207215 println ! ( "Starting server with detailed debug logging enabled for development" ) ;
208216 Ok ( ( ) )
@@ -212,11 +220,11 @@ impl DashboardManager {
212220}
213221
214222/// Save a quick dashboard to the current directory and open it
215- ///
223+ ///
216224/// # Arguments
217225/// * `nodes` - List of node information
218226/// * `verbosity` - Verbosity level (0-3)
219- ///
227+ ///
220228/// # Returns
221229/// * `Result<(), Box<dyn Error>>` - Result
222230pub fn quick_dashboard ( nodes : & [ NodeInfo ] , verbosity : u8 ) -> Result < ( ) , Box < dyn Error > > {
@@ -226,13 +234,16 @@ pub fn quick_dashboard(nodes: &[NodeInfo], verbosity: u8) -> Result<(), Box<dyn
226234}
227235
228236/// Run the dashboard with the given RPC client and commitment config
229- ///
237+ ///
230238/// # Arguments
231239/// * `client` - RPC client
232240/// * `commitment_config` - Commitment config
233- ///
241+ ///
234242/// # Returns
235243/// * `Result<(), Box<dyn Error>>` - Result
236- pub fn run_dashboard ( client : & RpcClient , commitment_config : CommitmentConfig ) -> Result < ( ) , Box < dyn Error > > {
244+ pub fn run_dashboard (
245+ client : & RpcClient ,
246+ commitment_config : CommitmentConfig ,
247+ ) -> Result < ( ) , Box < dyn Error > > {
237248 crate :: utils:: nodes:: run_dashboard ( client, commitment_config, 1 )
238- }
249+ }
0 commit comments