Browse Source

ensure data is loaded if any

Mark deVilliers 2 years ago
parent
commit
fd3a121761
2 changed files with 174 additions and 145 deletions
  1. 163 139
      ui/search.js
  2. 11 6
      ui/src/Search.elm

+ 163 - 139
ui/search.js

@@ -10689,7 +10689,6 @@ var _user$project$Search$getTimeSeriesEncoder = function (key) {
10689 10689
 var _user$project$Search$metadataURL = 'http://localhost:8081';
10690 10690
 var _user$project$Search$nodeURL = 'http://localhost:8080';
10691 10691
 var _user$project$Search$initialModel = {all: _elm_lang$core$Maybe$Nothing, filter: _elm_lang$core$Maybe$Nothing};
10692
-var _user$project$Search$init = {ctor: '_Tuple2', _0: _user$project$Search$initialModel, _1: _elm_lang$core$Platform_Cmd$none};
10693 10692
 var _user$project$Search$unsafeDrawGraph = _elm_lang$core$Native_Platform.outgoingPort(
10694 10693
 	'unsafeDrawGraph',
10695 10694
 	function (v) {
@@ -10698,8 +10697,8 @@ var _user$project$Search$unsafeDrawGraph = _elm_lang$core$Native_Platform.outgoi
10698 10697
 				return {value: v.value, date: v.date};
10699 10698
 			});
10700 10699
 	});
