Skip to content

Commit

Permalink
Merge pull request #961 from panbed/lambda
Browse files Browse the repository at this point in the history
Updating equal access branch with lambda functions
  • Loading branch information
dmols authored Sep 30, 2024
2 parents be77335 + 24e796a commit 7c828d5
Show file tree
Hide file tree
Showing 38 changed files with 1,183 additions and 318 deletions.
14 changes: 14 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ ADMIN_LTI_NAME="UDOIT 3 Admin"
USE_DEVELOPMENT_AUTH="no"
VERSION_NUMBER="3.3.1"

# Define which accessibility checker to use
# Available options: "phpally", "equalaccess_local", "equalaccess_lambda"
ACCESSIBILITY_CHECKER="phpally"

# NOTE: When using a lambda function with equal access,
# you need to define the following in a separate .env.local:
# AWS_ACCESS_KEY_ID=<access_key_id>
# AWS_SECRET_ACCESS_KEY=<secret_access_key>
# AWS_REGION=<region (e.g. us-east-1)>
# AWS_SERVICE=<service (e.g. execute-api)>
# AWS_HOST=abcdefghi.execute-api.us-east-1.amazonaws.com
# AWS_ENDPOINT=https://abcdefghi.execute-api.us-east-1.amazonaws.com/endpoint/generate-accessibility-report


