mirror of
https://github.com/Eugeny/tabby.git
synced 2025-10-04 05:54:57 +00:00
wip
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
"@types/webpack-env": "1.13.0",
|
||||
"awesome-typescript-loader": "3.1.2",
|
||||
"css-loader": "^0.28.0",
|
||||
"ngx-pipes": "^1.6.1",
|
||||
"pug": "^2.0.0-beta11",
|
||||
"pug-loader": "^2.3.0",
|
||||
"raw-loader": "^0.5.1",
|
||||
|
@@ -2,63 +2,81 @@
|
||||
strong Error in {{erroredPlugin}}:
|
||||
pre {{errorMessage}}
|
||||
|
||||
button.btn.btn-outline-info.btn-sm.pull-right((click)='openPluginsFolder()')
|
||||
i.fa.fa-folder
|
||||
span Plugins folder
|
||||
|
||||
h3 Installed
|
||||
|
||||
.list-group
|
||||
ng-container(*ngFor='let plugin of pluginManager.installedPlugins')
|
||||
ng-container(*ngFor='let plugin of pluginManager.installedPlugins|orderBy:"name"')
|
||||
.list-group-item.flex-column.align-items-start(*ngIf='knownUpgrades[plugin.name]')
|
||||
.d-flex.w-100
|
||||
h5.mr-auto.mb-0 {{plugin.name}}
|
||||
.mr-auto.d-flex.flex-column
|
||||
strong {{plugin.name}}
|
||||
small.text-muted.mb-0 {{plugin.description}}
|
||||
p.mb-0.mr-3 {{plugin.version}}
|
||||
button.btn.btn-outline-primary(
|
||||
*ngIf='npmInstalled',
|
||||
(click)='upgradePlugin(plugin)',
|
||||
[disabled]='busy[plugin.name] != undefined'
|
||||
)
|
||||
i.fa.fa-fw.fa-arrow-up(*ngIf='busy[plugin.name] != BusyState.Installing')
|
||||
i.fa.fa-fw.fa-circle-o-notch.fa-spin(*ngIf='busy[plugin.name] == BusyState.Installing')
|
||||
span Upgrade ({{knownUpgrades[plugin.name].version}})
|
||||
small.text-muted.mb-0 {{plugin.description}}
|
||||
|
||||
ng-container(*ngFor='let plugin of pluginManager.installedPlugins')
|
||||
ng-container(*ngFor='let plugin of pluginManager.installedPlugins|orderBy:"name"')
|
||||
.list-group-item.flex-column.align-items-start(*ngIf='!knownUpgrades[plugin.name]')
|
||||
.d-flex.w-100
|
||||
h5.mr-auto.mb-0 {{plugin.name}}
|
||||
.mr-auto.d-flex.flex-column
|
||||
strong {{plugin.name}}
|
||||
small.text-muted.mb-0 {{plugin.description}}
|
||||
p.mb-0.mr-3 {{plugin.version}}
|
||||
button.btn.btn-outline-danger(
|
||||
(click)='uninstallPlugin(plugin)',
|
||||
*ngIf='!plugin.isBuiltin',
|
||||
*ngIf='!plugin.isBuiltin && npmInstalled',
|
||||
[disabled]='busy[plugin.name] != undefined'
|
||||
)
|
||||
i.fa.fa-fw.fa-trash-o(*ngIf='busy[plugin.name] != BusyState.Uninstalling')
|
||||
i.fa.fa-fw.fa-circle-o-notch.fa-spin(*ngIf='busy[plugin.name] == BusyState.Uninstalling')
|
||||
small.text-muted.mb-0 {{plugin.description}}
|
||||
|
||||
.text-center.mt-5(*ngIf='npmMissing')
|
||||
h4 NPM not installed
|
||||
p.mb-2 The Node Package Manager is required to install Terminus plugins.
|
||||
.btn-group
|
||||
button.btn.btn-outline-primary((click)='downloadNPM()')
|
||||
i.fa.fa-download
|
||||
span Download NPM
|
||||
button.btn.btn-outline-info((click)='checkNPM()')
|
||||
i.fa.fa-refresh
|
||||
span Try again
|
||||
|
||||
div(*ngIf='npmInstalled')
|
||||
h3.mt-4 Available
|
||||
|
||||
.input-group.mb-4
|
||||
.input-group-addon
|
||||
i.fa.fa-fw.fa-circle-o-notch.fa-spin(*ngIf='!availablePluginsReady')
|
||||
i.fa.fa-fw.fa-search(*ngIf='availablePluginsReady')
|
||||
input.form-control(
|
||||
type='text',
|
||||
'[(ngModel)]'='_1',
|
||||
(ngModelChange)='searchAvailable(_1)',
|
||||
placeholder='Search plugins'
|
||||
)
|
||||
|
||||
|
||||
h3.mt-4 Available
|
||||
|
||||
.input-group.mb-4
|
||||
.input-group-addon
|
||||
i.fa.fa-fw.fa-circle-o-notch.fa-spin(*ngIf='!availablePluginsReady')
|
||||
i.fa.fa-fw.fa-search(*ngIf='availablePluginsReady')
|
||||
input.form-control(
|
||||
type='text',
|
||||
'[(ngModel)]'='_1',
|
||||
(ngModelChange)='searchAvailable(_1)',
|
||||
placeholder='Search plugins'
|
||||
)
|
||||
|
||||
|
||||
.list-group(*ngIf='availablePlugins$')
|
||||
ng-container(*ngFor='let plugin of (availablePlugins$|async)')
|
||||
.list-group-item.flex-column.align-items-start(*ngIf='!isAlreadyInstalled(plugin)')
|
||||
.d-flex.w-100
|
||||
h5.mr-auto.mb-0 {{plugin.name}}
|
||||
p.mb-0.mr-3 {{plugin.version}}
|
||||
button.btn.btn-outline-primary(
|
||||
(click)='installPlugin(plugin)',
|
||||
[disabled]='busy[plugin.name] != undefined'
|
||||
)
|
||||
i.fa.fa-fw.fa-download(*ngIf='busy[plugin.name] != BusyState.Installing')
|
||||
i.fa.fa-fw.fa-circle-o-notch.fa-spin(*ngIf='busy[plugin.name] == BusyState.Installing')
|
||||
span Install
|
||||
small.text-muted.mb-0 {{plugin.description}}
|
||||
.list-group(*ngIf='availablePlugins$')
|
||||
ng-container(*ngFor='let plugin of (availablePlugins$|async|orderBy:"name")')
|
||||
.list-group-item.flex-column.align-items-start(*ngIf='!isAlreadyInstalled(plugin)')
|
||||
.d-flex.w-100
|
||||
.mr-auto.d-flex.flex-column
|
||||
strong {{plugin.name}}
|
||||
small.text-muted.mb-0 {{plugin.description}}
|
||||
p.mb-0.mr-3 {{plugin.version}}
|
||||
button.btn.btn-outline-primary(
|
||||
(click)='installPlugin(plugin)',
|
||||
[disabled]='busy[plugin.name] != undefined'
|
||||
)
|
||||
i.fa.fa-fw.fa-download(*ngIf='busy[plugin.name] != BusyState.Installing')
|
||||
i.fa.fa-fw.fa-circle-o-notch.fa-spin(*ngIf='busy[plugin.name] == BusyState.Installing')
|
||||
|
@@ -2,7 +2,7 @@ import { BehaviorSubject, Observable } from 'rxjs'
|
||||
import * as semver from 'semver'
|
||||
|
||||
import { Component, Input } from '@angular/core'
|
||||
import { ConfigService } from 'terminus-core'
|
||||
import { ConfigService, HostAppService } from 'terminus-core'
|
||||
import { IPluginInfo, PluginManagerService } from '../services/pluginManager.service'
|
||||
|
||||
enum BusyState { Installing, Uninstalling }
|
||||
@@ -20,9 +20,12 @@ export class PluginsSettingsTabComponent {
|
||||
@Input() busy: {[id: string]: BusyState} = {}
|
||||
@Input() erroredPlugin: string
|
||||
@Input() errorMessage: string
|
||||
@Input() npmInstalled = false
|
||||
@Input() npmMissing = false
|
||||
|
||||
constructor (
|
||||
private config: ConfigService,
|
||||
private hostApp: HostAppService,
|
||||
public pluginManager: PluginManagerService
|
||||
) {
|
||||
}
|
||||
@@ -42,6 +45,20 @@ export class PluginsSettingsTabComponent {
|
||||
this.knownUpgrades[plugin.name] = available.find(x => x.name === plugin.name && semver.gt(x.version, plugin.version))
|
||||
}
|
||||
})
|
||||
this.checkNPM()
|
||||
}
|
||||
|
||||
openPluginsFolder (): void {
|
||||
this.hostApp.getShell().openItem(this.pluginManager.userPluginsPath)
|
||||
}
|
||||
|
||||
downloadNPM (): void {
|
||||
this.hostApp.getShell().openExternal('https://nodejs.org/en/download/current/')
|
||||
}
|
||||
|
||||
async checkNPM () {
|
||||
this.npmInstalled = await this.pluginManager.isNPMInstalled()
|
||||
this.npmMissing = !this.npmInstalled
|
||||
}
|
||||
|
||||
searchAvailable (query: string) {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { NgModule } from '@angular/core'
|
||||
import { BrowserModule } from '@angular/platform-browser'
|
||||
import { FormsModule } from '@angular/forms'
|
||||
import { NgPipesModule } from 'ngx-pipes'
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
|
||||
|
||||
import { SettingsTabProvider } from 'terminus-settings'
|
||||
@@ -14,6 +15,7 @@ import { PluginsSettingsTabProvider } from './settings'
|
||||
BrowserModule,
|
||||
FormsModule,
|
||||
NgbModule,
|
||||
NgPipesModule,
|
||||
],
|
||||
providers: [
|
||||
{ provide: SettingsTabProvider, useClass: PluginsSettingsTabProvider, multi: true },
|
||||
|
@@ -22,6 +22,7 @@ export class PluginManagerService {
|
||||
builtinPluginsPath: string = (window as any).builtinPluginsPath
|
||||
userPluginsPath: string = (window as any).userPluginsPath
|
||||
installedPlugins: IPluginInfo[] = (window as any).installedPlugins
|
||||
npmBinary = 'npm'
|
||||
|
||||
constructor (
|
||||
log: LogService,
|
||||
@@ -29,6 +30,15 @@ export class PluginManagerService {
|
||||
this.logger = log.create('pluginManager')
|
||||
}
|
||||
|
||||
async isNPMInstalled (): Promise<boolean> {
|
||||
try {
|
||||
await exec(`${this.npmBinary} -v`)
|
||||
return true
|
||||
} catch (_) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
listAvailable (query?: string): Observable<IPluginInfo[]> {
|
||||
return Observable
|
||||
.fromPromise(
|
||||
@@ -45,14 +55,14 @@ export class PluginManagerService {
|
||||
}
|
||||
|
||||
async installPlugin (plugin: IPluginInfo) {
|
||||
let result = await exec(`npm --prefix "${this.userPluginsPath}" install ${plugin.packageName}@${plugin.version}`)
|
||||
let result = await exec(`${this.npmBinary} --prefix "${this.userPluginsPath}" install ${plugin.packageName}@${plugin.version}`)
|
||||
console.log(result)
|
||||
this.installedPlugins = this.installedPlugins.filter(x => x.packageName !== plugin.packageName)
|
||||
this.installedPlugins.push(plugin)
|
||||
}
|
||||
|
||||
async uninstallPlugin (plugin: IPluginInfo) {
|
||||
await exec(`npm --prefix "${this.userPluginsPath}" remove ${plugin.packageName}`)
|
||||
await exec(`${this.npmBinary} --prefix "${this.userPluginsPath}" remove ${plugin.packageName}`)
|
||||
this.installedPlugins = this.installedPlugins.filter(x => x.packageName !== plugin.packageName)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user