summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/store/api.js34
-rw-r--r--src/store/modules/AccessControl/LocalUserMangementStore.js49
-rw-r--r--vue.config.js6
3 files changed, 55 insertions, 34 deletions
diff --git a/src/store/api.js b/src/store/api.js
new file mode 100644
index 00000000..d40ad0ad
--- /dev/null
+++ b/src/store/api.js
@@ -0,0 +1,34 @@
+import Axios from "axios";
+
+const api = Axios.create();
+
+// TODO: this is a temporary workaround until
+// authentication with login is working
+const username = process.env.VUE_APP_USERNAME;
+const password = process.env.VUE_APP_PASSWORD;
+if (username && password) {
+ api.defaults.auth = {};
+ api.defaults.auth.username = username;
+ api.defaults.auth.password = password;
+}
+
+export default {
+ get(path) {
+ return api.get(path);
+ },
+ delete(path, payload) {
+ return api.delete(path, payload);
+ },
+ post(path, payload) {
+ return api.post(path, payload);
+ },
+ patch(path, payload) {
+ return api.patch(path, payload);
+ },
+ put(path, payload) {
+ return api.put(path, payload);
+ },
+ all(promises) {
+ return Axios.all(promises);
+ }
+};
diff --git a/src/store/modules/AccessControl/LocalUserMangementStore.js b/src/store/modules/AccessControl/LocalUserMangementStore.js
index dddfd2cc..41bbe0d8 100644
--- a/src/store/modules/AccessControl/LocalUserMangementStore.js
+++ b/src/store/modules/AccessControl/LocalUserMangementStore.js
@@ -1,4 +1,4 @@
-import Axios from "axios";
+import api from "../../api";
const LocalUserManagementStore = {
namespaced: true,
@@ -17,38 +17,21 @@ const LocalUserManagementStore = {
},
actions: {
getUsers({ commit }) {
- let base;
- let username;
- let password;
- if (base && username && password) {
- Axios.defaults.baseURL = base;
- Axios.defaults.auth = {};
- Axios.defaults.auth.username = username;
- Axios.defaults.auth.password = password;
- Axios.get("redfish/v1/AccountService/Accounts")
- .then(response => {
- return response.data.Members.map(user => user["@odata.id"]);
- })
- .then(userIds => {
- return Axios.all(userIds.map(user => Axios.get(user)));
- })
- .then(users => {
- const userData = users.map(user => user.data);
- commit("setUsers", userData);
- })
- .catch(error => {
- console.log(error);
- });
- } else {
- // Faking async call with timeout
- setTimeout(() => {
- const users = [
- { UserName: "root", RoleId: "Admin", Locked: false, Enabled: true },
- { UserName: "user1", RoleId: "user", Locked: false, Enabled: false }
- ];
- commit("setUsers", users);
- }, 3000);
- }
+ api
+ .get("/redfish/v1/AccountService/Accounts")
+ .then(response => {
+ return response.data.Members.map(user => user["@odata.id"]);
+ })
+ .then(userIds => {
+ return api.all(userIds.map(user => api.get(user)));
+ })
+ .then(users => {
+ const userData = users.map(user => user.data);
+ commit("setUsers", userData);
+ })
+ .catch(error => {
+ console.log(error);
+ });
}
}
};
diff --git a/vue.config.js b/vue.config.js
index f053ebf7..c4175951 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -1 +1,5 @@
-module.exports = {};
+module.exports = {
+ devServer: {
+ proxy: process.env.BASE_URL
+ }
+};