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 2 commits
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
8 changes: 5 additions & 3 deletions src/services/storage-options/restApiService.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import StorageInterface from "../storageInterface";
import store from "@/store";

export default class RestApiService extends StorageInterface {
async getState() {
const response = await axios.get(`http://localhost:3000/state`);
return response.data;
async getState(executionId) {
const { data } = await axios.get(
`http://localhost:5000/v1/pinata/executions/${executionId}`
);
return data;
}

async updateState(state) {
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: 2 additions & 2 deletions src/services/storageService.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default class StorageService {
: new RestApiService();
}

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

async updateState(state) {
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.getState(
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