added config file editor

This commit is contained in:
Eugene Pankov
2018-08-26 22:27:50 +02:00
parent a98f2ce12d
commit 2e558e2aa2
12 changed files with 420 additions and 9 deletions

View File

@@ -13,7 +13,7 @@ export class StartPageComponent {
constructor (
private config: ConfigService,
private homeBase: HomeBaseService,
public homeBase: HomeBaseService,
@Inject(ToolbarButtonProvider) private toolbarButtonProviders: ToolbarButtonProvider[],
) {
}

View File

@@ -9,3 +9,4 @@ appearance:
css: '/* * { color: blue !important; } */'
opacity: 1.0
vibrancy: false
enableAnalytics: true

View File

@@ -80,6 +80,10 @@ export class ConfigService {
this.load()
}
getDefaults () {
return this.defaults
}
load (): void {
if (fs.existsSync(this.path)) {
this._store = yaml.safeLoad(fs.readFileSync(this.path, 'utf8'))
@@ -94,6 +98,17 @@ export class ConfigService {
this.emitChange()
}
readRaw (): string {
return yaml.safeDump(this._store)
}
writeRaw (data: string): void {
this._store = yaml.safeLoad(data)
this.save()
this.load()
this.emitChange()
}
emitChange (): void {
this.changed.next()
}

View File

@@ -1,6 +1,8 @@
import * as os from 'os'
import { Inject, Injectable } from '@angular/core'
import { Injectable } from '@angular/core'
import { ElectronService } from './electron.service'
import { ConfigService } from './config.service'
import ua = require('universal-analytics')
@Injectable()
export class HomeBaseService {
@@ -8,8 +10,13 @@ export class HomeBaseService {
constructor (
private electron: ElectronService,
private config: ConfigService,
) {
this.appVersion = electron.app.getVersion()
if (this.config.store.enableAnalytics) {
this.enableAnalytics()
}
}
openGitHub () {
@@ -26,4 +33,11 @@ export class HomeBaseService {
}[os.platform()]
this.electron.shell.openExternal(`https://github.com/eugeny/terminus/issues/new?body=${encodeURIComponent(body)}&labels=${label}`)
}
enableAnalytics () {
const session = ua('UA-3278102-20')
session.set('cd1', this.appVersion)
session.set('cd2', process.platform)
session.pageview('/').send()
}
}

View File

@@ -46,7 +46,7 @@ $nav-tabs-active-link-hover-border-color: darken($blue, 30%);
$nav-pills-border-radius: 0;
$input-bg: #111;
$input-bg-disabled: #333;
$input-disabled-bg: #333;
$input-color: $body-color;
$input-color-placeholder: #333;