import { Observable } from 'rxjs' ; import { first , map } from 'rxjs/operators' ; import { Injectable } from '@angular/core' ; import { JupyterService } from './jupyter.service' ; import { LoggerService } from './logger.service' ; @ Injectable ( { providedIn : 'root' } ) export class NotebookService { protected _name = 'NotebookService' ; constructor ( protected _jupyterSvc , protected _loggerSvc ) { } getCommManager ( ) { return this . _jupyterSvc . notebook$ . pipe ( map ( notebook => notebook . kernel . comm_manager ) , first ( ) ) ; } getCells ( ) { return this . _jupyterSvc . notebook$ . pipe ( map ( notebook => notebook . get_cells ( ) ) , first ( ) ) ; } getSelectedCell ( ) { return this . _jupyterSvc . notebook$ . pipe ( map ( notebook => notebook . get_selected_cell ( ) ) , first ( ) ) ; } getCellById ( id ) { return this . getCells ( ) . pipe ( map ( ( cells ) => cells . find ( ( c ) => c . cell_id === id ) || null ) , first ( ) ) ; } getMsgCell ( msgId ) { return this . _jupyterSvc . notebook$ . pipe ( map ( notebook => notebook . get_msg_cell ( msgId ) ) , first ( ) ) ; } }