mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-07 07:18:12 +00:00
chore(driver): moved analysis locales to separate local instance; improved analysis content
This commit is contained in:
+60
-23
@@ -71,13 +71,20 @@
|
|||||||
{{ t('analysis.title') }}
|
{{ t('analysis.title') }}
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
{{ analysisLanguage }}
|
<button
|
||||||
<button class="btn btn--image" @click="changeAnalysisLanguage('pl')">
|
class="btn btn--image"
|
||||||
<img src="/images/flags/pl.svg" alt="" width="20" />
|
:data-checked="analysisi18n.global.locale == 'pl'"
|
||||||
|
@click="changeAnalysisLanguage('pl')"
|
||||||
|
>
|
||||||
|
<img src="/images/flags/pl.svg" alt="flag pl" width="25" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button class="btn btn--image" @click="changeAnalysisLanguage('en')">
|
<button
|
||||||
<img src="/images/flags/en.svg" alt="" width="20" />
|
class="btn btn--image"
|
||||||
|
:data-checked="analysisi18n.global.locale == 'en'"
|
||||||
|
@click="changeAnalysisLanguage('en')"
|
||||||
|
>
|
||||||
|
<img src="/images/flags/en.svg" alt="flag eng" width="25" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -86,8 +93,10 @@
|
|||||||
<hr class="divider" />
|
<hr class="divider" />
|
||||||
|
|
||||||
<div class="analysis-actions">
|
<div class="analysis-actions">
|
||||||
<button class="btn btn--action">
|
<button class="btn btn--action" @click="copyAnalysisToClipboard()">
|
||||||
<i class="fa-regular fa-copy"></i>{{ t('analysis.button-copy') }}
|
<i class="fa-regular fa-copy"></i>{{ t('analysis.button-copy') }} ({{
|
||||||
|
analysisi18n.global.locale.toUpperCase()
|
||||||
|
}})
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button class="btn btn--action" @click="copyStockToClipboard()">
|
<button class="btn btn--action" @click="copyStockToClipboard()">
|
||||||
@@ -102,12 +111,24 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, PropType, watch, onMounted } from 'vue';
|
import { ref, computed, PropType, watch, onMounted } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { createI18n, useI18n } from 'vue-i18n';
|
||||||
import { Train } from '../../typings/common';
|
import { Train } from '../../typings/common';
|
||||||
import rulesJSON from '../../data/trainNumberRules.json';
|
import rulesJSON from '../../data/trainNumberRules.json';
|
||||||
import { useApiStore } from '../../store/apiStore';
|
import { useApiStore } from '../../store/apiStore';
|
||||||
|
|
||||||
const { t, locale } = useI18n();
|
import enLang from '../../locales/analysis/en.json';
|
||||||
|
import plLang from '../../locales/analysis/pl.json';
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
const analysisi18n = createI18n({
|
||||||
|
locale: 'pl',
|
||||||
|
messages: {
|
||||||
|
en: enLang,
|
||||||
|
pl: plLang
|
||||||
|
},
|
||||||
|
sync: false
|
||||||
|
});
|
||||||
|
|
||||||
const apiStore = useApiStore();
|
const apiStore = useApiStore();
|
||||||
|
|
||||||
@@ -121,12 +142,9 @@ const props = defineProps({
|
|||||||
const emits = defineEmits(['selectCategory']);
|
const emits = defineEmits(['selectCategory']);
|
||||||
|
|
||||||
const chosenCategoryIndex = ref(0);
|
const chosenCategoryIndex = ref(0);
|
||||||
|
|
||||||
const numberPropositions = ref<string[]>([]);
|
const numberPropositions = ref<string[]>([]);
|
||||||
const chosenCategoryRules = ref<any[]>([]);
|
const chosenCategoryRules = ref<any[]>([]);
|
||||||
|
|
||||||
const analysisLanguage = ref(locale.value);
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
computed(() => props.chosenTrain.trainNo),
|
computed(() => props.chosenTrain.trainNo),
|
||||||
() => {
|
() => {
|
||||||
@@ -220,8 +238,24 @@ function copyStockToClipboard() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeAnalysisLanguage(langId: string) {
|
function copyAnalysisToClipboard() {
|
||||||
analysisLanguage.value = langId;
|
let content = `\n${analysisi18n.global.t('title')}`;
|
||||||
|
content += analysisHtml.value;
|
||||||
|
|
||||||
|
content = content.replace(/<br>/g, '\n');
|
||||||
|
|
||||||
|
navigator.clipboard
|
||||||
|
.writeText(content)
|
||||||
|
.then(() => {
|
||||||
|
prompt(t('analysis.stock-clipboard-success'), content);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
alert(t('analysis.stock-clipboard-failure'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeAnalysisLanguage(langId: 'pl' | 'en') {
|
||||||
|
analysisi18n.global.locale = langId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const chosenCategory = computed(() => {
|
const chosenCategory = computed(() => {
|
||||||
@@ -338,16 +372,14 @@ const availableCategories = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const analysisHtml = computed(() => {
|
const analysisHtml = computed(() => {
|
||||||
let analysisStr = `${t('analysis.title')}: `;
|
let analysisStr = `<b>${chosenCategory.value} $number </b> (${props.chosenTrain.stockList[0]}, ${(props.chosenTrain.mass / 1000).toFixed(1)}t, ${props.chosenTrain.length}m)`;
|
||||||
|
|
||||||
analysisStr += `<b>${chosenCategory.value} $number </b> (${props.chosenTrain.stockList[0]}, ${(props.chosenTrain.mass / 1000).toFixed(1)}t, ${props.chosenTrain.length}m)`;
|
|
||||||
|
|
||||||
if (Object.keys(cargoWarnings.value).length > 0) {
|
if (Object.keys(cargoWarnings.value).length > 0) {
|
||||||
if (Object.keys(cargoWarnings.value).some((k) => k.includes('-twr')))
|
if (Object.keys(cargoWarnings.value).some((k) => k.includes('-twr')))
|
||||||
analysisStr += `<br>${t('analysis.warnings.has-twr')}`;
|
analysisStr += `<br>${analysisi18n.global.t('has-twr')}`;
|
||||||
|
|
||||||
if (Object.keys(cargoWarnings.value).some((k) => k.includes('-tn')))
|
if (Object.keys(cargoWarnings.value).some((k) => k.includes('-tn')))
|
||||||
analysisStr += `<br>${t('analysis.warnings.has-tn')}`;
|
analysisStr += `<br>${analysisi18n.global.t('has-tn')}`;
|
||||||
|
|
||||||
if (cargoWarnings.value['zags-loaded-twr'] || cargoWarnings.value['zags-empty-tn']) {
|
if (cargoWarnings.value['zags-loaded-twr'] || cargoWarnings.value['zags-empty-tn']) {
|
||||||
analysisStr += `<br><i>33UN1965 ${cargoWarnings.value['zags-loaded-twr'] || 0}/${cargoWarnings.value['zags-empty-tn'] || 0} Zags</i>`;
|
analysisStr += `<br><i>33UN1965 ${cargoWarnings.value['zags-loaded-twr'] || 0}/${cargoWarnings.value['zags-empty-tn'] || 0} Zags</i>`;
|
||||||
@@ -358,7 +390,7 @@ const analysisHtml = computed(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Object.keys(cargoWarnings.value).some((k) => k.includes('-pn'))) {
|
if (Object.keys(cargoWarnings.value).some((k) => k.includes('-pn'))) {
|
||||||
analysisStr += `${t('analysis.warnings.has-pn')}:`;
|
analysisStr += `${analysisi18n.global.t('has-pn')}:`;
|
||||||
|
|
||||||
if (cargoWarnings.value['innofreight-all-pn']) {
|
if (cargoWarnings.value['innofreight-all-pn']) {
|
||||||
analysisStr += `<br> - Innofreight - przekroczona skrajnia`;
|
analysisStr += `<br> - Innofreight - przekroczona skrajnia`;
|
||||||
@@ -380,8 +412,7 @@ const analysisHtml = computed(() => {
|
|||||||
|
|
||||||
hr.divider {
|
hr.divider {
|
||||||
margin: 0.5em 0;
|
margin: 0.5em 0;
|
||||||
border-bottom: #111;
|
border-top: #111;
|
||||||
border-width: 2px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.analysis-box {
|
.analysis-box {
|
||||||
@@ -423,6 +454,7 @@ hr.divider {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 0.5em;
|
gap: 0.5em;
|
||||||
|
margin-top: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.analysis-html {
|
.analysis-html {
|
||||||
@@ -438,8 +470,13 @@ hr.divider {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.5em;
|
gap: 0.5em;
|
||||||
|
|
||||||
.btn {
|
& > .btn {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
opacity: 0.6;
|
||||||
|
|
||||||
|
&[data-checked='true'] {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<!-- Proposed numbers container -->
|
<!-- Proposed numbers container -->
|
||||||
<transition name="view-anim">
|
<transition name="view-anim">
|
||||||
<DriverPropositions :chosenTrain="chosenTrain" v-if="arePropositionsVisible" />
|
<DriverAnalysis :chosenTrain="chosenTrain" v-if="arePropositionsVisible" />
|
||||||
</transition>
|
</transition>
|
||||||
|
|
||||||
<StockList :trainStockList="chosenTrain.stockList" :key="chosenTrain.id" :showPreviews="true" />
|
<StockList :trainStockList="chosenTrain.stockList" :key="chosenTrain.id" :showPreviews="true" />
|
||||||
@@ -27,7 +27,7 @@ import { useI18n } from 'vue-i18n';
|
|||||||
import StockList from '../Global/StockList.vue';
|
import StockList from '../Global/StockList.vue';
|
||||||
import TrainSchedule from '../TrainsView/TrainSchedule.vue';
|
import TrainSchedule from '../TrainsView/TrainSchedule.vue';
|
||||||
import TrainInfo from '../TrainsView/TrainInfo.vue';
|
import TrainInfo from '../TrainsView/TrainInfo.vue';
|
||||||
import DriverPropositions from './DriverPropositions.vue';
|
import DriverAnalysis from './DriverAnalysis.vue';
|
||||||
|
|
||||||
const i18n = useI18n();
|
const i18n = useI18n();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"title": "Analysis for: ",
|
||||||
|
|
||||||
|
"has-pn": "* contains extraordinary deliveries (PN)",
|
||||||
|
"has-tn": "* contains dangerous cargo (TN)",
|
||||||
|
"has-twr": "* contains high risk dangerous cargo (TWR)",
|
||||||
|
|
||||||
|
"empty": "empty",
|
||||||
|
"loaded": "loaded"
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"title": "Analiza dla: ",
|
||||||
|
|
||||||
|
"has-pn": "* przejazd z przesyłkami nadzwyczajnymi (PN)",
|
||||||
|
"has-tn": "* przewozi towary niebezpieczne (TN)",
|
||||||
|
"has-twr": "* przewozi towary niebezpieczne wysokiego ryzyka (TWR)",
|
||||||
|
|
||||||
|
"empty": "puste",
|
||||||
|
"loaded": "pełne"
|
||||||
|
}
|
||||||
+1
-9
@@ -444,7 +444,6 @@
|
|||||||
"button-show": "ANALYSIS & STOCK",
|
"button-show": "ANALYSIS & STOCK",
|
||||||
"number-info": "will be automatically updated to the current train number chosen in the simulator after the analysis is sent in the chat.",
|
"number-info": "will be automatically updated to the current train number chosen in the simulator after the analysis is sent in the chat.",
|
||||||
"button-copy": "COPY THE ANALYSIS",
|
"button-copy": "COPY THE ANALYSIS",
|
||||||
"title": "Analysis content",
|
|
||||||
"stock-copy": "COPY THE STOCK",
|
"stock-copy": "COPY THE STOCK",
|
||||||
"stock-clipboard-success": "Successfully copied the railway stock in a text form to your clipboard!",
|
"stock-clipboard-success": "Successfully copied the railway stock in a text form to your clipboard!",
|
||||||
"stock-clipboard-failure": "Oops! Something happened and the railway stock couldn't be copied to your clipboard! :/",
|
"stock-clipboard-failure": "Oops! Something happened and the railway stock couldn't be copied to your clipboard! :/",
|
||||||
@@ -465,14 +464,7 @@
|
|||||||
"zans-empty-tn": "TN: unclean tanks after UN1202",
|
"zans-empty-tn": "TN: unclean tanks after UN1202",
|
||||||
"military-all-pn": "PN: military transport",
|
"military-all-pn": "PN: military transport",
|
||||||
"edk80-all-pn": "PN: EDK80 railway crane",
|
"edk80-all-pn": "PN: EDK80 railway crane",
|
||||||
"innofreight-all-pn": "PN: Innofreight C45: exceeded gauge",
|
"innofreight-all-pn": "PN: Innofreight C45: exceeded gauge"
|
||||||
|
|
||||||
"has-pn": "* contains extraordinary deliveries (PN)",
|
|
||||||
"has-tn": "* contains dangerous cargo (TN)",
|
|
||||||
"has-twr": "* contains high risk dangerous cargo (TWR)",
|
|
||||||
|
|
||||||
"empty": "empty",
|
|
||||||
"loaded": "loaded"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
+2
-9
@@ -434,7 +434,7 @@
|
|||||||
"button-show": "ANALIZA I SKŁAD",
|
"button-show": "ANALIZA I SKŁAD",
|
||||||
"number-info": "zostanie automatycznie zaktualizowany na obecny numer wybrany w symulatorze po wysłaniu wiadomości na czacie.",
|
"number-info": "zostanie automatycznie zaktualizowany na obecny numer wybrany w symulatorze po wysłaniu wiadomości na czacie.",
|
||||||
"button-copy": "SKOPIUJ ANALIZĘ",
|
"button-copy": "SKOPIUJ ANALIZĘ",
|
||||||
"title": "Treść analizy",
|
"title": "Treść analizy:",
|
||||||
|
|
||||||
"stock-copy": "SKOPIUJ SKŁAD",
|
"stock-copy": "SKOPIUJ SKŁAD",
|
||||||
"stock-clipboard-success": "Pomyślnie skopiowano skład w postaci tekstowej do schowka:",
|
"stock-clipboard-success": "Pomyślnie skopiowano skład w postaci tekstowej do schowka:",
|
||||||
@@ -456,14 +456,7 @@
|
|||||||
"zans-empty-tn": "TN: brudne cysterny po UN1202",
|
"zans-empty-tn": "TN: brudne cysterny po UN1202",
|
||||||
"military-all-pn": "PN: transport wojskowy",
|
"military-all-pn": "PN: transport wojskowy",
|
||||||
"edk80-all-pn": "PN: żuraw kolejowy EDK80",
|
"edk80-all-pn": "PN: żuraw kolejowy EDK80",
|
||||||
"innofreight-all-pn": "PN: Innofreight C45: przekroczona skrajnia",
|
"innofreight-all-pn": "PN: Innofreight C45: przekroczona skrajnia"
|
||||||
|
|
||||||
"has-pn": "* przejazd z przesyłkami nadzwyczajnymi (PN)",
|
|
||||||
"has-tn": "* przewozi towary niebezpieczne (TN)",
|
|
||||||
"has-twr": "* przewozi towary niebezpieczne wysokiego ryzyka (TWR)",
|
|
||||||
|
|
||||||
"empty": "puste",
|
|
||||||
"loaded": "pełne"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"train-stats": {
|
"train-stats": {
|
||||||
|
|||||||
Reference in New Issue
Block a user