-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0bac920
commit ed98bd1
Showing
18 changed files
with
440 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { PluginEntity } from '@platform/types/bindings/plugins'; | ||
import { bridge } from '@service/bridge'; | ||
import { ParsedPath } from '@platform/types/files'; | ||
|
||
export class PluginDesc { | ||
public name: string = ''; | ||
public desc: string = ''; | ||
public icon: string = ''; | ||
public path: ParsedPath | undefined; | ||
|
||
constructor(public readonly entity: PluginEntity) {} | ||
|
||
public load(): Promise<void> { | ||
return bridge | ||
.files() | ||
.name(this.entity.dir_path) | ||
.then((path: ParsedPath) => { | ||
this.path = path; | ||
this.update(); | ||
}); | ||
} | ||
|
||
protected update() { | ||
this.icon = this.getIcon(); | ||
this.name = this.getName(); | ||
this.desc = this.getDesc(); | ||
} | ||
|
||
protected getIcon(): string { | ||
switch (this.entity.plugin_type) { | ||
case 'Parser': | ||
return 'swap_vert'; | ||
case 'ByteSource': | ||
return 'input'; | ||
} | ||
} | ||
|
||
protected getName(): string { | ||
if (!this.entity.metadata && !this.path) { | ||
return this.entity.dir_path; | ||
} else if (!this.entity.metadata && this.path) { | ||
return this.path.name; | ||
} else if (this.entity.metadata) { | ||
return this.entity.metadata.name; | ||
} else { | ||
return this.entity.dir_path; | ||
} | ||
} | ||
|
||
protected getDesc(): string { | ||
if (!this.entity.metadata && !this.path) { | ||
return this.entity.dir_path; | ||
} else if (!this.entity.metadata && this.path) { | ||
return this.path.name; | ||
} else if (this.entity.metadata && this.entity.metadata.description) { | ||
return this.entity.metadata.description; | ||
} else { | ||
return this.entity.dir_path; | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
application/client/src/app/ui/tabs/plugins/details/component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Component, ChangeDetectorRef, Input } from '@angular/core'; | ||
import { Ilc, IlcInterface } from '@env/decorators/component'; | ||
import { Initial } from '@env/decorators/initial'; | ||
import { ChangesDetector } from '@ui/env/extentions/changes'; | ||
import { PluginDesc } from '../desc'; | ||
import { Provider } from '../provider'; | ||
|
||
@Component({ | ||
selector: 'app-plugins-manager-details', | ||
templateUrl: './template.html', | ||
styleUrls: ['./styles.less'], | ||
standalone: false, | ||
}) | ||
@Initial() | ||
@Ilc() | ||
export class Details extends ChangesDetector { | ||
@Input() public provider!: Provider; | ||
@Input() public plugin!: PluginDesc; | ||
|
||
constructor(cdRef: ChangeDetectorRef) { | ||
super(cdRef); | ||
} | ||
} | ||
|
||
export interface Details extends IlcInterface {} |
12 changes: 12 additions & 0 deletions
12
application/client/src/app/ui/tabs/plugins/details/styles.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@import '../../../styles/variables.less'; | ||
|
||
:host { | ||
position: relative; | ||
& div.info { | ||
margin: 0 6px; | ||
overflow: hidden; | ||
& p { | ||
text-align: left; | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
application/client/src/app/ui/tabs/plugins/details/template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class="info"> | ||
<p class="title t-normal color-scheme-0">{{plugin.name}}</p> | ||
<p class="subtitle t-small color-scheme-2">{{plugin.desc}}</p> | ||
</div> |
64 changes: 64 additions & 0 deletions
64
application/client/src/app/ui/tabs/plugins/list/component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Component, ChangeDetectorRef, AfterContentInit, Input } from '@angular/core'; | ||
import { Ilc, IlcInterface } from '@env/decorators/component'; | ||
import { Initial } from '@env/decorators/initial'; | ||
import { ChangesDetector } from '@ui/env/extentions/changes'; | ||
import { Provider } from '../provider'; | ||
import { PluginDesc } from '../desc'; | ||
|
||
export enum Target { | ||
Active, | ||
Available, | ||
} | ||
|
||
@Component({ | ||
selector: 'app-plugins-manager-list', | ||
templateUrl: './template.html', | ||
styleUrls: ['./styles.less'], | ||
standalone: false, | ||
}) | ||
@Initial() | ||
@Ilc() | ||
export class List extends ChangesDetector implements AfterContentInit { | ||
@Input() public provider!: Provider; | ||
@Input() public target!: Target; | ||
|
||
public plugins: PluginDesc[] = []; | ||
|
||
constructor(cdRef: ChangeDetectorRef) { | ||
super(cdRef); | ||
} | ||
|
||
public ngAfterContentInit(): void { | ||
this.env().subscriber.register( | ||
this.provider.subjects.get().load.subscribe(() => { | ||
this.update(); | ||
}), | ||
this.provider.subjects.get().state.subscribe(() => { | ||
this.update(); | ||
}), | ||
); | ||
} | ||
|
||
public getTitle(): string { | ||
switch (this.target) { | ||
case Target.Active: | ||
return 'Active Plugins'; | ||
case Target.Available: | ||
return 'Available Plugins'; | ||
} | ||
} | ||
|
||
protected update() { | ||
switch (this.target) { | ||
case Target.Active: | ||
this.plugins = this.provider.get().active(); | ||
break; | ||
case Target.Available: | ||
this.plugins = this.provider.get().available(); | ||
break; | ||
} | ||
this.detectChanges(); | ||
} | ||
} | ||
|
||
export interface List extends IlcInterface {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@import '../../../styles/variables.less'; | ||
|
||
:host { | ||
position: relative; | ||
display: block; | ||
width: 100%; | ||
overflow: hidden; | ||
} |
18 changes: 18 additions & 0 deletions
18
application/client/src/app/ui/tabs/plugins/list/template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<mat-card> | ||
<mat-card-title>{{getTitle()}}</mat-card-title> | ||
<mat-card-content style="text-align: center"> | ||
<ng-container *ngIf="provider.state.loading"> | ||
<mat-progress-bar mode="indeterminate"></mat-progress-bar> | ||
</ng-container> | ||
<ng-container *ngIf="!provider.state.loading"> | ||
<app-plugins-manager-plugin | ||
[plugin]="plugin" | ||
[provider]="provider" | ||
*ngFor="let plugin of plugins" | ||
></app-plugins-manager-plugin> | ||
</ng-container> | ||
<ng-container *ngIf="!provider.state.loading && plugins.length === 0"> | ||
<p class="t-normal color-scheme-2">No plugins</p> | ||
</ng-container> | ||
</mat-card-content> | ||
</mat-card> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
application/client/src/app/ui/tabs/plugins/plugin/component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Component, ChangeDetectorRef, Input, HostListener } from '@angular/core'; | ||
import { Ilc, IlcInterface } from '@env/decorators/component'; | ||
import { Initial } from '@env/decorators/initial'; | ||
import { ChangesDetector } from '@ui/env/extentions/changes'; | ||
import { PluginDesc } from '../desc'; | ||
import { Provider } from '../provider'; | ||
|
||
@Component({ | ||
selector: 'app-plugins-manager-plugin', | ||
templateUrl: './template.html', | ||
styleUrls: ['./styles.less'], | ||
standalone: false, | ||
}) | ||
@Initial() | ||
@Ilc() | ||
export class Plugin extends ChangesDetector { | ||
@Input() public provider!: Provider; | ||
@Input() public plugin!: PluginDesc; | ||
|
||
@HostListener('click', ['$event']) onClick(_event: MouseEvent) { | ||
this.provider.select(this.plugin.entity.dir_path); | ||
} | ||
constructor(cdRef: ChangeDetectorRef) { | ||
super(cdRef); | ||
} | ||
} | ||
|
||
export interface Plugin extends IlcInterface {} |
Oops, something went wrong.