diff --git a/.github/prompts/exportCSV.prompt.md b/.github/prompts/exportCSV.prompt.md new file mode 100644 index 0000000..7adc4d0 --- /dev/null +++ b/.github/prompts/exportCSV.prompt.md @@ -0,0 +1,29 @@ +--- +mode: agent +--- +# API 路徑整理與引用檢查規則 + +## 目標 +- 針對 apis 目錄下所有子資料夾(如 account、alert、asset、building、dashboard、energy、forge、graph、history、login、operation、productSetting、system)的 api.js 與 index.js 檔案,完整追蹤 API 路徑的實際引用情形。 +- 追蹤流程: + 1. 先在 api.js 找出所有 API 路徑常數(如 `export const GET_XXX_API = '/path'`)。 + 2. 在 index.js 檔案確認這些常數有被 import 並包裝成 API function(如 `getXXX`)。 + 3. 再全專案搜尋這些 API function 是否有被其他檔案 import 並呼叫。 +- 產生一份 csv 報表,格式如下: + +| API 路徑 | 定義常數 | API function | 是否有被引用 | +|----------|----------|--------------|-------------| +| /user | GET_USER_API | getUser | Y | +| /admin | GET_ADMIN_API | getAdmin | N | + +## 詳細規則 +- 處理 apis 目錄下所有子資料夾的 api.js 與 index.js 檔案。 +- API 路徑的定義需涵蓋 get/post/put/delete 等(如 `export const API = '/path'`)。 +- 只統計有被 index.js import 並包裝成 function 的 API 路徑。 +- 檢查 function 是否有被其他檔案 import 並呼叫(排除 apis 目錄本身)。 +- 匹配到的檔案需記錄完整路徑,可多個檔案以分號分隔。 +- 統計結果輸出為 csv 檔案。 + +## 輸出 +- 檔名:api_usage_report.csv +- 欄位:API 路徑, 定義常數, API function, 是否有被引用, \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1b86ebb..f5365e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "echarts": "^5.4.3", "jquery-ui": "^1.14.1", "json-schema-generator": "^2.0.6", + "leaflet": "^1.9.4", "mqtt": "^5.10.3", "pinia": "^2.1.7", "requirejs": "^2.3.6", @@ -3350,6 +3351,12 @@ "node": ">=0.10.0" } }, + "node_modules/leaflet": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.9.4.tgz", + "integrity": "sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==", + "license": "BSD-2-Clause" + }, "node_modules/libphonenumber-js": { "version": "1.10.60", "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.60.tgz", diff --git a/package.json b/package.json index abef3dc..a0fcb0c 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "dev": "vite", "build": "vite build", - "preview": "vite preview" + "preview": "vite preview", + "build:staging": "vite build --mode staging" }, "dependencies": { "@ant-design/icons-vue": "^7.0.1", @@ -23,6 +24,7 @@ "echarts": "^5.4.3", "jquery-ui": "^1.14.1", "json-schema-generator": "^2.0.6", + "leaflet": "^1.9.4", "mqtt": "^5.10.3", "pinia": "^2.1.7", "requirejs": "^2.3.6", diff --git a/public/CviLux_globalmap.jpg b/public/CviLux_globalmap.jpg new file mode 100644 index 0000000..1c323a1 Binary files /dev/null and b/public/CviLux_globalmap.jpg differ diff --git a/public/CviLux_globalmap.png b/public/CviLux_globalmap.png new file mode 100644 index 0000000..e2b8c70 Binary files /dev/null and b/public/CviLux_globalmap.png differ diff --git a/src/apis/asset/api.js b/src/apis/asset/api.js index 94f08e1..234d100 100644 --- a/src/apis/asset/api.js +++ b/src/apis/asset/api.js @@ -34,4 +34,6 @@ export const GET_ASSET_ELECTYPE_API = `/AssetManage/GetElecType`; export const POST_ASSET_ELECTYPE_API = `/AssetManage/SaveElecType`; export const DELETE_ASSET_ELECTYPE_API = `/AssetManage/DeleteElecType`; -export const POST_ASSET_ELEC_SETTING_API = `/AssetManage/SaveAssetSetting`; \ No newline at end of file +export const POST_ASSET_ELEC_SETTING_API = `/AssetManage/SaveAssetSetting`; + +export const POST_ASSET_MQTT_PUBLISH_API = `/api/mqtt/publish`; \ No newline at end of file diff --git a/src/apis/asset/index.js b/src/apis/asset/index.js index adb52d1..3787c38 100644 --- a/src/apis/asset/index.js +++ b/src/apis/asset/index.js @@ -26,13 +26,14 @@ import { POST_ASSET_ELECTYPE_API, DELETE_ASSET_ELECTYPE_API, POST_ASSET_ELEC_SETTING_API, + POST_ASSET_MQTT_PUBLISH_API, } from "./api"; import instance from "@/util/request"; import apihandler from "@/util/apiHandler"; import { object } from "yup"; export const getAssetMainList = async (building_guid) => { - const res = await instance.post(GET_ASSET_MAIN_LIST_API,{building_guid}); + const res = await instance.post(GET_ASSET_MAIN_LIST_API, { building_guid }); return apihandler(res.code, res.data, { msg: res.msg, @@ -49,12 +50,17 @@ export const deleteAssetMainItem = async (id) => { }); }; -export const postAssetMainList = async ({ id, system_key, system_value, building_guid }) => { +export const postAssetMainList = async ({ + id, + system_key, + system_value, + building_guid, +}) => { const res = await instance.post(POST_ASSET_MAIN_LIST_API, { id, system_key, system_value, - building_guid + building_guid, }); return apihandler(res.code, res.data, { @@ -241,6 +247,9 @@ export const postDeviceItem = async ({ decimals, is_bool, is_link, + show_event_switch_btn, + event_switch_on_message, + event_switch_off_message, }) => { const res = await instance.post(POST_ASSET_DEVICE_ITEM_API, { id, @@ -250,6 +259,9 @@ export const postDeviceItem = async ({ decimals, is_bool, is_link, + show_event_switch_btn, + event_switch_on_message, + event_switch_off_message, }); return apihandler(res.code, res.data, { @@ -335,3 +347,15 @@ export const postAssetElecSetting = async (formData) => { code: res.code, }); }; + +export const postMQTTpublish = async ({ Topic, Payload }) => { + const res = await instance.post(POST_ASSET_MQTT_PUBLISH_API, { + Topic, + Payload, + }); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; diff --git a/src/apis/building/api.js b/src/apis/building/api.js index b71612b..7692b1a 100644 --- a/src/apis/building/api.js +++ b/src/apis/building/api.js @@ -4,3 +4,4 @@ export const DELETE_BUILDING_API = `/AssetManage/DeleteBuilding`; export const GET_AUTHPAGE_API = `/api/GetUsrFroList`; export const GET_SUBAUTHPAGE_API = `/api/Device/GetMainSub`; export const GET_ALL_DEVICE_API = `/api/Device/GetAllDevice`; +export const GET_FUNCTION_LIST_API = `/api/function/get-function-list`; diff --git a/src/apis/building/index.js b/src/apis/building/index.js index e726f1e..60da8fc 100644 --- a/src/apis/building/index.js +++ b/src/apis/building/index.js @@ -5,6 +5,7 @@ import { GET_AUTHPAGE_API, GET_SUBAUTHPAGE_API, GET_ALL_DEVICE_API, + GET_FUNCTION_LIST_API, } from "./api"; import instance from "@/util/request"; import apihandler from "@/util/apiHandler"; @@ -39,9 +40,9 @@ export const deleteBuildings = async (building_guid) => { }); }; -export const getAuth = async (lang) => { - const res = await instance.post(GET_AUTHPAGE_API, { - lang, +export const getAuth = async (building_id) => { + const res = await instance.get(GET_FUNCTION_LIST_API, { + params: { building_id }, }); return apihandler(res.code, res.data, { msg: res.msg, @@ -50,7 +51,7 @@ export const getAuth = async (lang) => { }; export const getAllSysSidebar = async (building_guid) => { - const res = await instance.post(GET_SUBAUTHPAGE_API, {building_guid}); + const res = await instance.post(GET_SUBAUTHPAGE_API, { building_guid }); return apihandler(res.code, res.data, { msg: res.msg, code: res.code, diff --git a/src/apis/dashboard/api.js b/src/apis/dashboard/api.js index 1d914f6..9be814d 100644 --- a/src/apis/dashboard/api.js +++ b/src/apis/dashboard/api.js @@ -10,4 +10,8 @@ export const GET_DASHBOARD_PRODUCT_HISTORY_API = `/SituationRoom/GetProductionHi export const GET_DASHBOARD_ENERGY_INFO_API = `api/dashboard/GetEnergyInfo` export const GET_DASHBOARD_ENERGY_COST_API = `api/dashboard/GetEnergyCost` -export const GET_DASHBOARD_ALARMOPERATION_INFO_API = `api/dashboard/GetAlarmOperationInfo` \ No newline at end of file +export const GET_DASHBOARD_ALARMOPERATION_INFO_API = `api/dashboard/GetAlarmOperationInfo` + +export const GET_DASHBOARD_2D3DINFO_API = `api/setting/visual/query` +export const POST_DASHBOARD_2D3DINFO_API = `api/setting/visual/update` + diff --git a/src/apis/dashboard/index.js b/src/apis/dashboard/index.js index 4ed95e8..236610e 100644 --- a/src/apis/dashboard/index.js +++ b/src/apis/dashboard/index.js @@ -11,6 +11,8 @@ import { GET_DASHBOARD_ENERGY_INFO_API, GET_DASHBOARD_ENERGY_COST_API, GET_DASHBOARD_ALARMOPERATION_INFO_API, + GET_DASHBOARD_2D3DINFO_API, + POST_DASHBOARD_2D3DINFO_API } from "./api"; import instance from "@/util/request"; import apihandler from "@/util/apiHandler"; @@ -176,3 +178,22 @@ export const getAlarmOperationInfo = async (building_guid) => { code: res.code, }); }; + +export const getDashboard2D3D = async (BuildingId) => { + const res = await instance.post(GET_DASHBOARD_2D3DINFO_API, { + BuildingId}); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; + +export const posttDashboard2D3D = async (formData) => { + const res = await instance.post(POST_DASHBOARD_2D3DINFO_API, formData); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; \ No newline at end of file diff --git a/src/apis/energy/api.js b/src/apis/energy/api.js index 9f427a0..ae7c5bb 100644 --- a/src/apis/energy/api.js +++ b/src/apis/energy/api.js @@ -1,6 +1,6 @@ export const GET_REALTIME_DIST_API = `/api/Energe/GetRealTimeDistribution`; export const GET_ELECUSE_DAY_API = `/api/Energe/GetElecUseDay`; -export const GET_TAI_POWER_API = `/api/Energe/GetTaipower`; +export const GET_TAI_POWER_API = `/api/energy-manager/power-usage`; export const GET_SIDEBAR_API = `/api/GetSideBar`; export const GET_SEARCH_API = `/api/Energe/GetFilter`; diff --git a/src/apis/headquarters/api.js b/src/apis/headquarters/api.js new file mode 100644 index 0000000..517ce4f --- /dev/null +++ b/src/apis/headquarters/api.js @@ -0,0 +1,6 @@ +export const GET_SITES_SYSTEM_STATUS_API = `/api/monitoring/sites-system-status`; +export const GET_SITES_SYSTEM_ENERGY_COST_RANK_API = `/api/energy-manager/all-site/energy-cost-rank`; +export const GET_SITES_SYSTEM_ENERGY_COST_TREND_API = `/api/energy-manager/all-site/energy-cost-trend`; +export const GET_SITES_SYSTEM_ENERGY_COST_GROWTH_API = `/api/energy-manager/all-site/energy-cost-growth-rate`; + + diff --git a/src/apis/headquarters/index.js b/src/apis/headquarters/index.js new file mode 100644 index 0000000..8cd7485 --- /dev/null +++ b/src/apis/headquarters/index.js @@ -0,0 +1,44 @@ +import { + GET_SITES_SYSTEM_STATUS_API, + GET_SITES_SYSTEM_ENERGY_COST_RANK_API, + GET_SITES_SYSTEM_ENERGY_COST_TREND_API, + GET_SITES_SYSTEM_ENERGY_COST_GROWTH_API, +} from "./api"; +import instance from "@/util/request"; +import apihandler from "@/util/apihandler"; + +export const getSystemStatus = async (building_ids) => { + const res = await instance.post(GET_SITES_SYSTEM_STATUS_API, building_ids); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; + +export const getSystemEnergyCostRank = async (building_ids) => { + const res = await instance.post(GET_SITES_SYSTEM_ENERGY_COST_RANK_API, building_ids); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; + +export const getSystemEnergyCostTrend = async (building_ids) => { + const res = await instance.post(GET_SITES_SYSTEM_ENERGY_COST_TREND_API, building_ids); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +} + +export const getSystemEnergyCostGrowth = async (building_ids) => { + const res = await instance.get(GET_SITES_SYSTEM_ENERGY_COST_GROWTH_API, building_ids); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +} \ No newline at end of file diff --git a/src/apis/history/api.js b/src/apis/history/api.js index c0fd361..981968e 100644 --- a/src/apis/history/api.js +++ b/src/apis/history/api.js @@ -4,6 +4,10 @@ export const GET_HISTORY_SIDEBAR_API = `/api/History/GetDeviceInfo`; export const GET_HISTORY_POINT_API = `/api/History/GetAllDevPoi`; export const GET_HISTORY_DATA_API = `/api/History/GetHistoryData`; export const GET_HISTORY_EXPORT_API = `/api/ExportHistoryExcel`; +export const GET_HISTORY_EXPORT_REPORT_API = `/api/History/GetHistoryExcelReport`; +export const GET_HISTORY_EXPORT_CURVE_API = `/api/History/GetHistoricalCurveExcelReport`; +export const GET_HISTORY_EXPORT_QUICK_API = `/api/History/GetQuickMeteringExcelReport`; +export const GET_HISTORY_EXPORT_CLASS_API = `/api/History/GetElectricityClassificationExcelReport`; export const GET_HISTORY_FAVORITE_API = `/api/History/GetHistoryFavorite`; export const POST_HISTORY_FAVORITE_API = `/api/History/SaveHistoryFavorite`; diff --git a/src/apis/history/index.js b/src/apis/history/index.js index c393159..5bc8564 100644 --- a/src/apis/history/index.js +++ b/src/apis/history/index.js @@ -7,6 +7,10 @@ import { DELETE_HISTORY_FAVORITE_API, UPDATE_HISTORY_FAVORITE_API, GET_HISTORY_EXPORT_API, + GET_HISTORY_EXPORT_REPORT_API, + GET_HISTORY_EXPORT_CURVE_API, + GET_HISTORY_EXPORT_QUICK_API, + GET_HISTORY_EXPORT_CLASS_API, } from "./api"; import instance, { fileInstance } from "@/util/request"; import apihandler from "@/util/apiHandler"; @@ -81,7 +85,52 @@ export const getHistoryData = async ({ }; export const getHistoryExportData = async ({ + Start_date, + End_date, + Start_time, + End_time, + Device_list, + Points, Type, + table_type, +}) => { + const api = + parseInt(table_type) === 1 + ? GET_HISTORY_EXPORT_CURVE_API + : parseInt(table_type) === 2 + ? GET_HISTORY_EXPORT_QUICK_API + : parseInt(table_type) === 3 + ? GET_HISTORY_EXPORT_CLASS_API + : GET_HISTORY_EXPORT_API; + + const res = await fileInstance.post( + api, + { + Start_date: Start_date, + End_date: End_date, + Start_time: Start_time, + End_time: End_time, + Points: Array.isArray(Points) ? Points : [Points], + Device_list: Array.isArray(Device_list) ? Device_list : [Device_list], + Type: parseInt(Type), + Building_tag_list: [...new Set(Device_list.map((d) => d.split("_")[1]))], + table_type: parseInt(table_type), + }, + { responseType: "blob" } + ); + + return apihandler( + res.code, + res, + { + msg: res.msg, + code: res.code, + }, + downloadExcel + ); +}; + +export const getHistoryExportReport = async ({ Start_date, End_date, Start_time, @@ -89,19 +138,8 @@ export const getHistoryExportData = async ({ Device_list, Points, }) => { - /* - { - Type, - Start_date, - End_date, - Start_time, - End_time, - Device_list, - Points, - } - */ const res = await fileInstance.post( - GET_HISTORY_EXPORT_API, + GET_HISTORY_EXPORT_REPORT_API, { // ...exportContent, Start_date: Start_date, @@ -110,7 +148,6 @@ export const getHistoryExportData = async ({ End_time: End_time, Points: Array.isArray(Points) ? Points : [Points], Device_list: Array.isArray(Device_list) ? Device_list : [Device_list], - Type: parseInt(Type), Building_tag_list: [...new Set(Device_list.map((d) => d.split("_")[1]))], }, { responseType: "blob" } diff --git a/src/apis/system/api.js b/src/apis/system/api.js index a57d55f..6fb0368 100644 --- a/src/apis/system/api.js +++ b/src/apis/system/api.js @@ -1,3 +1,4 @@ export const GET_SYSTEM_FLOOR_LIST_API = `/api/Device/GetFloor`; export const GET_SYSTEM_DEVICE_LIST_API = `/api/Device/GetDeviceList`; -export const GET_SYSTEM_REALTIME_API = `/api/Device/GetRealTimeData`; \ No newline at end of file +export const GET_SYSTEM_REALTIME_API = `/api/Device/GetRealTimeData`; +export const GET_SYSTEM_DEVICE_POWER_TOGGLE_API = `/api/device-events/power-toggle`; \ No newline at end of file diff --git a/src/apis/system/index.js b/src/apis/system/index.js index 787689d..2ff65f4 100644 --- a/src/apis/system/index.js +++ b/src/apis/system/index.js @@ -2,6 +2,7 @@ import { GET_SYSTEM_FLOOR_LIST_API, GET_SYSTEM_DEVICE_LIST_API, GET_SYSTEM_REALTIME_API, + GET_SYSTEM_DEVICE_POWER_TOGGLE_API } from "./api"; import instance from "@/util/request"; import apihandler from "@/util/apiHandler"; @@ -42,3 +43,16 @@ export const getSystemRealTime = async (device_list) => { code: res.code, }); }; + +export const toggleDevicePower = async ({topic_publish, device_item_id,new_value}) => { + const res = await instance.post(GET_SYSTEM_DEVICE_POWER_TOGGLE_API, { + topic_publish, + device_item_id, + new_value, + }); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +} diff --git a/src/assets/base.css b/src/assets/base.css index 09140d1..545b288 100644 --- a/src/assets/base.css +++ b/src/assets/base.css @@ -58,6 +58,7 @@ box-sizing: border-box; margin: 0; font-weight: normal; + scrollbar-color: auto !important; } body { diff --git a/src/components/alarm/AlarmDrawer.vue b/src/components/alarm/AlarmDrawer.vue index 7363e00..274c122 100644 --- a/src/components/alarm/AlarmDrawer.vue +++ b/src/components/alarm/AlarmDrawer.vue @@ -36,7 +36,7 @@ const toggleErrIcon = () => {