mirror of
https://github.com/Spythere/genera-tor.git
synced 2026-05-03 05:28:13 +00:00
@@ -1,2 +1,4 @@
|
||||
VITE_APP_API_URL=https://stacjownik.spythere.eu/api
|
||||
VITE_APP_SWDR_URL=https://api.td2.info.pl
|
||||
VITE_APP_SWDR_URL=https://api.td2.info.pl
|
||||
|
||||
VITE_APP_ORDER_VERSION=2
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "genera-tor",
|
||||
"version": "1.4.2",
|
||||
"version": "1.4.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -15,15 +15,25 @@
|
||||
<b class="text--accent">#{{ order.id.split('-')[1] }} </b>
|
||||
<b>
|
||||
{{ getOrderName(order.orderType) }} nr {{ order.orderBody['header']['orderNo'] }} dla
|
||||
pociągu nr
|
||||
{{ order.orderBody['header']['trainNo'] }}
|
||||
pociągu nr {{ order.orderBody['header']['trainNo'] }}
|
||||
</b>
|
||||
<span
|
||||
v-if="!order.orderVersion || order.orderVersion != ORDER_VERSION"
|
||||
class="wrong-order-indicator"
|
||||
tabindex="0"
|
||||
data-tooltip="Przestarzała wersja rozkazu! Może generować złe informacje!"
|
||||
>⚠
|
||||
</span>
|
||||
<br />
|
||||
{{ order.createdAt ? 'Dodano: ' : 'Zaktualizowano: ' }}
|
||||
{{ new Date(order.createdAt || order.updatedAt || 0).toLocaleString('pl-PL') }}
|
||||
<br />
|
||||
<button class="g-button action" @click="selectLocalOrder(order)">Wybierz</button>
|
||||
<button class="g-button action" @click="removeOrder(order)">Usuń</button>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="buttons">
|
||||
<button class="g-button action" @click="selectLocalOrder(order)">Wybierz</button>
|
||||
<button class="g-button action" @click="removeOrder(order)">Usuń</button>
|
||||
</div>
|
||||
</li>
|
||||
</transition-group>
|
||||
</section>
|
||||
@@ -41,7 +51,8 @@ export default defineComponent({
|
||||
|
||||
data() {
|
||||
return {
|
||||
localOrderList: [] as LocalStorageOrder[]
|
||||
localOrderList: [] as LocalStorageOrder[],
|
||||
ORDER_VERSION: import.meta.env['VITE_APP_ORDER_VERSION']
|
||||
};
|
||||
},
|
||||
|
||||
@@ -117,9 +128,13 @@ export default defineComponent({
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
hr {
|
||||
border: 1px solid #aaa;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
ul {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
h3 {
|
||||
@@ -144,17 +159,24 @@ li {
|
||||
|
||||
cursor: pointer;
|
||||
|
||||
button {
|
||||
margin: 1em 1em 0 0;
|
||||
}
|
||||
|
||||
&[selected='true'] {
|
||||
outline: 1px solid $accentCol;
|
||||
}
|
||||
|
||||
&.no-orders-warning {
|
||||
text-align: center;
|
||||
font-size: 1.2em;
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
.wrong-order-indicator {
|
||||
color: $accentCol;
|
||||
padding: 0 0.25em;
|
||||
}
|
||||
|
||||
.buttons {
|
||||
display: flex;
|
||||
gap: 0.5em;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,6 +2,11 @@ import { defineComponent } from 'vue';
|
||||
import { useStore } from '../store/store';
|
||||
import { LocalStorageOrder } from '../types/orderTypes';
|
||||
|
||||
function alertWrongOrderFormat() {
|
||||
alert('Wystąpił błąd podczas przetwarzania rozkazu! Informacje mogą być niepoprawne!');
|
||||
console.warn('Zły format zapisanego rozkazu!');
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
return {
|
||||
@@ -28,7 +33,8 @@ export default defineComponent({
|
||||
orderType: this.store.chosenOrderType,
|
||||
orderBody: this.store[this.store.chosenOrderType],
|
||||
orderFooter: this.store.orderFooter,
|
||||
createdAt: Date.now()
|
||||
createdAt: Date.now(),
|
||||
orderVersion: import.meta.env['VITE_APP_ORDER_VERSION'] || '1'
|
||||
};
|
||||
|
||||
const headerInfo = orderObj['orderBody']['header'];
|
||||
@@ -69,7 +75,8 @@ export default defineComponent({
|
||||
orderType: this.store.chosenOrderType,
|
||||
orderBody: this.store[this.store.chosenOrderType],
|
||||
orderFooter: this.store.orderFooter,
|
||||
updatedAt: Date.now()
|
||||
updatedAt: Date.now(),
|
||||
orderVersion: import.meta.env['VITE_APP_ORDER_VERSION'] || '1'
|
||||
};
|
||||
|
||||
window.localStorage.setItem(this.store.chosenLocalOrderId, JSON.stringify(orderObj));
|
||||
@@ -84,50 +91,72 @@ export default defineComponent({
|
||||
// localStorage.setItem('orderCount', (Number(localStorage.getItem('orderCount')) - 1).toString());
|
||||
},
|
||||
|
||||
selectLocalOrder(order: LocalStorageOrder) {
|
||||
this.store.chosenOrderType = order.orderType;
|
||||
this.store.chosenLocalOrderId = order.id;
|
||||
selectLocalOrder(localOrder: LocalStorageOrder) {
|
||||
// const localOrder = JSON.parse(JSON.stringify(order));
|
||||
const { orderBody: localOrderBody, orderFooter: localOrderFooter } = localOrder;
|
||||
|
||||
const localOrder = JSON.parse(JSON.stringify(order));
|
||||
const localOrderBody = localOrder['orderBody'];
|
||||
const localOrderFooter = localOrder['orderFooter'];
|
||||
this.store[localOrder.orderType].header.date = localOrderBody.header.date;
|
||||
this.store[localOrder.orderType].header.orderNo = localOrderBody.header.orderNo;
|
||||
this.store[localOrder.orderType].header.trainNo = localOrderBody.header.trainNo;
|
||||
|
||||
let storeOrderObj;
|
||||
if (localOrder.orderType == 'orderN' || localOrder.orderType == 'orderS') {
|
||||
const currentOrder = this.store[localOrder.orderType];
|
||||
|
||||
switch (order.orderType) {
|
||||
case 'orderN':
|
||||
case 'orderS':
|
||||
storeOrderObj = this.store[order.orderType];
|
||||
for (const orderKey in storeOrderObj) {
|
||||
for (const propKey in (storeOrderObj as any)[orderKey]) {
|
||||
(storeOrderObj as any)[orderKey][propKey] = localOrderBody[orderKey][propKey];
|
||||
}
|
||||
if (localOrderBody.rows.length != currentOrder.rows.length) {
|
||||
alertWrongOrderFormat();
|
||||
return;
|
||||
}
|
||||
|
||||
for (let rowIndex = 0; rowIndex < currentOrder.rows.length; rowIndex++) {
|
||||
const row = currentOrder.rows[rowIndex];
|
||||
|
||||
if (localOrderBody.rows[rowIndex] === undefined) {
|
||||
alertWrongOrderFormat();
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'orderO':
|
||||
storeOrderObj = this.store[order.orderType];
|
||||
|
||||
storeOrderObj['other'] = localOrderBody['other'];
|
||||
storeOrderObj['header']['date'] = localOrderBody['header']['date'];
|
||||
storeOrderObj['header']['orderNo'] = localOrderBody['header']['orderNo'];
|
||||
storeOrderObj['header']['trainNo'] = localOrderBody['header']['trainNo'];
|
||||
|
||||
for (let i = 0; i < storeOrderObj['orderList'].length; i++) {
|
||||
const orderItem = storeOrderObj['orderList'][i];
|
||||
|
||||
for (const prop in orderItem) {
|
||||
(storeOrderObj['orderList'][i] as any)[prop] = localOrderBody['orderList'][i][prop];
|
||||
for (const rowProp in row) {
|
||||
if (localOrderBody.rows[rowIndex][rowProp] === undefined) {
|
||||
alertWrongOrderFormat();
|
||||
continue;
|
||||
}
|
||||
|
||||
(currentOrder.rows[rowIndex] as any)[rowProp] = localOrderBody.rows[rowIndex][rowProp];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (localOrder.orderType == 'orderO') {
|
||||
const currentOrder = this.store[localOrder.orderType];
|
||||
|
||||
for (let rowIndex = 0; rowIndex < currentOrder.orderList.length; rowIndex++) {
|
||||
const row = currentOrder.orderList[rowIndex];
|
||||
|
||||
if (localOrderBody.orderList[rowIndex] === undefined) {
|
||||
alertWrongOrderFormat();
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
for (const rowProp in row) {
|
||||
if (localOrderBody.orderList[rowIndex][rowProp] === undefined) {
|
||||
alertWrongOrderFormat();
|
||||
continue;
|
||||
}
|
||||
|
||||
(currentOrder.orderList[rowIndex] as any)[rowProp] =
|
||||
localOrderBody.orderList[rowIndex][rowProp];
|
||||
}
|
||||
}
|
||||
|
||||
currentOrder.other = localOrderBody.other;
|
||||
}
|
||||
|
||||
for (const key in this.store.orderFooter) {
|
||||
(this.store.orderFooter as any)[key] = localOrderFooter[key];
|
||||
}
|
||||
|
||||
this.store.chosenOrderType = localOrder.orderType;
|
||||
this.store.chosenLocalOrderId = localOrder.id;
|
||||
this.store.orderMode = 'OrderMessage';
|
||||
}
|
||||
}
|
||||
|
||||
+40
-5
@@ -33,7 +33,9 @@ button {
|
||||
outline: none;
|
||||
background: none;
|
||||
|
||||
transition: all 150ms ease-in;
|
||||
transition:
|
||||
color 90ms ease-in,
|
||||
border 90ms ease-in;
|
||||
font-family: 'Libre Franklin', sans-serif;
|
||||
|
||||
cursor: pointer;
|
||||
@@ -46,20 +48,31 @@ button.g-button {
|
||||
color: white;
|
||||
|
||||
&.action {
|
||||
outline: 2px solid white;
|
||||
border: 2px solid white;
|
||||
padding: 0.5em;
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid $accentCol;
|
||||
border: 2px solid $accentCol;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: $accentCol;
|
||||
}
|
||||
}
|
||||
|
||||
&.option {
|
||||
position: relative;
|
||||
margin: 0 0.25em;
|
||||
padding: 0.25em;
|
||||
|
||||
&:focus-visible {
|
||||
outline: 1px solid $accentCol;
|
||||
&:focus-visible::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 2px;
|
||||
background-color: $accentCol;
|
||||
}
|
||||
|
||||
&[data-active='true'] {
|
||||
@@ -95,6 +108,10 @@ select {
|
||||
padding: 0.1em 0;
|
||||
border-radius: 0.3em;
|
||||
text-align: center;
|
||||
|
||||
&:hover {
|
||||
border: 2px solid $accentCol;
|
||||
}
|
||||
}
|
||||
|
||||
// List style
|
||||
@@ -195,3 +212,21 @@ label.g-checkbox {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tooltip
|
||||
[data-tooltip] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
[data-tooltip]:hover::after,
|
||||
[data-tooltip]:focus::after {
|
||||
position: absolute;
|
||||
|
||||
content: attr(data-tooltip);
|
||||
color: white;
|
||||
background: black;
|
||||
padding: 0.5em;
|
||||
margin: 0.25em;
|
||||
max-width: 300px;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ export interface LocalStorageOrder {
|
||||
orderFooter: any;
|
||||
createdAt?: number;
|
||||
updatedAt?: number;
|
||||
orderVersion?: string;
|
||||
}
|
||||
|
||||
export interface IOrderN {
|
||||
|
||||
Reference in New Issue
Block a user