Code cleaned up

This commit is contained in:
Piotr Pekala 2019-08-28 04:19:20 -07:00
parent eca520073b
commit 94240ee783
3 changed files with 11 additions and 8 deletions

View File

@ -14,6 +14,10 @@ export class MockedSymbolService {
public list() {
return of([]);
}
public raw() {
return of('<svg></svg>')
}
}
describe('Symbols component', () => {

View File

@ -10,12 +10,15 @@ import { ToolsService } from '../../../services/tools.service';
import { D3MapComponent } from '../../../cartography/components/d3-map/d3-map.component';
import { ANGULAR_MAP_DECLARATIONS } from '../../../cartography/angular-map.imports';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { SymbolService } from '../../../services/symbol.service';
import { MockedSymbolService } from '../../preferences/common/symbols/symbols.component.spec';
describe('ProjectMapMenuComponent', () => {
let component: ProjectMapMenuComponent;
let fixture: ComponentFixture<ProjectMapMenuComponent>;
let drawingService = new MockedDrawingService();
let mapSettingService = new MapSettingsService();
let mockedSymbolService = new MockedSymbolService;
beforeEach(async(() => {
TestBed.configureTestingModule({
@ -23,7 +26,8 @@ describe('ProjectMapMenuComponent', () => {
providers: [
{ provide: DrawingService, useValue: drawingService },
{ provide: ToolsService },
{ provide: MapSettingsService, useValue: mapSettingService }
{ provide: MapSettingsService, useValue: mapSettingService },
{ provide: SymbolService, useValue: mockedSymbolService}
],
declarations: [ProjectMapMenuComponent, D3MapComponent, ...ANGULAR_MAP_DECLARATIONS],
schemas: [NO_ERRORS_SCHEMA]

View File

@ -4,11 +4,8 @@ import { Server } from '../../../models/server';
import { ToolsService } from '../../../services/tools.service';
import { MapSettingsService } from '../../../services/mapsettings.service';
import { DrawingService } from '../../../services/drawing.service';
import { SymbolsDataSource } from '../../../cartography/datasources/symbols-datasource';
import * as svg from 'save-svg-as-png';
import { MapSymbolsDataSource } from '../../../cartography/datasources/map-datasource';
import { SymbolService } from '../../../services/symbol.service';
import { Observable } from 'rxjs';
@Component({
@ -33,8 +30,6 @@ export class ProjectMapMenuComponent implements OnInit, OnDestroy {
private toolsService: ToolsService,
private mapSettingsService: MapSettingsService,
private drawingService: DrawingService,
private symbolsDataSource: SymbolsDataSource,
private mapSymbolsDataSource: MapSymbolsDataSource,
private symbolService: SymbolService
) {}
@ -47,7 +42,7 @@ export class ProjectMapMenuComponent implements OnInit, OnDestroy {
while (i < splittedSvg.length) {
let splittedImage = splittedSvg[i].split("\"");
let splittedUrl = splittedImage[1].split("/");
let elem = await this.symbolService.raw(this.server, splittedUrl[7]).toPromise();
let splittedElement = elem.split('-->');
splittedSvg[i] = splittedElement[1].substring(2);
@ -59,7 +54,7 @@ export class ProjectMapMenuComponent implements OnInit, OnDestroy {
placeholder.innerHTML = svgString;
let element = placeholder.firstChild;
svg.saveSvgAsPng(element, "plot.png");
svg.saveSvgAsPng(element, "screenshot.png");
}
public addDrawing(selectedObject: string) {