Browse Source

add feature for an owner to change the entitlements on their own data

Mark deVilliers 2 years ago
parent
commit
bde18f81fe
4 changed files with 464 additions and 99 deletions
  1. 316 77
      ui/node.js
  2. 31 8
      ui/search.js
  3. 32 2
      ui/src/Decoders.elm
  4. 85 12
      ui/src/Node.elm

+ 316 - 77
ui/node.js

@@ -10391,14 +10391,6 @@ var _user$project$Decoders$Entitlement = F4(
10391 10391
 	function (a, b, c, d) {
10392 10392
 		return {subject: a, level: b, uid: c, status: d};
10393 10393
 	});
10394
-var _user$project$Decoders$decodeEntitlement = A5(
10395
-	_elm_lang$core$Json_Decode$map4,
10396
-	_user$project$Decoders$Entitlement,
10397
-	A2(_elm_lang$core$Json_Decode$field, 'subject', _elm_lang$core$Json_Decode$string),
10398
-	A2(_elm_lang$core$Json_Decode$field, 'level', _elm_lang$core$Json_Decode$string),
10399
-	A2(_elm_lang$core$Json_Decode$field, 'uid', _elm_lang$core$Json_Decode$string),
10400
-	A2(_elm_lang$core$Json_Decode$field, 'status', _elm_lang$core$Json_Decode$string));
10401
-var _user$project$Decoders$decodeEntitlements = _elm_lang$core$Json_Decode$list(_user$project$Decoders$decodeEntitlement);
10402 10394
 var _user$project$Decoders$MetadataItem = F2(
10403 10395
 	function (a, b) {
10404 10396
 		return {subject: a, description: b};
@@ -10499,6 +10491,37 @@ var _user$project$Decoders$decodeDataResponse = A2(
10499 10491
 		_elm_lang$core$Json_Decode$field,
10500 10492
 		'data',
10501 10493
 		_elm_lang$core$Json_Decode$list(_user$project$Decoders$decodeDataItem)));
10494
+var _user$project$Decoders$CanDiscover = {ctor: 'CanDiscover'};
10495
+var _user$project$Decoders$CanAccess = {ctor: 'CanAccess'};
10496
+var _user$project$Decoders$OwnerOnly = {ctor: 'OwnerOnly'};
10497
+var _user$project$Decoders$None = {ctor: 'None'};
10498
+var _user$project$Decoders$decodeAccessLevel = A2(
10499
+	_elm_lang$core$Json_Decode$andThen,
10500
+	function (str) {
10501
+		var _p2 = str;
10502
+		switch (_p2) {
10503
+			case 'none':
10504
+				return _elm_lang$core$Json_Decode$succeed(_user$project$Decoders$None);
10505
+			case 'owner-only':
10506
+				return _elm_lang$core$Json_Decode$succeed(_user$project$Decoders$OwnerOnly);
10507
+			case 'can-access':
10508
+				return _elm_lang$core$Json_Decode$succeed(_user$project$Decoders$CanAccess);
10509
+			case 'can-discover':
10510
+				return _elm_lang$core$Json_Decode$succeed(_user$project$Decoders$CanDiscover);
10511
+			default:
10512
+				return _elm_lang$core$Json_Decode$fail(
10513
+					A2(_elm_lang$core$Basics_ops['++'], 'Unknown AccessLevel: ', _p2));
10514
+		}
10515
+	},
10516
+	_elm_lang$core$Json_Decode$string);
10517
+var _user$project$Decoders$decodeEntitlement = A5(
10518
+	_elm_lang$core$Json_Decode$map4,
10519
+	_user$project$Decoders$Entitlement,
10520
+	A2(_elm_lang$core$Json_Decode$field, 'subject', _elm_lang$core$Json_Decode$string),
10521
+	A2(_elm_lang$core$Json_Decode$field, 'level', _user$project$Decoders$decodeAccessLevel),
10522
+	A2(_elm_lang$core$Json_Decode$field, 'uid', _elm_lang$core$Json_Decode$string),
10523
+	A2(_elm_lang$core$Json_Decode$field, 'status', _elm_lang$core$Json_Decode$string));
10524
+var _user$project$Decoders$decodeEntitlements = _elm_lang$core$Json_Decode$list(_user$project$Decoders$decodeEntitlement);
10502 10525
 
10503 10526
 var _user$project$Node$findEntitlement = F2(
10504 10527
 	function (key, entitlements) {
@@ -10514,52 +10537,249 @@ var _user$project$Node$findEntitlement = F2(
10514 10537
 				_p0._0);
10515 10538
 		}
10516 10539
 	});