10701
-var _user$project$Search$clearGraph = _elm_lang$core$Native_Platform.outgoingPort(
10702
-	'clearGraph',
10700
+var _user$project$Search$unsafeClearGraph = _elm_lang$core$Native_Platform.outgoingPort(
10701
+	'unsafeClearGraph',
10703 10702
 	function (v) {
10704 10703
 		return v;
10705 10704
 	});
@@ -10833,89 +10832,6 @@ var _user$project$Search$drawViewerWidget = function (item) {
10833 10832
 var _user$project$Search$ShowLocations = function (a) {
10834 10833
 	return {ctor: 'ShowLocations', _0: a};
10835 10834
 };
10836
-var _user$project$Search$drawFiltered = F2(
10837
-	function (tag, items) {
10838
-		var _p3 = tag;
10839
-		if (_p3.ctor === 'Nothing') {
10840
-			return A2(
10841
-				_elm_lang$html$Html$div,
10842
-				{ctor: '[]'},
10843
-				A2(
10844
-					_elm_lang$core$List$map,
10845
-					function (x) {
10846
-						return A2(
10847
-							_elm_lang$html$Html$div,
10848
-							{ctor: '[]'},
10849
-							{
10850
-								ctor: '::',
10851
-								_0: A2(
10852
-									_elm_lang$html$Html$a,
10853
-									{
10854
-										ctor: '::',
10855
-										_0: _elm_lang$html$Html_Events$onClick(
10856
-											_user$project$Search$ShowLocations(x)),
10857
-										_1: {
10858
-											ctor: '::',
10859
-											_0: _elm_lang$html$Html_Attributes$href('#'),
10860
-											_1: {ctor: '[]'}
10861
-										}
10862
-									},
10863
-									{
10864
-										ctor: '::',
10865
-										_0: _elm_lang$html$Html$text(x),
10866
-										_1: {ctor: '[]'}
10867
-									}),
10868
-								_1: {ctor: '[]'}
10869
-							});
10870
-					},
10871
-					_user$project$Search$uniqueTags(items)));
10872
-		} else {
10873
-			var _p4 = _p3._0;
10874
-			var filtered = A2(_user$project$Search$filterByTag, _p4, items);
10875
-			return A2(
10876
-				_elm_lang$html$Html$div,
10877
-				{ctor: '[]'},
10878
-				{
10879
-					ctor: '::',
10880
-					_0: A2(
10881
-						_elm_lang$html$Html$div,
10882
-						{ctor: '[]'},
10883
-						{
10884
-							ctor: '::',
10885
-							_0: _elm_lang$html$Html$text(_p4),
10886
-							_1: {ctor: '[]'}
10887
-						}),
10888
-					_1: {
10889
-						ctor: '::',
10890
-						_0: A2(
10891
-							_elm_lang$html$Html$div,
10892
-							{ctor: '[]'},
10893
-							A2(
10894
-								_elm_lang$core$List$map,
10895
-								function (item) {
10896
-									return A2(
10897
-										_elm_lang$html$Html$div,
10898
-										{ctor: '[]'},
10899
-										{
10900
-											ctor: '::',
10901
-											_0: _elm_lang$html$Html$text(item.key),
10902
-											_1: {
10903
-												ctor: '::',
10904
-												_0: _elm_lang$html$Html$text(' '),
10905
-												_1: {
10906
-													ctor: '::',
10907
-													_0: _user$project$Search$drawViewerWidget(item),
10908
-													_1: {ctor: '[]'}
10909
-												}
10910
-											}
10911
-										});
10912
-								},
10913
-								filtered)),
10914
-						_1: {ctor: '[]'}
10915
-					}
10916
-				});
10917
-		}
10918
-	});
10919 10835
 var _user$project$Search$RefreshMetadataCompleted = function (a) {
10920 10836
 	return {ctor: 'RefreshMetadataCompleted', _0: a};
10921 10837
 };
@@ -10926,10 +10842,11 @@ var _user$project$Search$getAllMetadata = function () {
10926 10842
 		_user$project$Decoders$decodeItems);
10927 10843
 	return A2(_elm_lang$http$Http$send, _user$project$Search$RefreshMetadataCompleted, request);
10928 10844
 }();
10845
+var _user$project$Search$init = {ctor: '_Tuple2', _0: _user$project$Search$initialModel, _1: _user$project$Search$getAllMetadata};
10929 10846
 var _user$project$Search$update = F2(
10930 10847
 	function (msg, model) {
10931
-		var _p5 = msg;
10932
-		switch (_p5.ctor) {
10848
+		var _p3 = msg;
10849
+		switch (_p3.ctor) {
10933 10850
 			case 'NoOp':
10934 10851
 				return {ctor: '_Tuple2', _0: model, _1: _elm_lang$core$Platform_Cmd$none};
10935 10852
 			case 'RefreshMetadata':
@@ -10941,15 +10858,15 @@ var _user$project$Search$update = F2(
10941 10858
 					_1: _user$project$Search$getAllMetadata
10942 10859
 				};
10943 10860
 			case 'RefreshMetadataCompleted':
10944
-				if (_p5._0.ctor === 'Ok') {
10861
+				if (_p3._0.ctor === 'Ok') {
10945 10862
 					return {
10946 10863
 						ctor: '_Tuple2',
10947 10864
 						_0: _elm_lang$core$Native_Utils.update(
10948 10865
 							model,
10949 10866
 							{
10950
-								all: _elm_lang$core$Maybe$Just(_p5._0._0)
10867
+								all: _elm_lang$core$Maybe$Just(_p3._0._0)
10951 10868
 							}),
10952
-						_1: _user$project$Search$clearGraph('only-for-the-compiler')
10869
+						_1: _user$project$Search$unsafeClearGraph('only-for-the-compiler')
10953 10870
 					};
10954 10871
 				} else {
10955 10872
 					return _elm_lang$core$Native_Utils.crashCase(
@@ -10958,12 +10875,12 @@ var _user$project$Search$update = F2(
10958 10875
 							start: {line: 68, column: 5},
10959 10876
 							end: {line: 120, column: 45}
10960 10877
 						},
10961
-						_p5)(
10962
-						_elm_lang$core$Basics$toString(_p5._0._0));
10878
+						_p3)(
10879
+						_elm_lang$core$Basics$toString(_p3._0._0));
10963 10880
 				}
10964 10881
 			case 'ShowLocations':
10965
-				var _p7 = model.all;
10966
-				if (_p7.ctor === 'Nothing') {
10882
+				var _p5 = model.all;
10883
+				if (_p5.ctor === 'Nothing') {
10967 10884
 					return {ctor: '_Tuple2', _0: model, _1: _elm_lang$core$Platform_Cmd$none};
10968 10885
 				} else {
10969 10886
 					return {
@@ -10971,7 +10888,7 @@ var _user$project$Search$update = F2(
10971 10888
 						_0: _elm_lang$core$Native_Utils.update(
10972 10889
 							model,
10973 10890
 							{
10974
-								filter: _elm_lang$core$Maybe$Just(_p5._0)
10891
+								filter: _elm_lang$core$Maybe$Just(_p3._0)
10975 10892
 							}),
10976 10893
 						_1: _elm_lang$core$Platform_Cmd$none
10977 10894
 					};
@@ -10980,22 +10897,22 @@ var _user$project$Search$update = F2(
10980 10897
 				return {
10981 10898
 					ctor: '_Tuple2',
10982 10899
 					_0: model,
10983
-					_1: _user$project$Search$getTimeSeriesData(_p5._0)
10900
+					_1: _user$project$Search$getTimeSeriesData(_p3._0)
10984 10901
 				};
10985 10902
 			case 'ViewGraphCompleted':
10986
-				if (_p5._1.ctor === 'Ok') {
10987
-					var items = A3(_user$project$Search$updateRight, model.all, _p5._0, _user$project$Decoders$Unknown);
10903
+				if (_p3._1.ctor === 'Ok') {
10904
+					var items = A3(_user$project$Search$updateRight, model.all, _p3._0, _user$project$Decoders$Unknown);
10988 10905
 					return {
10989 10906
 						ctor: '_Tuple2',
10990 10907
 						_0: _elm_lang$core$Native_Utils.update(
10991 10908
 							model,
10992 10909
 							{all: items}),
10993 10910
 						_1: _user$project$Search$unsafeDrawGraph(
10994
-							_user$project$Search$prepareGraphData(_p5._1._0.data))
10911
+							_user$project$Search$prepareGraphData(_p3._1._0.data))
10995 10912
 					};
10996 10913
 				} else {
10997
-					if (_p5._1._0.ctor === 'BadStatus') {
10998
-						var items = A3(_user$project$Search$updateRight, model.all, _p5._0, _user$project$Decoders$RequestAccess);
10914
+					if (_p3._1._0.ctor === 'BadStatus') {
10915
+						var items = A3(_user$project$Search$updateRight, model.all, _p3._0, _user$project$Decoders$RequestAccess);
10999 10916
 						return {
11000 10917
 							ctor: '_Tuple2',
11001 10918
 							_0: _elm_lang$core$Native_Utils.update(
@@ -11010,22 +10927,22 @@ var _user$project$Search$update = F2(
11010 10927
 								start: {line: 68, column: 5},
11011 10928
 								end: {line: 120, column: 45}
11012 10929
 							},
11013
-							_p5)(
11014
-							_elm_lang$core$Basics$toString(_p5._1._0));
10930
+							_p3)(
10931
+							_elm_lang$core$Basics$toString(_p3._1._0));
11015 10932
 					}
11016 10933
 				}
11017 10934
 			case 'RequestAccess':
11018
-				var _p9 = _p5._0;
11019
-				var items = A3(_user$project$Search$updateRight, model.all, _p9, _user$project$Decoders$Requesting);
10935
+				var _p7 = _p3._0;
10936
+				var items = A3(_user$project$Search$updateRight, model.all, _p7, _user$project$Decoders$Requesting);
11020 10937
 				return {
11021 10938
 					ctor: '_Tuple2',
11022 10939
 					_0: _elm_lang$core$Native_Utils.update(
11023 10940
 						model,
11024 10941
 						{all: items}),
11025
-					_1: _user$project$Search$requestAccess(_p9)
10942
+					_1: _user$project$Search$requestAccess(_p7)
11026 10943
 				};
11027 10944
 			default:
11028
-				if (_p5._0.ctor === 'Ok') {
10945
+				if (_p3._0.ctor === 'Ok') {
11029 10946
 					return {ctor: '_Tuple2', _0: model, _1: _elm_lang$core$Platform_Cmd$none};
11030 10947
 				} else {
11031 10948
 					return _elm_lang$core$Native_Utils.crashCase(
@@ -11034,12 +10951,117 @@ var _user$project$Search$update = F2(
11034 10951
 							start: {line: 68, column: 5},
11035 10952
 							end: {line: 120, column: 45}
11036 10953
 						},
11037
-						_p5)(
11038
-						_elm_lang$core$Basics$toString(_p5._0._0));
10954
+						_p3)(
10955
+						_elm_lang$core$Basics$toString(_p3._0._0));
11039 10956
 				}
11040 10957
 		}
11041 10958
 	});
11042 10959
 var _user$project$Search$RefreshMetadata = {ctor: 'RefreshMetadata'};
10960
+var _user$project$Search$drawFiltered = F2(
10961
+	function (tag, items) {
10962
+		var _p9 = tag;
10963
+		if (_p9.ctor === 'Nothing') {
10964
+			return A2(
10965
+				_elm_lang$html$Html$div,
10966
+				{ctor: '[]'},
10967
+				A2(
10968
+					_elm_lang$core$List$map,
10969
+					function (x) {
10970
+						return A2(
10971
+							_elm_lang$html$Html$div,
10972
+							{ctor: '[]'},
10973
+							{
10974
+								ctor: '::',
10975
+								_0: A2(
10976
+									_elm_lang$html$Html$a,
10977
+									{
10978
+										ctor: '::',
10979
+										_0: _elm_lang$html$Html_Events$onClick(
10980
+											_user$project$Search$ShowLocations(x)),
10981
+										_1: {
10982
+											ctor: '::',
10983
+											_0: _elm_lang$html$Html_Attributes$href('#'),
10984
+											_1: {ctor: '[]'}
10985
+										}
10986
+									},
10987
+									{
10988
+										ctor: '::',
10989
+										_0: _elm_lang$html$Html$text(x),
10990
+										_1: {ctor: '[]'}
10991
+									}),
10992
+								_1: {ctor: '[]'}
10993
+							});
10994
+					},
10995
+					_user$project$Search$uniqueTags(items)));
10996
+		} else {
10997
+			var _p10 = _p9._0;
10998
+			var filtered = A2(_user$project$Search$filterByTag, _p10, items);
10999
+			return A2(
11000
+				_elm_lang$html$Html$div,
11001
+				{ctor: '[]'},
11002
+				{
11003
+					ctor: '::',
11004
+					_0: A2(
11005
+						_elm_lang$html$Html$div,
11006
+						{ctor: '[]'},
11007
+						{
11008
+							ctor: '::',
11009
+							_0: _elm_lang$html$Html$text(_p10),
11010
+							_1: {ctor: '[]'}
11011
+						}),
11012
+					_1: {
11013
+						ctor: '::',
11014
+						_0: A2(
11015
+							_elm_lang$html$Html$div,
11016
+							{ctor: '[]'},
11017
+							A2(
11018
+								_elm_lang$core$List$map,
11019
+								function (item) {
11020
+									return A2(
11021
+										_elm_lang$html$Html$div,
11022
+										{ctor: '[]'},
11023
+										{
11024
+											ctor: '::',
11025
+											_0: _elm_lang$html$Html$text(item.key),
11026
+											_1: {
11027
+												ctor: '::',
11028
+												_0: _elm_lang$html$Html$text(' '),
11029
+												_1: {
11030
+													ctor: '::',
11031
+													_0: _user$project$Search$drawViewerWidget(item),
11032
+													_1: {ctor: '[]'}
11033
+												}
11034
+											}
11035
+										});
11036
+								},
11037
+								filtered)),
11038
+						_1: {
11039
+							ctor: '::',
11040
+							_0: A2(
11041
+								_elm_lang$html$Html$div,
11042
+								{ctor: '[]'},
11043
+								{
11044
+									ctor: '::',
11045
+									_0: A2(
11046
+										_elm_lang$html$Html$button,
11047
+										{
11048
+											ctor: '::',
11049
+											_0: _elm_lang$html$Html_Events$onClick(_user$project$Search$RefreshMetadata),
11050
+											_1: {ctor: '[]'}
11051
+										},
11052
+										{
11053
+											ctor: '::',
11054
+											_0: _elm_lang$html$Html$text('new search'),
11055
+											_1: {ctor: '[]'}
11056
+										}),
11057
+									_1: {ctor: '[]'}
11058
+								}),
11059
+							_1: {ctor: '[]'}
11060
+						}
11061
+					}
11062
+				});
11063
+		}
11064
+	});
11043 11065
 var _user$project$Search$view = function (model) {
11044 11066
 	var _p11 = model.all;
11045 11067
 	if (_p11.ctor === 'Nothing') {
@@ -11056,22 +11078,35 @@ var _user$project$Search$view = function (model) {
11056 11078
 				_1: {ctor: '[]'}
11057 11079
 			});
11058 11080
 	} else {
11059
-		return A2(
11060
-			_elm_lang$html$Html$div,
11061
-			{ctor: '[]'},
11062
-			{
11063
-				ctor: '::',
11064
-				_0: A2(
11065
-					_elm_lang$html$Html$div,
11066
-					{ctor: '[]'},
11067
-					{
11068
-						ctor: '::',
11069
-						_0: _elm_lang$html$Html$text('Metadata'),
11070
-						_1: {ctor: '[]'}
11071
-					}),
11072
-				_1: {
11081
+		var _p13 = _p11._0;
11082
+		var _p12 = _p13;
11083
+		if (_p12.ctor === '[]') {
11084
+			return A2(
11085
+				_elm_lang$html$Html$button,
11086
+				{
11073 11087
 					ctor: '::',
11074
-					_0: A2(_user$project$Search$drawFiltered, model.filter, _p11._0),
11088
+					_0: _elm_lang$html$Html_Events$onClick(_user$project$Search$RefreshMetadata),
11089
+					_1: {ctor: '[]'}
11090
+				},
11091
+				{
11092
+					ctor: '::',
11093
+					_0: _elm_lang$html$Html$text('refresh'),
11094
+					_1: {ctor: '[]'}
11095
+				});
11096
+		} else {
11097
+			return A2(
11098
+				_elm_lang$html$Html$div,
11099
+				{ctor: '[]'},
11100
+				{
11101
+					ctor: '::',
11102
+					_0: A2(
11103
+						_elm_lang$html$Html$div,
11104
+						{ctor: '[]'},
11105
+						{
11106
+							ctor: '::',
11107
+							_0: _elm_lang$html$Html$text('Metadata'),
11108
+							_1: {ctor: '[]'}
11109
+						}),
11075 11110
 					_1: {
11076 11111
 						ctor: '::',
11077 11112
 						_0: A2(
@@ -11079,24 +11114,13 @@ var _user$project$Search$view = function (model) {
11079 11114
 							{ctor: '[]'},
11080 11115
 							{
11081 11116
 								ctor: '::',
11082
-								_0: A2(
11083
-									_elm_lang$html$Html$button,
11084
-									{
11085
-										ctor: '::',
11086
-										_0: _elm_lang$html$Html_Events$onClick(_user$project$Search$RefreshMetadata),
11087
-										_1: {ctor: '[]'}
11088
-									},
11089
-									{
11090
-										ctor: '::',
11091
-										_0: _elm_lang$html$Html$text('new search'),
11092
-										_1: {ctor: '[]'}
11093
-									}),
11117
+								_0: A2(_user$project$Search$drawFiltered, model.filter, _p13),
11094 11118
 								_1: {ctor: '[]'}
11095 11119
 							}),
11096 11120
 						_1: {ctor: '[]'}
11097 11121
 					}
11098
-				}
11099
-			});
11122
+				});
11123
+		}
11100 11124
 	}
11101 11125
 };
11102 11126
 var _user$project$Search$main = _elm_lang$html$Html$program(

+ 11 - 6
ui/src/Search.elm

@@ -45,7 +45,7 @@ initialModel =
45 45
 
46 46
 init : ( Model, Cmd Msg )
47 47
 init =
48
-    ( initialModel, Cmd.none )
48
+    ( initialModel, getAllMetadata )
49 49
 
50 50
 
51 51
 
@@ -225,11 +225,15 @@ view model =
225 225
             button [ onClick RefreshMetadata ] [ text "refresh" ]
226 226
 
227 227
         Just d ->
228
-            div []
229
-                [ div [] [ text "Metadata" ]
230
-                , drawFiltered model.filter d
231
-                , div [] [ button [ onClick RefreshMetadata ] [ text "new search" ] ]
232
-                ]
228
+            case d of
229
+                [] ->
230
+                    button [ onClick RefreshMetadata ] [ text "refresh" ]
231
+
232
+                _ ->
233
+                    div []
234
+                        [ div [] [ text "Metadata" ]
235
+                        , div [] [ drawFiltered model.filter d ]
236
+                        ]
233 237
 
234 238
 
235 239
 drawFiltered : Maybe String -> Decoders.Items -> Html Msg
@@ -246,6 +250,7 @@ drawFiltered tag items =
246 250
                 div []
247 251
                     [ div [] [ text (t) ]
248 252
                     , div [] <| List.map (\item -> div [] [ text item.key, text " ", drawViewerWidget (item) ]) filtered
253
+                    , div [] [ button [ onClick RefreshMetadata ] [ text "new search" ] ]
249 254
                     ]
250 255
 
251 256