diff options
9 files changed, 120 insertions, 5 deletions
diff --git a/Backend/Api/Api/Controllers/UserController.cs b/Backend/Api/Api/Controllers/UserController.cs index 94e4b41..1bc395f 100644 --- a/Backend/Api/Api/Controllers/UserController.cs +++ b/Backend/Api/Api/Controllers/UserController.cs @@ -64,5 +64,15 @@ namespace Api.Controllers return Ok(rez); return BadRequest(); } + [HttpGet("history")] + [Authorize(Roles = "User")] + public async Task<ActionResult<List<PostSend>>> ViewHistory() + { + var id = await _userService.UserIdFromJwt(); + var rez = await _postService.UserHistory(id); + if (rez != null) + return Ok(rez); + return BadRequest(); + } } } diff --git a/Backend/Api/Api/Interfaces/IPostService.cs b/Backend/Api/Api/Interfaces/IPostService.cs index fc2ae03..12a5fe8 100644 --- a/Backend/Api/Api/Interfaces/IPostService.cs +++ b/Backend/Api/Api/Interfaces/IPostService.cs @@ -18,5 +18,6 @@ namespace Api.Interfaces Task<PostSendPage> SearchPosts(string locid, int page = 0, int sorttype = 1, int filterdate = 1); int DateEnumToDays(int filterdate); Task<List<PostSend>> GetUsersPosts(string id); + Task<List<PostSend>> UserHistory(string userid); } }
\ No newline at end of file diff --git a/Backend/Api/Api/Models/Location.cs b/Backend/Api/Api/Models/Location.cs index 3402f6c..b2f0aad 100644 --- a/Backend/Api/Api/Models/Location.cs +++ b/Backend/Api/Api/Models/Location.cs @@ -22,8 +22,9 @@ namespace Api.Models public enum LocationType { GRAD,ULICA,JEZERO,REKA,PLAZA,OKEAN, MORE, MOREUZ, MOST,BANJA, - PLANINA, VISORAVAN, PIRAMIDA, LIVADA, SELO, OSTRVO, POLUOSTRVO, KLISURA, ARHIPELAG, - ADA, DELTA, FJORD, GEJZIR, IZVOR, KOTLINA, MINERALNI_IZVOR, PECINA ,SUMA, VODOPAD,VULKAN + PLANINA, VISORAVAN, PIRAMIDA, LIVADA, SELO, OSTRVO, POLUOSTRVO, KLISURA, ARHIPELAG, + ADA, DELTA, FJORD, GEJZIR, IZVOR, KOTLINA, MINERALNI_IZVOR, PECINA ,SUMA, VODOPAD,VULKAN, + MUZEJ,ZAMAK,TRG,SPOMENIK,PARK,ZGRADA } public class Coords diff --git a/Backend/Api/Api/Services/PostService.cs b/Backend/Api/Api/Services/PostService.cs index 2d62f49..cc4d064 100644 --- a/Backend/Api/Api/Services/PostService.cs +++ b/Backend/Api/Api/Services/PostService.cs @@ -349,5 +349,21 @@ namespace Api.Services } return tosend; } + public async Task<List<PostSend>> UserHistory(string userid) + { + var posts = await _posts.Find(_ => true).ToListAsync(); + if (posts == null) + return null; + var tosend = new List<PostSend>(); + foreach (var post in posts) + { + if (post.views.Any(x => x.Equals(userid))) + { + var x = await postToPostSend(post); + tosend.Add(x); + } + } + return tosend; + } } } diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityAddPost.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityAddPost.kt index bd3ddb1..c4b5a60 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityAddPost.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityAddPost.kt @@ -44,6 +44,9 @@ class ActivityAddPost : AppCompatActivity() { private lateinit var descriptionString:String private lateinit var post:Button private lateinit var addLocation:Button + private lateinit var tagLayout:LinearLayout + private lateinit var tagButtons:List<Button> + private lateinit var tagAutoText: AutoCompleteTextView val incorectCoord:Double=1000.0 val LOCATIONREQCODE=123 var longitude:Double=incorectCoord @@ -70,6 +73,12 @@ class ActivityAddPost : AppCompatActivity() { post=findViewById<View>(R.id.btnActivityAddPostPost) as Button addLocation=findViewById<View>(R.id.btnActivityAddPostAddLocation) as Button + val tags=resources.getStringArray(R.array.Tags) + //Log.d("Main",tags[0].toString()) + val tagadapter = ArrayAdapter(this,android.R.layout.simple_list_item_1,tags) + tagAutoText= findViewById(R.id.acTags) as AutoCompleteTextView + tagAutoText.setAdapter(tagadapter) + progressDialog= ProgressDialog(this) progressDialog!!.setMessage("Molimo sacekajte!!!") progressDialog!!.setCancelable(false) diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsAdapter.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsAdapter.kt index cf16689..e09cd06 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsAdapter.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsAdapter.kt @@ -13,6 +13,7 @@ import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import com.example.brzodolokacije.Activities.ActivitySinglePost +import com.example.brzodolokacije.Activities.NavigationActivity import com.example.brzodolokacije.Interfaces.IBackendApi import com.example.brzodolokacije.Models.LocationType import com.example.brzodolokacije.Models.PostPreview @@ -63,6 +64,19 @@ class ShowPostsAdapter (val activity:Activity,val items : MutableList<PostPrevie val intent:Intent = Intent(activity,ActivitySinglePost::class.java) var b=Bundle() //getItem(position)!!.location.type=LocationType.ADA + //--------------------------------------------------------------- call back to add view tick + val Api= RetrofitHelper.getInstance() + val request=Api.addView("Bearer "+token,getItem(position)!!._id) + request.enqueue(object : retrofit2.Callback<PostPreview?> { + override fun onResponse(call: Call<PostPreview?>, response: Response<PostPreview?>) { + + } + + override fun onFailure(call: Call<PostPreview?>, t: Throwable) { + + } + }) + //--------------------------------------------------------------- b.putParcelable("selectedPost",getItem(position)!!) intent.putExtras(b) activity.startActivity(intent) diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Interfaces/IBackendApi.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Interfaces/IBackendApi.kt index 6d09251..9d94013 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Interfaces/IBackendApi.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Interfaces/IBackendApi.kt @@ -26,6 +26,8 @@ interface IBackendApi { fun resetpass(@Body obj:ResetPass):Call<ResponseBody> @GET("/api/post") fun getPosts(@Header("Authorization") authHeader:String):Call<MutableList<PostPreview>> + @GET("/api/Post/posts/{id}") + fun addView(@Header("Authorization") authHeader:String,@Path("id") id:String):Call<PostPreview> @POST("/api/Location/add") fun addLocation(@Header("Authorization") authHeader:String,@Body obj: Location ):Call<Location> @Multipart diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/activity_add_post.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/activity_add_post.xml index 21dce5e..c0b1ab7 100644 --- a/Client/BrzoDoLokacije/app/src/main/res/layout/activity_add_post.xml +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/activity_add_post.xml @@ -19,7 +19,7 @@ <Button android:id="@+id/nextImage" android:layout_width="78dp" - android:layout_height="499dp" + android:layout_height="0dp" android:background="@drawable/rounded_transparent_button" android:gravity="right" android:padding="30dp" @@ -33,7 +33,7 @@ <Button android:id="@+id/previousImage" android:layout_width="70dp" - android:layout_height="497dp" + android:layout_height="0dp" android:background="@drawable/rounded_transparent_button" android:gravity="left" @@ -117,7 +117,7 @@ android:ems="10" android:hint="Reykjavik, Iceland" android:inputType="textEmailAddress" - app:layout_constraintBottom_toTopOf="@+id/btnActivityAddPostPost" + app:layout_constraintBottom_toTopOf="@+id/llTags" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> @@ -149,5 +149,26 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="@+id/isActivityAddPostSwitcher" /> + <LinearLayout + android:id="@+id/llTags" + android:layout_width="0dp" + android:layout_height="50dp" + android:layout_marginLeft="20dp" + android:layout_marginRight="20dp" + android:orientation="horizontal" + app:layout_constraintBottom_toTopOf="@+id/acTags" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent"></LinearLayout> + + <AutoCompleteTextView + android:id="@+id/acTags" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="20dp" + android:minHeight="48dp" + android:hint="Dodaj tag" + app:layout_constraintBottom_toTopOf="@+id/btnActivityAddPostPost" + app:layout_constraintStart_toStartOf="parent" /> + </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/res/values/strings.xml b/Client/BrzoDoLokacije/app/src/main/res/values/strings.xml index a969148..fef04ac 100644 --- a/Client/BrzoDoLokacije/app/src/main/res/values/strings.xml +++ b/Client/BrzoDoLokacije/app/src/main/res/values/strings.xml @@ -6,4 +6,45 @@ <string name="title_activity_maps">MapsActivity</string> <string name="dodaj_objavu">Dodaj objavu</string> <string name="todo">TODO</string> + + + <!-- example lista tagova, make actual list for app --> + <string-array name="Tags"> + <item>GRAD</item> + <item>ULICA</item> + <item>JEZERO</item> + <item>REKA</item> + <item>PLAZA</item> + <item>OKEAN</item> + <item>MORE</item> + <item>MOREUZ</item> + <item>MOST</item> + <item>BANJA</item> + <item>PLANINA</item> + <item>VISORAVAN</item> + <item>PIRAMIDA</item> + <item>LIVADA</item> + <item>SELO</item> + <item>OSTRVO</item> + <item>POLUOSTRVO</item> + <item>KLISURA</item> + <item>ARHIPELAG</item> + <item>ADA</item> + <item>DELTA</item> + <item>FJORD</item> + <item>GEJZIR</item> + <item>IZVOR</item> + <item>KOTLINA</item> + <item>MINERALNI_IZVOR</item> + <item>PECINA</item> + <item>SUMA</item> + <item>VODOPAD</item> + <item>VULKAN</item> + <item>MUZEJ</item> + <item>ZAMAK</item> + <item>TRG</item> + <item>SPOMENIK</item> + <item>PARK</item> + <item>ZGRADA</item> + </string-array> </resources>
\ No newline at end of file |