Skip to content

Commit

Permalink
Update texts and styles and add scan object for engineers (#6)
Browse files Browse the repository at this point in the history
* chore: add an extra informative text

* chore: update medical texts and styles

* chore: update science texts and styles

* feat: add scan object for engineers, remove extra butra buttons

* chore: remove console.logs
  • Loading branch information
5annaha authored Apr 24, 2024
1 parent 781bfb4 commit 7754a96
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 32 deletions.
17 changes: 4 additions & 13 deletions src/components/Carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import MedicalSample from './MedicalSample.vue'
import MedicalScanner from './MedicalScanner.vue'
import ScienceArtifactDetails from './ScienceArtifactDetails.vue'
import ScienceInspectObject from './ScienceInspectObject.vue'
import EngineeringScanObject from './EngineeringScanObject.vue'
import Locator from './Locator.vue'
import ShipDatabase from './ShipDatabase.vue'
import SampleList from './SampleList.vue';
Expand Down Expand Up @@ -64,11 +65,6 @@ const PAGES = [
title: 'Operate scanners',
page: MedicalScanner,
},
{
icon: 'book',
title: 'View samples',
page: SampleList,
},
],
},
{
Expand All @@ -83,9 +79,9 @@ const PAGES = [
page: GameScanner,
},
{
icon: 'info-circle',
title: 'Ship knowledge database',
page: ShipDatabase,
icon: 'futbol',
title: 'Scan object',
page: EngineeringScanObject,
},
],
},
Expand Down Expand Up @@ -115,11 +111,6 @@ const PAGES = [
title: 'Operate scanners',
page: MedicalScanner,
},
{
icon: 'book',
title: 'View samples',
page: SampleList,
},
],
},
{
Expand Down
152 changes: 152 additions & 0 deletions src/components/EngineeringScanObject.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<!-- Engineering version of MedicalDiagnosis.vue -->
<template>
<v-ons-page @show="show" @hide="hide">
<toolbar-top />
<div style="text-align: center; margin-top: 50px;">
<h1>{{ this.title }}</h1>
<v-ons-search-input placeholder="Search" v-model="query" v-if="hasInput" @keyup="e => debouncedGetRecords(e.target.value)"></v-ons-search-input>
<div class="resultTextBox" v-if="state === 'results'">
<pre class="pre">{{ resultText }}</pre>
</div>
<div v-else-if="state === 'processing'" class="processing">
<h2>Processing...</h2>
<v-ons-progress-bar :value="dataProgress" secondary-value="100"></v-ons-progress-bar>
<br>
<v-ons-progress-bar :value="dataProgress1" secondary-value="100"></v-ons-progress-bar>
<br>
<v-ons-progress-bar :value="dataProgress2" secondary-value="100"></v-ons-progress-bar>
</div>
<div v-else>
Unknown state
</div>
</div>
</v-ons-page>
</template>
<script>

import { getBlob, patchBlob } from '../blob'
import { startWatch, cancelWatch, hasNfc } from '../nfc'
import { debounce, get } from 'lodash-es';
import axios from 'axios';

export default {
data() {
return {
res: null,
record: {},
id: 0,
query: '',
results: [ ],
resultText: '',
diagnosis: null,
title: '',
tagRegexp: '',
invalidTagTypeMessage: '',
tagNotFoundMessage: '',
hasInput: !hasNfc(),
scanProgress: 0,
dataProgress: 0,
dataProgress1: 0,
dataProgress2: 0,
intervalID: 0,
intervalID1: 0,
intervalID2: 0,
state: 'results',
}
},
methods: {
async getRecords(message) {
if (message.match(this.tagRegexp)) {
const res = await axios.get(`/tag/${message}`).catch(() => {
this.resultText = this.tagNotFoundMessage;
});
if (res) {
this.res = res;
this.analyze();
}
} else {
this.resultText = this.invalidTagTypeMessage;
}
},
showRecord() {
this.resultText = get(this.res, 'data.description', this.tagNotFoundMessage) + '\n\n\nReady to scan another object';
this.state = 'results';
},
async show() {
await startWatch(this.getRecords);
},
hide() {
cancelWatch()
},
analyze() {
this.state = 'processing';
this.dataProgress = 0;
this.dataProgress1 = 0;
this.dataProgress2 = 0;
const skillFactor = this.$store.state.user.skillFactor;
const analyseBaseTime = this.$store.state.user.analyseBaseTime;
this.intervalID = setInterval(() => {
if (this.dataProgress === 100) {
clearInterval(this.intervalID)
return
}
this.dataProgress++
}, 1 * analyseBaseTime * skillFactor)
this.intervalID1 = setInterval(() => {
if (this.dataProgress1 === 100) {
clearInterval(this.intervalID1)
return
}
this.dataProgress1++
}, 2 * analyseBaseTime * skillFactor)
this.intervalID2 = setInterval(() => {
if (this.dataProgress2 === 100) {
clearInterval(this.intervalID2)
this.showRecord()
return
}
this.dataProgress2++
}, 3 * analyseBaseTime * skillFactor)
},
},
created() {
this.title = 'SCAN OBJECT';
this.resultText = 'Ready to scan an object';
this.tagRegexp = /^engi:..*/;
this.tagNotFoundMessage = 'This object is unknown';
this.invalidTagTypeMessage = 'This is not recognized as an object\n\nReady to scan an object';
this.debouncedGetRecords = debounce(this.getRecords, 700);
},
}
</script>
<style scoped>
.result {
text-align: center;
display: inline-block;
width: 80px;
height: 80px;
}
.pre {
color: #fff;
font-family: monospace;
hyphens: auto;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
padding: 0;
margin: 0;
}
.resultTextBox {
background-color: rgba( 0, 0, 0, 0.4);
border: 1px solid #333;
margin: 20px;
padding: 10px;
text-align: left;
}
ons-list.autocomplete {
position: absolute;
width: 100%;
}
</style>
6 changes: 6 additions & 0 deletions src/components/GameScanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<!-- For wtf reason v-if causes a crash when changing state -->
<div v-show="state == 'scanning'" style="text-align: center; margin-top: 50px;">
<h2 @click="countDebug">Scanning...</h2>
<p class="italic">[Scan an engineering task NFC tag]</p>
<div v-if="debug">
<p>Tag contents:</p>
<v-ons-input placeholder="Tag contents" float v-model="tag"></v-ons-input>
Expand Down Expand Up @@ -233,3 +234,8 @@ export default {
},
}
</script>
<style lang="scss" scoped>
p.italic {
font-style: italic;
}
</style>
4 changes: 2 additions & 2 deletions src/components/MedicalDiagnosis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default {
}
},
showRecord() {
this.resultText = get(this.res, 'data.description', this.tagNotFoundMessage) + '\n\nReady to scan another injury';
this.resultText = get(this.res, 'data.description', this.tagNotFoundMessage) + '\n\n\nReady to scan another injury';
this.state = 'results';
},
async show() {
Expand Down Expand Up @@ -110,7 +110,7 @@ export default {
},
},
created() {
this.title = 'DIAGNOSE AN INJURY';
this.title = 'DIAGNOSE INJURY';
this.resultText = 'Scan an injury';
this.tagRegexp = /^medic:..*/;
this.tagNotFoundMessage = 'This injury is unknown';
Expand Down
29 changes: 18 additions & 11 deletions src/components/MedicalRecords.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default {
id: 0,
query: '',
results: [ ],
resultText: 'Scan a patient ID card',
resultText: 'Scan patient bio ID',
hasInput: !hasNfc(),
scanProgress: 0,
dataProgress: 0,
Expand All @@ -53,40 +53,47 @@ export default {
const person = this.record;
if (!person) return this.resultText = `Unknown person.

Ready to scan another patient ID card`;
Ready to scan another patient bio ID`;
this.query = ''
this.resultText = `Medical details:
this.resultText = `MEDICAL DETAILS:

Name: ${ person.full_name }
Age: ${ 542 - person.birth_year }
Fitness level: ${ person.medical_fitness_level || 'Unknown' }
Last fitness check: ${ person.medical_last_fitness_check || 'Unknown' }
Blood type: ${ person.blood_type || 'Unknown' }
Blood type: ${ person.medical_blood_type || 'Unknown' }
Allergies: ${ person.medical_allergies || 'None / Unknown' }

Medical records:
CURRENT MEDICATION:
${ person.medical_current_medication || 'None / Unknown' }

${ parseEntries(this.record.entries, 'MEDICAL') }
ACTIVE CONDITIONS:
${ person.medical_active_conditions.replaceAll('\n\n','\n') || 'None / Unknown' }

MEDICAL RECORDS:
${ parseEntries(this.record.entries, 'MEDICAL').join('\n').replaceAll('\n\n','\n') }

Ready to scan another patient ID card`

Ready to scan another patient bio ID`
this.state = 'results';
},
async getRecords(message) {
console.log('messa', message);
if (this.state === 'processing') return;
if (message.startsWith('card:')) {
if (message.startsWith('bio:')) {
this.id = message.split( ':', 2)[1]
if (!this.id) return;
this.record = await getBlob('/person/card', this.id)
this.record = await getBlob('/person/bio', this.id)
if (this.record) {
this.analyze();
} else {
this.showRecord();
}
} else {
this.resultText = `This does not seem to be an ID card.
this.resultText = `This does not seem to be an bio ID.


Scan a patient ID card`;
Scan patient bio ID`;
}
},
analyze() {
Expand Down
3 changes: 3 additions & 0 deletions src/components/MedicalSample.vue
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ input, textarea, .type-select {
margin: 1rem;
margin-top: 0.5rem;
}
option {
background: lighten($gray, 45);
}
.type-select {
text-align: center;
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/MedicalScanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ input, textarea, .type-select {
margin: 1rem;
margin-top: 0.5rem;
}
option {
background: lighten($gray, 45);
}
.type-select {
text-align: center;
}
Expand Down
12 changes: 8 additions & 4 deletions src/components/ScienceArtifactDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,21 @@ export default {
const artifact = this.record;
if (!artifact) return this.resultText = `This artifact is unknown.`;
this.query = ''
this.resultText = `Artifact scan results:
this.resultText = `ARTIFACT SCAN RESULTS:

Name: ${ artifact.name }
Catalog ID: ${ artifact.catalog_id }
Artifact origin: ${ artifact.type || 'Unknown' }
Discovered by: ${ artifact.discovered_by || 'Unknown' }
Discovery time: ${ artifact.discovered_at || 'Unknown' }
Discovery location: ${ artifact.discovered_from || 'Unknown' }
Artifact type: ${ artifact.type || 'Unknown' }

Additional entries:
ARTIFACT DESCRIPTION:
${ artifact.text.split("![]")[0].trim() || 'None' }

ADDITIONAL ENTRIES:
${ parseEntries(this.record.entries).join('\n\n').replaceAll('\n\n', '\n')}

${ parseEntries(this.record.entries) }

Ready to scan a new artifact.`
this.state = 'results';
Expand Down
4 changes: 2 additions & 2 deletions src/components/ScienceInspectObject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default {
}
},
showRecord() {
this.resultText = get(this.res, 'data.description', this.tagNotFoundMessage) + '\n\nReady to scan another object';
this.resultText = get(this.res, 'data.description', this.tagNotFoundMessage) + '\n\n\nReady to scan another object';
this.state = 'results';
},
async show() {
Expand Down Expand Up @@ -110,7 +110,7 @@ export default {
},
},
created() {
this.title = 'INSPECT OBJECT';
this.title = 'SCAN OBJECT';
this.resultText = 'Ready to scan an object';
this.tagRegexp = /^science:..*/;
this.tagNotFoundMessage = 'This object is unknown';
Expand Down

0 comments on commit 7754a96

Please sign in to comment.