');
+
+// Canvas for Elementary is available to an account admin, removing this one
+// // Features - group the ones that are Site Admin specific
+// // comment for "Canvas for Elementary"
+// var _site_admin_div = $('#account_settings > fieldset > legend:contains(Features)').parent('fieldset').find('div').slice(1,3).wrapAll('').parent();
+ // _site_admin_div.prepend(admin_shield_svg).css('background-color', sa_setting_hl_colour).prepend('
');
+
+ $('nav ul#section-tabs > li > a:contains(Domain Lookups)').css('align-items', 'center').css('display', 'flex').append(admin_shield_svg).parent().css('background-color', sa_setting_hl_colour);
+ $('nav ul#section-tabs > li > a:contains(SFTP User)').css('align-items', 'center').css('display', 'flex').append(admin_shield_svg).parent().css('background-color', sa_setting_hl_colour);
+
+ // reference to the Canvas Feature Option Summary
+ waitForKeyElements("#tab-features > div > span", append_feature_details);
+ // 20231006 - can't get the correct trigger for this to work correctly
+ // waitForKeyElements('#tab-features > div > table > tbody', append_feature_account_details);
+
+ // END - adding SiteAdmin user shield
+
+
+
+ // 20230824 - I think this code below no longer works - may remove it on a future release
//Changes to the 'Apps' tab - only if you click on my settings link, and did not navigate there natuarally
$('#account_settings_tabs > ul > li:contains("Apps"):first > a:first').click(function(a) {
a.preventDefault();
@@ -182,14 +267,14 @@ function myJQueryCode() {
$('#external_tools > div > div > div.Header > h2 > div > span.AddExternalToolButton > a.btn.btn-primary.add_tool_link.lm').click(function(b) {
b.preventDefault();
setTimeout(function() {
- $('body > div.ReactModalPortal > div > div > div > div > div.ReactModal__Header-Title > h4').after('');
+ $('body > div.ReactModalPortal > div > div > div > div > div.ReactModal__Header-Title > h4').after('');
var name = "Commons Setup";
var consumerKey = "1";
var sharedSecret = "c9b6c488-4750-48ce-897c-b919ff3cb0f1";
var configURL = "https://lor.instructure.com/api/account-setup/tool-config";
- $('#dg_button_canvasCommons').click(function(c) {
+ $('#cx_button_canvasCommons').click(function(c) {
c.preventDefault();
- $('#dg_button_canvasCommons').attr('disabled', 'disabled').css('cursor', 'default'); //Disable the button after click
+ $('#cx_button_canvasCommons').attr('disabled', 'disabled').css('cursor', 'default'); //Disable the button after click
//select URL
$('#configuration_type_selector-bs > ul > li:nth-child(2) > a').click();
@@ -209,37 +294,42 @@ function myJQueryCode() {
}
//Add Auth changer to users
- if (document.location.pathname.indexOf("/accounts/self/users/") >= 0 || document.location.pathname.indexOf("/users/") >=0 || document.location.pathname.indexOf("/accounts/1/users/") >= 0) {
+ if ( document.location.pathname.toLowerCase().match(re_users) !== null ) {
+ _cx_tools_on = true;
+
//figure out how many logins there are and create a select list for them
var optionCountHTML = '';
for (var i = 1; i <= $('fieldset#login_information > table.ic-Table > tbody > tr.login:not(:last)').length; i++) {
optionCountHTML += '';
}
- optionCountHTML = '';
+ optionCountHTML = '';
//Create the auth method select for Canvas, LDAP, SAML, Microsoft, and Google
- var changeAuthSelect = '';
- //Put in the option to the page for the auth method
- $('#name_and_email > table > tbody > tr:last').after('
' + changeAuthSelect + '
');
+ var changeAuthSelect = '';
+ var deleteAndGoButton = '';
+ var td_details = changeAuthSelect + optionCountHTML + deleteAndGoButton;
+
+ //Put in the option to the page for the auth method
+ $('#name_and_email > table > tbody > tr:last').after('
');
+
//put in the options dropdown
- $('#dg_changeAuth_tr').append('
' + optionCountHTML + '
');
- //add the 'Go' button
- $('#dg_changeAuthCount_td').after('
Delete old Method
');
+ $('#cx_changeAuth_tr').append('
' + td_details + '
');
+
//When you click the 'Go' button
- $('#dg_changeAuth_button').click(function(e) {
+ $('#cx_changeAuth_button').click(function(e) {
e.preventDefault();
//disable the options
- $('#dg_changeAuth_button,#dg_changeAuth,#dg_deleteOldAuthMethod,#dg_changeAuthCount').attr('disabled', 'disabled');
+ $('#cx_changeAuth_button,#cx_changeAuth,#cx_deleteOldAuthMethod,#cx_changeAuthCount').attr('disabled', 'disabled');
//replace the 'Go' button with the spinny wheel
- $('#dg_changeAuth_button').html('
');
+ $('#cx_changeAuth_button').html('
');
//check to see a proper value is selected
- if ($('#dg_changeAuth').val() === "null" || $('#dg_changeAuthCount').val() === "null") {
+ if ($('#cx_changeAuth').val() === "null" || $('#cx_changeAuthCount').val() === "null") {
alert('No Auth method or Number selected!');
return;
} else {
var currentUserID = ENV.USER_ID;
- var authMethodSelected = $('#dg_changeAuth').val();
- var authMethodNumber = $('#dg_changeAuthCount').val();
- var authDeleteOld = $('#dg_deleteOldAuthMethod:checked').length;
+ var authMethodSelected = $('#cx_changeAuth').val();
+ var authMethodNumber = $('#cx_changeAuthCount').val();
+ var authDeleteOld = $('#cx_deleteOldAuthMethod:checked').length;
var loginID = $('fieldset#login_information > table.ic-Table > tbody > tr.login:eq(' + (authMethodNumber - 1) + ') b.unique_id').text().trim();
var sisID = $('fieldset#login_information > table.ic-Table > tbody > tr.login:eq(' + (authMethodNumber - 1) + ') th[scope="row"] div:eq(0)').text().trim().split('SIS ID: ').join('');
@@ -284,34 +374,45 @@ function myJQueryCode() {
xhr.send(data);
}
});
- } else if (document.location.pathname.toLowerCase() === "/accounts/1/settings/configurations" || document.location.pathname.toLowerCase() === "/accounts/1/settings" || document.location.pathname.toLowerCase().indexOf("/accounts/self/") >=0 ) {
+ } else if ( document.location.pathname.toLowerCase().match(re_settings) !== null ) {
+ _cx_tools_on = true;
+
//token storage and update
- var tokenInputHTML = ' ';
+ var tokenInputHTML = ' ';
$('#right-side').prepend(tokenInputHTML);
- $('#dg_apiTokenButton').click(function(e) {
+ $('#cx_apiTokenButton').click(function(e) {
e.preventDefault();
- if (confirm("Update token with: " + $('#dg_apiToken').val())) {
- storeItem('token', $('#dg_apiToken').val());
+ if (confirm("Update token with: " + $('#cx_apiToken').val())) {
+ storeItem('token', $('#cx_apiToken').val());
location.reload();
}
return;
});
- } else if (document.location.pathname.toLowerCase() === "/dgtools") {
- //focus on the DG links page
+ } else if ( document.location.pathname.toLowerCase().match(re_auth_providers) !== null ) {
+ _cx_tools_on = true;
+
+ // new common identity box on the authentication page
+ // ic-Form-control with a child input tag with name attribute of "authentication_provider[instructure_identity_login_percentage]"
+ $('#application div.ic-Form-control > input[name="authentication_provider[instructure_identity_login_percentage]"]').parent().append(admin_shield_svg).css('background-color', sa_setting_hl_colour);
+
+ } else if (document.location.pathname.toLowerCase() === "/cxtools1") {
+ _cx_tools_on = true;
+
+ //focus on the CX Tools links page
$('li.ic-app-header__menu-list-item--active').attr('class', "menu-item ic-app-header__menu-list-item");
- $('li#dg_li_self').attr('class', "menu-item ic-app-header__menu-list-item ic-app-header__menu-list-item--active");
+ $('li#cx_li_self').attr('class', "menu-item ic-app-header__menu-list-item ic-app-header__menu-list-item--active");
- document.title = "DG - Update User SIS id from one to another";
- $('#main').html('
(once you have clicked this button and the developer key has been enabled, you will need to refer to Microsoft documentation step 5 onwards)
+
(once you have clicked this button and the developer key has been enabled, you will need to refer to Microsoft documentation - note: this may have been done already if Microsoft Teams classes has been already configured)
');
+
+ // When the user clicks "Create trust"
+ $('#cx_createTrust').click(function(e){
e.preventDefault();
updateConsoleLog('Start creating trust...');
//disbaled the button and fields
- $('#dg_createTrust, #dg_trustID, #dg_shard').attr('disabled','disabled');
+ $('#cx_createTrust, #cx_trustID, #cx_shard').attr('disabled','disabled');
//action the function to create the trust
- var trustID = $('#dg_trustID').val();
- var shardID = $('#dg_shard').val();
+ var trustID = $('#cx_trustID').val();
+ var shardID = $('#cx_shard').val();
createTrust(trustID,shardID);
return 0;
});
//List trusts attached to the Canvas
- $('#dg_ListTrust').click(function(e){
+ $('#cx_ListTrust').click(function(e){
e.preventDefault();
updateConsoleLog('Checking trusts...');
- $('#dg_ListTrust').attr('disabled','disabled');
+ $('#cx_ListTrust').attr('disabled','disabled');
listTrusts();
});
}
@@ -527,7 +822,7 @@ function myJQueryCode() {
//link to the IC support page within the Canvas help
$($('#global_nav_help_link').parent()).click(function() {
//check to see if the link has been made, as the canvas help only renders on the help link click!
- if ($('#dg_icSupportLink').length === 0) {
+ if ($('#cx_icSupportLink').length === 0) {
var buildIcLink = [];
var linkURL = "https://s3.amazonaws.com/SSL_Assets/APAC/ticketpage.html";
@@ -545,7 +840,7 @@ function myJQueryCode() {
$.ajax(settings).done(function(response) {
buildIcLink = {
- dgtools: true,
+ cxtools: true,
name: response.name,
currentURL: document.location.toString(),
DOMAIN_ROOT_ACCOUNT_ID: ENV.DOMAIN_ROOT_ACCOUNT_ID,
@@ -558,7 +853,7 @@ function myJQueryCode() {
//build the support link URI
linkURL = buildURI(buildIcLink, linkURL);
console.log(linkURL);
- $('#help_tray > ul:first > li:first').before('
');
});
}
return;
@@ -567,16 +862,40 @@ function myJQueryCode() {
//if within a course
if(document.location.pathname.toLowerCase().indexOf('/courses/') >= 0){
+ // Add button to take user back to courses list for root account
+ $('div.ic-app-nav-toggle-and-crumbs > div.right-of-crumbs').append(' View all courses');
+
+
if(document.location.pathname.toLowerCase() === "/courses/" + ENV.course_id){
+ _cx_tools_on = true;
+
//If on the homepage of the course
//Settings link above the options on RHS
- $('#course_show_secondary > div.course-options > a.btn.button-sidebar-wide.course-home-sub-navigation-lti:last').before(' Course Settings');
+ $('#course_show_secondary > div.course-options > a.btn.button-sidebar-wide.course-home-sub-navigation-lti:last').before(' Course Settings');
//Undelete option
- $('#course_show_secondary > div.course-options > a.btn.button-sidebar-wide.course-home-sub-navigation-lti:last').before(' Undelete Course Content');
+ $('#course_show_secondary > div.course-options > a.btn.button-sidebar-wide.course-home-sub-navigation-lti:last').before(' Undelete Course Content');
}
}
+ if ( document.location.pathname.match(re_perms) !== null ) {
+ _cx_tools_on = true;
+
+ // change each header to be no longer than 18 characters followed by an ellipses - but only call the function once the table has been loaded
+ waitForKeyElements("table.ic-permissions__table", fix_permission_header);
+ }
+
+ // Turn on ribbon if a page has modification through the CX Tools
+ if (_cx_tools_on == true) {
+ // put the banner div after the body
+ $('body').prepend('
CX Tools ON
');
+ }
+
+ // Display a warning so that users know to configure their access token
+ if (token === null || (typeof token === "string" && token.length === 0)) {
+ $('body').prepend('
NO ACCESS TOKEN CONFIGURED
');
+ }
+
});
// ELSE if on the IC request page
} else if (document.location.hostname === "s3.amazonaws.com") {
@@ -611,8 +930,8 @@ function myJQueryCode() {
var icSupportObject = getUrlVars();
- //if done via DG tools
- if (icSupportObject.dgtools == "true") {
+ //if done via CX Tools
+ if (icSupportObject.cxtools == "true") {
console.log('gg');
//fill out the title field
$('#school_name').val(icSupportObject.name);
@@ -640,7 +959,7 @@ function myJQueryCode() {
}, 5000
);
}
- }else if(document.location.pathname.toLowerCase() === "/dgtools3") {
+ }else if(document.location.pathname.toLowerCase() === "/cxtools3") {
//Once on the create users page
var urlVars = getUrlVars();
if(urlVars.sfUsers == "true"){
@@ -648,11 +967,11 @@ function myJQueryCode() {
$.each(splitUsers,function(){
var thisUser = this.split('~');
if(thisUser[0]!="undefined" && thisUser[0]!="" && thisUser[1]!="undefined" && thisUser[1]!="" && thisUser[2]!="undefined" && thisUser[2]!=""){
- $('#dg_first_name').val($('#dg_first_name').val() + thisUser[0] + '\n');
- $('#dg_last_name').val($('#dg_last_name').val() + thisUser[1] + '\n');
- $('#dg_user_id').val($('#dg_user_id').val() + thisUser[2] + '\n');
- $('#dg_login_id').val($('#dg_login_id').val() + thisUser[2] + '\n');
- $('#dg_email').val($('#dg_email').val() + thisUser[2] + '\n');
+ $('#cx_first_name').val($('#cx_first_name').val() + thisUser[0] + '\n');
+ $('#cx_last_name').val($('#cx_last_name').val() + thisUser[1] + '\n');
+ $('#cx_user_id').val($('#cx_user_id').val() + thisUser[2] + '\n');
+ $('#cx_login_id').val($('#cx_login_id').val() + thisUser[2] + '\n');
+ $('#cx_email').val($('#cx_email').val() + thisUser[2] + '\n');
}
});
}
@@ -662,10 +981,10 @@ function myJQueryCode() {
// ============== My functions =====================
//get all the LTIs installed
- function listLtiID(){
+ function listLtiID(canvas_account_id){
var form = new FormData();
var settings = {
- "url": "/api/v1/accounts/1/external_tools?per_page=100",
+ "url": "/api/v1/accounts/" + canvas_account_id + "/external_tools?per_page=100",
"method": "GET",
"timeout": 0,
"headers": {
@@ -679,21 +998,21 @@ function myJQueryCode() {
$.ajax(settings).done(function (response) {
console.log(response);
- apiReply = JSON.parse(response);
+ var apiReply = JSON.parse(response);
if(apiReply.length > 0){
$.each(apiReply,function(index,element){
console.log(element);
- $("td.external_tool.e-tool-table-data[title='"+ element.name + "']").append(' - LTI ID #' + element.id);
+ $("td.external_tool.e-tool-table-data[title='"+ element.name.replace(/[']/g, '\\$&') + "']").append(' - LTI ID #' + element.id);
});
//add the hide button too
- var buildHideButton = '