update flap and add latest output button
This commit is contained in:
parent
5afe24ed52
commit
287cd0107d
@ -69,46 +69,63 @@ dbsetup({
|
||||
// ===========================================================
|
||||
// DEVBUG INLINE DEBUGGING HELPER - FOR USE WITH DEVBUG SERVER
|
||||
// TODO: REMOVE BEFORE COMMITTING
|
||||
$dev_outs = [];
|
||||
function devbug_microtime($difftime = 0){
|
||||
$time = explode(' ', microtime()); return ((float)$time[1]+(float)$time[0])-$difftime; }
|
||||
$GLOBALS['devbug_dev_outs'] = [];
|
||||
$GLOBALS['devbug_dev_out_iters'] = [];
|
||||
$GLOBALS['devbug_mark_time'] = devbug_microtime();
|
||||
function out($key, $what, $group = null){
|
||||
global $dev_outs;
|
||||
if ( $group ){
|
||||
if ( !array_key_exists($group, $dev_outs) ){
|
||||
$dev_outs[$group] = [ $key => $what ];
|
||||
}
|
||||
else {
|
||||
$dev_outs[$group][$key] = $what;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$dev_outs[$key] = $what;
|
||||
}
|
||||
$dev_outs = $GLOBALS['devbug_dev_outs'];
|
||||
if ( $group ){
|
||||
if ( !array_key_exists($group, $dev_outs) ) $dev_outs[$group] = [ $key => $what ];
|
||||
else $dev_outs[$group][$key] = $what;
|
||||
}
|
||||
else $dev_outs[$key] = $what;
|
||||
$GLOBALS['devbug_dev_outs'] = $dev_outs;
|
||||
}
|
||||
function breakpoint($continue = false, $name = null){
|
||||
global $dev_outs;
|
||||
$devbug = "{{ Server URL }}";
|
||||
$project_api_key = "{{ Project API Key }}";
|
||||
$bt = debug_backtrace();
|
||||
$caller = array_shift($bt);
|
||||
$dev_outs = $GLOBALS['devbug_dev_outs'];
|
||||
$devbug = "{{ Server URL }}/";
|
||||
$project_api_key = "{{ Project API Key }}";
|
||||
$bt = debug_backtrace();
|
||||
$caller = array_shift($bt);
|
||||
$time = devbug_microtime();
|
||||
$dev_outs['DevBug Summary'] = [
|
||||
'Start Time' => $GLOBALS['devbug_mark_time'],
|
||||
'Breakpoint Time' => $time,
|
||||
'Total Execution Time' => $time - $GLOBALS['devbug_mark_time'],
|
||||
'Breakpoint Stacktrace' => $caller,
|
||||
];
|
||||
|
||||
// Send to devbug server
|
||||
$ch = curl_init();
|
||||
$url = $devbug.'api/v1/out/'.$project_api_key;
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, [
|
||||
'data' => json_encode([
|
||||
'brief' => ($name ? $name : 'Breakpoint').': '.$caller['file'].': '.$caller['line'],
|
||||
'data' => $dev_outs,
|
||||
])
|
||||
]);
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$odata = curl_exec($ch);
|
||||
|
||||
if ( !$continue ) { exit(); }
|
||||
// Send to devbug server
|
||||
$ch = curl_init();
|
||||
$url = $devbug.'api/v1/out/'.$project_api_key;
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, [
|
||||
'data' => json_encode([
|
||||
'brief' => ($name ? $name : 'Breakpoint').': '.$caller['file'].': '.$caller['line'],
|
||||
'data' => $dev_outs,
|
||||
])
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$odata = curl_exec($ch);
|
||||
if ( !$continue ) { exit(); }
|
||||
}
|
||||
function devbugtime($prefix = 'time: '){ $mt = explode(' ', microtime()); $mt = $mt[1].' '.$mt[0]; return $prefix.$mt; }
|
||||
function outtime($key, $what, $group = null){ out(devbugtime($key), $what, $group); }
|
||||
function outiter($key, $what, $group = null){
|
||||
$keyname = $group ? $key.$group : $key;
|
||||
if ( !$GLOBALS['devbug_dev_out_iters'][$keyname] ) $GLOBALS['devbug_dev_out_iters'][$keyname] = 0;
|
||||
out($key.'_'.$GLOBALS['devbug_dev_out_iters'][$keyname], $what, $group);
|
||||
$GLOBALS['devbug_dev_out_iters'][$keyname]++;
|
||||
}
|
||||
function outpoint($group){
|
||||
$bt = debug_backtrace();
|
||||
$caller = array_shift($bt);
|
||||
out('point: '.$caller['file'].': '.$caller['line'], devbugtime(), $group);
|
||||
}
|
||||
function devbug_chop($string, $at=120){ return substr($string, 0, 30); }
|
||||
// ===========================================================`,
|
||||
},
|
||||
permission: {
|
||||
|
@ -196,6 +196,29 @@ class v1 {
|
||||
|
||||
return _flitter.view(res, 'dash_v1:out', {project, user: req.session.auth.user, out, prettyd:pretty, show_back: true, title: out.brief, title_small: true });
|
||||
}
|
||||
|
||||
async out_latest(req, res, next){
|
||||
const project = await Project.findById(req.params.project)
|
||||
if ( !project || (!await devbug.permission.project.view(project, req.session.auth.user)) ){
|
||||
return _flitter.error(res, 401, {reason: 'You do not have permission to view this project.'})
|
||||
}
|
||||
|
||||
const out = await Out.findOne({}, {}, { sort: { 'created': -1 } })
|
||||
if ( !out ){
|
||||
return _flitter.error(res, 404, {reason: 'This project has no outputs yet.'})
|
||||
}
|
||||
|
||||
let pretty
|
||||
try {
|
||||
pretty = JSON.stringify(JSON.parse(out.data), null, 4)
|
||||
console.log('Pretty out: ', pretty)
|
||||
}
|
||||
catch (e){
|
||||
return _flitter.error(res, 500, {reason: 'Unable to parse output data. Data contains invalid JSON.'})
|
||||
}
|
||||
|
||||
return _flitter.view(res, 'dash_v1:out', {project, user: req.session.auth.user, out, prettyd:pretty, show_back: true, title: 'Latest output: '+out.brief, title_small: true });
|
||||
}
|
||||
|
||||
async out_delete(req, res, next){
|
||||
const out = await Out.findById(req.params.id)
|
||||
|
@ -57,6 +57,7 @@ const v1 = {
|
||||
'/using_devbug/:page': [ _flitter.controller('dash:v1').show_usage_page ],
|
||||
|
||||
'/out/view/:id': [ _flitter.controller('dash:v1').out_view ],
|
||||
'/out/view-latest/:project': [ _flitter.controller('dash:v1').out_latest ],
|
||||
'/out/delete/:id/:project': [ _flitter.controller('dash:v1').out_delete ],
|
||||
|
||||
'/code': [ _flitter.controller('dash:v1').view_code ],
|
||||
|
@ -43,6 +43,7 @@ block content
|
||||
a.action(href='/dash/v1/snippet/share/'+snippet.id) Share
|
||||
|
||||
h2 Development Outputs
|
||||
a.btn(href='/dash/v1/out/view-latest/'+project.id) Latest
|
||||
table
|
||||
thead
|
||||
tr
|
||||
|
@ -18,9 +18,10 @@
|
||||
"dependencies": {
|
||||
"flitter-auth": "^0.4.0",
|
||||
"flitter-cli": "^0.10.0",
|
||||
"flitter-flap": "^0.2.2",
|
||||
"flitter-flap": "^0.3.0",
|
||||
"flitter-forms": "^0.7.2",
|
||||
"flitter-upload": "^0.7.6",
|
||||
"js-beautify": "^1.10.2",
|
||||
"libflitter": "^0.27.4",
|
||||
"stringify-object": "^3.3.0"
|
||||
}
|
||||
|
78
yarn.lock
78
yarn.lock
@ -487,7 +487,7 @@ command-line-args@^5.0.2:
|
||||
lodash.camelcase "^4.3.0"
|
||||
typical "^4.0.0"
|
||||
|
||||
commander@^2.5.0, commander@^2.9.0:
|
||||
commander@^2.19.0, commander@^2.5.0, commander@^2.9.0:
|
||||
version "2.20.0"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422"
|
||||
integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==
|
||||
@ -512,6 +512,14 @@ concat-map@0.0.1:
|
||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
|
||||
|
||||
config-chain@^1.1.12:
|
||||
version "1.1.12"
|
||||
resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.12.tgz#0fde8d091200eb5e808caf25fe618c02f48e4efa"
|
||||
integrity sha512-a1eOIcu8+7lUInge4Rpf/n4Krkf3Dd9lqhljRzII1/Zno/kRtUWnznPO3jOKBmTEktkt3fkxisUcivoj0ebzoA==
|
||||
dependencies:
|
||||
ini "^1.3.4"
|
||||
proto-list "~1.2.1"
|
||||
|
||||
connect-mongodb-session@^2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/connect-mongodb-session/-/connect-mongodb-session-2.2.0.tgz#3d70bc9912756bfdfd2aeeda4def1fd9e07c69a6"
|
||||
@ -701,6 +709,16 @@ dotenv@^6.2.0:
|
||||
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-6.2.0.tgz#941c0410535d942c8becf28d3f357dbd9d476064"
|
||||
integrity sha512-HygQCKUBSFl8wKQZBSemMywRWcEDNidvNbjGVyZu3nbZ8qq9ubiPoGLMdRDpfSrpkkm9BXYFkpKxxFX38o/76w==
|
||||
|
||||
editorconfig@^0.15.3:
|
||||
version "0.15.3"
|
||||
resolved "https://registry.yarnpkg.com/editorconfig/-/editorconfig-0.15.3.tgz#bef84c4e75fb8dcb0ce5cee8efd51c15999befc5"
|
||||
integrity sha512-M9wIMFx96vq0R4F+gRpY3o2exzb8hEj/n9S8unZtHSvYjibBp/iMufSzvmOcV/laG0ZtuTVGtiJggPOSW2r93g==
|
||||
dependencies:
|
||||
commander "^2.19.0"
|
||||
lru-cache "^4.1.5"
|
||||
semver "^5.6.0"
|
||||
sigmund "^1.0.1"
|
||||
|
||||
ee-first@1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
|
||||
@ -851,10 +869,10 @@ flitter-cli@^0.10.0:
|
||||
mkdirp "^0.5.1"
|
||||
nesh "^1.7.0"
|
||||
|
||||
flitter-flap@^0.2.2:
|
||||
version "0.2.2"
|
||||
resolved "https://registry.yarnpkg.com/flitter-flap/-/flitter-flap-0.2.2.tgz#5735567510ba85ebfede2e1ed47dc2f36c0e962b"
|
||||
integrity sha512-iy1RqEcls36NDTGO6u/IZ58z/2yQFeR1Sa/BqTGkKzPQFOBoxMl7uoFSsMvmiwH9d6qJDOZ5SE2jGTav9NJNtw==
|
||||
flitter-flap@^0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/flitter-flap/-/flitter-flap-0.3.0.tgz#04db1cf5181dd874acab66b064dc783294ccf69d"
|
||||
integrity sha512-v7mwgQR6cvz/LPV9ZHNVVIGFKU7wjwjw+OcTuwIKz8q1W7HWf9Vicy7ucXnRLOvMpOUb3GIWOaCqxBQfHBz/mg==
|
||||
dependencies:
|
||||
del "^4.1.0"
|
||||
node-migration "^1.0.1"
|
||||
@ -1060,7 +1078,7 @@ inherits@2, inherits@2.0.3, inherits@~2.0.1, inherits@~2.0.3:
|
||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
||||
integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=
|
||||
|
||||
ini@~1.3.0:
|
||||
ini@^1.3.4, ini@~1.3.0:
|
||||
version "1.3.5"
|
||||
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927"
|
||||
integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==
|
||||
@ -1173,6 +1191,17 @@ isarray@~1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
|
||||
integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=
|
||||
|
||||
js-beautify@^1.10.2:
|
||||
version "1.10.2"
|
||||
resolved "https://registry.yarnpkg.com/js-beautify/-/js-beautify-1.10.2.tgz#88c9099cd6559402b124cfab18754936f8a7b178"
|
||||
integrity sha512-ZtBYyNUYJIsBWERnQP0rPN9KjkrDfJcMjuVGcvXOUJrD1zmOGwhRwQ4msG+HJ+Ni/FA7+sRQEMYVzdTQDvnzvQ==
|
||||
dependencies:
|
||||
config-chain "^1.1.12"
|
||||
editorconfig "^0.15.3"
|
||||
glob "^7.1.3"
|
||||
mkdirp "~0.5.1"
|
||||
nopt "~4.0.1"
|
||||
|
||||
js-stringify@^1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/js-stringify/-/js-stringify-1.0.2.tgz#1736fddfd9724f28a3682adc6230ae7e4e9679db"
|
||||
@ -1322,6 +1351,14 @@ longest@^1.0.1:
|
||||
resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097"
|
||||
integrity sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=
|
||||
|
||||
lru-cache@^4.1.5:
|
||||
version "4.1.5"
|
||||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd"
|
||||
integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==
|
||||
dependencies:
|
||||
pseudomap "^1.0.2"
|
||||
yallist "^2.1.2"
|
||||
|
||||
media-typer@0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
|
||||
@ -1403,7 +1440,7 @@ minizlib@^1.1.1:
|
||||
dependencies:
|
||||
minipass "^2.2.1"
|
||||
|
||||
mkdirp@^0.5.0, mkdirp@^0.5.1:
|
||||
mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1:
|
||||
version "0.5.1"
|
||||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
|
||||
integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=
|
||||
@ -1559,7 +1596,7 @@ node-pre-gyp@0.12.0:
|
||||
semver "^5.3.0"
|
||||
tar "^4"
|
||||
|
||||
nopt@^4.0.1:
|
||||
nopt@^4.0.1, nopt@~4.0.1:
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d"
|
||||
integrity sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=
|
||||
@ -1742,6 +1779,11 @@ promise@^7.0.1:
|
||||
dependencies:
|
||||
asap "~2.0.3"
|
||||
|
||||
proto-list@~1.2.1:
|
||||
version "1.2.4"
|
||||
resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849"
|
||||
integrity sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk=
|
||||
|
||||
proxy-addr@~2.0.4:
|
||||
version "2.0.4"
|
||||
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.4.tgz#ecfc733bf22ff8c6f407fa275327b9ab67e48b93"
|
||||
@ -1750,6 +1792,11 @@ proxy-addr@~2.0.4:
|
||||
forwarded "~0.1.2"
|
||||
ipaddr.js "1.8.0"
|
||||
|
||||
pseudomap@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
|
||||
integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM=
|
||||
|
||||
pug-attrs@^2.0.3:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/pug-attrs/-/pug-attrs-2.0.3.tgz#a3095f970e64151f7bdad957eef55fb5d7905d15"
|
||||
@ -2088,6 +2135,11 @@ semver@^5.1.0, semver@^5.3.0:
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b"
|
||||
integrity sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==
|
||||
|
||||
semver@^5.6.0:
|
||||
version "5.7.1"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
|
||||
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
|
||||
|
||||
send@0.16.2:
|
||||
version "0.16.2"
|
||||
resolved "https://registry.yarnpkg.com/send/-/send-0.16.2.tgz#6ecca1e0f8c156d141597559848df64730a6bbc1"
|
||||
@ -2137,6 +2189,11 @@ sift@7.0.1:
|
||||
resolved "https://registry.yarnpkg.com/sift/-/sift-7.0.1.tgz#47d62c50b159d316f1372f8b53f9c10cd21a4b08"
|
||||
integrity sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g==
|
||||
|
||||
sigmund@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590"
|
||||
integrity sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=
|
||||
|
||||
signal-exit@^3.0.0:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
|
||||
@ -2465,6 +2522,11 @@ y18n@^3.2.0:
|
||||
resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41"
|
||||
integrity sha1-bRX7qITAhnnA136I53WegR4H+kE=
|
||||
|
||||
yallist@^2.1.2:
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"
|
||||
integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=
|
||||
|
||||
yallist@^3.0.0, yallist@^3.0.2:
|
||||
version "3.0.3"
|
||||
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9"
|
||||
|
Loading…
Reference in New Issue
Block a user