From 5207eec99a9fe4c270a8f21ef9ba8a4f4a54b75b Mon Sep 17 00:00:00 2001 From: "sas.fajri" Date: Thu, 7 May 2026 16:20:02 +0700 Subject: [PATCH] Add dashboard user MCU menu --- .../dashboard-user-mcu/api/dashboard_user.js | 43 ++++ .../components/oneDashboardUserMcuDetail.vue | 194 ++++++++++++++++++ .../components/oneDashboardUserMcuList.vue | 115 +++++++++++ test/vuex/dashboard-user-mcu/index.php | 66 ++++++ .../modules/dashboard_user.js | 132 ++++++++++++ test/vuex/dashboard-user-mcu/store.js | 12 ++ 6 files changed, 562 insertions(+) create mode 100644 test/vuex/dashboard-user-mcu/api/dashboard_user.js create mode 100644 test/vuex/dashboard-user-mcu/components/oneDashboardUserMcuDetail.vue create mode 100644 test/vuex/dashboard-user-mcu/components/oneDashboardUserMcuList.vue create mode 100644 test/vuex/dashboard-user-mcu/index.php create mode 100644 test/vuex/dashboard-user-mcu/modules/dashboard_user.js create mode 100644 test/vuex/dashboard-user-mcu/store.js diff --git a/test/vuex/dashboard-user-mcu/api/dashboard_user.js b/test/vuex/dashboard-user-mcu/api/dashboard_user.js new file mode 100644 index 0000000..5bbdccc --- /dev/null +++ b/test/vuex/dashboard-user-mcu/api/dashboard_user.js @@ -0,0 +1,43 @@ +const URL = (window.BASE_URL ? window.BASE_URL : "") + "/one-api/dashboard_mcu/user/"; + +async function post(endpoint, prm) { + try { + var resp = await axios.post(URL + endpoint, prm) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + } + } + return resp.data + } catch (e) { + return { + status: "ERR", + message: e.message + } + } +} + +export async function save(prm) { + return post('save', prm) +} + +export async function reset_password(prm) { + return post('reset_password', prm) +} + +export async function assign_project(prm) { + return post('assign_project', prm) +} + +export async function remove_project(prm) { + return post('remove_project', prm) +} + +export async function search_project(prm) { + return post('search_project', prm) +} + +export async function search(prm) { + return post('search', prm) +} diff --git a/test/vuex/dashboard-user-mcu/components/oneDashboardUserMcuDetail.vue b/test/vuex/dashboard-user-mcu/components/oneDashboardUserMcuDetail.vue new file mode 100644 index 0000000..4f3c578 --- /dev/null +++ b/test/vuex/dashboard-user-mcu/components/oneDashboardUserMcuDetail.vue @@ -0,0 +1,194 @@ + + + diff --git a/test/vuex/dashboard-user-mcu/components/oneDashboardUserMcuList.vue b/test/vuex/dashboard-user-mcu/components/oneDashboardUserMcuList.vue new file mode 100644 index 0000000..f5f09b4 --- /dev/null +++ b/test/vuex/dashboard-user-mcu/components/oneDashboardUserMcuList.vue @@ -0,0 +1,115 @@ + + + diff --git a/test/vuex/dashboard-user-mcu/index.php b/test/vuex/dashboard-user-mcu/index.php new file mode 100644 index 0000000..8871616 --- /dev/null +++ b/test/vuex/dashboard-user-mcu/index.php @@ -0,0 +1,66 @@ + + + + + + + + Dashboard User MCU + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + diff --git a/test/vuex/dashboard-user-mcu/modules/dashboard_user.js b/test/vuex/dashboard-user-mcu/modules/dashboard_user.js new file mode 100644 index 0000000..86079c0 --- /dev/null +++ b/test/vuex/dashboard-user-mcu/modules/dashboard_user.js @@ -0,0 +1,132 @@ +import * as api from "../api/dashboard_user.js" + +export default { + namespaced: true, + state: { + users: [], + selected_user: {}, + project_options: [], + search_username: '', + search_project: { mcu_id: 'all', project_number: 'All', project_name: 'Semua Project' }, + project_keyword: '', + page: 1, + limit: 20, + total_rows: 0, + total_pages: 0, + search_status: 0, + save_status: 0, + save_error_message: '', + dialog_success: false, + msg_success: '' + }, + mutations: { + update_users(state, val) { state.users = val }, + update_selected_user(state, val) { state.selected_user = val }, + update_project_options(state, val) { state.project_options = val }, + update_search_username(state, val) { state.search_username = val }, + update_search_project(state, val) { state.search_project = val }, + update_project_keyword(state, val) { state.project_keyword = val }, + update_page(state, val) { state.page = val }, + update_limit(state, val) { state.limit = val }, + update_total_rows(state, val) { state.total_rows = val }, + update_total_pages(state, val) { state.total_pages = val }, + update_search_status(state, val) { state.search_status = val }, + update_save_status(state, val) { state.save_status = val }, + update_save_error_message(state, val) { state.save_error_message = val }, + update_dialog_success(state, val) { state.dialog_success = val }, + update_msg_success(state, val) { state.msg_success = val } + }, + actions: { + async search(context, prm) { + context.commit('update_search_status', 1) + try { + prm.token = one_token() + let resp = await api.search(prm) + if (resp.status != 'OK') { + context.commit('update_search_status', 3) + context.commit('update_save_error_message', resp.message) + } else { + let data = resp.data || {} + context.commit('update_users', data.records || []) + context.commit('update_total_rows', data.pagination ? data.pagination.total_rows : 0) + context.commit('update_total_pages', data.pagination ? data.pagination.total_pages : 0) + context.commit('update_page', data.pagination ? data.pagination.page : 1) + context.commit('update_limit', data.pagination ? data.pagination.limit : 20) + context.commit('update_search_status', 2) + } + } catch (e) { + context.commit('update_search_status', 3) + context.commit('update_save_error_message', e.message) + } + }, + async search_project(context, prm) { + try { + prm.token = one_token() + let resp = await api.search_project(prm) + if (resp.status != 'OK') { + context.commit('update_project_options', []) + } else { + context.commit('update_project_options', resp.data.records || []) + } + } catch (e) { + context.commit('update_project_options', []) + } + }, + async save(context, prm) { + context.commit('update_save_status', 1) + prm.token = one_token() + let resp = await api.save(prm) + if (resp.status != 'OK') { + context.commit('update_save_status', 3) + context.commit('update_save_error_message', resp.message) + return resp + } + context.commit('update_save_status', 2) + context.commit('update_msg_success', (resp.data && resp.data.message) ? resp.data.message : 'User berhasil disimpan') + context.commit('update_dialog_success', true) + return resp + }, + async reset_password(context, prm) { + context.commit('update_save_status', 1) + prm.token = one_token() + let resp = await api.reset_password(prm) + if (resp.status != 'OK') { + context.commit('update_save_status', 3) + context.commit('update_save_error_message', resp.message) + return resp + } + context.commit('update_save_status', 2) + context.commit('update_msg_success', (resp.data && resp.data.message) ? resp.data.message : 'Password berhasil direset') + context.commit('update_dialog_success', true) + return resp + }, + async assign_project(context, prm) { + context.commit('update_save_status', 1) + prm.token = one_token() + let resp = await api.assign_project(prm) + if (resp.status != 'OK') { + context.commit('update_save_status', 3) + context.commit('update_save_error_message', resp.message) + return resp + } + context.commit('update_save_status', 2) + context.commit('update_msg_success', (resp.data && resp.data.message) ? resp.data.message : 'Project berhasil di-assign') + context.commit('update_dialog_success', true) + return resp + }, + async remove_project(context, prm) { + context.commit('update_save_status', 1) + prm.token = one_token() + let resp = await api.remove_project(prm) + if (resp.status != 'OK') { + context.commit('update_save_status', 3) + context.commit('update_save_error_message', resp.message) + return resp + } + context.commit('update_save_status', 2) + context.commit('update_msg_success', (resp.data && resp.data.message) ? resp.data.message : 'Project berhasil dihapus') + context.commit('update_dialog_success', true) + return resp + } + } +} diff --git a/test/vuex/dashboard-user-mcu/store.js b/test/vuex/dashboard-user-mcu/store.js new file mode 100644 index 0000000..75c0dd4 --- /dev/null +++ b/test/vuex/dashboard-user-mcu/store.js @@ -0,0 +1,12 @@ +import dashboard_user from "./modules/dashboard_user.js"; +import system from "../../../apps/modules/system/system.js"; + +export const store = new Vuex.Store({ + modules: { + dashboard_user: dashboard_user, + system: system + }, + state: {}, + mutations: {}, + actions: {} +});