fix save button

This commit is contained in:
Peter Clement 2021-07-20 12:30:11 +01:00
parent 30558ad3bd
commit 1c6d455094
1 changed files with 11 additions and 7 deletions

View File

@ -99,10 +99,10 @@
let googleSaveButtonDisabled let googleSaveButtonDisabled
let oidcSaveButtonDisabled let oidcSaveButtonDisabled
$: { $: {
isEqual(providers.google, originalGoogleDoc) isEqual(providers.google?.config, originalGoogleDoc?.config)
? (googleSaveButtonDisabled = true) ? (googleSaveButtonDisabled = true)
: (googleSaveButtonDisabled = false) : (googleSaveButtonDisabled = false)
isEqual(providers.oidc, originalOidcDoc) isEqual(providers.oidc?.config, originalOidcDoc?.config)
? (oidcSaveButtonDisabled = true) ? (oidcSaveButtonDisabled = true)
: (oidcSaveButtonDisabled = false) : (oidcSaveButtonDisabled = false)
} }
@ -147,7 +147,6 @@
// only if the user has provided an image, upload it. // only if the user has provided an image, upload it.
image && uploadLogo(image) image && uploadLogo(image)
let calls = [] let calls = []
let completed = []
docs.forEach(element => { docs.forEach(element => {
if (element.type === ConfigTypes.OIDC) { if (element.type === ConfigTypes.OIDC) {
//Add a UUID here so each config is distinguishable when it arrives at the login page. //Add a UUID here so each config is distinguishable when it arrives at the login page.
@ -161,7 +160,9 @@
) )
} else { } else {
calls.push(api.post(`/api/admin/configs`, element)) calls.push(api.post(`/api/admin/configs`, element))
completed.push(ConfigTypes.OIDC) // turn the save button grey when clicked
oidcSaveButtonDisabled = true
originalOidcDoc = cloneDeep(providers.oidc)
} }
} }
} }
@ -173,7 +174,8 @@
) )
} else { } else {
calls.push(api.post(`/api/admin/configs`, element)) calls.push(api.post(`/api/admin/configs`, element))
completed.push(ConfigTypes.Google) googleSaveButtonDisabled = true
originalGoogleDoc = cloneDeep(providers.google)
} }
} }
} }
@ -213,8 +215,9 @@
type: ConfigTypes.Google, type: ConfigTypes.Google,
config: { activated: true }, config: { activated: true },
} }
originalGoogleDoc = cloneDeep(googleDoc)
} else { } else {
originalGoogleDoc = googleDoc originalGoogleDoc = cloneDeep(googleDoc)
providers.google = googleDoc providers.google = googleDoc
} }
@ -237,8 +240,9 @@
} }
const oidcResponse = await api.get(`/api/admin/configs/${ConfigTypes.OIDC}`) const oidcResponse = await api.get(`/api/admin/configs/${ConfigTypes.OIDC}`)
const oidcDoc = await oidcResponse.json() const oidcDoc = await oidcResponse.json()
console.log("teaste")
if (!oidcDoc._id) { if (!oidcDoc._id) {
console.log("hi")
providers.oidc = { providers.oidc = {
type: ConfigTypes.OIDC, type: ConfigTypes.OIDC,
config: { configs: [{ activated: true }] }, config: { configs: [{ activated: true }] },