cpee 2.1.141 → 2.1.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/cockpit/compliance-view.html +2 -5
- data/cockpit/compliance.html +2 -5
- data/cockpit/conformance.html +299 -0
- data/cockpit/css/compliance.css +3 -64
- data/cockpit/css/ui.css +7 -5
- data/cockpit/edit.html +1 -4
- data/cockpit/graph.html +1 -4
- data/cockpit/index.html +1 -4
- data/cockpit/js/compliance.js +85 -396
- data/cockpit/js/extended_columns.js +1 -1
- data/cockpit/js/instance.js +3 -3
- data/cockpit/js/mp-conformance.js +84 -0
- data/cockpit/js/parameters.js +3 -1
- data/cockpit/js/ui.js +2 -2
- data/cockpit/js/wfadaptor.js +41 -30
- data/cockpit/llm.html +1 -4
- data/cockpit/llmmodel.html +1 -4
- data/cockpit/model.html +1 -4
- data/cockpit/only_llm.html +1 -4
- data/cockpit/rngs/aggregations.rng +15 -0
- data/cockpit/rngs/intervals.rng +12 -0
- data/cockpit/rngs/nlrequirements.rng +8 -0
- data/cockpit/rngs/requirements.rng +2 -2
- data/cockpit/rngs/rules.rng +30 -0
- data/cockpit/themes/base.js +5 -4
- data/cockpit/track.html +1 -4
- data/cpee.gemspec +1 -1
- data/lib/cpee/implementation_callbacks.rb +4 -2
- data/lib/cpee/implementation_notifications.rb +2 -2
- data/server/executionhandlers/ruby/controller.rb +4 -1
- metadata +7 -1
data/cockpit/js/compliance.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
var latestComplianceResult = null;
|
|
2
|
+
var requirements_state = { requirements: null, nl: null };
|
|
2
3
|
|
|
3
4
|
$(document).ready(function() { //{{{
|
|
4
5
|
$.ajax({
|
|
@@ -7,12 +8,18 @@ $(document).ready(function() { //{{{
|
|
|
7
8
|
dataType: "xml",
|
|
8
9
|
success: function(rng){
|
|
9
10
|
save['requirements'] = new RelaxNGui(rng,$('#dat_requirements'));
|
|
10
|
-
|
|
11
|
+
load_requirements();
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
$.ajax({
|
|
15
|
+
type: "GET",
|
|
16
|
+
url: "rngs/nlrequirements.rng",
|
|
17
|
+
dataType: "xml",
|
|
18
|
+
success: function(rng){
|
|
19
|
+
save['nlrequirements'] = new RelaxNGui(rng,$('#dat_nlrequirements'));
|
|
20
|
+
load_requirements();
|
|
11
21
|
}
|
|
12
22
|
});
|
|
13
|
-
|
|
14
|
-
initialize_nl_requirements_tab();
|
|
15
|
-
initialize_ast_requirements_tab();
|
|
16
23
|
|
|
17
24
|
function loadComplianceLog(uuid, options) {
|
|
18
25
|
var renderOptions = options || {};
|
|
@@ -434,268 +441,126 @@ $(document).ready(function() { //{{{
|
|
|
434
441
|
});
|
|
435
442
|
});
|
|
436
443
|
|
|
437
|
-
document.addEventListener('attributes:changed', function
|
|
438
|
-
|
|
439
|
-
let reqs;
|
|
440
|
-
let regex = /\"\s*=>\s*"/g
|
|
441
|
-
if (save.attributes_raw.requirements.match(regex)) {
|
|
442
|
-
reqs = save.attributes_raw.requirements.replace(regex,"\":\"");
|
|
443
|
-
} else {
|
|
444
|
-
reqs = save.attributes_raw.requirements;
|
|
445
|
-
}
|
|
446
|
-
reqj = JSON.parse(reqs);
|
|
447
|
-
for (let key in reqj) {
|
|
448
|
-
let ele = $X("<" + key + " xmlns='http://cpee.org/ns/properties/2.0'/>");
|
|
449
|
-
ele.text(reqj[key]);
|
|
450
|
-
req.append(ele);
|
|
451
|
-
}
|
|
452
|
-
save['requirements'].content(req);
|
|
453
|
-
ensure_ast_inline_save_buttons(reqj);
|
|
454
|
-
sync_nl_rows_to_requirement_keys(reqj);
|
|
455
|
-
|
|
456
|
-
let nlReqj = parse_saved_object(save.attributes_raw['NL-requirements']);
|
|
457
|
-
sync_nl_rows_to_requirement_keys(nlReqj);
|
|
458
|
-
apply_nl_requirements_values(nlReqj);
|
|
459
|
-
});
|
|
460
|
-
|
|
461
|
-
$(document).on('relaxngui_remove', '#dat_requirements', function(event){
|
|
462
|
-
sync_nl_rows_to_requirement_keys(read_requirements_object(), true);
|
|
463
|
-
do_nl_requirements_save(event);
|
|
464
|
-
do_requirements_save(event);
|
|
465
|
-
});
|
|
466
|
-
$(document).on('relaxngui_move', '#dat_requirements', function(event){
|
|
467
|
-
do_requirements_save(event);
|
|
468
|
-
});
|
|
469
|
-
$(document).on('relaxngui_change', '#dat_requirements', function(event){
|
|
470
|
-
do_requirements_save(event);
|
|
444
|
+
document.addEventListener('attributes:changed', function() {
|
|
445
|
+
load_requirements();
|
|
471
446
|
});
|
|
472
447
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
clearTimeout(astButtonsTimer);
|
|
476
|
-
astButtonsTimer = setTimeout(function() {
|
|
477
|
-
ensure_ast_inline_save_buttons(read_requirements_object());
|
|
478
|
-
}, 250);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
// Requirements RNG is generic anyName/value, so keys can be renamed live.
|
|
482
|
-
// Keep the per-requirement action list aligned with current editor content.
|
|
483
|
-
$(document).on(
|
|
484
|
-
'input change keyup blur paste',
|
|
485
|
-
'#dat_requirements input, #dat_requirements textarea, #dat_requirements select, #dat_requirements [contenteditable=true]',
|
|
486
|
-
function() {
|
|
487
|
-
schedule_ast_buttons_sync();
|
|
488
|
-
}
|
|
489
|
-
);
|
|
490
|
-
|
|
491
|
-
var nlTimer;
|
|
492
|
-
$(document).on('input', '#dat_nlrequirements .nlreq-text', function(event){
|
|
493
|
-
clearTimeout(nlTimer);
|
|
494
|
-
nlTimer = setTimeout(function(){ do_nl_requirements_save(event); }, 2000);
|
|
448
|
+
$(document).on('relaxngui_remove', '#dat_requirements', function() {
|
|
449
|
+
prune_nl_requirements();
|
|
495
450
|
});
|
|
496
451
|
}); //}}}
|
|
497
452
|
|
|
498
|
-
function
|
|
499
|
-
|
|
500
|
-
sync_nl_rows_to_requirement_keys(read_requirements_object(), true);
|
|
501
|
-
add_nl_requirement_row();
|
|
502
|
-
do_nl_requirements_save();
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
if ($('#dat_nlrequirements .nlreq-row').length === 0) {
|
|
506
|
-
add_nl_requirement_row();
|
|
507
|
-
}
|
|
453
|
+
function read_requirements(editor) { //{{{
|
|
454
|
+
return editor ? parse_saved_object(editor.save_json()) : {};
|
|
508
455
|
} //}}}
|
|
509
456
|
|
|
510
|
-
function
|
|
511
|
-
$(
|
|
512
|
-
|
|
457
|
+
function requirements_xml(rootName, reqObject) { //{{{
|
|
458
|
+
let req = $X("<" + rootName + " xmlns='http://cpee.org/ns/properties/2.0'/>");
|
|
459
|
+
Object.keys(reqObject).forEach(function(key) {
|
|
460
|
+
let ele = $X("<" + key + " xmlns='http://cpee.org/ns/properties/2.0'/>");
|
|
461
|
+
ele.text(reqObject[key]);
|
|
462
|
+
req.append(ele);
|
|
513
463
|
});
|
|
514
|
-
|
|
515
|
-
ensure_ast_inline_save_buttons(read_requirements_object());
|
|
464
|
+
return req;
|
|
516
465
|
} //}}}
|
|
517
466
|
|
|
518
|
-
function
|
|
519
|
-
if (
|
|
467
|
+
function load_requirements() { //{{{
|
|
468
|
+
if (!save['requirements'] || !save['nlrequirements'] || !save['attributes_raw']) {
|
|
520
469
|
return;
|
|
521
470
|
}
|
|
471
|
+
let raw = save['attributes_raw'].requirements || '';
|
|
472
|
+
let nlraw = save['attributes_raw']['NL-requirements'] || '';
|
|
473
|
+
if (raw === requirements_state.requirements && nlraw === requirements_state.nl) {
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
requirements_state.requirements = raw;
|
|
477
|
+
requirements_state.nl = nlraw;
|
|
522
478
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
Object.keys(reqObject)
|
|
530
|
-
.sort(sort_requirement_ids)
|
|
531
|
-
.forEach(function(key) {
|
|
532
|
-
var keyInput = $('#dat_requirements input.relaxngui_cell').filter(function() {
|
|
533
|
-
return ($(this).val() || '').trim() === key;
|
|
534
|
-
}).first();
|
|
535
|
-
|
|
536
|
-
if (keyInput.length === 0) {
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
if (keyInput.prev('.astreq-save').length === 0) {
|
|
541
|
-
$('<button type="button" class="astreq-save" title="Save requirements into attributes">Save</button>')
|
|
542
|
-
.attr('data-requirement-id', key)
|
|
543
|
-
.insertBefore(keyInput);
|
|
544
|
-
} else {
|
|
545
|
-
keyInput.prev('.astreq-save').attr('data-requirement-id', key);
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
keyInput.addClass('astreq-key');
|
|
549
|
-
if ((keyInput.val() || '').trim() !== '') {
|
|
550
|
-
keyInput.prop('readonly', true);
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
var valueInput = keyInput.parent().find('input.relaxngui_cell').not(keyInput).first();
|
|
554
|
-
if (valueInput.length > 0) {
|
|
555
|
-
valueInput.addClass('astreq-value');
|
|
556
|
-
}
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
apply_ast_field_roles();
|
|
560
|
-
|
|
561
|
-
$('#dat_requirements .astreq-save').each(function() {
|
|
562
|
-
var btn = $(this);
|
|
563
|
-
var nextInput = btn.next('input.relaxngui_cell');
|
|
564
|
-
if (nextInput.length === 0) {
|
|
565
|
-
btn.remove();
|
|
566
|
-
}
|
|
567
|
-
});
|
|
568
|
-
} //}}}
|
|
569
|
-
|
|
570
|
-
function apply_ast_field_roles() { //{{{
|
|
571
|
-
$('#dat_requirements .astreq-key').prop('readonly', false).removeAttr('tabindex').css('pointer-events', '');
|
|
572
|
-
$('#dat_requirements .astreq-value').removeClass('astreq-value');
|
|
573
|
-
|
|
574
|
-
$('#dat_requirements').find('div').each(function() {
|
|
575
|
-
var cells = $(this).children('input.relaxngui_cell');
|
|
576
|
-
if (cells.length < 2) {
|
|
577
|
-
return;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
var keyCell = cells.first();
|
|
581
|
-
var valueCell = cells.last();
|
|
582
|
-
|
|
583
|
-
keyCell.addClass('astreq-key');
|
|
584
|
-
valueCell.addClass('astreq-value');
|
|
585
|
-
|
|
586
|
-
if ((keyCell.val() || '').trim() !== '') {
|
|
587
|
-
keyCell.prop('readonly', true);
|
|
588
|
-
keyCell.attr('tabindex', '-1');
|
|
589
|
-
keyCell.css('pointer-events', 'none');
|
|
479
|
+
let req = parse_saved_object(raw);
|
|
480
|
+
let nl = parse_saved_object(nlraw);
|
|
481
|
+
Object.keys(req).forEach(function(key) {
|
|
482
|
+
if (!(key in nl)) {
|
|
483
|
+
nl[key] = '';
|
|
590
484
|
}
|
|
591
485
|
});
|
|
486
|
+
save['requirements'].content(requirements_xml('requirements', req));
|
|
487
|
+
save['nlrequirements'].content(requirements_xml('nlrequirements', nl));
|
|
592
488
|
} //}}}
|
|
593
489
|
|
|
594
|
-
function
|
|
595
|
-
if (!
|
|
490
|
+
function save_requirements() { //{{{
|
|
491
|
+
if (!save['requirements'] || !save['nlrequirements'] || !save['attributes']) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
let req = JSON.stringify(read_requirements(save['requirements']));
|
|
495
|
+
let nl = JSON.stringify(read_requirements(save['nlrequirements']));
|
|
496
|
+
if (req === requirements_state.requirements && nl === requirements_state.nl) {
|
|
596
497
|
return;
|
|
597
498
|
}
|
|
598
499
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
var reqj = current_requirements_json_string();
|
|
604
|
-
do_requirements_save({ target: $('#dat_requirements')[0] }, reqj);
|
|
605
|
-
|
|
606
|
-
button.text('Saved');
|
|
607
|
-
button.prop('disabled', false);
|
|
608
|
-
setTimeout(function() {
|
|
609
|
-
button.text(originalText);
|
|
610
|
-
}, 900);
|
|
611
|
-
} //}}}
|
|
612
|
-
|
|
613
|
-
function initialize_nl_requirements_from_saved_requirements() { //{{{
|
|
614
|
-
if (!save['requirements']) {
|
|
500
|
+
let att = save['attributes'].save();
|
|
501
|
+
let attributes = $(' > attributes', att);
|
|
502
|
+
if (attributes.length === 0) {
|
|
615
503
|
return;
|
|
616
504
|
}
|
|
617
|
-
|
|
618
|
-
|
|
505
|
+
[['requirements', req], ['NL-requirements', nl]].forEach(function([name, value]) {
|
|
506
|
+
let node = attributes.children(name);
|
|
507
|
+
if (node.length === 0) {
|
|
508
|
+
node = $X("<" + name + " xmlns='http://cpee.org/ns/properties/2.0'/>");
|
|
509
|
+
attributes.append(node);
|
|
510
|
+
}
|
|
511
|
+
node.text(value);
|
|
512
|
+
save['attributes_raw'][name] = value;
|
|
513
|
+
});
|
|
514
|
+
requirements_state.requirements = req;
|
|
515
|
+
requirements_state.nl = nl;
|
|
516
|
+
save['attributes'].content(att);
|
|
517
|
+
do_parameters_save_part('attributes', $(att).serializePrettyXML());
|
|
619
518
|
} //}}}
|
|
620
519
|
|
|
621
|
-
function
|
|
622
|
-
|
|
623
|
-
|
|
520
|
+
function prune_nl_requirements() { //{{{
|
|
521
|
+
let current = read_requirements(save['requirements']);
|
|
522
|
+
let removed = Object.keys(parse_saved_object(requirements_state.requirements)).filter(function(key) {
|
|
523
|
+
return !(key in current);
|
|
524
|
+
});
|
|
525
|
+
if (removed.length === 0) {
|
|
624
526
|
return;
|
|
625
527
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
row.append($('<span class="nlreq-id"></span>').text(rid));
|
|
630
|
-
row.append(
|
|
631
|
-
$('<input type="text" class="nlreq-text" placeholder="Write natural-language requirement"/>')
|
|
632
|
-
.val(textValue || '')
|
|
633
|
-
);
|
|
634
|
-
row.append('<span class="nlreq-status"></span>');
|
|
635
|
-
row.find('.nlreq-extract').on('click', function() {
|
|
636
|
-
extract_single_nl_requirement(row);
|
|
528
|
+
let nl = read_requirements(save['nlrequirements']);
|
|
529
|
+
removed.forEach(function(key) {
|
|
530
|
+
delete nl[key];
|
|
637
531
|
});
|
|
638
|
-
|
|
532
|
+
save['nlrequirements'].content(requirements_xml('nlrequirements', nl));
|
|
639
533
|
} //}}}
|
|
640
534
|
|
|
641
|
-
function extract_single_nl_requirement(
|
|
642
|
-
var
|
|
643
|
-
var
|
|
644
|
-
var
|
|
645
|
-
var button =
|
|
535
|
+
function extract_single_nl_requirement(entry) { //{{{
|
|
536
|
+
var inputs = entry.find('.relaxngui_row > input.relaxngui_cell');
|
|
537
|
+
var requirementId = inputs.first().val();
|
|
538
|
+
var naturalText = (inputs.last().val() || '').trim();
|
|
539
|
+
var button = entry.children('[data-type=act]');
|
|
646
540
|
|
|
647
|
-
if (!naturalText) {
|
|
648
|
-
status.text('Enter text').removeClass('ok').addClass('error');
|
|
649
|
-
return;
|
|
650
|
-
}
|
|
651
|
-
if (!save['requirements']) {
|
|
652
|
-
status.text('Not ready').removeClass('ok').addClass('error');
|
|
541
|
+
if (!naturalText || !save['requirements']) {
|
|
653
542
|
return;
|
|
654
543
|
}
|
|
655
544
|
|
|
656
|
-
status.text('Extracting...').removeClass('ok error');
|
|
657
545
|
button.prop('disabled', true);
|
|
658
546
|
|
|
659
547
|
extract_ast_from_natural_language(
|
|
660
548
|
naturalText,
|
|
661
549
|
function(ast) {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
550
|
+
let req = read_requirements(save['requirements']);
|
|
551
|
+
req[requirementId] = ast;
|
|
552
|
+
save['requirements'].content(requirements_xml('requirements', req));
|
|
553
|
+
save_requirements();
|
|
665
554
|
button.prop('disabled', false);
|
|
666
555
|
},
|
|
667
|
-
function(
|
|
668
|
-
status.text(message || 'Failed').removeClass('ok').addClass('error');
|
|
556
|
+
function() {
|
|
669
557
|
button.prop('disabled', false);
|
|
670
558
|
}
|
|
671
559
|
);
|
|
672
560
|
} //}}}
|
|
673
561
|
|
|
674
|
-
function sync_nl_rows_to_requirement_keys(requirementsObject, pruneMissing) { //{{{
|
|
675
|
-
if (!requirementsObject || typeof requirementsObject !== 'object') {
|
|
676
|
-
return;
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
var keys = Object.keys(requirementsObject);
|
|
680
|
-
|
|
681
|
-
if (pruneMissing) {
|
|
682
|
-
$('#dat_nlrequirements .nlreq-row').each(function() {
|
|
683
|
-
var rid = $(this).attr('data-requirement-id');
|
|
684
|
-
if (rid && keys.indexOf(rid) === -1) {
|
|
685
|
-
$(this).remove();
|
|
686
|
-
}
|
|
687
|
-
});
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
keys.forEach(function(key) {
|
|
691
|
-
if ($('#dat_nlrequirements .nlreq-row[data-requirement-id="' + key + '"]').length === 0) {
|
|
692
|
-
add_nl_requirement_row(key, '');
|
|
693
|
-
}
|
|
694
|
-
});
|
|
695
|
-
} //}}}
|
|
696
|
-
|
|
697
562
|
function next_requirement_id() { //{{{
|
|
698
|
-
var currentReqs =
|
|
563
|
+
var currentReqs = Object.assign({}, read_requirements(save['nlrequirements']), read_requirements(save['requirements']));
|
|
699
564
|
var used = {};
|
|
700
565
|
Object.keys(currentReqs).forEach(function(key) {
|
|
701
566
|
var m = key.match(/^R(\d+)$/);
|
|
@@ -712,54 +577,6 @@ function next_requirement_id() { //{{{
|
|
|
712
577
|
return 'R' + candidate;
|
|
713
578
|
} //}}}
|
|
714
579
|
|
|
715
|
-
function upsert_requirement_ast(requirementId, astText) { //{{{
|
|
716
|
-
var reqObject = read_requirements_object();
|
|
717
|
-
reqObject[requirementId] = astText;
|
|
718
|
-
write_requirements_object(reqObject);
|
|
719
|
-
} //}}}
|
|
720
|
-
|
|
721
|
-
function stringify_requirements_object(reqObject) { //{{{
|
|
722
|
-
var ordered = {};
|
|
723
|
-
Object.keys(reqObject || {})
|
|
724
|
-
.sort(sort_requirement_ids)
|
|
725
|
-
.forEach(function(key) {
|
|
726
|
-
ordered[key] = reqObject[key];
|
|
727
|
-
});
|
|
728
|
-
return JSON.stringify(ordered);
|
|
729
|
-
} //}}}
|
|
730
|
-
|
|
731
|
-
function current_requirements_json_string() { //{{{
|
|
732
|
-
if (!save['requirements']) {
|
|
733
|
-
return '{}';
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
var raw = save['requirements'].save_json();
|
|
737
|
-
var parsed = parse_saved_object(raw);
|
|
738
|
-
return stringify_requirements_object(parsed);
|
|
739
|
-
} //}}}
|
|
740
|
-
|
|
741
|
-
function read_requirements_object() { //{{{
|
|
742
|
-
if (!save['requirements']) {
|
|
743
|
-
return {};
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
var raw = save['requirements'].save_json();
|
|
747
|
-
if (raw == null || raw === '') {
|
|
748
|
-
return {};
|
|
749
|
-
}
|
|
750
|
-
if (typeof raw === 'string') {
|
|
751
|
-
try {
|
|
752
|
-
return JSON.parse(raw);
|
|
753
|
-
} catch (e) {
|
|
754
|
-
return {};
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
if (typeof raw === 'object') {
|
|
758
|
-
return raw;
|
|
759
|
-
}
|
|
760
|
-
return {};
|
|
761
|
-
} //}}}
|
|
762
|
-
|
|
763
580
|
function parse_saved_object(raw) { //{{{
|
|
764
581
|
if (raw == null || raw === '') {
|
|
765
582
|
return {};
|
|
@@ -781,57 +598,6 @@ function parse_saved_object(raw) { //{{{
|
|
|
781
598
|
return {};
|
|
782
599
|
} //}}}
|
|
783
600
|
|
|
784
|
-
function apply_nl_requirements_values(nlReqObject) { //{{{
|
|
785
|
-
if (!nlReqObject || typeof nlReqObject !== 'object') {
|
|
786
|
-
return;
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
Object.keys(nlReqObject).forEach(function(key) {
|
|
790
|
-
var row = $('#dat_nlrequirements .nlreq-row[data-requirement-id="' + key + '"]');
|
|
791
|
-
if (row.length > 0) {
|
|
792
|
-
row.find('.nlreq-text').val(nlReqObject[key] || '');
|
|
793
|
-
}
|
|
794
|
-
});
|
|
795
|
-
} //}}}
|
|
796
|
-
|
|
797
|
-
function read_nl_requirements_object_from_ui() { //{{{
|
|
798
|
-
var data = {};
|
|
799
|
-
$('#dat_nlrequirements .nlreq-row').each(function() {
|
|
800
|
-
var requirementId = $(this).attr('data-requirement-id');
|
|
801
|
-
if (!requirementId) {
|
|
802
|
-
return;
|
|
803
|
-
}
|
|
804
|
-
var text = $(this).find('.nlreq-text').val();
|
|
805
|
-
data[requirementId] = text == null ? '' : String(text);
|
|
806
|
-
});
|
|
807
|
-
return data;
|
|
808
|
-
} //}}}
|
|
809
|
-
|
|
810
|
-
function write_requirements_object(reqObject) { //{{{
|
|
811
|
-
let req = $X("<requirements xmlns='http://cpee.org/ns/properties/2.0'/>");
|
|
812
|
-
Object.keys(reqObject)
|
|
813
|
-
.sort(sort_requirement_ids)
|
|
814
|
-
.forEach(function(key) {
|
|
815
|
-
let ele = $X("<" + key + " xmlns='http://cpee.org/ns/properties/2.0'/>");
|
|
816
|
-
ele.text(reqObject[key]);
|
|
817
|
-
req.append(ele);
|
|
818
|
-
});
|
|
819
|
-
var reqj = stringify_requirements_object(reqObject);
|
|
820
|
-
save['attributes_raw'].requirements = reqj;
|
|
821
|
-
save['requirements'].content(req);
|
|
822
|
-
ensure_ast_inline_save_buttons(reqObject);
|
|
823
|
-
do_requirements_save({ target: $('#dat_requirements')[0] }, reqj);
|
|
824
|
-
} //}}}
|
|
825
|
-
|
|
826
|
-
function sort_requirement_ids(a, b) { //{{{
|
|
827
|
-
var am = String(a).match(/^R(\d+)$/);
|
|
828
|
-
var bm = String(b).match(/^R(\d+)$/);
|
|
829
|
-
if (am && bm) {
|
|
830
|
-
return parseInt(am[1], 10) - parseInt(bm[1], 10);
|
|
831
|
-
}
|
|
832
|
-
return String(a).localeCompare(String(b));
|
|
833
|
-
} //}}}
|
|
834
|
-
|
|
835
601
|
function extract_ast_from_natural_language(naturalText, onSuccess, onError) { //{{{
|
|
836
602
|
var configuredEndpoint = $('body').attr('data-singlerule-endpoint') || '/compextract/singlerule';
|
|
837
603
|
var url = absolute_extract_url(configuredEndpoint);
|
|
@@ -1125,80 +891,3 @@ function getCurrentProcessXml() { //{{{
|
|
|
1125
891
|
|
|
1126
892
|
return null;
|
|
1127
893
|
} //}}}
|
|
1128
|
-
|
|
1129
|
-
function do_requirements_save(event, forcedRequirementsJson) { //{{{
|
|
1130
|
-
if (!save['attributes'] || !save['requirements']) {
|
|
1131
|
-
return;
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
var requirementsChanged = save['requirements'].has_changed();
|
|
1135
|
-
var hasForced = typeof forcedRequirementsJson === 'string';
|
|
1136
|
-
if (!requirementsChanged && !hasForced) {
|
|
1137
|
-
return;
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
if (requirementsChanged) {
|
|
1141
|
-
save['requirements'].set_checkpoint();
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
let reqj = hasForced ? forcedRequirementsJson : current_requirements_json_string();
|
|
1145
|
-
ensure_ast_inline_save_buttons(parse_saved_object(reqj));
|
|
1146
|
-
{
|
|
1147
|
-
let att = save['attributes'].save();
|
|
1148
|
-
let attributesNode = $(' > attributes', att);
|
|
1149
|
-
if (attributesNode.length === 0) {
|
|
1150
|
-
return;
|
|
1151
|
-
}
|
|
1152
|
-
let requirementsNode = attributesNode.children('requirements');
|
|
1153
|
-
if (requirementsNode.length === 0) {
|
|
1154
|
-
requirementsNode = $X("<requirements xmlns='http://cpee.org/ns/properties/2.0'/>");
|
|
1155
|
-
attributesNode.append(requirementsNode);
|
|
1156
|
-
}
|
|
1157
|
-
requirementsNode.text(reqj);
|
|
1158
|
-
save['attributes_raw'].requirements = reqj;
|
|
1159
|
-
save['attributes'].content(att);
|
|
1160
|
-
do_parameters_save_part('attributes',$(att).serializePrettyXML());
|
|
1161
|
-
}
|
|
1162
|
-
} //}}}
|
|
1163
|
-
|
|
1164
|
-
function do_nl_requirements_save(event) { //{{{
|
|
1165
|
-
if (!save['attributes']) {
|
|
1166
|
-
return;
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
// Keep regular requirements in sync when NL requirements are persisted.
|
|
1170
|
-
if (save['requirements']) {
|
|
1171
|
-
do_requirements_save({ target: $('#dat_requirements')[0] });
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
let nlReqj = JSON.stringify(read_nl_requirements_object_from_ui());
|
|
1175
|
-
let att = save['attributes'].save();
|
|
1176
|
-
let attributesNode = $(' > attributes', att);
|
|
1177
|
-
if (attributesNode.length === 0) {
|
|
1178
|
-
return;
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
let nlReqNode = attributesNode.children('NL-requirements');
|
|
1182
|
-
if (nlReqNode.length === 0) {
|
|
1183
|
-
nlReqNode = $X("<NL-requirements xmlns='http://cpee.org/ns/properties/2.0'/>");
|
|
1184
|
-
attributesNode.append(nlReqNode);
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
if (save['requirements']) {
|
|
1188
|
-
let reqj = (typeof save['attributes_raw'].requirements === 'string' && save['attributes_raw'].requirements.trim() !== '')
|
|
1189
|
-
? save['attributes_raw'].requirements
|
|
1190
|
-
: current_requirements_json_string();
|
|
1191
|
-
let requirementsNode = attributesNode.children('requirements');
|
|
1192
|
-
if (requirementsNode.length === 0) {
|
|
1193
|
-
requirementsNode = $X("<requirements xmlns='http://cpee.org/ns/properties/2.0'/>");
|
|
1194
|
-
attributesNode.append(requirementsNode);
|
|
1195
|
-
}
|
|
1196
|
-
requirementsNode.text(reqj);
|
|
1197
|
-
save['attributes_raw'].requirements = reqj;
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
nlReqNode.text(nlReqj);
|
|
1201
|
-
save['attributes_raw']['NL-requirements'] = nlReqj;
|
|
1202
|
-
save['attributes'].content(att);
|
|
1203
|
-
do_parameters_save_part('attributes',$(att).serializePrettyXML());
|
|
1204
|
-
} //}}}
|
|
@@ -204,7 +204,7 @@ function draw_extended_columns(graphrealization,max,labels,dimensions,striped) {
|
|
|
204
204
|
svgcolumn.append(svgback);
|
|
205
205
|
svgcolumn.append(svgfront);
|
|
206
206
|
svgcolumn.css('grid-row', '1/span ' + (max.row + 2))
|
|
207
|
-
svgcolumn.css('grid-column', tcolumns.indexOf(
|
|
207
|
+
svgcolumn.css('grid-column', tcolumns.indexOf(h) + 2);
|
|
208
208
|
svgcolumn.attr('height', graphrealization.illustrator.svg.container.attr('height'));
|
|
209
209
|
graphrealization.illustrator.svg.label_container.append(svgcolumn);
|
|
210
210
|
|
data/cockpit/js/instance.js
CHANGED
|
@@ -210,7 +210,7 @@ function cockpit() { //{{{
|
|
|
210
210
|
$("button[name=loadtestset]").attr('disabled','disabled');
|
|
211
211
|
},
|
|
212
212
|
complete: function() {
|
|
213
|
-
var q = $.
|
|
213
|
+
var q = $.query_params();
|
|
214
214
|
if (q.theme) { graph_theme = q.theme; }
|
|
215
215
|
if (q.position) { graph_position = q.position == 'false' ? 'false' : 'true'; }
|
|
216
216
|
if (q.highlight) {
|
|
@@ -538,7 +538,7 @@ function monitor_instance(cin,rep,load,exec) {// {{{
|
|
|
538
538
|
$("#current-index").show();
|
|
539
539
|
$("#current-index").attr('href','index.html?monitor=' + url);
|
|
540
540
|
|
|
541
|
-
var q = $.
|
|
541
|
+
var q = $.query_params();
|
|
542
542
|
history.replaceState({}, '', '?' + ('debug' in q ? "debug&" : "") + (graph_position ? "position=" + graph_position + "&" : "") + (graph_highlight ? "highlight=" + graph_highlight + "&" : "") + (graph_theme ? "theme=" + graph_theme + "&" : "") + (q.min || q.min=="" ? "min&" : "") + 'monitor='+url);
|
|
543
543
|
|
|
544
544
|
// Change url to return to current instance when reloading (because new subscription is made)
|
|
@@ -1587,7 +1587,7 @@ function format_code(res,skim,lnums) {// {{{
|
|
|
1587
1587
|
while (m = res.match(/^ +|^(?!<div style=)|^$/m)) {
|
|
1588
1588
|
m = m[0];
|
|
1589
1589
|
var tm = (m.length + 2) * 0.6 + 2 * 0.6 + 4 * 0.6;
|
|
1590
|
-
var ln = (lnums ?
|
|
1590
|
+
var ln = (lnums ? l.sprintf("%03d") + ': ' : '');
|
|
1591
1591
|
res = res.replace(/^ +|^(?!<div style=)|^$/m,"<div style='text-indent:-" + tm + "em;margin-left:" + tm + "em'>" + ln + " ".repeat(m.length));
|
|
1592
1592
|
l++;
|
|
1593
1593
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
function mp_conformance_editor(name, item) { //{{{
|
|
2
|
+
let state = null;
|
|
3
|
+
let timer;
|
|
4
|
+
|
|
5
|
+
let load = function() {
|
|
6
|
+
if (!save[name] || !save['attributes_raw']) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
let raw = save['attributes_raw'][name] || '';
|
|
10
|
+
if (raw === state) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
state = raw;
|
|
14
|
+
|
|
15
|
+
let entries = [];
|
|
16
|
+
if (raw !== '') {
|
|
17
|
+
try {
|
|
18
|
+
entries = [].concat(JSON.parse(raw)[item] || []);
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error(name + ' is not valid JSON:', e.message);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
let root = $X('<' + name + ' xmlns="http://cpee.org/ns/properties/2.0"/>');
|
|
24
|
+
entries.forEach(function(entry) {
|
|
25
|
+
let node = $X('<' + item + ' xmlns="http://cpee.org/ns/properties/2.0"/>');
|
|
26
|
+
Object.entries(entry).forEach(function([key, value]) {
|
|
27
|
+
let ele = $X('<' + key + ' xmlns="http://cpee.org/ns/properties/2.0"/>');
|
|
28
|
+
ele.text(value);
|
|
29
|
+
node.append(ele);
|
|
30
|
+
});
|
|
31
|
+
root.append(node);
|
|
32
|
+
});
|
|
33
|
+
save[name].content(root);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
let store = function() {
|
|
37
|
+
clearTimeout(timer);
|
|
38
|
+
if (!save[name] || !save['attributes']) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
let json = save[name].save_json();
|
|
42
|
+
if (json === state) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
let att = save['attributes'].save();
|
|
46
|
+
let attributes = $(' > attributes', att);
|
|
47
|
+
if (attributes.length === 0) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
let node = attributes.children(name);
|
|
51
|
+
if (node.length === 0) {
|
|
52
|
+
node = $X('<' + name + ' xmlns="http://cpee.org/ns/properties/2.0"/>');
|
|
53
|
+
attributes.append(node);
|
|
54
|
+
}
|
|
55
|
+
node.text(json);
|
|
56
|
+
state = json;
|
|
57
|
+
save['attributes_raw'][name] = json;
|
|
58
|
+
save['attributes'].content(att);
|
|
59
|
+
do_parameters_save_part('attributes', $(att).serializePrettyXML());
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
$.ajax({
|
|
63
|
+
type: "GET",
|
|
64
|
+
url: "rngs/" + name + ".rng",
|
|
65
|
+
dataType: "xml",
|
|
66
|
+
success: function(rng) {
|
|
67
|
+
save[name] = new RelaxNGui(rng, $('#dat_' + name));
|
|
68
|
+
load();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
document.addEventListener('attributes:changed', load);
|
|
72
|
+
$(document).on('input', '#dat_' + name + ' input', function() {
|
|
73
|
+
clearTimeout(timer);
|
|
74
|
+
timer = setTimeout(store, 5000);
|
|
75
|
+
});
|
|
76
|
+
$(document).on('relaxngui_remove relaxngui_move', '#dat_' + name, function() {
|
|
77
|
+
store();
|
|
78
|
+
});
|
|
79
|
+
} //}}}
|
|
80
|
+
|
|
81
|
+
$(document).ready(function() { //{{{
|
|
82
|
+
mp_conformance_editor('intervals', 'interval');
|
|
83
|
+
mp_conformance_editor('rules', 'rule');
|
|
84
|
+
}); //}}}
|