Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
cd931b8
Refactoring code to better reflect new App purpose.
matej-gutman Sep 24, 2021
60ffd67
Delete 1.json
matej-gutman Sep 24, 2021
c93f924
Some more refactoring. Refactored LOGIN and REGISTER part to prepare …
matej-gutman Oct 20, 2021
b8a6c21
Refactored part of source that handles blog posts and prepared it for…
matej-gutman Oct 21, 2021
bcd4440
Bugfix: server only reports relative image location. BASE_URL appended.
matej-gutman Oct 22, 2021
3861827
Bugfix: server only reports relative image location. BASE_URL appended.
matej-gutman Oct 22, 2021
a2ce720
The 'get blog' functionality added and tested.
matej-gutman Oct 25, 2021
33960b5
Added BASE_URL to glide load image while viewing blog.
matej-gutman Oct 25, 2021
193b57c
Modified checking of task owner to fit new server API.
matej-gutman Oct 25, 2021
29bd7ad
Bugfix: blogs (now tasks) were ordered incorrectly. They are ordered …
matej-gutman Oct 26, 2021
34c0087
Bugfix: the content of file is read via InputStream instead of binary…
matej-gutman Nov 2, 2021
baee614
Code cleanup.
matej-gutman Nov 2, 2021
c0801e4
Account fragment update. New scheme that handles new server requests …
matej-gutman Nov 3, 2021
e85c2d8
Account update set for new API.
matej-gutman Nov 3, 2021
080f39b
Change password updated to reflect new API.
matej-gutman Nov 3, 2021
1e253bf
Bugfix: launching account fragment caused auth token to be deleted fr…
matej-gutman Nov 6, 2021
169ccec
Added support for filtering and ordering tailored for new server API.
matej-gutman Dec 3, 2021
f6412f5
Added support for filtering by 'updated' and 'created' parameter.
matej-gutman Dec 3, 2021
06be0bb
Refactored 'blog' to 'task' and 'slug' to 'id' to better reflect new …
matej-gutman Dec 13, 2021
3f9badd
Refactored 'publish' to 'create'.
matej-gutman Dec 13, 2021
e6c6fdb
Bugfix: if task was deleted from server, it now deletes from cache wh…
matej-gutman Dec 14, 2021
8999c5e
Password reset form path changed.
matej-gutman Jan 4, 2022
5f95099
'Server Message Translator' class added to help with translating mess…
matej-gutman Jan 6, 2022
b97c049
Server messages translator tested successfully.
matej-gutman Jan 6, 2022
ea1b3ca
translations to Slovenian and Spanish
Apr 11, 2022
8cae788
translating server messages
Apr 20, 2022
a557082
check if the role is admin
luna-zivkovic Apr 25, 2022
b5ab035
Small changes
luna-zivkovic Apr 25, 2022
28c557f
user registration by admin
luna-zivkovic Apr 26, 2022
3fa184f
getting all users from server and displaying them
luna-zivkovic May 3, 2022
1e31235
get data from a particular user
luna-zivkovic May 4, 2022
0fd07eb
updating users features except role
luna-zivkovic May 12, 2022
1757b66
updating users role
luna-zivkovic May 15, 2022
f7ec1ef
UI - edit users profile change
luna-zivkovic May 16, 2022
d7e0e54
updating UI
luna-zivkovic May 23, 2022
1f57721
handling exceptions
luna-zivkovic May 31, 2022
2e9366a
admin permitions
luna-zivkovic Jun 24, 2022
16081a0
locking pictures
luna-zivkovic Jul 7, 2022
1415271
changes
luna-zivkovic Jul 16, 2022
9d62235
small changes
luna-zivkovic Jul 18, 2022
3b074aa
admin rights
luna-zivkovic Jul 19, 2022
a1df0f7
tests
luna-zivkovic Jul 19, 2022
713d733
removing udp
luna-zivkovic Jul 20, 2022
6ead572
port change
luna-zivkovic Jul 20, 2022
f8870e5
removing comments
luna-zivkovic Jul 20, 2022
8373d00
adding udp
luna-zivkovic Aug 5, 2022
40c5402
removing udp
luna-zivkovic Aug 5, 2022
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
admin permitions
  • Loading branch information