10517
-var _user$project$Node$drawAccepted = function (ent) {
10518
-	var _p1 = ent;
10519
-	if (_p1.ctor === 'Nothing') {
10520
-		return _elm_lang$html$Html$text('entitlement not set');
10521
-	} else {
10522
-		return _elm_lang$html$Html$text(_p1._0.level);
10540
+var _user$project$Node$drawAccessLevel = function (level) {
10541
+	var _p1 = level;
10542
+	switch (_p1.ctor) {
10543
+		case 'OwnerOnly':
10544
+			return _elm_lang$html$Html$text('owner-only');
10545
+		case 'CanDiscover':
10546
+			return _elm_lang$html$Html$text('can-discover');
10547
+		case 'CanAccess':
10548
+			return _elm_lang$html$Html$text('can-access');
10549
+		default:
10550
+			return _elm_lang$html$Html$text('none');
10523 10551
 	}
10524 10552
 };
10525
-var _user$project$Node$drawEntitlement = function (e) {
10526
-	return A2(
10527
-		_elm_lang$html$Html$div,
10528
-		{ctor: '[]'},
10553
+var _user$project$Node$subscriptions = function (model) {
10554
+	return _elm_lang$core$Platform_Sub$none;
10555
+};
10556
+var _user$project$Node$accessLevelEncoder = function (level) {
10557
+	var _p2 = level;
10558
+	switch (_p2.ctor) {
10559
+		case 'OwnerOnly':
10560
+			return _elm_lang$core$Json_Encode$string('owner-only');
10561
+		case 'CanDiscover':
10562
+			return _elm_lang$core$Json_Encode$string('can-discover');
10563
+		case 'CanAccess':
10564
+			return _elm_lang$core$Json_Encode$string('can-access');
10565
+		default:
10566
+			return _elm_lang$core$Json_Encode$string('none');
10567
+	}
10568
+};
10569
+var _user$project$Node$entitlementEncoder = function (ent) {
10570
+	return _elm_lang$core$Json_Encode$object(
10529 10571
 		{
10530 10572
 			ctor: '::',
10531
-			_0: _elm_lang$html$Html$text(e.subject),
10573
+			_0: {
10574
+				ctor: '_Tuple2',
10575
+				_0: 'subject',
10576
+				_1: _elm_lang$core$Json_Encode$string(ent.subject)
10577
+			},
10532 10578
 			_1: {
10533 10579
 				ctor: '::',
10534
-				_0: _elm_lang$html$Html$text(':'),
10580
+				_0: {
10581
+					ctor: '_Tuple2',
10582
+					_0: 'level',
10583
+					_1: _user$project$Node$accessLevelEncoder(ent.level)
10584
+				},
10535 10585
 				_1: {
10536 10586
 					ctor: '::',
10537
-					_0: _elm_lang$html$Html$text(e.level),
10538
-					_1: {ctor: '[]'}
10587
+					_0: {
10588
+						ctor: '_Tuple2',
10589
+						_0: 'uid',
10590
+						_1: _elm_lang$core$Json_Encode$string(ent.uid)
10591
+					},
10592
+					_1: {
10593
+						ctor: '::',
10594
+						_0: {
10595
+							ctor: '_Tuple2',
10596
+							_0: 'status',
10597
+							_1: _elm_lang$core$Json_Encode$string(ent.status)
10598
+						},
10599
+						_1: {ctor: '[]'}
10600
+					}
10539 10601
 				}
10540 10602
 			}
10541 10603
 		});
10542 10604
 };
10543
-var _user$project$Node$drawEntitlements = function (e) {
10544
-	return A2(
10545
-		_elm_lang$html$Html$div,
10546
-		{ctor: '[]'},
10547
-		A2(
10548
-			_elm_lang$core$List$map,
10549
-			function (ent) {
10550
-				return _user$project$Node$drawEntitlement(ent);
10551
-			},
10552
-			e));
10553
-};
10554
-var _user$project$Node$subscriptions = function (model) {
10555
-	return _elm_lang$core$Platform_Sub$none;
10556
-};
10557 10605
 var _user$project$Node$nodeURL = 'http://localhost:8080';
10558 10606
 var _user$project$Node$initialModel = {accepted: _elm_lang$core$Maybe$Nothing, requested: _elm_lang$core$Maybe$Nothing, metadata: _elm_lang$core$Maybe$Nothing};
10559 10607
 var _user$project$Node$Model = F3(
10560 10608
 	function (a, b, c) {
10561 10609
 		return {accepted: a, requested: b, metadata: c};
10562 10610
 	});
10611
+var _user$project$Node$AmendEntitlementCompleted = function (a) {
10612
+	return {ctor: 'AmendEntitlementCompleted', _0: a};
10613
+};
10614
+var _user$project$Node$amendEntitlement = function (ent) {
10615
+	var request = A3(
10616
+		_elm_lang$http$Http$post,
10617
+		A2(
10618
+			_elm_lang$core$Basics_ops['++'],
10619
+			_user$project$Node$nodeURL,
10620
+			A2(_elm_lang$core$Basics_ops['++'], '/entitlements/accepted/', ent.uid)),
10621
+		_elm_lang$http$Http$jsonBody(
10622
+			_user$project$Node$entitlementEncoder(ent)),
10623
+		_user$project$Decoders$decodeEntitlement);
10624
+	return A2(_elm_lang$http$Http$send, _user$project$Node$AmendEntitlementCompleted, request);
10625
+};
10626
+var _user$project$Node$AmendEntitlement = function (a) {
10627
+	return {ctor: 'AmendEntitlement', _0: a};
10628
+};
10629
+var _user$project$Node$drawAccessLevelSelector = function (ent) {
10630
+	var _p3 = ent.level;
10631
+	switch (_p3.ctor) {
10632
+		case 'OwnerOnly':
10633
+			return A2(
10634
+				_elm_lang$html$Html$span,
10635
+				{ctor: '[]'},
10636
+				{
10637
+					ctor: '::',
10638
+					_0: A2(
10639
+						_elm_lang$html$Html$a,
10640
+						{
10641
+							ctor: '::',
10642
+							_0: _elm_lang$html$Html_Events$onClick(
10643
+								_user$project$Node$AmendEntitlement(
10644
+									_elm_lang$core$Native_Utils.update(
10645
+										ent,
10646
+										{level: _user$project$Decoders$CanDiscover}))),
10647
+							_1: {
10648
+								ctor: '::',
10649
+								_0: _elm_lang$html$Html_Attributes$href('#'),
10650
+								_1: {ctor: '[]'}
10651
+							}
10652
+						},
10653
+						{
10654
+							ctor: '::',
10655
+							_0: _elm_lang$html$Html$text('make searchable'),
10656
+							_1: {ctor: '[]'}
10657
+						}),
10658
+					_1: {ctor: '[]'}
10659
+				});
10660
+		case 'CanDiscover':
10661
+			return A2(
10662
+				_elm_lang$html$Html$span,
10663
+				{ctor: '[]'},
10664
+				{
10665
+					ctor: '::',
10666
+					_0: A2(
10667
+						_elm_lang$html$Html$a,
10668
+						{
10669
+							ctor: '::',
10670
+							_0: _elm_lang$html$Html_Events$onClick(
10671
+								_user$project$Node$AmendEntitlement(
10672
+									_elm_lang$core$Native_Utils.update(
10673
+										ent,
10674
+										{level: _user$project$Decoders$OwnerOnly}))),
10675
+							_1: {
10676
+								ctor: '::',
10677
+								_0: _elm_lang$html$Html_Attributes$href('#'),
10678
+								_1: {ctor: '[]'}
10679
+							}
10680
+						},
10681
+						{
10682
+							ctor: '::',
10683
+							_0: _elm_lang$html$Html$text('stop making available for search'),
10684
+							_1: {ctor: '[]'}
10685
+						}),
10686
+					_1: {
10687
+						ctor: '::',
10688
+						_0: _elm_lang$html$Html$text(' '),
10689
+						_1: {
10690
+							ctor: '::',
10691
+							_0: A2(
10692
+								_elm_lang$html$Html$a,
10693
+								{
10694
+									ctor: '::',
10695
+									_0: _elm_lang$html$Html_Events$onClick(
10696
+										_user$project$Node$AmendEntitlement(
10697
+											_elm_lang$core$Native_Utils.update(
10698
+												ent,
10699
+												{level: _user$project$Decoders$CanAccess}))),
10700
+									_1: {
10701
+										ctor: '::',
10702
+										_0: _elm_lang$html$Html_Attributes$href('#'),
10703
+										_1: {ctor: '[]'}
10704
+									}
10705
+								},
10706
+								{
10707
+									ctor: '::',
10708
+									_0: _elm_lang$html$Html$text('allow access to values'),
10709
+									_1: {ctor: '[]'}
10710
+								}),
10711
+							_1: {ctor: '[]'}
10712
+						}
10713
+					}
10714
+				});
10715
+		case 'CanAccess':
10716
+			return A2(
10717
+				_elm_lang$html$Html$span,
10718
+				{ctor: '[]'},
10719
+				{
10720
+					ctor: '::',
10721
+					_0: A2(
10722
+						_elm_lang$html$Html$a,
10723
+						{
10724
+							ctor: '::',
10725
+							_0: _elm_lang$html$Html_Events$onClick(
10726
+								_user$project$Node$AmendEntitlement(
10727
+									_elm_lang$core$Native_Utils.update(
10728
+										ent,
10729
+										{level: _user$project$Decoders$CanDiscover}))),
10730
+							_1: {
10731
+								ctor: '::',
10732
+								_0: _elm_lang$html$Html_Attributes$href('#'),
10733
+								_1: {ctor: '[]'}
10734
+							}
10735
+						},
10736
+						{
10737
+							ctor: '::',
10738
+							_0: _elm_lang$html$Html$text('remove access'),
10739
+							_1: {ctor: '[]'}
10740
+						}),
10741
+					_1: {ctor: '[]'}
10742
+				});
10743
+		default:
10744
+			return A2(
10745
+				_elm_lang$html$Html$span,
10746
+				{ctor: '[]'},
10747
+				{
10748
+					ctor: '::',
10749
+					_0: _elm_lang$html$Html$text('nothing to be done : '),
10750
+					_1: {
10751
+						ctor: '::',
10752
+						_0: _elm_lang$html$Html$text(
10753
+							_elm_lang$core$Basics$toString(ent.level)),
10754
+						_1: {ctor: '[]'}
10755
+					}
10756
+				});
10757
+	}
10758
+};
10759
+var _user$project$Node$drawAccepted = function (ent) {
10760
+	var _p4 = ent;
10761
+	if (_p4.ctor === 'Nothing') {
10762
+		return _elm_lang$html$Html$text('entitlement not set');
10763
+	} else {
10764
+		var _p5 = _p4._0;
10765
+		return A2(
10766
+			_elm_lang$html$Html$div,
10767
+			{ctor: '[]'},
10768
+			{
10769
+				ctor: '::',
10770
+				_0: _user$project$Node$drawAccessLevel(_p5.level),
10771
+				_1: {
10772
+					ctor: '::',
10773
+					_0: _elm_lang$html$Html$text(' '),
10774
+					_1: {
10775
+						ctor: '::',
10776
+						_0: _user$project$Node$drawAccessLevelSelector(_p5),
10777
+						_1: {ctor: '[]'}
10778
+					}
10779
+				}
10780
+			});
10781
+	}
10782
+};
10563 10783
 var _user$project$Node$DeclineEntitlementCompleted = function (a) {
10564 10784
 	return {ctor: 'DeclineEntitlementCompleted', _0: a};
10565 10785
 };
@@ -10599,11 +10819,11 @@ var _user$project$Node$AcceptEntitlement = function (a) {
10599 10819
 	return {ctor: 'AcceptEntitlement', _0: a};
10600 10820
 };
10601 10821
 var _user$project$Node$drawRequested = function (ent) {
10602
-	var _p2 = ent;
10603
-	if (_p2.ctor === 'Nothing') {
10822
+	var _p6 = ent;
10823
+	if (_p6.ctor === 'Nothing') {
10604 10824
 		return _elm_lang$html$Html$text('');
10605 10825
 	} else {
10606
-		var _p3 = _p2._0;
10826
+		var _p7 = _p6._0;
10607 10827
 		return A2(
10608 10828
 			_elm_lang$html$Html$div,
10609 10829
 			{ctor: '[]'},
@@ -10612,7 +10832,7 @@ var _user$project$Node$drawRequested = function (ent) {
10612 10832
 				_0: _elm_lang$html$Html$text(' requested : '),
10613 10833
 				_1: {
10614 10834
 					ctor: '::',
10615
-					_0: _elm_lang$html$Html$text(_p3.level),
10835
+					_0: _user$project$Node$drawAccessLevel(_p7.level),
10616 10836
 					_1: {
10617 10837
 						ctor: '::',
10618 10838
 						_0: A2(
@@ -10620,7 +10840,7 @@ var _user$project$Node$drawRequested = function (ent) {
10620 10840
 							{
10621 10841
 								ctor: '::',
10622 10842
 								_0: _elm_lang$html$Html_Events$onClick(
10623
-									_user$project$Node$AcceptEntitlement(_p3)),
10843
+									_user$project$Node$AcceptEntitlement(_p7)),
10624 10844
 								_1: {
10625 10845
 									ctor: '::',
10626 10846
 									_0: _elm_lang$html$Html_Attributes$href('#'),
@@ -10642,7 +10862,7 @@ var _user$project$Node$drawRequested = function (ent) {
10642 10862
 									{
10643 10863
 										ctor: '::',
10644 10864
 										_0: _elm_lang$html$Html_Events$onClick(
10645
-											_user$project$Node$DeclineEntitlement(_p3)),
10865
+											_user$project$Node$DeclineEntitlement(_p7)),
10646 10866
 										_1: {
10647 10867
 											ctor: '::',
10648 10868
 											_0: _elm_lang$html$Html_Attributes$href('#'),
@@ -10711,8 +10931,8 @@ var _user$project$Node$drawMetadata = F2(
10711 10931
 				e));
10712 10932
 	});
10713 10933
 var _user$project$Node$view = function (model) {
10714
-	var _p4 = model.metadata;
10715
-	if (_p4.ctor === 'Nothing') {
10934
+	var _p8 = model.metadata;
10935
+	if (_p8.ctor === 'Nothing') {
10716 10936
 		return _elm_lang$html$Html$text('no data exists.');
10717 10937
 	} else {
10718 10938
 		return A2(
@@ -10731,7 +10951,7 @@ var _user$project$Node$view = function (model) {
10731 10951
 							_0: _elm_lang$html$Html$text('Data'),
10732 10952
 							_1: {
10733 10953
 								ctor: '::',
10734
-								_0: A2(_user$project$Node$drawMetadata, _p4._0, model),
10954
+								_0: A2(_user$project$Node$drawMetadata, _p8._0, model),
10735 10955
 								_1: {ctor: '[]'}
10736 10956
 							}
10737 10957
 						}),
@@ -10762,18 +10982,18 @@ var _user$project$Node$getAcceptedEntitlements = function () {
10762 10982
 }();
10763 10983
 var _user$project$Node$update = F2(
10764 10984
 	function (msg, model) {
10765
-		var _p5 = msg;
10766
-		switch (_p5.ctor) {
10985
+		var _p9 = msg;
10986
+		switch (_p9.ctor) {
10767 10987
 			case 'NoOp':
10768 10988
 				return {ctor: '_Tuple2', _0: model, _1: _elm_lang$core$Platform_Cmd$none};
10769 10989
 			case 'GetAcceptedEntitlementsCompleted':
10770
-				if (_p5._0.ctor === 'Ok') {
10990
+				if (_p9._0.ctor === 'Ok') {
10771 10991
 					return {
10772 10992
 						ctor: '_Tuple2',
10773 10993
 						_0: _elm_lang$core$Native_Utils.update(
10774 10994
 							model,
10775 10995
 							{
10776
-								accepted: _elm_lang$core$Maybe$Just(_p5._0._0)
10996
+								accepted: _elm_lang$core$Maybe$Just(_p9._0._0)
10777 10997
 							}),
10778 10998
 						_1: _user$project$Node$getRequestedEntitlements
10779 10999
 					};
@@ -10781,20 +11001,20 @@ var _user$project$Node$update = F2(
10781 11001
 					return _elm_lang$core$Native_Utils.crashCase(
10782 11002
 						'Node',
10783 11003
 						{
10784
-							start: {line: 54, column: 5},
10785
-							end: {line: 92, column: 45}
11004
+							start: {line: 57, column: 5},
11005
+							end: {line: 104, column: 45}
10786 11006
 						},
10787
-						_p5)(
10788
-						_elm_lang$core$Basics$toString(_p5._0._0));
11007
+						_p9)(
11008
+						_elm_lang$core$Basics$toString(_p9._0._0));
10789 11009
 				}
10790 11010
 			case 'GetRequestedEntitlementsCompleted':
10791
-				if (_p5._0.ctor === 'Ok') {
11011
+				if (_p9._0.ctor === 'Ok') {
10792 11012
 					return {
10793 11013
 						ctor: '_Tuple2',
10794 11014
 						_0: _elm_lang$core$Native_Utils.update(
10795 11015
 							model,
10796 11016
 							{
10797
-								requested: _elm_lang$core$Maybe$Just(_p5._0._0)
11017
+								requested: _elm_lang$core$Maybe$Just(_p9._0._0)
10798 11018
 							}),
10799 11019
 						_1: _elm_lang$core$Platform_Cmd$none
10800 11020
 					};
@@ -10802,20 +11022,20 @@ var _user$project$Node$update = F2(
10802 11022
 					return _elm_lang$core$Native_Utils.crashCase(
10803 11023
 						'Node',
10804 11024
 						{
10805
-							start: {line: 54, column: 5},
10806
-							end: {line: 92, column: 45}
11025
+							start: {line: 57, column: 5},
11026
+							end: {line: 104, column: 45}
10807 11027
 						},
10808
-						_p5)(
10809
-						_elm_lang$core$Basics$toString(_p5._0._0));
11028
+						_p9)(
11029
+						_elm_lang$core$Basics$toString(_p9._0._0));
10810 11030
 				}
10811 11031
 			case 'GetMetadataCompleted':
10812
-				if (_p5._0.ctor === 'Ok') {
11032
+				if (_p9._0.ctor === 'Ok') {
10813 11033
 					return {
10814 11034
 						ctor: '_Tuple2',
10815 11035
 						_0: _elm_lang$core$Native_Utils.update(
10816 11036
 							model,
10817 11037
 							{
10818
-								metadata: _elm_lang$core$Maybe$Just(_p5._0._0)
11038
+								metadata: _elm_lang$core$Maybe$Just(_p9._0._0)
10819 11039
 							}),
10820 11040
 						_1: _user$project$Node$getAcceptedEntitlements
10821 11041
 					};
@@ -10823,49 +11043,68 @@ var _user$project$Node$update = F2(
10823 11043
 					return _elm_lang$core$Native_Utils.crashCase(
10824 11044
 						'Node',
10825 11045
 						{
10826
-							start: {line: 54, column: 5},
10827
-							end: {line: 92, column: 45}
11046
+							start: {line: 57, column: 5},
11047
+							end: {line: 104, column: 45}
10828 11048
 						},
10829
-						_p5)(
10830
-						_elm_lang$core$Basics$toString(_p5._0._0));
11049
+						_p9)(
11050
+						_elm_lang$core$Basics$toString(_p9._0._0));
10831 11051
 				}
10832 11052
 			case 'AcceptEntitlement':
10833 11053
 				return {
10834 11054
 					ctor: '_Tuple2',
10835 11055
 					_0: model,
10836
-					_1: _user$project$Node$acceptEntitlement(_p5._0)
11056
+					_1: _user$project$Node$acceptEntitlement(_p9._0)
10837 11057
 				};
10838 11058
 			case 'AcceptEntitlementCompleted':
10839
-				if (_p5._0.ctor === 'Ok') {
11059
+				if (_p9._0.ctor === 'Ok') {
10840 11060
 					return {ctor: '_Tuple2', _0: model, _1: _user$project$Node$getAcceptedEntitlements};
10841 11061
 				} else {
10842 11062
 					return _elm_lang$core$Native_Utils.crashCase(
10843 11063
 						'Node',
10844 11064
 						{
10845
-							start: {line: 54, column: 5},
10846
-							end: {line: 92, column: 45}
11065
+							start: {line: 57, column: 5},
11066
+							end: {line: 104, column: 45}
10847 11067
 						},
10848
-						_p5)(
10849
-						_elm_lang$core$Basics$toString(_p5._0._0));
11068
+						_p9)(
11069
+						_elm_lang$core$Basics$toString(_p9._0._0));
10850 11070
 				}
10851 11071
 			case 'DeclineEntitlement':
10852 11072
 				return {
10853 11073
 					ctor: '_Tuple2',
10854 11074
 					_0: model,
10855
-					_1: _user$project$Node$declineEntitlement(_p5._0)
11075
+					_1: _user$project$Node$declineEntitlement(_p9._0)
11076
+				};
11077
+			case 'DeclineEntitlementCompleted':
11078
+				if (_p9._0.ctor === 'Ok') {
11079
+					return {ctor: '_Tuple2', _0: model, _1: _user$project$Node$getAcceptedEntitlements};
11080
+				} else {
11081
+					return _elm_lang$core$Native_Utils.crashCase(
11082
+						'Node',
11083
+						{
11084
+							start: {line: 57, column: 5},
11085
+							end: {line: 104, column: 45}
11086
+						},
11087
+						_p9)(
11088
+						_elm_lang$core$Basics$toString(_p9._0._0));
11089
+				}
11090
+			case 'AmendEntitlement':
11091
+				return {
11092
+					ctor: '_Tuple2',
11093
+					_0: model,
11094
+					_1: _user$project$Node$amendEntitlement(_p9._0)
10856 11095
 				};
10857 11096
 			default:
10858
-				if (_p5._0.ctor === 'Ok') {
11097
+				if (_p9._0.ctor === 'Ok') {
10859 11098
 					return {ctor: '_Tuple2', _0: model, _1: _user$project$Node$getAcceptedEntitlements};
10860 11099
 				} else {
10861 11100
 					return _elm_lang$core$Native_Utils.crashCase(
10862 11101
 						'Node',
10863 11102
 						{
10864
-							start: {line: 54, column: 5},
10865
-							end: {line: 92, column: 45}
11103
+							start: {line: 57, column: 5},
11104
+							end: {line: 104, column: 45}
10866 11105
 						},
10867
-						_p5)(
10868
-						_elm_lang$core$Basics$toString(_p5._0._0));
11106
+						_p9)(
11107
+						_elm_lang$core$Basics$toString(_p9._0._0));
10869 11108
 				}
10870 11109
 		}
10871 11110
 	});

+ 31 - 8
ui/search.js

@@ -10457,14 +10457,6 @@ var _user$project$Decoders$Entitlement = F4(
10457 10457
 	function (a, b, c, d) {
10458 10458
 		return {subject: a, level: b, uid: c, status: d};
10459 10459
 	});
10460
-var _user$project$Decoders$decodeEntitlement = A5(
10461
-	_elm_lang$core$Json_Decode$map4,
10462
-	_user$project$Decoders$Entitlement,
10463
-	A2(_elm_lang$core$Json_Decode$field, 'subject', _elm_lang$core$Json_Decode$string),
10464
-	A2(_elm_lang$core$Json_Decode$field, 'level', _elm_lang$core$Json_Decode$string),
10465
-	A2(_elm_lang$core$Json_Decode$field, 'uid', _elm_lang$core$Json_Decode$string),
10466
-	A2(_elm_lang$core$Json_Decode$field, 'status', _elm_lang$core$Json_Decode$string));
10467
-var _user$project$Decoders$decodeEntitlements = _elm_lang$core$Json_Decode$list(_user$project$Decoders$decodeEntitlement);
10468 10460
 var _user$project$Decoders$MetadataItem = F2(
10469 10461
 	function (a, b) {
10470 10462
 		return {subject: a, description: b};
@@ -10565,6 +10557,37 @@ var _user$project$Decoders$decodeDataResponse = A2(
10565 10557
 		_elm_lang$core$Json_Decode$field,
10566 10558
 		'data',
10567 10559
 		_elm_lang$core$Json_Decode$list(_user$project$Decoders$decodeDataItem)));
10560
+var _user$project$Decoders$CanDiscover = {ctor: 'CanDiscover'};
10561
+var _user$project$Decoders$CanAccess = {ctor: 'CanAccess'};
10562
+var _user$project$Decoders$OwnerOnly = {ctor: 'OwnerOnly'};
10563
+var _user$project$Decoders$None = {ctor: 'None'};
10564
+var _user$project$Decoders$decodeAccessLevel = A2(
10565
+	_elm_lang$core$Json_Decode$andThen,
10566
+	function (str) {
10567
+		var _p2 = str;
10568
+		switch (_p2) {
10569
+			case 'none':
10570
+				return _elm_lang$core$Json_Decode$succeed(_user$project$Decoders$None);
10571
+			case 'owner-only':
10572
+				return _elm_lang$core$Json_Decode$succeed(_user$project$Decoders$OwnerOnly);
10573
+			case 'can-access':
10574
+				return _elm_lang$core$Json_Decode$succeed(_user$project$Decoders$CanAccess);
10575
+			case 'can-discover':
10576
+				return _elm_lang$core$Json_Decode$succeed(_user$project$Decoders$CanDiscover);
10577
+			default:
10578
+				return _elm_lang$core$Json_Decode$fail(
10579
+					A2(_elm_lang$core$Basics_ops['++'], 'Unknown AccessLevel: ', _p2));
10580
+		}
10581
+	},
10582
+	_elm_lang$core$Json_Decode$string);
10583
+var _user$project$Decoders$decodeEntitlement = A5(
10584
+	_elm_lang$core$Json_Decode$map4,
10585
+	_user$project$Decoders$Entitlement,
10586
+	A2(_elm_lang$core$Json_Decode$field, 'subject', _elm_lang$core$Json_Decode$string),
10587
+	A2(_elm_lang$core$Json_Decode$field, 'level', _user$project$Decoders$decodeAccessLevel),
10588
+	A2(_elm_lang$core$Json_Decode$field, 'uid', _elm_lang$core$Json_Decode$string),
10589
+	A2(_elm_lang$core$Json_Decode$field, 'status', _elm_lang$core$Json_Decode$string));
10590
+var _user$project$Decoders$decodeEntitlements = _elm_lang$core$Json_Decode$list(_user$project$Decoders$decodeEntitlement);
10568 10591
 
10569 10592
 var _user$project$Search$filterByTag = F2(
10570 10593
 	function (tag, data) {

+ 32 - 2
ui/src/Decoders.elm

@@ -106,21 +106,51 @@ jsValDecoder =
106 106
 
107 107
 type alias Entitlement =
108 108
     { subject : String
109
-    , level : String
109
+    , level : AccessLevel
110 110
     , uid : String
111 111
     , status : String
112 112
     }
113 113
 
114 114
 
115
+type AccessLevel
116
+    = None
117
+    | OwnerOnly
118
+    | CanAccess
119
+    | CanDiscover
120
+
121
+
115 122
 decodeEntitlement : Decoder Entitlement
116 123
 decodeEntitlement =
117 124
     Json.Decode.map4 Entitlement
118 125
         (Json.Decode.field "subject" Json.Decode.string)
119
-        (Json.Decode.field "level" Json.Decode.string)
126
+        (Json.Decode.field "level" decodeAccessLevel)
120 127
         (Json.Decode.field "uid" Json.Decode.string)
121 128
         (Json.Decode.field "status" Json.Decode.string)
122 129
 
123 130
 
131
+decodeAccessLevel : Decoder AccessLevel
132
+decodeAccessLevel =
133
+    Json.Decode.string
134
+        |> Json.Decode.andThen
135
+            (\str ->
136
+                case str of
137
+                    "none" ->
138
+                        Json.Decode.succeed None
139
+
140
+                    "owner-only" ->
141
+                        Json.Decode.succeed OwnerOnly
142
+
143
+                    "can-access" ->
144
+                        Json.Decode.succeed CanAccess
145
+
146
+                    "can-discover" ->
147
+                        Json.Decode.succeed CanDiscover
148
+
149
+                    somethingElse ->
150
+                        Json.Decode.fail <| "Unknown AccessLevel: " ++ somethingElse
151
+            )
152
+
153
+
124 154
 type alias Entitlements =
125 155
     List Entitlement
126 156
 

+ 85 - 12
ui/src/Node.elm

@@ -6,6 +6,7 @@ import Html.Attributes exposing (..)
6 6
 import Html.Events exposing (onClick)
7 7
 import List.Extra exposing (..)
8 8
 import Decoders
9
+import Json.Encode exposing (..)
9 10
 
10 11
 
11 12
 main : Program Never Model Msg
@@ -47,6 +48,8 @@ type Msg
47 48
     | AcceptEntitlementCompleted (Result Http.Error Decoders.Entitlement)
48 49
     | DeclineEntitlement Decoders.Entitlement
49 50
     | DeclineEntitlementCompleted (Result Http.Error Decoders.Entitlement)
51
+    | AmendEntitlement Decoders.Entitlement
52
+    | AmendEntitlementCompleted (Result Http.Error Decoders.Entitlement)
50 53
 
51 54
 
52 55
 update : Msg -> Model -> ( Model, Cmd Msg )
@@ -91,6 +94,15 @@ update msg model =
91 94
         DeclineEntitlementCompleted (Err httpError) ->
92 95
             Debug.crash (toString httpError)
93 96
 
97
+        AmendEntitlement ent ->
98
+            ( model, amendEntitlement ent )
99
+
100
+        AmendEntitlementCompleted (Ok ent) ->
101
+            ( model, getAcceptedEntitlements )
102
+
103
+        AmendEntitlementCompleted (Err httpError) ->
104
+            Debug.crash (toString httpError)
105
+
94 106
 
95 107
 
96 108
 --RPC
@@ -146,6 +158,41 @@ declineEntitlement ent =
146 158
         Http.send DeclineEntitlementCompleted request
147 159
 
148 160
 
161
+entitlementEncoder : Decoders.Entitlement -> Json.Encode.Value
162
+entitlementEncoder ent =
163
+    Json.Encode.object
164
+        [ ( "subject", Json.Encode.string ent.subject )
165
+        , ( "level", accessLevelEncoder ent.level )
166
+        , ( "uid", Json.Encode.string ent.uid )
167
+        , ( "status", Json.Encode.string ent.status )
168
+        ]
169
+
170
+
171
+accessLevelEncoder : Decoders.AccessLevel -> Json.Encode.Value
172
+accessLevelEncoder level =
173
+    case level of
174
+        Decoders.OwnerOnly ->
175
+            Json.Encode.string "owner-only"
176
+
177
+        Decoders.CanDiscover ->
178
+            Json.Encode.string "can-discover"
179
+
180
+        Decoders.CanAccess ->
181
+            Json.Encode.string "can-access"
182
+
183
+        Decoders.None ->
184
+            Json.Encode.string "none"
185
+
186
+
187
+amendEntitlement : Decoders.Entitlement -> Cmd Msg
188
+amendEntitlement ent =
189
+    let
190
+        request =
191
+            Http.post (nodeURL ++ "/entitlements/accepted/" ++ ent.uid) (Http.jsonBody (entitlementEncoder ent)) Decoders.decodeEntitlement
192
+    in
193
+        Http.send AmendEntitlementCompleted request
194
+
195
+
149 196
 
150 197
 -- SUBSCRIPTIONS
151 198
 
@@ -175,16 +222,6 @@ view model =
175 222
                 ]
176 223
 
177 224
 
178
-drawEntitlements : Decoders.Entitlements -> Html Msg
179
-drawEntitlements e =
180
-    div [] <| List.map (\ent -> drawEntitlement ent) e
181
-
182
-
183
-drawEntitlement : Decoders.Entitlement -> Html Msg
184
-drawEntitlement e =
185
-    div [] [ text (e.subject), text (":"), text (e.level) ]
186
-
187
-
188 225
 drawMetadata : Decoders.Metadata -> Model -> Html Msg
189 226
 drawMetadata e model =
190 227
     div [] <| List.map (\m -> drawMetadataItem m model) e
@@ -214,7 +251,43 @@ drawAccepted ent =
214 251
             text ("entitlement not set")
215 252
 
216 253
         Just e ->
217
-            text (e.level)
254
+            div [] [ drawAccessLevel (e.level), text " ", drawAccessLevelSelector (e) ]
255
+
256
+
257
+drawAccessLevelSelector : Decoders.Entitlement -> Html Msg
258
+drawAccessLevelSelector ent =
259
+    case ent.level of
260
+        Decoders.OwnerOnly ->
261
+            Html.span [] [ a [ onClick (AmendEntitlement { ent | level = Decoders.CanDiscover }), href "#" ] [ text ("make searchable") ] ]
262
+
263
+        Decoders.CanDiscover ->
264
+            Html.span []
265
+                [ a [ onClick (AmendEntitlement { ent | level = Decoders.OwnerOnly }), href "#" ] [ text ("stop making available for search") ]
266
+                , text (" ")
267
+                , a [ onClick (AmendEntitlement { ent | level = Decoders.CanAccess }), href "#" ] [ text ("allow access to values") ]
268
+                ]
269
+
270
+        Decoders.CanAccess ->
271
+            Html.span [] [ a [ onClick (AmendEntitlement { ent | level = Decoders.CanDiscover }), href "#" ] [ text ("remove access") ] ]
272
+
273
+        Decoders.None ->
274
+            Html.span [] [ text ("nothing to be done : "), text (toString ent.level) ]
275
+
276
+
277
+drawAccessLevel : Decoders.AccessLevel -> Html Msg
278
+drawAccessLevel level =
279
+    case level of
280
+        Decoders.OwnerOnly ->
281
+            text ("owner-only")
282
+
283
+        Decoders.CanDiscover ->
284
+            text ("can-discover")
285
+
286
+        Decoders.CanAccess ->
287
+            text ("can-access")
288
+
289
+        Decoders.None ->
290
+            text ("none")
218 291
 
219 292
 
220 293
 drawRequested : Maybe Decoders.Entitlement -> Html Msg
@@ -226,7 +299,7 @@ drawRequested ent =
226 299
         Just e ->
227 300
             div []
228 301
                 [ text (" requested : ")
229
-                , text (e.level)
302
+                , drawAccessLevel (e.level)
230 303
                 , a [ onClick (AcceptEntitlement e), href "#" ] [ text ("accept") ]
231 304
                 , text (" ")
232 305
                 , a [ onClick (DeclineEntitlement e), href "#" ] [ text ("decline") ]