###> symfony/messenger ###
MESSENGER_TRANSPORT_DSN=doctrine://default
Expand All @@ -68,6 +81,7 @@ PHPALLY_SUGGESTION_RULES="
RedirectedLink,
EmbedTagDetected,
IframeNotHandled,
TableNotEmpty
"
# Rules that are easiest to tackle when using UDOIT. Comma-separated list of rule IDs.
EASY_FIX_RULES="
Expand Down
3 changes: 1 addition & 2 deletions assets/js/Components/Admin/UsersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ class UsersPage extends React.Component {
.then((responseStr) => responseStr.json())
.then((response) => {
let users = this.state.users
console.log('response', response);
if (response && response.id) {
const ind = users.findIndex((el) => { el.id === response.id })
users[ind] = response
Expand All @@ -183,4 +182,4 @@ class UsersPage extends React.Component {
}
}

export default UsersPage;
export default UsersPage;
32 changes: 27 additions & 5 deletions assets/js/Components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class App extends React.Component {
this.handleIssueSave = this.handleIssueSave.bind(this)
this.handleFileSave = this.handleFileSave.bind(this)
this.handleCourseRescan = this.handleCourseRescan.bind(this)
this.handleFullCourseRescan = this.handleFullCourseRescan.bind(this)
this.handleNewReport = this.handleNewReport.bind(this)
this.resizeFrame = this.resizeFrame.bind(this)
}
Expand All @@ -53,6 +54,7 @@ class App extends React.Component {
navigation={this.state.navigation}
handleNavigation={this.handleNavigation}
handleCourseRescan={this.handleCourseRescan}
handleFullCourseRescan={this.handleFullCourseRescan}
handleModal={this.handleModal} />

{(('welcome' !== this.state.navigation) && ('summary' !== this.state.navigation)) &&
Expand Down Expand Up @@ -148,6 +150,11 @@ class App extends React.Component {
return api.scanCourse(this.settings.course.id)
}

fullRescan() {
let api = new Api(this.settings)
return api.fullRescan(this.settings.course.id)
}

disableReview = () => {
return this.state.syncComplete && !this.state.disableReview
}
Expand All @@ -162,6 +169,16 @@ class App extends React.Component {
this.forceUpdate()
}

handleFullCourseRescan() {
if (this.state.hasNewReport) {
this.setState({ hasNewReport: false, syncComplete: false })
this.fullRescan()
.then((response) => response.json())
.then(this.handleNewReport)
}
this.forceUpdate()
}

handleNewReport(data) {
let report = this.state.report
let hasNewReport = this.state.hasNewReport
Expand All @@ -184,7 +201,6 @@ class App extends React.Component {
});
}
if (data.data && data.data.id) {
console.log('new data', data.data)
report = data.data
hasNewReport = true
}
Expand Down Expand Up @@ -217,14 +233,20 @@ class App extends React.Component {
}

handleIssueSave(newIssue, newReport) {
let { report } = this.state
report = {...report, ...newReport}
const oldReport = this.state.report;

const report = { ...oldReport, ...newReport };

if (report && Array.isArray(report.issues)) {
report.issues = report.issues.map(issue => (issue.id == newIssue.id) ? newIssue : issue)
// Combine backend issues with frontend issue state
report.issues = report.issues.map((issue) => {
if (issue.id === newIssue.id) return newIssue;
const oldIssue = oldReport.issues.find((oldReportIssue) => oldReportIssue.id === issue.id);
return oldIssue !== undefined ? { ...oldIssue, ...issue } : issue;
});
}

this.setState({ report })
this.setState({ report });
}

handleFileSave(newFile, newReport) {
Expand Down
6 changes: 5 additions & 1 deletion assets/js/Components/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ export const issueRuleIds = [
"RedirectedLink",
"TableDataShouldHaveTableHeader",
"TableHeaderShouldHaveScope",
"TableNotEmpty",
"VideoCaptionsMatchCourseLanguage",
"VideoEmbedCheck",
"VideoProvidesCaptions",
"VideosEmbeddedOrLinkedNeedCaptions",
"VideosHaveAutoGeneratedCaptions"
"VideosHaveAutoGeneratedCaptions",

"img_alt_misuse",
"text_contrast_sufficient",
]
21 changes: 9 additions & 12 deletions assets/js/Components/ContentPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,6 @@ class ContentPage extends React.Component {
}
}

static getDerivedStateFromProps(props, state) {
const stateActiveIssue = state.activeIssue
const propsActiveIssue = stateActiveIssue && props.report.issues[stateActiveIssue.id]
if(propsActiveIssue && propsActiveIssue.status !== stateActiveIssue.status) {
return {
activeIssue: propsActiveIssue
}
}
return null
}

handleSearchTerm = (e, val) => {
this.setState({searchTerm: val, filteredIssues: [], tableSettings: Object.assign({}, this.state.tableSettings, {pageNum: 0})});
}
Expand All @@ -102,9 +91,17 @@ class ContentPage extends React.Component {
}

handleCloseButton = () => {
const newReport = { ...this.props.report };
newReport.issues = newReport.issues.map((issue) => {
issue.recentlyResolved = false;
issue.recentlyUpdated = false;
return issue;
});

this.setState({
report: newReport,
modalOpen: false
})
});
}

handleTrayToggle = (e, val) => {
Expand Down
53 changes: 51 additions & 2 deletions assets/js/Components/FilesModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class FilesModal extends React.Component {
this.handleDropAccept = this.handleDropAccept.bind(this)
this.handleDropReject = this.handleDropReject.bind(this)
this.handleFilePost = this.handleFilePost.bind(this)
this.setAcceptType = this.setAcceptType.bind(this)
}

componentDidUpdate(prevProps, prevState) {
Expand All @@ -59,6 +60,46 @@ class FilesModal extends React.Component {
return -1;
}

setAcceptType(file) {
let accept = []

switch(file.fileType) {
case "doc":
accept = ["doc", "docx"]
break

case "ppt":
accept = ["ppt", "pptx"]
break

case "xls":
accept = ["xls", "xlsx"]
break

default:
accept = file.fileType
break
}

let extension = file.fileName.slice(-4)

switch(extension) {
case "xlsx":
accept = "xlsx"
break

case "pptx":
accept = "pptx"
break

case "docx":
accept = "docx"
break
}

return accept
}

// Handler for the previous and next buttons on the modal
// Will wrap around if the index goes out of bounds
handleFileChange(newIndex) {
Expand All @@ -80,7 +121,8 @@ class FilesModal extends React.Component {
}

render() {
const { activeFile } = this.props
let { activeFile } = this.props
activeFile.acceptType = this.setAcceptType(activeFile)
let activeIndex = this.findActiveIndex()

return (
Expand Down Expand Up @@ -121,7 +163,7 @@ class FilesModal extends React.Component {
<Text display="block" weight="bold">{this.props.t('label.replace')}</Text>
<Text as="p">{this.props.t('label.replace.desc')}</Text>
<FileDrop
accept={activeFile.fileType}
accept={activeFile.acceptType}
onDropAccepted={this.handleDropAccept}
onDropRejected={this.handleDropReject}
renderLabel={
Expand Down Expand Up @@ -207,6 +249,13 @@ class FilesModal extends React.Component {
return
}

if(file.size > 1024 * 1024 * 10) {
this.addMessage({severity: 'error', message: this.props.t('msg.file.replace.file_size'), timeout: 5000})
this.setState({ replaceFileObj: null })
this.forceUpdate()
return
}

this.setState({ replaceFileObj: file })
}

Expand Down
2 changes: 1 addition & 1 deletion assets/js/Components/FilesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,4 @@ class FilesPage extends React.Component {
}
}

export default FilesPage;
export default FilesPage;
6 changes: 2 additions & 4 deletions assets/js/Components/Forms/HeadingEmptyForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,15 @@ export default class HeadingEmptyForm extends React.Component {
if(!this.state.deleteHeader) {
this.checkTextNotEmpty()
}


if (this.formErrors.length > 0) {
this.setState({ textInputErrors: this.formErrors })
}
}

else {
this.setState({ textInputErrors: []})
let issue = this.props.activeIssue
issue.newHtml = this.processHtml()
console.log(issue.newHtml)
this.props.handleIssueSave(issue)
}
}
Expand Down
1 change: 0 additions & 1 deletion assets/js/Components/Forms/TableHeaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export default class TableHeaders extends React.Component {
}

handleSubmit() {
console.log('activeIssue', this.props.activeIssue)
let issue = this.props.activeIssue
issue.newHtml = this.fixHeaders()
this.props.handleIssueSave(issue)
Expand Down
1 change: 1 addition & 0 deletions assets/js/Components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Header extends React.Component {
{/* <Menu.Item onClick={() => this.handleMoreNav('settings')}>{this.props.t('menu.settings')}</Menu.Item> */}
<Menu.Separator />
<Menu.Item onClick={this.props.handleCourseRescan}>{this.props.t('menu.scan_course')}</Menu.Item>
<Menu.Item onClick={this.props.handleFullCourseRescan}>{this.props.t('menu.full_rescan')}</Menu.Item>
<Menu.Separator />
<Menu.Item href={pdfUrl}>{this.props.t('menu.download_pdf')}</Menu.Item>
</Menu>
Expand Down
16 changes: 16 additions & 0 deletions assets/js/Services/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class Api {
adminCourses: '/api/admin/courses/account/{account}/term/{term}',
scanContent: '/api/sync/content/{contentItem}',
scanCourse: '/api/sync/{course}',
fullRescan: '/api/sync/rescan/{course}',
scanIssue: '/api/issues/{issue}/scan',
adminReport: '/api/admin/courses/{course}/reports/latest',
adminReportHistory: '/api/admin/reports/account/{account}/term/{term}',
Expand Down Expand Up @@ -233,6 +234,21 @@ export default class Api {
})
}

fullRescan(courseId)
{
const authToken = this.getAuthToken()
let url = `${this.apiUrl}${this.endpoints.fullRescan}`
url = url.replace('{course}', courseId)

return fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-AUTH-TOKEN': authToken,
},
})
}

scanContent(contentId)
{
const authToken = this.getAuthToken()
Expand Down
2 changes: 0 additions & 2 deletions assets/js/Services/Html.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ export function setInnerText(element, newText) {
const children = element.childNodes
let textNodeFound = false

console.log(children)

children.forEach(node => {
if(node.nodeType === Node.TEXT_NODE) {
if(textNodeFound != true) {
Expand Down
3 changes: 3 additions & 0 deletions assets/js/Services/Ufixit.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ const UfixitForms = {
VideoCaptionsMatchCourseLanguage: Video,
VideosEmbeddedOrLinkedNeedCaptions: Video,
VideosHaveAutoGeneratedCaptions: Video,

img_alt_misuse: AltText,
text_contrast_sufficient: ContrastForm,
}

export function returnIssueForm(activeIssue) {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/getInitialData.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function getInitialData() {
data = JSON.parse(settingsElement.textContent)

if (Object.keys(data).length > 0) {
console.log('data', data)
console.log('Data was found and loaded!')
} else {
console.error('No data loaded!')
}
Expand Down
3 changes: 2 additions & 1 deletion build/nginx/deploy.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ server {

rewrite ^/udoit3/(.*)$ /$1 break;
try_files $uri @symfonyFront;
client_max_body_size 10M;
}

set $symfonyRoot /var/www/html/public;
Expand All @@ -29,4 +30,4 @@ server {
}
error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;
}
}
3 changes: 2 additions & 1 deletion build/nginx/local.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ server {

rewrite ^/udoit3/(.*)$ /$1 break;
try_files $uri @symfonyFront;
client_max_body_size 10M;
}

set $symfonyRoot /var/www/html/public;
Expand All @@ -29,4 +30,4 @@ server {
}
error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;
}
}
2 changes: 2 additions & 0 deletions build/nginx/php-custom.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
max_execution_time = 180
memory_limit = 800M
upload_max_filesize = 10M
post_max_size = 10M
Loading

0 comments on commit 7c828d5

Please sign in to comment.