Răsfoiți Sursa

Merge branch 'master' of http://10.1.1.202:3030/steve07s/BIM-Resource

manto07m 3 ani în urmă
părinte
comite
6fed36a370

+ 166 - 0
assets/equipmentTable3.json

@@ -0,0 +1,166 @@
+[
+    {
+        "category_name": "建築",
+        "children": [
+            {
+                "category_name": "人孔陰井"
+            },
+            {
+                "category_name": "電扶梯"
+            },
+            {
+                "category_name": "衛浴設備"
+            },
+            {
+                "category_name": "門"
+            },
+            {
+                "category_name": "窗"
+            },
+            {
+                "category_name": "停車格"
+            }
+        ]
+    },
+    {
+        "category_name": "結構",
+        "children": [
+            {
+                "category_name": "柱"
+            },
+            {
+                "category_name": "梁"
+            },
+            {
+                "category_name": "板"
+            }
+        ]
+    },
+    {
+        "category_name": "景觀",
+        "children": [
+            {
+                "category_name": "設備"
+            }
+        ]
+    },
+    {
+        "category_name": "機電",
+        "children": [
+            {
+                "category_name": "給水",
+                "children": [
+                    {
+                        "category_name": "管配件"
+                    },
+                    {
+                        "category_name": "管附件"
+                    },
+                    {
+                        "category_name": "設備"
+                    }
+                ]
+            },
+            {
+                "category_name": "排水",
+                "children": [
+                    {
+                        "category_name": "管配件"
+                    },
+                    {
+                        "category_name": "管附件"
+                    },
+                    {
+                        "category_name": "設備"
+                    }
+                ]
+            },
+            {
+                "category_name": "空調",
+                "children": [
+                    {
+                        "category_name": "管配件"
+                    },
+                    {
+                        "category_name": "管附件"
+                    },
+                    {
+                        "category_name": "設備"
+                    }
+                ]
+            },
+            {
+                "category_name": "消防",
+                "children": [
+                    {
+                        "category_name": "管配件"
+                    },
+                    {
+                        "category_name": "管附件"
+                    },
+                    {
+                        "category_name": "設備"
+                    }
+                ]
+            },
+            {
+                "category_name": "動力",
+                "children": [
+                    {
+                        "category_name": "管配件"
+                    },
+                    {
+                        "category_name": "管附件"
+                    },
+                    {
+                        "category_name": "設備",
+                        "children": [
+                            {
+                                "category_name": "照明"
+                            },
+                            {
+                                "category_name": "發電機設備"
+                            },
+                            {
+                                "category_name": "弱電設備"
+                            }
+                        ]
+                    }
+                ]
+            },
+            {
+                "category_name": "瓦斯",
+                "children": [
+                    {
+                        "category_name": "設備"
+                    }
+                ]
+            },
+            {
+                "category_name": "其他"
+            }
+        ]
+    },
+    {
+        "category_name": "汙水",
+        "children": [
+            {
+                "category_name": "管配件"
+            },
+            {
+                "category_name": "管附件"
+            },
+            {
+                "category_name": "設備"
+            }
+        ]
+    },
+    {
+        "category_name": "捷運",
+        "children": [
+            {
+                "category_name": "設備"
+            }
+        ]
+    }
+]

+ 19 - 36
component-detail.php

@@ -10,13 +10,13 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
 	<script>
 		var isFavorite = false;
 		var revitVersion = "";
-		var searchURL = window.location.search;
-		searchURL = searchURL.substring(1, searchURL.length);
-		var name = decodeURIComponent(searchURL.split("&")[0].split("=")[1]);
-		var type = searchURL.split("&")[1].split("=")[1];
-		var parent = searchURL.split("&")[2].split("=")[1];
-		var typeInChinese = "";
-		var parentInChinese = "";
+
+		var url_href = window.location.href;
+		var url = new URL(url_href);
+		name = url.searchParams.get("object");
+		type = url.searchParams.get("type");
+		parent = url.searchParams.get("parent");
+
 		var userName = "<?php echo $_SESSION['name'] ?>";
 		var role = "<?php echo ($groupName); ?>";
 		var right = <?php echo ($right); ?>;
@@ -25,24 +25,11 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
 		var value = [];
 		var sizeValue = [];
 		pageHeader = "元件庫";