luna-zivkovic committed Jun 24, 2022
commit 2e9366a7d4719c0655aa5cb09bef95bc95f4633c
18 changes: 13 additions & 5 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.templateapp.cloudapi.business.datasource.network.auth.network_responses

import com.google.gson.annotations.Expose
import com.google.gson.annotations.SerializedName
import com.templateapp.cloudapi.business.datasource.network.responseObjects.User

Expand All @@ -9,7 +10,11 @@ class RegistrationResponse(
var error: String,

@SerializedName("success")
var success: String
var success: String,

@SerializedName("response")
@Expose
val response: String?,


)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class AccountDto(
@SerializedName("age")
val age: Int,


@SerializedName("enabled")
val enabled: Boolean,

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.templateapp.cloudapi.business.domain.models

import com.templateapp.cloudapi.business.datasource.cache.account.RoleEntity

data class Device(
val _id: String,
val serialNumber : String
)









Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ class Constants {

companion object{

const val BASE_URL = "http://192.168.1.8:3000/"
const val PASSWORD_RESET_URL: String = "http://192.168.1.8:3000/passwordresetform"
const val REGISTER_ADMIN_URL: String = "http://192.168.1.8:3000/registeruser"
const val BASE_URL = "http://appcloud-env.eba-theyd4uu.eu-central-1.elasticbeanstalk.com/"
const val PASSWORD_RESET_URL: String = "http://appcloud-env.eba-theyd4uu.eu-central-1.elasticbeanstalk.com/passwordresetform"
const val REGISTER_ADMIN_URL: String = "http://appcloud-env.eba-theyd4uu.eu-central-1.elasticbeanstalk.com/registeruser"


const val NETWORK_TIMEOUT = 6000L
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,32 @@ class Register(
fun execute(
email: String,

): Flow<DataState<String>> = flow {
emit(DataState.loading<String>())
): Flow<DataState<Response>> = flow {
emit(DataState.loading<Response>())
val registerResponse = service.register(
email = email,

)
// Incorrect login credentials counts as a 200 response from server, so need to handle that
registerResponse.error?.let{
throw Exception(it)

registerResponse.response?.let {
if(registerResponse.response != SuccessHandling.SUCCESS_ACCOUNT_UPDATED){
throw Exception(ErrorHandling.ERROR_UPDATE_ACCOUNT)
}
}?:run{
throw Exception(ErrorHandling.ERROR_UPDATE_ACCOUNT)
}

// cache account information

emit(DataState.data(data = "Success", response = null))
emit(DataState.data<Response>(
data = Response(
message = SuccessHandling.SUCCESS_ACCOUNT_UPDATED,
uiComponentType = UIComponentType.Toast(),
messageType = MessageType.Success()
),
response = null
))

}.catch { e ->
emit(handleUseCaseException(e, serverMsgTranslator))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.templateapp.cloudapi.presentation;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

import android.annotation.SuppressLint;
import android.os.AsyncTask;
import android.os.Build;

public class UDP_Client
{

private InetAddress IPAddress = null;
private String message = "Hello Android!" ;
private AsyncTask<Void, Void, Void> async_cient;
public String Message;


@SuppressLint("NewApi")
public void NachrichtSenden()
{
async_cient = new AsyncTask<Void, Void, Void>()
{
@Override
protected Void doInBackground(Void... params)
{
DatagramSocket ds = null;

try
{
byte[] ipAddr = new byte[]{ (byte) 255, (byte) 255,(byte)255, (byte) 255};
InetAddress addr = InetAddress.getByAddress(ipAddr);
ds = new DatagramSocket(3000);
DatagramPacket dp;
dp = new DatagramPacket(Message.getBytes(), Message.getBytes().length, addr, 3000);
ds.setBroadcast(true);
ds.send(dp);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
if (ds != null)
{
ds.close();
}
}
return null;
}

protected void onPostExecute(Void result)
{
super.onPostExecute(result);
}
};

if (Build.VERSION.SDK_INT >= 11) async_cient.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else async_cient.execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.navigation.fragment.findNavController
import com.templateapp.cloudapi.R
import com.templateapp.cloudapi.business.datasource.network.main.OpenApiMainService
import com.templateapp.cloudapi.databinding.FragmentLauncherBinding
import com.templateapp.cloudapi.presentation.UDP_Client
import com.templateapp.cloudapi.presentation.auth.BaseAuthFragment
import com.templateapp.cloudapi.presentation.auth.register.RegisterState
import kotlinx.coroutines.flow.*
Expand All @@ -34,6 +35,9 @@ class LauncherFragment: BaseAuthFragment() {

//search()

/* val Client = UDP_Client()
Client.Message = "Your message"
Client.NachrichtSenden()*/
var openApiMainService: OpenApiMainService


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.templateapp.cloudapi.presentation.auth.register

import com.templateapp.cloudapi.presentation.main.account.update.UpdateAccountEvents


sealed class RegisterEvents{

Expand All @@ -11,5 +13,7 @@ sealed class RegisterEvents{
val email: String
): RegisterEvents()


object OnUpdateComplete: RegisterEvents()
object OnRemoveHeadFromQueue: RegisterEvents()
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ class RegisterFragment : BaseAuthFragment() {
viewModel.onTriggerEvent(RegisterEvents.OnRemoveHeadFromQueue)
}
})
if(state.isComplete){
findNavController().popBackStack(R.id.accountFragment, false)
Toast.makeText(context ,"You have successfully sent an email", Toast.LENGTH_SHORT).show();
}

}


}

private fun setRegisterFields(
Expand All @@ -67,7 +74,7 @@ class RegisterFragment : BaseAuthFragment() {
viewModel.onTriggerEvent(RegisterEvents.Register(
email = binding.inputEmail.text.toString(),
))
Toast.makeText(context,"You have successfully sent an email",Toast.LENGTH_SHORT).show();

}

override fun onPause() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ import com.templateapp.cloudapi.business.domain.util.StateMessage
data class RegisterState(
val isLoading: Boolean = false,
val email: String = "",

val isComplete: Boolean = false,
val queue: Queue<StateMessage> = Queue(mutableListOf()),
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.templateapp.cloudapi.presentation.auth.register

import android.util.Log
import android.widget.Toast
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.templateapp.cloudapi.business.domain.util.StateMessage
import com.templateapp.cloudapi.business.domain.util.SuccessHandling
import com.templateapp.cloudapi.business.domain.util.UIComponentType
import com.templateapp.cloudapi.business.domain.util.doesMessageAlreadyExistInQueue
import com.templateapp.cloudapi.business.interactors.auth.Register
import com.templateapp.cloudapi.presentation.main.account.update.UpdateAccountEvents
import com.templateapp.cloudapi.presentation.session.SessionEvents
import com.templateapp.cloudapi.presentation.session.SessionManager
import dagger.hilt.android.lifecycle.HiltViewModel
Expand Down Expand Up @@ -40,6 +43,16 @@ constructor(
is RegisterEvents.OnRemoveHeadFromQueue -> {
removeHeadFromQueue()
}

is RegisterEvents.OnUpdateComplete -> {
onUpdateComplete()
}
}
}

private fun onUpdateComplete(){
state.value?.let { state ->
this.state.value = state.copy(isComplete = true)
}
}

Expand Down Expand Up @@ -79,10 +92,20 @@ constructor(
).onEach { dataState ->
this.state.value = state.copy(isLoading = dataState.isLoading)

dataState.data?.let { success ->
//sessionManager.onTriggerEvent(SessionEvents.Login(success))
dataState.data?.let { response ->
if(response.message == SuccessHandling.SUCCESS_ACCOUNT_UPDATED){
onTriggerEvent(RegisterEvents.OnUpdateComplete)
}else{

appendToMessageQueue(
stateMessage = StateMessage(
response = response
)
)
}
}


dataState.stateMessage?.let { stateMessage ->
appendToMessageQueue(stateMessage)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
package com.templateapp.cloudapi.presentation.main.account.detail

import com.templateapp.cloudapi.presentation.main.account.settings.SettingsEvents
import com.templateapp.cloudapi.presentation.main.account.update.UpdateAccountEvents


sealed class AccountEvents{

object GetAccount: AccountEvents()
object ManageUsers: AccountEvents()

object Logout: AccountEvents()

object ManageUsers: AccountEvents()
object ManageDevices: AccountEvents()

object GetAccount: AccountEvents()

object MyAccount: AccountEvents()

object OnRemoveHeadFromQueue: AccountEvents()

object OnAdmin: AccountEvents()

}
Loading