fix(striker-ui-api): complete file upload endpoint

main
Tsu-ba-me 3 years ago
parent c767daa9c4
commit b2b347fc72
  1. 8
      striker-ui-api/lib/accessDB.js
  2. 21
      striker-ui-api/routes/files.js

@ -60,12 +60,11 @@ const accessDB = {
jobData, jobData,
jobTitle, jobTitle,
jobDescription, jobDescription,
{ jobHostUUID } = { jobHostUUID: 'all' }, { jobHostUUID } = { jobHostUUID: undefined },
) => { ) => {
const subParams = { const subParams = {
file: __filename, file: __filename,
line: 0, line: 0,
job_host_uuid: jobHostUUID,
job_command: SERVER_PATHS.usr.sbin['anvil-sync-shared'].self, job_command: SERVER_PATHS.usr.sbin['anvil-sync-shared'].self,
job_data: jobData, job_data: jobData,
job_name: `storage::${jobName}`, job_name: `storage::${jobName}`,
@ -73,6 +72,11 @@ const accessDB = {
job_description: `job_${jobDescription}`, job_description: `job_${jobDescription}`,
job_progress: 0, job_progress: 0,
}; };
if (jobHostUUID) {
subParams.job_host_uuid = jobHostUUID;
}
console.log(JSON.stringify(subParams, null, 2)); console.log(JSON.stringify(subParams, null, 2));
return execDatabaseModuleSubroutine('insert_or_update_jobs', subParams) return execDatabaseModuleSubroutine('insert_or_update_jobs', subParams)

@ -30,7 +30,9 @@ router
WHERE file_uuid = '${fileUUID}';`, WHERE file_uuid = '${fileUUID}';`,
).stdout; ).stdout;
dbJobAnvilSyncShared('purge', `file_uuid=${fileUUID}`, '0136', '0137'); dbJobAnvilSyncShared('purge', `file_uuid=${fileUUID}`, '0136', '0137', {
jobHostUUID: 'all',
});
} }
response.status(204).send(); response.status(204).send();
@ -41,17 +43,22 @@ router
console.log('Receiving shared file.'); console.log('Receiving shared file.');
if (file) { if (file) {
console.log(`file:`); console.log(`file: ${JSON.stringify(file, null, 2)}`);
console.dir(file); console.log(`body: ${JSON.stringify(body, null, 2)}`);
console.log('body:'); dbJobAnvilSyncShared(
console.dir(body); 'move_incoming',
`file=${file.path}`,
'0132',
'0133',
);
response.status(200).send(); response.status(200).send();
} }
}) })
.put('/:fileUUID', (request, response) => { .put('/:fileUUID', (request, response) => {
console.log('Begin edit single file.'); console.log('Begin edit single file.');
console.dir(request.body);
const { fileUUID } = request.params; const { fileUUID } = request.params;
const { fileName, fileLocations, fileType } = request.body; const { fileName, fileLocations, fileType } = request.body;
@ -79,6 +86,7 @@ router
`file_uuid=${fileUUID}\nold_name=${oldFileName}\nnew_name=${fileName}`, `file_uuid=${fileUUID}\nold_name=${oldFileName}\nnew_name=${fileName}`,
'0138', '0138',
'0139', '0139',
{ jobHostUUID: 'all' },
), ),
); );
} }
@ -98,6 +106,7 @@ router
`file_uuid=${fileUUID}`, `file_uuid=${fileUUID}`,
'0143', '0143',
'0144', '0144',
{ jobHostUUID: 'all' },
), ),
); );
} }

Loading…
Cancel
Save