Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : allow users to open a specific execution #181

Merged
merged 3 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
1 change: 0 additions & 1 deletion src/components/ControlPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,6 @@ export default {
});
}
}
console.log(updatedItems);
await this.$store.commit("setSessionItems", [...updatedItems]);
await this.$store.commit("setSessionNodes", [...updatedNodes]);
await this.$store.commit("setSessionConnections", [
Expand Down
6 changes: 1 addition & 5 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,7 @@ const routes = [
path: "/main",
name: "main",
component: MainView,
children: [
{
path: "workspace",
},
],
children: [{ path: "workspace" }, { path: "workspace/:execID" }],
},
{
path: "/settings",
Expand Down
7 changes: 7 additions & 0 deletions src/services/storage-options/restApiService.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ export default class RestApiService extends StorageInterface {
};
}

async getStateMethod(executionId) {
SmartWolf1220 marked this conversation as resolved.
Show resolved Hide resolved
const { data } = await axios.get(
`http://localhost:5000/v1/pinata/executions/${executionId}`
);
return data;
}

async getMetaData() {}

async updateCredentials(credentials) {
Expand Down
5 changes: 5 additions & 0 deletions src/services/storageInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export default class StorageInterface {
throw new Error("Method 'getCredentials()' must be implemented.");
}

// eslint-disable-next-line
async getStateMethod(executionId) {
throw new Error("Method 'getStateMethod()' must be implemented.");
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dockabernathy01 remove this method now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the code.
Please check.

// eslint-disable-next-line
async updateCredentials(credentials) {
throw new Error("Method 'updateCredentials()' must be implemented.");
Expand Down
4 changes: 4 additions & 0 deletions src/services/storageService.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export default class StorageService {
return await this.storage.getCredentials();
}

async getStateMethod(executionId) {
return await this.storage.getStateMethod(executionId);
}

async getMetaData() {
return await this.storage.getMetaData();
}
Expand Down
16 changes: 16 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,22 @@ const store = new Vuex.Store({
}
this._vm.$storageService.updateItem(payload);
},

deleteSessionItems(state, ids) {
state.session.items = ids.reduce((acc, currentId) => {
return acc.filter((item) => item.stepID !== currentId);
}, state.session.items);
this._vm.$storageService.deleteItems(ids);
},

setSessionNotes(state, payload) {
state.session.notes.content = payload.content;
state.session.notes.text = payload.text;
if (!this.$isElectron) {
this._vm.$storageService.updateState(state);
}
},

updateSession(state, payload) {
let isStatusChanged = false;
if (state.session.status !== payload.status) {
Expand All @@ -198,6 +201,15 @@ const store = new Vuex.Store({
if (state.case.duration !== payload.duration) {
state.case.duration = payload.duration;
}
if (state.session.ended !== payload.ended && payload.ended) {
state.session.ended = payload.ended;
}
if (state.session.quickTest !== payload.quickTest && payload.quickTest) {
state.session.quickTest = payload.quickTest;
}
if (state.session.sessionID !== payload.sessionID && payload.sessionID) {
state.session.sessionID = payload.sessionID;
}

if (
Vue.prototype.$isElectron ||
Expand All @@ -209,6 +221,7 @@ const store = new Vuex.Store({
this._vm.$storageService.updateState(state);
}
},

clearState(state) {
state.case.caseID = null;
state.case.title = "";
Expand Down Expand Up @@ -287,6 +300,7 @@ const store = new Vuex.Store({
state.session.ended = "";
this._vm.$storageService.updateState(state);
},

restoreState(state, payload) {
state.case = {
...state.case,
Expand Down Expand Up @@ -319,6 +333,7 @@ const store = new Vuex.Store({

this._vm.$storageService.updateState(state);
},

togglePreSessionTask(state, { taskId, checked }) {
const taskIndex = state.session.preSessionTasks.findIndex(
(task) => task.id === taskId
Expand All @@ -327,6 +342,7 @@ const store = new Vuex.Store({
state.session.preSessionTasks[taskIndex].checked = checked;
}
},

togglePostSessionTask(state, { taskId, checked }) {
const taskIndex = state.session.postSessionTasks.findIndex(
(task) => task.id === taskId
Expand Down
17 changes: 17 additions & 0 deletions src/views/MainView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export default {
this.$electronService.onDataChange(this.fetchItems);
this.$electronService.onMetaChange(this.fetchItems);
}
this.getCurrentExecution();
},
computed: {
...mapGetters({
Expand Down Expand Up @@ -233,6 +234,22 @@ export default {
this.$store.commit("setSessionItemsFromExternalWindow", sessionItems);
}
},
async getCurrentExecution() {
let currentPath = this.$route.path;
const executionId = currentPath.split("/").pop();

if (executionId !== "" && executionId !== "workspace") {
const currentExecution = await this.$storageService.getStateMethod(
executionId
);
const data = currentExecution.custom_fields;
this.$store.commit("updateSession", data);
this.$store.commit("setSessionItems", data.items);
this.$store.commit("setSessionNodes", data.nodes);
this.$store.commit("setSessionConnections", data.connections);
await this.$router.push({ path: "/main/workspace" });
}
},
addItem(newItem) {
console.log("Add");
this.$store.commit("addSessionItem", newItem);
Expand Down