-
-		$.getJSON('./assets/equipmentTable2.json', function(data) {
-			for (var i = 0; i < data.length; i++) {
-				if (parent == data[i].category_code) {
-					parentInChinese = data[i].category_name;
-				}
-				for (var j = 0; j < data[i].children.length; j++) {
-					if (type == data[i].children[j].component_code) {
-						typeInChinese = data[i].children[j].component_name;
-					}
-				}
-			}
-		});
 	</script>
 	<style>
 		.hide-image {
 			display: none;
-			
+
 		}
 
 		.preview:hover .hide-image {
@@ -147,7 +134,7 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
 	<script>
 		/*Vue */
 		vm.mount('.body');
-addUserImage(userName.charAt(0),role);
+		addUserImage(userName.charAt(0), role);
 	</script>
 	<?php include("bim-support-body.html"); ?>
 	<script>
@@ -156,9 +143,9 @@ addUserImage(userName.charAt(0),role);
 				url: "./script/php/equipment_group_detail.php",
 				type: "GET",
 				data: {
-					type: typeInChinese,
+					type: type,
 					object: name,
-					parent: parentInChinese
+					parent: parent
 				},
 				contentType: "application/json",
 				dataType: "json"
@@ -191,16 +178,15 @@ addUserImage(userName.charAt(0),role);
 				$("#insertComponentName").text(name);
 
 				$.ajax({
-					url: "./assets/glb/Revit元件/Components/" + parentInChinese + "/" + typeInChinese + "/" + name + ".PNG",
+					url: "./assets/glb/Revit元件/Components/" + parent + "/" + type + "/" + name + ".PNG",
 					success: function() {
-						$("#2DImage").append("<img src='./assets/glb/Revit元件/Components/" + parentInChinese + "/" + typeInChinese + "/" + name + ".PNG' style='width: 100%; aspect-ratio: 1 / 1;'>")
+						$("#2DImage").append("<img src='./assets/glb/Revit元件/Components/" + parent + "/" + type + "/" + name + ".PNG' style='width: 100%; aspect-ratio: 1 / 1;'>")
 					},
 					error: function() {
 						$("#2DImage").append("<span>此元件沒有2D圖例</span>");
 					}
 				});
 
-
 			}).error(function(error) {
 				console.log(error.responseText);
 			});
@@ -209,8 +195,7 @@ addUserImage(userName.charAt(0),role);
 				url: "./script/php/addFavorite.php",
 				type: "GET",
 				data: {
-					type: typeInChinese,
-					object: name,
+					CheckFavorite: parent + "/" + type + "/" + name
 				},
 				contentType: "application/json",
 				dataType: "json"
