@@ -76,45 +76,83 @@ const removeFilter = (paramName) => {
7676}
7777
7878
79- const getFilterQueryStringFromURI = ( ) => {
79+ const getFilterQueryStringFromURI = ( only_saved_filters = false ) => {
8080 const url_params = getURLParams ( ) ;
8181
8282 let query_string = '' ;
83- if ( url_params [ 'uri' ] != null && url_params [ 'uri' ] . trim ( ) != '' ) {
84- const uri = url_params [ 'uri' ] . trim ( )
85- query_string += `&uri=${ uri } `
86- document . querySelector ( 'input[name=uri]' ) . value = uri ;
87- document . querySelector ( '#filters-active' ) . classList . remove ( 'hidden' ) ;
83+ if ( only_saved_filters === true ) {
84+ if ( url_params [ 'uri' ] != null && url_params [ 'uri' ] . trim ( ) != '' ) {
85+ const uri = url_params [ 'uri' ] . trim ( )
86+ query_string += `&uri=${ uri } `
87+ document . querySelector ( 'input[name="uri"]' ) . value = uri ;
88+ document . querySelector ( '#filters-active' ) . classList . remove ( 'hidden' ) ;
89+ }
90+ if ( url_params [ 'filename' ] != null && url_params [ 'filename' ] . trim ( ) != '' ) {
91+ const filename = url_params [ 'filename' ] . trim ( )
92+ query_string += `&filename=${ filename } `
93+ document . querySelector ( 'input[name="filename"]' ) . value = filename ;
94+ document . querySelector ( '#filters-active' ) . classList . remove ( 'hidden' ) ;
95+ }
96+ if ( url_params [ 'branch' ] != null && url_params [ 'branch' ] . trim ( ) != '' ) {
97+ const branch = url_params [ 'branch' ] . trim ( )
98+ query_string += `&branch=${ branch } `
99+ document . querySelector ( 'input[name="branch"]' ) . value = branch ;
100+ document . querySelector ( '#filters-active' ) . classList . remove ( 'hidden' ) ;
101+ }
102+ if ( url_params [ 'machine_id' ] != null && url_params [ 'machine_id' ] . trim ( ) != '' ) {
103+ const machine_id = url_params [ 'machine_id' ] . trim ( )
104+ query_string += `&machine_id=${ machine_id } `
105+ document . querySelector ( 'input[name="machine_id"]' ) . value = machine_id ;
106+ document . querySelector ( '#filters-active' ) . classList . remove ( 'hidden' ) ;
107+ }
108+ if ( url_params [ 'machine' ] != null && url_params [ 'machine' ] . trim ( ) != '' ) {
109+ const machine = url_params [ 'machine' ] . trim ( )
110+ query_string += `&machine=${ machine } `
111+ document . querySelector ( 'input[name="machine"]' ) . value = machine ;
112+ document . querySelector ( '#filters-active' ) . classList . remove ( 'hidden' ) ;
113+ }
114+ if ( url_params [ 'usage_scenario_variables' ] != null && url_params [ 'usage_scenario_variables' ] . trim ( ) != '' ) {
115+ const usage_scenario_variables = url_params [ 'usage_scenario_variables' ] . trim ( )
116+ query_string += `&usage_scenario_variables=${ usage_scenario_variables } `
117+ document . querySelector ( 'input[name="usage_scenario_variables"]' ) . value = usage_scenario_variables ;
118+ document . querySelector ( '#filters-active' ) . classList . remove ( 'hidden' ) ;
119+ }
88120 }
89- if ( url_params [ 'filename' ] != null && url_params [ 'filename' ] . trim ( ) != '' ) {
90- const filename = url_params [ 'filename' ] . trim ( )
91- query_string += `&filename= ${ filename } `
92- document . querySelector ( 'input[name=filename]' ) . value = filename ;
121+
122+ let show_archived = null ;
123+ if ( url_params [ 'show_archived' ] != null && url_params [ 'show_archived' ] . trim ( ) != '' ) {
124+ show_archived = url_params [ 'show_archived' ] . trim ( )
93125 document . querySelector ( '#filters-active' ) . classList . remove ( 'hidden' ) ;
94- }
95- if ( url_params [ 'branch' ] != null && url_params [ 'branch' ] . trim ( ) != '' ) {
96- const branch = url_params [ 'branch' ] . trim ( )
97- query_string += `&branch=${ branch } `
98- document . querySelector ( 'input[name=branch]' ) . value = branch ;
126+ } else if ( localStorage . getItem ( 'show_archived' ) ) {
127+ show_archived = localStorage . getItem ( 'show_archived' ) ;
99128 document . querySelector ( '#filters-active' ) . classList . remove ( 'hidden' ) ;
129+ } else {
130+ show_archived = 'false' ;
100131 }
101- if ( url_params [ 'machine_id' ] != null && url_params [ 'machine_id' ] . trim ( ) != '' ) {
102- const machine_id = url_params [ 'machine_id' ] . trim ( )
103- query_string += `&machine_id=${ machine_id } `
104- document . querySelector ( 'input[name=machine_id]' ) . value = machine_id ;
105- document . querySelector ( '#filters-active' ) . classList . remove ( 'hidden' ) ;
132+
133+ const archived_radio = document . querySelector ( `input[name="show_archived"][value="${ show_archived } "]` )
134+ if ( archived_radio != null ) { // since user can submit bullshit we do not want to except on querySelector after accessing checkes
135+ archived_radio . checked = true ;
136+ localStorage . setItem ( 'show_archived' , show_archived ) ;
137+ query_string += `&show_archived=${ show_archived } `
106138 }
107- if ( url_params [ 'machine' ] != null && url_params [ 'machine' ] . trim ( ) != '' ) {
108- const machine = url_params [ 'machine' ] . trim ( )
109- query_string += `&machine= ${ machine } `
110- document . querySelector ( 'input[name=machine]' ) . value = machine ;
139+
140+ let show_other_users = null ;
141+ if ( url_params [ 'show_other_users' ] != null && url_params [ 'show_other_users' ] . trim ( ) != '' ) {
142+ show_other_users = url_params [ 'show_other_users' ] . trim ( )
111143 document . querySelector ( '#filters-active' ) . classList . remove ( 'hidden' ) ;
112- }
113- if ( url_params [ 'usage_scenario_variables' ] != null && url_params [ 'usage_scenario_variables' ] . trim ( ) != '' ) {
114- const usage_scenario_variables = url_params [ 'usage_scenario_variables' ] . trim ( )
115- query_string += `&usage_scenario_variables=${ usage_scenario_variables } `
116- document . querySelector ( 'input[name=usage_scenario_variables]' ) . value = usage_scenario_variables ;
144+ } else if ( localStorage . getItem ( 'show_other_users' ) ) {
145+ show_other_users = localStorage . getItem ( 'show_other_users' ) ;
117146 document . querySelector ( '#filters-active' ) . classList . remove ( 'hidden' ) ;
147+ } else {
148+ show_other_users = 'true' ;
149+ }
150+
151+ const other_users_radio = document . querySelector ( `input[name="show_other_users"][value="${ show_other_users } "]` )
152+ if ( other_users_radio != null ) { // since user can submit bullshit we do not want to except on querySelector after accessing checkes
153+ document . querySelector ( `input[name="show_other_users"][value="${ show_other_users } "]` ) . checked = true ;
154+ localStorage . setItem ( 'show_other_users' , show_other_users ) ;
155+ query_string += `&show_other_users=${ show_other_users } `
118156 }
119157
120158 return query_string
@@ -123,21 +161,25 @@ const getFilterQueryStringFromURI = () => {
123161const getFilterQueryStringFromInputs = ( ) => {
124162 let query_string = '' ;
125163
126- const uri = document . querySelector ( 'input[name=uri]' ) . value . trim ( )
127- const filename = document . querySelector ( 'input[name=filename]' ) . value . trim ( )
128- const branch = document . querySelector ( 'input[name=branch]' ) . value . trim ( )
129- const machine = document . querySelector ( 'input[name=machine]' ) . value . trim ( )
130- const machine_id = document . querySelector ( 'input[name=machine_id]' ) . value . trim ( )
131- const usage_scenario_variables = document . querySelector ( 'input[name=usage_scenario_variables]' ) . value . trim ( )
132- const show_archived = document . querySelector ( 'input[name=show_archived]:checked' ) . value . trim ( )
164+ const uri = document . querySelector ( 'input[name="uri"]' ) . value . trim ( )
165+ const filename = document . querySelector ( 'input[name="filename"]' ) . value . trim ( )
166+ const branch = document . querySelector ( 'input[name="branch"]' ) . value . trim ( )
167+ const machine = document . querySelector ( 'input[name="machine"]' ) . value . trim ( )
168+ const machine_id = document . querySelector ( 'input[name="machine_id"]' ) . value . trim ( )
169+ const usage_scenario_variables = document . querySelector ( 'input[name="usage_scenario_variables"]' ) . value . trim ( )
170+ const show_archived = document . querySelector ( 'input[name="show_archived"]:checked' ) ?. value ?. trim ( )
171+ localStorage . setItem ( 'show_archived' , show_archived ) ;
172+ const show_other_users = document . querySelector ( 'input[name="show_other_users"]:checked' ) ?. value ?. trim ( )
173+ localStorage . setItem ( 'show_other_users' , show_other_users ) ;
133174
134175 if ( uri != '' ) query_string += `&uri=${ uri } `
135176 if ( filename != '' ) query_string += `&filename=${ filename } `
136177 if ( branch != '' ) query_string += `&branch=${ branch } `
137178 if ( machine != '' ) query_string += `&machine=${ machine } `
138179 if ( machine_id != '' ) query_string += `&machine_id=${ machine_id } `
139180 if ( usage_scenario_variables != '' ) query_string += `&usage_scenario_variables=${ usage_scenario_variables } `
140- if ( show_archived ) query_string += `&show_archived=${ show_archived } `
181+ if ( show_archived != null && show_archived != '' ) query_string += `&show_archived=${ show_archived } `
182+ if ( show_other_users != null && show_other_users != '' ) query_string += `&show_other_users=${ show_other_users } `
141183
142184 document . querySelector ( '#filters-active' ) . classList . remove ( 'hidden' ) ;
143185
@@ -183,7 +225,7 @@ async function getRepositories(sort_by = 'date') {
183225
184226 if ( ! $ . fn . DataTable . isDataTable ( table ) ) {
185227 const uri = this . getAttribute ( 'data-uri' ) ;
186- getRunsTable ( $ ( table ) , `/v2/runs?uri=${ uri } &uri_mode=exact&limit=0` , false , false , true )
228+ getRunsTable ( $ ( table ) , `/v2/runs?uri=${ uri } &uri_mode=exact&limit=0& ${ getFilterQueryStringFromURI ( true ) } ` , false , false , true )
187229 }
188230 } } ) ;
189231 $ ( '.ui.accordion.filter-dropdown' ) . hide ( ) ;
0 commit comments