settings ui updates

This commit is contained in:
Eugene Pankov
2021-04-05 12:32:37 +02:00
parent dc53668685
commit b4e703674b
19 changed files with 580 additions and 417 deletions

View File

@@ -21,4 +21,5 @@ export { NotificationsService } from '../services/notifications.service'
export { ShellIntegrationService } from '../services/shellIntegration.service'
export { ThemesService } from '../services/themes.service'
export { TabsService } from '../services/tabs.service'
export { UpdaterService } from '../services/updater.service'
export * from '../utils'

View File

@@ -86,7 +86,7 @@ title-bar(
button.btn.btn-secondary.btn-tab-bar.btn-update(
*ngIf='updatesAvailable',
title='Update available - Click to install',
(click)='updateApp()',
(click)='updater.update()',
[fastHtmlBind]='updateIcon'
)

View File

@@ -136,9 +136,13 @@ export class AppRootComponent {
ngbModal.open(SafeModeModalComponent)
}
this.updater.check().then(available => {
this.updatesAvailable = available
})
setInterval(() => {
if (this.config.store.enableAutomaticUpdates) {
this.updater.check().then(available => {
this.updatesAvailable = available
})
}
}, 3600 * 12)
this.touchbar.update()
@@ -190,20 +194,6 @@ export class AppRootComponent {
return this.config.store.appearance.tabsLocation === 'left' || this.config.store.appearance.tabsLocation === 'right'
}
async updateApp () {
if ((await this.electron.showMessageBox(
this.hostApp.getWindow(),
{
type: 'warning',
message: 'Installing the update will close all tabs and restart Terminus.',
buttons: ['Cancel', 'Update'],
defaultId: 1,
}
)).response === 1) {
this.updater.update()
}
}
onTabDragStart () {
this.tabsDragging = true
}

View File

@@ -3,5 +3,8 @@
#handle,
[style.background-color]='tab.color',
) {{index + 1}}
.name([title]='tab.customTitle || tab.title') {{tab.customTitle || tab.title}}
.name(
[title]='tab.customTitle || tab.title',
[class.no-hover]='config.store.terminal.hideCloseButton'
) {{tab.customTitle || tab.title}}
button(*ngIf='!config.store.terminal.hideCloseButton',(click)='app.closeTab(tab, true)') ×

View File

@@ -76,7 +76,7 @@ $tabs-height: 38px;
}
}
&:hover .name {
&:hover .name:not(.no-hover) {
-webkit-mask-image: linear-gradient(black 0 0), linear-gradient(to left, transparent 0%, black 100%);
-webkit-mask-size: calc(100% - 60px) auto, 60px auto;
-webkit-mask-repeat: no-repeat;

View File

@@ -4,6 +4,7 @@ import { Injectable } from '@angular/core'
import { Logger, LogService } from './log.service'
import { ElectronService } from './electron.service'
import { ConfigService } from './config.service'
import { HostAppService } from './hostApp.service'
const UPDATES_URL = 'https://api.github.com/repos/eugeny/terminus/releases/latest'
@@ -17,8 +18,9 @@ export class UpdaterService {
private constructor (
log: LogService,
config: ConfigService,
private electron: ElectronService,
private config: ConfigService,
private hostApp: HostAppService,
) {
this.logger = log.create('updater')
@@ -58,10 +60,42 @@ export class UpdaterService {
}
async check (): Promise<boolean> {
if (!this.config.store.enableAutomaticUpdates) {
return false
}
if (!this.electronUpdaterAvailable) {
if (this.electronUpdaterAvailable) {
return new Promise((resolve, reject) => {
// eslint-disable-next-line @typescript-eslint/init-declarations, prefer-const
let cancel
const onNoUpdate = () => {
cancel()
resolve(false)
}
const onUpdate = () => {
cancel()
resolve(this.downloaded)
}
const onError = (err) => {
cancel()
reject(err)
}
cancel = () => {
this.electron.autoUpdater.off('error', onError)
this.electron.autoUpdater.off('update-not-available', onNoUpdate)
this.electron.autoUpdater.off('update-available', onUpdate)
}
this.electron.autoUpdater.on('error', onError)
this.electron.autoUpdater.on('update-not-available', onNoUpdate)
this.electron.autoUpdater.on('update-available', onUpdate)
this.electron.autoUpdater.checkForUpdates()
})
this.electron.autoUpdater.on('update-available', () => {
this.logger.info('Update available')
})
this.electron.autoUpdater.once('update-not-available', () => {
this.logger.info('No updates')
})
} else {
this.logger.debug('Checking for updates through fallback method.')
const response = await axios.get(UPDATES_URL)
const data = response.data
@@ -81,8 +115,18 @@ export class UpdaterService {
if (!this.electronUpdaterAvailable) {
this.electron.shell.openExternal(this.updateURL)
} else {
await this.downloaded
this.electron.autoUpdater.quitAndInstall()
if ((await this.electron.showMessageBox(
this.hostApp.getWindow(),
{
type: 'warning',
message: 'Installing the update will close all tabs and restart Terminus.',
buttons: ['Cancel', 'Update'],
defaultId: 1,
}
)).response === 1) {
await this.downloaded
this.electron.autoUpdater.quitAndInstall()
}
}
}
}