2017-03-24 22:29:54 +00:00
|
|
|
import { Injectable } from '@angular/core'
|
2017-04-11 00:22:48 +00:00
|
|
|
import { TabRecoveryProvider, AppService } from 'terminus-core'
|
|
|
|
|
2017-04-16 18:38:42 +00:00
|
|
|
import { TerminalTabComponent } from './components/terminalTab.component'
|
|
|
|
import { SessionsService } from './services/sessions.service'
|
2017-03-24 22:29:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
@Injectable()
|
2017-03-25 17:12:43 +00:00
|
|
|
export class RecoveryProvider extends TabRecoveryProvider {
|
2017-04-08 12:50:10 +00:00
|
|
|
constructor (
|
|
|
|
private sessions: SessionsService,
|
|
|
|
private app: AppService,
|
|
|
|
) {
|
2017-03-25 17:12:43 +00:00
|
|
|
super()
|
|
|
|
}
|
2017-03-24 22:29:54 +00:00
|
|
|
|
2017-04-08 12:50:10 +00:00
|
|
|
async recover (recoveryToken: any): Promise<void> {
|
2017-03-24 22:29:54 +00:00
|
|
|
if (recoveryToken.type == 'app:terminal') {
|
2017-03-25 20:00:16 +00:00
|
|
|
let session = await this.sessions.recover(recoveryToken.recoveryId)
|
|
|
|
if (!session) {
|
2017-04-08 12:50:10 +00:00
|
|
|
return
|
2017-03-25 20:00:16 +00:00
|
|
|
}
|
2017-04-08 12:50:10 +00:00
|
|
|
this.app.openNewTab(TerminalTabComponent, { session })
|
2017-03-24 22:29:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|