Last commit before vue-version
This commit is contained in:
parent
68f8ebf719
commit
a63b582fe5
4 changed files with 94 additions and 16 deletions
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var intervallId = undefined;
|
var intervallId = undefined;
|
||||||
|
|
||||||
window.onblur = () => {
|
window.onblur = () => {
|
||||||
stopBackgroundUpdates();
|
stopBackgroundUpdates();
|
||||||
}
|
}
|
||||||
|
@ -27,21 +28,20 @@
|
||||||
// Create Callbacks
|
// Create Callbacks
|
||||||
callbacks.entering[States.RECORDING] = () => {
|
callbacks.entering[States.RECORDING] = () => {
|
||||||
updateProgess();
|
updateProgess();
|
||||||
|
loadRecordTags();
|
||||||
|
};
|
||||||
|
callbacks.entering[States.IDLE] = () => {
|
||||||
|
loadProjectList().then(() => {
|
||||||
|
checkForUpdate();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
initState();
|
initState();
|
||||||
onLogIn();
|
|
||||||
updateVisibility();
|
updateVisibility();
|
||||||
updateAuthBtnText();
|
updateAuthBtnText();
|
||||||
startBackgroundUpdates();
|
startBackgroundUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onLogIn() {
|
|
||||||
loadProjectList().then(() => {
|
|
||||||
checkForUpdate();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkForUpdate() {
|
function checkForUpdate() {
|
||||||
if (currentRecord !== undefined) {
|
if (currentRecord !== undefined) {
|
||||||
updateProgess();
|
updateProgess();
|
||||||
|
@ -98,20 +98,26 @@
|
||||||
</ul>
|
</ul>
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<div class="idle hidden" style="text-align: center;">
|
<div class="recording hidden" style="text-align: center;">
|
||||||
|
<h1>
|
||||||
|
Currently Tracking
|
||||||
|
</h1>
|
||||||
|
<div id="tracking-list">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="idle recording hidden" style="text-align: center;">
|
||||||
<h1>
|
<h1>
|
||||||
Select project to track
|
Select project to track
|
||||||
</h1>
|
</h1>
|
||||||
<div id="project-list">
|
<div id="project-list">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="recording hidden" style="text-align: center;">
|
<div class="idle recording hidden" style="text-align: center;">
|
||||||
<h1>
|
<h1>
|
||||||
Tracking <span id="current-project-name"></span>
|
Records
|
||||||
</h1>
|
</h1>
|
||||||
<h2 id="current-record-duration" style="color: red;"></h2>
|
<div id="record-list">
|
||||||
<small id="update-notice" >Updated every 30 seconds</small><br/>
|
</div>
|
||||||
<button id="stop-btn" onclick="stopRecord()">Stop</button>
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -14,6 +14,19 @@ const api = {
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getRecordTags() {
|
||||||
|
return request("/getRecordTags.php")
|
||||||
|
.then((r) => {
|
||||||
|
return r.json();
|
||||||
|
})
|
||||||
|
.then((j) => {
|
||||||
|
return j.record_tags;
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
console.log(e);
|
||||||
|
return {};
|
||||||
|
});
|
||||||
|
},
|
||||||
startRecord(projectId, startTime = new Date()) {
|
startRecord(projectId, startTime = new Date()) {
|
||||||
return request("/startRecord.php", {
|
return request("/startRecord.php", {
|
||||||
project_id: projectId,
|
project_id: projectId,
|
||||||
|
@ -72,6 +85,32 @@ const api = {
|
||||||
return undefined;
|
return undefined;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
addTagToRecord(tagId, recordId) {
|
||||||
|
return request("/addTagToRecord.php", {
|
||||||
|
tag_id: tagId,
|
||||||
|
record_id: recordId,
|
||||||
|
}).catch((e) => {
|
||||||
|
console.log(e);
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
removeTagFromRecord(tagId, recordId) {
|
||||||
|
return request("/removeTagFromRecord.php", {
|
||||||
|
tag_id: tagId,
|
||||||
|
record_id: recordId,
|
||||||
|
}).catch((e) => {
|
||||||
|
console.log(e);
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
addRecordTag(tagName) {
|
||||||
|
return request("/addRecordTag.php", {
|
||||||
|
tag_name: tagName,
|
||||||
|
}).catch((e) => {
|
||||||
|
console.log(e);
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function request(path, json = {}, options = {}) {
|
function request(path, json = {}, options = {}) {
|
||||||
|
|
|
@ -37,7 +37,6 @@ function handleAuthBtn() {
|
||||||
}
|
}
|
||||||
|
|
||||||
logIn(apiKey, userId);
|
logIn(apiKey, userId);
|
||||||
onLogIn();
|
|
||||||
}
|
}
|
||||||
u("#api-key").first().value = "";
|
u("#api-key").first().value = "";
|
||||||
updateAuthBtnText();
|
updateAuthBtnText();
|
||||||
|
|
|
@ -4,6 +4,7 @@ const PROJECT_META = "p";
|
||||||
let currentRecord = undefined;
|
let currentRecord = undefined;
|
||||||
let currentProject = undefined;
|
let currentProject = undefined;
|
||||||
let projectList = undefined;
|
let projectList = undefined;
|
||||||
|
let recordTags = undefined;
|
||||||
|
|
||||||
function loadProjectList() {
|
function loadProjectList() {
|
||||||
return api.getProjects().then((projects) => {
|
return api.getProjects().then((projects) => {
|
||||||
|
@ -38,6 +39,39 @@ function loadProjectList() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadRecordTags() {
|
||||||
|
return api.getRecordTags().then((tags) => {
|
||||||
|
projectList = Object.values(projects);
|
||||||
|
|
||||||
|
var container = u(u("#project-list").first());
|
||||||
|
container.children().remove();
|
||||||
|
Object.values(projects).forEach((project) => {
|
||||||
|
var obj = createNode(PROJECT_OBJECT);
|
||||||
|
var data = undefined;
|
||||||
|
|
||||||
|
data = createNode(PROJECT_TITLE);
|
||||||
|
append(obj, data);
|
||||||
|
u(data).text(project["name"]);
|
||||||
|
|
||||||
|
var duration = Number((parseFloat(project["duration"]) / 60 / 60).toFixed(2));
|
||||||
|
var unit = "hours";
|
||||||
|
data = createNode(PROJECT_META);
|
||||||
|
append(obj, data);
|
||||||
|
u(data).text(duration + " " + unit);
|
||||||
|
|
||||||
|
data = createNode(PROJECT_META);
|
||||||
|
append(obj, data);
|
||||||
|
u(data).text(project["record_count"] + " records");
|
||||||
|
|
||||||
|
obj = u(obj);
|
||||||
|
obj.data("project-id", project["project_id"]);
|
||||||
|
obj.on("click", projectClicked);
|
||||||
|
|
||||||
|
container.append(obj);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Created new DOM object
|
// Created new DOM object
|
||||||
// element: Type of DOM object (div, p, ...)
|
// element: Type of DOM object (div, p, ...)
|
||||||
function createNode(element) {
|
function createNode(element) {
|
||||||
|
|
Loading…
Reference in a new issue