final
This commit is contained in:
parent
6bac297408
commit
ae9b93a13e
@ -21,7 +21,7 @@ data class UserDto(
|
||||
@SerialName("lastEnter")
|
||||
val lastEntry : String? = null,
|
||||
@SerialName("access")
|
||||
val access : String,
|
||||
val access : Boolean,
|
||||
@SerialName("authorities")
|
||||
val authorities : String
|
||||
) {
|
||||
|
@ -19,6 +19,7 @@ class UserRepoImpl (
|
||||
login = login,
|
||||
position = dto.position,
|
||||
lastEntry = dto.lastEntry ?: "",
|
||||
access = dto.access
|
||||
)
|
||||
|
||||
}
|
||||
|
@ -4,11 +4,12 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class UserEntity(
|
||||
val id : Long,
|
||||
var login: String,
|
||||
var name: String,
|
||||
var avatarUrl: String?,
|
||||
val login: String,
|
||||
val name: String,
|
||||
val avatarUrl: String?,
|
||||
val position : String,
|
||||
var lastEntry : String?,
|
||||
val lastEntry : String?,
|
||||
val access : Boolean,
|
||||
val authorities : String
|
||||
|
||||
)
|
||||
|
@ -3,11 +3,14 @@ package ru.myitschool.work.ui.admin
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.squareup.picasso.Picasso
|
||||
import kotlinx.coroutines.launch
|
||||
import ru.myitschool.work.R
|
||||
import ru.myitschool.work.databinding.FragmentAdminBinding
|
||||
import ru.myitschool.work.databinding.FragmentProfileBinding
|
||||
@ -33,17 +36,34 @@ class AdminFragment : Fragment(R.layout.fragment_admin) {
|
||||
viewModel.search(login)
|
||||
}
|
||||
|
||||
viewBinding.switchMaterial.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (isChecked) {
|
||||
viewModel.viewModelScope.launch {
|
||||
viewModel.unblockUser()
|
||||
viewBinding.switchMaterial.text = "Доступ запрещен"
|
||||
}
|
||||
} else {
|
||||
viewModel.viewModelScope.launch {
|
||||
viewModel.blockUser()
|
||||
viewBinding.switchMaterial.text = "Доступ разрешен"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
viewModel.state.collectWithLifecycle(this) { state ->
|
||||
|
||||
viewBinding.error.visibility = if (state is AdminViewModel.State.Error) View.VISIBLE else View.GONE
|
||||
viewBinding.switchMaterial.visibility = if (state is AdminViewModel.State.Show) View.VISIBLE else View.GONE
|
||||
|
||||
|
||||
when(state) {
|
||||
is AdminViewModel.State.Loading -> Unit
|
||||
is AdminViewModel.State.Show -> {
|
||||
viewBinding.noData.visibility = View.GONE
|
||||
viewBinding.name.text = "Должность: ${state.profileInfo.position}"
|
||||
viewBinding.name.text = "${state.profileInfo.name}"
|
||||
viewBinding.position.text = "Должность: ${state.profileInfo.position}"
|
||||
if (state.profileInfo.lastEntry == null) viewBinding.lastEntry.text = "Время последнего входа: Нет данных"
|
||||
else viewBinding.lastEntry.text = "Время последнего входа: ${state.profileInfo.lastEntry}"
|
||||
Picasso.get().load(state.profileInfo.avatarUrl).resize(100, 100).centerCrop().into(viewBinding.imageView)
|
||||
|
@ -42,8 +42,9 @@ class AdminViewModel(
|
||||
getUserUseCase.invoke(login).fold(
|
||||
onSuccess = { data ->
|
||||
Log.d("uraa", "успех успех ${data.toString()}")
|
||||
if (data.access == true) State.Show(data, entranceList, true)
|
||||
else State.Show(data, entranceList, false)
|
||||
|
||||
State.Show(data, entranceList)
|
||||
},
|
||||
onFailure = { error ->
|
||||
Log.d("kaput", error.message.toString())
|
||||
@ -115,7 +116,8 @@ class AdminViewModel(
|
||||
data object Loading: State
|
||||
data class Show(
|
||||
val profileInfo : UserEntity,
|
||||
val entrancesList : List<EntranceEntity>
|
||||
val entrancesList : List<EntranceEntity>,
|
||||
val flag : Boolean
|
||||
) : State
|
||||
data class Error(
|
||||
val text: String
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.sicampus.bootcamp2025.ui.centerList
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
@ -34,7 +35,7 @@ class EntranceAdapter(
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(item : EntranceEntity) {
|
||||
binding.time.text = item.enteredAt
|
||||
binding.time.text = item.enterType
|
||||
binding.type.text = item.enterType
|
||||
binding.entry.text = item.name
|
||||
}
|
||||
}
|
||||
|
@ -134,13 +134,6 @@
|
||||
android:gravity="center"
|
||||
tools:text="Ошибка помогите" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/refresh"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/ic_refresh"
|
||||
android:gravity="center" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
@ -242,6 +235,7 @@
|
||||
app:layout_constraintVertical_bias="1.0" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
@ -314,11 +308,24 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/view2" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/switchMaterial"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="@string/access_right"
|
||||
android:textColor="@color/black"
|
||||
android:textOff="@string/access_wrong"
|
||||
android:textOn="@string/access_right"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textView4"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.497"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/lastEntry"
|
||||
app:layout_constraintVertical_bias="0.634"
|
||||
app:thumbTint="@color/white"
|
||||
app:trackTint="@color/orange" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
|
23
app/src/main/res/values-en/strings.xml
Normal file
23
app/src/main/res/values-en/strings.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">NTO Pass</string>
|
||||
<string name="authorization">Authorization</string>
|
||||
<string name="login">Login</string>
|
||||
<string name="password">Password</string>
|
||||
<string name="password_hint">Password must contain at least 8 characters</string>
|
||||
<string name="sign_in">Sign in</string>
|
||||
<string name="error_valid">Validation Error</string>
|
||||
<string name="error_invalid_credentials">Wrong login or password</string>
|
||||
<string name="error_unknown">Unknown error</string>
|
||||
<string name="entry_history">Entry history</string>
|
||||
<string name="entry_time">Entry time</string>
|
||||
<string name="entry">Entry</string>
|
||||
<string name="type_of_entrance">Type of pass</string>
|
||||
<string name="no_data">No data</string>
|
||||
<string name="qr_success_result">Success</string>
|
||||
<string name="qr_wrong_result">Something wrong</string>
|
||||
<string name="qr_null_result">Operation was cancelled</string>
|
||||
<string name="profile">Profile</string>
|
||||
<string name="find">Find</string>
|
||||
<string name="close_button">Close</string>
|
||||
</resources>
|
@ -17,8 +17,10 @@
|
||||
<string name="qr_wrong_result">Что-то пошло не так</string>
|
||||
<string name="qr_null_result">Вход был отменён</string>
|
||||
<string name="profile">Профиль</string>
|
||||
<string name="user_view">Просмотр пользователя</string>
|
||||
<string name="found_user">Найти информацию о сотруднике</string>
|
||||
<string name="user_view" translatable="false">Просмотр пользователя</string>
|
||||
<string name="found_user" translatable="false">Найти информацию о сотруднике</string>
|
||||
<string name="find">Найти</string>
|
||||
<string name="access">Доступ\n</string>
|
||||
<string name="access" translatable="false">Доступ\n</string>
|
||||
<string name="access_right" translatable="false">Доступ разрешен</string>
|
||||
<string name="access_wrong" translatable="false">Доступ запрещен</string>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user