@abi-software/flatmapvuer 0.5.9-beta.0 → 0.5.9-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/flatmapvuer",
3
- "version": "0.5.9-beta.0",
3
+ "version": "0.5.9-beta.2",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/flatmapvuer.common.js",
6
6
  "files": [
@@ -27,7 +27,8 @@
27
27
  "version": "npm run build-bundle;npm run changelog; git add CHANGELOG.md"
28
28
  },
29
29
  "dependencies": {
30
- "@abi-software/flatmap-viewer": "^2.4.2-b.3",
30
+ "@abi-software/flatmap-viewer": "^2.4.2-b.4",
31
+ "@abi-software/sparc-annotation": "0.0.5",
31
32
  "@abi-software/svg-sprite": "^0.3.0",
32
33
  "core-js": "^3.3.2",
33
34
  "css-element-queries": "^1.2.2",
package/src/App.vue CHANGED
@@ -119,6 +119,7 @@ export default {
119
119
  "Human Female":{taxo: "NCBITaxon:9606", biologicalSex: "PATO:0000383", iconClass:"mapicon-icon_human", displayWarning:true},
120
120
  "Human Male":{taxo: "NCBITaxon:9606", biologicalSex: "PATO:0000384", iconClass:"mapicon-icon_human", displayWarning:true},
121
121
  "Rat":{taxo: "NCBITaxon:10114", iconClass:"mapicon-icon_rat", displayWarning:true, displayLatestChanges:true},
122
+ "Rat (NPO)":{taxo: "NCBITaxon:10116", iconClass:"mapicon-icon_rat", displayWarning:true, displayLatestChanges:true},
122
123
  "Mouse":{taxo: "NCBITaxon:10090", iconClass:"mapicon-icon_mouse", displayWarning:true},
123
124
  "Kember":{taxo: "ABI:1000001", displayWarning:true},
124
125
  "Pig":{taxo: "NCBITaxon:9823", iconClass:"mapicon-icon_pig", displayWarning:true},
@@ -133,7 +134,7 @@ export default {
133
134
  position: "absolute"
134
135
  },
135
136
  displayCloseButton: false,
136
- initial: "Rat",
137
+ initial: "Rat (NPO)",
137
138
  helpMode: false,
138
139
  mapSettings: [],
139
140
  //flatmapAPI: "https://mapcore-demo.org/current/flatmap/v2/"
@@ -19,7 +19,7 @@
19
19
  <i class="el-icon-arrow-up"></i>
20
20
  </div>
21
21
  <div v-show="!showSubmissions" class="hide" @click="showSubmissions = true">
22
- Show previous submissions
22
+ Show previous {{ prevSubs.length }} submission(s)
23
23
  <i class="el-icon-arrow-down"></i>
24
24
  </div>
25
25
  <template v-if="showSubmissions">
@@ -29,10 +29,13 @@
29
29
  </el-row>
30
30
  <div class="entry" v-for="(sub, index) in prevSubs" :key="index">
31
31
  <el-row class="dialog-text">
32
- <strong>{{ sub.timestamp }}</strong> Anonoymous
32
+ <strong>{{ formatTime(sub.created) }}</strong> {{ sub.creator.name }}
33
33
  </el-row>
34
34
  <el-row class="dialog-text">
35
- <strong>Evidence: </strong> {{ sub.evidence.join(', ') }}
35
+ <strong>Evidence: </strong>
36
+ <el-row v-for="(evidence) in sub.evidence" :key="evidence" class="dialog-text">
37
+ <a :href="evidence" target="_blank"> {{ evidence }}</a>
38
+ </el-row>
36
39
  </el-row>
37
40
  <el-row class="dialog-text">
38
41
  <strong>Comment: </strong> {{ sub.comment }}
@@ -40,76 +43,83 @@
40
43
  </div>
41
44
  </template>
42
45
  </template>
43
- <el-row class="dialog-spacer"></el-row>
44
- <el-row v-if="!editing">
45
- <i
46
- class="el-icon-edit standard-icon"
47
- @click="editing = true"
48
- />
49
- </el-row>
50
- <template v-else>
51
- <el-row class="dialog-text">
52
- <strong class="sub-title">Suggest changes:</strong>
53
- </el-row>
54
- <el-row class="dialog-text">
55
- <strong>Evidvence:</strong>
56
- </el-row>
57
- <el-row v-for="(value, index) in evidence" :key="value">
58
- <el-col :span="20">
59
- {{ evidence[index] }}
60
- </el-col>
61
- <el-col :span="4">
46
+ <template v-if="authenticated">
47
+ <template v-if="isEditable">
48
+ <el-row class="dialog-spacer"></el-row>
49
+ <el-row v-if="!editing">
62
50
  <i
63
- class="el-icon-close standard-icon"
64
- @click="removeEvidence(index)"
51
+ class="el-icon-edit standard-icon"
52
+ @click="editing = true"
65
53
  />
66
- </el-col>
67
- </el-row>
68
- <el-row>
69
- <el-input
70
- size="mini"
71
- placeholder="Enter"
72
- v-model="newEvidence"
73
- @change="evidenceEntered($event)"
74
- >
75
- <el-select
76
- :popper-append-to-body="false"
77
- v-model="evidencePrefix"
78
- placeholder="Select"
79
- class="select-box"
80
- popper-class="flatmap_dropdown"
81
- slot="prepend"
82
- >
83
- <el-option v-for="item in evidencePrefixes" :key="item" :label="item" :value="item">
84
- <el-row>
85
- <el-col :span="12">{{ item }}</el-col>
86
- </el-row>
87
- </el-option>
88
- </el-select>
89
- </el-input>
90
- </el-row>
91
- <el-row>
92
- <strong>Comment:</strong>
93
- </el-row>
94
- <el-row class="dialog-text">
95
-
96
- <el-input
97
- type="textarea"
98
- :autosize="{ minRows: 2, maxRows: 4}"
99
- placeholder="Enter"
100
- v-model="comment"
101
- />
102
- </el-row>
103
- <el-row class="dialog-text">
104
- <el-button
105
- class="button"
106
- type="primary"
107
- plain
108
- @click="submit"
109
- >
110
- Submit
111
- </el-button>
112
- </el-row>
54
+ </el-row>
55
+ <template v-else>
56
+ <el-row class="dialog-text">
57
+ <strong class="sub-title">Suggest changes:</strong>
58
+ </el-row>
59
+ <el-row class="dialog-text">
60
+ <strong>Evidvence:</strong>
61
+ </el-row>
62
+ <el-row v-for="(value, index) in evidence" :key="value">
63
+ <el-col :span="20">
64
+ {{ evidence[index] }}
65
+ </el-col>
66
+ <el-col :span="4">
67
+ <i
68
+ class="el-icon-close standard-icon"
69
+ @click="removeEvidence(index)"
70
+ />
71
+ </el-col>
72
+ </el-row>
73
+ <el-row>
74
+ <el-input
75
+ size="mini"
76
+ placeholder="Enter"
77
+ v-model="newEvidence"
78
+ @change="evidenceEntered($event)"
79
+ >
80
+ <el-select
81
+ :popper-append-to-body="false"
82
+ v-model="evidencePrefix"
83
+ placeholder="Select"
84
+ class="select-box"
85
+ popper-class="flatmap_dropdown"
86
+ slot="prepend"
87
+ >
88
+ <el-option v-for="item in evidencePrefixes" :key="item" :label="item" :value="item">
89
+ <el-row>
90
+ <el-col :span="12">{{ item }}</el-col>
91
+ </el-row>
92
+ </el-option>
93
+ </el-select>
94
+ </el-input>
95
+ </el-row>
96
+ <el-row>
97
+ <strong>Comment:</strong>
98
+ </el-row>
99
+ <el-row class="dialog-text">
100
+ <el-input
101
+ type="textarea"
102
+ :autosize="{ minRows: 2, maxRows: 4}"
103
+ placeholder="Enter"
104
+ v-model="comment"
105
+ />
106
+ </el-row>
107
+ <el-row class="dialog-text">
108
+ <el-button
109
+ class="button"
110
+ type="primary"
111
+ plain
112
+ @click="submit"
113
+ >
114
+ Submit
115
+ </el-button>
116
+ </el-row>
117
+ </template>
118
+ <el-row class="dialog-text" v-if="errorMessage">
119
+ <strong class="sub-title"> {{ errorMessage }}
120
+ </strong>
121
+ </el-row>
122
+ </template>
113
123
  </template>
114
124
  </template>
115
125
  </div>
@@ -121,9 +131,11 @@
121
131
  /* eslint-disable no-alert, no-console */
122
132
  /* eslint-disable no-alert, no-console */
123
133
  import Vue from "vue";
134
+ import { AnnotationService } from "@abi-software/sparc-annotation";
124
135
  import { Button, Col, Input, Main, Row, Select } from "element-ui";
125
136
  import lang from "element-ui/lib/locale/lang/en";
126
137
  import locale from "element-ui/lib/locale";
138
+
127
139
  locale.use(lang);
128
140
  Vue.use(Button);
129
141
  Vue.use(Col);
@@ -139,14 +151,15 @@ export default {
139
151
  type: Object,
140
152
  },
141
153
  },
154
+ inject: ['flatmapAPI'],
142
155
  data: function() {
143
156
  return {
144
157
  displayPair: {
145
- "Feature": "id",
158
+ "Feature ID": "featureId",
146
159
  "Tooltip": "label",
147
160
  "Models": "models",
148
161
  "Name": "name",
149
- "Map layer": "layer",
162
+ "Resource": "resourceId"
150
163
  },
151
164
  editing: false,
152
165
  evidencePrefixes: [
@@ -155,24 +168,18 @@ export default {
155
168
  ],
156
169
  evidencePrefix: "DOI:",
157
170
  evidence: [ ],
171
+ authenticated: false,
158
172
  newEvidence: '',
159
173
  comment: '',
160
- submissions: [ ],
161
- showSubmissions: true
174
+ prevSubs: [ ],
175
+ showSubmissions: true,
176
+ errorMessage: "",
162
177
  }
163
178
  },
164
179
  computed: {
165
- prevSubs: function() {
166
- return this.submissions.filter(sub => {
167
- if (this.annotationEntry) {
168
- if (sub.id === this.annotationEntry.id &&
169
- sub.layer === this.annotationEntry.layer) {
170
- return true;
171
- }
172
- }
173
- return false;
174
- });
175
- }
180
+ isEditable: function() {
181
+ return this.annotationEntry['resourceId'] && this.annotationEntry['featureId'];
182
+ },
176
183
  },
177
184
  methods: {
178
185
  evidenceEntered: function(value) {
@@ -181,17 +188,54 @@ export default {
181
188
  this.newEvidence = "";
182
189
  }
183
190
  },
191
+ formatTime: function(dateString) {
192
+ const options = { year: "numeric", month: "long", day: "numeric",
193
+ hour: "numeric", minute: "numeric", second: "numeric" };
194
+ return new Date(dateString).toLocaleDateString(undefined, options);
195
+ },
196
+ updatePrevSubmissions: function() {
197
+ if (this.$annotator && this.authenticated) {
198
+ if (this.annotationEntry['resourceId'] &&
199
+ this.annotationEntry['featureId']) {
200
+ this.$annotator.itemAnnotations(this.annotationEntry['resourceId'],
201
+ this.annotationEntry['featureId']).then((value) => {
202
+ this.prevSubs = value;
203
+ })
204
+ .catch((reason) => {
205
+ console.log(reason); // Error!
206
+ });
207
+ }
208
+ }
209
+ },
184
210
  submit: function() {
185
- const now = new Date();
186
211
  if ((this.evidence.length > 0) || this.comment) {
187
- this.submissions.push( {
188
- id: this.annotationEntry['id'],
189
- layer: this.annotationEntry['layer'],
190
- evidence: this.evidence,
191
- comment: this.comment,
192
- timestamp: now.toLocaleString(),
193
- });
194
- this.resetSubmission();
212
+ if (this.annotationEntry['resourceId'] &&
213
+ this.annotationEntry['featureId']) {
214
+ const evidenceURLs = [];
215
+ this.evidence.forEach((evidence) => {
216
+ if (evidence.includes("DOI:")) {
217
+ const link = evidence.replace("DOI:", "https://doi.org/");
218
+ evidenceURLs.push(new URL(link));
219
+ } else if (evidence.includes("PMID:")) {
220
+ const link = evidence.replace("PMID:", "https://pubmed.ncbi.nlm.nih.gov/");
221
+ evidenceURLs.push(new URL(link));
222
+ }
223
+ });
224
+ const userAnnotation = {
225
+ resource: this.annotationEntry['resourceId'],
226
+ item: this.annotationEntry['featureId'],
227
+ evidence: evidenceURLs,
228
+ comment: this.comment,
229
+ }
230
+ this.$annotator.addAnnotation(userAnnotation).then(() => {
231
+ this.errorMessage = "";
232
+ this.resetSubmission();
233
+ this.updatePrevSubmissions();
234
+ })
235
+ .catch(() => {
236
+ this.errorMessage = "There is a problem with the submission, please try again later";
237
+ });
238
+ }
195
239
  }
196
240
  },
197
241
  removeEvidence: function(index) {
@@ -208,10 +252,25 @@ export default {
208
252
  annotationEntry: {
209
253
  handler: function() {
210
254
  this.resetSubmission();
255
+ this.updatePrevSubmissions();
211
256
  },
212
257
  immediate: false,
213
258
  deep: false,
214
259
  }
260
+ },
261
+ mounted: function() {
262
+ if (!this.$annotator) {
263
+ Vue.prototype.$annotator = new AnnotationService(
264
+ `${this.flatmapAPI}annotator`);
265
+ }
266
+ this.$annotator.authenticate().then((userData) => {
267
+ if (userData.name && userData.email) {
268
+ this.authenticated = true;
269
+ this.updatePrevSubmissions();
270
+ } else {
271
+ this.errorMessage = "";
272
+ }
273
+ })
215
274
  }
216
275
  };
217
276
  </script>