added user page
This commit is contained in:
parent
26b3c76145
commit
87c21ffc90
@ -1,7 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import CatalogMixins from '../mixins/CatalogMixins.js';
|
import CatalogMixins from '../mixins/CatalogMixins.js';
|
||||||
import Monitor from '../models/Monitor';
|
import User from '../models/User.js';
|
||||||
import DataService from '../services/DataService';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [
|
mixins: [
|
||||||
@ -9,30 +8,12 @@ export default {
|
|||||||
],
|
],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
getAllUrl: 'user/',
|
getAllUrl: 'user',
|
||||||
dataUrl: 'user',
|
dataUrl: 'user',
|
||||||
transformer: (data) => new User(data),
|
transformer: (data) => new User(data),
|
||||||
headers: [
|
headers: [
|
||||||
{ name: 'userName', label: 'user' }
|
{ name: 'login', label: 'Логин' }
|
||||||
],
|
]
|
||||||
dataFilterUrl: 'monitor/filter?'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
filter() {
|
|
||||||
let urlParams = ""
|
|
||||||
if (document.getElementById('modelNameFilterInput').value !== "") {
|
|
||||||
urlParams += "modelName=" + this.modelName;
|
|
||||||
}
|
|
||||||
DataService.readAll(this.dataFilterUrl + urlParams, (data) => new Monitor(data))
|
|
||||||
.then(data => {
|
|
||||||
this.items = data;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
clearFilters() {
|
|
||||||
this.loadItems();
|
|
||||||
this.id = null;
|
|
||||||
this.modelName = null;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeCreate() {
|
beforeCreate() {
|
||||||
@ -44,13 +25,6 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="input-group mb-3">
|
|
||||||
<input type="text" class="form-control" id="modelNameFilterInput" placeholder="Модель" required v-model="modelName">
|
|
||||||
<button class="btn btn-primary" type="button" id="report-button"
|
|
||||||
@click.prevent="filter">Сформировать</button>
|
|
||||||
<button class="btn btn-outline-secondary" type="button" id="report-button"
|
|
||||||
@click.prevent="clearFilters">Очистить</button>
|
|
||||||
</div>
|
|
||||||
<ToolBar
|
<ToolBar
|
||||||
@add="showAddModal"
|
@add="showAddModal"
|
||||||
@edit="showEditModal"
|
@edit="showEditModal"
|
||||||
@ -67,9 +41,5 @@ export default {
|
|||||||
:confirm="this.modal.confirm"
|
:confirm="this.modal.confirm"
|
||||||
v-model:visible="this.modalShow"
|
v-model:visible="this.modalShow"
|
||||||
@done="saveItem">
|
@done="saveItem">
|
||||||
<div class="mb-3">
|
|
||||||
<label for="model" class="form-label">Модель</label>
|
|
||||||
<input type="text" class="form-control" id="model" required v-model="data.modelName">
|
|
||||||
</div>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
@ -7,12 +7,14 @@ import Computers from './components/Computers.vue'
|
|||||||
import Monitors from './components/Monitors.vue'
|
import Monitors from './components/Monitors.vue'
|
||||||
import Login from "./components/Login.vue";
|
import Login from "./components/Login.vue";
|
||||||
import Signup from "@/components/Signup.vue";
|
import Signup from "@/components/Signup.vue";
|
||||||
|
import Users from "@/components/Users.vue";
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{ path: '/', redirect: '/cabinets' },
|
{ path: '/', redirect: '/cabinets' },
|
||||||
{ path: '/cabinets', component: Cabinets, meta: { label: 'Кабинеты' } },
|
{ path: '/cabinets', component: Cabinets, meta: { label: 'Кабинеты' } },
|
||||||
{ path: '/computers', component: Computers, meta: { label: 'Компьютеры' } },
|
{ path: '/computers', component: Computers, meta: { label: 'Компьютеры' } },
|
||||||
{ path: '/monitors', component: Monitors, meta: { label: 'Мониторы' } },
|
{ path: '/monitors', component: Monitors, meta: { label: 'Мониторы' } },
|
||||||
|
{ path: '/users', component: Users, meta: { label: 'Пользователи' } },
|
||||||
{ path: '/login', component: Login},
|
{ path: '/login', component: Login},
|
||||||
{ path: '/signup', component: Signup}
|
{ path: '/signup', component: Signup}
|
||||||
]
|
]
|
||||||
|
21
frontend/src/models/User.js
Normal file
21
frontend/src/models/User.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
export default class Monitor {
|
||||||
|
constructor(data) {
|
||||||
|
this._id = data?.id;
|
||||||
|
this._login = data?.login;
|
||||||
|
}
|
||||||
|
|
||||||
|
get id() {
|
||||||
|
return this._id;
|
||||||
|
}
|
||||||
|
|
||||||
|
get login() {
|
||||||
|
return this._login;
|
||||||
|
}
|
||||||
|
|
||||||
|
set login(value) {
|
||||||
|
if (typeof value !== 'string' || value === null || value.length == 0) {
|
||||||
|
throw 'New model name value ' + value + ' is not a string or empty';
|
||||||
|
}
|
||||||
|
this._login = value;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.kalyshev.yan.user.controller;
|
package com.kalyshev.yan.user.controller;
|
||||||
|
|
||||||
|
import com.kalyshev.yan.configuration.OpenAPI30Configuration;
|
||||||
import com.kalyshev.yan.user.model.User;
|
import com.kalyshev.yan.user.model.User;
|
||||||
import com.kalyshev.yan.user.service.UserService;
|
import com.kalyshev.yan.user.service.UserService;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -17,7 +18,7 @@ public class UserController {
|
|||||||
public UserController(UserService userService) {
|
public UserController(UserService userService) {
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
}
|
}
|
||||||
@GetMapping(URL_LOGIN)
|
@GetMapping(OpenAPI30Configuration.API_PREFIX + "/user")
|
||||||
public List<UserDto> getUsers() {
|
public List<UserDto> getUsers() {
|
||||||
return userService.findAllUsers().stream()
|
return userService.findAllUsers().stream()
|
||||||
.map(UserDto::new)
|
.map(UserDto::new)
|
||||||
|
Loading…
Reference in New Issue
Block a user