feat: added fronted for timers_list, added urls for cors
This commit is contained in:
277
client/src/views/TimersList/TimersList.css
Normal file
277
client/src/views/TimersList/TimersList.css
Normal file
@@ -0,0 +1,277 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.timers-container {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
padding: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
background-color: #ffffff;
|
||||
padding: 16px 16px;
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.page-header h1 {
|
||||
font-size: 32px;
|
||||
font-weight: 400;
|
||||
color: #212121;
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
|
||||
.timers-list {
|
||||
padding: 16px;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.loading,
|
||||
.error-message,
|
||||
.empty-state {
|
||||
background-color: #ffffff;
|
||||
border-radius: 4px;
|
||||
padding: 24px;
|
||||
text-align: center;
|
||||
margin-bottom: 16px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.loading p,
|
||||
.empty-state p {
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
background-color: #ffebee;
|
||||
border-left: 4px solid #f44336;
|
||||
}
|
||||
|
||||
.error-message p {
|
||||
color: #c62828;
|
||||
}
|
||||
|
||||
.timer-cards {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.timer-card {
|
||||
background-color: #ffffff;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.timer-card:hover {
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.timer-card.expanded {
|
||||
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 16px;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
transition: background-color 0.2s ease;
|
||||
}
|
||||
|
||||
.card-header:hover {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.timer-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
margin-right: 16px;
|
||||
color: #1976d2;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.timer-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.timer-title {
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
color: #212121;
|
||||
margin: 0 0 4px 0;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.timer-subtitle {
|
||||
font-size: 13px;
|
||||
color: #757575;
|
||||
margin: 0;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.expand-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
color: #999;
|
||||
font-size: 24px;
|
||||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.timer-card.expanded .expand-icon {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.card-content {
|
||||
border-top: 1px solid #e0e0e0;
|
||||
padding: 16px;
|
||||
background-color: #fafafa;
|
||||
animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
@keyframes slideDown {
|
||||
from {
|
||||
opacity: 0;
|
||||
max-height: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
max-height: 500px;
|
||||
}
|
||||
}
|
||||
|
||||
.timer-details {
|
||||
margin-bottom: 16px;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
}
|
||||
|
||||
.detail-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 8px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.detail-label {
|
||||
color: #666;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.detail-value {
|
||||
color: #212121;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.card-actions {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
padding: 10px 12px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
min-height: 36px;
|
||||
}
|
||||
|
||||
.btn ion-icon {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #1976d2;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: #1565c0;
|
||||
box-shadow: 0 4px 8px rgba(25, 118, 210, 0.3);
|
||||
}
|
||||
|
||||
.btn-primary:active {
|
||||
background-color: #0d47a1;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background-color: #e0e0e0;
|
||||
color: #212121;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background-color: #d0d0d0;
|
||||
}
|
||||
|
||||
.btn-secondary:active {
|
||||
background-color: #c0c0c0;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background-color: #fff3e0;
|
||||
color: #e65100;
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background-color: #ffe0b2;
|
||||
}
|
||||
|
||||
.btn-danger:active {
|
||||
background-color: #ffcc80;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.page-header {
|
||||
padding: 12px 16px;
|
||||
}
|
||||
.page-header h1 {
|
||||
font-size: 24px;
|
||||
}
|
||||
.timers-list {
|
||||
padding: 8px;
|
||||
}
|
||||
.card-header {
|
||||
padding: 12px;
|
||||
}
|
||||
.timer-icon {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
margin-right: 12px;
|
||||
}
|
||||
.card-content {
|
||||
padding: 12px;
|
||||
}
|
||||
.card-actions {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
.btn {
|
||||
padding: 8px 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
81
client/src/views/TimersList/TimersList.html
Normal file
81
client/src/views/TimersList/TimersList.html
Normal file
@@ -0,0 +1,81 @@
|
||||
<div class="timers-container">
|
||||
<div class="page-header">
|
||||
<h1>Таймеры</h1>
|
||||
</div>
|
||||
|
||||
<div class="timers-list">
|
||||
<!-- Loading state -->
|
||||
<div v-if="loading" class="loading">
|
||||
<p>Загрузка таймеров...</p>
|
||||
</div>
|
||||
|
||||
<!-- Error state -->
|
||||
<div v-else-if="error" class="error-message">
|
||||
<p>{{ error }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Empty state -->
|
||||
<div v-else-if="timers.length === 0" class="empty-state">
|
||||
<p>Нет таймеров</p>
|
||||
</div>
|
||||
|
||||
<!-- Timers list -->
|
||||
<div v-else class="timer-cards">
|
||||
<div
|
||||
v-for="timer in timers"
|
||||
:key="timer.id"
|
||||
class="timer-card"
|
||||
:class="{ expanded: expandedId === timer.id }"
|
||||
>
|
||||
<!-- Card header -->
|
||||
<div class="card-header" @click="toggleExpand(timer.id)">
|
||||
<div class="timer-icon">
|
||||
<ion-icon :icon="timerOutline"></ion-icon>
|
||||
</div>
|
||||
<div class="timer-info">
|
||||
<h3 class="timer-title">{{ timer.title }}</h3>
|
||||
<p class="timer-subtitle">{{ timer.count_pomodoro }} помидоров по {{ timer.pomodoro_time }} минут</p>
|
||||
</div>
|
||||
<div class="expand-icon">
|
||||
<ion-icon
|
||||
:icon="expandedId === timer.id ? chevronUp : chevronDown"
|
||||
></ion-icon>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Card content -->
|
||||
<div v-show="expandedId === timer.id" class="card-content">
|
||||
<div class="timer-details">
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Название:</span>
|
||||
<span class="detail-value">{{ timer.title }}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Длительность помидора:</span>
|
||||
<span class="detail-value">{{ timer.pomodoro_time }} минут</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Количество помидоров:</span>
|
||||
<span class="detail-value">{{ timer.count_pomodoro }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-actions">
|
||||
<button class="btn btn-primary">
|
||||
<ion-icon :icon="playCircleOutline"></ion-icon>
|
||||
Открыть
|
||||
</button>
|
||||
<button class="btn btn-secondary">
|
||||
<ion-icon :icon="pencilOutline"></ion-icon>
|
||||
Редактировать
|
||||
</button>
|
||||
<button class="btn btn-danger">
|
||||
<ion-icon :icon="trashOutline"></ion-icon>
|
||||
Удалить
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
67
client/src/views/TimersList/TimersList.js
Normal file
67
client/src/views/TimersList/TimersList.js
Normal file
@@ -0,0 +1,67 @@
|
||||
import { IonIcon } from '@ionic/vue';
|
||||
import {
|
||||
timerOutline,
|
||||
chevronUp,
|
||||
chevronDown,
|
||||
playCircleOutline,
|
||||
pencilOutline,
|
||||
trashOutline
|
||||
} from 'ionicons/icons';
|
||||
|
||||
export default {
|
||||
name: 'TimersList',
|
||||
components: {
|
||||
IonIcon,
|
||||
},
|
||||
setup() {
|
||||
// Возвращаем иконки, чтобы они были доступны в шаблоне
|
||||
return {
|
||||
timerOutline,
|
||||
chevronUp,
|
||||
chevronDown,
|
||||
playCircleOutline,
|
||||
pencilOutline,
|
||||
trashOutline,
|
||||
};
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
timers: [],
|
||||
expandedId: null,
|
||||
loading: true,
|
||||
error: null,
|
||||
apiUrl: 'http://127.0.0.1:8090/api/timers'
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.fetchTimers();
|
||||
},
|
||||
methods: {
|
||||
async fetchTimers() {
|
||||
try {
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
|
||||
// Для Tauri invoke (раскомментировать при необходимости)
|
||||
// const { invoke } = window.__TAURI__.tauri;
|
||||
// this.timers = await invoke('list_timers');
|
||||
|
||||
const response = await fetch(`${this.apiUrl}/`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
this.timers = await response.json();
|
||||
this.loading = false;
|
||||
} catch (err) {
|
||||
this.error = `Ошибка загрузки таймеров: ${err.message}`;
|
||||
this.loading = false;
|
||||
console.error('Fetch error:', err);
|
||||
}
|
||||
},
|
||||
toggleExpand(timerId) {
|
||||
this.expandedId = this.expandedId === timerId ? null : timerId;
|
||||
}
|
||||
},
|
||||
};
|
||||
4
client/src/views/TimersList/TimersList.vue
Normal file
4
client/src/views/TimersList/TimersList.vue
Normal file
@@ -0,0 +1,4 @@
|
||||
<!-- TimersList.vue -->
|
||||
<template src="./TimersList.html"></template>
|
||||
<script src="./TimersList.js"></script>
|
||||
<style src="./TimersList.css" scoped></style>
|
||||
Reference in New Issue
Block a user