Files
tabby-web/frontend/src/api.ts

51 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-06-28 09:32:13 +02:00
import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { Resolve } from '@angular/router'
import { Observable } from 'rxjs'
2021-06-25 21:55:40 +02:00
export interface User {
2021-10-24 21:50:55 +02:00
id: number
active_config: number
active_version: string
custom_connection_gateway: string|null
custom_connection_gateway_token: string|null
config_sync_token: string
github_username: string
is_pro: boolean
is_sponsor: boolean
2021-06-25 21:55:40 +02:00
}
export interface Config {
2021-10-24 21:50:55 +02:00
id: number
content: string
last_used_with_version: string
created_at: Date
modified_at: Date
2021-06-25 21:55:40 +02:00
}
export interface Version {
2021-10-24 21:50:55 +02:00
version: string
plugins: string[]
2021-06-25 21:55:40 +02:00
}
2021-06-28 09:32:13 +02:00
export interface InstanceInfo {
2021-10-24 21:50:55 +02:00
login_enabled: boolean
homepage_enabled: boolean
2021-06-28 09:32:13 +02:00
}
2021-07-11 16:13:18 +02:00
export interface Gateway {
2021-10-24 21:50:55 +02:00
host: string
port: number
url: string
auth_token: string
2021-07-11 16:13:18 +02:00
}
2021-06-28 09:32:13 +02:00
@Injectable({ providedIn: 'root' })
export class InstanceInfoResolver implements Resolve<Observable<InstanceInfo>> {
2021-10-24 21:50:55 +02:00
constructor (private http: HttpClient) { }
2021-06-28 09:32:13 +02:00
2021-10-24 21:50:55 +02:00
resolve (): Observable<InstanceInfo> {
return this.http.get('/api/1/instance-info').toPromise()
}
2021-06-28 09:32:13 +02:00
}