░▒▓████████████████████████████████▓▒░ ░▒▓█ ▓▒░ ░▒▓█ ~ S W A M P ~ ▓▒░ ░▒▓█ ▓▒░ ░▒▓████████████████████████████████▓▒░
pplmvsvm
LOCATION:
/var/www/canvas/ui/features/gradebook_uploads/jquery
☗ ROOT
↻ REFRESH
✎ CARVE FLESH
EDITING: wait_for_processing.js
/* * Copyright (C) 2015 - present Instructure, Inc. * * This file is part of Canvas. * * Canvas is free software: you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License as published by the Free * Software Foundation, version 3 of the License. * * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see <http://www.gnu.org/licenses/>. */ import $ from 'jquery' import {useScope as useI18nScope} from '@canvas/i18n' import '@canvas/jquery/jquery.ajaxJSON' import 'spin.js/jquery.spin' const I18n = useI18nScope('gradebook_uploads') async function sleep(milliseconds) { return new Promise(resolve => { setTimeout(resolve, milliseconds) }) } /** * The sleep_time parameter is included here to speed up testing. * There is an issue with jest.useFakeTimers and native Promises * that prevents this from being tested efficiently otherwise. * https://github.com/facebook/jest/issues/7151 */ export async function waitForProcessing(progress, sleep_time = 2000) { const spinner = $('#spinner').spin() while (!['completed', 'failed'].includes(progress.workflow_state)) { /* eslint-disable no-await-in-loop */ await sleep(sleep_time) progress = await $.ajaxJSON(`/api/v1/progress/${progress.id}`, 'GET').promise() /* eslint-enable no-await-in-loop */ } if (progress.workflow_state === 'completed') { const uploadedGradebook = await $.ajaxJSON(ENV.uploaded_gradebook_data_path, 'GET').promise() spinner.hide() return uploadedGradebook } else if (progress.message?.includes('Invalid header row')) { throw new Error(I18n.t('The CSV header row is invalid.')) } else { throw new Error( I18n.t('An unknown error has occurred. Verify the CSV file or try again later.') ) } }
CANCEL
Name
Type
Size
Modified
Actions
↩ ..
DIR
—
—
📁 __tests__/
DIR
—
2023-09-24 03:36
📄 index.js
JS
18.6 KB
2023-09-24 03:39
EDIT
📄 process_gradebook_upload.js
JS
8.9 KB
2023-09-24 03:39
EDIT
📄 wait_for_processing.js
JS
2 KB
2023-09-24 03:36
EDIT