Formatted according to eslint
This commit is contained in:
parent
444acaf046
commit
a2473bd06d
6 changed files with 388 additions and 393 deletions
|
@ -1,6 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<form @submit="submitForm">
|
<form @submit="submitForm">
|
||||||
|
|
||||||
<b-input-group id="form">
|
<b-input-group id="form">
|
||||||
<b-form-input
|
<b-form-input
|
||||||
id="name"
|
id="name"
|
||||||
|
@ -49,16 +48,17 @@ export default {
|
||||||
// Try to login
|
// Try to login
|
||||||
store
|
store
|
||||||
.dispatch("addProject", {
|
.dispatch("addProject", {
|
||||||
name: this.form.name,
|
name: this.form.name
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.form.name = "";
|
this.form.name = "";
|
||||||
this.working = false;
|
this.working = false;
|
||||||
}).catch((e) => {
|
})
|
||||||
|
.catch(e => {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
||||||
this.working = false;
|
this.working = false;
|
||||||
})
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,13 +72,13 @@ export default {
|
||||||
sortDesc: {
|
sortDesc: {
|
||||||
required: false,
|
required: false,
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false
|
||||||
},
|
},
|
||||||
running: {
|
running: {
|
||||||
required: false,
|
required: false,
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -86,31 +86,31 @@ export default {
|
||||||
requiredFields: [
|
requiredFields: [
|
||||||
{
|
{
|
||||||
key: "project",
|
key: "project",
|
||||||
label: "Project",
|
label: "Project"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "start",
|
key: "start",
|
||||||
label: "Start",
|
label: "Start"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "duration",
|
key: "duration",
|
||||||
label: "Duration",
|
label: "Duration"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "details",
|
key: "details",
|
||||||
label: "Details",
|
label: "Details"
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
runningFields: [
|
runningFields: [
|
||||||
{
|
{
|
||||||
key: "abort",
|
key: "abort",
|
||||||
label: "Abort",
|
label: "Abort"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "stop",
|
key: "stop",
|
||||||
label: "Stop",
|
label: "Stop"
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -125,7 +125,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getDurationTimestamp: helperService.getDurationTimestamp,
|
getDurationTimestamp: helperService.getDurationTimestamp,
|
||||||
|
@ -147,8 +147,8 @@ export default {
|
||||||
detailsRecord: function(id) {
|
detailsRecord: function(id) {
|
||||||
return id;
|
return id;
|
||||||
// this.$router.push("/record/" + id);
|
// this.$router.push("/record/" + id);
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ export const juggl = {
|
||||||
usingFinishedRecords: false,
|
usingFinishedRecords: false,
|
||||||
usingRunningRecords: false,
|
usingRunningRecords: false,
|
||||||
usingProjects: false,
|
usingProjects: false,
|
||||||
recordsLimit: 0,
|
recordsLimit: 0
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
setKey(state, key) {
|
setKey(state, key) {
|
||||||
|
@ -46,35 +46,31 @@ export const juggl = {
|
||||||
state.auth = { apiKey: apiKey, userId: userId };
|
state.auth = { apiKey: apiKey, userId: userId };
|
||||||
localStorage.setItem("apiKey", apiKey);
|
localStorage.setItem("apiKey", apiKey);
|
||||||
localStorage.setItem("userId", userId);
|
localStorage.setItem("userId", userId);
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
runningRecords: (state) => {
|
runningRecords: state => {
|
||||||
return Object.values(state.records).filter(
|
return Object.values(state.records).filter(record => record.running);
|
||||||
(record) => record.running
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
finishedRecords: (state) => {
|
finishedRecords: state => {
|
||||||
return Object.values(state.records).filter(
|
return Object.values(state.records).filter(record => !record.running);
|
||||||
(record) => !record.running
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
auth: (state) => state.auth,
|
auth: state => state.auth,
|
||||||
apiUrl: (state) => state.apiUrl,
|
apiUrl: state => state.apiUrl,
|
||||||
user: (state) => state.user,
|
user: state => state.user,
|
||||||
isLoggedIn: (state) => !!state.auth,
|
isLoggedIn: state => !!state.auth,
|
||||||
records: (state) => state.records,
|
records: state => state.records,
|
||||||
projects: (state) => state.projects,
|
projects: state => state.projects,
|
||||||
projectIds: (state) => {
|
projectIds: state => {
|
||||||
var projectIds = [];
|
var projectIds = [];
|
||||||
Object.values(state.projects).forEach((project) => {
|
Object.values(state.projects).forEach(project => {
|
||||||
projectIds.push(project.project_id);
|
projectIds.push(project.project_id);
|
||||||
});
|
});
|
||||||
return projectIds;
|
return projectIds;
|
||||||
},
|
},
|
||||||
runningProjectIds: (state, getters) => {
|
runningProjectIds: (state, getters) => {
|
||||||
var runningProjectIds = [];
|
var runningProjectIds = [];
|
||||||
Object.values(getters.runningRecords).forEach((record) => {
|
Object.values(getters.runningRecords).forEach(record => {
|
||||||
var projectId = record.project_id;
|
var projectId = record.project_id;
|
||||||
if (runningProjectIds.includes(runningProjectIds) === false) {
|
if (runningProjectIds.includes(runningProjectIds) === false) {
|
||||||
runningProjectIds.push(projectId);
|
runningProjectIds.push(projectId);
|
||||||
|
@ -84,36 +80,34 @@ export const juggl = {
|
||||||
},
|
},
|
||||||
finishedProjectIds: (state, getters) => {
|
finishedProjectIds: (state, getters) => {
|
||||||
var runningProjectIds = getters.runningProjectIds;
|
var runningProjectIds = getters.runningProjectIds;
|
||||||
return getters.projectIds.filter(
|
return getters.projectIds.filter(id => !runningProjectIds.includes(id));
|
||||||
(id) => !runningProjectIds.includes(id)
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
finishedProjects: (state, getters) => {
|
finishedProjects: (state, getters) => {
|
||||||
var ids = getters.finishedProjectIds;
|
var ids = getters.finishedProjectIds;
|
||||||
return Object.values(state.projects).filter((project) =>
|
return Object.values(state.projects).filter(project =>
|
||||||
ids.includes(project.project_id)
|
ids.includes(project.project_id)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
runningProjects: (state, getters) => {
|
runningProjects: (state, getters) => {
|
||||||
var ids = getters.runningProjectIds;
|
var ids = getters.runningProjectIds;
|
||||||
return Object.values(state.projects).filter((project) =>
|
return Object.values(state.projects).filter(project =>
|
||||||
ids.includes(project.project_id)
|
ids.includes(project.project_id)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
getProjectById: (state, getters) => (id) => {
|
getProjectById: (state, getters) => id => {
|
||||||
return Object.values(getters.projects).find(
|
return Object.values(getters.projects).find(
|
||||||
(project) => project.project_id === id
|
project => project.project_id === id
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
getRecordById: (state, getters) => (id) => {
|
getRecordById: (state, getters) => id => {
|
||||||
return Object.values(getters.records).find(
|
return Object.values(getters.records).find(
|
||||||
(record) => record.record_id === id
|
record => record.record_id === id
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
loadProjects({ commit }) {
|
loadProjects({ commit }) {
|
||||||
return jugglService.getProjects().then((r) => {
|
return jugglService.getProjects().then(r => {
|
||||||
commit("setProjects", r.data.projects);
|
commit("setProjects", r.data.projects);
|
||||||
commit("usingProjects", true);
|
commit("usingProjects", true);
|
||||||
});
|
});
|
||||||
|
@ -124,24 +118,26 @@ export const juggl = {
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
.then((r) => {
|
.then(r => {
|
||||||
commit("setUser", r.data.users[0]);
|
commit("setUser", r.data.users[0]);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
loadRecords({ commit, state }, { limit, finished }) {
|
loadRecords({ commit, state }, { limit, finished }) {
|
||||||
commit("setRecordsLimit", limit);
|
commit("setRecordsLimit", limit);
|
||||||
return jugglService.getRecords({ limit: state.recordsLimit, finished: finished }).then((r) => {
|
return jugglService
|
||||||
|
.getRecords({ limit: state.recordsLimit, finished: finished })
|
||||||
|
.then(r => {
|
||||||
commit("setRecords", r.data.records);
|
commit("setRecords", r.data.records);
|
||||||
commit("usingFinishedRecords", true);
|
commit("usingFinishedRecords", true);
|
||||||
commit("usingRunningRecords", true);
|
commit("usingRunningRecords", true);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
loadRunningRecords({ commit, getters }) {
|
loadRunningRecords({ commit, getters }) {
|
||||||
return jugglService.getRunningRecords().then((r) => {
|
return jugglService.getRunningRecords().then(r => {
|
||||||
var allRecords = {
|
var allRecords = {
|
||||||
...getters.finishedRecords,
|
...getters.finishedRecords,
|
||||||
...r.data.records,
|
...r.data.records
|
||||||
};
|
};
|
||||||
commit("setRecords", allRecords);
|
commit("setRecords", allRecords);
|
||||||
commit("usingRunningRecords", true);
|
commit("usingRunningRecords", true);
|
||||||
|
@ -160,7 +156,7 @@ export const juggl = {
|
||||||
this.dispatch("logout");
|
this.dispatch("logout");
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
.then((r) => {
|
.then(r => {
|
||||||
if (r === false) {
|
if (r === false) {
|
||||||
this.dispatch("logout");
|
this.dispatch("logout");
|
||||||
return false;
|
return false;
|
||||||
|
@ -239,6 +235,6 @@ export const juggl = {
|
||||||
}
|
}
|
||||||
|
|
||||||
commit("login", { apiKey: apiKey, userId: userId });
|
commit("login", { apiKey: apiKey, userId: userId });
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,5 +39,4 @@ export default {
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="sass">
|
<style lang="sass"></style>
|
||||||
</style>
|
|
||||||
|
|
Loading…
Reference in a new issue