annotate client/src/store/imports.js @ 1578:ca9bd1ce26e5

Fix backend Dockerfile ca-certificates is needed to fetch go dependencies via https.
author Tom Gottfried <tom@intevation.de>
date Thu, 13 Dec 2018 14:57:39 +0100
parents 2365acde39dc
children bbbc27a7ec99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1362
ca33ad696594 remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1311
diff changeset
1 /* This is Free Software under GNU Affero General Public License v >= 3.0
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
2 * without warranty, see README.md and license for details.
1173
3035ddd3d1a8 feat: importqueue
Thomas Junk <thomas.junk@intevation.de>
parents: 1142
diff changeset
3 *
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
4 * SPDX-License-Identifier: AGPL-3.0-or-later
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
5 * License-Filename: LICENSES/AGPL-3.0.txt
1173
3035ddd3d1a8 feat: importqueue
Thomas Junk <thomas.junk@intevation.de>
parents: 1142
diff changeset
6 *
3035ddd3d1a8 feat: importqueue
Thomas Junk <thomas.junk@intevation.de>
parents: 1142
diff changeset
7 * Copyright (C) 2018 by via donau
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
8 * – Österreichische Wasserstraßen-Gesellschaft mbH
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
9 * Software engineering by Intevation GmbH
1173
3035ddd3d1a8 feat: importqueue
Thomas Junk <thomas.junk@intevation.de>
parents: 1142
diff changeset
10 *
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
11 * Author(s):
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
12 * Thomas Junk <thomas.junk@intevation.de>
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
13 */
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
14
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents: 1173
diff changeset
15 import { HTTP } from "../lib/http";
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
16
1311
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
17 /* eslint-disable no-unused-vars */
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
18 /* eslint-disable no-unreachable */
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
19 const STATES = {
1468
5e1218b5a123 proof of concept
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
20 NEEDSAPPROVAL: "pending",
5e1218b5a123 proof of concept
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
21 APPROVED: "accepted",
1475
2365acde39dc Staging area: Dealing with backend response.
Thomas Junk <thomas.junk@intevation.de>
parents: 1470
diff changeset
22 REJECTED: "declined"
1311
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
23 };
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
24
1429
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
25 const SCHEDULES = {
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
26 DAILY: "daily",
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
27 MONTHLY: "monthly"
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
28 };
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
29
1296
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
30 // initial state
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
31 const init = () => {
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
32 return {
1310
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
33 imports: [],
1429
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
34 staging: [],
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
35 schedules: [],
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
36 importScheduleDetail: null,
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
37 importScheduleDetailVisible: false
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
38 };
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
39 };
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
40
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
41 const newImportScheduleDetail = () => {
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
42 return {
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
43 import: "",
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
44 type: "",
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
45 author: "",
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
46 schedule: "",
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
47 emailNotification: null
1296
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
48 };
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
49 };
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
50
1344
eda98694e678 staging: retrieve real data instead of displaying demodata
Thomas Junk <thomas.junk@intevation.de>
parents: 1311
diff changeset
51 const imports = {
1296
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
52 init,
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
53 namespaced: true,
1296
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
54 state: init(),
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
55 mutations: {
1429
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
56 clearImportScheduleDetail: state => {
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
57 state.importScheduleDetail = newImportScheduleDetail();
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
58 },
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
59 deleteSchedule: (state, index) => {
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
60 state.schedules.splice(index, 1);
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
61 },
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
62 setImportScheduleDetailInvisible: state => {
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
63 state.importScheduleDetailVisible = false;
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
64 },
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
65 setImportScheduleDetailVisible: state => {
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
66 state.importScheduleDetailVisible = true;
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
67 },
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
68 setSchedules: (state, schedules) => {
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
69 state.schedules = schedules;
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
70 },
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
71 setImports: (state, imports) => {
1173
3035ddd3d1a8 feat: importqueue
Thomas Junk <thomas.junk@intevation.de>
parents: 1142
diff changeset
72 state.imports = imports;
1310
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
73 },
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
74 setStaging: (state, staging) => {
1350
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1344
diff changeset
75 const enriched = staging.map(x => {
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1344
diff changeset
76 return { ...x, status: STATES.NEEDSAPPROVAL };
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1344
diff changeset
77 });
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1344
diff changeset
78 state.staging = enriched;
1311
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
79 },
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
80
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
81 toggleApproval: (state, change) => {
1344
eda98694e678 staging: retrieve real data instead of displaying demodata
Thomas Junk <thomas.junk@intevation.de>
parents: 1311
diff changeset
82 const { id, newStatus } = change;
1350
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1344
diff changeset
83 const stagedResult = state.staging.find(e => {
1311
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
84 return e.id === id;
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
85 });
1344
eda98694e678 staging: retrieve real data instead of displaying demodata
Thomas Junk <thomas.junk@intevation.de>
parents: 1311
diff changeset
86 if (stagedResult.status === newStatus) {
eda98694e678 staging: retrieve real data instead of displaying demodata
Thomas Junk <thomas.junk@intevation.de>
parents: 1311
diff changeset
87 stagedResult.status = STATES.NEEDSAPPROVAL;
1311
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
88 } else {
1344
eda98694e678 staging: retrieve real data instead of displaying demodata
Thomas Junk <thomas.junk@intevation.de>
parents: 1311
diff changeset
89 stagedResult.status = newStatus;
1311
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
90 }
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
91 }
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
92 },
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
93 actions: {
1429
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
94 getSchedules({ commit }) {
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
95 throw new Error("Not Implemented!");
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
96 return new Promise((resolve, reject) => {
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
97 HTTP.get("/imports", {
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
98 headers: { "X-Gemma-Auth": localStorage.getItem("token") }
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
99 })
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
100 .then(response => {
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
101 commit("setImports", response.data.imports);
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
102 resolve(response);
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
103 })
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
104 .catch(error => {
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
105 reject(error);
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
106 });
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
107 });
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
108 },
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
109 getImports({ commit }) {
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
110 return new Promise((resolve, reject) => {
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
111 HTTP.get("/imports", {
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
112 headers: { "X-Gemma-Auth": localStorage.getItem("token") }
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
113 })
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
114 .then(response => {
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
115 commit("setImports", response.data.imports);
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
116 resolve(response);
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
117 })
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
118 .catch(error => {
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
119 reject(error);
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
120 });
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
121 });
1310
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
122 },
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
123 getStaging({ commit }) {
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
124 return new Promise((resolve, reject) => {
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
125 HTTP.get("/imports?states=pending", {
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
126 headers: { "X-Gemma-Auth": localStorage.getItem("token") }
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
127 })
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
128 .then(response => {
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
129 commit("setStaging", response.data.imports);
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
130 resolve(response);
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
131 })
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
132 .catch(error => {
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
133 reject(error);
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
134 });
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
135 });
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
136 }
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
137 }
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
138 };
1344
eda98694e678 staging: retrieve real data instead of displaying demodata
Thomas Junk <thomas.junk@intevation.de>
parents: 1311
diff changeset
139
1429
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
140 export { imports, STATES, SCHEDULES };