1111 * or submit itself to any jurisdiction.
1212 */
1313
14+ import { switchCase } from '/js/src/index.js' ;
1415import { getRemoteData } from '../../utilities/fetch/getRemoteData.js' ;
1516import { ObservableData } from '../../utilities/ObservableData.js' ;
1617import { DetectorType , DATA_TAKING_DETECTOR_TYPES } from '../../domain/enums/DetectorTypes.js' ;
@@ -32,10 +33,10 @@ const getPhysicalDetectorsFromAllDetectors = (allDetectors) => allDetectors.filt
3233 * Return the QC detectors from a list of detectors
3334 *
3435 * @param {Detector[] } allDetectors the list of all detectors
35- * @return {Detector[] } physical detectors
36+ * @return {Detector[] } QC detectors
3637 */
3738const getQcDetectorsFromAllDetectors = ( allDetectors ) => allDetectors
38- . filter ( ( { type, name } ) => [ DetectorType . PHYSICAL , DetectorType . QC ] . includes ( type ) && ! DETECTORS_EXCLUDED_FROM_QC . includes ( name ) ) ;
39+ . filter ( ( { type, name } ) => [ DetectorType . PHYSICAL , DetectorType . QC_ONLY ] . includes ( type ) && ! DETECTORS_EXCLUDED_FROM_QC . includes ( name ) ) ;
3940
4041/**
4142 * Service class to fetch detectors from the backend
@@ -73,7 +74,14 @@ export class DetectorsProvider extends RemoteDataProvider {
7374 */
7475 async getRemoteData ( ) {
7576 const { data } = await getRemoteData ( '/api/detectors' ) ;
76- data . sort ( ( { name : name1 } , { name : name2 } ) => name1 . localeCompare ( name2 ) ) ;
77+ const typeToOrderingKey = ( type ) => switchCase ( type , {
78+ [ DetectorType . OTHER ] : 0 ,
79+ [ DetectorType . VIRTUAL ] : 1 ,
80+ [ DetectorType . PHYSICAL ] : 2 ,
81+ [ DetectorType . QC_ONLY ] : 3 ,
82+ } ) ;
83+ data . sort ( ( { name : name1 , type : type1 } , { name : name2 , type : type2 } ) =>
84+ - ( typeToOrderingKey ( type1 ) - typeToOrderingKey ( type2 ) ) * 10 + name1 . localeCompare ( name2 ) ) ;
7785 return data ;
7886 }
7987
@@ -142,3 +150,5 @@ export class DetectorsProvider extends RemoteDataProvider {
142150}
143151
144152export const detectorsProvider = new DetectorsProvider ( ) ;
153+
154+ window . d = detectorsProvider ;
0 commit comments