core electron integration (#356)

* core electron integration

* test fixes
This commit is contained in:
Denys Vuika
2018-05-14 04:12:45 +01:00
committed by Cilibiu Bogdan
parent daf7d65c03
commit e1ea9fbfc1
7 changed files with 71 additions and 7 deletions

View File

@@ -23,9 +23,13 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, EventEmitter } from '@angular/core';
import { Router, ActivatedRoute, NavigationEnd } from '@angular/router';
import { TranslationService, PageTitleService, UserPreferencesService, AppConfigService } from '@alfresco/adf-core';
import {
TranslationService, PageTitleService, UserPreferencesService, AppConfigService,
FileModel, UploadService
} from '@alfresco/adf-core';
import { ElectronService } from '@ngstack/electron';
@Component({
selector: 'app-root',
@@ -39,7 +43,9 @@ export class AppComponent implements OnInit {
private pageTitle: PageTitleService,
private translateService: TranslationService,
preferences: UserPreferencesService,
config: AppConfigService) {
config: AppConfigService,
private electronService: ElectronService,
private uploadService: UploadService) {
// TODO: remove once ADF 2.3.0 is out (needs bug fixes)
preferences.defaults.supportedPageSizes = config.get('pagination.supportedPageSizes');
preferences.defaults.paginationSize = config.get('pagination.size');
@@ -69,5 +75,25 @@ export class AppComponent implements OnInit {
pageTitle.setTitle(data.title || '');
}
});
this.electronService.on('app:navigateRoute', (event: any, ...args: string[]) => {
this.router.navigate([...args]);
});
this.electronService.on('app:upload', (event: any, files: any[] = []) => {
const models = files.map(fileInfo => {
const file = new File([fileInfo.data], fileInfo.name);
return new FileModel(file, {
path: fileInfo.path,
parentId: fileInfo.parentId
});
});
if (models.length > 0) {
this.uploadService.addToQueue(...models);
this.uploadService.uploadFilesInTheQueue(new EventEmitter());
}
});
}
}