mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-20 02:18:01 +00:00
added config file editor
This commit is contained in:
@@ -19,8 +19,6 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab')
|
||||
i.fa.fa-bug
|
||||
span Report a problem
|
||||
|
||||
|
||||
|
||||
.form-line
|
||||
.header
|
||||
.title Theme
|
||||
@@ -213,6 +211,15 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab')
|
||||
i.fa.fa-bug
|
||||
span Open DevTools
|
||||
|
||||
.form-line
|
||||
.header
|
||||
.title Enable analytics
|
||||
.description We use Google Analytics
|
||||
toggle(
|
||||
[(ngModel)]='config.store.enableAnalytics',
|
||||
(ngModelChange)='config.save(); config.requestRestart()',
|
||||
)
|
||||
|
||||
.form-line
|
||||
.header
|
||||
.title Custom CSS
|
||||
@@ -253,3 +260,29 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab')
|
||||
| {{provider.title}}
|
||||
ng-template(ngbTabContent)
|
||||
settings-tab-body([provider]='provider')
|
||||
|
||||
|
||||
ngb-tab(id='config-file')
|
||||
ng-template(ngbTabTitle)
|
||||
| Config file
|
||||
ng-template.test(ngbTabContent)
|
||||
.d-flex.flex-column.w-100.h-100
|
||||
.h-100.d-flex
|
||||
.w-100.d-flex.flex-column
|
||||
h3 Config file
|
||||
textarea.form-control.h-100(
|
||||
[(ngModel)]='configFile'
|
||||
)
|
||||
.w-100.d-flex.flex-column
|
||||
h3 Defaults
|
||||
textarea.form-control.h-100(
|
||||
[(ngModel)]='configDefaults',
|
||||
readonly
|
||||
)
|
||||
.mt-3
|
||||
button.btn.btn-primary((click)='saveConfigFile()', *ngIf='isConfigFileValid()')
|
||||
i.fa.fa-check.mr-2
|
||||
| Save and apply
|
||||
button.btn.btn-primary(disabled, *ngIf='!isConfigFileValid()')
|
||||
i.fa.fa-warning.mr-2
|
||||
| Invalid syntax
|
||||
|
@@ -20,5 +20,5 @@
|
||||
|
||||
textarea {
|
||||
font-family: 'Source Sans Mono', monospace;
|
||||
height: 120px;
|
||||
min-height: 120px;
|
||||
}
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import * as yaml from 'js-yaml'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { Component, Inject, Input } from '@angular/core'
|
||||
import { ElectronService, DockingService, ConfigService, IHotkeyDescription, HotkeyProvider, BaseTabComponent, Theme, HostAppService, Platform, HomeBaseService } from 'terminus-core'
|
||||
|
||||
@@ -17,6 +19,9 @@ export class SettingsTabComponent extends BaseTabComponent {
|
||||
hotkeyDescriptions: IHotkeyDescription[]
|
||||
screens: any[]
|
||||
Platform = Platform
|
||||
configDefaults: any
|
||||
configFile: string
|
||||
private configSubscription: Subscription
|
||||
|
||||
constructor (
|
||||
public config: ConfigService,
|
||||
@@ -34,6 +39,12 @@ export class SettingsTabComponent extends BaseTabComponent {
|
||||
this.screens = this.docking.getScreens()
|
||||
this.settingsProviders = config.enabledServices(this.settingsProviders)
|
||||
this.themes = config.enabledServices(this.themes)
|
||||
|
||||
this.configDefaults = yaml.safeDump(config.getDefaults())
|
||||
this.configFile = config.readRaw()
|
||||
this.configSubscription = config.changed$.subscribe(() => {
|
||||
this.configFile = config.readRaw()
|
||||
})
|
||||
}
|
||||
|
||||
getRecoveryToken (): any {
|
||||
@@ -41,6 +52,7 @@ export class SettingsTabComponent extends BaseTabComponent {
|
||||
}
|
||||
|
||||
ngOnDestroy () {
|
||||
this.configSubscription.unsubscribe()
|
||||
this.config.save()
|
||||
}
|
||||
|
||||
@@ -48,4 +60,19 @@ export class SettingsTabComponent extends BaseTabComponent {
|
||||
this.electron.app.relaunch()
|
||||
this.electron.app.exit()
|
||||
}
|
||||
|
||||
saveConfigFile () {
|
||||
if (this.isConfigFileValid()) {
|
||||
this.config.writeRaw(this.configFile)
|
||||
}
|
||||
}
|
||||
|
||||
isConfigFileValid () {
|
||||
try {
|
||||
yaml.safeLoad(this.configFile)
|
||||
return true
|
||||
} catch (_) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,12 @@
|
||||
:host /deep/ ngb-tabset > .tab-content {
|
||||
padding: 15px 30px;
|
||||
margin: 0;
|
||||
flex: auto;
|
||||
overflow-y: auto;
|
||||
flex: auto;
|
||||
display: flex;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
:host /deep/ ngb-tabset > .tab-content > .tab-pane {
|
||||
width: 100%;
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { NgPipesModule } from 'ngx-pipes'
|
||||
|
||||
import { ToolbarButtonProvider, TabRecoveryProvider } from 'terminus-core'
|
||||
import TerminusCorePlugin from 'terminus-core'
|
||||
|
||||
import { HotkeyInputModalComponent } from './components/hotkeyInputModal.component'
|
||||
import { MultiHotkeyInputComponent } from './components/multiHotkeyInput.component'
|
||||
@@ -20,6 +21,7 @@ import { RecoveryProvider } from './recoveryProvider'
|
||||
FormsModule,
|
||||
NgbModule,
|
||||
NgPipesModule,
|
||||
TerminusCorePlugin,
|
||||
],
|
||||
providers: [
|
||||
{ provide: ToolbarButtonProvider, useClass: ButtonProvider, multi: true },
|
||||
|
Reference in New Issue
Block a user