Я в настоящее время разрабатываю приложение каталога с angular 7, на данный момент все идет хорошо, просто я застрял в этой проблеме, и я не знаю, как ее решить.
Проблема в том, что у меня есть список с несколькими параметрами, и его параметры загружаются из файла .ts, поэтому в моем файле. html я не помещаю слишком много в мой список выбора, а только один, который загружает все содержимое из моего .ts файл вроде этого:
<option *ngFor="let worker of workerExportList" [ngValue]="worker" data-toggle="tooltip" data-placement="top" title="Tooltip on top">{{worker.label}}</option>
Вот изображение из моего списка:
Я хочу, чтобы каждый раз, когда я просматриваю Опция из этого списка отображает всплывающие подсказки.
Пример на моей мыши помещен в «Экспорт каталогов». Отображается всплывающая подсказка, которая указывает, например, «Привет экспортировать каталоги», а когда я наведу указатель мыши на другую опцию список, например, «Экспорт сопоставлений», другой плакат всплывающих подсказок, например, «Приветствия экспорта сопоставлений».
На данный момент я не смог этого сделать, единственное, что мне удалось do - это отображение уникальных всплывающих подсказок, которые отображаются во всех параметрах списка.
вот мой код из моего компонента. html страница:
и вот код для моего component.ts:
import { Observable } from 'rxjs/Rx';
import { Http, RequestOptions, Headers, ResponseContentType, Response } from '@angular/http';
import { environment } from './../../../../environments/environment';
import { ExportService } from './../../exportDirectoryBrowsing/export.service';
import { sideMenuComponent } from './../../../layout/side-menu-component/side-menu.component';
import { WorkerParameterInfo } from './../workerParameterInfo';
import { WorkerExport } from './WorkerExport';
import { MappingSystemService } from './../../mappingSystem/mapping-system.service';
import { CatalogService } from './../../catalogue/Catalog.service';
import { Catalog } from './../../catalogue/Catalog';
import { MappingSystem } from './../../mappingSystem/MappingSystem';
import { MappingContext } from './../../mappingContext/MappingContext';
import { Component, ViewChild } from '@angular/core';
import { LazyLoadEvent, ConfirmationService, TreeNode, Message } from 'primeng/primeng';
import { FormsModule } from '@angular/forms';
import { WorkersService } from '../worker.service';
import { SharedService } from './../../../shared.service';
import { FormGroup, FormBuilder } from '@angular/forms';
import * as FileSaver from 'file-saver';
import { DialogModule, Dialog } from 'primeng/components/dialog/dialog';
import {ProgressSpinnerModule} from 'primeng/components/progressspinner/progressspinner';
import { Timeouts } from 'selenium-webdriver';
@Component({
selector: 'export',
templateUrl: './export.component.html',
styleUrls: ['./../../global.css'],
providers: [WorkersService, ConfirmationService]
})
export class ExportComponent {
value = 0;
workerForm: FormGroup;
selectedExportWorker: WorkerExport;
selectedMappingContext: MappingContext;
selectedMappingSystem: MappingSystem;
selectedCatalog: Catalog;
catalogues: Catalog[] = [];
workerExportList: WorkerExport[] = [];
mappingSystems: MappingSystem[] = [];
blankObject: Catalog = new Catalog(0, 'TOUS', 'TOUS', null);
blankObjectMS: MappingSystem = new MappingSystem(0, 'TOUS', null, null, null, null, null);
blanckObjectMSAllInAZip : MappingSystem = new MappingSystem(100, 'TOUS DANS UN ZIP', null, null, null, null, null);
isHiddenCatalogue = false;
isHiddenMappingSystem = false;
filesTree2: TreeNode[] = [];
selectedFile: TreeNode;
msgs: Message[] = [];
display: Boolean = false;
response: Response;
@ViewChild('dialog') dialog: DialogModule;
@ViewChild('spinner') spinner: ProgressSpinnerModule;
constructor(private workersService: WorkersService, private api: SharedService,
fb: FormBuilder, private catalogService: CatalogService, private mappingSystemService: MappingSystemService,
private exportService: ExportService, private confirmationService: ConfirmationService, private http: Http) {
this.workerExportList.push(new WorkerExport('catalogueExport', 'Export des catalogues'));
this.workerExportList.push(new WorkerExport('mappingExportV1_0', 'Export des mappings S1F0'));
this.workerExportList.push(new WorkerExport('mappingExport', 'Export des mappings'));
this.workerExportList.push(new WorkerExport('release', 'Livraison'));
this.workerExportList.push(new WorkerExport('summaryExport', 'Export du rapport XLS - mapping des scopes'));
this.workerExportList.push(new WorkerExport('koalaExport', 'Export koala'));
this.workerExportList.push(new WorkerExport('pamdaExport', 'Export pamda'));
this.workerExportList.push(new WorkerExport('orphanExport', 'Export orphelins - entités non mappées'));
this.workerExportList.push(new WorkerExport('hierarchyValidator', 'Validation hiérarchie - entités sans relation'));
this.workerExportList.push(new WorkerExport('dataExport', 'Export des données'));
this.workerForm = fb.group({
'selectedExportWorker': '',
'selectedCatalog': this.blankObject,
'selectedMappingSystem': this.blankObjectMS
})
this.selectedCatalog = this.blankObject;
this.selectedMappingSystem = this.blankObjectMS;
this.api.getDataMappingContext().subscribe(_sharingData => {
this.selectedMappingContext = _sharingData;
if (_sharingData) {
this.exportService.getByMappingCOntext(_sharingData.id).subscribe(data => {
this.createTree(data, this.filesTree2, null);
console.log(this.filesTree2);
});
}
});
}
ngOnInit() {
localStorage.removeItem('mapping');
localStorage.removeItem('page');
this.api.getDataMappingContext().subscribe(mappingContext => {
if (mappingContext != null) {
this.selectedMappingContext = mappingContext;
this.mappingSystemService.getByMappingContext(this.selectedMappingContext.id).subscribe(data => this.mappingSystems = data);
this.catalogService.getCatalogByMappingContext(this.selectedMappingContext.id).subscribe(data => this.catalogues = data);
}
});
}
exportCatalogue() {
return this.workersService.exportCatalogue(new WorkerParameterInfo()).subscribe();
}
selectWorker() {
this.value = 0;
if (this.selectedExportWorker != null && (
this.selectedExportWorker.code === 'catalogueExport' ||
this.selectedExportWorker.code === 'dataExport')) {
this.isHiddenCatalogue = false;
} else {
this.isHiddenCatalogue = true ;
}
if (this.selectedExportWorker != null && this.selectedExportWorker.code === 'koalaExport') {
this.isHiddenMappingSystem = false;
} else {
this.isHiddenMappingSystem = true;
}
}
executer() {
this.value = 60;
let workerParameterInfo = new WorkerParameterInfo();
workerParameterInfo.currentMappingContext = this.selectedMappingContext.id;
workerParameterInfo.disabledByUser = false;
if (this.selectedExportWorker.code === 'catalogueExport') {
this.display = true;
workerParameterInfo.catalogueIdOrALL = this.selectedCatalog.id.toString();
this.workersService.exportCatalogue(workerParameterInfo).subscribe((res: Response) => {
console.log('response catalogueExport :', res);
this.display = false;
this.refresh();
});
} else if (this.selectedExportWorker.code === 'mappingExportV1_0') {
this.display = true;
this.workersService.exportMappingV10(workerParameterInfo).subscribe((res: Response) => {
this.display = false;
this.refresh();
});
} else if (this.selectedExportWorker.code === 'mappingExport') {
this.display = true;
this.workersService.exportMapping(workerParameterInfo).subscribe((res: Response) => {
this.display = false;
this.refresh();
});
} else if (this.selectedExportWorker.code === 'koalaExport') {
this.display = true;
workerParameterInfo.mappingSystemIdOrALL = this.selectedMappingSystem.id.toString();
console.log('koala workerParameterInfo :', workerParameterInfo.mappingSystemIdOrALL);
this.workersService.exportKoala(workerParameterInfo).subscribe((res: Response) => {
console.log(res);
this.display = false;
this.refresh();
});
} else if (this.selectedExportWorker.code === 'release') {
this.display = true;
this.workersService.exportLivraison(workerParameterInfo).subscribe((res: Response) => {
this.display = false;
this.refresh();
});
} else if (this.selectedExportWorker.code === 'summaryExport') {
this.display = true;
this.workersService.exportSummary(workerParameterInfo).subscribe((res: Response) => {
this.display = false;
this.refresh();
});
} else if (this.selectedExportWorker.code === 'pamdaExport') {
this.display = true;
this.workersService.exportPamda(workerParameterInfo).subscribe((res: Response) => {
this.display = false;
this.refresh();
});
} else if (this.selectedExportWorker.code === 'orphanExport') {
this.display = true;
this.workersService.exportOrphan(workerParameterInfo).subscribe((res: Response) => {
this.display = false;
this.refresh();
});
} else if (this.selectedExportWorker.code === 'hierarchyValidator') {
this.display = true;
this.workersService.validateHierarchy(workerParameterInfo).subscribe((res: Response) => {
this.display = false;
this.refresh();
});
} else if (this.selectedExportWorker.code === 'dataExport') {
this.display = true;
workerParameterInfo.catalogueIdOrALL = this.selectedCatalog.id.toString();
this.workersService.exportData(workerParameterInfo).subscribe((res: Response) => {
this.display = false;
this.refresh();
});
}
this.value = 90;
this.refresh();
this.value = 100;
}
createTree(data: any[], tree: TreeNode[], parent: TreeNode) {
// console.log('creating Tree From: ', data);
data.forEach(dir => {
let treeNode: TreeNode = {
label: '',
data: '',
children: [],
leaf: false,
expandedIcon: '',
collapsedIcon: '',
icon: '',
expanded: true,
parent: {}
};
if (dir.leaf === false) {
treeNode.label = dir.label;
treeNode.expandedIcon = 'fa-folder-open';
treeNode.collapsedIcon = 'fa-folder';
treeNode.parent = parent;
this.createTree(dir.children, treeNode.children, treeNode)
tree.push(treeNode);
} else {
treeNode.label = dir.label;
treeNode.leaf = true;
treeNode.data = dir.data;
treeNode.parent = parent;
if (treeNode.label.endsWith('zip')) {
treeNode.icon = 'fa-file-archive';
} else if (treeNode.label.endsWith('xml')) {
treeNode.icon = 'fa-file-code';
} else if (treeNode.label.endsWith('xls')) {
treeNode.icon = 'fa-file-excel';
} else if (treeNode.label.endsWith('txt')) {
treeNode.icon = 'fa-file';
} else {
treeNode.icon = 'fa-file';
}
tree.push(treeNode);
}
});
}
confirmDelete() {
this.confirmationService.confirm({
message: 'Êtes-vous sûr de vouloir supprimer cet objet?',
header: 'Confirmation de suppression',
icon: 'fa fa-trash',
accept: () => {
this.deleteFile();
}
});
}
nodeSelect(event) {
if (event.node.leaf === false) {
this.selectedFile = null;
}
}
deleteFile() {
this.exportService.delete(this.selectedFile.data).subscribe(() => {
this.selectedFile.parent.children.splice(this.selectedFile.parent.children.findIndex(
child => child.data === this.selectedFile.data), 1);
this.showSuccess('Fichier supprimé avec succès');
});
}
downloadFile() {
const headers = new Headers();
headers.append('Content-Type', 'application/json');
let requestOptions = new RequestOptions({
headers: headers,
responseType: ResponseContentType.Blob, // dont forget to import the enum
// In case you get Module not found: Error: Can't resolve '@angular/http/src/enums', just use 3 instead ex 'responseType:3'
});
let workerParameterInfo = new WorkerParameterInfo();
workerParameterInfo.pathFile = this.selectedFile.data;
let bodyString = JSON.stringify(workerParameterInfo);
this.http.post(`${environment.url.base}${environment.url.pamda.downloadFile}`, bodyString, requestOptions).subscribe(res => {
FileSaver.saveAs(res.blob(), this.selectedFile.label)
});
}
refresh() {
this.filesTree2 = [];
if (this.selectedMappingContext) {
this.exportService.getByMappingCOntext(this.selectedMappingContext.id).subscribe(data => {
this.createTree(data, this.filesTree2, null);
// console.log(this.filesTree2);
})
}
}
showError() {
this.msgs = [];
this.msgs.push({ severity: 'error', summary: 'Message d\'erreur', detail: 'Vous ne pouvez pas supprimer ce catalogue' });
}
showSuccess(details) {
this.msgs = [];
this.msgs.push({ severity: 'success', summary: 'Succès', detail: details });
}
}
Может кто-нибудь, пожалуйста, помогите мне ??