Move svg processing from main to service.

This commit is contained in:
József Farkas
2016-05-22 23:32:59 +02:00
parent a3396334ae
commit 3e767d7339
3 changed files with 28 additions and 26 deletions

View File

@@ -1,16 +1,32 @@
import { Injectable } from '@angular/core';
import {SvgModule} from '../components/svg-module.model';
@Injectable()
export class DataProviderService {
constructor() { }
getBaseLayer(): any {
return require('xml!../../images/base-layer.svg').svg;
}
getUHKConfig(): any {
return require('json!../../config-serializer/uhk-config.json');
}
getKeyboardSvgAttributes(): { viewBox: string, transform: string, fill: string } {
let svg: any = this.getBaseLayer();
return {
viewBox: svg.$.viewBox,
transform: svg.g[0].$.transform,
fill: svg.g[0].$.fill
};
}
getSvgModules(): SvgModule[] {
let modules = this.getBaseLayer().g[0].g.map(obj => new SvgModule(obj));
return [modules[1], modules[0]]; // TODO: remove if the svg will be correct
}
private getBaseLayer(): any {
return require('xml!../../images/base-layer.svg').svg;
}
}