Commit 185566ef authored by Jeremy Fischer's avatar Jeremy Fischer
Browse files

Fix Undefined node errors temporarily.

Tables now generated with integers only
A lot of work towards filesystem (Nextcloud/Local at 90%)
Misc Fixes
parent c9f8086e
commons @ a88ca87b
Subproject commit 194a1400c87255868728a50d907edc64270a8925
Subproject commit a88ca87bdd95ac399bf66d26e4c63b2d6434c881
......@@ -62,8 +62,11 @@ resources = [
{"var": "auth_info", "path": "?authGet"},
];
//Load required modules, register event handler for processLoad, then start loading resources.
jmcjs.core.module_load("fileload");
jmcjs.core.module_load("route");
jmcjs.core.module_load("loader", function() {
jmcjs.core.module_load("events", function() {
jmcjs.core.module_load("filedrop");
jmcjs.events.registerEventHandler("jmcjs.loader.itemLoad", processLoad, "init requested load");
items += resources.length;
jmcjs.loader.loadList(resources, init);
......
......@@ -3,7 +3,6 @@ if (declare_load("filesystem") !== TRUE)
die();
depend("config");
$path = urldecode($_REQUEST["obj"]);
while ($path != str_replace("..", ".", $path))
$path = str_replace("..", ".", $path);
......@@ -30,13 +29,38 @@ if ($type = "files") {
}
}
die(json_encode(array('files' => $files, 'dirs' => $dirs)));
}else if (isset($_REQUEST['rename']) && file_exists($syspath)) {
$newname = str_replace("/", "_", $_REQUEST['name']);
$oldname = explode("/",$path);
$newloc = "";
for($i = 0; $i < count($oldname)-1; $i++){
$newloc .= $oldname[$i]."/";
}
$oldname = $oldname[count($oldname)-1];
rename($syspath, $GLOBALS["config"]["team"]["filestore"] . "/" . $newloc.$newname);
die("ok ".$newloc.$newname);
}else if (isset($_REQUEST['delete']) && file_exists($syspath)) {
$oldname = explode("/",$path);
$newloc = "trash/";
for($i = 0; $i < count($oldname)-1; $i++){
$newloc .= $oldname[$i]."/";
}
$oldname = $oldname[count($oldname)-1];
echo($GLOBALS["config"]["team"]["filestore"] . "/". $newloc);
mkdir($GLOBALS["config"]["team"]["filestore"] . "/". $newloc,0755,true);
rename($syspath, $GLOBALS["config"]["team"]["filestore"] . "/trash/". $path."_".microtime());
die("ok ".$newloc.$oldname);
} else if (isset($_REQUEST["fileGet"]) && !is_dir($syspath)) {
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=blob.dat");
echo file_get_contents($syspath);
die(file_get_contents($syspath));
} else if (isset($_FILES["file"]) && is_dir($syspath)) {
$fileName = str_replace("/", "_", $_REQUEST["name"]);
move_uploaded_file($_FILES["file"]["tmp_name"], $_REQUEST["name"]);
print_r($_REQUEST);
print_r($_FILES);
print_r($fileName);
move_uploaded_file($_FILES["file"]["tmp_name"], $syspath."/".$_REQUEST["name"]);
die("ok");
} else if (isset($_REQUEST["subdirCreate"]) && is_dir($syspath)) {
$newpath = $_REQUEST["subdirCreate"];
while ($newpath != str_replace("..", ".", $newpath))
......
......@@ -153,6 +153,8 @@ width: 100%;
</hud>
</body>
<script src="jmcjs/core.js"></script>
<script src="jmcjs/route.js"></script>
<script src="jmcjs/events.js"></script>
<script src="res/module/actions.user.js"></script>
<script src="res/module/logic.net.js"></script>
<script src="res/module/logic.node.js"></script>
......
......@@ -6,12 +6,6 @@ var teamData = {};
var current_view = "dashboard";
var sessionManagerURL = "";
window.addEventListener('onhashchange', function(e) {
e.preventDefault();
e.returnValue = '';
jmcjs.events.triggerEvent("nav", window.location.hash.substring(1, window.location.hash.length));
});
//Setup views
overview_init();
details_init();
......@@ -40,3 +34,5 @@ setTimeout(loadGraph, 5);
setInterval(getNews, 3000);
//setTimeout("log_message('Workspace Loading...')",10);
//Init Navigation
jmcjs.route.init();
......@@ -3,7 +3,6 @@ function logout() {
location.reload();
}
var currentDragNode = "";
var draggingNode = false;
var draggingNodeOffsetX = 0;
......@@ -39,7 +38,6 @@ function node_add_child(element) {
});
}
var lastmove = Date.now();
function uinput() {
lastmove = Date.now();
......@@ -48,20 +46,37 @@ function uinput() {
document.addEventListener('mousemove', uinput, false);
document.addEventListener('keydown', uinput, false);
function makeDir() {
var requestPath = decodeURIComponent(window.location.hash.substring(7));
var breadCrumbs = "";
var dirName = prompt("Name of new Folder", "New Folder");
if (dirName != null) {
sync_get("?fs&subdirCreate=" + encodeURIComponent(dirName) + "&obj=" + encodeURIComponent(requestPath));
fileNav();
jmcjs.core.xhr("?fs&subdirCreate=" + encodeURIComponent(dirName) + "&obj=" + encodeURIComponent(requestPath), undefined, function() {
jmcjs.route.navigate(window.location);
});
}
}
function file_rename(file_item) {
var path = decodeURIComponent(file_item.parentElement.parentElement.href).replace("#files/download", "#files");
path = path.split("#")[1].substring(6);
var oldName = path.split("/")[path.split("/").length - 1];
var newName = prompt("New Name?", oldName);
if (newName != null && newName != oldName) {
jmcjs.core.xhr("?fs&rename&name=" + encodeURIComponent(newName) + "&obj=" + encodeURIComponent(path), undefined, function() {
jmcjs.route.navigate(window.location);
});
}
}
function file_delete(file_item) {
var path = decodeURIComponent(file_item.parentElement.parentElement.href).replace("#files/download", "#files");
path = path.split("#")[1].substring(6);
jmcjs.core.xhr("?fs&delete&obj=" + encodeURIComponent(path), undefined, function() {
jmcjs.route.navigate(window.location);
});
}
function updates_install() {
console.log(sync_get("?do_update"));
......
function fileNav() {
jmcjs.route.add("#files", function(route) {
var data = "";
var requestPath = decodeURIComponent(window.location.hash.substring(7));
var requestPath = decodeURIComponent(route.substring(7));
var breadCrumbs = "";
var pathComponents = requestPath.split("/");
var templ_edit = '<act onclick="file_rename(this); return false;" class="btn-floating btn-small waves-effect waves-light light-blue" style="position: absolute; top: 0em; left: 0em;"><i class="material-icons">edit</i></act>';
var templ_remove = '<act onclick="file_delete(this); return false;" class="btn-floating btn-small waves-effect waves-light red" style="position: absolute; top: 0em; right: 0em;"><i class="material-icons">delete_forever</i></act>';
if (pathComponents[0] == "download") {
var url = "?fs&fileGet&obj=" + encodeURIComponent(requestPath.substring(9));
var xhr = new XMLHttpRequest();
......@@ -36,14 +39,14 @@ function fileNav() {
xhr.send();
} else {
if (pathComponents[0] == "files") {
breadCrumbs += '<a style="float: right;" onclick="makeDir()">Create Folder</a><a style="float: right;" onclick="fileUpload()">Upload File</a>';
breadCrumbs += '<a style="float: right;" onclick="makeDir()">Create Folder</a><a style="float: right;" onclick="alert('+"'"+'You can use Drag&Drop to upload files'+"'"+')">Upload File</a>';
files = JSON.parse(sync_get("?fs&list&obj=" + encodeURIComponent(requestPath)));
for (file in files["dirs"]) {
data += renderFile(files["dirs"][file], "Folder", "Nextcloud", "res/icons/folder.svg", "lock_outline", requestPath + "/" + files["dirs"][file]);
data += renderFile(files["dirs"][file], "Folder", "Nextcloud", "res/icons/folder.svg", "lock_outline", requestPath + "/" + files["dirs"][file], templ_edit, templ_remove);
}
for (file in files["files"]) {
//TODO: filetypes, name handling, ..
data += renderFile(files["files"][file], "File", "Nextcloud", "res/icons/application-octet-stream.svg", "lock_outline", "download/" + requestPath + "/" + files["files"][file]);
data += renderFile(files["files"][file], "File", "Nextcloud", "res/icons/application-octet-stream.svg", "lock_outline", "download/" + requestPath + "/" + files["files"][file], templ_edit, templ_remove);
}
} else if (pathComponents[0] == "asset") {
if (pathComponents[2] != undefined) {
......@@ -66,17 +69,29 @@ function fileNav() {
} else {
data += renderFile("Filebox", "System Folder", "Nextcloud", "res/icons/folder.svg", "lock_open", "files");
data += renderFile("Task Files", "System Folder", "System", "res/icons/folder.svg", "lock_outline", "asset");
data += renderFile("Documents", "System Folder", "System", "res/icons/folder.svg", "lock_outline", "docs");
data += renderFile("Documents", "System Folder", "System", "res/icons/folder.svg", "lock_outline", "docs", templ_edit);
}
var crumbPath = "";
for (i in pathComponents) {
if (pathComponents[i].length > 0) {
crumbPath += pathComponents[i] + "/";
crumb = '<a href="#files/' + crumbPath.substring(0, crumbPath.length - 1) + '" onclick="setTimeout(fileNav,50);">' + pathComponents[i] + '</a>/';
crumb = '<a href="#files/' + crumbPath.substring(0, crumbPath.length - 1) + '">' + pathComponents[i] + '</a>/';
breadCrumbs += crumb;
}
}
document.getElementById("fileList").innerHTML = data;
document.getElementById("breadCrumbs").innerHTML = breadCrumbs;
}
}
\ No newline at end of file
jmcjs.route.complete_navigation(null, "Files | A* Dev", route);
});
jmcjs.events.registerEventHandler("jmcjs.filedrop.drop", function(event, data) {
var path = "";
if (data.target.tagName == "P") {
path = window.location.hash.substring(1);
} else if (data.target.parentElement.href != "") {
path = data.target.parentElement.href.split("#")[1];
}
path = path.substring(6);
jmcjs.fileload.up("?fs&obj="+encodeURIComponent(path), data.file, function(){jmcjs.route.navigate(window.location);});
});
......@@ -2,21 +2,23 @@ function mscalc() {
var nodes = [];
for (node in nodeTree) {
if (nodeTree[node]["level"] >= 3) {
if (nodeTree[node] != undefined && nodeTree[node]["isDeleted"] != true && nodeTree[node]["level"] >= 3) {
nodes.push(nodeTree[node]);
}
}
for (node in nodes) {
if (getParentNodeAtLevel(nodes[node],3)["state"] == 0) {
if (nodeTree[node] != undefined && nodeTree[node]["isDeleted"] != true && getParentNodeAtLevel(nodes[node],3)["state"] == 0) {
document.getElementById("node_" + nodes[node]["self"]).style.opacity = "0.5";
}
}
}
function isNodeInChildren(node, testNode) {
console.log("Checking children of " + node);
if(nodeTree[node] != undefined && nodeTree[node]["isDeleted"] != true)
for (child in nodeTree[node]["children"]) {
if (nodeTree[node]["children"][child] == testNode || isNodeInChildren(nodeTree[node]["children"][child], testNode)) {
if (nodeTree[node]["children"][child] != undefined && nodeTree[node]["children"][child]["isDeleted"] != true && nodeTree[node]["children"][child] == testNode || isNodeInChildren(nodeTree[node]["children"][child], testNode)) {
return true;
}
}
......@@ -27,7 +29,7 @@ function getNodeProgress(node) {
var data = {};
data["weight"] = 0;
data["complete"] = 0;
if (node == undefined) {
if (node == undefined || node["isDeleted"]) {
console.exception("UNDEFINED NODE! CANNOT CALCULATE PROGRESS");
return data;
};
......@@ -51,6 +53,8 @@ function getNodeProgress(node) {
}
function getNodeAwardTP(node) {
if (node == undefined || node["isDeleted"])
return 0;
if (node["level"] > 3) {
return node["tp"];
}
......@@ -67,6 +71,8 @@ function getNodeAwardTP(node) {
}
function getNodeDisplayTP(node) {
if (node == undefined || node["isDeleted"])
return 0;
if (node["level"] > 3) {
return node["tp"] || 0;
}
......@@ -98,16 +104,18 @@ function getUserTP(user, completedOnly) {
completedOnly = true;
var tp = 0;
for (node in nodeTree) {
var assignees = 0;
var isAssigned = false;
for (assignee in nodeTree[node]["assignees"]) {
assignees++;
if (nodeTree[node]["assignees"][assignee] == user) {
isAssigned = true;
if (nodeTree[node] != undefined && nodeTree[node]["isDeleted"] != true) {
var assignees = 0;
var isAssigned = false;
for (assignee in nodeTree[node]["assignees"]) {
assignees++;
if (nodeTree[node]["assignees"][assignee] == user) {
isAssigned = true;
}
}
if (isAssigned && (!completedOnly || nodeTree[node]["state"] == 4)) {
tp += getNodeAwardTP(nodeTree[node]) / assignees;
}
}
if (isAssigned && (!completedOnly || nodeTree[node]["state"] == 4)) {
tp += getNodeAwardTP(nodeTree[node]) / assignees;
}
}
return tp;
......@@ -118,16 +126,18 @@ function getUserTasks(user, completedOnly) {
completedOnly = false;
var tasks = [];
for (node in nodeTree) {
var assignees = 0;
var isAssigned = false;
for (assignee in nodeTree[node]["assignees"]) {
assignees++;
if (nodeTree[node]["assignees"][assignee] == user) {
isAssigned = true;
if (nodeTree[node] != undefined && nodeTree[node]["isDeleted"] != true) {
var assignees = 0;
var isAssigned = false;
for (assignee in nodeTree[node]["assignees"]) {
assignees++;
if (nodeTree[node]["assignees"][assignee] == user) {
isAssigned = true;
}
}
if (isAssigned && (!completedOnly || nodeTree[node]["state"] != 4)) {
tasks.push(nodeTree[node]);
}
}
if (isAssigned && (!completedOnly || nodeTree[node]["state"] != 4)) {
tasks.push(nodeTree[node]);
}
}
return tasks;
......@@ -156,7 +166,6 @@ function getParentNodeAtLevel(node, targetLevel) {
}
}
function getNodeLevelName(level) {
if (levelNames[level] != undefined) {
return levelNames[level];
......
......@@ -16,8 +16,6 @@ function nav_files() {
data = files_template;
document.getElementById("main").innerHTML = menuData + data;
updateNotificationBadge();
fileNav();
setTimeout(fileNav, 500);
}
function nav_planning() {
......
function renderFile(name, type, creator, image, permission, path) {
return '<a href="#files/' + path + '" onclick="setTimeout(fileNav,50);"><file><graphical><icon><img src="' + image + '"/></icon><permission><i class="material-icons">' + permission + '</i></permission></graphical><name>' + name + '</name><type>' + type + '</type><creator>' + creator + '</creator></file></a>';
}
\ No newline at end of file
function renderFile(name, type, creator, image, permission, path, edit, remove) {
var isReceiver = "";
if(type == "Folder"){
isReceiver = "data-file-receiver";
}
if(edit == undefined) edit = "";
if(remove == undefined) remove = "";
return '<a href="#files/' + path + '"><file '+isReceiver+'>'+edit+remove+'<graphical><icon><img src="' + image + '"/></icon><permission><i class="material-icons">' + permission + '</i></permission></graphical><name>' + name + '</name><type>' + type + '</type><creator>' + creator + '</creator></file></a>';
}
jmcjs.events.registerEventHandler("jmcjs.filedrop.hover", function(event, nativeEvent) {
nativeEvent.target.style.backgroundColor = "blue";
});
jmcjs.events.registerEventHandler("jmcjs.filedrop.endhover", function(event, target) {
target.style.backgroundColor = "";
});
\ No newline at end of file
......@@ -90,7 +90,7 @@ function update_dashboard() {
var row_template = '<tr onclick="details_show(); return true;"><td>$state</td><td>$name</td><td>$activeTime</td><td>$tasks</td></tr>';
for (member in teamData["members"]) {
var cm = teamData["members"][member];
var tp = getUserTP(cm["FullID"], false) - getUserTP(cm["FullID"], true);
var tp = Math.floor(getUserTP(cm["FullID"], false) - getUserTP(cm["FullID"], true));
var time = "";
if (cm["timeOut"] != undefined) {
......@@ -156,8 +156,8 @@ function leaderboard_render() {
console.log("Leaderboard Calc " + member);
var entry = [];
entry[0] = member;
entry[1] = getUserTP(member);
entry[2] = getUserTasks(member).length - getUserTasks(member, true).length;
entry[1] = Math.floor(getUserTP(member));
entry[2] = Math.floor(getUserTasks(member).length - getUserTasks(member, true).length);
console.log(entry);
leaderboardData.push(entry);
}
......
......@@ -2,7 +2,7 @@
<p id="breadCrumbs">
</p>
<p id="fileList">
<p id="fileList" data-file-receiver style="min-height: 60%;">
</p>
</panelFlow>
......@@ -16,6 +16,12 @@ file {
margin: 0.5em 0.5em 0.5em 0.5em;
transition: background-color 0.5s ease;
}
file * {
pointer-events: none;
}
file act{
pointer-events: inherit;
}
file:hover {
background-color: #bbbbbb;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment