mirror of
https://github.com/Spythere/station-manager-2.0.git
synced 2026-05-03 05:28:13 +00:00
zmiana endpointów; poprawki designu
This commit is contained in:
+9
-12
@@ -14,7 +14,7 @@
|
||||
<br />
|
||||
<input type="password" id="password" v-model="password" />
|
||||
<br />
|
||||
<button>{{ loginState == LoginState.LOADING ? 'Logowanie...' : 'Zaloguj się' }}</button>
|
||||
<button>{{ isLoading ? 'Logowanie...' : 'Zaloguj się' }}</button>
|
||||
</form>
|
||||
<p style="color: yellow; height: 25px">{{ errorMessage }}</p>
|
||||
</div>
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { useStore, baseURL } from '../store';
|
||||
import { useStore } from '../store';
|
||||
import { AuthState, IUser } from '../types/types';
|
||||
import axios from 'axios';
|
||||
import client from '../common/http';
|
||||
|
||||
enum LoginState {
|
||||
INITIALIZED = 0,
|
||||
@@ -38,6 +38,7 @@ export default defineComponent({
|
||||
return {
|
||||
errorMessage: '',
|
||||
loginState: LoginState.INITIALIZED,
|
||||
isLoading: false,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -55,21 +56,15 @@ export default defineComponent({
|
||||
methods: {
|
||||
async signIn(e: Event) {
|
||||
this.loginState = LoginState.LOADING;
|
||||
this.isLoading = true;
|
||||
|
||||
try {
|
||||
const response = await axios.post<IUser>(
|
||||
'auth/login',
|
||||
{ username: this.name, password: this.password },
|
||||
{
|
||||
baseURL,
|
||||
withCredentials: true,
|
||||
}
|
||||
);
|
||||
const response = await client.post<IUser>('auth/login', { username: this.name, password: this.password });
|
||||
|
||||
this.$router.push('/');
|
||||
this.store.setUserData(response.data);
|
||||
|
||||
this.loginState = LoginState.LOADED;
|
||||
this.$router.push('/');
|
||||
} catch (e: any) {
|
||||
this.loginState = LoginState.ERROR;
|
||||
this.store.removeUserData();
|
||||
@@ -89,6 +84,8 @@ export default defineComponent({
|
||||
|
||||
this.errorMessage = 'Wystąpił błąd podczas łączenia z serwerem!';
|
||||
return false;
|
||||
} finally {
|
||||
this.isLoading = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -19,9 +19,7 @@
|
||||
<tr v-for="(station, row) in store.sortedStationList" tabindex="0">
|
||||
<td v-for="(value, propName) in headerNameList" @click="changeProperty(station, row, propName as string)">
|
||||
<span v-if="propName === 'url'" :style="station.url ? 'color: gold' : 'color: gray;'">URL</span>
|
||||
<span v-else-if="propName === 'projectUrl'" :style="station.projectUrl ? 'color: gold' : 'color: gray;'"
|
||||
>URL</span
|
||||
>
|
||||
<span v-else-if="propName === 'projectUrl'" :style="station.projectUrl ? 'color: gold' : 'color: gray;'">URL</span>
|
||||
|
||||
<span v-else-if="propName === 'checkpoints'">{{ station[propName] ? 'POKAŻ' : 'DODAJ' }}</span>
|
||||
|
||||
@@ -119,9 +117,7 @@ export default defineComponent({
|
||||
return;
|
||||
}
|
||||
|
||||
const stationListRow = this.store.stationList.findIndex(
|
||||
(station) => station.name == this.store.sortedStationList[row].name
|
||||
);
|
||||
const stationListRow = this.store.stationList.findIndex((station) => station.name == this.store.sortedStationList[row].name);
|
||||
|
||||
if (stationListRow == -1) return;
|
||||
const oldValue = (this.store.stationList[stationListRow] as any)[propertyName];
|
||||
@@ -134,16 +130,13 @@ export default defineComponent({
|
||||
|
||||
let newValue = prompt(`Zmień wartość dla rubryki ${this.headerNameList[propertyName]}`, oldValue || '');
|
||||
if (newValue == null) return;
|
||||
(this.store.stationList[stationListRow] as any)[propertyName] =
|
||||
typeof oldValue === 'number' ? parseInt(newValue) : newValue;
|
||||
(this.store.stationList[stationListRow] as any)[propertyName] = typeof oldValue === 'number' ? parseInt(newValue) : newValue;
|
||||
// this.$set(this.stationList[stationListRow], propertyName, parseInt(newValue));
|
||||
this.addChange(station, propertyName, oldValue, typeof oldValue === 'number' ? parseInt(newValue) : newValue);
|
||||
},
|
||||
|
||||
changeCheckpoints(row: number) {
|
||||
const stationListRow = this.store.stationList.findIndex(
|
||||
(station) => station.name == this.store.sortedStationList[row].name
|
||||
);
|
||||
const stationListRow = this.store.stationList.findIndex((station) => station.name == this.store.sortedStationList[row].name);
|
||||
|
||||
if (stationListRow == -1) return;
|
||||
const oldCheckpoints = this.store.stationList[stationListRow].checkpoints;
|
||||
@@ -234,4 +227,8 @@ td img {
|
||||
height: 1.45em;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
button {
|
||||
color: black;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user