import { Component, Input, Pipe, PipeTransform } from '@angular/core';
import { ConfigService, IProject, ProjectType } from "../services/config.service";
import { AlertService } from "../services/alert.service";
@Component({
selector: 'project-card',
template: `
Project ID |
{{ project.id }} |
Sharing type |
{{ project.type | readableType }} |
Local path |
{{ project.pathClient }} |
Server path |
{{ project.pathServer }} |
Status |
{{ project.status }} - {{ project.isInSync ? "Up to Date" : "Out of Sync"}}
|
`,
styleUrls: ['./app/config/config.component.css']
})
export class ProjectCardComponent {
@Input() project: IProject;
constructor(
private alert: AlertService,
private configSvr: ConfigService
) {
}
delete(prj: IProject) {
this.configSvr.deleteProject(prj)
.subscribe(res => {
}, err => {
this.alert.error("Delete local ERROR: " + err);
});
}
sync(prj: IProject) {
this.configSvr.syncProject(prj)
.subscribe(res => {
}, err => {
this.alert.error("ERROR: " + err);
});
}
}
// Remove APPS. prefix if translate has failed
@Pipe({
name: 'readableType'
})
export class ProjectReadableTypePipe implements PipeTransform {
transform(type: ProjectType): string {
switch (type) {
case ProjectType.NATIVE_PATHMAP: return "Native (path mapping)";
case ProjectType.SYNCTHING: return "Cloud (Syncthing)";
default: return String(type);
}
}
}