Merge CEC-394 Car update log (#82)

This commit is contained in:
John Wu
2021-08-26 15:03:45 -07:00
committed by GitHub
parent d1815e2ff9
commit 74eb2707a3
34 changed files with 3114 additions and 3583 deletions

View File

@@ -6,43 +6,7 @@ const updatesAPI = {
data.id++;
return data;
},
getPackages: async (search, token) => {
return {
data: [
{
id: 1,
package_name: "Test",
version: "1.0",
link: "http://cloudfront.com/download",
ecu_list: "ECU1 1.0.0,ECU2 1.0.2",
},
{
id: 2,
package_name: "Test",
version: "1.1",
link: "http://cloudfront.com/download",
ecu_list: "ECU1 1.0.1,ECU2 1.0.2",
},
{
id: 3,
package_name: "Test",
version: "1.2",
link: "http://cloudfront.com/download",
ecu_list: "ECU1 1.1.0,ECU2 1.1.2",
}
]
}
},
updatePackage: async (data, token) => {
return data;
},
deployPackage: async (data, token) => {
return data;
},
getCarUpdates: async (filter, token) => {
return { data: [] };
},

View File

@@ -1,4 +1,5 @@
import { fetchRespHandler } from "../utils/http"
import { logger } from "../services/monitoring";
const API_ENDPOINT = "https://grafana.fiskerdps.com/api/datasources/proxy/2"
@@ -9,7 +10,7 @@ const grafanaAPI = {
})
.then(fetchRespHandler)
.then(result => result.data[0].count)
.catch(error => console.log(error)),
.catch(error => logger.warn(error.stack)),
getSignalsCount: async () => fetch(`${API_ENDPOINT}/?query=SELECT%20count()%20as%20count%0AFROM%20default.vehicle_signal%20FORMAT%20JSON`, {
method: "GET",
@@ -17,7 +18,7 @@ const grafanaAPI = {
})
.then(fetchRespHandler)
.then(result => result.data[0].count)
.catch(error => console.log(error)),
.catch(error => logger.warn(error.stack)),
};
export default grafanaAPI;

View File

@@ -10,7 +10,7 @@ const manifestsAPI = {
.then(fetchRespHandler),
getManifests: async (search, token) => {
var u = addQueryParams(`${API_ENDPOINT}/manifests`, search);
const u = addQueryParams(`${API_ENDPOINT}/manifests`, search);
return fetch(u, {
method: "GET",
headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)),

View File

@@ -1,22 +1,9 @@
import { datadogRum } from '@datadog/browser-rum';
import { datadogLogs } from "@datadog/browser-logs";
const applicationId = '8ecd160c-ad5c-4e06-8d88-3a6b89833246';
const clientToken = 'pubeb25449bb91773fc993855c7378e375a';
const site = 'datadoghq.com';
const service = 'ota-portal';
datadogRum.init({
applicationId,
clientToken,
site,
service,
// Specify a version number to identify the deployed version of your application in Datadog
// version: '1.0.0',
sampleRate: 100,
trackInteractions: true
});
datadogLogs.init({
clientToken,
site,

View File

@@ -10,32 +10,26 @@ const updatesAPI = {
})
.then(fetchRespHandler),
deletePackage: async (package_id, token) => fetch(`${API_ENDPOINT}/update?id=${package_id}`, {
method: "DELETE",
headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)),
})
.then(fetchRespHandler),
getPackages: async (search, token) => {
var u = addQueryParams(`${API_ENDPOINT}/updates`, search);
getCarUpdateLog: async (query, token) => {
const u = addQueryParams(`${API_ENDPOINT}/carupdateslog`, query);
return fetch(u, {
method: "GET",
headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)),
})
.then(fetchRespHandler);
},
updatePackage: async (update, token) => fetch(`${API_ENDPOINT}/update`, {
method: "PUT",
headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)),
body: JSON.stringify(update),
})
.then(fetchRespHandler),
getCarUpdateProgress: async (carupdateids, token) => {
const u = `${API_ENDPOINT}/carupdatesstatuses?carupdateids=${carupdateids}`;
return fetch(u, {
method: "GET",
headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)),
})
.then(fetchRespHandler);
},
getCarUpdates: async (search, token) => {
var u = addQueryParams(`${API_ENDPOINT}/carupdates`, search);
const u = addQueryParams(`${API_ENDPOINT}/carupdates`, search);
return fetch(u, {
method: "GET",
headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)),
@@ -44,16 +38,7 @@ const updatesAPI = {
},
getVINUpdates: async (vin, token) => {
var u = addQueryParams(`${API_ENDPOINT}/carupdates`, { vin });
return fetch(u, {
method: "GET",
headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)),
})
.then(fetchRespHandler);
},
getCarUpdateProgress: async (carupdateids, token) => {
var u = `${API_ENDPOINT}/carupdatesstatuses?carupdateids=${carupdateids}`;
const u = addQueryParams(`${API_ENDPOINT}/carupdates`, { vin });
return fetch(u, {
method: "GET",
headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)),