mirror of
https://github.com/Eugeny/tabby-web.git
synced 2026-08-17 06:46:05 +01:00
wip
This commit is contained in:
@@ -21,6 +21,7 @@ export interface Config {
|
||||
|
||||
export interface Version {
|
||||
version: string
|
||||
plugins: string[]
|
||||
}
|
||||
|
||||
export interface InstanceInfo {
|
||||
@@ -31,6 +32,7 @@ export interface Gateway {
|
||||
host: string
|
||||
port: number
|
||||
url: string
|
||||
auth_token: string
|
||||
}
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
.list-group.list-group-light
|
||||
ng-container(*ngFor='let config of configService.configs')
|
||||
button.list-group-item.list-group-item-action(
|
||||
*ngIf='config !== configService.activeConfig',
|
||||
*ngIf='config.id !== configService.activeConfig?.id',
|
||||
(click)='selectConfig(config)'
|
||||
)
|
||||
fa-icon([icon]='_configIcon')
|
||||
|
||||
@@ -46,4 +46,11 @@ export class ConfigModalComponent {
|
||||
this.modalInstance.dismiss()
|
||||
}
|
||||
|
||||
async deleteConfig () {
|
||||
if (confirm('Delete this config? This cannot be undone.')) {
|
||||
await this.configService.deleteConfig(this.configService.activeConfig)
|
||||
}
|
||||
this.configService.selectDefaultConfig()
|
||||
this.modalInstance.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ export class SocketProxy {
|
||||
close$ = new Subject<Buffer>()
|
||||
|
||||
url: string
|
||||
authToken: string
|
||||
webSocket: WebSocket
|
||||
initialBuffer: Buffer
|
||||
options: {
|
||||
@@ -27,15 +28,27 @@ export class SocketProxy {
|
||||
async connect (options) {
|
||||
this.options = options
|
||||
this.url = this.appConnector.loginService.user.custom_connection_gateway
|
||||
this.authToken = this.appConnector.loginService.user.custom_connection_gateway_token
|
||||
if (!this.url) {
|
||||
try {
|
||||
this.url = (await this.appConnector.chooseConnectionGateway()).url
|
||||
const gateway = await this.appConnector.chooseConnectionGateway()
|
||||
this.url = gateway.url
|
||||
this.authToken = gateway.auth_token
|
||||
} catch (err) {
|
||||
this.error$.next(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
this.webSocket = new WebSocket(this.url)
|
||||
try {
|
||||
this.webSocket = new WebSocket(this.url)
|
||||
} catch (err) {
|
||||
this.error$.next(err)
|
||||
return
|
||||
}
|
||||
this.webSocket.onerror = err => {
|
||||
this.error$.next(new Error(`Failed to connect to the connection gateway at ${this.url}`))
|
||||
return
|
||||
}
|
||||
this.webSocket.onmessage = async event => {
|
||||
if (typeof(event.data) === 'string') {
|
||||
this.handleServiceMessage(JSON.parse(event.data))
|
||||
@@ -53,7 +66,7 @@ export class SocketProxy {
|
||||
this.sendServiceMessage({
|
||||
_: 'hello',
|
||||
version: 1,
|
||||
auth_token: this.appConnector.loginService.user.custom_connection_gateway_token,
|
||||
auth_token: this.authToken,
|
||||
})
|
||||
} else if (msg._ === 'ready') {
|
||||
this.sendServiceMessage({
|
||||
@@ -139,7 +152,7 @@ export class AppConnectorService {
|
||||
}
|
||||
|
||||
getPluginsToLoad (): string[] {
|
||||
return [
|
||||
const loadOrder = [
|
||||
'tabby-core',
|
||||
'tabby-settings',
|
||||
'tabby-terminal',
|
||||
@@ -147,6 +160,11 @@ export class AppConnectorService {
|
||||
'tabby-community-color-schemes',
|
||||
'tabby-web',
|
||||
]
|
||||
|
||||
return [
|
||||
...loadOrder.filter(x => this.version.plugins.includes(x)),
|
||||
...this.version.plugins.filter(x => !loadOrder.includes(x)),
|
||||
]
|
||||
}
|
||||
|
||||
createSocket () {
|
||||
|
||||
@@ -76,6 +76,11 @@ export class ConfigService {
|
||||
this.selectConfig(this.configs.find(c => c.id === this.loginService.user.active_config) ?? this.configs[0])
|
||||
}
|
||||
|
||||
async deleteConfig (config: Config) {
|
||||
await this.http.delete(`/api/1/configs/${config.id}`).toPromise()
|
||||
this.configs = this.configs.filter(x => x.id !== config.id)
|
||||
}
|
||||
|
||||
private async init () {
|
||||
this.configs = await this.http.get('/api/1/configs').toPromise()
|
||||
this.versions = await this.http.get('/api/1/versions').toPromise()
|
||||
|
||||
Reference in New Issue
Block a user