Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
adb6025
Post Java Class
Oct 31, 2022
3b927ce
Maybe making the upload page work
ljackson23 Nov 7, 2022
1232737
fixing upload page to match post
ljackson23 Nov 9, 2022
f5b0e2d
fixing the upload success page
ljackson23 Nov 14, 2022
9d11c77
fixing the upload success page
ljackson23 Nov 16, 2022
6bf0309
Stylized feed page (nav bar)
alana-kiwi23 Nov 16, 2022
840e070
upload success page fixing
ljackson23 Nov 16, 2022
668435c
11/16/22
anaiysaa Nov 16, 2022
d26c796
11/16/22
anaiysaa Nov 16, 2022
8b29a17
added @PostMapping to api path
jasmine-xnf Nov 21, 2022
956342c
Merge branch 'api' of https://github.com/HolyNamesAcademy/Projects-II…
anaiysaa Nov 21, 2022
fbf2c5c
Merge branch 'master' into api
anaiysaa Nov 21, 2022
9a01010
i know that the data is getting inputted but it isnt showing up on th…
ljackson23 Nov 21, 2022
3b01cbb
11/23/2022
AerialAstrea Nov 23, 2022
437f7a6
Stylized feed page (nav bar)
alana-kiwi23 Nov 23, 2022
82b8edf
small comments and little changes
AerialAstrea Nov 28, 2022
575d04d
Update bootRun.xml
anmac42 Nov 28, 2022
79efa31
still fixing upload success page
ljackson23 Nov 28, 2022
d6d3309
cleaned up some errors
AerialAstrea Nov 28, 2022
83d50ec
Merge branch 'database' of https://github.com/HolyNamesAcademy/Projec…
AerialAstrea Nov 28, 2022
e33988c
finally builds!!!
AerialAstrea Nov 28, 2022
c824a09
updated @PostMapping
jasmine-xnf Dec 7, 2022
21dc21b
Stylized feed page (nav bar)
alana-kiwi23 Dec 7, 2022
5e37a45
updated @PostMapping
jasmine-xnf Dec 7, 2022
c9a17d0
:))
AerialAstrea Dec 7, 2022
1c3f177
in the main controller it doesnt like the post isnt filled with anyth…
ljackson23 Dec 7, 2022
af78929
Stylized feed page (nav bar)
alana-kiwi23 Dec 7, 2022
a9bf677
still need to figure out postid
AerialAstrea Dec 12, 2022
696bc99
everything works other than age (it just shows 0 even if the user cha…
ljackson23 Dec 12, 2022
731e9d0
Stylized feed page (nav bar)
alana-kiwi23 Dec 12, 2022
d9fa470
11/16/22
anaiysaa Dec 14, 2022
692bbae
Working Upload Page >:D
ljackson23 Dec 14, 2022
6121358
Stylized feed page (nav bar)
alana-kiwi23 Jan 11, 2023
fd7837a
added other method headers
AerialAstrea Jan 11, 2023
3fe95b2
in azure works ;) but in here tho but did some changes
AerialAstrea Jan 12, 2023
f2f544e
making it look pretty D:
ljackson23 Jan 23, 2023
e3459fc
ahhh
AerialAstrea Jan 25, 2023
6f8247b
it works <333
AerialAstrea Jan 25, 2023
18adfa8
looking less ghetto!
ljackson23 Jan 25, 2023
aabb5d9
:))
AerialAstrea Jan 25, 2023
1ad408d
naming of methods in Post
AerialAstrea Jan 25, 2023
2260da0
null postid
AerialAstrea Jan 25, 2023
f02da00
new constructor & changing variable
AerialAstrea Jan 25, 2023
34486ae
:)
AerialAstrea Jan 26, 2023
b7e1516
upload page
ljackson23 Jan 30, 2023
e5a35ee
Merge branch 'master' into database
AerialAstrea Jan 30, 2023
4fdb504
remove env
AerialAstrea Jan 30, 2023
7af2801
Update MainController.java
AerialAstrea Jan 30, 2023
32d6a38
Merge pull request #1 from HolyNamesAcademy/database
AerialAstrea Jan 30, 2023
d40a436
Stylized feed page (nav bar)
alana-kiwi23 Jan 30, 2023
441eefd
Stylized feed page (nav bar)
alana-kiwi23 Jan 30, 2023
c3d7cfe
Stylized feed page (nav bar)
alana-kiwi23 Feb 1, 2023
a0ebb20
Merge branch 'master' into Feed
alana-kiwi23 Feb 8, 2023
b087b44
Merge remote-tracking branch 'origin/Feed' into Feed
alana-kiwi23 Feb 8, 2023
3c5126a
Merge branch 'master' into uploadPage
ljackson23 Feb 8, 2023
6cdd8d2
can upload!
AerialAstrea Feb 8, 2023
d7b4bdd
formating <:
AerialAstrea Feb 8, 2023
c0c5809
java type
alana-kiwi23 Feb 13, 2023
47cc1fc
Merge pull request #3 from HolyNamesAcademy/Feed
alana-kiwi23 Feb 13, 2023
275807e
upload page
ljackson23 Feb 13, 2023
7eb2edf
setting up for loop to auto-add posts from database
alana-kiwi23 Feb 13, 2023
f27f470
:))
AerialAstrea Feb 15, 2023
5cb74a3
Merge branch 'master' into uploadPage
AerialAstrea Feb 15, 2023
b5d2b34
spacing in main
AerialAstrea Feb 15, 2023
1df6f0c
ready for database
alana-kiwi23 Feb 15, 2023
54ff3aa
upload page
ljackson23 Feb 15, 2023
7227c6f
viewPost Method
AerialAstrea Feb 15, 2023
53df816
Merge branch 'master' into uploadPage
AerialAstrea Feb 15, 2023
d0e1b85
added back import statement
AerialAstrea Feb 15, 2023
68a02c7
:))
AerialAstrea Feb 15, 2023
d868325
Changed an import statement
AerialAstrea Feb 15, 2023
f7494f4
my tests and change to TreeMap <3
AerialAstrea Feb 15, 2023
2ae086f
Comments and Hypothetically delete method works...
AerialAstrea Feb 15, 2023
4daa47d
update post
AerialAstrea Feb 22, 2023
39f36e9
02/22/2023
AerialAstrea Feb 22, 2023
ffae99c
Merge branch 'master' into database
AerialAstrea Feb 27, 2023
4edd1f8
Update MainController.java
AerialAstrea Feb 27, 2023
ad57580
Stylized feed page (nav bar)
alana-kiwi23 Jan 30, 2023
b250b1b
added a new view method (search by username)
AerialAstrea Feb 27, 2023
dd5c0aa
java type
alana-kiwi23 Feb 13, 2023
360c374
setting up for loop to auto-add posts from database
alana-kiwi23 Feb 13, 2023
3d1aacc
ready for database
alana-kiwi23 Feb 15, 2023
f640313
comment?
AerialAstrea Feb 27, 2023
066533e
Merge remote-tracking branch 'origin/Feed' into Feed
alana-kiwi23 Feb 27, 2023
576e59c
Update SqlDB.java
AerialAstrea Mar 1, 2023
69701dc
Merge branch 'master' of https://github.com/HolyNamesAcademy/Projects…
alana-kiwi23 Mar 6, 2023
0091132
fixed errors and got access to feed page
alana-kiwi23 Mar 8, 2023
f029059
:))
AerialAstrea Mar 8, 2023
2a41f1a
Merge branch 'database'
AerialAstrea Mar 8, 2023
36d7c47
removed a line
AerialAstrea Mar 8, 2023
1c86df7
cleaned up code :))
AerialAstrea Mar 8, 2023
d455fa5
fixed a comment
AerialAstrea Mar 8, 2023
d3e9c77
code clean up
AerialAstrea Mar 8, 2023
15f25ea
delete post button wip
blossoo Mar 15, 2023
9e62868
delete red
blossoo Mar 15, 2023
f7f4e28
blob store for images
ljackson23 Mar 15, 2023
77a9595
blob store for images
ljackson23 Mar 15, 2023
65882c3
Merge branch 'database' into uploadPage
AerialAstrea Mar 20, 2023
91dc8ca
Update uploadPage.html
blossoo Mar 20, 2023
116cb23
Merge pull request #4 from HolyNamesAcademy/master
ljackson23 Mar 20, 2023
db98d7f
Merge remote-tracking branch 'origin/uploadPage' into uploadPage
ljackson23 Mar 20, 2023
9682fcf
fixing invalid connection string
ljackson23 Mar 27, 2023
7b79fc9
set environment variables for database
ljackson23 Mar 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .idea/runConfigurations/bootRun.xml

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

