chore: remove duplicate and superseded files (#25308)
This commit is contained in:
parent
fa912917f7
commit
38471d1286
2 changed files with 0 additions and 105 deletions
|
|
@ -1,78 +0,0 @@
|
|||
const TEST_UNKNOWN = "unknown";
|
||||
const TEST_SUCCESS = "success";
|
||||
const TEST_FAILED = "failed";
|
||||
const TEST_RUNNING = "running";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
testState: TEST_UNKNOWN,
|
||||
testError: null,
|
||||
testResult: null,
|
||||
testTimeout: 15000, // 15s
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
testRunning() {
|
||||
return this.testState === TEST_RUNNING;
|
||||
},
|
||||
testSuccess() {
|
||||
return this.testState === TEST_SUCCESS;
|
||||
},
|
||||
testFailed() {
|
||||
return this.testState === TEST_FAILED;
|
||||
},
|
||||
testUnknown() {
|
||||
return this.testState === TEST_UNKNOWN;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
resetTest() {
|
||||
this.testState = TEST_UNKNOWN;
|
||||
this.testError = null;
|
||||
this.testResult = null;
|
||||
},
|
||||
|
||||
async test(testApi) {
|
||||
if (!this.$refs.form.reportValidity()) return false;
|
||||
this.testState = TEST_RUNNING;
|
||||
try {
|
||||
const res = await testApi();
|
||||
for (const [key, { error }] of Object.entries(res.data)) {
|
||||
if (error) {
|
||||
this.testState = TEST_FAILED;
|
||||
this.testResult = null;
|
||||
this.testError = `${key}: ${error}`;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
this.testResult = res.data;
|
||||
this.testError = null;
|
||||
this.testState = TEST_SUCCESS;
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
this.testState = TEST_FAILED;
|
||||
this.testResult = null;
|
||||
this.testError = e.response?.data?.error || e.message;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
handleCreateError(e) {
|
||||
this.handleError(e, "create failed");
|
||||
},
|
||||
handleUpdateError(e) {
|
||||
this.handleError(e, "update failed");
|
||||
},
|
||||
handleRemoveError(e) {
|
||||
this.handleError(e, "remove failed");
|
||||
},
|
||||
handleError(e, msg) {
|
||||
console.error(e);
|
||||
let message = msg;
|
||||
const { error } = e.response.data || {};
|
||||
if (error) message += `: ${error}`;
|
||||
alert(message);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
import settings from "./settings";
|
||||
|
||||
const KM = "km";
|
||||
const MILES = "mi";
|
||||
export const UNITS = [KM, MILES];
|
||||
|
||||
const MILES_FACTOR = 0.6213711922;
|
||||
|
||||
function isMiles() {
|
||||
return settings.unit === MILES;
|
||||
}
|
||||
|
||||
export function distanceValue(value) {
|
||||
return isMiles() ? value * MILES_FACTOR : value;
|
||||
}
|
||||
|
||||
export function distanceUnit() {
|
||||
return isMiles() ? "mi" : "km";
|
||||
}
|
||||
|
||||
export function getUnits() {
|
||||
return isMiles() ? MILES : KM;
|
||||
}
|
||||
|
||||
export function setUnits(value) {
|
||||
settings.unit = value;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue