parent
2dafb07cea
commit
a078b768da
@ -0,0 +1,52 @@
|
||||
// ===========================================================
|
||||
// DEVBUG INLINE DEBUGGING HELPER - FOR USE WITH DEVBUG SERVER
|
||||
// TODO: REMOVE BEFORE COMMITTING
|
||||
let outs = {}
|
||||
let devbug_url = 'http://localhost:8000/'
|
||||
let project_api_key = 'CHANGEME'
|
||||
const out = (key, what, group="") => {
|
||||
if ( group ){
|
||||
if ( Object.keys(outs).includes(group) ) outs[group][key] = what
|
||||
else outs[group] = {}; outs[group][key] = what
|
||||
}
|
||||
else {
|
||||
outs[key] = what
|
||||
}
|
||||
}
|
||||
const breakpoint = (html = false, name = null) => {
|
||||
var e = new Error();
|
||||
(function() {
|
||||
// Load better json
|
||||
var js_decycle = document.createElement("script");
|
||||
js_decycle.src = devbug_url+"assets/cycle.js";
|
||||
js_decycle.type = 'text/javascript';
|
||||
js_decycle.onload = () => {
|
||||
// Load the script
|
||||
var script = document.createElement("script");
|
||||
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js';
|
||||
script.type = 'text/javascript';
|
||||
script.onload = () => {
|
||||
var $ = window.jQuery;
|
||||
$(() => {
|
||||
var s = e.stack.split('at'); var caller = '';
|
||||
if ( s.length < 3 ) s = e.stack.split('@')
|
||||
if ( s.length > 2 ) caller = s[2].trim()
|
||||
else if ( s.length > 1 ) caller = s[1]
|
||||
else caller = 'Unable to determine stacktrace'
|
||||
var data = new FormData();
|
||||
console.log(JSON.decycle({brief: (name ? name : 'Breakpoint: ')+caller,data: outs}))
|
||||
data.append('data', JSON.stringify(JSON.rmref(JSON.decycle({brief: (name ? name : 'Breakpoint: ')+caller,data: outs}))))
|
||||
$.ajax({
|
||||
url: devbug_url+'api/v1/out/'+project_api_key,
|
||||
data: data, cache: false, contentType: false, processData: false, method: 'POST', type: 'POST',
|
||||
success: (res) => { console.log('DevBug POST Completed'); console.log(res) }
|
||||
})
|
||||
});
|
||||
};
|
||||
document.getElementsByTagName("head")[0].appendChild(script);
|
||||
}
|
||||
document.getElementsByTagName("head")[0].appendChild(js_decycle);
|
||||
})();
|
||||
}
|
||||
window.out = out; window.breakpoint = breakpoint;
|
||||
// ===========================================================
|
@ -0,0 +1,118 @@
|
||||
if (typeof JSON.rmref !== "function") {
|
||||
JSON.rmref = function rmref(o){
|
||||
function eachRecursive(obj) {
|
||||
for (var k in obj)
|
||||
{
|
||||
if (typeof obj[k] == "object" && obj[k] !== null)
|
||||
eachRecursive(obj[k]);
|
||||
else {
|
||||
for ( var key in obj ){
|
||||
if ( key === "$ref" ){
|
||||
obj[k] = "cyclic structure removed";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
eachRecursive(o)
|
||||
return o
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof JSON.decycle !== "function") {
|
||||
JSON.decycle = function decycle(object, replacer) {
|
||||
"use strict";
|
||||
|
||||
var objects = new WeakMap(); // object to path mappings
|
||||
|
||||
return (function derez(value, path) {
|
||||
|
||||
var old_path; // The path of an earlier occurance of value
|
||||
var nu; // The new object or array
|
||||
|
||||
if (replacer !== undefined) {
|
||||
value = replacer(value);
|
||||
}
|
||||
|
||||
if (
|
||||
typeof value === "object"
|
||||
&& value !== null
|
||||
&& !(value instanceof Boolean)
|
||||
&& !(value instanceof Date)
|
||||
&& !(value instanceof Number)
|
||||
&& !(value instanceof RegExp)
|
||||
&& !(value instanceof String)
|
||||
) {
|
||||
|
||||
|
||||
old_path = objects.get(value);
|
||||
if (old_path !== undefined) {
|
||||
return {$ref: old_path};
|
||||
}
|
||||
|
||||
|
||||
objects.set(value, path);
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
nu = [];
|
||||
value.forEach(function (element, i) {
|
||||
nu[i] = derez(element, path + "[" + i + "]");
|
||||
});
|
||||
} else {
|
||||
|
||||
nu = {};
|
||||
Object.keys(value).forEach(function (name) {
|
||||
nu[name] = derez(
|
||||
value[name],
|
||||
path + "[" + JSON.stringify(name) + "]"
|
||||
);
|
||||
});
|
||||
}
|
||||
return nu;
|
||||
}
|
||||
return value;
|
||||
}(object, "$"));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
if (typeof JSON.retrocycle !== "function") {
|
||||
JSON.retrocycle = function retrocycle($) {
|
||||
"use strict";
|
||||
|
||||
var px = /^\$(?:\[(?:\d+|"(?:[^\\"\u0000-\u001f]|\\(?:[\\"\/bfnrt]|u[0-9a-zA-Z]{4}))*")\])*$/;
|
||||
|
||||
(function rez(value) {
|
||||
|
||||
|
||||
if (value && typeof value === "object") {
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach(function (element, i) {
|
||||
if (typeof element === "object" && element !== null) {
|
||||
var path = element.$ref;
|
||||
if (typeof path === "string" && px.test(path)) {
|
||||
value[i] = eval(path);
|
||||
} else {
|
||||
rez(element);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Object.keys(value).forEach(function (name) {
|
||||
var item = value[name];
|
||||
if (typeof item === "object" && item !== null) {
|
||||
var path = item.$ref;
|
||||
if (typeof path === "string" && px.test(path)) {
|
||||
value[name] = eval(path);
|
||||
} else {
|
||||
rez(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}($));
|
||||
return $;
|
||||
};
|
||||
}
|
@ -1,48 +1,88 @@
|
||||
extends ./template
|
||||
block content
|
||||
h2 Shared With
|
||||
h2 Owned By
|
||||
table
|
||||
thead
|
||||
tr
|
||||
th(scope='col' style='min-width: 250px') Username
|
||||
th(scope='col') Actions
|
||||
tbody
|
||||
each user in sharing.shared
|
||||
tr
|
||||
td #{(sharing.current_owns ? `You (${sharing.owner.username})` : sharing.owner.username)}
|
||||
|
||||
if sharing.read.length > 0
|
||||
br
|
||||
h2 Shared With (Read-Only)
|
||||
table
|
||||
thead
|
||||
tr
|
||||
td #{(user.uuid === project.user_id ? user.username + " (Owner)" : user.username)}
|
||||
td
|
||||
ul(style='list-style-type: none; margin: 0; padding: 0;')
|
||||
if !(user.uuid === project.user_id)
|
||||
li
|
||||
a.action(href='/dash/v1/project/share/'+project.id+'/revoke/'+user.uuid) Revoke
|
||||
li
|
||||
a.action(href='/dash/v1/project/share/'+project.id+'/transfer/'+user.uuid) Transfer Ownership
|
||||
else
|
||||
li
|
||||
strike Revoke
|
||||
li
|
||||
strike Transfer Ownership
|
||||
th(scope='col' style='min-width: 250px') Username
|
||||
th(scope='col') Actions
|
||||
tbody
|
||||
each user in sharing.read
|
||||
tr
|
||||
td #{(user.uuid === project.user_id ? user.username + " (Owner)" : user.username)}
|
||||
td
|
||||
ul(style='list-style-type: none; margin: 0; padding: 0;')
|
||||
if !(user.uuid === project.user_id)
|
||||
li
|
||||
a.action(href='/dash/v1/project/share/'+project.id+'/revoke/'+user.uuid) Revoke
|
||||
li
|
||||
a.action(href='/dash/v1/project/share/'+project.id+'/transfer/'+user.uuid) Transfer Ownership
|
||||
else
|
||||
li
|
||||
strike Revoke
|
||||
li
|
||||
strike Transfer Ownership
|
||||
|
||||
if sharing.edit.length > 0
|
||||
br
|
||||
h2 Shared With (Edit)
|
||||
table
|
||||
thead
|
||||
tr
|
||||
th(scope='col' style='min-width: 250px') Username
|
||||
th(scope='col') Actions
|
||||
tbody
|
||||
each user in sharing.edit
|
||||
tr
|
||||
td #{(user.uuid === project.user_id ? user.username + " (Owner)" : user.username)}
|
||||
td
|
||||
ul(style='list-style-type: none; margin: 0; padding: 0;')
|
||||
if !(user.uuid === project.user_id)
|
||||
li
|
||||
a.action(href='/dash/v1/project/share/'+project.id+'/revoke/'+user.uuid+'/edit') Revoke
|
||||
li
|
||||
a.action(href='/dash/v1/project/share/'+project.id+'/transfer/'+user.uuid) Transfer Ownership
|
||||
else
|
||||
li
|
||||
strike Revoke
|
||||
li
|
||||
strike Transfer Ownership
|
||||
br
|
||||
h2 Share With New User
|
||||
a.btn(href='/dash/v1/project/share/'+project.id+'/invite') Generate Sharing Link
|
||||
br
|
||||
br
|
||||
table
|
||||
thead
|
||||
tr
|
||||
th(scope='col' style='min-width: 250px') Username
|
||||
th(scope='col') Actions
|
||||
tbody
|
||||
each user in sharing.to_share
|
||||
|
||||
if sharing.other.length > 0
|
||||
br
|
||||
br
|
||||
table
|
||||
thead
|
||||
tr
|
||||
td #{(user.uuid === project.user_id ? user.username + " (Owner)" : user.username)}
|
||||
td
|
||||
ul(style='list-style-type: none; margin: 0; padding: 0;')
|
||||
if !(user.uuid === project.user_id)
|
||||
li
|
||||
a.action(href='/dash/v1/project/share/' + project.id + '/share/'+user.uuid) Share
|
||||
else
|
||||
th(scope='col' style='min-width: 250px') Username
|
||||
th(scope='col') Actions
|
||||
tbody
|
||||
each user in sharing.other
|
||||
tr
|
||||
td #{(user.uuid === project.user_id ? user.username + " (Owner)" : user.username)}
|
||||
td
|
||||
ul(style='list-style-type: none; margin: 0; padding: 0;')
|
||||
if !(user.uuid === project.user_id)
|
||||
li
|
||||
a.action(href='/dash/v1/project/share/' + project.id + '/share/'+user.uuid) Share (View)
|
||||
li
|
||||
a.action(href='/dash/v1/project/share/' + project.id + '/share/'+user.uuid+'/edit') Share (Edit)
|
||||
else
|
||||
li
|
||||
strike Share
|
||||
li
|
||||
strike Share
|
||||
li
|
||||
a.action(href='/dash/v1/project/share/' + project.id + '/transfer/' + user.uuid) Transfer Ownership
|
||||
a.action(href='/dash/v1/project/share/' + project.id + '/transfer/' + user.uuid) Transfer Ownership
|
||||
|
Loading…
Reference in new issue