1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-12-23 10:32:29 +03:00

shorter notification for copying

This commit is contained in:
Eugene Pankov 2021-03-10 22:08:11 +01:00
parent 0bf870738e
commit 836014c270
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
8 changed files with 55 additions and 39 deletions

View File

@ -2,14 +2,16 @@
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
padding: 20px 0 50px;
.toast {
box-shadow: 0 1px 0 rgba(0,0,0,.25);
padding: 10px;
padding: 7px 12px;
background-image: none;
width: auto;
flex-basis: auto;
border-radius: 0.5rem;
font-size: 0.75rem;
&.toast-error {
background-color: #BD362F;

View File

@ -17,6 +17,7 @@ export { Logger, LogService } from '../services/log.service'
export { HomeBaseService } from '../services/homeBase.service'
export { HotkeysService } from '../services/hotkeys.service'
export { HostAppService, Platform } from '../services/hostApp.service'
export { NotificationsService } from '../services/notifications.service'
export { ShellIntegrationService } from '../services/shellIntegration.service'
export { ThemesService } from '../services/themes.service'
export { TabsService } from '../services/tabs.service'

View File

@ -0,0 +1,23 @@
import { Injectable } from '@angular/core'
import { ToastrService } from 'ngx-toastr'
@Injectable({ providedIn: 'root' })
export class NotificationsService {
private constructor (
private toastr: ToastrService,
) { }
notice (text: string): void {
this.toastr.info(text, undefined, {
timeOut: 1000,
})
}
info (text: string, details?: string): void {
this.toastr.info(text, details)
}
error (text: string, details?: string): void {
this.toastr.error(text, details)
}
}

View File

@ -1,7 +1,6 @@
import { Injectable, NgZone } from '@angular/core'
import SerialPort from 'serialport'
import { ToastrService } from 'ngx-toastr'
import { LogService, AppService, SelectorOption, ConfigService } from 'terminus-core'
import { LogService, AppService, SelectorOption, ConfigService, NotificationsService } from 'terminus-core'
import { SettingsTabComponent } from 'terminus-settings'
import { SerialConnection, SerialSession, SerialPortInfo, BAUD_RATES } from '../api'
import { SerialTabComponent } from '../components/serialTab.component'
@ -11,7 +10,7 @@ export class SerialService {
private constructor (
private log: LogService,
private zone: NgZone,
private toastr: ToastrService,
private notifications: NotificationsService,
private app: AppService,
private config: ConfigService,
) { }
@ -51,7 +50,7 @@ export class SerialService {
serial.on('error', error => {
this.zone.run(() => {
if (connected) {
this.toastr.error(error.toString())
this.notifications.error(error.toString())
} else {
reject(error)
}
@ -65,7 +64,7 @@ export class SerialService {
try {
serial.open()
} catch (e) {
this.toastr.error(e.message)
this.notifications.error(e.message)
reject(e)
}
})
@ -142,7 +141,7 @@ export class SerialService {
})
return tab
} catch (error) {
this.toastr.error(`Could not connect: ${error}`)
this.notifications.error(`Could not connect: ${error}`)
throw error
}
}

View File

@ -9,8 +9,7 @@ import * as fs from 'mz/fs'
import { execFile } from 'mz/child_process'
import * as path from 'path'
import * as sshpk from 'sshpk'
import { ToastrService } from 'ngx-toastr'
import { HostAppService, Platform, Logger, LogService, ElectronService, AppService, SelectorOption, ConfigService } from 'terminus-core'
import { HostAppService, Platform, Logger, LogService, ElectronService, AppService, SelectorOption, ConfigService, NotificationsService } from 'terminus-core'
import { SettingsTabComponent } from 'terminus-settings'
import { ALGORITHM_BLACKLIST, SSHConnection, SSHSession } from '../api'
import { PromptModalComponent } from '../components/promptModal.component'
@ -39,7 +38,7 @@ export class SSHService {
private ngbModal: NgbModal,
private hostApp: HostAppService,
private passwordStorage: PasswordStorageService,
private toastr: ToastrService,
private notifications: NotificationsService,
private app: AppService,
private config: ConfigService,
) {
@ -70,7 +69,7 @@ export class SSHService {
privateKey = (await fs.readFile(privateKeyPath)).toString()
} catch (error) {
logCallback?.(colors.bgRed.black(' X ') + 'Could not read the private key file')
this.toastr.error('Could not read the private key file')
this.notifications.error('Could not read the private key file')
}
if (privateKey) {
@ -166,7 +165,7 @@ export class SSHService {
this.zone.run(() => {
if (connected) {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
this.toastr.error(error.toString())
this.notifications.error(error.toString())
} else {
reject(error)
}
@ -289,7 +288,7 @@ export class SSHService {
},
} as any)
} catch (e) {
this.toastr.error(e.message)
this.notifications.error(e.message)
return reject(e)
}
@ -411,7 +410,7 @@ export class SSHService {
return tab
} catch (error) {
this.toastr.error(`Could not connect: ${error}`)
this.notifications.error(`Could not connect: ${error}`)
throw error
}
}

View File

@ -1,11 +1,10 @@
import type { MenuItemConstructorOptions } from 'electron'
import { Observable, Subject, Subscription } from 'rxjs'
import { first } from 'rxjs/operators'
import { ToastrService } from 'ngx-toastr'
import colors from 'ansi-colors'
import { NgZone, OnInit, OnDestroy, Injector, ViewChild, HostBinding, Input, ElementRef, InjectFlags } from '@angular/core'
import { trigger, transition, style, animate, AnimationTriggerMetadata } from '@angular/animations'
import { AppService, ConfigService, BaseTabComponent, ElectronService, HostAppService, HotkeysService, Platform, LogService, Logger, TabContextMenuItemProvider, SplitTabComponent } from 'terminus-core'
import { AppService, ConfigService, BaseTabComponent, ElectronService, HostAppService, HotkeysService, NotificationsService, Platform, LogService, Logger, TabContextMenuItemProvider, SplitTabComponent } from 'terminus-core'
import { BaseSession, SessionsService } from '../services/sessions.service'
import { TerminalFrontendService } from '../services/terminalFrontend.service'
@ -15,11 +14,6 @@ import { ResizeEvent } from './interfaces'
import { TerminalDecorator } from './decorator'
/** @hidden */
export interface ToastrServiceProxy {
info: (_: string) => void
error: (_: string) => void
}
/**
* A class to base your custom terminal tabs on
*/
@ -82,7 +76,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
protected sessions: SessionsService
protected electron: ElectronService
protected terminalContainersService: TerminalFrontendService
protected toastr: ToastrServiceProxy
protected notifications: NotificationsService
protected log: LogService
protected decorators: TerminalDecorator[] = []
protected contextMenuProviders: TabContextMenuItemProvider[]
@ -137,7 +131,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
this.sessions = injector.get(SessionsService)
this.electron = injector.get(ElectronService)
this.terminalContainersService = injector.get(TerminalFrontendService)
this.toastr = injector.get(ToastrService)
this.notifications = injector.get(NotificationsService)
this.log = injector.get(LogService)
this.decorators = injector.get<any>(TerminalDecorator, null, InjectFlags.Optional) as TerminalDecorator[]
this.contextMenuProviders = injector.get<any>(TabContextMenuItemProvider, null, InjectFlags.Optional) as TabContextMenuItemProvider[]
@ -154,7 +148,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
if (this.frontend?.getSelection()) {
this.frontend.copySelection()
this.frontend.clearSelection()
this.toastr.info('Copied')
this.notifications.notice('Copied')
} else {
this.sendInput('\x03')
}
@ -162,7 +156,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
case 'copy':
this.frontend?.copySelection()
this.frontend?.clearSelection()
this.toastr.info('Copied')
this.notifications.notice('Copied')
break
case 'paste':
this.paste()
@ -454,9 +448,9 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
}
if (cwd) {
this.electron.clipboard.writeText(cwd)
this.toastr.info('Copied')
this.notifications.notice('Copied')
} else {
this.toastr.error('Shell does not support current path detection')
this.notifications.error('Shell does not support current path detection')
}
}

View File

@ -1,7 +1,6 @@
import { Component, Input, Output, EventEmitter } from '@angular/core'
import { ToastrService } from 'ngx-toastr'
import { Frontend, SearchOptions } from '../frontends/frontend'
import { ConfigService } from 'terminus-core'
import { ConfigService, NotificationsService } from 'terminus-core'
@Component({
selector: 'search-panel',
@ -20,7 +19,7 @@ export class SearchPanelComponent {
@Output() close = new EventEmitter()
constructor (
private toastr: ToastrService,
private notifications: NotificationsService,
public config: ConfigService,
) { }
@ -35,7 +34,7 @@ export class SearchPanelComponent {
}
if (!this.frontend.findNext(this.query, { ...this.options, incremental: incremental || undefined })) {
this.notFound = true
this.toastr.error('Not found')
this.notifications.notice('Not found')
}
}
@ -45,7 +44,7 @@ export class SearchPanelComponent {
}
if (!this.frontend.findPrevious(this.query, { ...this.options, incremental: incremental || undefined })) {
this.notFound = true
this.toastr.error('Not found')
this.notifications.notice('Not found')
}
}

View File

@ -1,7 +1,6 @@
import { MenuItemConstructorOptions } from 'electron'
import { Injectable, NgZone, Optional, Inject } from '@angular/core'
import { ToastrService } from 'ngx-toastr'
import { ConfigService, BaseTabComponent, TabContextMenuItemProvider, TabHeaderComponent, SplitTabComponent } from 'terminus-core'
import { ConfigService, BaseTabComponent, TabContextMenuItemProvider, TabHeaderComponent, SplitTabComponent, NotificationsService } from 'terminus-core'
import { TerminalTabComponent } from './components/terminalTab.component'
import { UACService } from './services/uac.service'
import { TerminalService } from './services/terminal.service'
@ -14,7 +13,7 @@ export class SaveAsProfileContextMenu extends TabContextMenuItemProvider {
constructor (
private config: ConfigService,
private zone: NgZone,
private toastr: ToastrService,
private notifications: NotificationsService,
) {
super()
}
@ -39,7 +38,7 @@ export class SaveAsProfileContextMenu extends TabContextMenuItemProvider {
profile,
]
this.config.save()
this.toastr.info('Saved')
this.notifications.info('Saved')
}),
},
]
@ -141,7 +140,7 @@ export class CopyPasteContextMenu extends TabContextMenuItemProvider {
constructor (
private zone: NgZone,
private toastr: ToastrService,
private notifications: NotificationsService,
) {
super()
}
@ -158,7 +157,7 @@ export class CopyPasteContextMenu extends TabContextMenuItemProvider {
this.zone.run(() => {
setTimeout(() => {
tab.frontend?.copySelection()
this.toastr.info('Copied')
this.notifications.notice('Copied')
})
})
},