move_users #5

Merged
vbuglov merged 4 commits from move_users into master 2024-04-03 09:28:15 +00:00
28 changed files with 145 additions and 184 deletions
Showing only changes of commit 2b2ad786b2 - Show all commits

View File

@ -42,6 +42,12 @@ prehook:
@chmod +x $(HOOK_PATH) @chmod +x $(HOOK_PATH)
@echo "Pre-push hook set successfully." @echo "Pre-push hook set successfully."
add:
ifeq ($(pack),)
$(error mn is not set)
endif
yarn add "../repo/${pack}/"
push: push:
ifeq ($(commit),) ifeq ($(commit),)
$(error mn is not set) $(error mn is not set)

View File

@ -15,6 +15,7 @@
"lint_fix": "yarn eslint './**/*.{js,vue}' --fix" "lint_fix": "yarn eslint './**/*.{js,vue}' --fix"
}, },
"dependencies": { "dependencies": {
"3-class-complex-assistants": "../repo/3-class-complex-assistants/",
"axios": "^1.6.7", "axios": "^1.6.7",
"flowbite": "^2.3.0", "flowbite": "^2.3.0",
"flowbite-vue": "^0.1.2", "flowbite-vue": "^0.1.2",

View File

@ -1,32 +1,45 @@
import {get, post, put, remove} from './apiHelpers.js' import {get, post, put, remove} from './apiHelpers.js'
import {convertList, convertObject} from '@helpers/adapter/adapter.js' import {convertList, convertObject} from '@helpers/adapter/adapter.js'
import {Logger} from '3-class-complex-assistants'
import moment from 'moment/moment.js'
const config = { const config = {
id: "id", id: "id",
created_at: "created_at", created_at: "createdAt",
updated_at: "updated_at", updated_at: "updatedAt",
deleted_at: "deleted_at", deleted_at: "deletedAt",
name: "name", name: "name",
port: "port", port: "port",
proxy_ip: "proxy_ip", proxy_ip: "proxyIp",
internet_uri: "internet_uri", internet_uri: "internetUri",
description: "description", description: "description",
is_online: "is_online", is_online: "isOnline",
site_ip: "device_ip", site_ip: "deviceIp",
} }
const configToServer = { const configToServer = {
id: "id", id: "id",
created_at: "created_at", createdAt: "created_at",
updated_at: "updated_at", updatedAt: "updated_at",
deleted_at: "deleted_at", deletedAt: "deleted_at",
name: "name", name: "name",
port: "port", port: "port",
proxy_ip: "proxy_ip", proxyIp: "proxy_ip",
internet_uri: "internet_uri", internetUri: "internet_uri",
description: "description", description: "description",
is_online: "is_online", isOnline: "is_online",
device_ip: "site_ip", deviceIp: "site_ip",
}
const loggerInfo = {
"loggerLevel": 1,
"serviceName": "users-manage",
"port": 5173,
"datetime": moment().format("YYYY-MM-DDTHH:mm:ss"),
}
const callbackError = (error) => {
return console.err(error)
} }
class Services { class Services {
@ -40,6 +53,7 @@ class Services {
this.apiAddr = apiAddr this.apiAddr = apiAddr
this.config = config this.config = config
this.configToServer = configToServer this.configToServer = configToServer
this.loggerConfig = {...loggerInfo, callFunc: callbackError, isPushToServer: true}
} }
/** /**
@ -59,13 +73,14 @@ class Services {
*/ */
async createService(payload) { async createService(payload) {
const logger = new Logger(this.loggerConfig)
let newService = [] let newService = []
const updatedPort = parseFloat(payload.port) const updatedPort = parseFloat(payload.port)
const updatedService = {...convertObject(payload, {config: this.configToServer}), port: updatedPort} const updatedService = {...convertObject(payload, {config: this.configToServer}), port: updatedPort}
await post(`${this.apiAddr}/servers`, updatedService).then(res => { await post(`${this.apiAddr}/servers`, updatedService).then(res => {
newService = convertObject(res.value, {config: this.config}) newService = convertObject(res.value, {config: this.config})
}).catch(err => { }).catch(err => {
console.log('err', err) logger.error(err)
}) })
return newService return newService
} }
@ -77,6 +92,7 @@ class Services {
*/ */
async updateService(payload) { async updateService(payload) {
const logger = new Logger(this.loggerConfig)
let resService = [] let resService = []
const updatedPort = parseFloat(payload.port) const updatedPort = parseFloat(payload.port)
const updatedService = {...convertObject(payload, {config: this.configToServer}), port: updatedPort} const updatedService = {...convertObject(payload, {config: this.configToServer}), port: updatedPort}
@ -84,7 +100,7 @@ class Services {
await put(`${this.apiAddr}/servers`, updatedService, payload.id).then(res => { await put(`${this.apiAddr}/servers`, updatedService, payload.id).then(res => {
resService = convertObject(res.value, {config: this.config}) resService = convertObject(res.value, {config: this.config})
}).catch(err => { }).catch(err => {
console.log('err', err) logger.error(err)
}) })
} }
return resService return resService
@ -97,11 +113,12 @@ class Services {
*/ */
async deleteService(id) { async deleteService(id) {
const logger = new Logger(this.loggerConfig)
let deletedServiceId = null let deletedServiceId = null
await remove(`${this.apiAddr}/servers`, id).then((res) => { await remove(`${this.apiAddr}/servers`, id).then((res) => {
deletedServiceId = res.id deletedServiceId = res.id
}).catch(err => { }).catch(err => {
console.log('err', err) logger.error(err)
}) })
return deletedServiceId return deletedServiceId
} }

View File

@ -8,7 +8,7 @@ import {devUsersList} from './StaticData.js'
* @param {Number} id * @param {Number} id
*/ */
const adapter_config = { const adapterConfig = {
id: "id", id: "id",
first_name: "firstName", first_name: "firstName",
last_name: "lastName", last_name: "lastName",
@ -17,7 +17,7 @@ const adapter_config = {
service_id: "serviceId", service_id: "serviceId",
} }
const server_config = { const serverConfig = {
id: "id", id: "id",
firstName: "first_name", firstName: "first_name",
lastName: "last_name", lastName: "last_name",
@ -35,8 +35,8 @@ class Users {
*/ */
constructor(apiAddr, params = {mode: 'prod'}) { constructor(apiAddr, params = {mode: 'prod'}) {
this.apiAddr = apiAddr this.apiAddr = apiAddr
this.config = adapter_config this.config = adapterConfig
this.server_config = server_config this.serverConfig = serverConfig
this.mode = params.mode this.mode = params.mode
} }
@ -76,7 +76,7 @@ class Users {
* @returns {Promise<Object>} * @returns {Promise<Object>}
*/ */
async createUser(userData) { async createUser(userData) {
const newUser = await post(`${this.apiAddr}/users`, convertObject(userData, {config: this.server_config})) const newUser = await post(`${this.apiAddr}/users`, convertObject(userData, {config: this.serverConfig}))
return convertObject(newUser, {config: this.config}) return convertObject(newUser, {config: this.config})
} }
@ -88,7 +88,7 @@ class Users {
async updateUser(userData) { async updateUser(userData) {
const updatedUserData = {...userData} const updatedUserData = {...userData}
delete updatedUserData.id delete updatedUserData.id
const newUser = await put(`${this.apiAddr}/users/${userData.id}`, convertObject(updatedUserData, {config: this.server_config})) const newUser = await put(`${this.apiAddr}/users/${userData.id}`, convertObject(updatedUserData, {config: this.serverConfig}))
return convertObject(newUser, {config: this.config}) return convertObject(newUser, {config: this.config})
} }

View File

@ -2,7 +2,6 @@
export default { export default {
name: 'VDoubleSwitch', name: 'VDoubleSwitch',
components: { components: {
// Button,
}, },
props: { props: {
machine: { machine: {

View File

@ -1,4 +1,3 @@
<!-- eslint-disable vue/prop-name-casing -->
<script> <script>
import {mapGetters} from 'vuex' import {mapGetters} from 'vuex'
import Input from '@atoms/VInput.vue' import Input from '@atoms/VInput.vue'
@ -51,11 +50,11 @@ export default {
secondColor="#2563eb" secondColor="#2563eb"
firstTitle="Офлайн" firstTitle="Офлайн"
secondTitle="Онлайн" secondTitle="Онлайн"
:isCheck="selectedService?.is_online" :isCheck="selectedService?.isOnline"
position="col" position="col"
labelClass="items-start pb-2" labelClass="items-start pb-2"
switchClass="switcher mt-1" switchClass="switcher mt-1"
@switched="(e) => editData({key: 'is_online', value: e})" @switched="(e) => editData({key: 'isOnline', value: e})"
/> />
</div> </div>
<Input <Input
@ -91,8 +90,8 @@ export default {
<span class="mr-2 min-w-[80px]">IP proxy:</span> <span class="mr-2 min-w-[80px]">IP proxy:</span>
<Input <Input
id="proxyIp" id="proxyIp"
name="proxy_ip" name="proxyIp"
:value="selectedService?.proxy_ip" :value="selectedService?.proxyIp"
inputClass="py-2" inputClass="py-2"
placeholder="IP proxy" placeholder="IP proxy"
:onChange="editData" :onChange="editData"
@ -102,8 +101,8 @@ export default {
<span class="mr-2 min-w-[80px]">IP устр-ва:</span> <span class="mr-2 min-w-[80px]">IP устр-ва:</span>
<Input <Input
id="deviceIp" id="deviceIp"
name="device_ip" name="deviceIp"
:value="selectedService?.device_ip" :value="selectedService?.deviceIp"
inputClass="py-2" inputClass="py-2"
placeholder="IP устройства" placeholder="IP устройства"
:onChange="editData" :onChange="editData"

View File

@ -35,11 +35,11 @@ export default {
default: "", default: "",
type: String type: String
}, },
device_ip: { deviceIp: {
default: "", default: "",
type: String type: String
}, },
proxy_ip: { proxyIp: {
default: "", default: "",
type: String type: String
}, },
@ -68,13 +68,11 @@ export default {
}, },
watch: { watch: {
isSaveData: function (newVal) { isSaveData: function (newVal) {
// console.log('newVal', newVal)
if (newVal) { if (newVal) {
this.saveServiceData() this.saveServiceData()
} }
}, },
isOnline: function (newVal) { isOnline: function (newVal) {
// console.log('newVal', newVal)
this.status = this.setStatus(newVal) this.status = this.setStatus(newVal)
} }
}, },
@ -92,14 +90,13 @@ export default {
const data = { const data = {
name: this.selectedService.name, name: this.selectedService.name,
port: this.selectedService.port, port: this.selectedService.port,
device_ip: this.selectedService.device_ip, deviceIp: this.selectedService.deviceIp,
proxy_ip: this.selectedService.proxy_ip, proxyIp: this.selectedService.proxyIp,
description: this.selectedService.description, description: this.selectedService.description,
is_online: this.selectedService.is_online, isOnline: this.selectedService.isOnline,
} }
this.serviceOfServices.createNewService(data) this.serviceOfServices.createNewService(data)
} else { } else {
// this.updateRoutesWithApi(this.selectedService)
this.serviceOfServices.saveService(this.selectedService) this.serviceOfServices.saveService(this.selectedService)
} }
}, },
@ -168,10 +165,10 @@ export default {
</span> </span>
</div> </div>
<p class=" font-normal text-sm text-gray-700 dark:text-gray-400 mb-2 flex"> <p class=" font-normal text-sm text-gray-700 dark:text-gray-400 mb-2 flex">
<span class="min-w-[80px] font-w-700 inline-block flex"> IP proxy:</span> {{ proxy_ip }} <span class="min-w-[80px] font-w-700 inline-block flex"> IP proxy:</span> {{ proxyIp }}
</p> </p>
<p class=" font-normal text-sm text-gray-700 dark:text-gray-400 mb-2 flex"> <p class=" font-normal text-sm text-gray-700 dark:text-gray-400 mb-2 flex">
<span class="min-w-[80px] font-w-700 inline-block flex"> IP устр-ва:</span> {{ device_ip }} <span class="min-w-[80px] font-w-700 inline-block flex"> IP устр-ва:</span> {{ deviceIp }}
</p> </p>
<p class=" font-normal text-sm text-gray-700 dark:text-gray-400 mb-2 flex "> <p class=" font-normal text-sm text-gray-700 dark:text-gray-400 mb-2 flex ">
<span class="min-w-[80px] font-w-700 inline-block flex"> Описание:</span> <span <span class="min-w-[80px] font-w-700 inline-block flex"> Описание:</span> <span

View File

@ -57,9 +57,9 @@ export default {
:service="service" :service="service"
:name="service.name" :name="service.name"
:port="`${service.port}`" :port="`${service.port}`"
:device_ip="service.device_ip" :deviceIp="service.deviceIp"
:proxy_ip="service.proxy_ip" :proxyIp="service.proxyIp"
:isOnline="service.is_online" :isOnline="service.isOnline"
:description="service.description" :description="service.description"
/> />
</div> </div>

View File

@ -51,7 +51,6 @@ export default {
this.serviceOfUsers.editUserByService(params) this.serviceOfUsers.editUserByService(params)
}, },
saveUser() { saveUser() {
// console.log('Save user')
this.errorPassword = isRepeatPasswordEmpty(this.selectedUser.password, this.repeatPassword) this.errorPassword = isRepeatPasswordEmpty(this.selectedUser.password, this.repeatPassword)
if (this.errorPassword) return if (this.errorPassword) return
this.serviceOfUsers.saveUpdatedDataUser(this.selectedService.id) this.serviceOfUsers.saveUpdatedDataUser(this.selectedService.id)

View File

@ -33,7 +33,6 @@ export default {
}, },
watch: { watch: {
selectedService: function (newValue, oldValue) { selectedService: function (newValue, oldValue) {
console.log('newValue.id', newValue.id)
if (newValue.id !== oldValue.id) { if (newValue.id !== oldValue.id) {
this.serviceOfUsers.setStatusUser('inactive') this.serviceOfUsers.setStatusUser('inactive')
} }

View File

@ -6,7 +6,6 @@ const generatePassword = () => {
const randomNumber = Math.floor(Math.random() * chars.length) const randomNumber = Math.floor(Math.random() * chars.length)
pass += chars.substring(randomNumber, randomNumber + 1) pass += chars.substring(randomNumber, randomNumber + 1)
} }
// console.log('pass', pass)
return pass return pass
} }

View File

@ -49,7 +49,6 @@ class ServiceOfServices {
async editSelectedService(params) { async editSelectedService(params) {
const selectedService = this.store.getters['services/selectedService'] const selectedService = this.store.getters['services/selectedService']
// console.log('selectedService', selectedService)
selectedService[params.key] = params.value selectedService[params.key] = params.value
this.store.dispatch('services/editSelectedService', selectedService) this.store.dispatch('services/editSelectedService', selectedService)
} }
@ -65,7 +64,6 @@ class ServiceOfServices {
const editedService = await this.adapterOfServices.updateService(updateService) const editedService = await this.adapterOfServices.updateService(updateService)
const services = this.store.getters['services/services'] const services = this.store.getters['services/services']
const updatedServices = !isEmpty(editedService) ? updatedService(editedService, services) : services const updatedServices = !isEmpty(editedService) ? updatedService(editedService, services) : services
// console.log('updatedServices', updatedServices)
this.store.dispatch('services/saveService', updatedServices) this.store.dispatch('services/saveService', updatedServices)
return editedService return editedService
} }

View File

@ -13,7 +13,6 @@ class UsersOfServices {
*/ */
async getUsers(mode) { async getUsers(mode) {
const users = await this.adapter.getUsers({mode}) const users = await this.adapter.getUsers({mode})
// await this.saveSiteUsers(users)
this.store.dispatch('users/updateUsers', users) this.store.dispatch('users/updateUsers', users)
return users return users
} }
@ -28,7 +27,6 @@ class UsersOfServices {
const users = await this.adapter.getUsers({mode}) const users = await this.adapter.getUsers({mode})
const usersWithService = await this.adapter.getUsersByServiceId(serviceId, mode) const usersWithService = await this.adapter.getUsersByServiceId(serviceId, mode)
const usersWithoutService = usersWithoutThisService(serviceId, users) const usersWithoutService = usersWithoutThisService(serviceId, users)
// await this.saveSiteUsers(users)
this.store.dispatch('users/updateUsers', users) this.store.dispatch('users/updateUsers', users)
this.store.dispatch('users/updateUsersWithService', usersWithService) this.store.dispatch('users/updateUsersWithService', usersWithService)
this.store.dispatch('users/updateUsersWithoutService', usersWithoutService) this.store.dispatch('users/updateUsersWithoutService', usersWithoutService)
@ -43,8 +41,6 @@ class UsersOfServices {
async getUsersWithoutService(serviceId) { async getUsersWithoutService(serviceId) {
const users = this.store.getters['users/users'] const users = this.store.getters['users/users']
const filteredUsers = usersWithoutThisService(serviceId, users) const filteredUsers = usersWithoutThisService(serviceId, users)
// await this.saveSiteUsers(users)
// console.log('filteredUsers', filteredUsers)
this.store.dispatch('users/updateUsersWithoutService', filteredUsers) this.store.dispatch('users/updateUsersWithoutService', filteredUsers)
return filteredUsers return filteredUsers
} }
@ -55,10 +51,7 @@ class UsersOfServices {
* @returns {Promise<Object>} * @returns {Promise<Object>}
*/ */
async createNewUser() { async createNewUser() {
// const createdUser = await this.adapter.createUser(userData)
const newUser = {id: -1, firstName: '',lastName: '', role: '', email: '', password: '', serviceId: []} const newUser = {id: -1, firstName: '',lastName: '', role: '', email: '', password: '', serviceId: []}
// const users = this.store.getters['users/users']
// const updatedUsers = addedUser(newUser, users)
this.store.dispatch('users/updateSelectedUser', newUser) this.store.dispatch('users/updateSelectedUser', newUser)
return newUser return newUser
} }
@ -118,7 +111,6 @@ class UsersOfServices {
*/ */
async editUserByService(params) { async editUserByService(params) {
const selectedUser = this.store.getters['users/selectedUser'] const selectedUser = this.store.getters['users/selectedUser']
// console.log('selectedService', selectedService)
if (selectedUser) { if (selectedUser) {
selectedUser[params.key] = params.value selectedUser[params.key] = params.value
this.store.dispatch('users/updateSelectedUser', selectedUser) this.store.dispatch('users/updateSelectedUser', selectedUser)
@ -150,7 +142,6 @@ class UsersOfServices {
* @returns {Promise<Object>} * @returns {Promise<Object>}
*/ */
async saveUpdatedDataUser(serviceId) { async saveUpdatedDataUser(serviceId) {
// console.log('serviceId', serviceId)
const selectedUser = this.store.getters['users/selectedUser'] const selectedUser = this.store.getters['users/selectedUser']
// const userStatus = this.store.getters['users/userStatus'] // const userStatus = this.store.getters['users/userStatus']
if (selectedUser && selectedUser.id) { if (selectedUser && selectedUser.id) {
@ -171,7 +162,6 @@ class UsersOfServices {
// return createdUser // return createdUser
} }
if (selectedUser.id !== -1) { if (selectedUser.id !== -1) {
// console.log('selectedUser', selectedUser)
// const updatedUser = await this.adapter.updateUser(selectedUser) // Запрос на обновление пользователя с новыми данными // const updatedUser = await this.adapter.updateUser(selectedUser) // Запрос на обновление пользователя с новыми данными
const users = this.store.getters['users/usersWithService'] const users = this.store.getters['users/usersWithService']
const updatedUsers = updatedUser(selectedUser, users) const updatedUsers = updatedUser(selectedUser, users)

View File

@ -8,7 +8,6 @@ const getUserById = (id, users) => {
} }
const usersWithThisService = (serviceId, users) => { const usersWithThisService = (serviceId, users) => {
// console.log('serviceId', serviceId)
return users.filter((user) => user.serviceId.includes(serviceId)) return users.filter((user) => user.serviceId.includes(serviceId))
} }

View File

@ -1,6 +1,4 @@
import routeOptions from './routeOptions.json' import routeOptions from './routeOptions.json'
// import Services from '@helpers/Services/Services.js';
// import {config} from './StaticData.js'
import {isEmpty} from "ramda"; import {isEmpty} from "ramda";
const initState = { const initState = {
@ -65,7 +63,6 @@ const actions = {
saveServices: async ({commit}, services) => { saveServices: async ({commit}, services) => {
commit('setServices', services) commit('setServices', services)
commit('setServicesState', 'active') commit('setServicesState', 'active')
// console.log('services', services)
}, },
saveService: async ({commit}, updatedServices) => { saveService: async ({commit}, updatedServices) => {

View File

@ -1,8 +1,3 @@
// import Users from '@helpers/Users/Users.js';
// const path = import.meta.env.VITE_API_ADDR
// const UsersService = new Users(path)
const initState = { const initState = {
userStatus: 'inactive', userStatus: 'inactive',
@ -38,7 +33,6 @@ const mutations = {
const actions = { const actions = {
updateUsers: async ({commit}, users) => { updateUsers: async ({commit}, users) => {
commit('setUsers', users) commit('setUsers', users)
// console.log('users', users)
}, },
updateUserStatus: async ({commit}, userStatus) => { updateUserStatus: async ({commit}, userStatus) => {
commit('setUserStatus', userStatus) commit('setUserStatus', userStatus)

View File

@ -51,10 +51,8 @@ class UsersInService {
is_online: selectedService.is_online, is_online: selectedService.is_online,
} }
const newService = await this.serviceOfServices.createNewService(data) const newService = await this.serviceOfServices.createNewService(data)
console.log('newService', newService)
this.serviceOfUsers.saveUpdatedDataUser(newService.id) this.serviceOfUsers.saveUpdatedDataUser(newService.id)
} else { } else {
// this.updateRoutesWithApi(this.selectedService)
this.serviceOfServices.saveService(selectedService) this.serviceOfServices.saveService(selectedService)
this.serviceOfUsers.saveUpdatedDataUser(selectedService.id) this.serviceOfUsers.saveUpdatedDataUser(selectedService.id)
} }

View File

@ -53,42 +53,42 @@ const defaultServices = [
const resServices = [ const resServices = [
{ {
"id": 1, "id": 1,
"created_at": "2024-03-06T17:31:31.948355541+03:00", "createdAt": "2024-03-06T17:31:31.948355541+03:00",
"updated_at": "2024-03-06T17:31:31.948355541+03:00", "updatedAt": "2024-03-06T17:31:31.948355541+03:00",
"deleted_at": null, "deletedAt": null,
"name": "jsonplaceholder.typicode.com", "name": "jsonplaceholder.typicode.com",
"port": 9965, "port": 9965,
"proxy_ip": "172.25.78.153", "proxyIp": "172.25.78.153",
"device_ip": "https://jsonplaceholder.typicode.com/", "deviceIp": "https://jsonplaceholder.typicode.com/",
"internet_uri": "localhost", "internetUri": "localhost",
"description": "localhost", "description": "localhost",
"is_online": true "isOnline": true
}, },
{ {
"id": 2, "id": 2,
"created_at": "2024-03-07T11:43:51.026265459+03:00", "createdAt": "2024-03-07T11:43:51.026265459+03:00",
"updated_at": "2024-03-07T13:35:12.506368972+03:00", "updatedAt": "2024-03-07T13:35:12.506368972+03:00",
"deleted_at": null, "deletedAt": null,
"name": "new 2", "name": "new 2",
"port": 4548, "port": 4548,
"proxy_ip": "172.25.78.151", "proxyIp": "172.25.78.151",
"device_ip": "172.25.78.151", "deviceIp": "172.25.78.151",
"internet_uri": "", "internetUri": "",
"description": "new site 2", "description": "new site 2",
"is_online": true "isOnline": true
}, },
{ {
"id": 3, "id": 3,
"created_at": "2024-03-07T11:43:51.027148541+03:00", "createdAt": "2024-03-07T11:43:51.027148541+03:00",
"updated_at": "2024-03-07T13:35:24.919273428+03:00", "updatedAt": "2024-03-07T13:35:24.919273428+03:00",
"deleted_at": null, "deletedAt": null,
"name": "new 3", "name": "new 3",
"port": 2527, "port": 2527,
"proxy_ip": "172.25.78.151", "proxyIp": "172.25.78.151",
"device_ip": "172.25.78.151", "deviceIp": "172.25.78.151",
"internet_uri": "", "internetUri": "",
"description": "new site 3...", "description": "new site 3...",
"is_online": true "isOnline": true
} }
] ]

View File

@ -53,42 +53,42 @@ const defaultServices = [
const resServices = [ const resServices = [
{ {
"id": 1, "id": 1,
"created_at": "2024-03-06T17:31:31.948355541+03:00", "createdAt": "2024-03-06T17:31:31.948355541+03:00",
"updated_at": "2024-03-06T17:31:31.948355541+03:00", "updatedAt": "2024-03-06T17:31:31.948355541+03:00",
"deleted_at": null, "deletedAt": null,
"name": "jsonplaceholder.typicode.com", "name": "jsonplaceholder.typicode.com",
"port": 9965, "port": 9965,
"proxy_ip": "172.25.78.153", "proxyIp": "172.25.78.153",
"device_ip": "https://jsonplaceholder.typicode.com/", "deviceIp": "https://jsonplaceholder.typicode.com/",
"internet_uri": "localhost", "internetUri": "localhost",
"description": "localhost", "description": "localhost",
"is_online": true "isOnline": true
}, },
{ {
"id": 2, "id": 2,
"created_at": "2024-03-07T11:43:51.026265459+03:00", "createdAt": "2024-03-07T11:43:51.026265459+03:00",
"updated_at": "2024-03-07T13:35:12.506368972+03:00", "updatedAt": "2024-03-07T13:35:12.506368972+03:00",
"deleted_at": null, "deletedAt": null,
"name": "new 2", "name": "new 2",
"port": 4548, "port": 4548,
"proxy_ip": "172.25.78.151", "proxyIp": "172.25.78.151",
"device_ip": "172.25.78.151", "deviceIp": "172.25.78.151",
"internet_uri": "", "internetUri": "",
"description": "new site 2", "description": "new site 2",
"is_online": true "isOnline": true
}, },
{ {
"id": 3, "id": 3,
"created_at": "2024-03-07T11:43:51.027148541+03:00", "createdAt": "2024-03-07T11:43:51.027148541+03:00",
"updated_at": "2024-03-07T13:35:24.919273428+03:00", "updatedAt": "2024-03-07T13:35:24.919273428+03:00",
"deleted_at": null, "deletedAt": null,
"name": "new 3", "name": "new 3",
"port": 2527, "port": 2527,
"proxy_ip": "172.25.78.151", "proxyIp": "172.25.78.151",
"device_ip": "172.25.78.151", "deviceIp": "172.25.78.151",
"internet_uri": "", "internetUri": "",
"description": "new site 3...", "description": "new site 3...",
"is_online": true "isOnline": true
} }
] ]
@ -393,8 +393,6 @@ describe("tests services store with vuex", () => {
const resetSelectedService = store.getters['services/selectedService'] const resetSelectedService = store.getters['services/selectedService']
const resetServices = store.getters['services/services'] const resetServices = store.getters['services/services']
// console.log('Reset store 11 test', resetSelectedService)
expect(resetSelectedService).toBe(null) // After reset store expect(resetSelectedService).toBe(null) // After reset store
expect(resetServices).toStrictEqual([]) // After reset store expect(resetServices).toStrictEqual([]) // After reset store

View File

@ -169,8 +169,6 @@ describe("tests users store with vuex", () => {
const usersWithServices = store.getters['users/usersWithService'] const usersWithServices = store.getters['users/usersWithService']
// console.log('usersWithServices', usersWithServices)
const userAddedService = usersWithServices.find(user => user.id === 5) const userAddedService = usersWithServices.find(user => user.id === 5)
expect(userAddedService).toBeDefined() expect(userAddedService).toBeDefined()
@ -280,8 +278,6 @@ describe("tests users store with vuex", () => {
const usersWithService = store.getters['users/usersWithService'] const usersWithService = store.getters['users/usersWithService']
const userAfterUpdating = usersWithService.find(user => user.id === 3) const userAfterUpdating = usersWithService.find(user => user.id === 3)
// console.log('userAfterUpdating', userAfterUpdating)
expect(userAfterUpdating).toBeDefined() expect(userAfterUpdating).toBeDefined()
expect(userAfterUpdating.id).toEqual(3) expect(userAfterUpdating.id).toEqual(3)
@ -320,8 +316,6 @@ describe("tests users store with vuex", () => {
const resetUsers = store.getters['users/users'] const resetUsers = store.getters['users/users']
const resetUserStatus = store.getters['users/userStatus'] const resetUserStatus = store.getters['users/userStatus']
// console.log('Reset store 11 test', resetSelectedService)
expect(resetSelectedUser).toBe(null) // After reset store expect(resetSelectedUser).toBe(null) // After reset store
expect(resetUsers).toStrictEqual([]) // After reset store expect(resetUsers).toStrictEqual([]) // After reset store
expect(resetUserStatus).toEqual('inactive') // After reset store expect(resetUserStatus).toEqual('inactive') // After reset store

View File

@ -15,10 +15,4 @@ describe('tests for caseOfUsersInService', () => {
test('init', () => { test('init', () => {
expect(caseOfUsersInService).toBeDefined() expect(caseOfUsersInService).toBeDefined()
}) })
// test('fetchUsersWithoutService', async () => {
// await caseOfUsersInService.fetchUsersWithoutService()
// const storeUsers = store.getters['users/usersWithoutSite']
// expect(storeUsers).toEqual([appUser])
// })
}) })

View File

@ -70,7 +70,6 @@ describe("tests EditServiceCard component", () => {
const selectedService = store.getters['services/selectedService'] const selectedService = store.getters['services/selectedService']
const wrapper = mount(EditServiceCard, { const wrapper = mount(EditServiceCard, {
// shallow: true,
global: { global: {
plugins: [store] plugins: [store]
}, },

View File

@ -42,16 +42,16 @@ describe("tests Service Card component", () => {
const resServices = [ const resServices = [
{ {
"id": 1, "id": 1,
"created_at": "2024-03-06T17:31:31.948355541+03:00", "createdAt": "2024-03-06T17:31:31.948355541+03:00",
"updated_at": "2024-03-06T17:31:31.948355541+03:00", "updatedAt": "2024-03-06T17:31:31.948355541+03:00",
"deleted_at": null, "deletedAt": null,
"name": "jsonplaceholder.typicode.com", "name": "jsonplaceholder.typicode.com",
"port": 9965, "port": 9965,
"proxy_ip": "172.25.78.153", "proxyIp": "172.25.78.153",
"device_ip": "https://jsonplaceholder.typicode.com/", "deviceIp": "https://jsonplaceholder.typicode.com/",
"internet_uri": "localhost", "internetUri": "localhost",
"description": "localhost", "description": "localhost",
"is_online": true "isOnline": true
}, },
] ]
@ -75,7 +75,6 @@ describe("tests Service Card component", () => {
test('Service Card mounted with vuex', async () => { test('Service Card mounted with vuex', async () => {
const wrapper = mount(ServiceCard, { const wrapper = mount(ServiceCard, {
// shallow: true,
global: { global: {
plugins: [store] plugins: [store]
}, },
@ -85,8 +84,6 @@ describe("tests Service Card component", () => {
}, },
}) })
// console.log('wrapper.html', wrapper.html())
await serviceOfServices.fetchServices() await serviceOfServices.fetchServices()
store.commit('services/setServicesState', 'active') store.commit('services/setServicesState', 'active')
@ -177,8 +174,6 @@ describe("tests Service Card component", () => {
}, },
}) })
// console.log('wrapper.html', wrapper.html())
await wrapper.get('[test-id="canelButton"]').trigger('click') await wrapper.get('[test-id="canelButton"]').trigger('click')
expect(wrapper.html()).not.toContain('Отменить') expect(wrapper.html()).not.toContain('Отменить')
@ -202,8 +197,6 @@ describe("tests Service Card component", () => {
}, },
}) })
// console.log('wrapper.html', wrapper.vm.status)
const defaultStatus = wrapper.vm.status const defaultStatus = wrapper.vm.status
expect(defaultStatus.title).toContain('disable') expect(defaultStatus.title).toContain('disable')
@ -281,19 +274,14 @@ describe("tests Service Card component", () => {
}, },
}) })
// console.log('wrapper.html', wrapper.html())
const defaultIsDelete = wrapper.vm.isDelete const defaultIsDelete = wrapper.vm.isDelete
expect(defaultIsDelete).toBe(false) expect(defaultIsDelete).toBe(false)
await wrapper.get('.ri-close-line').trigger('click') // Рендер отрисовывает только с помощью триггером await wrapper.get('.ri-close-line').trigger('click') // Рендер отрисовывает только с помощью триггером
// wrapper.vm.deleteService(true)
const updatedIsDelete = wrapper.vm.isDelete const updatedIsDelete = wrapper.vm.isDelete
// console.log('wrapper.html', wrapper.html())
expect(updatedIsDelete).toBe(true) expect(updatedIsDelete).toBe(true)
expect(wrapper.html()).toContain('Отменить') expect(wrapper.html()).toContain('Отменить')

View File

@ -69,42 +69,42 @@ describe("tests Services List component", () => {
const resServices = [ const resServices = [
{ {
"id": 1, "id": 1,
"created_at": "2024-03-06T17:31:31.948355541+03:00", "createdAt": "2024-03-06T17:31:31.948355541+03:00",
"updated_at": "2024-03-06T17:31:31.948355541+03:00", "updatedAt": "2024-03-06T17:31:31.948355541+03:00",
"deleted_at": null, "deletedAt": null,
"name": "jsonplaceholder.typicode.com", "name": "jsonplaceholder.typicode.com",
"port": 9965, "port": 9965,
"proxy_ip": "172.25.78.153", "proxyIp": "172.25.78.153",
"device_ip": "https://jsonplaceholder.typicode.com/", "deviceIp": "https://jsonplaceholder.typicode.com/",
"internet_uri": "localhost", "internetUri": "localhost",
"description": "localhost", "description": "localhost",
"is_online": true "isOnline": true
}, },
{ {
"id": 2, "id": 2,
"created_at": "2024-03-07T11:43:51.026265459+03:00", "createdAt": "2024-03-07T11:43:51.026265459+03:00",
"updated_at": "2024-03-07T13:35:12.506368972+03:00", "updatedAt": "2024-03-07T13:35:12.506368972+03:00",
"deleted_at": null, "deletedAt": null,
"name": "new 2", "name": "new 2",
"port": 4548, "port": 4548,
"proxy_ip": "172.25.78.151", "proxyIp": "172.25.78.151",
"device_ip": "172.25.78.151", "deviceIp": "172.25.78.151",
"internet_uri": "", "internetUri": "",
"description": "new site 2", "description": "new site 2",
"is_online": true "isOnline": true
}, },
{ {
"id": 3, "id": 3,
"created_at": "2024-03-07T11:43:51.027148541+03:00", "createdAt": "2024-03-07T11:43:51.027148541+03:00",
"updated_at": "2024-03-07T13:35:24.919273428+03:00", "updatedAt": "2024-03-07T13:35:24.919273428+03:00",
"deleted_at": null, "deletedAt": null,
"name": "new 3", "name": "new 3",
"port": 2527, "port": 2527,
"proxy_ip": "172.25.78.151", "proxyIp": "172.25.78.151",
"device_ip": "172.25.78.151", "deviceIp": "172.25.78.151",
"internet_uri": "", "internetUri": "",
"description": "new site 3...", "description": "new site 3...",
"is_online": true "isOnline": true
} }
] ]
@ -123,7 +123,6 @@ describe("tests Services List component", () => {
test('Services List mounted with vuex', async () => { test('Services List mounted with vuex', async () => {
const wrapper = mount(ServicesList, { const wrapper = mount(ServicesList, {
// shallow: true,
global: { global: {
plugins: [store] plugins: [store]
}, },
@ -137,8 +136,6 @@ describe("tests Services List component", () => {
}, },
}) })
// console.log('wrapper.vm', wrapper.vm)
await serviceOfServices.fetchServices() await serviceOfServices.fetchServices()
const uploadServices = store.getters['services/services'] const uploadServices = store.getters['services/services']

View File

@ -20,7 +20,6 @@ const users = {
state.notIncludedSiteUsersList = [] state.notIncludedSiteUsersList = []
}, },
saveUsersOffSite({commit}, users) { saveUsersOffSite({commit}, users) {
console.log(users)
commit('setUsersOffSite', users) commit('setUsersOffSite', users)
} }
}, },

View File

@ -285,7 +285,7 @@ describe("tests UserEditor component", () => {
}) })
// await wrapper.setData({ showNewPassword: true }) // await wrapper.setData({ showNewPassword: true })
// console.log('passwordField', passwordField.attributes().type) // expect(passwordField.attributes().type).toBe(true)
wrapper.vm.togglePass() wrapper.vm.togglePass()

View File

@ -39,16 +39,16 @@ describe("tests Services Manager Page component", () => {
const resServices = [ const resServices = [
{ {
"id": 1, "id": 1,
"created_at": "2024-03-06T17:31:31.948355541+03:00", "createdAt": "2024-03-06T17:31:31.948355541+03:00",
"updated_at": "2024-03-06T17:31:31.948355541+03:00", "updatedAt": "2024-03-06T17:31:31.948355541+03:00",
"deleted_at": null, "deletedAt": null,
"name": "jsonplaceholder.typicode.com", "name": "jsonplaceholder.typicode.com",
"port": 9965, "port": 9965,
"proxy_ip": "172.25.78.153", "proxyIp": "172.25.78.153",
"device_ip": "https://jsonplaceholder.typicode.com/", "deviceIp": "https://jsonplaceholder.typicode.com/",
"internet_uri": "localhost", "internetUri": "localhost",
"description": "localhost", "description": "localhost",
"is_online": true "isOnline": true
}, },
] ]
@ -61,14 +61,11 @@ describe("tests Services Manager Page component", () => {
test('Services Manager Page mounted with vuex', async () => { test('Services Manager Page mounted with vuex', async () => {
const wrapper = mount(Services, { const wrapper = mount(Services, {
// shallow: true,
global: { global: {
plugins: [store] plugins: [store]
} }
}) })
// console.log('wrapper.vm', wrapper.vm)
await serviceOfServices.fetchServices() await serviceOfServices.fetchServices()
const uploadServices = store.getters['services/services'] const uploadServices = store.getters['services/services']

View File

@ -2,6 +2,9 @@
# yarn lockfile v1 # yarn lockfile v1
"3-class-complex-assistants@../repo/3-class-complex-assistants/":
version "0.0.6"
"@aashutoshrathi/word-wrap@^1.2.3": "@aashutoshrathi/word-wrap@^1.2.3":
version "1.2.6" version "1.2.6"
resolved "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf" resolved "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf"