Skip to content

Commit

Permalink
Add option to ignore case in organization and site names
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrho committed Oct 1, 2024
1 parent 16c8575 commit fdfba3c
Show file tree
Hide file tree
Showing 8 changed files with 650 additions and 204 deletions.
12 changes: 8 additions & 4 deletions jccm/src/Frontend/Components/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const Login = ({ isOpen, onClose }) => {
setIsUserLoggedIn,
setCurrentActiveThemeName,
getConsoleWindowWidth,
settings,
} = useStore();
const { showMessageBar } = useMessageBar();
const [cloudList, setCloudList] = useState([]);
Expand Down Expand Up @@ -95,6 +96,8 @@ export const Login = ({ isOpen, onClose }) => {

const [isGoogleSSOLogin, setIsGoogleSSOLogin] = useState(false);

const ignoreCaseInName = settings?.ignoreCaseInName || false;

const togglePasswordVisibility = () => {
setPasswordVisible(!passwordVisible);

Expand Down Expand Up @@ -247,7 +250,7 @@ export const Login = ({ isOpen, onClose }) => {
return { status: 'two_factor' };
} else {
// console.log('Login successful!');
// await eventBus.emit('cloud-inventory-refresh');
// await eventBus.emit('cloud-inventory-refresh', {force: true, ignoreCaseInName});

return {
status: 'success',
Expand Down Expand Up @@ -294,9 +297,10 @@ export const Login = ({ isOpen, onClose }) => {
Constants.getActiveThemeName(data?.user?.theme)
);

setTimeout(async () => {
await eventBus.emit('cloud-inventory-refresh');
}, 1000);
await eventBus.emit('cloud-inventory-refresh', {
force: true,
ignoreCaseInName,
});

onClose();
} else if (response.status === 'two_factor') {
Expand Down
Empty file.
10 changes: 4 additions & 6 deletions jccm/src/Frontend/Layout/Devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ export const getDeviceFacts = async (device, upperSerialNumber=false, bastionHos
}
};

export const adoptDevices = async (device, jsiTerm=false, deleteOutboundSSHTerm=false, bastionHost = {}) => {
export const adoptDevices = async (device, jsiTerm=false, deleteOutboundSSHTerm=false, bastionHost = {}, ignoreCaseInName = false) => {
const { address, port, username, password, organization, site } = device;
const response = await electronAPI.saAdoptDevice({ address, port, username, password, organization, site, jsiTerm, deleteOutboundSSHTerm, bastionHost });

// console.log('>>>>adoptDevices -> response: ', response);
const response = await electronAPI.saAdoptDevice({ address, port, username, password, organization, site, jsiTerm, deleteOutboundSSHTerm, bastionHost, ignoreCaseInName });

if (response?.adopt) {
return { status: true, result: response.reply };
Expand All @@ -26,8 +24,8 @@ export const adoptDevices = async (device, jsiTerm=false, deleteOutboundSSHTerm=
};

export const releaseDevices = async (deviceInfo) => {
const { organization, serialNumber} = deviceInfo;
const response = await electronAPI.saReleaseDevice({ organization, serial: serialNumber });
const { organization, serialNumber, ignoreCaseInName = false} = deviceInfo;
const response = await electronAPI.saReleaseDevice({ organization, serial: serialNumber, ignoreCaseInName });

if (response.release) {
return { status: true, result: response.reply };
Expand Down
41 changes: 41 additions & 0 deletions jccm/src/Frontend/Layout/GlobalSettings/GeneralCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ export const GeneralCard = () => {
saveFunction();
};

const saveIgnoreCase = (newIgnoreCase) => {
const saveFunction = async () => {
const newSettings = { ...settings, ignoreCase: newIgnoreCase };
setSettings(newSettings);
exportSettings(newSettings);
};
saveFunction();
};

const saveDeleteOutboundSSHTerm = (newDeleteOutboundSSHTerm) => {
const saveFunction = async () => {
const newSettings = {
Expand Down Expand Up @@ -93,6 +102,12 @@ export const GeneralCard = () => {
saveDeleteOutboundSSHTerm(checked);
};

const onChangeIgnoreCase = async (event) => {
const checked = event.currentTarget.checked;
saveIgnoreCase(checked);
};


return (
<div
style={{
Expand Down Expand Up @@ -161,6 +176,32 @@ export const GeneralCard = () => {
<Text>{settings.jsiTerm ? 'Enabled' : 'Disabled'}</Text>
</div>

<div
style={{
display: 'flex',
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'center',
gap: '5px',
width: '100%',
marginLeft: '10px',
}}
>
<Text>Ignore case of org name and site name: </Text>
<div
style={{
transform: 'scale(0.6)',
transformOrigin: 'right',
}}
>
<Switch
checked={settings.ignoreCase ? true : false}
onChange={onChangeIgnoreCase}
/>
</div>
<Text>{settings.ignoreCase ? 'Enabled' : 'Disabled'}</Text>
</div>

<div
style={{
display: 'flex',
Expand Down
Loading

0 comments on commit fdfba3c

Please sign in to comment.