1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"type": "java",
"name": "Attach Spring",
Expand Down
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
sourceCompatibility = '1.11'

configurations {
developmentOnly
Expand All @@ -23,6 +23,9 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'com.microsoft.sqlserver:mssql-jdbc'
implementation 'com.azure:azure-sdk-bom:1.2.9'
implementation 'com.azure:azure-storage-blob:12.7.0'
implementation group: 'com.microsoft.azure', name: 'azure-storage', version: '8.0.0'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
39 changes: 39 additions & 0 deletions src/main/java/service/BlobServiceClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package service;

import java.io.*;
import java.util.Map;
import java.util.stream.Stream;
import com.azure.core.util.Configuration;
import com.azure.storage.blob.BlobClient;
import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.BlobContainerClientBuilder;
import com.microsoft.azure.storage.CloudStorageAccount;
import com.microsoft.azure.storage.*;
import com.microsoft.azure.storage.blob.*;

import org.springframework.web.multipart.MultipartFile;

public class BlobServiceClient {
public String BlobServiceClient (MultipartFile f) throws IOException{
try {
String constr = System.getenv("StorageExplorerConnectionString");
CloudStorageAccount storageAccount = CloudStorageAccount.parse(constr);

CloudBlobClient blobClient = storageAccount.createCloudBlobClient();

CloudBlobContainer container = blobClient.getContainerReference("plantbook");

CloudBlockBlob blob = container.getBlockBlobReference(f.getOriginalFilename());

blob.upload(new BufferedInputStream(f.getInputStream()), f.getInputStream().available());
System.out.println("ok");

return blob.getUri().toString();
}
catch (Exception e){
System.err.println("error");
System.err.println(e.getMessage());
}
return "ok";
}
}
81 changes: 81 additions & 0 deletions src/main/java/service/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.*;

@Controller
public class MainController {
Expand All @@ -19,6 +27,79 @@ public String index() {
@GetMapping("/hello")
public String hello(@RequestParam(name="name", required=false, defaultValue="World") String name, Model model) {
model.addAttribute("name", name);

return "hello";
}

@GetMapping ("/uploadPage")
public String uploadPage(Model m){
Post post = new Post(); // needs arguments but if i keep the default then the upload success page doesn't work
m.addAttribute("plant");

List<String> listStatus = Arrays.asList("Alive", "Dead", "Watered", "Un-Watered");
m.addAttribute("post", post);
m.addAttribute("listStatus", listStatus);

return "uploadPage";
}

@PostMapping("/uploadPage")
public String submitUploadPage(@ModelAttribute("post") Post post, Model m, @RequestParam MultipartFile f ){
m.addAttribute("Age", post.getAge());
m.addAttribute("PlantName", post.getPlantName());
m.addAttribute("Species", post.getSpecies());
m.addAttribute("NameOfUser", post.getNameOfUser());
m.addAttribute("Caption", post.getCaption());
//m.addAttribute("PhotoUrl", post.getPhotoUrl());
System.out.print(post);
BlobServiceClient b = new BlobServiceClient();
String url;
try{
url = b.BlobServiceClient(f);
}catch(IOException e){
e.printStackTrace();
url = "didnt work";
}
post.setPhotoUrl(url);


sqlDB.uploadPost(post);
return "uploadSuccess";

}

@GetMapping ("/delete") // delete testing, works (just need to implement button)
public String delete(Model m){
sqlDB.deletePosts(6);

return "index";
}

@GetMapping("/feed")
public String feed(@RequestParam(name="Clarence", required=false, defaultValue="planty") String name, Model model){
model.addAttribute("Clarence", name);
ArrayList<Post> posts = new ArrayList<>();

TreeMap<Integer, Post> data = sqlDB.viewAllPosts();
for (Post plant : data.values()) { // enhanced for to loop through all the post and put into an array
posts.add(plant);
System.out.print(plant.PlantName);
System.out.print(plant.PhotoUrl);
System.out.println(plant.Caption);
}

model.addAttribute("posts", posts);
return "/feed";
}

/* function httpGet(Url)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", https://house-plants.p.rapidapi.com/common/coralberry, false ); // false for synchronous request
xmlHttp.send( https://house-plants.p.rapidapi.com/common/coralberry );
return xmlHttp.responseText;
}
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
public respHttpResponse<String> getResponse() {return response;}
*/
}
106 changes: 106 additions & 0 deletions src/main/java/service/Post.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package service;

public class Post {
public Integer PostId;
public int PlantId, Age;
public String PlantName, Species, Status, NameOfUser, Caption, PhotoUrl;

public Post(Integer PostId, int PlantId, int Age, String PlantName, String Species, String Status, String NameOfUser, String Caption, String PhotoUrl) {
this.PostId = PostId;
this.PlantId = PlantId;
this.Age = Age;
this.PlantName = PlantName;
this.Species = Species;
this.Status = Status;
this.NameOfUser = NameOfUser;
this.Caption = Caption;
this.PhotoUrl = PhotoUrl;
}

public Post(){
PostId = null;
PlantId = 0;
Age = 0;
PlantName = "";
Species = "";
Status = "";
NameOfUser = "";
Caption = "";
PhotoUrl = "";
}

public Post(int PlantId, int Age, String PlantName, String Species, String Status, String NameOfUser, String Caption, String PhotoUrl) {
PostId = null; // "created" when post is added to the database
this.PlantId = PlantId;
this.Age = Age;
this.PlantName = PlantName;
this.Species = Species;
this.Status = Status;
this.NameOfUser = NameOfUser;
this.Caption = Caption;
this.PhotoUrl = PhotoUrl;
}

// all the getter methods
public int getPostID() {
return PostId;
}
public int getPlantID() {
return PlantId;
}
public int getAge() {
return Age;
}
public String getPlantName() {
return PlantName;
}
public String getSpecies() {
return Species;
}
public String getStatus() {
return Status;
}
public String getNameOfUser() {
return NameOfUser;
}
public String getCaption() {
return Caption;
}
public String getPhotoUrl() {
return PhotoUrl;
}

// all the setter methods
public void setPostID(int PostId) {
this.PostId = PostId;
}
public void setPlantID(int PlantId) {
this.PlantId = PlantId;
}
public void setAge(int Age) {
this.Age = Age;
}
public void setPlantName(String PlantName) {
this.PlantName = PlantName;
}
public void setSpecies(String Species) {
this.Species = Species;
}
public void setStatus(String Status) {
this.Status = Status;
}
public void setNameOfUser(String NameOfUser) {
this.NameOfUser = NameOfUser;
}
public void setCaption(String Caption) {
this.Caption = Caption;
}
public void setPhotoUrl(String PhotoUrl) {
this.PhotoUrl = PhotoUrl;
}

@Override
public String toString(){
return "Post [ Photo URL=" + PhotoUrl + ", Plant Type=" + Species + ", Age=" + Age + ", Caption=" + Caption + ", Life Status=" + Status + "]";
}
}
Loading