2020-06-03 17:46:20 +00:00
|
|
|
export default () => key => {
|
|
|
|
if (key.startsWith('Status:')) {
|
|
|
|
return function(serviceA, serviceB) {
|
|
|
|
const [, dir] = key.split(':');
|
|
|
|
let a, b;
|
|
|
|
if (dir === 'asc') {
|
|
|
|
b = serviceA;
|
|
|
|
a = serviceB;
|
|
|
|
} else {
|
|
|
|
a = serviceA;
|
|
|
|
b = serviceB;
|
|
|
|
}
|
|
|
|
switch (true) {
|
2020-08-21 07:53:22 +00:00
|
|
|
case a.MeshChecksCritical > b.MeshChecksCritical:
|
2020-06-03 17:46:20 +00:00
|
|
|
return 1;
|
2020-08-21 07:53:22 +00:00
|
|
|
case a.MeshChecksCritical < b.MeshChecksCritical:
|
2020-06-03 17:46:20 +00:00
|
|
|
return -1;
|
|
|
|
default:
|
|
|
|
switch (true) {
|
2020-08-21 07:53:22 +00:00
|
|
|
case a.MeshChecksWarning > b.MeshChecksWarning:
|
2020-06-03 17:46:20 +00:00
|
|
|
return 1;
|
2020-08-21 07:53:22 +00:00
|
|
|
case a.MeshChecksWarning < b.MeshChecksWarning:
|
2020-06-03 17:46:20 +00:00
|
|
|
return -1;
|
|
|
|
default:
|
|
|
|
switch (true) {
|
2020-08-21 07:53:22 +00:00
|
|
|
case a.MeshChecksPassing < b.MeshChecksPassing:
|
2020-06-03 17:46:20 +00:00
|
|
|
return 1;
|
2020-08-21 07:53:22 +00:00
|
|
|
case a.MeshChecksPassing > b.MeshChecksPassing:
|
2020-06-03 17:46:20 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return key;
|
|
|
|
};
|