diff --git a/app/assets/agents/ecma5.js b/app/assets/agents/ecma5.js new file mode 100644 index 0000000..efcf1ce --- /dev/null +++ b/app/assets/agents/ecma5.js @@ -0,0 +1,69 @@ +const devbug = { + outs: {}, + url: 'http://localhost:8000/', + api_key: false, + out(key, what, group=false){ + console.log(this) + if ( group ){ + if ( !Object.keys(this.outs).includes(group) ) this.outs[group] = {} + this.outs[group][key] = what + return this; + } + this.outs[key] = what + return this; + }, + script(addr, then){ + var sc = document.createElement('script'); + sc.src = addr; sc.type = 'text/javascript'; + sc.onload = then; + document.getElementsByTagName('head')[0].appendChild(sc); + return this; + }, + load_dc: function(then){ this.script(this.url+'assets/cycle.js', then); return this; }, + load_jq: function(then){ + this.script('https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js', () => { + $ = window.jQuery; + $(then); + }); + return this; + }, + libs: function(then){ + // need both + if ( typeof JSON.rmref !== 'function' && typeof window.jQuery !== 'function' ) this.load_dc(() => this.load_jq(then)) + // need decycle + else if ( typeof JSON.rmref !== 'function' ) this.load_dc(then) + // need jquery + else if ( typeof window.jQuery !== 'function' ) this.load_jq(then) + else then() + return this; + }, + json(data){ + return JSON.stringify(JSON.rmref(JSON.decycle(data))); + }, + breakpoint(name, exception = false){ + var e = new Error(); + this.libs(() => { + 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(); + data.append('data', this.json({ + brief: (name ? name : 'Breakpoint')+`: ${caller}`, + data: this.outs, + })) + $.ajax({ + url: this.url+'api/v1/out/'+this.api_key, + data, cache: false, contentType: false, processData: false, method: 'POST', type: 'POST', + success: (res) => { console.log('DevBug POST Completed'); console.debug(res); } + }) + }) + if ( exception ) throw e + return this + } +} + +window.devbug = devbug; +window.out = window.devbug.out.bind(window.devbug); +window.breakpoint = window.devbug.breakpoint.bind(window.devbug); \ No newline at end of file diff --git a/app/assets/cycle.js b/app/assets/cycle.js index 2e980f6..2542321 100644 --- a/app/assets/cycle.js +++ b/app/assets/cycle.js @@ -1,14 +1,15 @@ if (typeof JSON.rmref !== "function") { JSON.rmref = function rmref(o){ - function eachRecursive(obj) { + function eachRecursive(obj, ci = 'root', ci2 = 'root') { for (var k in obj) { if (typeof obj[k] == "object" && obj[k] !== null) - eachRecursive(obj[k]); + eachRecursive(obj[k], k, ci); else { for ( var key in obj ){ if ( key === "$ref" ){ - obj[k] = "cyclic structure removed"; + console.log(obj[k]) + obj[k] = "cyclic structure removed: "+ci2; break; } } diff --git a/app/views/dash_v1/share.pug b/app/views/dash_v1/share.pug index ac00146..02f2c06 100644 --- a/app/views/dash_v1/share.pug +++ b/app/views/dash_v1/share.pug @@ -24,14 +24,14 @@ block content td ul(style='list-style-type: none; margin: 0; padding: 0;') if !(user.uuid === project.user_id) - li + li.action-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 + li.action-li strike Revoke - li + li.action-li strike Transfer Ownership if sharing.edit.length > 0 @@ -49,14 +49,14 @@ block content td ul(style='list-style-type: none; margin: 0; padding: 0;') if !(user.uuid === project.user_id) - li + li.action-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 + li.action-li strike Revoke - li + li.action-li strike Transfer Ownership br h2 Share With New User @@ -77,12 +77,12 @@ block content td ul(style='list-style-type: none; margin: 0; padding: 0;') if !(user.uuid === project.user_id) - li + li.action-li a.action(href='/dash/v1/project/share/' + project.id + '/share/'+user.uuid) Share (View) - li + li.action-li a.action(href='/dash/v1/project/share/' + project.id + '/share/'+user.uuid+'/edit') Share (Edit) else - li + li.action-li strike Share - li + li.action-li a.action(href='/dash/v1/project/share/' + project.id + '/transfer/' + user.uuid) Transfer Ownership diff --git a/app/views/dash_v1/view.pug b/app/views/dash_v1/view.pug index 958951c..aeeda74 100644 --- a/app/views/dash_v1/view.pug +++ b/app/views/dash_v1/view.pug @@ -14,8 +14,8 @@ block content td #{ out.created.toLocaleString({timeZone: 'America/Chicago'}) } td ul(style='list-style-type: none; margin: 0; padding: 0;') - li + li.action-li a.action(href='/dash/v1/out/view/'+out.id) View if ( devbug.permission.project.edit(project, user) ) - li + li.action-li a.action(href='/dash/v1/out/delete/'+out.id+'/'+project.id) Delete diff --git a/app/views/errors/500.pug b/app/views/errors/500.pug index 88a14ae..b508d47 100644 --- a/app/views/errors/500.pug +++ b/app/views/errors/500.pug @@ -30,4 +30,4 @@ html body .flitter-container img.flitter-image(src="/assets/flitter.png") - p.flitter-name 500: Internal Server Error \ No newline at end of file + p.flitter-name 500: #{(reason ? reason : "Internal Server Error")} \ No newline at end of file