Mercurial > gemma
annotate client/src/store/application.js @ 1096:aa1f5daf6fc9
refac: centralized stores
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 30 Oct 2018 16:55:29 +0100 |
parents | client/src/application/stores/application.js@7ec2133c6404 |
children | 8d12056d602a |
rev | line source |
---|---|
1063
7ec2133c6404
client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents:
1055
diff
changeset
|
1 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1014
diff
changeset
|
2 * without warranty, see README.md and license for details. |
1063
7ec2133c6404
client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents:
1055
diff
changeset
|
3 * |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1014
diff
changeset
|
4 * SPDX-License-Identifier: AGPL-3.0-or-later |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1014
diff
changeset
|
5 * License-Filename: LICENSES/AGPL-3.0.txt |
1063
7ec2133c6404
client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents:
1055
diff
changeset
|
6 * |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1014
diff
changeset
|
7 * Copyright (C) 2018 by via donau |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1014
diff
changeset
|
8 * – Österreichische Wasserstraßen-Gesellschaft mbH |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1014
diff
changeset
|
9 * Software engineering by Intevation GmbH |
1063
7ec2133c6404
client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents:
1055
diff
changeset
|
10 * |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1014
diff
changeset
|
11 * Author(s): |
1063
7ec2133c6404
client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents:
1055
diff
changeset
|
12 * Thomas Junk <thomas.junk@intevation.de> |
7ec2133c6404
client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents:
1055
diff
changeset
|
13 * Markus Kottländer <markus.kottlaender@intevation.de> |
7ec2133c6404
client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents:
1055
diff
changeset
|
14 * Bernhard E. Reiter <bernhard.reiter@intevation.de> |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1014
diff
changeset
|
15 */ |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1014
diff
changeset
|
16 |
1096
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
1063
diff
changeset
|
17 import { version } from "../../package.json"; |
1014
77202406b1a7
reverted demo build target, include revision number based on version tag
Markus Kottlaender <markus@intevation.de>
parents:
810
diff
changeset
|
18 |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
19 const defaultCollapseState = true; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
20 |
647
620a65f11b33
fix: splitscreenoption has to be reset for logout
Thomas Junk <thomas.junk@intevation.de>
parents:
622
diff
changeset
|
21 const initializeSplitScreen = () => { |
620a65f11b33
fix: splitscreenoption has to be reset for logout
Thomas Junk <thomas.junk@intevation.de>
parents:
622
diff
changeset
|
22 return { |
620a65f11b33
fix: splitscreenoption has to be reset for logout
Thomas Junk <thomas.junk@intevation.de>
parents:
622
diff
changeset
|
23 active: false, |
620a65f11b33
fix: splitscreenoption has to be reset for logout
Thomas Junk <thomas.junk@intevation.de>
parents:
622
diff
changeset
|
24 mode: "v" |
620a65f11b33
fix: splitscreenoption has to be reset for logout
Thomas Junk <thomas.junk@intevation.de>
parents:
622
diff
changeset
|
25 }; |
620a65f11b33
fix: splitscreenoption has to be reset for logout
Thomas Junk <thomas.junk@intevation.de>
parents:
622
diff
changeset
|
26 }; |
620a65f11b33
fix: splitscreenoption has to be reset for logout
Thomas Junk <thomas.junk@intevation.de>
parents:
622
diff
changeset
|
27 |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
28 const Application = { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
29 namespaced: true, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
30 state: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
31 appTitle: process.env.VUE_APP_TITLE, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
32 secondaryLogo: process.env.VUE_APP_SECONDARY_LOGO_URL, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
33 sidebar: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
34 iscollapsed: defaultCollapseState |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
35 }, |
1055
1ff8c072df18
WIP: Bottleneck list/table
Markus Kottlaender <markus@intevation.de>
parents:
1019
diff
changeset
|
36 bottlenecksCollapsed: true, |
647
620a65f11b33
fix: splitscreenoption has to be reset for logout
Thomas Junk <thomas.junk@intevation.de>
parents:
622
diff
changeset
|
37 splitsceen: initializeSplitScreen(), |
622
47f11401d999
feat: Usermenu is now collapsible
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
38 usermenu: { |
47f11401d999
feat: Usermenu is now collapsible
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
39 iscollapsed: defaultCollapseState |
47f11401d999
feat: Usermenu is now collapsible
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
40 }, |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
647
diff
changeset
|
41 countries: ["AT", "SK", "HU", "HR", "RS", "BiH", "BG", "RO", "UA"], |
1063
7ec2133c6404
client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents:
1055
diff
changeset
|
42 // there are three states of drawMode: null, "LineString", "Polygon" |
1014
77202406b1a7
reverted demo build target, include revision number based on version tag
Markus Kottlaender <markus@intevation.de>
parents:
810
diff
changeset
|
43 drawMode: null, |
77202406b1a7
reverted demo build target, include revision number based on version tag
Markus Kottlaender <markus@intevation.de>
parents:
810
diff
changeset
|
44 version |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
45 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
46 getters: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
47 countries: state => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
48 return state.countries; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
49 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
50 sidebarCollapsed: state => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
51 return state.sidebar.iscollapsed; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
52 }, |
622
47f11401d999
feat: Usermenu is now collapsible
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
53 isUsermenuCollapsed: state => { |
47f11401d999
feat: Usermenu is now collapsible
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
54 return state.usermenu.iscollapsed; |
47f11401d999
feat: Usermenu is now collapsible
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
55 }, |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
56 appTitle: state => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
57 return state.appTitle; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
58 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
59 secondaryLogo: state => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
60 return state.secondaryLogo; |
593
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
61 }, |
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
62 isSplitscreen: state => { |
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
63 return state.splitsceen.active; |
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
64 }, |
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
65 splitMode: state => { |
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
66 return state.splitsceen.mode; |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
647
diff
changeset
|
67 }, |
1014
77202406b1a7
reverted demo build target, include revision number based on version tag
Markus Kottlaender <markus@intevation.de>
parents:
810
diff
changeset
|
68 versionStr: state => { |
77202406b1a7
reverted demo build target, include revision number based on version tag
Markus Kottlaender <markus@intevation.de>
parents:
810
diff
changeset
|
69 // version number from package.json |
77202406b1a7
reverted demo build target, include revision number based on version tag
Markus Kottlaender <markus@intevation.de>
parents:
810
diff
changeset
|
70 let versionStr = "v" + state.version; |
77202406b1a7
reverted demo build target, include revision number based on version tag
Markus Kottlaender <markus@intevation.de>
parents:
810
diff
changeset
|
71 |
77202406b1a7
reverted demo build target, include revision number based on version tag
Markus Kottlaender <markus@intevation.de>
parents:
810
diff
changeset
|
72 // hg revision |
77202406b1a7
reverted demo build target, include revision number based on version tag
Markus Kottlaender <markus@intevation.de>
parents:
810
diff
changeset
|
73 if ( |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1014
diff
changeset
|
74 process.env.VUE_APP_HGREV && |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1014
diff
changeset
|
75 (state.version.includes("dev") || |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1014
diff
changeset
|
76 state.version.includes("beta") || |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1014
diff
changeset
|
77 state.version.includes("alpha")) |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1014
diff
changeset
|
78 ) |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1014
diff
changeset
|
79 versionStr += " " + process.env.VUE_APP_HGREV; |
1014
77202406b1a7
reverted demo build target, include revision number based on version tag
Markus Kottlaender <markus@intevation.de>
parents:
810
diff
changeset
|
80 |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
1014
diff
changeset
|
81 return versionStr; |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
82 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
83 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
84 mutations: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
85 toggleSidebar: state => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
86 state.sidebar.iscollapsed = !state.sidebar.iscollapsed; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
87 }, |
1055
1ff8c072df18
WIP: Bottleneck list/table
Markus Kottlaender <markus@intevation.de>
parents:
1019
diff
changeset
|
88 toggleBottlenecks: state => { |
1ff8c072df18
WIP: Bottleneck list/table
Markus Kottlaender <markus@intevation.de>
parents:
1019
diff
changeset
|
89 state.bottlenecksCollapsed = !state.bottlenecksCollapsed; |
1ff8c072df18
WIP: Bottleneck list/table
Markus Kottlaender <markus@intevation.de>
parents:
1019
diff
changeset
|
90 }, |
622
47f11401d999
feat: Usermenu is now collapsible
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
91 toggleUserMenu: state => { |
47f11401d999
feat: Usermenu is now collapsible
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
92 state.usermenu.iscollapsed = !state.usermenu.iscollapsed; |
47f11401d999
feat: Usermenu is now collapsible
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
93 }, |
593
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
94 toggleSplitScreen: state => { |
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
95 state.splitsceen.active = !state.splitsceen.active; |
c4a4dc612191
feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
96 }, |
810 | 97 openSplitScreen: state => { |
98 state.splitsceen.active = true; | |
99 }, | |
100 closeSplitScreen: state => { | |
101 state.splitsceen.active = false; | |
102 }, | |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
103 resetSidebar: state => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
104 state.sidebar.iscollapsed = defaultCollapseState; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
105 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
106 collapseSidebar: state => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
107 state.sidebar.iscollapsed = true; |
622
47f11401d999
feat: Usermenu is now collapsible
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
108 }, |
47f11401d999
feat: Usermenu is now collapsible
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
109 resetUserMenu: state => { |
47f11401d999
feat: Usermenu is now collapsible
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
110 state.usermenu.iscollapsed = defaultCollapseState; |
47f11401d999
feat: Usermenu is now collapsible
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
111 }, |
47f11401d999
feat: Usermenu is now collapsible
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
112 collapseUserMenu: state => { |
47f11401d999
feat: Usermenu is now collapsible
Thomas Junk <thomas.junk@intevation.de>
parents:
593
diff
changeset
|
113 state.usermenu.iscollapsed = true; |
647
620a65f11b33
fix: splitscreenoption has to be reset for logout
Thomas Junk <thomas.junk@intevation.de>
parents:
622
diff
changeset
|
114 }, |
620a65f11b33
fix: splitscreenoption has to be reset for logout
Thomas Junk <thomas.junk@intevation.de>
parents:
622
diff
changeset
|
115 resetSplitScreen: state => { |
620a65f11b33
fix: splitscreenoption has to be reset for logout
Thomas Junk <thomas.junk@intevation.de>
parents:
622
diff
changeset
|
116 state.splitsceen = initializeSplitScreen(); |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
647
diff
changeset
|
117 }, |
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
647
diff
changeset
|
118 toggleDrawModeLine: state => { |
1063
7ec2133c6404
client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents:
1055
diff
changeset
|
119 if (state.drawMode) { |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
647
diff
changeset
|
120 state.drawMode = null; |
1063
7ec2133c6404
client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents:
1055
diff
changeset
|
121 } else { |
7ec2133c6404
client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents:
1055
diff
changeset
|
122 state.drawMode = "LineString"; |
649
83081ba6c9c1
feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
647
diff
changeset
|
123 } |
1063
7ec2133c6404
client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents:
1055
diff
changeset
|
124 }, |
7ec2133c6404
client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents:
1055
diff
changeset
|
125 activateDrawModePolygon: state => { |
7ec2133c6404
client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents:
1055
diff
changeset
|
126 state.drawMode = "Polygon"; |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
127 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
128 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
129 actions: {} |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
130 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
131 |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
132 export default Application; |