@@ -232,12 +217,12 @@ addUserImage(userName.charAt(0),role);
 		for (var i = 0; i < jsonData.length; i++) {
 			for (var j = 0; j < jsonData[i].children.length; j++) {
 				$("a").each(function() {
-					if (jsonData[i].category_code == parent) {
-						if (jsonData[i].children[j].component_code == type) {
+					if (jsonData[i].category_name == parent) {
+						if (jsonData[i].children[j].component_name == type) {
 							var searchText = jsonData[i].children[j].component_name;
 							var found;
 
-							if ($(this).context.innerText == searchText && $(this).context.name == jsonData[i].category_code) {
+							if ($(this).context.innerText == searchText && $(this).context.name == jsonData[i].category_name) {
 								$(this).context.classList.add("highlight");
 								$(this).context.parentNode.parentNode.parentNode.classList.add("nav-expanded");
 							}
@@ -261,7 +246,7 @@ addUserImage(userName.charAt(0),role);
 					url: "./script/php/addFavorite.php",
 					type: "POST",
 					data: {
-						DelFavorite: parentInChinese + "/" + typeInChinese + "/" + name,
+						DelFavorite: parent + "/" + type + "/" + name,
 						username: userName
 					}
 				}).done(function(data) {
@@ -292,7 +277,7 @@ addUserImage(userName.charAt(0),role);
 					url: "./script/php/addFavorite.php",
 					type: "POST",
 					data: {
-						AddFavorite: parentInChinese + "/" + typeInChinese + "/" + name,
+						AddFavorite: parent + "/" + type + "/" + name,
 						username: userName,
 						revitVersion: revitVersion
 					}
@@ -324,8 +309,6 @@ addUserImage(userName.charAt(0),role);
 	</script>
 	<!-- Vendor -->
 
-
-
 	<script src="script/js/3Dpic-detail.js" type="module" async></script>
 
 </body>

+ 20 - 20
component-favorite.php

@@ -25,8 +25,7 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
 		var parent = [];
 		var type = [];
 		var object = [];
-		var typeInEnglish = [];
-		var parentInEnglish = [];
+
 	</script>
 </head>
 
@@ -78,7 +77,7 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
 	<script>
 		/*Vue */
 		vm.mount('.body');
-addUserImage(userName.charAt(0),role);
+		addUserImage(userName.charAt(0), role);
 	</script>
 	<?php include("bim-support-body.html"); ?>
 
@@ -117,22 +116,6 @@ addUserImage(userName.charAt(0),role);
 					object[i] = array[2];
 				}
 
-				$.getJSON('./assets/equipmentTable2.json', function(data) {
-					for (var k = 0; k < path.length; k++) {
-						for (var i = 0; i < data.length; i++) {
-							if (parent[k] == data[i].category_name) {
-								parentInEnglish[k] = data[i].category_code;
-							}
-							for (var j = 0; j < data[i].children.length; j++) {
-								if (type[k] == data[i].children[j].component_name) {
-									typeInEnglish[k] = data[i].children[j].component_code;
-								}
-							}
-						}
-					}
-				});
-
-
 				revitVersion = data.revitVersion;
 				for (var i = 0; i < data.year.length; i++) {
 					$("#revitVersion").append('<label><input type="checkbox" value=".' + data.year[i] + '" />   ' + data.year[i] + '</label> ');
@@ -164,6 +147,23 @@ addUserImage(userName.charAt(0),role);
 			}
 		});
 
+		$('#mgSelectAll').on('click', function(ev) {
+			ev.preventDefault();
+			var $this = $(this),
+				$label = $this.find('> span');
+			$checks = $("input[name='delCheck']")
+
+			if ($this.attr('data-all-selected')) {
+				$this.removeAttr('data-all-selected');
+				$checks.prop('checked', false).trigger('change');
+				$label.html($label.data('all-text'));
+			} else {
+				$this.attr('data-all-selected', 'true');
+				$checks.prop('checked', true).trigger('change');
+				$label.html($label.data('none-text'));
+			}
+		});
+
 		function DelFavorite() {
 			$.ajax({
 				url: "./script/php/addFavorite.php",
@@ -178,8 +178,8 @@ addUserImage(userName.charAt(0),role);
 				console.log(error);
 			});
 		}
-
 	</script>
+	<script src="./script/js/data-sort.js"></script>
 	<script src="script/js/3Dpic-favorite.js" type="module"></script>
 
 </body>

+ 28 - 74
component-list.php

@@ -11,57 +11,25 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
 		var rvtName = [];
 		var categoryTable = [];
 		var year = [];
-
 		//當選擇大項時,需要展示所有'細項分類'內的元件
 		var category = [];
-		var categoryInEnglish = [];
-
 		//現在的細項分類
 		var type = "";
-		var typeInChinese = "";
-
 		//現在的大項分類
 		var parent = "";
-		var parentInChinese = "";
-
-		//類別的中英文字典,中文是為了檔案路徑
-		var allTypeInEnglish = [];
-		var allTypeInChinese = [];
-		var allParentInEnglish = [];
-		var allParentInChinese = [];
 
 		var userName = "<?php echo $_SESSION['name'] ?>";
 		var role = "<?php echo ($groupName); ?>";
 		var right = <?php echo ($right); ?>;
-		var searchURL = window.location.search;
 
-		searchURL = searchURL.substring(1, searchURL.length);
-		if (searchURL != "") {
-			//類別選擇細項
-			if (searchURL.split("&") != undefined && searchURL.split("&")[1] != undefined) {
-				type = searchURL.split("&")[0].split("=")[1];
-				parent = searchURL.split("&")[1].split("=")[1];
-			//類別選擇大項
-			} else if (searchURL.split("&") != undefined && searchURL.split("&")[1] == undefined) {
-				parent = searchURL.split("&")[0].split("=")[1];
-			}
-		}
+		var url_href = window.location.href;
+		var url = new URL(url_href);
+		url.searchParams.get("type") == null ? type = "" : type = url.searchParams.get("type");
+		parent = url.searchParams.get("parent");
 
 		var $grid;
 
 		pageHeader = "元件庫";
-
-		//匯入大細項類別的中英文字典
-		$.getJSON('./assets/equipmentTable2.json', function(data) {
-			for (var i = 0; i < data.length; i++) {
-				allParentInEnglish.push(data[i].category_code);
-				allParentInChinese.push(data[i].category_name);
-				for (var j = 0; j < data[i].children.length; j++) {
-					allTypeInEnglish.push(data[i].children[j].component_code);
-					allTypeInChinese.push(data[i].children[j].component_name);
-				}
-			}
-		});
 	</script>
 </head>
 
@@ -107,34 +75,20 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
 	<script>
 		/*Vue */
 		vm.mount('.body');
-addUserImage(userName.charAt(0),role);
+		addUserImage(userName.charAt(0), role);
 	</script>
 
 	<?php include("bim-support-body.html"); ?>
 	<script type="application/javascript">
 		$(function() {
 
-			//現在大項的中文
-			for (var i = 0; i < allParentInEnglish.length; i++) {
-				if (allParentInEnglish[i] == parent) {
-					parentInChinese = allParentInChinese[i];
-				}
-			}
-
-			//現在細項的中文
-			for (var i = 0; i < allTypeInEnglish.length; i++) {
-				if (allTypeInEnglish[i] == type) {
-					typeInChinese = allTypeInChinese[i];
-				}
-			}
-
 			//撈現在類別內的元件
 			$.ajax({
 				url: "./script/php/equipment_group.php",
 				type: "GET",
 				data: {
-					type: typeInChinese,
-					parent: parentInChinese
+					type: type,
+					parent: parent
 				},
 				contentType: "application/json",
 				dataType: "json"
@@ -143,25 +97,22 @@ addUserImage(userName.charAt(0),role);
 				rvtName = data['rvtName'];
 				category = data["category"];
 
-				//若類別選大項,需要列所有細項的元件,因此需要所有元件的細項名稱
-				for (var i = 0; i < category.length; i++) {
-					for (var j = 0; j < allTypeInChinese.length; j++) {
-						if (category[i] == allTypeInChinese[j]) {
-							categoryInEnglish[i] = allTypeInEnglish[j];
-						}
-					}
-				}
-
 				//一開始進入BIM元件庫顯示
-				if (searchURL == "") {
+				if (url.search == "") {
 					$("#content").append("<h1 style='color: red;'>注意!BIM元件庫需配合BIM程式庫中的拖放元件API使用!</h1>");
 					$("#content").append("<h3>請選擇左方類別以搜尋元件,搜尋到需要的元件請點擊加入清單按鈕</h3>");
 					$("#content").append("<h3>到BIM程式庫下載拖放元件API,並參考操作方式以進行元件放置動作</h3>");
 					$("#content").css("padding", "0");
 					$("#content").css("text-align", "center");
-				}
 
-				if (!(type == "" && parent == "")) {
+					$("a").each(function() {
+						if ($(this).context.name != "" && $(this).context.className == "menu-item" && $(this).context.name != parent) {
+							//其他大項類別不要產生ul
+							$(this).closest("ul").remove();
+						}
+					});
+
+				} else {
 					$.when(initThreeJS()).then(function() {
 
 						$grid = $("#content").isotope({
@@ -170,7 +121,7 @@ addUserImage(userName.charAt(0),role);
 						});
 
 						//若選到細項,該細項內沒有元件檔案
-						if ($("#content").children().length == 0 && searchURL != "") {
+						if ($("#content").children().length == 0) {
 							$("#content").append("<h3>此類別沒有元件檔案</h3>");
 							$("#content").css("padding", "0");
 							$("#content").css("text-align", "center");
@@ -214,38 +165,41 @@ addUserImage(userName.charAt(0),role);
 			for (var i = 0; i < jsonData.length; i++) {
 				for (var j = 0; j < jsonData[i].children.length; j++) {
 					$("a").each(function() {
-						if (jsonData[i].category_code == parent) {
+
+						if (jsonData[i].category_name == parent) {
 							//選到的是細項類別
-							if (jsonData[i].children[j].component_code == type) {
+							if (jsonData[i].children[j].component_name == type) {
 								var searchText = jsonData[i].children[j].component_name;
 								var found;
 
-								if ($(this).context.innerText == searchText && $(this).context.name == jsonData[i].category_code) {
+								if ($(this).context.innerText == searchText && $(this).context.name == jsonData[i].category_name) {
 									$(this).context.classList.add("highlight");
 									$(this).context.parentNode.parentNode.parentNode.classList.add("nav-expanded");
 								}
 								//選到的是大項類別
 							} else if (type == "") {
-								var searchText = parentInChinese;
+								var searchText = parent;
 								var found;
-
-								if ($(this).context.innerText == searchText && $(this).context.name == jsonData[i].category_code) {
+								if ($(this).context.innerText == searchText && $(this).context.name == jsonData[i].category_name) {
 									if (!$(this).context.classList.contains("highlight")) {
 										$(this).context.classList.add("highlight");
 										$(this).context.setAttribute("style", "background: #0088cc");
 									} else {
 										$(this).context.removeAttribute("href");
 									}
-
+								} else if ($(this).context.name != "" && $(this).context.className == "menu-item" && $(this).context.name != parent) {
+									//其他大項類別不要產生ul
+									$(this).closest("ul").remove();
 								}
+
 							}
 						}
-
 					});
 				}
 			}
 
 
+
 		});
 	</script>
 	<script src="./script/js/data-sort.js"></script>

+ 1 - 1
script/js/3Dpic-detail.js

@@ -62,7 +62,7 @@
 		scene.add(grid);
 
 		var loader = new GLTFLoader();
-		loader.setPath("./assets/glb/Revit元件/Components/" + parentInChinese + "/" + typeInChinese + "/");
+		loader.setPath("./assets/glb/Revit元件/Components/" + parent + "/" + type + "/");
 
 		loader.load(name + ".glb", function (gltf) {
 			var mroot = gltf.scene;

+ 5 - 7
script/js/3Dpic-favorite.js

@@ -56,7 +56,7 @@
 			element.appendChild(sceneElement);
 
 			const aImg = document.createElement('a');
-			aImg.setAttribute("href", "component-detail.php?object=" + object[i] + "&type=" + typeInEnglish[i] + "&parent=" + parentInEnglish[i]);
+			aImg.setAttribute("href", "component-detail.php?object=" + object[i] + "&type=" + type[i] + "&parent=" + parent[i]);
 			sceneElement.appendChild(aImg);
 
 			const img = document.createElement('img');
@@ -73,7 +73,7 @@
 
 			const h5 = document.createElement('a');
 			h5.innerText = object[i];
-			h5.setAttribute("href", "component-detail.php?object=" + object[i] + "&type=" + typeInEnglish[i] + "&parent=" + parentInEnglish[i]);
+			h5.setAttribute("href", "component-detail.php?object=" + object[i] + "&type=" + type[i] + "&parent=" + parent[i]);
 			h5.style = "padding-bottom: 0px;"
 			thumbnail.appendChild(h5);
 
@@ -147,11 +147,9 @@
 			controls.maxDistance = 10;
 			controls.maxPolarAngle = 0.5 * Math.PI;
 			controls.autoRotate = true;
-			controls.mouseButtons = {
-				LEFT: '',
-				TOP: '',
-				RIGHT: ''
-			}
+			controls.enableZoom = false;
+			controls.enableRotate = false;
+			controls.enablePan = false;
 			scene.userData.controls = controls;
 
 

+ 5 - 5
script/js/3Dpic.js

@@ -45,7 +45,7 @@
 			if (type != "")
 				aImg.setAttribute("href", "component-detail.php?object=" + rvtName[i] + "&type=" + type + "&parent=" + parent);
 			else
-				aImg.setAttribute("href", "component-detail.php?object=" + rvtName[i] + "&type=" + categoryInEnglish[i] + "&parent=" + parent);
+				aImg.setAttribute("href", "component-detail.php?object=" + rvtName[i] + "&type=" + category[i] + "&parent=" + parent);
 			
 
 
@@ -66,7 +66,7 @@
 			if (type != "")
 				h5.setAttribute("href", "component-detail.php?object=" + rvtName[i] + "&type=" + type + "&parent=" + parent);
 			else
-				h5.setAttribute("href", "component-detail.php?object=" + rvtName[i] + "&type=" + categoryInEnglish[i] + "&parent=" + parent);
+				h5.setAttribute("href", "component-detail.php?object=" + rvtName[i] + "&type=" + category[i] + "&parent=" + parent);
 			
 			thumbnail.appendChild(h5);
 
@@ -143,10 +143,10 @@
 
 			//change to new directory
 			var loader = new GLTFLoader();
-			if (typeInChinese != "")
-				loader.setPath("./assets/glb/Revit元件/Components/" + parentInChinese + "/" + typeInChinese + "/");
+			if (type != "")
+				loader.setPath("./assets/glb/Revit元件/Components/" + parent + "/" + type + "/");
 			else
-				loader.setPath("./assets/glb/Revit元件/Components/" + parentInChinese + "/" + category[i] + "/");
+				loader.setPath("./assets/glb/Revit元件/Components/" + parent + "/" + category[i] + "/");
 			var name = rvtName[i] + ".glb";
 
 			loader.load(name, function (gltf) {

+ 4 - 14
script/js/global.js

@@ -420,7 +420,7 @@ vm.component('equipment-list', {
     <div class="widget-content">
         <nav id="menu" class="nav-main" role="navigation">
             <ul class="nav nav-main">
-                <special-li v-for="item in jsonData" v-bind:name="item.category_name" v-bind:children="item.children" v-bind:parent="item.category_code"></special-li>     
+                <special-li v-for="item in jsonData" v-bind:name="item.category_name" v-bind:children="item.children" v-bind:parent="item.category_name"></special-li>     
                 <hr class="separator" />
                 <li>
                     <a v-bind:href="url" class="menu-item"><i class="fa fa-gears"></i>清單列表</a>
@@ -439,7 +439,7 @@ vm.component('special-li', {
     <li class="nav-parent">
         <a class="dropdown-btn" v-bind:href="hrefLink(parent)" v-bind:name="parent">{{name}}</a>
         <ul class="nav nav-children" style="background: inherit; padding-left: 15px;">
-            <special-li2 v-for="item in children" v-bind:href="item.component_code" v-bind:name="item.component_name" v-bind:parent="parent"></special-li2>
+            <special-li2 v-for="item in children" v-bind:href="item.component_name" v-bind:name="item.component_name" v-bind:parent="parent"></special-li2>
         </ul>
     </li>
     `,
@@ -468,8 +468,8 @@ vm.component('special-li2', {
         parent: String
     },
     methods: {
-        hrefLink(code, parent) {
-            return 'component-list.php?type=' + code + '&parent=' + parent;
+        hrefLink(name, parent) {
+            return 'component-list.php?type=' + name + '&parent=' + parent;
         }
     }
 });
@@ -497,16 +497,6 @@ vm.component('api-list', {
         </ul>
     </div>
     <hr class="separator" />
-    <div class="widget-header clearfix">
-        <h6 class="title pull-left mt-xs">專案</h6>                    
-    </div>
-    <div class="widget-content">
-        <ul class="mg-folders">
-            <inner-menu-li href="api-list.php?type=專案(果林地下汙水管線建置系統)" name="菓林地下汙水管線建置系統"></inner-menu-li>
-            <inner-menu-li href="api-list.php?type=專案(CF管線點位調查)" name="CF管線點位調查"></inner-menu-li>                                       
-        </ul>
-    </div>
-    <hr class="separator" />
     <div class="widget-header clearfix">
         <h6 class="title pull-left mt-xs">其他</h6>                    
     </div>

+ 2 - 2
script/php/addFavorite.php

@@ -35,8 +35,8 @@ if (isset($_POST["AddFavorite"])) {
                     END
                 END";
     sqlsrv_query($conn, $sql);
-} else if (isset($_GET["object"])) {
-    $favorite = $_GET["type"] . "/" . $_GET["object"];
+} else if (isset($_GET["CheckFavorite"])) {
+    $favorite = $_GET["CheckFavorite"];
     $sql = "SELECT * FROM [BIMComponents].[dbo].[Favorite_Table] Where [favorite] = '" . $favorite . "' AND [user_name] = '" . $_SESSION["name"] . "';";
     $i = 0;
     $fetchResult = sqlsrv_query($conn, $sql);

+ 18 - 0
script/php/upload_component.php

@@ -0,0 +1,18 @@
+<?php
+
+$uploads_dir = '../../assets/glb/Revit元件/'; //Directory to save the file that comes from client application.
+
+if(isset($_POST["filepath"])){
+    $filepath = $_POST["filepath"];
+    $filename = $_POST["filename"];
+    
+    $originalFilepath = $uploads_dir.$filename;
+    $destinationFilepath = $uploads_dir.$filepath."/".$filename;
+    rename($originalFilepath, $destinationFilepath);
+
+}else if ($_FILES["file"]["error"] == UPLOAD_ERR_OK) {
+    $tmp_name = $_FILES["file"]["tmp_name"];
+    $name = $_FILES["file"]["name"];
+    move_uploaded_file($tmp_name, "$uploads_dir/$name");
+}
+?>