From 41fc9f5e6d4f065be2ba608f83c46b3f610d9880 Mon Sep 17 00:00:00 2001 From: crusader Date: Thu, 11 Oct 2018 00:38:56 +0900 Subject: [PATCH] ing --- src/app/app.component.html | 8 ++++---- src/app/app.component.ts | 6 +++--- .../component/menu/export-csv.component.html | 3 --- .../component/menu/export-png.component.html | 4 ++++ ...mponent.scss => export-png.component.scss} | 0 ...v.component.ts => export-png.component.ts} | 17 +++++++++++++---- src/app/component/menu/index.ts | 4 ++-- src/commons/type/menu-event.ts | 3 +++ src/commons/type/menu-ids.ts | 3 +++ src/electron/menu/build-default.ts | 19 +++++++++++++++++++ 10 files changed, 51 insertions(+), 16 deletions(-) delete mode 100644 src/app/component/menu/export-csv.component.html create mode 100644 src/app/component/menu/export-png.component.html rename src/app/component/menu/{export-csv.component.scss => export-png.component.scss} (100%) rename src/app/component/menu/{export-csv.component.ts => export-png.component.ts} (70%) diff --git a/src/app/app.component.html b/src/app/app.component.html index 85e04cc..8dacc6d 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -33,12 +33,12 @@ - - + - - + + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index b546585..7e693d2 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -22,7 +22,7 @@ export class AppComponent implements OnInit, AfterContentInit, AfterViewInit, On menuSubscription: Subscription; displayAbout: boolean; - displayExportCSV: boolean; + displayExportPNG: boolean; displayPreferences: boolean; displayPrint: boolean; @@ -48,8 +48,8 @@ export class AppComponent implements OnInit, AfterContentInit, AfterViewInit, On case 'show-about': this.displayAbout = true; break; - case 'show-export-csv': - this.displayExportCSV = true; + case 'show-export-png': + this.displayExportPNG = true; break; case 'show-preferences': this.displayPreferences = true; diff --git a/src/app/component/menu/export-csv.component.html b/src/app/component/menu/export-csv.component.html deleted file mode 100644 index 1797c1d..0000000 --- a/src/app/component/menu/export-csv.component.html +++ /dev/null @@ -1,3 +0,0 @@ -
- Export CSV -
\ No newline at end of file diff --git a/src/app/component/menu/export-png.component.html b/src/app/component/menu/export-png.component.html new file mode 100644 index 0000000..0c82d6e --- /dev/null +++ b/src/app/component/menu/export-png.component.html @@ -0,0 +1,4 @@ +
+ + Export PNG +
\ No newline at end of file diff --git a/src/app/component/menu/export-csv.component.scss b/src/app/component/menu/export-png.component.scss similarity index 100% rename from src/app/component/menu/export-csv.component.scss rename to src/app/component/menu/export-png.component.scss diff --git a/src/app/component/menu/export-csv.component.ts b/src/app/component/menu/export-png.component.ts similarity index 70% rename from src/app/component/menu/export-csv.component.ts rename to src/app/component/menu/export-png.component.ts index 297dbd0..41f378c 100644 --- a/src/app/component/menu/export-csv.component.ts +++ b/src/app/component/menu/export-png.component.ts @@ -4,15 +4,17 @@ import { take } from 'rxjs/operators'; import * as AppStore from '../../store'; import { TargetDisplayType } from '../../core/type'; +import { Message } from 'primeng/primeng'; const { saveSvgAsPng, svgAsDataUri } = require('save-svg-as-png'); @Component({ - selector: 'app-menu-export-csv', - templateUrl: './export-csv.component.html', - styleUrls: ['./export-csv.component.scss'], + selector: 'app-menu-export-png', + templateUrl: './export-png.component.html', + styleUrls: ['./export-png.component.scss'], }) -export class ExportCSVComponent implements OnInit, AfterContentInit, OnDestroy { +export class ExportPNGComponent implements OnInit, AfterContentInit, OnDestroy { + msgs: Message[] = []; constructor( private store: Store, @@ -31,6 +33,7 @@ export class ExportCSVComponent implements OnInit, AfterContentInit, OnDestroy { } export() { + const __this = this; this.store.pipe( take(1), select((state) => { @@ -38,6 +41,12 @@ export class ExportCSVComponent implements OnInit, AfterContentInit, OnDestroy { const targetDisplayElementRef = AppStore.TargetSelector.TargetSelector.selectTargetDisplayElementRef(state); if (TargetDisplayType.MAP !== targetDisplayType) { + this.msgs = []; + this.msgs.push({ + severity: 'error', + summary: 'Invalid Display Type', + detail: 'Export PNG is only supported for Map Display type' + }); return; } diff --git a/src/app/component/menu/index.ts b/src/app/component/menu/index.ts index ff3c390..4360d54 100644 --- a/src/app/component/menu/index.ts +++ b/src/app/component/menu/index.ts @@ -1,11 +1,11 @@ import { AboutComponent } from './about.component'; -import { ExportCSVComponent } from './export-csv.component'; +import { ExportPNGComponent } from './export-png.component'; import { PreferencesComponent } from './preferences.component'; import { PrintComponent } from './print.component'; export const COMPONENTS = [ AboutComponent, - ExportCSVComponent, + ExportPNGComponent, PreferencesComponent, PrintComponent, ]; diff --git a/src/commons/type/menu-event.ts b/src/commons/type/menu-event.ts index 2826672..bc76ab9 100644 --- a/src/commons/type/menu-event.ts +++ b/src/commons/type/menu-event.ts @@ -2,6 +2,9 @@ export type MenuEvent = | 'save' | 'show-preferences' | 'show-about' + | 'show-export-png' + | 'show-export-jpg' + | 'show-export-svg' | 'show-export-csv' | 'show-print' | 'change-language-english' diff --git a/src/commons/type/menu-ids.ts b/src/commons/type/menu-ids.ts index d8905ab..c97b3b8 100644 --- a/src/commons/type/menu-ids.ts +++ b/src/commons/type/menu-ids.ts @@ -2,6 +2,9 @@ export type MenuIDs = | 'save' | 'preferences' | 'about' + | 'export-png' + | 'export-jpg' + | 'export-svg' | 'export-csv' | 'print' | 'language-english' diff --git a/src/electron/menu/build-default.ts b/src/electron/menu/build-default.ts index da9f8d3..44f0529 100644 --- a/src/electron/menu/build-default.ts +++ b/src/electron/menu/build-default.ts @@ -55,10 +55,28 @@ export function buildDefaultMenu( { label: __DARWIN__ ? 'Export as…' : 'Export as…', submenu: [ + { + label: __DARWIN__ ? 'PNG…' : 'PNG…', + id: 'export-png', + click: emit('show-export-png'), + }, + { + label: __DARWIN__ ? 'JPG…' : 'JPG…', + id: 'export-jpg', + click: emit('show-export-jpg'), + enabled: false, + }, + { + label: __DARWIN__ ? 'svg…' : 'svg…', + id: 'export-svg', + click: emit('show-export-svg'), + enabled: false, + }, { label: __DARWIN__ ? 'CSV…' : 'CSV…', id: 'export-csv', click: emit('show-export-csv'), + enabled: false, }, ], }, @@ -67,6 +85,7 @@ export function buildDefaultMenu( label: __DARWIN__ ? 'Print…' : 'Print…', id: 'print', click: emit('show-print'), + enabled: false, }, ], };