Карточка на онлайн пользователя

This commit is contained in:
iriska-gri committed 2024-04-17 14:09:06 +03:00
1 parent 78e4eab353
commit 4471550f7d
6 files changed
+68 -63

No files matched your search

+2
View File
@@ -7,6 +7,8 @@ from rest_framework.response import Response
class CalendarEventsAPIView(APIView): class CalendarEventsAPIView(APIView):
def get(self, request): def get(self, request):
return Response('ku') return Response('ku')
def post(self, request): def post(self, request):
@@ -23,7 +23,7 @@
/> />
</div> </div>
<div class="text-caption font-weight-regular"> <div class="text-caption font-weight-regular">
({{nStaff}} человек в штате) ({{nStaff}} активных учетных записей)
</div> </div>
</v-toolbar> </v-toolbar>
</template> </template>
@@ -78,13 +78,13 @@ export default {
components: { VueCal }, components: { VueCal },
setup() { setup() {
const events = ref([ const events = ref([]);
]);
function f_generalvacation() { function f_generalvacation() {
// axiosApiInstance axiosApiInstance
// .get("api/general_vacation/generalvacation/") .get("api/calendar_of_events/calendarEvents/")
// .then((data) => { .then((data) => {
console.log(data, 'dataaaaaaaaaaaaa');
})
// for (let x in data.data) { // for (let x in data.data) {
// if (x == "План-график") { // if (x == "План-график") {
// data.data[x].map((e) => { // data.data[x].map((e) => {
@@ -52,7 +52,6 @@
<info-user-card <info-user-card
:author="author" :author="author"
:opendialog = open :opendialog = open
:loging="author.login"
@update:opendialog="open = $event" @update:opendialog="open = $event"
/> />
</div> </div>
@@ -1,86 +1,91 @@
<template> <template>
<div class="align-center d-flex flex-column py-1"> <div class="align-center d-flex flex-column py-1">
<v-btn variant="text" v-for="x in onlineuser" :key="x" height="50">
<v-avatar size="36px">
<v-btn <v-img :src="checkremote(`${spravURL}${x}.jpg`)" @click="whatuser(x)" />
variant="text"
v-for="x in onlineuser"
:key="x"
height="50"
>
<v-avatar
size="36px"
>
<v-img
:src="checkremote( `${spravURL}${x}.jpg`)"
@click="whatuser(x)"
/>
</v-avatar> </v-avatar>
</v-btn> </v-btn>
<info-user-card <info-user-card
:author="author"
:opendialog = open :opendialog="open"
:loging="loging"
@update:opendialog="open = $event" @update:opendialog="open = $event"
/> />
</div> </div>
</template> </template>
<script> <script>
import { ref,watch } from 'vue' import { ref, watch } from "vue";
import { baseWS } from '@/utils/axios-api' import { baseWS } from "@/utils/axios-api";
import {useAccountStore} from '@/store/AccountStore' import { useAccountStore } from "@/store/AccountStore";
import { spravURL } from '@/utils/axios-api' import { spravURL } from "@/utils/axios-api";
import {checkremote} from '@/utils/universal_functions' import { checkremote } from "@/utils/universal_functions";
import { axiosApiInstance } from "@/utils/axios-api";
export default { export default {
setup() { setup() {
const loging = ref('') const author = ref({});
const open = ref(false) const open = ref(false);
const wsfuncs={onliner:function(data){ const wsfuncs = {
let newset = new Set(data) onliner: function (data) {
let arr= Array.from(newset) let newset = new Set(data);
let arr = Array.from(newset);
arr.splice(arr.findIndex(e=> e == accountStore.user.login), 1) arr.splice(
onlineuser.value = arr arr.findIndex((e) => e == accountStore.user.login),
}} 1
const accountStore = useAccountStore() );
let onlineuser= ref([]) onlineuser.value = arr;
},
};
const accountStore = useAccountStore();
let onlineuser = ref([]);
const connect = new WebSocket(baseWS+"ws/watcher/?token="+localStorage.access) const connect = new WebSocket(
baseWS + "ws/watcher/?token=" + localStorage.access
);
const whatuser = (x) => { const whatuser = (x) => {
loging.value = x open.value = true;
open.value = true axiosApiInstance
} .get(`api/accounts/getuser/?userlogin=${x}`)
.then((data) => {
author.value = {
department: data.data.department,
fio: data.data.fio,
post: data.data.post,
email: data.data.email,
tel: data.data.tel,
room: data.data.room,
login: data.data.login,
};
});
};
connect.onmessage = (e) => { connect.onmessage = (e) => {
let data = JSON.parse(e.data) let data = JSON.parse(e.data);
wsfuncs[data['message']['action']](data.message.data) wsfuncs[data["message"]["action"]](data.message.data);
} };
watch(()=>accountStore.cod2user,function(){ watch(
() => accountStore.cod2user,
function () {
if (!accountStore.cod2user.value) { if (!accountStore.cod2user.value) {
connect.close() connect.close();
} }
}) }
);
return { return {
loging, author,
open, open,
onlineuser, onlineuser,
checkremote, checkremote,
spravURL, spravURL,
whatuser, whatuser,
accountStore accountStore,
} };
} },
};
}
</script> </script>
<style> <style></style>
</style>
@@ -11,7 +11,6 @@
<info-user-card <info-user-card
:author=author :author=author
:opendialog = open :opendialog = open
:loging="author.login"
@update:opendialog="open = $event" @update:opendialog="open = $event"
/> />
</div> </div>