Skip to content

Commit

Permalink
Improve ux for when gdal hasn't finished loading
Browse files Browse the repository at this point in the history
  • Loading branch information
mthh committed Aug 23, 2024
1 parent 34bd5c6 commit a6788e6
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/AppPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import ImportWindow from './components/ImportWindow.tsx';
import InfoFeatureBox from './components/InfoFeatureBox.tsx';
import FunctionalitySelection from './components/Modals/FunctionalitySelection.tsx';
import TableFunctionalitySelection from './components/Modals/TableFunctionalitySelection.tsx';
import { setGdalLoaded } from './components/LeftMenu/gdalLoadingStatus';

// Stores
import { classificationPanelStore } from './store/ClassificationPanelStore';
Expand Down Expand Up @@ -398,6 +399,7 @@ const AppPage: () => JSX.Element = () => {
loadGdal().then((gdal) => {
// @ts-expect-error - we should fix the type of globalThis.gdal
globalThis.gdal = gdal;
setGdalLoaded(true);
});

// Add event listener to the window to handle resize events
Expand Down
5 changes: 4 additions & 1 deletion src/components/LeftMenu/ImportSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { setModalStore } from '../../store/ModalStore';

// Subcomponents
import ExampleDatasetModal from '../Modals/ExampleDatasetModal.tsx';
import { gdalLoaded } from './gdalLoadingStatus';

// Styles
import '../../styles/LeftMenu.css';
Expand All @@ -25,8 +26,11 @@ export default function ImportSection(): JSX.Element {
'border-bottom-left-radius': '0',
'border-bottom-right-radius': '0',
'border-bottom-width': '0',
cursor: gdalLoaded() ? 'pointer' : 'not-allowed',
}}
onClick={() => { setFileDropStore({ show: true }); }}
disabled={!gdalLoaded()}
title={gdalLoaded() ? '' : LL().ImportSection.GdalNotLoaded()}
>
{ LL().ImportSection.OpenImportWindow() }
</button>
Expand All @@ -50,7 +54,6 @@ export default function ImportSection(): JSX.Element {
cancelButton: LL().DatasetCatalog.cancelButton(),
});
}}
disabled={false}
>
{ LL().ImportSection.ExampleDatasets() }
</button>
Expand Down
8 changes: 8 additions & 0 deletions src/components/LeftMenu/gdalLoadingStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createSignal } from 'solid-js';

const [
gdalLoaded,
setGdalLoaded,
] = createSignal<boolean>(false);

export { gdalLoaded, setGdalLoaded };
1 change: 1 addition & 0 deletions src/i18n/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ const en = {
ImportSection: {
OpenImportWindow: 'Open data import window...',
ExampleDatasets: 'Browse example datasets...',
GdalNotLoaded: 'The import module isn\'t loaded yet. Please wait a few seconds...',
},
MapConfiguration: {
Dimensions: 'Dimensions',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/fr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ const fr = {
ImportSection: {
OpenImportWindow: 'Ouvrir la fenêtre d\'import des données...',
ExampleDatasets: 'Explorer les jeux de données d\'exemple...',
GdalNotLoaded: 'Le module d\'import n\'a pas fini de charger. Veuillez patienter quelques instants...',
},
MapConfiguration: {
Dimensions: 'Dimensions',
Expand Down
8 changes: 8 additions & 0 deletions src/i18n/i18n-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,10 @@ type RootTranslation = {
* B​r​o​w​s​e​ ​e​x​a​m​p​l​e​ ​d​a​t​a​s​e​t​s​.​.​.
*/
ExampleDatasets: string
/**
* T​h​e​ ​i​m​p​o​r​t​ ​m​o​d​u​l​e​ ​i​s​n​'​t​ ​l​o​a​d​e​d​ ​y​e​t​.​ ​P​l​e​a​s​e​ ​w​a​i​t​ ​a​ ​f​e​w​ ​s​e​c​o​n​d​s​.​.​.
*/
GdalNotLoaded: string
}
MapConfiguration: {
/**
Expand Down Expand Up @@ -5379,6 +5383,10 @@ export type TranslationFunctions = {
* Browse example datasets...
*/
ExampleDatasets: () => LocalizedString
/**
* The import module isn't loaded yet. Please wait a few seconds...
*/
GdalNotLoaded: () => LocalizedString
}
MapConfiguration: {
/**
Expand Down
4 changes: 4 additions & 0 deletions src/styles/Main.css
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ button.unstyled {
padding: unset;
}

.button.is-primary[disabled], fieldset[disabled] .button.is-primary {
background-color: unset !important;
}

/* Somehow large outline to make visible which button is focused */
button.button:focus {
/* -webkit-focus-ring-color auto thin; */
Expand Down

0 comments on commit a6788e6

Please sign in to comment.